*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --text: #111827;
  --text-sub: #6b7280;
  --border: #e5e7eb;
  --bg: #f9fafb;
  --white: #ffffff;
  --radius: 14px;
  --shadow: 0 4px 24px rgba(0,0,0,0.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.page { display: none; }
.page.active { display: flex; flex-direction: column; min-height: 100vh; }

/* ── 顶部导航栏（所有页面通用） ── */
.top-nav {
  position: fixed;
  top: 18px;
  right: 22px;
  z-index: 900;
  pointer-events: none;   /* 让链接区域之外不拦截点击 */
}
.top-nav-right {
  display: flex;
  align-items: center;
  gap: 18px;
  pointer-events: auto;
}
.top-nav-link {
  color: var(--text-sub);
  text-decoration: none;
  font-size: .95rem;
  font-weight: 600;
  letter-spacing: .5px;
  padding: 4px 2px;
  position: relative;
  transition: color .18s ease, transform .15s ease;
}
.top-nav-link:hover { color: var(--primary); }
.top-nav-link.active { color: var(--primary); }
.top-nav-lang { opacity: .85; }
.top-nav-lang:hover { opacity: 1; }

/* hero 页面（蓝色背景）：导航文字反白 */
body.on-hero .top-nav-link { color: rgba(255, 255, 255, .92); }
body.on-hero .top-nav-link:hover { color: #ffffff; }
body.on-hero .top-nav-link.active { color: #ffffff; }

/* ── Hero ── */
.hero {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; padding: 48px 24px;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 55%, #0ea5e9 100%);
  color: white; min-height: 100vh;
}
.hero-icon { font-size: 80px; margin-bottom: 20px; animation: bounce 2s infinite; }
@keyframes bounce { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-14px)} }
.hero h1 { font-size: clamp(2rem,6vw,3.5rem); font-weight: 800; letter-spacing: -1px; margin-bottom: 14px; }
.hero-sub { font-size: clamp(1rem,3vw,1.2rem); opacity: .85; margin-bottom: 44px; max-width: 420px; }

/* ── Buttons ── */
.btn-primary {
  background: white; color: var(--primary);
  font-size: 1.05rem; font-weight: 700;
  padding: 14px 40px; border: none; border-radius: 50px;
  cursor: pointer; box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  transition: transform .15s, box-shadow .15s;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 12px 32px rgba(0,0,0,0.25); }

.btn-next {
  background: var(--primary); color: white;
  font-size: 1rem; font-weight: 700;
  padding: 13px 32px; border: none; border-radius: 50px;
  cursor: pointer; transition: background .15s, transform .1s;
  box-shadow: 0 4px 16px rgba(37,99,235,0.3);
}
.btn-next:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-next:active { transform: translateY(0); }

.btn-secondary {
  background: var(--white); color: var(--text-sub);
  font-size: 1rem; font-weight: 600;
  padding: 13px 24px; border: 1.5px solid var(--border); border-radius: 50px;
  cursor: pointer; transition: background .15s;
}
.btn-secondary:hover { background: var(--bg); }

.btn-back {
  background: none; border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 16px; font-size: .9rem; cursor: pointer; color: var(--text-sub);
  margin-bottom: 20px; transition: background .15s;
}
.btn-back:hover { background: var(--border); }

.btn-add {
  background: var(--primary-light); color: var(--primary);
  border: 1.5px dashed var(--primary); border-radius: 10px;
  padding: 10px 20px; font-size: .9rem; font-weight: 600;
  cursor: pointer; margin-top: 12px; width: 100%;
  transition: background .15s;
}
.btn-add:hover { background: #dbeafe; }

.btn-remove {
  background: #fee2e2; color: #ef4444; border: none;
  border-radius: 8px; padding: 10px 12px; cursor: pointer;
  font-size: 1rem; flex-shrink: 0; transition: background .15s;
}
.btn-remove:hover { background: #fecaca; }

/* ── Container ── */
.container { max-width: 640px; margin: 0 auto; padding: 28px 20px 80px; width: 100%; }
.container.full-width { max-width: 100%; padding: 28px 32px 80px; }

/* 表单页：把进度条与卡片往下挪，避免紧贴顶部 */
#page-form .container { padding-top: 96px; }

/* ── Progress ── */
.progress-wrap { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.progress-bar { flex: 1; height: 6px; background: var(--border); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 99px; transition: width .4s ease; }
.progress-text { font-size: .85rem; color: var(--text-sub); white-space: nowrap; font-weight: 500; }

/* ── Step card ── */
.step-card {
  background: var(--white); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 32px 28px;
  animation: slideUp .3s ease;
}
@keyframes slideUp { from{opacity:0;transform:translateY(16px)} to{opacity:1;transform:translateY(0)} }

.step-title { font-size: 1.4rem; font-weight: 800; margin-bottom: 22px; color: var(--text); }
.step-hint { font-size: .88rem; color: var(--text-sub); margin-bottom: 14px; }
.step-body { margin-bottom: 28px; }

.btn-row { display: flex; gap: 12px; justify-content: flex-end; }

/* ── Form inputs ── */
.form-input {
  width: 100%; padding: 13px 16px;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  font-size: 1rem; outline: none; background: white;
  transition: border-color .15s, box-shadow .15s;
}
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }

/* ── Select ── */
.form-select {
  width: 100%; padding: 13px 16px;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  font-size: 1rem; outline: none; background: var(--white);
  transition: border-color .15s, box-shadow .15s;
  cursor: pointer;
}
.form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }

/* 覆盖浏览器自动填充的黄绿色背景，保持输入框为纯白底 */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active,
textarea:-webkit-autofill,
select:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px var(--white) inset !important;
  -webkit-text-fill-color: var(--text) !important;
  caret-color: var(--text);
  transition: background-color 5000s ease-in-out 0s;
}

/* ── 计划周期下拉选择 ── */
.weeks-display {
  width: 100%; padding: 13px 16px;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  background: var(--white);
  cursor: pointer;
  font-size: 1rem; color: var(--text-sub);
  transition: border-color .15s, box-shadow .15s;
  user-select: none;
}
.weeks-display:hover { border-color: var(--primary); }
.weeks-display.smart { color: var(--primary); font-weight: 600; }

.weeks-dropdown {
  margin-top: 6px;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 240px; overflow-y: auto;
  z-index: 100;
  animation: slideUp .15s ease;
}
.weeks-option {
  padding: 10px 16px; cursor: pointer;
  transition: background .15s; font-size: .95rem;
  color: var(--text);
}
.weeks-option:hover { background: var(--primary-light); color: var(--primary); }
.weeks-option:first-child {
  border-bottom: 1px dashed var(--border);
  font-weight: 600;
  color: var(--primary);
}

/* ── Radio ── */
.radio-group { display: flex; gap: 10px; flex-wrap: wrap; }
.radio-group.column { flex-direction: column; gap: 8px; }

.radio-card {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px; border: 1.5px solid var(--border);
  border-radius: var(--radius); cursor: pointer; background: var(--white);
  transition: border-color .15s, background .15s;
  font-size: .95rem;
}
.radio-card input[type="radio"] { accent-color: var(--primary); width: 17px; height: 17px; flex-shrink: 0; }
.radio-card:has(input:checked) {
  border-color: var(--primary); background: var(--primary-light);
  color: var(--primary); font-weight: 600;
}

/* ── Time input ── */
.time-wrap { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.time-wrap.large { gap: 12px; }

.time-input {
  width: 80px; padding: 12px 10px; text-align: center;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  font-size: 1.1rem; font-weight: 600; outline: none; background: white;
  transition: border-color .15s, box-shadow .15s;
  -moz-appearance: textfield;
  appearance: textfield;
}
.time-input::-webkit-outer-spin-button,
.time-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.time-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.time-input.wide { width: 100px; }

.time-sep { font-size: 1rem; color: var(--text-sub); font-weight: 500; }

/* ── Record row ── */
.record-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px; flex-wrap: wrap;
}

.record-row select {
  flex: 0 0 110px; padding: 11px 10px;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  font-size: .95rem; outline: none; background: var(--white);
  transition: border-color .15s;
}
.record-row select:focus { border-color: var(--primary); }
.record-row .time-wrap { flex: 1; }

/* ── Result Layout ── */
.result-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

.result-left {
  min-width: 0;
}

.result-right {
  min-width: 0;
}

/* ── Result ── */
.result-box {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px;
  min-height: 300px; box-shadow: var(--shadow);
  word-break: break-word;
}

.text-container {
  line-height: 1.85;
  font-size: 1rem;
}

/* Markdown styles */
.md-body { line-height: 1.85; font-size: 1rem; }
.md-body h1,.md-body h2,.md-body h3 { margin: 1.2em 0 .5em; font-weight: 700; line-height: 1.3; }
.md-body h1 { font-size: 1.5rem; }
.md-body h2 { font-size: 1.25rem; color: var(--primary); }
.md-body h3 { font-size: 1.1rem; }
.md-body p { margin-bottom: .85em; }
.md-body ul,.md-body ol { padding-left: 1.5em; margin-bottom: .85em; }
.md-body li { margin-bottom: .35em; }
.md-body strong { font-weight: 700; color: var(--text); }
.md-body em { font-style: italic; }
.md-body code { background: #f1f5f9; padding: 2px 6px; border-radius: 4px; font-size: .9em; }
.md-body pre { background: #f1f5f9; padding: 14px; border-radius: 8px; overflow-x: auto; margin-bottom: .85em; }
.md-body pre code { background: none; padding: 0; }
.md-body table { border-collapse: collapse; width: 100%; margin-bottom: .85em; font-size: .93rem; }
.md-body th,.md-body td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.md-body th { background: var(--primary-light); font-weight: 600; color: var(--primary); }
.md-body hr { border: none; border-top: 1px solid var(--border); margin: 1.2em 0; }
.md-body blockquote { border-left: 3px solid var(--primary); padding-left: 14px; color: var(--text-sub); margin: .8em 0; }

.cursor {
  display: inline-block; color: var(--primary);
  animation: blink .8s step-start infinite;
  font-size: 1.1em; vertical-align: text-bottom;
}
@keyframes blink { 50%{opacity:0} }
.cursor.hidden { display: none; }

/* Thinking text */
.thinking-text {
  display: inline-block;
  color: var(--text-sub);
  font-style: italic;
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

/* ── Thinking Panel (思考模型专用) ── */
.thinking-panel {
  margin-bottom: 20px;
  border: 1.5px solid #e9d5ff;
  background: #faf5ff;
  border-radius: 12px;
  overflow: hidden;
  animation: slideUp .25s ease;
}

.thinking-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  transition: background .15s;
}
.thinking-header:hover { background: #f3e8ff; }

.thinking-icon { font-size: 1.2rem; line-height: 1; }

.thinking-title {
  font-weight: 700;
  color: #6d28d9;
  font-size: .95rem;
  flex: 0 0 auto;
}

.thinking-status {
  flex: 1;
  font-size: .82rem;
  color: #7c3aed;
  font-style: italic;
  text-align: right;
  padding-right: 8px;
}
.thinking-status.thinking { animation: pulse 1.5s ease-in-out infinite; }

.thinking-toggle {
  color: #6d28d9;
  font-weight: 700;
  font-size: 1rem;
  width: 16px;
  text-align: center;
  flex: 0 0 16px;
}

.thinking-body {
  max-height: 360px;
  overflow: hidden;
  padding: 0 14px 14px;
  transition: max-height .3s ease, padding .3s ease;
}
.thinking-body.collapsed {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
}

.thinking-content {
  font-family: ui-monospace, 'SF Mono', 'Cascadia Code', Consolas, 'PingFang SC', monospace;
  font-size: .85rem;
  line-height: 1.7;
  color: #4c1d95;
  white-space: pre-wrap;
  word-break: break-word;
  background: white;
  border-radius: 8px;
  padding: 14px 16px;
  border: 1px solid #e9d5ff;
  max-height: 320px;
  overflow-y: auto;
}

@media (max-width: 600px) {
  .thinking-body { max-height: 260px; }
  .thinking-content { max-height: 220px; font-size: .8rem; padding: 12px; }
  .thinking-status { font-size: .78rem; }
}

.hidden { display: none !important; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 28px; left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: #1f2937; color: white;
  padding: 12px 24px; border-radius: 50px;
  font-size: .9rem; opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s; z-index: 999;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Responsive ── */
@media (max-width: 480px) {
  .container { padding: 20px 14px 70px; }
  .step-card { padding: 24px 18px; }
  .step-title { font-size: 1.2rem; }
  .btn-row { flex-direction: column-reverse; }
  .btn-next, .btn-secondary { width: 100%; text-align: center; }
  .record-row select { flex: 0 0 95px; }
  .time-input { width: 68px; }
}

/* ── Mileage rows ── */
.mileage-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.mileage-label { font-size: .95rem; font-weight: 600; color: var(--text); white-space: nowrap; }

/* ── Goal sub-options ── */
.sub-options {
  margin-top: 8px;
  margin-left: 16px;
  padding: 14px;
  background: var(--primary-light);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1.5px solid #bfdbfe;
  animation: slideUp .2s ease;
}
.sub-card {
  background: white;
  border-color: #bfdbfe;
}
.sub-card:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

/* ── Days grid ── */
.days-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 4px;
}

.day-btn {
  padding: 12px 6px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-sub);
  transition: border-color .15s, background .15s, color .15s;
  text-align: center;
}
.day-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.day-btn.selected {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}

@media (max-width: 400px) {
  .days-grid { grid-template-columns: repeat(4, 1fr); gap: 7px; }
  .day-btn { padding: 10px 4px; font-size: .82rem; }
  .mileage-row { flex-direction: column; align-items: flex-start; }
}

/* ── Generation Steps ── */
.gen-steps {
  margin-bottom: 32px;
  padding: 20px;
  background: var(--primary-light);
  border-radius: var(--radius);
  border: 1.5px solid #bfdbfe;
}

.gen-step {
  margin-bottom: 16px;
}
.gen-step:last-child { margin-bottom: 0; }

.step-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.step-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
  transition: transform .3s ease, box-shadow .3s ease;
  flex-shrink: 0;
}

.step-dot.collapsed {
  transform: scale(0.7);
  opacity: 0.5;
}

.step-dot.expanded {
  transform: scale(1);
  opacity: 1;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.2);
}

.step-label {
  font-size: .95rem;
  font-weight: 600;
  color: var(--primary);
}

.step-detail {
  margin-top: 8px;
  margin-left: 26px;
  padding: 12px 16px;
  background: white;
  border-radius: 8px;
  font-size: .9rem;
  color: var(--text);
  white-space: pre-wrap;
  word-wrap: break-word;
  line-height: 1.7;
  max-height: 0;
  overflow: hidden;
  transition: max-height .3s ease, padding .3s ease;
}

.step-detail.show {
  border: 1px solid #bfdbfe;
  max-height: 1000px;
  overflow: visible;
}

.step-ai-content {
  line-height: 1.8;
  font-size: .95rem;
}

.step-ai-content h1, .step-ai-content h2, .step-ai-content h3 {
  margin: 1em 0 .5em;
  font-weight: 700;
  line-height: 1.3;
}
.step-ai-content h1 { font-size: 1.4rem; }
.step-ai-content h2 { font-size: 1.2rem; color: var(--primary); }
.step-ai-content h3 { font-size: 1.05rem; }
.step-ai-content p { margin-bottom: .8em; }
.step-ai-content ul, .step-ai-content ol { padding-left: 1.5em; margin-bottom: .8em; }
.step-ai-content li { margin-bottom: .3em; }
.step-ai-content strong { font-weight: 700; }
.step-ai-content code { background: #f1f5f9; padding: 2px 6px; border-radius: 4px; font-size: .88em; }
.step-ai-content pre { background: #f1f5f9; padding: 12px; border-radius: 8px; overflow-x: auto; margin-bottom: .8em; }
.step-ai-content pre code { background: none; padding: 0; }
.step-ai-content table { border-collapse: collapse; width: 100%; margin-bottom: .8em; font-size: .9rem; }
.step-ai-content th, .step-ai-content td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.step-ai-content th { background: var(--primary-light); font-weight: 600; color: var(--primary); }
.step-ai-content hr { border: none; border-top: 1px solid var(--border); margin: 1em 0; }
.step-ai-content blockquote { border-left: 3px solid var(--primary); padding-left: 12px; color: var(--text-sub); margin: .7em 0; }

@media (max-width: 480px) {
  .gen-steps { padding: 14px; }
  .step-detail { margin-left: 20px; font-size: .85rem; }
}

/* ── Training Schedule ── */
.schedule-wrapper {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.schedule-header {
  background: linear-gradient(135deg, var(--primary) 0%, #1d4ed8 100%);
  color: white;
  padding: 16px 20px;
  border-bottom: 2px solid var(--primary-dark);
}

.schedule-header h3 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
}

.schedule-container {
  padding: 20px;
}

.schedule-container:empty::before {
  content: "等待 AI 生成训练计划...";
  display: block;
  text-align: center;
  color: var(--text-sub);
  padding: 40px 20px;
  font-style: italic;
}

.schedule-week {
  margin-bottom: 20px;
  background: var(--bg);
  border-radius: 10px;
  padding: 16px;
  border: 1.5px solid var(--border);
}

.schedule-week:last-child {
  margin-bottom: 0;
}

.schedule-week-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--primary-light);
}

.schedule-days-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.schedule-day-card {
  background: white;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  transition: transform .2s, box-shadow .2s;
}

.schedule-day-card:hover {
  transform: translateX(4px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.schedule-day-header {
  font-size: .88rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.schedule-item {
  background: var(--primary-light);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 6px;
  border: 1px solid #bfdbfe;
  transition: background .15s, border-color .15s;
  overflow: hidden;
}

.schedule-item:last-child {
  margin-bottom: 0;
}

.schedule-item:hover {
  background: #dbeafe;
}

.schedule-item.has-steps {
  cursor: pointer;
  user-select: none;
}

.schedule-item.has-steps:hover {
  border-color: var(--primary);
}

.schedule-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.schedule-item-info {
  flex: 1;
  min-width: 0;
}

.schedule-item-name {
  font-size: .9rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
}

.schedule-item-duration {
  font-size: .82rem;
  color: var(--text-sub);
  font-weight: 500;
}

.schedule-item-arrow {
  font-size: .9rem;
  color: var(--primary);
  font-weight: bold;
  flex-shrink: 0;
  transition: transform .2s;
}

.schedule-item-detail {
  max-height: 0;
  overflow: hidden;
  transition: max-height .3s ease, margin-top .3s ease;
}

.schedule-item.open .schedule-item-detail {
  max-height: 500px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed #bfdbfe;
}

.schedule-steps-title {
  font-size: .85rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
}

.schedule-step {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 6px;
  font-size: .82rem;
  line-height: 1.5;
}

.schedule-step:last-child {
  margin-bottom: 0;
}

.step-num {
  background: var(--primary);
  color: white;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}

.step-text {
  flex: 1;
  color: var(--text);
}

.ara-creating {
  display: inline-block;
  color: var(--primary);
  font-weight: 600;
  font-size: .95rem;
  padding: 6px 14px;
  background: var(--primary-light);
  border-radius: 20px;
  margin-left: 8px;
  animation: pulse 1.2s ease-in-out infinite;
}

.ara-success {
  display: inline-block;
  color: #059669;
  font-weight: 600;
  font-size: .88rem;
  padding: 4px 12px;
  background: #d1fae5;
  border-radius: 20px;
  margin-left: 8px;
  border: 1px solid #6ee7b7;
  animation: fadeOut 1.5s ease forwards;
}

@keyframes fadeOut {
  0%   { opacity: 1; }
  60%  { opacity: 1; }
  100% { opacity: 0; }
}

/* 响应式：平板及以下 */
@media (max-width: 1024px) {
  .result-layout {
    grid-template-columns: 1fr;
  }
  
  .result-right {
    order: -1; /* 移到上方 */
  }
}

/* 手机端 */
@media (max-width: 600px) {
  .container.full-width {
    padding: 20px 16px 60px;
  }
  
  .result-layout {
    gap: 16px;
  }
  
  .result-box {
    padding: 20px;
  }
  
  .schedule-wrapper {
    margin-bottom: 16px;
  }
  
  .schedule-container {
    padding: 14px;
  }
  
  .schedule-week {
    padding: 12px;
  }
  
  .schedule-week-title {
    font-size: 1rem;
  }
}

/* ── Error tip ── */
.error-tip {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  color: #dc2626;
  padding: 16px 20px;
  font-size: .95rem;
  line-height: 1.7;
}
.error-tip small {
  display: block;
  margin-top: 6px;
  color: #ef4444;
  font-size: .8rem;
  opacity: .8;
}

/* ── Result status bar（生成中 + 停止按钮） ── */
.result-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--primary-light);
  border: 1px solid #dbeafe;
  border-radius: var(--radius);
  padding: 10px 16px;
  margin-bottom: 16px;
  font-size: .9rem;
  color: var(--primary-dark);
}
.result-status-text {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}
.result-status-text::before {
  content: '';
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 0 rgba(37,99,235,.6);
  animation: status-pulse 1.2s ease-in-out infinite;
}
@keyframes status-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(37,99,235,.6); }
  50%      { box-shadow: 0 0 0 6px rgba(37,99,235,0); }
}
.btn-stop {
  background: var(--white);
  color: #dc2626;
  border: 1.5px solid #fecaca;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
  white-space: nowrap;
}
.btn-stop:hover { background: #fef2f2; border-color: #fca5a5; }
.btn-stop:active { transform: scale(.97); }

/* ── 停止提示（generate 末尾追加） ── */
.stopped-tip {
  margin-top: 16px;
  padding: 12px 16px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius);
  color: #92400e;
  font-size: .9rem;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.btn-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  border-bottom: 1px solid currentColor;
  padding-bottom: 1px;
  transition: opacity .15s;
}
.btn-link:hover { opacity: .7; }

/* ── Scrollbar (全局极简风格) ── */
/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(37, 99, 235, 0.32) transparent;
}

