:root {
  --bg: #f6f7f9; --panel: #ffffff; --ink: #1d2330; --muted: #6b7384; --line: #e2e5eb;
  --accent: #2f6fed; --accent-ink: #ffffff; --ok: #1f9d55; --warn: #c98a00; --bad: #d64545;
  --chip: #eef2fb; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b; --panel: #1b2029; --ink: #e8ebf1; --muted: #98a1b3; --line: #2b313d;
    --accent: #5b8cff; --accent-ink: #0d1117; --chip: #232a36; --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 system-ui, "Noto Sans TC", "Microsoft JhengHei", sans-serif; }
button, select, input, textarea { font: inherit; color: inherit; }
button { background: var(--chip); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.ghost { background: transparent; }
button.danger, .danger button { color: var(--bad); }
button:disabled { opacity: .5; cursor: not-allowed; }
.btn { display: inline-block; background: var(--accent); color: var(--accent-ink); border-radius: 8px; padding: 6px 12px; cursor: pointer; font-weight: 600; }
input, select, textarea { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; width: 100%; }
textarea { resize: vertical; }
label { display: block; font-size: 13px; color: var(--muted); }
label > input, label > select, label > textarea { margin-top: 4px; color: var(--ink); }
code { background: var(--chip); padding: 0 4px; border-radius: 4px; }

.top { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; padding: 10px 16px;
  background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; font-size: 18px; }
.ver { font-size: 11px; color: var(--muted); font-weight: 400; }
.proj { display: flex; gap: 6px; align-items: center; flex: 1; min-width: 240px; }
.proj select { max-width: 320px; }
.proj button { white-space: nowrap; }
.status { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.on { background: var(--ok); } .dot.busy { background: var(--warn); } .dot.bad { background: var(--bad); }
.cu { background: var(--chip); border-radius: 999px; padding: 1px 8px; }

.tabs { display: flex; gap: 4px; padding: 8px 16px 0; overflow-x: auto; }
.tabs button { border-radius: 8px 8px 0 0; border-bottom: none; white-space: nowrap; }
.tabs button.on { background: var(--panel); border-color: var(--line); font-weight: 600; }
main { padding: 0 16px 48px; }
.tab { display: none; } .tab.on { display: block; }

.bar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 0 8px 8px 8px; padding: 10px 12px; margin-bottom: 12px; }
.bar-actions { display: flex; gap: 8px; }
.summary { font-size: 13px; color: var(--muted); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 12px 0; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 8px; font-size: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.hint { font-size: 12px; color: var(--muted); margin: 4px 0 8px; }
.grid2 { display: grid; grid-template-columns: 220px 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }

.imggrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.imgcell { position: relative; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--chip); }
.imgcell img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.imgcell .nm { font-size: 11px; padding: 2px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.imgcell .x { position: absolute; top: 4px; right: 4px; padding: 0 6px; font-size: 12px; }

.subj { border-top: 1px dashed var(--line); padding: 10px 0; display: grid; grid-template-columns: 160px 80px 1fr auto; gap: 8px; align-items: start; }
@media (max-width: 720px) { .subj { grid-template-columns: 1fr 1fr; } }
.pick { display: flex; flex-wrap: wrap; gap: 4px; grid-column: 1 / -1; }
.pick img { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; border: 2px solid transparent; cursor: pointer; opacity: .55; }
.pick img.sel { border-color: var(--accent); opacity: 1; }
.pick .num { position: relative; }

.seglist { display: flex; flex-direction: column; gap: 12px; }
.seg { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.seg-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.seg-head .no { font-weight: 700; background: var(--chip); border-radius: 6px; padding: 0 8px; }
.seg-head input.title { flex: 1; min-width: 160px; }
.seg-head input.dur { width: 70px; }
.seg-body { display: grid; grid-template-columns: 1fr 300px; gap: 12px; padding: 12px; }
@media (max-width: 900px) { .seg-body { grid-template-columns: 1fr; } }
.shots { display: flex; flex-direction: column; gap: 8px; }
.shot { border: 1px solid var(--line); border-radius: 8px; padding: 8px; display: grid; grid-template-columns: 70px 1fr; gap: 6px 8px; }
.shot .line { grid-column: 1 / -1; display: grid; grid-template-columns: 140px 110px 1fr auto; gap: 6px; }
@media (max-width: 640px) { .shot .line { grid-template-columns: 1fr 1fr; } }
.seg-side { display: flex; flex-direction: column; gap: 8px; }
.out { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #000; aspect-ratio: 9 / 16; max-height: 440px; }
.out.h { aspect-ratio: 16 / 9; }
.out iframe { width: 100%; height: 100%; border: 0; }
.out.empty { display: grid; place-items: center; color: #aaa; font-size: 13px; background: var(--chip); }
.badge { font-size: 12px; border-radius: 999px; padding: 1px 8px; background: var(--chip); color: var(--muted); }
.badge.ok { color: var(--ok); } .badge.warn { color: var(--warn); } .badge.bad { color: var(--bad); }
.row { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
.radio { display: inline-flex; gap: 6px; align-items: center; color: var(--ink); font-size: 14px; }
.radio input { width: auto; }

dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--ink); padding: 0; width: min(560px, 94vw); max-height: 92vh; overflow-y: auto; overflow-x: hidden; }
dialog:has(.wide) { width: min(1100px, 96vw); }
dialog::backdrop { background: rgba(0,0,0,.45); }
.dlg { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.dlg.wide { width: auto; }
.dlg h3 { margin: 0; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; }
.gensegs { max-height: 220px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.gensegs label { color: var(--ink); display: flex; gap: 8px; align-items: center; padding: 2px 0; }
.gensegs input { width: auto; }
.est { background: var(--chip); border-radius: 8px; padding: 10px; font-size: 14px; }
.est b { font-size: 18px; }

.runrow { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); cursor: pointer; }
.progress { height: 8px; border-radius: 99px; background: var(--chip); overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); transition: width .4s; }
.log { font: 12px/1.5 ui-monospace, Consolas, monospace; max-height: 320px; overflow: auto; background: var(--chip); border-radius: 8px; padding: 8px; white-space: pre-wrap; }
.segprog { display: grid; grid-template-columns: 90px 1fr 110px; gap: 8px; align-items: center; font-size: 13px; padding: 3px 0; }

#toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg);
  padding: 8px 14px; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 20; }
#toast.on { opacity: .95; }

.login { position: fixed; inset: 0; background: var(--bg); display: grid; place-items: center; z-index: 30; padding: 16px; }
.login[hidden] { display: none; }
.login-box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 28px; width: min(380px, 100%); text-align: center; box-shadow: var(--shadow); }
.login-box .brand { font-size: 24px; margin-bottom: 8px; }
#gbtn { display: flex; justify-content: center; margin: 16px 0 8px; min-height: 44px; }
#logout { font-size: 12px; }

.bal { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; font-size: 14px; }
.bal b { font-size: 16px; }
.esttable { width: 100%; border-collapse: collapse; font-size: 13px; margin: 6px 0; }
.esttable { table-layout: auto; }
.esttable th, .esttable td { border-bottom: 1px solid var(--line); padding: 5px 8px; text-align: right; }
.esttable th:first-child, .esttable td:first-child { text-align: left; white-space: normal; }
.esttable tr.total td { font-weight: 700; border-top: 2px solid var(--line); }
.after { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; margin-top: 8px; }
.after div { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 13px; }
.after div b { display: block; font-size: 17px; }
.warnbox { color: var(--bad); font-weight: 600; }
.confirm { font-weight: 600; }

@media (max-width: 640px) { .esttable th:nth-child(3), .esttable td:nth-child(3), .esttable th:nth-child(4), .esttable td:nth-child(4) { display: none; } }
