/* ============================================================
   AI 自由收入规划师 · 全局样式
   设计：深色主题 + 紫橙渐变 + 移动端优先
   ============================================================ */

:root {
  --bg: #0f172a;
  --bg-2: #1e293b;
  --bg-3: #334155;
  --card: #1e293b;
  --border: #334155;
  --text: #e2e8f0;
  --text-2: #cbd5e1;
  --muted: #94a3b8;
  --primary: #6366f1;
  --primary-2: #818cf8;
  --accent: #f59e0b;
  --accent-2: #fbbf24;
  --danger: #ef4444;
  --success: #22c55e;
  --grad: linear-gradient(135deg, #6366f1, #f59e0b);
  --grad-soft: linear-gradient(135deg, rgba(99,102,241,.15), rgba(245,158,11,.15));
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,.3);
  --max-w: 560px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: var(--max-w);
  margin: 0 auto;
  min-height: 100dvh;
  padding: 0 16px 40px;
}

/* —— 页面切换 —— */
.page { display: none; animation: fadeUp .4s ease; }
.page.active { display: block; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* —— 通用按钮 —— */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 14px 28px; border: none; border-radius: var(--radius-sm);
  font-size: 16px; font-weight: 700; cursor: pointer; transition: all .2s;
  width: 100%; max-width: 320px;
}
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 4px 16px rgba(99,102,241,.35); }
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-ghost {
  background: transparent; color: var(--text-2); border: 1px solid var(--border);
  width: auto; padding: 10px 20px; font-size: 14px;
}
.btn-ghost:hover { border-color: var(--primary); color: var(--primary-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ============================================================
   首页
   ============================================================ */
#page-home {
  display: none; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100dvh; text-align: center; padding-top: 0;
}
#page-home.active { display: flex; }

.hero-badge {
  display: inline-block; padding: 6px 14px; border-radius: 20px;
  background: var(--grad-soft); border: 1px solid rgba(99,102,241,.3);
  font-size: 12px; color: var(--primary-2); margin-bottom: 24px;
}
.hero h1 {
  font-size: 32px; line-height: 1.3; margin-bottom: 12px;
  background: var(--grad); -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.hero p.sub { font-size: 16px; color: var(--muted); margin-bottom: 36px; max-width: 340px; }
.hero-features { display: flex; flex-direction: column; gap: 10px; margin-bottom: 40px; text-align: left; }
.hero-feature { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-2); }
.hero-feature .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }

/* ============================================================
   输入页
   ============================================================ */
.page-head { padding: 24px 0 16px; }
.page-head h2 { font-size: 22px; margin-bottom: 4px; }
.page-head p { font-size: 14px; color: var(--muted); }

.progress-bar { height: 4px; background: var(--bg-3); border-radius: 2px; margin: 16px 0 24px; overflow: hidden; }
.progress-bar .fill { height: 100%; background: var(--grad); border-radius: 2px; transition: width .3s; width: 0; }

.form-group { margin-bottom: 20px; }
.form-group legend { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .5px; }
.form-section-label { font-size: 13px; font-weight: 600; color: var(--accent); margin: 24px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 14px; color: var(--text-2); margin-bottom: 6px; }
.field input[type="number"] {
  width: 100%; padding: 14px 16px; background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: 16px; outline: none; transition: border .2s;
}
.field input[type="number"]:focus { border-color: var(--primary); }
.field input[type="number"]::-webkit-outer-spin-button,
.field input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.field input[type="number"] { -moz-appearance: textfield; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.field .err { font-size: 12px; color: var(--danger); margin-top: 4px; display: none; }
.field.error input { border-color: var(--danger); }
.field.error .err { display: block; }

.skill-tags { display: flex; flex-wrap: wrap; gap: 10px; }
.skill-tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 18px; background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 24px; font-size: 14px; color: var(--text-2); cursor: pointer; transition: all .2s; user-select: none;
}
.skill-tag input { display: none; }
.skill-tag:active { transform: scale(.96); }
.skill-tag.checked { background: var(--grad-soft); border-color: var(--primary); color: var(--primary-2); font-weight: 600; }
.skill-tag.checked::before { content: "✓ "; }

.form-actions { display: flex; gap: 12px; margin-top: 32px; align-items: center; }

/* ============================================================
   结果页
   ============================================================ */
.score-wrap { display: flex; flex-direction: column; align-items: center; padding: 20px 0; }
.score-ring { position: relative; width: 180px; height: 180px; }
.score-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.score-ring .ring-bg { fill: none; stroke: var(--bg-3); stroke-width: 10; }
.score-ring .ring-fg { fill: none; stroke: url(#grad); stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset 1s ease; }
.score-center { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); text-align: center; }
.score-center .num { font-size: 42px; font-weight: 800; line-height: 1; background: var(--grad); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.score-center .lbl { font-size: 12px; color: var(--muted); margin-top: 4px; }
.score-level { margin-top: 16px; font-size: 18px; font-weight: 700; }
.score-level .tag { padding: 4px 12px; border-radius: 16px; font-size: 14px; }
.score-explain { margin-top: 12px; font-size: 12px; color: var(--muted); text-align: center; padding: 0 12px; line-height: 1.5; }

.gap-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 24px 0; }
.gap-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 8px; text-align: center; }
.gap-card .val { font-size: 18px; font-weight: 700; color: var(--accent); }
.gap-card .val.danger { color: var(--danger); }
.gap-card .lbl { font-size: 11px; color: var(--muted); margin-top: 4px; }

