/* ============================================================
   StepFun 语音体验站 - 共享样式（移动端优先）
   ============================================================ */

:root {
  --bg: #0a0d14;
  --bg-soft: #0f1420;
  --surface: #151b2b;
  --surface-2: #1b2336;
  --line: #263050;
  --text: #e8ecf5;
  --text-dim: #9aa6c0;
  --text-faint: #6b7690;
  --accent: #6c8cff;
  --accent-2: #38d9d9;
  --accent-grad: linear-gradient(135deg, #6c8cff 0%, #38d9d9 100%);
  --danger: #ff6b7a;
  --warn: #ffb054;
  --ok: #3ddc97;
  --radius: 16px;
  --radius-sm: 10px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(108, 140, 255, .14), transparent 60%),
    radial-gradient(900px 500px at -10% 30%, rgba(56, 217, 217, .10), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }

.wrap { max-width: 880px; margin: 0 auto; padding: 0 16px calc(24px + var(--safe-b)); }

/* ---------- 顶部栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  background: rgba(10, 13, 20, .82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar .back {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 10px; flex: none;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
  font-size: 18px;
}
.topbar .back:active { transform: scale(.94); }
.topbar .tt { font-size: 16px; font-weight: 700; letter-spacing: .2px; }
.topbar .sub { font-size: 12px; color: var(--text-dim); font-weight: 400; margin-left: 2px; }
.topbar .spacer { flex: 1; }
.topbar .pill {
  font-size: 11px; color: var(--accent-2);
  border: 1px solid rgba(56, 217, 217, .35); background: rgba(56, 217, 217, .08);
  padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}

/* ---------- 首页 ---------- */
.hero { padding: 40px 4px 10px; text-align: center; }
.hero h1 {
  margin: 0 0 10px; font-size: clamp(26px, 6vw, 40px); font-weight: 800; letter-spacing: .5px;
  background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p { margin: 0 auto; max-width: 560px; color: var(--text-dim); font-size: 14px; }
.hero .badges { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 16px; }
.hero .badges span {
  font-size: 12px; color: var(--text-dim); border: 1px solid var(--line);
  background: var(--surface); padding: 4px 12px; border-radius: 999px;
}

.cards { display: grid; grid-template-columns: 1fr; gap: 14px; margin-top: 26px; }
@media (min-width: 640px) { .cards { grid-template-columns: 1fr 1fr; } }
@media (min-width: 900px) { .cards { grid-template-columns: repeat(3, 1fr); } }

.card {
  display: flex; flex-direction: column; gap: 10px;
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg-soft) 100%);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 16px 16px; position: relative; overflow: hidden;
  transition: transform .15s ease, border-color .15s ease;
}
.card:active { transform: scale(.985); border-color: var(--accent); }
.card .icon {
  width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  background: var(--accent-grad); font-size: 22px; flex: none;
  box-shadow: 0 6px 18px rgba(108, 140, 255, .25);
}
.card h3 { margin: 0; font-size: 17px; }
.card .model-id { font-size: 11px; color: var(--accent-2); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }
.card .desc { margin: 0; font-size: 13px; color: var(--text-dim); }
.card ul { margin: 2px 0 0; padding-left: 18px; }
.card li { font-size: 12.5px; color: var(--text-faint); margin: 2px 0; }
.card .go {
  margin-top: auto; padding-top: 8px;
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--accent); font-size: 14px; font-weight: 600;
}
.card .tag-free { position: absolute; top: 12px; right: 12px; font-size: 10px; color: var(--ok); border: 1px solid rgba(61,220,151,.4); border-radius: 999px; padding: 2px 8px; background: rgba(61,220,151,.07); }

.footer { margin-top: 34px; padding: 18px 4px 8px; border-top: 1px solid var(--line); color: var(--text-faint); font-size: 12px; text-align: center; }
.footer a { color: var(--text-dim); }

