/* 切片工作台 · 设计令牌与基础样式
   色彩、字体、版式的依据见 docs/设计说明.md */

:root {
  --paper: #f6f4ee;
  --surface: #ffffff;
  --ink: #1c1f1c;
  --muted: #6b7269;
  --line: #e2ded4;
  --green: #0f5132;
  --mint: #e3f0e8;
  --hl: #ffe176;
  --amber: #9a5b00;
  --amber-bg: #fff1d9;
  --danger: #b3261e;
  --danger-bg: #fbe5e3;
  --stage: #14201a;
  --radius: 10px;
  --font: system-ui, "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 22px; line-height: 1.25; letter-spacing: -.01em; }
h2 { font-size: 16px; line-height: 1.35; }
h3 { font-size: 14px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--green); }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); font-size: 13px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- 布局骨架：手机底栏，宽屏左侧栏 ---------- */
.app { display: grid; grid-template-rows: auto 1fr auto; min-height: 100dvh; }
/* 防止长标题、长原话把页面撑宽（手机上出现左右滚动） */
.app, .main, .view, .stack, .card, .item, .item-main { min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 650; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: var(--green); color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 800; }
.topbar-side { display: inline-flex; align-items: center; gap: 10px; }
.main { padding: 14px 13px 22px; min-width: 0; }
.nav {
  /* 手机底栏：吸附在视口底部，内容再长也不用滚到底才看到导航。列数按实际入口数量 */
  position: sticky; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 2px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: var(--surface);
  border-top: 1px solid var(--line);
}
.nav button {
  display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 46px;
  padding: 6px 0; border: 0; background: transparent; color: var(--muted); border-radius: 8px; font-size: 12px;
}
.nav button[aria-current="page"] { color: var(--green); background: var(--mint); font-weight: 650; }
.nav svg { width: 19px; height: 19px; }
.btn svg { width: 16px; height: 16px; }
/* 行内小箭头：不限定尺寸的 svg 会撑满整行，把卡片拉得很高 */
.item-link > svg, .btn > svg, .item > svg { flex: 0 0 auto; }
.item-link > svg, .item > svg { width: 15px; height: 15px; color: var(--muted); }