/* Webkit / Blink（Edge / Chrome / Safari） */
*::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: rgba(37, 99, 235, 0.32);
  border-radius: 999px;
  /* 用透明 border + background-clip 让滚动条视觉更窄，不挡内容 */
  border: 1px solid transparent;
  background-clip: padding-box;
  transition: background .18s ease;
}

*::-webkit-scrollbar-thumb:hover {
  background: rgba(37, 99, 235, 0.55);
  background-clip: padding-box;
}

/* 隐藏两端箭头按钮，极简风 */
*::-webkit-scrollbar-button,
*::-webkit-scrollbar-button:single-button,
*::-webkit-scrollbar-button:double-button {
  display: none;
  width: 0;
  height: 0;
  background: transparent;
}

*::-webkit-scrollbar-corner {
  background: transparent;
}

/* ── 历史记录：浮动按钮 ── */
.history-fab {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 900;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid rgba(37, 99, 235, .25);
  background: rgba(255, 255, 255, .92);
  color: #2563eb;
  font-size: .88rem;
  font-weight: 600;
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .06), 0 1px 2px rgba(0, 0, 0, .04);
  transition: transform .15s ease, box-shadow .2s ease, background .15s ease;
}
.history-fab:hover {
  background: #2563eb;
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(37, 99, 235, .3);
}
.history-fab-icon { font-size: 1rem; line-height: 1; }

