:root {
  --bg: #f6f6f4;
  --panel: #ffffff;
  --panel-2: #f1f1ee;
  --line: #e4e3df;
  --text: #1c1c1a;
  --muted: #74736d;
  --accent: #ff6a1a;
  --accent-ink: #ffffff;
  --accent-soft: #fff0e6;
  --ok: #1f9d55;
  --ok-soft: #e6f6ec;
  --warn: #b7791f;
  --warn-soft: #fdf3e1;
  --bad: #d64545;
  --bad-soft: #fdeaea;
  --info-soft: #eaf1fd;
  --info: #2f6fdb;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 4px 16px rgba(0, 0, 0, .04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121211;
    --panel: #1c1c1b;
    --panel-2: #252523;
    --line: #33332f;
    --text: #eeeee9;
    --muted: #9b9a93;
    --accent-soft: #3a2316;
    --ok-soft: #15301f;
    --warn-soft: #362a12;
    --bad-soft: #3a1a1a;
    --info-soft: #172338;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img, video { display: block; max-width: 100%; }
.boot { padding: 40vh 0; text-align: center; color: var(--muted); }

/* ------------------------------------------------------------------ layout */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px; padding-top: max(10px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: .2px; white-space: nowrap; }
.brand i { width: 26px; height: 26px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; color: #fff; font-style: normal; font-size: 13px; }
.nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; }
.nav::-webkit-scrollbar { display: none; }
.nav a { padding: 6px 12px; border-radius: 999px; color: var(--muted); white-space: nowrap; font-size: 14px; }
.nav a.on { background: var(--panel-2); color: var(--text); font-weight: 600; }
.me { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; white-space: nowrap; position: relative; }
.me-btn { display: flex; align-items: center; gap: 8px; padding: 4px 8px 4px 4px; border: 0; border-radius: 999px; background: transparent; color: inherit; font: inherit; cursor: pointer; }
.me-btn:hover, .me-btn[aria-expanded="true"] { background: var(--panel-2); }
.me-btn .caret { font-size: 10px; opacity: .7; }
.me .menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 200px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.14); padding: 6px; z-index: 50; }
.me .menu-head { display: flex; align-items: center; gap: 10px; padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.me .menu-head b { display: block; color: var(--text); font-size: 14px; }
.me .menu-head span { font-size: 12px; }
.me .menu a { display: block; padding: 9px 10px; border-radius: 8px; color: var(--text); font-size: 14px; }
.me .menu a:hover { background: var(--panel-2); }
.voice-row { display: flex; gap: 8px; align-items: center; }
.voice-row .select { flex: 1; min-width: 0; }
.voice-row .listen { flex: none; height: 38px; }
.voice-row .listen.playing { color: var(--accent); }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--panel-2); object-fit: cover; display: grid; place-items: center; font-size: 12px; color: var(--muted); flex: none; }
main { max-width: 1180px; margin: 0 auto; padding: 20px 20px 120px; }
@media (max-width: 720px) {
  .top { padding: 8px 12px; gap: 10px; }
  .brand span { display: none; }
  .me .name { display: none; }
  .nav { gap: 2px; }
  .nav a { padding: 6px 9px; }
  main { padding: 14px 12px 120px; }
}

.head { display: flex; align-items: center; gap: 12px; margin: 4px 0 16px; flex-wrap: wrap; }
.head h1 { font-size: 22px; margin: 0; letter-spacing: .2px; }
.head .sp { flex: 1; }
.sub { color: var(--muted); font-size: 13px; }
.back { color: var(--muted); font-size: 14px; display: inline-flex; align-items: center; gap: 4px; margin-bottom: 6px; }