/* ---------- 通用组件 ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-top: 14px;
}
.panel h2 { margin: 0 0 4px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.panel .hint { margin: 0 0 12px; font-size: 12px; color: var(--text-faint); }

label.field { display: block; margin-top: 12px; }
label.field .lab { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
label.field .lab .cnt { font-size: 11px; color: var(--text-faint); font-family: ui-monospace, Menlo, monospace; }

input[type="text"], input[type="number"], textarea, select {
  width: 100%; background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 11px 12px; font-size: 16px; /* 防 iOS 聚焦缩放 */
  font-family: inherit; outline: none; appearance: none;
}
textarea { resize: vertical; min-height: 84px; line-height: 1.55; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
select { background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%), linear-gradient(135deg, var(--text-dim) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
input[type="range"] { width: 100%; accent-color: var(--accent); height: 28px; }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 480px) { .row { grid-template-columns: 1fr; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 10px 18px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); font-size: 15px; font-weight: 600;
  cursor: pointer; user-select: none; transition: transform .12s ease, opacity .12s;
  font-family: inherit;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn.primary { background: var(--accent-grad); border: none; color: #06121f; }
.btn.block { width: 100%; }
.btn.danger { background: rgba(255, 107, 122, .14); border-color: rgba(255, 107, 122, .45); color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: 13px; border-radius: 9px; }

.tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs .tab {
  flex: none; padding: 8px 14px; border-radius: 999px; font-size: 13.5px; cursor: pointer;
  background: var(--bg-soft); border: 1px solid var(--line); color: var(--text-dim); white-space: nowrap;
}
.tabs .tab.on { background: var(--accent-grad); color: #06121f; border-color: transparent; font-weight: 700; }

audio { width: 100%; height: 44px; margin-top: 10px; border-radius: 10px; }

.status {
  display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-dim);
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px;
}
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); flex: none; }
.status.ok .dot { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.status.busy .dot { background: var(--warn); animation: blink 1s infinite; }
.status.err .dot { background: var(--danger); }
@keyframes blink { 50% { opacity: .25; } }

.toast {
  position: fixed; left: 50%; bottom: calc(28px + var(--safe-b)); transform: translateX(-50%) translateY(20px);
  background: #222b40; border: 1px solid var(--line); color: var(--text);
  padding: 11px 18px; border-radius: 12px; font-size: 13.5px; z-index: 999;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: 86vw; text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: rgba(255, 107, 122, .5); color: var(--danger); }

.spin {
  width: 16px; height: 16px; border: 2px solid rgba(255, 255, 255, .25); border-top-color: #fff;
  border-radius: 50%; animation: rot .8s linear infinite; display: inline-block; vertical-align: -3px;
}
@keyframes rot { to { transform: rotate(360deg); } }

.note { font-size: 12px; color: var(--text-faint); margin-top: 10px; line-height: 1.7; }
.note.warn { color: var(--warn); }

/* 语音波形动画 */
.wave { display: inline-flex; align-items: flex-end; gap: 3px; height: 18px; }
.wave i { width: 3px; background: var(--accent-2); border-radius: 2px; height: 4px; }
.wave.on i { animation: eq .9s ease-in-out infinite; }
.wave.on i:nth-child(1) { animation-delay: 0s; }
.wave.on i:nth-child(2) { animation-delay: .15s; }
.wave.on i:nth-child(3) { animation-delay: .3s; }
.wave.on i:nth-child(4) { animation-delay: .45s; }
.wave.on i:nth-child(5) { animation-delay: .6s; }
@keyframes eq { 0%, 100% { height: 4px; } 50% { height: 18px; } }

/* ---------- 对话界面（Realtime） ---------- */
.chat { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; padding-bottom: 8px; }
.msg { max-width: 86%; padding: 10px 14px; border-radius: 16px; font-size: 14.5px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; }
.msg.user { align-self: flex-end; background: linear-gradient(135deg, #2b3f7a, #274a7d); border-bottom-right-radius: 4px; }
.msg.ai { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.sys { align-self: center; background: transparent; color: var(--text-faint); font-size: 12px; padding: 2px 10px; }
.msg .who { display: block; font-size: 11px; color: var(--text-faint); margin-bottom: 3px; }

.micbar { position: sticky; bottom: 0; z-index: 40; margin-top: 14px; padding: 12px 0 calc(6px + var(--safe-b)); background: linear-gradient(180deg, transparent, var(--bg) 35%); }
.mic-btn {
  width: 100%; min-height: 58px; border-radius: 16px; border: none; cursor: pointer;
  background: var(--accent-grad); color: #06121f; font-size: 16.5px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  box-shadow: 0 10px 28px rgba(108, 140, 255, .35); transition: transform .12s;
  font-family: inherit;
}
.mic-btn:active { transform: scale(.98); }
.mic-btn.live { background: linear-gradient(135deg, #ff6b7a, #ff9a54); box-shadow: 0 10px 28px rgba(255, 107, 122, .35); animation: pulse 1.6s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 10px 28px rgba(255, 107, 122, .35); } 50% { box-shadow: 0 10px 38px rgba(255, 107, 122, .65); } }

.textbar { display: flex; gap: 8px; margin-top: 10px; }
.textbar input { flex: 1; }

/* ---------- 角色/剧本编辑器 ---------- */
.dyn-row { display: grid; gap: 8px; grid-template-columns: 1fr 1.6fr auto; align-items: start; margin-bottom: 8px; }
@media (max-width: 560px) { .dyn-row { grid-template-columns: 1fr; } }
.dyn-row .del { align-self: stretch; min-width: 42px; color: var(--danger); background: rgba(255, 107, 122, .1); border-color: rgba(255, 107, 122, .35); }
.dyn-row select { font-size: 14px; }

/* ---------- 字幕 ---------- */
.subs { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; }
.sub-item { font-size: 13.5px; color: var(--text-faint); padding: 7px 11px; border-radius: 10px; background: var(--bg-soft); border: 1px solid transparent; transition: all .15s; }
.sub-item.on { color: var(--text); border-color: var(--accent); background: rgba(108, 140, 255, .1); }
.sub-item .w { transition: color .1s; }
.sub-item .w.on { color: var(--accent-2); font-weight: 700; }

/* ---------- 进度 ---------- */
.progress { height: 6px; background: var(--bg-soft); border-radius: 999px; overflow: hidden; margin-top: 12px; }
.progress i { display: block; height: 100%; width: 40%; background: var(--accent-grad); border-radius: 999px; animation: slide 1.4s ease-in-out infinite; }
@keyframes slide { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }

.kv { display: flex; gap: 8px; font-size: 12.5px; margin-top: 6px; }
.kv b { color: var(--text-dim); font-weight: 600; flex: none; }
.kv span { color: var(--text-faint); word-break: break-all; }

pre.code {
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px; font-size: 12px; overflow-x: auto; color: var(--text-dim);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; line-height: 1.6; white-space: pre-wrap; word-break: break-all;
}