/* ── 历史记录：抽屉容器 ── */
.history-drawer {
  position: fixed;
  inset: 0;
  z-index: 1000;
  pointer-events: none;
}
.history-drawer.hidden { display: none; }
.history-drawer.show   { pointer-events: auto; }

.history-mask {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .35);
  opacity: 0;
  transition: opacity .22s ease;
}
.history-drawer.show .history-mask { opacity: 1; }

.history-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(440px, 100vw);
  background: var(--bg, #f8fafc);
  color: var(--text, #111827);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .22s cubic-bezier(.4, 0, .2, 1);
  box-shadow: -8px 0 32px rgba(0, 0, 0, .12);
}
.history-drawer.show .history-panel { transform: translateX(0); }

.history-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border, #e5e7eb);
  background: #fff;
  flex: 0 0 auto;
}
.history-panel-header h3 {
  margin: 0;
  font-size: 1.05rem;
  color: #111827;
}
.history-close {
  border: none;
  background: transparent;
  font-size: 1.2rem;
  color: #6b7280;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background .15s, color .15s;
}
.history-close:hover {
  background: #f3f4f6;
  color: #111827;
}

/* ── 历史记录：列表视图 ── */
.history-list-view,
.history-detail-view {
  flex: 1 1 auto;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.history-list { padding: 12px 14px; }

.history-item {
  background: #fff;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s;
}
.history-item:hover {
  transform: translateY(-1px);
  border-color: #93c5fd;
  box-shadow: 0 4px 14px rgba(37, 99, 235, .1);
}

.history-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.history-item-time {
  font-size: .78rem;
  color: #6b7280;
  font-variant-numeric: tabular-nums;
}
.history-item-badge {
  font-size: .72rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eff6ff;
  color: #2563eb;
  font-weight: 600;
}
.history-item-badge.thinking {
  background: #f5f3ff;
  color: #6d28d9;
}

.history-item-goal {
  font-size: 1rem;
  font-weight: 700;
  color: #111827;
  margin-bottom: 6px;
  line-height: 1.4;
}

.history-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: .78rem;
  color: #6b7280;
}

