/* 星河音乐工坊 · 设计系统
 * 基准：E:\awesome-design-md\design-md\spotify（深色"内容优先"纪律：UI 退到阴影里，让音乐发光）
 *      + elevenlabs（编辑级克制的排版、柔和渐变光晕作为唯一"色彩事件"）
 * 品牌化：把 Spotify 的单一绿换成"星河"紫→青渐变；圆角/药丸/层级沿用 Spotify 的几何。
 * 所有颜色都走 CSS 变量，页面里禁止写死色值。
 */
:root {
  /* ---- 画布与表面 ---- */
  --canvas: #0d0d12;
  --canvas-soft: #121218;
  --surface: #16161d;
  --surface-2: #1e1e27;
  --surface-3: #262631;
  --hairline: #2a2a35;
  --hairline-strong: #3a3a48;

  /* ---- 文字 ---- */
  --text: #f5f5f7;
  --text-body: #c9c9d1;
  --text-muted: #9a9aa6;
  /* ⚠️ 2026-10-13 按 WCAG 实测调过：原来是 #6c6c7a，在 --surface-3 上只有 **2.89:1**、
     在 --canvas 上也才 3.75:1（正文/12px 提示都要求 ≥4.5:1）。
     #8e8e9a 是"刚好达标"的最小改动：最差组合（on --surface-3）**4.62:1**，
     同时仍明显比 --text-muted(#9a9aa6, 5.38:1) 暗，层级没被抹平。 */
  --text-soft: #8e8e9a;
  --on-accent: #0d0d12;

  /* ---- 品牌 ---- */
  --accent: #8b5cf6;          /* 星河紫 */
  --accent-2: #22d3ee;        /* 星河青 */
  --accent-soft: rgba(139, 92, 246, .16);
  --accent-line: rgba(139, 92, 246, .38);
  --grad-brand: linear-gradient(96deg, var(--accent) 0%, #6366f1 45%, var(--accent-2) 100%);
  --grad-orb: radial-gradient(closest-side, rgba(139,92,246,.55), transparent 70%);

  /* ---- 语义 ---- */
  --success: #1ed760;
  --warning: #ffa42b;
  --error: #f3727f;

  /* ---- 几何 ---- */
  --r-pill: 9999px;
  --r-card: 14px;
  --r-input: 10px;
  --r-panel: 18px;

  /* ---- 间距/字阶 ---- */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Mono", Consolas, "Courier New", monospace;

  /* ---- 阴影（Spotify 的重阴影 + 内描边手感）---- */
  --shadow-card: 0 8px 24px rgba(0, 0, 0, .5);
  --shadow-pop: 0 16px 48px rgba(0, 0, 0, .65);
  --ring: inset 0 0 0 1px var(--hairline);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--canvas); color: var(--text);
  font-family: var(--font); font-size: 15px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* 大气渐变光晕：页面里唯一的"色彩事件"（ElevenLabs 的做法，但落在深色底上） */
body::before {
  content: ""; position: fixed; inset: -20% -10% auto -10%; height: 60vh; z-index: 0;
  background:
    radial-gradient(closest-side, rgba(139,92,246,.20), transparent 70%) 12% 0/45vw 45vw no-repeat,
    radial-gradient(closest-side, rgba(34,211,238,.14), transparent 70%) 68% 8%/38vw 38vw no-repeat,
    radial-gradient(closest-side, rgba(244,197,168,.10), transparent 70%) 92% 40%/32vw 32vw no-repeat;
  pointer-events: none; filter: blur(6px);
}
#app { position: relative; z-index: 1; }

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.015em; }
h1 { font-size: 34px; line-height: 1.15; letter-spacing: -.03em; }
h2 { font-size: 22px; }
h3 { font-size: 17px; }
p { margin: 0 0 var(--s3); color: var(--text-body); }
code, .mono { font-family: var(--mono); font-size: 12.5px; }