@media (min-width: 760px) {
  .app { grid-template-columns: 196px minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .topbar { grid-column: 1 / -1; }
  .nav {
    position: static; z-index: auto;
    grid-column: 1; grid-row: 2; grid-template-columns: 1fr; align-content: start; gap: 3px;
    padding: 14px 10px; border-top: 0; border-right: 1px solid var(--line);
  }
  .nav button { flex-direction: row; justify-content: flex-start; gap: 9px; padding: 10px 12px; font-size: 14px; }
  .main { grid-column: 2; grid-row: 2; padding: 22px 26px 40px; max-width: 1180px; }
}

/* ---------- 通用组件 ---------- */
.stack { display: grid; gap: 12px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 14px; }
.list { display: grid; gap: 0; padding: 0; }
.list > * + * { border-top: 1px solid var(--line); }
.item { padding: 11px 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.item-main { min-width: 0; flex: 1 1 auto; overflow-wrap: anywhere; }
.item strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item > .btn { flex: 0 0 auto; }
.item-link { display: block; width: 100%; text-align: left; border: 0; background: transparent; color: inherit; }
.item-link:hover strong { color: var(--green); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-weight: 500; text-decoration: none;
}
.btn:hover { border-color: #c9c3b6; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--green); border-color: var(--green); color: #fff; font-weight: 650; }
.btn-primary:hover { background: #0c4229; border-color: #0c4229; }
.btn-quiet { border-color: transparent; background: transparent; color: var(--green); min-height: 36px; padding: 6px 8px; }
.btn-quiet:hover { background: var(--mint); border-color: transparent; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-sm { min-height: 34px; padding: 5px 10px; font-size: 13px; }
.btn-sm svg { width: 14px; height: 14px; }

.tag {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px;
  font-size: 12px; color: var(--muted); background: var(--paper); white-space: nowrap;
}
.tag-good { color: var(--green); background: var(--mint); }
.tag-amber { color: var(--amber); background: var(--amber-bg); }
.tag-bad { color: var(--danger); background: var(--danger-bg); }
.tag-hl { color: #6b4e00; background: var(--hl); }

.field { display: grid; gap: 5px; }
.field > span { font-size: 13px; color: var(--muted); }
/* 并排的字段按底部对齐：标题行字数不同时，两个控件仍然在同一水平线上 */
.row > .field { align-self: flex-end; }
.field-sm { flex: 0 1 190px; min-width: 150px; }
input[type="text"], input[type="password"], input[type="search"], select, textarea {
  width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--surface); font-size: 16px;
}
textarea { resize: vertical; min-height: 76px; }
.choice { display: flex; align-items: center; gap: 9px; min-height: 44px; }
.choice input { width: 18px; height: 18px; accent-color: var(--green); flex: 0 0 18px; }

.notice { background: var(--mint); border-color: #c6dfd1; }
.warning { background: var(--amber-bg); border-color: #f0d9ab; }
.error-text { color: var(--danger); font-size: 13px; }

.empty { padding: 22px 14px; text-align: center; color: var(--muted); }
.page-head { display: grid; gap: 3px; margin-bottom: 14px; }
.page-head p { color: var(--muted); }
/* 作为 grid 子项的按钮默认会被拉伸到整行宽，文字跟着居中；这里让它按内容宽度靠左 */
.back { align-self: start; justify-self: start; margin: -4px 0 0 -8px; }

/* ---------- 登录 ---------- */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login { width: min(100%, 380px); display: grid; gap: 14px; }
.login h1 { font-size: 24px; }
.login-mark { width: 44px; height: 44px; border-radius: 12px; background: var(--green); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 20px; }

/* ---------- 视频 ---------- */
.player { background: var(--stage); border-radius: var(--radius); overflow: hidden; aspect-ratio: 9 / 16; max-height: 72dvh; width: auto; justify-self: center; }
.player video { display: block; width: 100%; height: 100%; object-fit: contain; }
.modes { display: flex; gap: 4px; padding: 3px; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; }
.modes button { flex: 1; min-height: 38px; border: 0; background: transparent; border-radius: 6px; color: var(--muted); }
.modes button[aria-pressed="true"] { background: var(--surface); color: var(--green); font-weight: 650; box-shadow: 0 1px 2px rgba(0, 0, 0, .06); }

/* ---------- 原片话术：逐句定位与选段 ---------- */
.lines { max-height: 56dvh; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.line {
  display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 8px; width: 100%;
  padding: 9px 10px; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left;
}
.line:last-child { border-bottom: 0; }
.line .mono { color: var(--muted); font-size: 12px; padding-top: 3px; }
.line[aria-current="true"] { background: var(--mint); color: var(--green); }
.line.picked { background: var(--hl); color: #3d3000; }
.line:hover { background: var(--paper); }

/* ---------- 黄金开头：原话当标题 ---------- */
.quote { font-size: 18px; font-weight: 600; line-height: 1.45; letter-spacing: -.005em; }
.quote-lg { font-size: 21px; }
.tc { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
.opening-row { width: 100%; text-align: left; border: 0; background: transparent; padding: 11px 14px; display: grid; gap: 4px; }
.opening-row[aria-pressed="true"] { background: var(--mint); }
.opening-row:hover { background: var(--paper); }

/* ---------- 任务进度 ---------- */
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.steps li { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 7px 0; color: var(--muted); }
.steps li[data-state="done"] { color: var(--ink); }
.steps li[data-state="current"] { color: var(--green); font-weight: 650; }
.steps li[data-state="interrupted"], .steps li[data-state="stopped"] { color: var(--amber); font-weight: 650; }
.dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; display: inline-block; }
.dot-fill { background: currentColor; }
.dot-spin { border-top-color: transparent; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.bar { height: 4px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--green); transition: width .4s ease; }
.events { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; font-size: 13px; color: var(--muted); max-height: 220px; overflow-y: auto; }
.events li { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 8px; }
.events .mono { white-space: nowrap; }
/* 带日期的记录（管理页的巡检记录）：时间是「12/06 12:28」，列要放得下，否则日期和时间会折成两行 */
.events-dated li { grid-template-columns: 82px minmax(0, 1fr); }

/* ---------- 首页两栏（宽屏） ---------- */
.two { display: grid; gap: 14px; }
/* 播放器 + 操作区：手机上视频在上、操作在下；宽屏左右两栏 */
.review-grid { display: grid; gap: 14px; min-width: 0; }
@media (min-width: 760px) {
  .two { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); align-items: start; }
  .review-grid { grid-template-columns: minmax(0, auto) minmax(0, 1fr); align-items: start; }
}
.health { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; }
.online::before, .offline::before { content: ""; width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 5px; }
.online::before { background: var(--green); }
.offline::before { background: var(--danger); }
.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.copy { display: grid; gap: 6px; }
.copy textarea { font-size: 14px; min-height: 58px; }
.copy .btn { justify-self: start; }
/* ---------- 成员：我的视频 ---------- */
/* 选好的视频文件：显示文件名和大小 */
input[type="file"] { padding: 8px; font-size: 14px; }
input[type="file"]::file-selector-button {
  min-height: 32px; margin-right: 10px; padding: 5px 12px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--paper); color: var(--ink); font: inherit; cursor: pointer;
}
input[type="file"]::file-selector-button:hover { border-color: #c9c3b6; }
/* 上传页的说明：一行一条，留出行距 */
.notes { margin: 8px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; display: grid; gap: 4px; }
/* 黄金开头：已经用在成片里的、或者额度用完的，整条变淡且不可点 */
.opening-row:disabled { opacity: .55; cursor: default; }
.opening-row:disabled:hover { background: transparent; }
.opening-row[data-action="mine-pick"]:hover { background: var(--mint); }
/* 开头行里的「已用 / 可选」标签：不让它被挤到折行 */
.opening-row .tag { flex: 0 0 auto; }
/* 列表底下的提交条：手机上吸附在底栏上方，列表再长也随时能点；宽屏回到普通的一行 */
.action-bar { position: sticky; bottom: calc(66px + env(safe-area-inset-bottom)); z-index: 15; margin-bottom: -6px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px; margin-top: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 -4px 14px rgba(28, 31, 28, .07); }
.action-bar .btn { flex: 1 1 auto; }
@media (min-width: 760px) { .action-bar { position: static; box-shadow: none; } .action-bar .btn { flex: 0 0 auto; } }
/* 表单里的主按钮：手机上通栏好点按；宽屏按内容宽，不拉成一整条 */
.form-card { max-width: 560px; }
@media (min-width: 760px) { .form-card > .btn { justify-self: start; } }
.toast {
  position: fixed; left: 50%; bottom: calc(78px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 14px;
  max-width: min(92vw, 420px); z-index: 50; box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
}
.toast.err { background: var(--danger); }
@media (min-width: 760px) { .toast { bottom: 24px; } }
.view { animation: fade .16s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .view { animation: none; } .dot-spin { animation: none; } .bar > i { transition: none; } }
