/* ==========================================================================
   ds-video-svc 手机前端样式
   --------------------------------------------------------------------------
   设计约束（都是手机真机上踩出来的，不是审美偏好）：
   1. 输入框 font-size ≥ 16px  —— iOS Safari 小于 16px 会**自动放大页面**，
      放大后布局全乱、还要手动缩回去。
   2. 可点元素 ≥ 44px 高  —— 手指热区（Apple HIG 的下限）。
   3. 全部留出 env(safe-area-inset-*)  —— 刘海屏 / 底部小黑条 / 手势条。
   4. 不引用任何 CDN —— 离线可用、无供应链风险、弱网不白屏。
   5. prefers-reduced-motion —— 前庭敏感的用户不该被动画晃到。
   ========================================================================== */

:root {
  --accent: #FBBF24;          /* 品牌主色（用户指定） */
  --accent-dim: rgba(251, 191, 36, 0.14);
  --bg: #0B0B0F;
  --surface: #16161D;
  --surface-2: #1E1E27;
  --border: #2A2A35;
  --text: #EDEDF2;
  --muted: #9696A6;
  --ok: #4ADE80;
  --warn: #FBBF24;
  --err: #F87171;
  --radius: 14px;
  --tabbar-h: 58px;
}

* { box-sizing: border-box; }

/* ★ [hidden] 必须写 !important。
     UA 样式表里的 `[hidden] { display: none }` 会被**作者样式表**里任何
     带 display 的类覆盖（.icon-btn{display:grid} / .toast{position:fixed}…），
     表现为"设了 hidden 但元素还在屏幕上"。
     特性相同、作者表赢 ⇒ 只能靠 !important 压住。 */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: 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.55;
  /* 禁掉 iOS 的点击高亮方块（默认是一块灰色方，很脏） */
  -webkit-tap-highlight-color: transparent;
  /* 禁掉下拉刷新/橡皮筋：这是应用，不是网页 */
  overscroll-behavior-y: none;
}

/* iOS 上 body 固定高会让地址栏收起时抖动，改用 min-height */
body, html { min-height: 100%; }

/* 键盘可达性：焦点环必须看得见 */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------------------------------------------------------------- 顶栏 */
.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(11, 11, 15, 0.88);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
  padding: calc(env(safe-area-inset-top) + 10px) 16px 8px;
}

.appbar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
}

.appbar-title {
  font-size: 17px;
  font-weight: 700;
  margin: 0;
  letter-spacing: .2px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  min-width: 34px;
  display: grid;
  place-items: center;
  font-size: 26px;
  line-height: 1;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  padding: 0;
}
.icon-btn:active { background: var(--accent-dim); }

.health {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  min-height: 18px;
}

.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
}
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px rgba(74, 222, 128, .15); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 3px rgba(251, 191, 36, .15); }
.dot.err { background: var(--err); box-shadow: 0 0 0 3px rgba(248, 113, 113, .15); }

.health-queue { margin-left: auto; color: var(--muted); }

/* ---------------------------------------------------------------- 主体 */
#main {
  padding: 14px 14px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 20px);
  max-width: 720px;
  margin: 0 auto;
}