/* ---------------- 布局 ---------------- */
.nav {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: var(--s5);
  padding: var(--s3) var(--s5); background: rgba(13,13,18,.78);
  backdrop-filter: saturate(160%) blur(14px); border-bottom: 1px solid var(--hairline);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.02em; }
.brand .dot {
  width: 22px; height: 22px; border-radius: 50%; background: var(--grad-brand);
  box-shadow: 0 0 0 1px rgba(255,255,255,.12), 0 6px 18px rgba(139,92,246,.45);
}
.nav-links { display: flex; gap: var(--s2); margin-left: var(--s3); }
.nav-link {
  padding: 7px 14px; border-radius: var(--r-pill); color: var(--text-muted);
  font-size: 14px; font-weight: 600; transition: color .15s, background-color .15s, border-color .15s, box-shadow .15s;
}
.nav-link:hover { color: var(--text); background: var(--surface-2); }
.nav-link.active { color: var(--text); background: var(--surface-3); }
.nav-spacer { flex: 1; }

.wrap { max-width: 1180px; margin: 0 auto; padding: var(--s6) var(--s5) 96px; }
.wrap-narrow { max-width: 860px; }

/* ---------------- 组件 ---------------- */
.card {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--r-card); padding: var(--s5); box-shadow: var(--shadow-card);
}
.card + .card { margin-top: var(--s4); }
.panel {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--r-panel); padding: var(--s5);
}
.row { display: flex; gap: var(--s3); align-items: center; }
.row-wrap { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: var(--s4); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.spacer { flex: 1; }
.mt2 { margin-top: var(--s2); } .mt3 { margin-top: var(--s3); } .mt4 { margin-top: var(--s4); }
.mt5 { margin-top: var(--s5); } .mt6 { margin-top: var(--s6); }
.muted { color: var(--text-muted); } .soft { color: var(--text-soft); }
.small { font-size: 13px; } .tiny { font-size: 12px; }
.center { text-align: center; }
.hidden { display: none !important; }

/* 按钮：药丸几何，主按钮是品牌渐变，次按钮是描边 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--r-pill); border: 1px solid var(--hairline-strong);
  background: var(--surface-2); color: var(--text); font-weight: 600; font-size: 14px;
  cursor: pointer; transition: color .16s, background-color .16s, border-color .16s, box-shadow .16s, transform .16s; white-space: nowrap;
}
.btn:hover { background: var(--surface-3); border-color: var(--hairline-strong); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--grad-brand); color: #fff; border: none; box-shadow: 0 8px 24px rgba(99,102,241,.35); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-icon { width: 38px; height: 38px; padding: 0; border-radius: 50%; }

/* 表单 */
.field { margin-bottom: var(--s4); }
.label { display: block; font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.input, .textarea, .select {
  width: 100%; padding: 11px 14px; background: var(--canvas-soft);
  border: 1px solid var(--hairline); border-radius: var(--r-input); color: var(--text);
  transition: color .15s, background-color .15s, border-color .15s, box-shadow .15s; outline: none;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.textarea { min-height: 132px; resize: vertical; line-height: 1.7; }
.hint { font-size: 12px; color: var(--text-soft); margin-top: 6px; }

/* --------------------------------------------------------------------------------------
 * 键盘焦点环（2026-10-13 补）
 *
 * 为什么补：原来**只**给输入框写了 `.input:focus`，按钮/标签页/导航这些**没有任何可见焦点** ——
 * 键盘 Tab 走一遍，人完全不知道停在哪。参照的深色系统（linear.app / runwayml）都把
 * "可见焦点"当基本功：Linear 的招牌就是那圈淡紫 focus ring。
 *
 * 用 `:focus-visible` 而不是 `:focus`：**鼠标点击不弹环、键盘导航才弹**，
 * 这样既看得见焦点，又不会让每次点击都闪一圈。
 * ------------------------------------------------------------------------------------ */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-input);
}
/* 药丸/圆形控件（标签页、圆形播放键）用同样的环，但别把圆角改方 */
.tab:focus-visible, .badge:focus-visible, .work:focus-visible { border-radius: var(--r-pill); }
.btn:focus-visible { border-radius: var(--r-pill); }

/* --------------------------------------------------------------------------------------
 * 尊重"减少动态效果"（2026-10-13 补）
 *
 * 背景光晕、进度条、卡片过渡在系统开启 reduce 时应当停 —— 这是可访问性要求，
 * 也是参照系统（runwayml 的"零动效克制"）的一致性要求。
 * ------------------------------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* 标签页 */
.tabs { display: inline-flex; gap: 4px; padding: 4px; background: var(--canvas-soft);
         border: 1px solid var(--hairline); border-radius: var(--r-pill); }
.tab { padding: 8px 18px; border-radius: var(--r-pill); border: none; background: transparent;
       color: var(--text-muted); font-weight: 600; font-size: 14px; cursor: pointer; transition: color .15s, background-color .15s, border-color .15s, box-shadow .15s; }
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface-3); color: var(--text); box-shadow: var(--ring); }