.section-title { font-size: 16px; font-weight: 700; margin: 28px 0 12px; display: flex; align-items: center; gap: 8px; }
.section-title .bar { width: 4px; height: 18px; background: var(--grad); border-radius: 2px; }

.bottleneck-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.bottleneck-tag { padding: 6px 14px; border-radius: 16px; font-size: 13px; background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.3); color: #fca5a5; }

.report-box { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px; margin: 12px 0; font-size: 14px; color: var(--text-2); line-height: 1.7; }
.report-box .src { font-size: 11px; color: var(--muted); margin-top: 8px; }

/* 路径卡片 */
.path-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; margin-bottom: 14px; transition: border .2s;
}
.path-card:hover { border-color: var(--primary); }
.path-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.path-card-head .name { font-size: 17px; font-weight: 700; }
.path-card-head .match { font-size: 12px; padding: 3px 10px; border-radius: 12px; background: var(--grad-soft); color: var(--accent-2); white-space: nowrap; }
.path-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.path-meta .chip { font-size: 11px; padding: 3px 8px; border-radius: 6px; background: var(--bg-3); color: var(--text-2); }
.path-meta .chip.warn { background: rgba(239,68,68,.12); color: #fca5a5; }
.path-meta .chip.ok { background: rgba(34,197,94,.12); color: #86efac; }
.path-chart { height: 100px; margin: 10px 0; }
.path-reason { font-size: 13px; color: var(--muted); line-height: 1.6; margin-bottom: 12px; }
.path-card .btn { width: 100%; max-width: none; padding: 12px; font-size: 14px; }

/* ============================================================
   计划页
   ============================================================ */
.plan-loading { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 20px; text-align: center; }
.spinner { width: 44px; height: 44px; border: 4px solid var(--bg-3); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; margin-bottom: 16px; }
@keyframes spin { to { transform: rotate(360deg); } }
.plan-loading p { color: var(--muted); font-size: 14px; }

.plan-week { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.plan-week .week-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.plan-week .week-num { width: 32px; height: 32px; border-radius: 50%; background: var(--grad); color: #fff; font-size: 14px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.plan-week .week-theme { font-size: 15px; font-weight: 600; }
.task-item { display: flex; gap: 10px; padding: 12px 0; border-top: 1px solid var(--border); }
.task-item:first-of-type { border-top: none; }
.task-item .task-idx { width: 22px; height: 22px; border-radius: 6px; background: var(--bg-3); color: var(--muted); font-size: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 2px; }
.task-body { flex: 1; }
.task-body .task-text { font-size: 14px; color: var(--text); line-height: 1.5; }
.task-body .task-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.task-body .task-meta .chip { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: var(--bg-3); color: var(--text-2); }
.task-body .task-meta .chip.tool { background: rgba(99,102,241,.15); color: var(--primary-2); }
.task-body .task-meta .chip.out { background: rgba(245,158,11,.12); color: var(--accent-2); }

.milestone-box { background: var(--grad-soft); border: 1px solid rgba(245,158,11,.3); border-radius: var(--radius); padding: 18px; margin: 20px 0; text-align: center; }
.milestone-box .icon { font-size: 28px; margin-bottom: 8px; }
.milestone-box .label { font-size: 12px; color: var(--accent-2); font-weight: 600; text-transform: uppercase; letter-spacing: 1px; }
.milestone-box .text { font-size: 15px; font-weight: 600; margin-top: 6px; }

.plan-actions { display: flex; gap: 10px; margin-top: 24px; }
.plan-actions .btn { flex: 1; max-width: none; }

/* —— 顶部导航条 —— */
.topbar { display: flex; align-items: center; gap: 10px; padding: 16px 0; }
.topbar .back { font-size: 20px; color: var(--muted); cursor: pointer; background: none; border: none; padding: 4px; }
.topbar .back:hover { color: var(--text); }
.topbar .title { font-size: 15px; font-weight: 600; }

/* —— Toast —— */
.toast {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--bg-3); color: var(--text); padding: 12px 24px; border-radius: 24px;
  font-size: 14px; box-shadow: var(--shadow); opacity: 0; transition: all .3s; z-index: 999; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* —— 响应式 —— */
@media (min-width: 600px) {
  #app { padding: 0 24px 40px; }
  .hero h1 { font-size: 38px; }
  .gap-cards { gap: 14px; }
  .gap-card .val { font-size: 20px; }
}

@media (max-width: 360px) {
  .hero h1 { font-size: 26px; }
  .gap-cards { grid-template-columns: 1fr; }
  .score-center .num { font-size: 36px; }
}