.history-list-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: #9ca3af;
  text-align: center;
}
.history-list-empty.hidden { display: none; }
.history-empty-icon { font-size: 3rem; margin-bottom: 12px; opacity: .5; }
.history-empty-hint { font-size: .85rem; opacity: .8; margin-top: 4px; }

/* ── 历史记录：详情视图 ── */
.history-detail-view { padding: 0 0 20px; }

.history-back {
  margin: 12px 14px 4px;
  border: none;
  background: transparent;
  color: #2563eb;
  font-size: .9rem;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
  align-self: flex-start;
}
.history-back:hover { background: #eff6ff; }

.history-detail-content { padding: 4px 20px 20px; }

.history-detail-header {
  padding: 6px 0 14px;
  border-bottom: 1px solid var(--border, #e5e7eb);
  margin-bottom: 14px;
}
.history-detail-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #111827;
  margin-bottom: 4px;
}
.history-detail-sub {
  font-size: .8rem;
  color: #6b7280;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.history-section {
  margin-bottom: 18px;
}
.history-section h4 {
  margin: 0 0 8px;
  font-size: .9rem;
  font-weight: 700;
  color: #2563eb;
  letter-spacing: .02em;
}

.history-inputs {
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 14px;
  row-gap: 6px;
  font-size: .85rem;
  background: #fff;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  padding: 12px 14px;
  margin: 0;
}
.history-inputs dt {
  color: #6b7280;
  font-weight: 500;
  white-space: nowrap;
}
.history-inputs dd {
  color: #111827;
  margin: 0;
  word-break: break-word;
}

.history-ai-text {
  font-size: .88rem;
  line-height: 1.7;
  color: #1f2937;
  background: #fff;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  padding: 12px 14px;
  max-height: 360px;
  overflow-y: auto;
}
.history-ai-text p { margin: 6px 0; }
.history-ai-text h1, .history-ai-text h2, .history-ai-text h3 {
  font-size: 1rem;
  color: #111827;
  margin: 10px 0 4px;
}

.history-thinking {
  background: #faf5ff;
  border: 1px solid #e9d5ff;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 18px;
}
.history-thinking summary {
  cursor: pointer;
  font-weight: 600;
  color: #6d28d9;
  font-size: .9rem;
  user-select: none;
  outline: none;
}
.history-thinking pre {
  margin: 8px 0 0;
  font-family: ui-monospace, 'SF Mono', Consolas, monospace;
  font-size: .8rem;
  line-height: 1.6;
  color: #4c1d95;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 280px;
  overflow-y: auto;
}

/* ========== 鉴权弹窗（登录 / 注册 / 游客） ========== */
.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}
.auth-modal.hidden { display: none; }
.auth-mask {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .55);
  backdrop-filter: blur(2px);
}
.auth-panel {
  position: relative;
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  background: var(--white, #fff);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .25);
  padding: 32px 32px 24px;
  animation: authPanelIn .25s ease;
}
@keyframes authPanelIn {
  from { transform: translateY(20px) scale(.96); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

.auth-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.auth-sub {
  font-size: .85rem;
  color: var(--text-sub);
  margin-bottom: 20px;
}

.auth-view { display: block; }
.auth-view.hidden { display: none; }

.auth-field {
  margin-bottom: 14px;
}
.auth-field label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.auth-field input {
  width: 100%;
  padding: 10px 12px;
  font-size: .95rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.auth-field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}
.auth-hint {
  margin-top: 4px;
  font-size: .75rem;
  color: var(--text-sub);
}

.auth-code-row {
  display: flex;
  gap: 8px;
}
.auth-code-row input {
  flex: 1;
}
.auth-send-code-btn {
  flex-shrink: 0;
  padding: 0 14px;
  font-size: .85rem;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-light);
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.auth-send-code-btn:hover:not(:disabled) {
  background: #dbeafe;
}
.auth-send-code-btn:disabled {
  color: var(--text-sub);
  background: #f3f4f6;
  cursor: not-allowed;
}

.auth-err {
  min-height: 18px;
  font-size: .82rem;
  color: #ef4444;
  margin: 4px 0 8px;
}

.auth-submit-btn {
  display: block;
  width: 100%;
  padding: 12px;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  margin-top: 4px;
  transition: transform .12s, box-shadow .15s, opacity .15s;
  box-shadow: 0 4px 16px rgba(37, 99, 235, .25);
}
.auth-submit-btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(37, 99, 235, .35); }
.auth-submit-btn:disabled { opacity: .6; cursor: not-allowed; }

.auth-switch {
  margin-top: 16px;
  text-align: center;
  font-size: .85rem;
  color: var(--text-sub);
}
.auth-switch a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  margin-left: 4px;
}
.auth-switch a:hover { text-decoration: underline; }

.auth-divider {
  display: flex;
  align-items: center;
  margin: 22px 0 14px;
  color: var(--text-sub);
  font-size: .8rem;
}
.auth-divider::before, .auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.auth-divider span { padding: 0 12px; }

.auth-visitor-btn {
  display: block;
  width: 100%;
  padding: 11px;
  font-size: .95rem;
  color: var(--text);
  background: #f3f4f6;
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: background .15s;
  text-align: center;
}
.auth-visitor-btn:hover { background: #e5e7eb; }
.auth-visitor-note {
  display: block;
  margin-top: 2px;
  font-size: .75rem;
  color: var(--text-sub);
  font-weight: 400;
}

.auth-visitor-locked {
  text-align: center;
  padding: 24px 12px 8px;
}
.auth-visitor-locked.hidden { display: none; }
.auth-visitor-icon { font-size: 40px; margin-bottom: 12px; }
.auth-visitor-msg { font-size: 1rem; color: var(--text); margin-bottom: 6px; }
.auth-visitor-link {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
  font-size: .95rem;
}
.auth-visitor-link:hover { text-decoration: underline; }

/* 顶部导航"登录 / 用户名"链接 */
.top-nav-auth {
  color: var(--primary);
}
.top-nav-auth:hover { color: var(--primary-dark); }
.top-nav-auth.is-user {
  color: var(--text);
  cursor: default;
  font-weight: 600;
}

.history-detail-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 6px;
}
.history-detail-actions .btn-secondary {
  border: 1px solid #fca5a5;
  background: #fff;
  color: #dc2626;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: .85rem;
  transition: background .15s, color .15s;
}
.history-detail-actions .btn-secondary:hover {
  background: #fef2f2;
  color: #b91c1c;
}

/* ── 历史页（/history） ── */
.history-page-hint {
  color: var(--text-sub);
  font-size: .9rem;
  margin: -8px 0 24px;
}
.history-page-empty {
  background: var(--white);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 60px 20px;
  text-align: center;
  color: var(--text-sub);
  font-size: 1rem;
}
.history-page-list { display: flex; flex-direction: column; gap: 12px; }
.history-page-list .history-item {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  cursor: pointer;
  transition: transform .15s, box-shadow .2s, border-color .2s;
}
.history-page-list .history-item:hover {
  transform: translateY(-1px);
  border-color: var(--primary);
  box-shadow: var(--shadow);
}

@media (max-width: 600px) {
  .history-fab { top: 12px; right: 12px; padding: 6px 12px; font-size: .82rem; }
  .history-fab-label { display: none; }    /* 移动端只留图标，省空间 */
  .history-panel { width: 100vw; }
  .history-item-meta { gap: 6px; font-size: .72rem; }
  .top-nav { top: 12px; right: 14px; }
  .top-nav-right { gap: 12px; }
  .top-nav-link { font-size: .85rem; }
}

/* ========== 移动端/平板端响应式强化（统一放这里便于维护） ========== */

/* 平板：601 - 1024px */
@media (min-width: 601px) and (max-width: 1024px) {
  .container { max-width: 720px; padding: 28px 24px 80px; }
  .container.full-width { max-width: 100%; padding: 24px 24px 80px; }
  /* hero 内容稍收紧 */
  .hero-icon { font-size: 4rem; }
  .hero h1 { font-size: 2.4rem; }
  /* 训练计划表保证不溢出：横向滚动 */
  .schedule-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .schedule-day-list { min-width: 380px; }
  /* 表单行间距 */
  .record-row { gap: 8px; }
}

/* 手机：<= 600px */
@media (max-width: 600px) {
  /* 顶部 hero 缩放：hero 模式下字体也用白底色用深色 */
  .hero { padding: 60px 18px 40px; }
  .hero-icon { font-size: 3.2rem; }
  .hero h1 { font-size: 2rem; }
  .hero-sub { font-size: .92rem; }
  .btn-primary { padding: 14px 32px; font-size: 1rem; }

  /* 训练计划表：横向滚动避免列数过多溢出 */
  .schedule-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .schedule-day-list { min-width: 360px; }
  .schedule-week-header { font-size: .9rem; }

  /* 生成状态条：按钮和文字可换行 */
  .result-status-bar {
    flex-wrap: wrap;
    padding: 10px 12px;
    gap: 8px;
  }
  .result-status-text { font-size: .85rem; }
  .btn-stop { font-size: .8rem; padding: 5px 10px; }

  /* 停止提示 */
  .stopped-tip { padding: 10px 12px; font-size: .85rem; }

  /* 错误提示 */
  .error-tip { padding: 12px 14px; font-size: .9rem; }
  .error-retry { margin-top: 8px; }

  /* 触摸目标最小 44px 高（WCAG 移动端建议） */
  .btn-stop, .day-btn, .btn-next, .btn-secondary, .btn-back, .btn-add {
    min-height: 44px;
  }
  /* 思考面板在小屏更紧凑 */
  .thinking-panel { margin: 12px 0; }
  .thinking-body { max-height: 200px; }
  .thinking-content { padding: 10px 12px; font-size: .78rem; }

  /* form 步骤卡片 */
  .step-card { padding: 20px 16px; }
  .step-title { font-size: 1.1rem; }

  /* 训练计划表：每周天数列改单列 */
  .schedule-day-list { grid-template-columns: 1fr; }

  /* 历史记录详情 */
  .history-detail-content { padding: 4px 12px 20px; }
}

/* 小型手机：<= 380px */
@media (max-width: 380px) {
  .top-nav { top: 10px; right: 10px; }
  .top-nav-right { gap: 8px; }
  .top-nav-link { font-size: .78rem; padding: 3px 1px; }
  .hero h1 { font-size: 1.7rem; }
  .hero-sub { font-size: .85rem; }
  .btn-primary { padding: 12px 24px; font-size: .92rem; }
  .container { padding: 20px 10px 60px; }
  /* 表单控件更紧凑 */
  .record-row select { flex: 0 0 80px; font-size: .82rem; }
  .time-input { width: 56px; }
  .day-btn { font-size: .8rem; padding: 9px 2px; }
  .schedule-day-list { min-width: 300px; }
}
