:root {
  --bg: #0f1115; --panel: #171a21; --panel2: #1e222b; --line: #2a2f3a;
  --text: #e6e8ee; --muted: #8b93a3; --accent: #5b8cff;
  --pending: #8b93a3; --under_review: #e0a93b; --approved: #3fb97a; --rejected: #e5594f;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger:hover { border-color: var(--rejected); color: var(--rejected); }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; width: 100%; }
textarea { resize: vertical; min-height: 64px; }
.hidden { display: none !important; }

header.top { display: flex; align-items: center; gap: 16px; padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--panel); }
header.top .brand { font-weight: 700; font-size: 16px; color: var(--text); }
header.top nav { display: flex; gap: 12px; flex: 1; }
header.top .who { color: var(--muted); }

main.page { padding: 20px; max-width: 1100px; margin: 0 auto; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 20px; }
.center { max-width: 380px; margin: 12vh auto; }
.center h1 { margin-top: 0; }
.field { margin-bottom: 12px; }
.field label { display: block; color: var(--muted); margin-bottom: 4px; font-size: 12px; }
.err { color: var(--rejected); margin: 8px 0; min-height: 1em; }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.chips { display: flex; gap: 6px; }
.chip { border-radius: 999px; padding: 3px 12px; font-size: 12px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
tr.row:hover { background: var(--panel); cursor: pointer; }
.muted { color: var(--muted); }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; color: #111; }
.badge.pending { background: var(--pending); }
.badge.under_review { background: var(--under_review); }
.badge.approved { background: var(--approved); }
.badge.rejected { background: var(--rejected); color: #fff; }

/* review screen */
.review { display: grid; grid-template-columns: 1fr var(--sidew, 360px); height: calc(100vh - var(--hh, 49px)); height: calc(100dvh - var(--hh, 49px)); }
.review { grid-template-rows: minmax(0, 1fr); }
.review > * { min-height: 0; }
.review.theater { grid-template-columns: 1fr; }
.review.theater .side { display: none; }
.stage { display: flex; flex-direction: column; min-width: 0; padding: 14px 16px; gap: 10px; }
.stage .titlebar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.stage .titlebar h2 { margin: 0; font-size: 16px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.statusctl { display: flex; gap: 6px; }
.statusctl button.active { color: #111; font-weight: 600; }
.statusctl button.active[data-s=pending] { background: var(--pending); }
.statusctl button.active[data-s=under_review] { background: var(--under_review); }
.statusctl button.active[data-s=approved] { background: var(--approved); }
.statusctl button.active[data-s=rejected] { background: var(--rejected); color: #fff; }
.vwrap { flex: 1 1 0; min-height: 0; background: #000; border-radius: 8px; display: flex; align-items: center; justify-content: center; position: relative; }
.vwrap video { max-width: 100%; max-height: 100%; margin: auto; }
.vwrap.scroll { overflow: auto; }
.vwrap.scroll video { flex: none; }
.side { position: relative; }
.split { position: absolute; left: -3px; top: 0; bottom: 0; width: 7px; cursor: col-resize; z-index: 5; touch-action: none; }
.split:hover, .split:active { background: var(--accent); opacity: .5; }
.review.theater ~ * .split { display: none; }
.vwrap .overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.6); color: #fff; }
.scrub { position: relative; height: 28px; background: var(--panel); border-radius: 6px; cursor: pointer; border: 1px solid var(--line); }
.scrub .fill { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(91,140,255,.25); border-radius: 6px 0 0 6px; pointer-events: none; }
.scrub .head { position: absolute; top: -3px; bottom: -3px; width: 2px; background: #fff; pointer-events: none; }
.scrub .mark { position: absolute; top: 3px; bottom: 3px; width: 6px; margin-left: -3px; border-radius: 3px; background: var(--under_review); }
.scrub .mark.resolved { background: var(--approved); opacity: .6; }
.transport { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.transport .tc { font: 600 18px ui-monospace, SFMono-Regular, Menlo, monospace; min-width: 130px; }
.transport .fr { color: var(--muted); font: 12px ui-monospace, Menlo, monospace; }
.transport select { width: auto; padding: 4px 6px; }
.hint { color: var(--muted); font-size: 12px; }

.side { border-left: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.side .composer { padding: 12px; border-bottom: 1px solid var(--line); }
.side .composer .at { color: var(--accent); font: 12px ui-monospace, Menlo, monospace; margin-bottom: 6px; display: flex; justify-content: space-between; }
.side .composer .row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.clist { overflow-y: auto; flex: 1; padding: 6px 0; }
.cmt { padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.cmt.active { background: var(--panel2); box-shadow: inset 3px 0 0 var(--accent); }
.cmt.resolved .body { opacity: .5; text-decoration: line-through; }
.cmt .meta { display: flex; gap: 8px; align-items: baseline; font-size: 12px; color: var(--muted); }
.cmt .tcb { font: 600 12px ui-monospace, Menlo, monospace; color: var(--accent); }
.cmt .body { margin: 4px 0; white-space: pre-wrap; word-break: break-word; }
.cmt .acts { display: flex; gap: 10px; font-size: 12px; }
.cmt .acts a { color: var(--muted); cursor: pointer; }
.cmt .acts a:hover { color: var(--text); }
.reply { margin: 8px 0 0 14px; padding-left: 10px; border-left: 2px solid var(--line); }
.history { font-size: 12px; color: var(--muted); padding: 8px 14px; border-top: 1px solid var(--line); max-height: 90px; overflow: auto; }

@media (max-width: 900px) { .review { grid-template-columns: 1fr; grid-template-rows: none; height: auto; } .side { border-left: 0; border-top: 1px solid var(--line); } .vwrap { min-height: 220px; max-height: 70vh; } }

/* range comments */
.scrub .sel { position: absolute; top: 0; bottom: 0; background: rgba(91,140,255,.45); border: 1px solid var(--accent); border-radius: 3px; pointer-events: none; }
.scrub .band { position: absolute; top: 3px; bottom: 3px; background: rgba(224,169,59,.28); border-radius: 3px; pointer-events: none; }
.scrub .band.resolved { background: rgba(63,185,122,.18); }
.side .composer .at > span:last-child a { margin-left: 8px; }

/* settings */
.ok { color: var(--approved); margin: 8px 0; min-height: 1em; }
.connstatus { padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; background: var(--panel2); border-left: 4px solid var(--pending); }
.connstatus.ready { border-left-color: var(--approved); }
.connstatus.starting { border-left-color: var(--under_review); }
.connstatus.error { border-left-color: var(--rejected); }
.connstatus .detail { color: var(--muted); font-size: 12px; margin-top: 4px; word-break: break-word; }

/* export dialog */
dialog.dlg { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 20px; max-width: 460px; width: calc(100% - 32px); }
dialog.dlg::backdrop { background: rgba(0,0,0,.6); }

/* comment links */
.cmt.flash { animation: cflash 2.4s ease-out; }
@keyframes cflash { 0%, 35% { background: color-mix(in srgb, var(--accent) 38%, transparent); } 100% { background: transparent; } }
.notice { margin: 8px 12px 0; padding: 8px 10px; border-radius: 6px; background: var(--panel2); border-left: 3px solid var(--under_review); font-size: 12px; }
@media (prefers-reduced-motion: reduce) { .cmt.flash { animation: none; background: var(--panel2); } }

/* thumbnails & grid */
main.page.wide { max-width: 1500px; }
.vgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.vcard { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; cursor: pointer; transition: transform .12s, border-color .12s, box-shadow .12s; outline: none; }
.vcard:hover, .vcard:focus-visible { transform: translateY(-2px); border-color: var(--accent); box-shadow: 0 8px 24px rgba(0,0,0,.35); }
.thumb { position: relative; aspect-ratio: 16 / 9; background: #000; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .ph { position: absolute; inset: 0; display: none; place-items: center; color: var(--muted); font-size: 28px; background: linear-gradient(135deg, var(--panel2), var(--bg)); }
.thumb.empty .ph { display: grid; }
.thumb.loading .ph { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.thumb .sbadge { position: absolute; top: 8px; left: 8px; }
.thumb .sbadge .badge { box-shadow: 0 1px 6px rgba(0,0,0,.5); }
.thumb .cc { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.72); color: #fff; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.vmeta { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.vmeta strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.vmeta .muted { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb.mini { width: 72px; border-radius: 6px; }
.thumb.mini .ph { font-size: 14px; }
@media (prefers-reduced-motion: reduce) { .vcard { transition: none; } .thumb.loading .ph { animation: none; } }

/* review-only: no selecting / long-press saving of the picture */
.vwrap video, .thumb img { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; -webkit-user-drag: none; }

/* ---- projects & share links ---- */
.phead { display: flex; align-items: flex-end; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.phead .spacer { flex: 1; }
.pacts { display: flex; gap: 8px; flex-wrap: wrap; }
.thumb .pbtn { position: absolute; top: 8px; right: 8px; padding: 2px 8px; font-size: 12px; background: rgba(0,0,0,.72); border-color: transparent; color: #fff; opacity: 0; transition: opacity .12s; }
.vcard:hover .pbtn, .vcard:focus-within .pbtn, .pbtn:focus-visible { opacity: 1; }
td .pbtn { padding: 1px 8px; font-size: 12px; margin-left: 6px; }
.mosaic { display: grid; grid-template-columns: 1fr 1fr; aspect-ratio: 16 / 9; background: #000; overflow: hidden; position: relative; }
.mosaic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mosaic img:only-child { grid-column: 1 / -1; grid-row: 1 / -1; }
.mosaic.empty { background: linear-gradient(135deg, var(--panel2), var(--bg)); place-items: center; }
.mosaic .ph { grid-column: 1 / -1; color: var(--muted); font-size: 34px; align-self: center; justify-self: center; }
dialog.dlg.wide { max-width: 640px; }
.picklist { display: flex; flex-direction: column; gap: 2px; max-height: 240px; overflow: auto; margin: 8px 0; }
.picklist.tall { max-height: 360px; }
.pick { display: flex; gap: 10px; align-items: center; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.pick:hover { background: var(--panel2); }
.pick.dim { opacity: .55; cursor: default; }
.sharelist { display: flex; flex-direction: column; gap: 10px; margin: 8px 0 14px; }
.sharerow { border: 1px solid var(--line); border-radius: 8px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.sharerow.expired { opacity: .6; }
.sr-top { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 13px; }
.sr-acts { display: flex; gap: 8px; justify-content: flex-end; }
.newshare { border-top: 1px solid var(--line); padding-top: 14px; }
.gtag { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; color: var(--muted); }