/* 徽标 */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--r-pill);
  background: var(--surface-2); color: var(--text-muted); font-size: 12px; font-weight: 600;
  border: 1px solid var(--hairline);
  /* ⚠️ 徽标**绝不能被压扁换行**：在 flex 行里被挤窄时，文字会折成一个竖条状的橙色块
     （2026-10-13 浏览器验收截图里看到的"盖住按钮"就是这个）。 */
  white-space: nowrap; flex: 0 0 auto;
}
.badge-accent { background: var(--accent-soft); color: #c4b5fd; border-color: var(--accent-line); }
.badge-ok { color: var(--success); border-color: rgba(30,215,96,.35); background: rgba(30,215,96,.10); }
.badge-warn { color: var(--warning); border-color: rgba(255,164,43,.35); background: rgba(255,164,43,.10); }
.badge-err { color: var(--error); border-color: rgba(243,114,127,.35); background: rgba(243,114,127,.10); }

/* 进度条 */
.progress { height: 6px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--grad-brand); transition: width .4s ease; }
.progress-striped > i { background-image: linear-gradient(96deg, var(--accent), var(--accent-2), var(--accent));
  background-size: 200% 100%; animation: slide 1.4s linear infinite; }
@keyframes slide { from { background-position: 0 0 } to { background-position: -200% 0 } }

/* 播放器行 */
.track { display: flex; align-items: center; gap: var(--s3); padding: var(--s3);
         background: var(--surface-2); border: 1px solid var(--hairline); border-radius: var(--r-card); }
.track + .track { margin-top: var(--s2); }
.track-title { font-weight: 600; }
.play-btn { width: 40px; height: 40px; border-radius: 50%; border: none; cursor: pointer;
            background: var(--grad-brand); color: #fff; display: grid; place-items: center; flex: none; }
.play-btn:hover { filter: brightness(1.1); }
/* 就绪前播放键是禁用的（见 app.js 里那段说明）：**必须看得出来**，
   否则"灰着"只存在于代码里，用户看到的还是一个亮着的、点下去没反应的按钮。 */
.play-btn[disabled] { opacity: .45; cursor: not-allowed; }
.play-btn[disabled]:hover { filter: none; }
.wave { flex: 1; height: 34px; min-width: 80px; }
.audio-el { width: 100%; }

/* 作品卡（曲库） */
.work {
  background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-card);
  overflow: hidden; transition: border-color .18s, box-shadow .18s, transform .18s; cursor: pointer;
}
.work:hover { transform: translateY(-2px); box-shadow: var(--shadow-pop); border-color: var(--hairline-strong); }
.work-cover { aspect-ratio: 16/9; background: var(--grad-brand); opacity: .85; }
.work-body { padding: var(--s3) var(--s4) var(--s4); }

/* 空状态 */
.empty { padding: var(--s8) var(--s5); text-align: center; color: var(--text-muted);
         border: 1px dashed var(--hairline-strong); border-radius: var(--r-panel); }

/* 弹层 */
.modal-mask { position: fixed; inset: 0; background: rgba(5,5,8,.72); backdrop-filter: blur(6px);
              display: grid; place-items: center; z-index: 50; padding: var(--s5); }
