:root {
  --bg: #f5f6f8; --card: #ffffff; --text: #1d2230; --muted: #667085; --line: #e3e6ec;
  --accent: #e0312f; --accent-2: #b8241f; --ok: #16803c; --warn: #b45309; --bad: #c0262d; --info: #2463c7;
  --chip: #eef1f5; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161b; --card: #1d2027; --text: #e7e9ee; --muted: #9aa1ad; --line: #2e323c;
    --chip: #272b34; --shadow: none; --accent: #ef4444; --accent-2: #dc2626;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 "Microsoft JhengHei UI", "Microsoft JhengHei", "Noto Sans TC", system-ui, sans-serif; }
code { background: var(--chip); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
h2 { font-size: 17px; margin: 0 0 8px; }
h3 { font-size: 15px; margin: 0; }
a { color: var(--info); }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 20px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; font-size: 18px; }
.watch { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.dot.busy { background: var(--info); animation: pulse 1.4s infinite; }
.dot.ext { background: var(--warn); }
.dot.err { background: var(--bad); }
@keyframes pulse { 50% { opacity: .35; } }

.tabs { display: flex; gap: 4px; padding: 0 20px; background: var(--card); border-bottom: 1px solid var(--line);
  overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 3px solid transparent; border-radius: 0; color: var(--muted);
  padding: 10px 14px; font-weight: 600; white-space: nowrap; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent);
  color: #fff; font-size: 12px; text-align: center; }
.badge.warn { background: var(--bad); }

main { max-width: 1200px; margin: 0 auto; padding: 16px 20px 60px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px;
  box-shadow: var(--shadow); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.grid .card { margin: 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.grow { flex: 1 1 240px; min-width: 0; }
.bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 13px; margin: 4px 0; }
.msg { font-size: 14px; margin-top: 6px; }
.msg.ok { color: var(--ok); } .msg.bad { color: var(--bad); }

button { font: inherit; border: 1px solid transparent; border-radius: 7px; padding: 7px 14px; cursor: pointer;
  background: var(--accent); color: #fff; font-weight: 600; }
button:hover { background: var(--accent-2); }
button:disabled { opacity: .5; cursor: default; }
button.small { padding: 4px 10px; font-size: 13px; }
button.ghost { background: transparent; color: var(--text); border-color: var(--line); }
button.ghost:hover { background: var(--chip); }
button.good { background: var(--ok); } button.good:hover { filter: brightness(.9); }
button.quiet { background: var(--chip); color: var(--text); } button.quiet:hover { filter: brightness(.95); }

input, select, textarea { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line);
  border-radius: 7px; padding: 6px 9px; max-width: 100%; }
textarea { width: 100%; resize: vertical; min-height: 70px; }
input[type=text], input[type=url] { width: 100%; }
label.field { display: block; margin: 8px 0; font-size: 13px; color: var(--muted); }
label.field > input, label.field > textarea, label.field > select, label.field > .ctl { display: block; margin-top: 3px; color: var(--text); }
label.check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
.ctl { display: flex !important; gap: 6px; flex-wrap: wrap; align-items: center; }

.drop { display: flex; align-items: center; justify-content: center; border: 2px dashed var(--line); border-radius: 10px;
  min-height: 110px; margin-top: 10px; cursor: pointer; color: var(--muted); text-align: center; padding: 16px; }
.drop.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.progress { margin-top: 10px; font-size: 14px; }
.progress .track { height: 8px; background: var(--chip); border-radius: 4px; overflow: hidden; margin-top: 4px; }
.progress .fill { height: 100%; background: var(--info); width: 0; transition: width .2s; }
.progress.done .fill { background: var(--ok); } .progress.fail .fill { background: var(--bad); }

.video-card h2 { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.meta { color: var(--muted); font-size: 13px; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; background: var(--chip); font-size: 12px;
  color: var(--text); white-space: nowrap; }
.pill.ok { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.pill.warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.pill.bad { background: color-mix(in srgb, var(--bad) 16%, transparent); color: var(--bad); }
.pill.info { background: color-mix(in srgb, var(--info) 16%, transparent); color: var(--info); }
.clip { display: grid; grid-template-columns: var(--player-w, 290px) minmax(0, 1fr); gap: 18px; border-top: 1px solid var(--line); padding-top: 14px;
  margin-top: 14px; }
.player video { width: 100%; aspect-ratio: 9 / 16; background: #000; border-radius: 8px; display: block; }
.files { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.file { border: 1px solid var(--line); border-radius: 8px; padding: 8px; cursor: pointer; }
.file.sel { border-color: var(--info); box-shadow: 0 0 0 1px var(--info); }
.file .name { font-size: 13px; word-break: break-all; }
.file .acts { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.file .status { margin-top: 4px; font-size: 13px; }
.sheet-head { display: flex; justify-content: space-between; gap: 8px; align-items: center; flex-wrap: wrap; }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 14px; }
.reason { font-size: 13px; color: var(--muted); margin: 2px 0 8px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 13px; }
.table-wrap { overflow-x: auto; }
td.err { color: var(--bad); font-size: 13px; max-width: 380px; word-break: break-word; }
.log { background: #0f1115; color: #d7dae0; border-radius: 8px; padding: 12px; height: 460px; overflow: auto;
  font: 12.5px/1.45 Consolas, "Cascadia Mono", monospace; white-space: pre-wrap; word-break: break-all; margin: 8px 0 0; }

.chset .readonly { font-size: 13px; color: var(--muted); }
.chset .toggles { display: flex; gap: 14px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1d2230; color: #fff;
  padding: 10px 18px; border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.25); z-index: 20; max-width: 90vw; }
.toast.bad { background: var(--bad); }
dialog { border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text); max-width: 480px; }
dialog::backdrop { background: rgba(0,0,0,.35); }
.dialog-buttons { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.empty { color: var(--muted); text-align: center; padding: 30px; }

@media (max-width: 760px) {
  .clip { grid-template-columns: 1fr; }
  .player { max-width: var(--player-w, 320px); }
  .two { grid-template-columns: minmax(0, 1fr); }
  main { padding: 12px 16px 40px; }
  .grid { grid-template-columns: 1fr; }
}
label.field > select, label.field > .ctl select { max-width: 100%; }
label.field > select { width: 100%; }
.clip > div { min-width: 0; }
button:disabled, button:disabled:hover { background: var(--chip); color: var(--muted); }
.styles { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.styles button { position: relative; background: var(--chip); color: var(--text); border: 2px solid transparent;
  padding: 5px 14px; border-radius: 8px; font-weight: 600; font-size: 14px; }
.styles button:hover { background: var(--chip); border-color: var(--line); }
.styles button.sel { border-color: var(--accent); }
.styles .tip { display: none; position: absolute; top: calc(100% + 6px); left: 0;
  z-index: 10; pointer-events: none; padding: 10px 12px; border-radius: 8px; background: #2b303b;
  box-shadow: 0 4px 16px rgba(0,0,0,.3); white-space: nowrap; text-align: center; color: #e7e9ee;
  font-weight: 400; font-size: 12px; }
.styles .tip img { display: block; margin: 0 auto 4px; max-width: 240px; }
.styles button:hover .tip, .styles button:focus-visible .tip, .styles button:active .tip { display: block; }
.styles button:last-child .tip { left: auto; right: 0; }
/* channel list: folders, rows, long-press dragging */
.chlist { display: flex; flex-direction: column; gap: 12px; }
.folder { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 4px 10px 8px; }
.fhead { display: flex; align-items: center; gap: 8px; padding: 8px 2px; cursor: pointer; user-select: none;
  -webkit-user-select: none; -webkit-touch-callout: none; flex-wrap: wrap; }
.fhead b { flex: 1 1 auto; }
.rows { display: flex; flex-direction: column; gap: 6px; min-height: 36px; }
.rows:empty::after { content: "把頻道拖到這裡"; color: var(--muted); font-size: 13px; border: 1px dashed var(--line);
  border-radius: 8px; padding: 8px; text-align: center; }
.chrow { border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.chhead { display: flex; align-items: center; gap: 8px; padding: 9px 10px; cursor: pointer; user-select: none;
  -webkit-user-select: none; -webkit-touch-callout: none; flex-wrap: wrap; }
.chhead b { min-width: 100px; }
.grip { color: var(--muted); letter-spacing: -3px; cursor: grab; }
.chev { margin-left: auto; color: var(--muted); transition: transform .15s; }
.folder:not(.loose) > .fhead .chev { margin-left: 0; }
.chrow.open > .chhead .chev, .folder.open > .fhead .chev { transform: rotate(90deg); }
.chbody > .card { margin: 0 8px 8px; box-shadow: none; }
.chrow, .folder { transition: transform .2s ease, background .2s ease, box-shadow .2s ease; }
.pressing { transform: scale(.985); background: color-mix(in srgb, var(--accent) 8%, var(--bg)); }
.placeholder { opacity: .35; outline: 2px dashed var(--accent); outline-offset: -2px; }
.placeholder > * { visibility: hidden; }
.drag-ghost { position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none; margin: 0; opacity: .97;
  background: var(--card); border: 1px solid var(--accent); border-radius: 8px;
  box-shadow: 0 14px 34px rgba(0,0,0,.4); will-change: transform; }
.folder.drop-target { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.small.icon { padding: 2px 7px; }
.chhead .meta { font-size: 12px; }
.chhead b { min-width: 0; overflow-wrap: anywhere; }
body.dragging, body.dragging * { cursor: grabbing !important; user-select: none; -webkit-user-select: none; }
/* review: 等待審核中 / 已審核完畢 and the preview size */
.seg { display: inline-flex; flex-wrap: wrap; background: var(--chip); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button { background: transparent; color: var(--muted); border-radius: 7px; padding: 6px 14px; }
.seg button:hover { background: transparent; color: var(--text); }
.seg button.active { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.quiet-badge { background: var(--muted); }
#zoom { width: 130px; accent-color: var(--accent); }
input.hours { width: 5.5em; }