/* ------------------------------------------------------------------ controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); cursor: pointer; white-space: nowrap; font-size: 14px; font-weight: 500;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover { background: var(--panel-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.danger { color: var(--bad); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn.lg { height: 46px; padding: 0 22px; font-size: 16px; border-radius: 12px; }
.btn.block { width: 100%; }

.input, .select, .textarea {
  width: 100%; border: 1px solid var(--line); background: var(--panel); border-radius: 10px;
  padding: 9px 12px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.textarea { resize: vertical; min-height: 44px; line-height: 1.45; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > label { font-size: 13px; color: var(--muted); font-weight: 500; }
.hint { font-size: 12px; color: var(--muted); }

.seg { display: inline-flex; background: var(--panel-2); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 6px 14px; border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--muted); }
.seg button.on { background: var(--panel); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 6px 14px;
  cursor: pointer; font-size: 14px; transition: all .15s;
}
.chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-size: 14px; }
.switch input { appearance: none; -webkit-appearance: none; width: 38px; height: 22px; border-radius: 999px; background: var(--line); position: relative; cursor: pointer; transition: background .15s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(16px); }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.run { background: var(--info-soft); color: var(--info); }
.pill.wait { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.mute { background: var(--panel-2); color: var(--muted); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.run .dot { animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .25; } }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.section { padding: 18px; margin-bottom: 16px; }
.section h2 { font-size: 16px; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.section h2 .n { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 12px; display: grid; place-items: center; }
.empty { padding: 48px 16px; text-align: center; color: var(--muted); }
.err { background: var(--bad-soft); color: var(--bad); border-radius: 10px; padding: 10px 12px; font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.note { background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: 10px 12px; font-size: 13px; }

/* ------------------------------------------------------------------ job list */
.jobs { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.job { display: flex; gap: 12px; padding: 12px; align-items: stretch; transition: transform .15s, box-shadow .15s; }
.job:hover { transform: translateY(-1px); }
.poster { width: 72px; aspect-ratio: 9 / 16; border-radius: 10px; background: var(--panel-2); object-fit: cover; flex: none; overflow: hidden; display: grid; place-items: center; color: var(--muted); font-size: 22px; }
.job .meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.job .title { font-weight: 600; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.job .row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.bar { height: 6px; border-radius: 999px; background: var(--panel-2); overflow: hidden; position: relative; }
.bar i { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 999px; transition: width .6s; }
.bar.live i::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,.45), transparent); animation: sweep 1.4s infinite; }
@keyframes sweep { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* ------------------------------------------------------------------ new job */
.refs { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); max-height: 520px; overflow-y: auto; padding: 2px; }
.ref { border: 2px solid transparent; border-radius: 12px; overflow: hidden; cursor: pointer; background: var(--panel-2); position: relative; transition: border-color .15s; text-align: left; padding: 0; }
.ref.on { border-color: var(--accent); }
.ref img { width: 100%; aspect-ratio: 9 / 16; object-fit: cover; background: var(--line); }
.ref .cap { padding: 8px; font-size: 12px; display: grid; gap: 2px; }
.ref .cap b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ref .badge { position: absolute; top: 6px; left: 6px; }
.ref .play { position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgba(0,0,0,.55); color: #fff; cursor: pointer; font-size: 12px; }
.drop { border: 2px dashed var(--line); border-radius: 12px; padding: 28px; text-align: center; color: var(--muted); cursor: pointer; display: block; }
.drop:hover { border-color: var(--accent); }
.drop input { display: none; }
.settings { display: grid; gap: 16px 24px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); align-items: start; }
.sticky-submit { position: sticky; bottom: 0; padding: 12px 0 max(12px, env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 35%); display: flex; justify-content: flex-end; gap: 12px; align-items: center; }