.modal { width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--hairline);
         border-radius: var(--r-panel); padding: var(--s6); box-shadow: var(--shadow-pop); }

/* 提示 */
.toast-host { position: fixed; right: 20px; bottom: 20px; z-index: 60; display: flex;
              flex-direction: column; gap: var(--s2); }
.toast { padding: 12px 16px; border-radius: var(--r-card); background: var(--surface-2);
         border: 1px solid var(--hairline-strong); box-shadow: var(--shadow-pop); max-width: 380px;
         font-size: 14px; animation: pop .18s ease-out; }
.toast.ok { border-color: rgba(30,215,96,.45); }
.toast.err { border-color: rgba(243,114,127,.45); }
@keyframes pop { from { opacity: 0; transform: translateY(6px) } to { opacity: 1; transform: none } }

.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2));
            background-size: 200% 100%; animation: slide 1.2s linear infinite; border-radius: 8px; }

/* ---------------- 分轨工作台（P3）---------------- */
.chan {
  display: grid; gap: 8px; padding: 12px; border-radius: var(--r-card);
  background: var(--surface-2); border: 1px solid var(--hairline);
}
.chan + .chan { margin-top: 10px; }
.chan-head { display: flex; align-items: center; gap: 8px; }
.chan-name { font-weight: 650; letter-spacing: -.01em; min-width: 76px; }
.chan-btn { min-width: 34px; }
.chan-btn.on { background: var(--accent-soft); border-color: var(--accent-line); color: #c4b5fd; }
.chan[data-i] .chan-btn.on[data-act="solo"] { color: var(--warning); border-color: rgba(255,164,43,.45); background: rgba(255,164,43,.12); }
.chan-wave {
  position: relative; height: 56px; border-radius: 8px; overflow: hidden;
  background: var(--canvas-soft); border: 1px solid var(--hairline);
}
.chan-loading { padding: 16px; display: block; }
.wave-canvas { display: block; }
.playhead {
  position: absolute; top: 0; bottom: 0; width: 2px; background: #fff;
  box-shadow: 0 0 8px rgba(255,255,255,.8); pointer-events: none; transition: left .05s linear;
}
.sel-band {
  position: absolute; top: 0; bottom: 0; background: rgba(243,114,127,.22);
  border-left: 2px solid var(--error); border-right: 2px solid var(--error);
  pointer-events: none;
}
.chan-ctl {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-variant-numeric: tabular-nums;
}
.chan-ctl input[type="range"] { width: 150px; accent-color: var(--accent); }
input[type="range"] { accent-color: var(--accent); }

@media (max-width: 720px) {
  .chan-ctl input[type="range"] { width: 110px; }
  .chan-wave { height: 44px; }
  .wrap { padding: var(--s5) var(--s4) 88px; }
  h1 { font-size: 26px; }
  /* ⚠️ 2026-10-13 修手机端横幅（真机视口实测 docW 423 > vw 390 → 每页横向溢出）：
     原来是**不换行的 flex 行**且 brand/nav-link 都没锁宽，390px 下文字被压成**竖排**
     （品牌名"星河音乐工坊"一字一行、导航链接同样），最右边的退出按钮还被挤出屏幕。
     修法三条：① 横幅允许换行；② 品牌与导航链接**锁成单行**，不再被压扁；
     ③ 导航整行换到第二行，右边只留"邮箱 + 退出"。 */
  .nav { gap: var(--s3); padding: var(--s3) var(--s4); flex-wrap: wrap; }
  .brand { white-space: nowrap; font-size: 15px; }
  .brand .dot { width: 18px; height: 18px; }
  .nav-links { margin-left: 0; order: 3; width: 100%; flex-wrap: wrap; }
  .nav-link { white-space: nowrap; }
  .nav-spacer { display: none; }
}
@media (max-width: 420px) {
  /* 更窄的手机上，邮箱让位（退出按钮保留 —— 那才是要点的东西） */
  #who { display: none; }
}