.view { animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.field { margin-bottom: 16px; }
.field:last-of-type { margin-bottom: 4px; }

.label {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 7px;
  letter-spacing: .3px;
}
.req { color: var(--accent); }
.value { margin-left: auto; color: var(--accent); font-size: 14px; font-weight: 700; }

.input {
  width: 100%;
  /* ★ 16px 是硬下限：iOS Safari <16px 会自动放大页面 */
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
  min-height: 46px;
  appearance: none;
  -webkit-appearance: none;
}
.input::placeholder { color: #6C6C7A; }
.input:focus { border-color: var(--accent); background: #1B1B23; }

.textarea { min-height: 92px; resize: vertical; line-height: 1.5; }

select.input {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%239696A6' d='M1 1l5 5 5-5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}

.hint {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

/* 滑块 */
.slider {
  width: 100%;
  height: 40px;                 /* 加高命中区，但视觉上靠 accent-color 表现 */
  accent-color: var(--accent);
  background: transparent;
  margin: 0;
}

.chips { display: flex; gap: 8px; margin-top: 6px; }
.chip {
  flex: 1;
  min-height: 36px;
  font-size: 14px;
  font-family: inherit;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  cursor: pointer;
  padding: 0 4px;
}
.chip[aria-pressed="true"] {
  color: var(--accent);
  background: var(--accent-dim);
  border-color: rgba(251, 191, 36, .45);
  font-weight: 700;
}

.form-error {
  margin: 0 0 12px;
  padding: 10px 12px;
  font-size: 13px;
  color: #FECACA;
  background: rgba(248, 113, 113, .12);
  border: 1px solid rgba(248, 113, 113, .35);
  border-radius: 10px;
}

.btn-primary {
  width: 100%;
  min-height: 52px;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  color: #1A1405;
  background: var(--accent);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  margin-top: 4px;
}
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: .55; cursor: default; }

.btn-ghost {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
  font-family: inherit;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 9px;
  cursor: pointer;
}
.btn-ghost:active { color: var(--accent); }

.btn-row { display: flex; gap: 10px; margin-top: 14px; }
.btn-row .btn-ghost { flex: 1; min-height: 44px; font-size: 14px; }

/* ---------------------------------------------------------------- 列表 */
.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.section-title { font-size: 15px; font-weight: 700; margin: 0; }

.job-list { display: flex; flex-direction: column; gap: 10px; }

.job-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 14px;
  cursor: pointer;
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 62px;
}
.job-card:active { background: var(--surface-2); }

.job-main { flex: 1; min-width: 0; }
.job-topic {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.job-meta {
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--muted);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  flex: none;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge.queued, .badge.prompt_ready, .badge.submitting { color: #A5B4FC; background: rgba(165,180,252,.12); border-color: rgba(165,180,252,.3); }
.badge.prompting, .badge.rendering, .badge.downloading { color: var(--accent); background: var(--accent-dim); border-color: rgba(251,191,36,.35); }
.badge.done { color: var(--ok); background: rgba(74,222,128,.12); border-color: rgba(74,222,128,.3); }
.badge.failed { color: var(--err); background: rgba(248,113,113,.12); border-color: rgba(248,113,113,.32); }
.badge.cancelled { color: var(--muted); background: rgba(150,150,166,.12); border-color: rgba(150,150,166,.28); }

.empty {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 40px 16px;
}

/* ---------------------------------------------------------------- 详情 */
.detail-title {
  font-size: 17px;
  font-weight: 700;
  margin: 0 0 3px;
  line-height: 1.4;
  word-break: break-word;
}
.detail-sub { font-size: 12px; color: var(--muted); margin-bottom: 14px; }

.section-title-s {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  margin: 18px 0 9px;
  letter-spacing: .4px;
}

/* 进度步骤条（竖排：手机上横排放不下 6 步） */
.steps { display: flex; flex-direction: column; }
.step { display: flex; gap: 12px; }
.step-rail { display: flex; flex-direction: column; align-items: center; width: 20px; flex: none; }
.step-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 2px solid var(--border);
  margin-top: 4px;
  flex: none;
}
.step-line { flex: 1; width: 2px; background: var(--border); min-height: 22px; }
.step:last-child .step-line { display: none; }
.step.done .step-dot { background: var(--ok); border-color: var(--ok); }
.step.done .step-line { background: rgba(74,222,128,.45); }
.step.active .step-dot {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-dim);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 3px var(--accent-dim); } 50% { box-shadow: 0 0 0 7px rgba(251,191,36,.05); } }
.step.failed .step-dot { background: var(--err); border-color: var(--err); animation: none; }
.step.cancelled .step-dot { background: var(--muted); border-color: var(--muted); animation: none; }

.step-body { padding-bottom: 14px; min-width: 0; }
.step-name { font-size: 14px; font-weight: 600; }
.step-note { font-size: 11.5px; color: var(--muted); margin-top: 1px; }

/* 视频 */
.video-wrap {
  background: #000;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  justify-content: center;
}
.video-wrap video {
  width: 100%;
  max-width: 420px;
  max-height: 68vh;
  display: block;
  background: #000;
}

/* 提示词 */
.prompt-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  font-size: 12.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 320px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #D6D6E0;
}

.err-box {
  background: rgba(248,113,113,.1);
  border: 1px solid rgba(248,113,113,.32);
  border-radius: 10px;
  padding: 12px;
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  color: #FECACA;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.kv { display: flex; gap: 10px; font-size: 12.5px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.kv:last-child { border-bottom: none; }
.kv-k { color: var(--muted); width: 76px; flex: none; }
.kv-v { color: var(--text); word-break: break-all; min-width: 0; }

/* ---------------------------------------------------------------- 底部导航 */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  display: flex;
  background: rgba(16,16,22,.94);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1;
  min-height: var(--tabbar-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: none;
  border: none;
  color: var(--muted);
  font-family: inherit;
  cursor: pointer;
  padding: 0;
}
.tab-icon { font-size: 19px; line-height: 1; }
.tab-text { font-size: 11px; }
.tab[aria-selected="true"] { color: var(--accent); }

/* ---------------------------------------------------------------- 提示条 */
.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
  z-index: 50;
  background: #26262F;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 13px;
  max-width: calc(100vw - 32px);
  text-align: center;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
  animation: fade .16s ease-out;
}

/* ---------------------------------------------------------------- 无障碍 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* 屏幕再窄（iPhone SE 320px）也不塌 */
@media (max-width: 340px) {
  .chip { font-size: 13px; }
  #main { padding-left: 10px; padding-right: 10px; }
}