/* ------------------------------------------------------------------ editor */
.editor { display: grid; grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); gap: 20px; align-items: start; }
.player { position: sticky; top: 72px; }
.player video { width: 100%; aspect-ratio: 9 / 16; background: #000; border-radius: var(--radius); object-fit: contain; }
.player .actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.vtabs { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.shots { display: grid; gap: 10px; }
.shot { display: grid; grid-template-columns: 76px 1fr; gap: 12px; padding: 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); transition: border-color .15s, box-shadow .15s; }
.shot.now { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.shot.dirty { background: color-mix(in srgb, var(--accent-soft) 45%, var(--panel)); }
.thumb { width: 76px; aspect-ratio: 9 / 16; border-radius: 9px; overflow: hidden; background: var(--panel-2); position: relative; cursor: pointer; border: 0; padding: 0; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .t { position: absolute; left: 0; right: 0; bottom: 0; font-size: 11px; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.7)); padding: 10px 4px 3px; text-align: center; }
.shot .body { display: grid; gap: 6px; min-width: 0; }
.shot .line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.shot .tools { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.role { font-size: 11px; padding: 1px 7px; border-radius: 6px; background: var(--panel-2); color: var(--muted); }
.savebar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 30; display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 18px;
  background: var(--text); color: var(--bg); border-radius: 14px; box-shadow: 0 8px 30px rgba(0,0,0,.25);
  width: min(560px, calc(100% - 24px));
}
.savebar .msg { flex: 1; font-size: 14px; }
.savebar .btn.ghost { color: var(--bg); }
.savebar .btn.ghost:hover { background: rgba(255,255,255,.12); }
.busy { position: relative; }
.busy::after { content: ""; position: absolute; inset: 0; background: color-mix(in srgb, var(--bg) 55%, transparent); border-radius: var(--radius); pointer-events: all; }
.progress { padding: 18px; margin-bottom: 16px; display: grid; gap: 10px; }
.progress .stage { font-weight: 600; display: flex; justify-content: space-between; gap: 12px; }
@media (max-width: 860px) {
  .editor { grid-template-columns: minmax(0, 1fr); }
  .player { position: static; max-width: 360px; margin: 0 auto; width: 100%; }
}

/* ------------------------------------------------------------------ picker / tiles */
.tiles { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
.tile { border: 2px solid transparent; border-radius: 12px; overflow: hidden; background: var(--panel-2); cursor: pointer; text-align: left; padding: 0; position: relative; }
.tile.on { border-color: var(--accent); }
.tile img { width: 100%; aspect-ratio: 9 / 16; object-fit: cover; background: var(--line); }
.tile .d { margin: 6px 7px; font-size: 11.5px; line-height: 1.35; max-height: 2.7em; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile .flag { position: absolute; top: 5px; left: 5px; }
.preview { display: grid; grid-template-columns: 150px 1fr; gap: 14px; padding: 12px; background: var(--panel-2); border-radius: 12px; margin-bottom: 12px; align-items: start; }
.preview video, .preview img { width: 150px; aspect-ratio: 9 / 16; border-radius: 10px; background: #000; object-fit: cover; }
@media (max-width: 560px) {
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .preview { grid-template-columns: 110px 1fr; }
  .preview video, .preview img { width: 110px; }
}

/* ------------------------------------------------------------------ modal / toast */
.modal-bg { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade .15s; }
.modal { background: var(--panel); border-radius: 18px; width: min(900px, 100%); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal.narrow { width: min(420px, 100%); }
.modal header { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal header h3 { margin: 0; font-size: 16px; flex: 1; }
.modal .content { padding: 14px 16px; overflow-y: auto; }
@media (max-width: 560px) {
  .modal-bg { padding: 0; align-items: flex-end; }
  .modal { border-radius: 18px 18px 0 0; max-height: 92vh; max-height: 92dvh; }
}
@keyframes fade { from { opacity: 0; } }
.toast { position: fixed; top: 72px; left: 50%; transform: translateX(-50%); z-index: 60; background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 10px; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.2); animation: fade .2s; max-width: calc(100% - 32px); }
.toast.bad { background: var(--bad); color: #fff; }

/* ------------------------------------------------------------------ products */
.plist { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.pcard { padding: 16px; display: grid; gap: 6px; cursor: pointer; }
.pcard b { font-size: 16px; }
.listedit { display: grid; gap: 6px; }
.listedit .r { display: flex; gap: 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 720px) { .grid2 { grid-template-columns: 1fr; } }
.stats { display: flex; gap: 24px; flex-wrap: wrap; }
.stats div b { display: block; font-size: 22px; }
.stats div span { font-size: 12px; color: var(--muted); }
