:root {
  --bg: #ffffff; --bg2: #f6f6f7; --bg3: #f2f2f7; --line: #e5e5e7; --line2: #d2d2d7;
  --text: #1c1c1e; --text2: #6e6e73; --text3: #8e8e93;
  --accent: #007aff; --accent-bg: #e5f0ff; --accent-text: #0a5bd3;
  --ok-bg: #e3f6e8; --ok: #1f7a38; --warn-bg: #fff1d6; --warn: #9a5b00; --err-bg: #fde8e8; --err: #b42318;
  --hl: #ffe58a; --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1c1e; --bg2: #232326; --bg3: #000000; --line: #38383a; --line2: #48484a;
    --text: #f2f2f7; --text2: #aeaeb2; --text3: #8e8e93;
    --accent: #0a84ff; --accent-bg: #0b2a4d; --accent-text: #6cb4ff;
    --ok-bg: #12351f; --ok: #6fdc8c; --warn-bg: #3d2c08; --warn: #ffc95c; --err-bg: #3d1414; --err: #ff8a80; --hl: #6b5a12;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-text); text-decoration: none; }
svg.i { width: 1.1em; height: 1.1em; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.18em; flex: none; }
.muted { color: var(--text3); }
.sec { color: var(--text2); }
mark { background: var(--hl); color: inherit; border-radius: 2px; padding: 0 1px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 0 14px; border-radius: 9px;
  border: 1px solid var(--line2); background: var(--bg); cursor: pointer; white-space: nowrap; font-size: 15px; }
.btn:hover { background: var(--bg2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--err); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { min-height: 32px; padding: 0 10px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: default; }
input.field, select.field, textarea.field { width: 100%; min-height: 40px; padding: 8px 11px; border: 1px solid var(--line2); border-radius: 8px; background: var(--bg); font-size: 16px; }
textarea.field { min-height: 70px; resize: vertical; }
.field:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.chip { display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line2);
  font-size: 14px; color: var(--text2); background: var(--bg); white-space: nowrap; cursor: pointer; }
.chip.on { background: var(--accent-bg); border-color: transparent; color: var(--accent-text); }
.pill { font-size: 13px; font-weight: 500; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.p-done { background: var(--ok-bg); color: var(--ok); }
.p-review, .p-error { background: var(--warn-bg); color: var(--warn); }
.p-error { background: var(--err-bg); color: var(--err); }
.p-queued, .p-processing { background: var(--accent-bg); color: var(--accent-text); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.err { color: var(--err); font-size: 14px; }
.empty { padding: 48px 24px; text-align: center; color: var(--text2); line-height: 1.7; }

/* ---------- layout ---------- */
.shell { display: flex; height: 100dvh; }
.sidebar { width: 250px; flex: none; background: var(--bg2); border-right: 1px solid var(--line); padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.brand { font-weight: 600; font-size: 18px; padding: 6px 10px 14px; display: flex; align-items: center; gap: 8px; }
.sb-h { font-size: 13px; font-weight: 600; color: var(--text3); padding: 16px 10px 6px; }
.sb-i { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--text); font-size: 15px; cursor: pointer; }
.sb-i:hover { background: var(--line); }
.sb-i .n { margin-left: auto; color: var(--text3); font-size: 14px; }
.sb-i.on { background: var(--accent-bg); color: var(--accent-text); font-weight: 500; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 60px; flex: none; display: flex; align-items: center; gap: 12px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.search { flex: 1; max-width: 720px; display: flex; align-items: center; gap: 8px; height: 40px; border: 1px solid var(--line2); border-radius: 10px; padding: 0 12px; background: var(--bg); }
.search input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 16px; min-width: 0; }
.panes { flex: 1; display: flex; min-height: 0; }
.list { width: 520px; flex: none; border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.filters { display: flex; gap: 6px; padding: 10px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; align-items: center; }
.count { padding: 8px 16px; font-size: 14px; color: var(--text3); display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); }
.rows { overflow-y: auto; flex: 1; }
.row { display: flex; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--line); align-items: center; cursor: pointer; }
.row:hover { background: var(--bg2); }
.row.on { background: var(--accent-bg); }
.thumb { width: 88px; aspect-ratio: 90/54; object-fit: cover; border-radius: 4px; background: var(--bg3); flex: none; box-shadow: 0 0 0 1px var(--line); }
.row .nm { font-size: 16px; font-weight: 600; }
.row .nm span { font-weight: 400; color: var(--text2); margin-left: 6px; }
.row .sub { font-size: 14px; color: var(--text2); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .meta { font-size: 13px; color: var(--text3); margin-top: 3px; display: flex; gap: 8px; }
.row .g { flex: 1; min-width: 0; }
.detail { flex: 1; min-width: 0; overflow-y: auto; padding: 22px 28px 40px; }
.tabbar { display: none; }

/* ---------- card detail ---------- */
.sides { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.side img { width: 100%; border-radius: 6px; box-shadow: 0 0 0 1px var(--line); display: block; background: var(--bg3); cursor: zoom-in; }
.side .cap { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--text3); margin-top: 6px; gap: 6px; }
.side .tools { display: flex; gap: 2px; }
.head { margin: 20px 0 14px; }
.head h1 { font-size: 28px; font-weight: 600; margin: 0; }
.head h1 span { font-size: 18px; color: var(--text2); font-weight: 400; margin-left: 10px; }
.head .t { font-size: 15px; color: var(--text2); margin-top: 6px; line-height: 1.5; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; }
.kv { display: grid; grid-template-columns: 120px 1fr; border-top: 1px solid var(--line); }
.kv > div { padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 16px; overflow-wrap: anywhere; }
.kv .k { color: var(--text3); font-size: 15px; }
.kv .warn { background: var(--warn-bg); }
.reviewbox { background: var(--warn-bg); color: var(--warn); border-radius: 10px; padding: 12px 14px; margin: 14px 0; font-size: 15px; line-height: 1.6; }
.reviewbox b { font-weight: 600; }
.note { margin-top: 16px; background: var(--bg2); border-radius: 8px; padding: 12px 14px; white-space: pre-wrap; line-height: 1.6; }
.foot { margin-top: 14px; font-size: 13px; color: var(--text3); display: flex; flex-wrap: wrap; gap: 6px 18px; }
.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 6px; font-size: 14px; color: var(--text2); }
.form .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.subform { border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: grid; gap: 8px; }
.phone-row { display: grid; grid-template-columns: 110px 1fr 90px 36px; gap: 8px; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: flex; align-items: center; justify-content: center; z-index: 50; cursor: zoom-out; }
.lightbox img { max-width: 96vw; max-height: 92vh; }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 40; }
.modal { background: var(--bg); border-radius: 14px; padding: 20px; width: min(640px, 94vw); max-height: 86vh; overflow-y: auto; }

/* ---------- capture ---------- */
.capture { flex: 1; display: flex; min-height: 0; }
.cap-main { flex: 1; display: flex; flex-direction: column; gap: 12px; padding: 16px 18px; min-width: 0; }
.cap-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: 9px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 7px 14px; cursor: pointer; font-size: 15px; }
.seg button.on { background: var(--text); color: var(--bg); }
.viewer { position: relative; flex: 1; min-height: 300px; background: #111; border-radius: 12px; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.viewer video { max-width: 100%; max-height: 100%; }
.guide { position: absolute; aspect-ratio: 90/54; width: min(78%, 120vh); border: 3px dashed rgba(255,214,10,.85); border-radius: 12px; pointer-events: none; }
.badge { position: absolute; top: 14px; left: 14px; background: rgba(0,0,0,.6); color: #fff; border-radius: 999px; padding: 7px 14px; font-size: 15px; }
.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; transition: opacity .25s; }
.flash.go { opacity: .8; transition: none; }
.shoot { min-height: 48px; padding: 0 26px; font-size: 17px; font-weight: 600; }
.kbd { font-size: 12px; border: 1px solid var(--line2); border-radius: 4px; padding: 1px 6px; color: var(--text2); }
.cap-side { width: 430px; flex: none; border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.cap-side h3 { font-size: 15px; margin: 0; padding: 16px 18px 10px; display: flex; justify-content: space-between; }
.tray { overflow-y: auto; flex: 1; }
.tray .row { padding: 9px 18px; }
.tray .thumb { width: 70px; }
.drop { margin: 14px 18px 18px; border: 2px dashed var(--line2); border-radius: 12px; padding: 18px; text-align: center; color: var(--text2); font-size: 15px; line-height: 1.6; }
.drop.over { border-color: var(--accent); background: var(--accent-bg); }
.pending { display: flex; gap: 8px; align-items: center; }
.pending img { width: 80px; border-radius: 4px; box-shadow: 0 0 0 1px var(--line); }

/* ---------- settings ---------- */
.page { flex: 1; overflow-y: auto; padding: 26px 32px 60px; max-width: 1180px; }
.page h1 { font-size: 26px; font-weight: 600; margin: 0 0 6px; }
.page h2 { font-size: 19px; font-weight: 600; margin: 34px 0 10px; }
.lead { color: var(--text2); font-size: 15px; line-height: 1.6; margin: 0 0 16px; }
.tbl { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.tr { display: grid; grid-template-columns: 70px 1.3fr 1.6fr 1.1fr 1fr 1fr 150px; gap: 10px; align-items: center; padding: 12px 14px; border-top: 1px solid var(--line); font-size: 15px; }
.tr.th { border-top: 0; background: var(--bg2); font-size: 13px; color: var(--text3); font-weight: 600; padding: 9px 14px; }
.tr .url { font-family: ui-monospace, Menlo, monospace; font-size: 13px; overflow-wrap: anywhere; }
.tr .sub { font-size: 13px; color: var(--text3); }
.tr.off { color: var(--text3); }
.prio { display: flex; align-items: center; gap: 2px; }
.prio b { width: 26px; height: 26px; border-radius: 50%; background: var(--accent-bg); color: var(--accent-text); display: inline-flex; align-items: center; justify-content: center; font-size: 14px; }
.card-box { border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px; background: var(--bg2); }
.login form { background: var(--bg); border-radius: 16px; padding: 28px; width: min(400px, 100%); display: grid; gap: 14px; box-shadow: 0 0 0 1px var(--line); }
.login h1 { margin: 0; font-size: 24px; }

/* ---------- phone layout ---------- */
@media (max-width: 899px) {
  .sidebar, .cap-side.desktop-only { display: none; }
  .shell { flex-direction: column; }
  .topbar { height: auto; padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top)); }
  .topbar .desktop-only { display: none; }
  .list { width: 100%; border-right: 0; }
  .panes.has-detail .list { display: none; }
  .panes:not(.has-detail) .detail { display: none; }
  .detail { padding: 14px 16px 120px; }
  .row .thumb { width: 76px; }
  .tabbar { display: flex; flex: none; border-top: 1px solid var(--line); background: var(--bg2); padding-bottom: env(safe-area-inset-bottom); }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 6px; font-size: 12px; color: var(--text2); }
  .tabbar a.on { color: var(--accent); }
  .tabbar svg.i { width: 26px; height: 26px; }
  .capture { flex-direction: column; overflow-y: auto; }
  .cap-main { padding: 10px; }
  .viewer { min-height: 56vh; }
  .cap-side { width: 100%; border-left: 0; border-top: 1px solid var(--line); }
  .page { padding: 18px 16px 100px; }
  .tr { grid-template-columns: 1fr 1fr; }
  .tr.th { display: none; }
  .kv { grid-template-columns: 96px 1fr; }
  .form .grid2 { grid-template-columns: 1fr; }
  .hide-phone { display: none !important; }
}
@media (min-width: 900px) { .show-phone { display: none !important; } }
