/* Model Review — one dark, quiet UI so the model is the brightest thing on screen. */
:root {
  --bg: #111317; --panel: #171a1f; --panel-2: #1d2127; --line: #2a2f37; --line-2: #353b45;
  --text: #e7e9ee; --muted: #9aa1ad; --faint: #6b7280;
  --accent: #ffb020; --accent-ink: #15181d; --blue: #5b9dff; --ok: #3ecf8e; --warn: #ffb020; --danger: #ff6b6b;
  --radius: 10px; --side-w: 380px; --top-h: 52px;
  color-scheme: dark;
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { display: flex; flex-direction: column; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 6px; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 10px; font-weight: 650; }
h3 { font-size: 13px; margin: 0 0 8px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
p { margin: 0 0 10px; }
code { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: 12px; } .right { text-align: right; } .grow { flex: 1; }

/* ---------- top bar */
.topbar { height: var(--top-h); flex: none; display: flex; align-items: center; gap: 22px; padding: 0 18px; border-bottom: 1px solid var(--line); background: var(--panel); }
.brand { color: var(--text); font-weight: 700; letter-spacing: .01em; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { color: var(--accent); }
#nav { flex: 1; display: flex; align-items: center; gap: 4px; }
.nav-link { color: var(--muted); padding: 6px 10px; border-radius: 7px; }
.nav-link:hover { color: var(--text); background: var(--panel-2); text-decoration: none; }
.nav-link.active { color: var(--text); background: var(--panel-2); }
.nav-spacer { flex: 1; }
.nav-user { display: flex; align-items: center; gap: 8px; color: var(--text); }
.nav-user:hover { text-decoration: none; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: #2c3340; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--accent); }
body[data-page="login"] .topbar, body[data-page="invite"] .topbar { border-bottom-color: transparent; background: transparent; }

main { flex: 1; min-height: 0; overflow: auto; }
body[data-page="r"] main, body[data-page="new"] main { overflow: hidden; }

/* ---------- buttons & form controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #252a32; text-decoration: none; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #ffbf47; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: rgba(255, 107, 107, .1); }
.btn.small { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn.big { height: 44px; padding: 0 22px; font-size: 15px; width: 100%; }
.icon-btn { border: 0; background: none; color: var(--muted); font-size: 16px; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
button.link { border: 0; background: none; color: var(--muted); font: inherit; font-size: 12.5px; padding: 2px 0; cursor: pointer; }
button.link:hover { color: var(--text); text-decoration: underline; }
button.link.danger:hover { color: var(--danger); }
input, textarea, select { width: 100%; font: inherit; color: var(--text); background: #0f1114; border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px; }
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus, .btn:focus-visible, .tool:focus-visible, .dropzone:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.field { display: block; margin: 0 0 14px; }
.field > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; font-weight: 550; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 4px 0 16px; cursor: pointer; }
.check input { width: auto; margin-top: 3px; accent-color: var(--accent); }
.check strong { font-weight: 550; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.form-error { color: var(--danger); }
.tag { display: inline-block; margin-left: 8px; padding: 0 7px; border-radius: 99px; font-size: 11px; line-height: 18px; background: #262b33; color: var(--muted); vertical-align: 1px; }
.tag.ok { background: rgba(62, 207, 142, .14); color: var(--ok); }
.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
.seg button { border: 0; background: none; color: var(--muted); font: inherit; padding: 4px 12px; border-radius: 6px; cursor: pointer; }
.seg button.on { background: #2c323c; color: var(--text); }
.seg.small button { padding: 3px 9px; font-size: 12.5px; }

/* ---------- pages */
.page { max-width: 1240px; margin: 0 auto; padding: 26px 24px 60px; }
.page.narrow { max-width: 760px; }
.page-head { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; }
.empty { text-align: center; color: var(--muted); padding: 60px 20px; }
.empty.small { padding: 24px 10px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-weight: 550; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); }
.table td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.inline-form { display: flex; gap: 8px; }
.inline-form input { flex: 2; } .inline-form select { flex: 1; } .inline-form .btn { height: auto; }
.link-box { display: flex; gap: 8px; margin: 8px 0; }
.link-box input { font: 12px ui-monospace, Menlo, monospace; }
.invite-result { margin-top: 14px; padding: 12px; border: 1px dashed var(--line-2); border-radius: 8px; }
.invite-result textarea { font: 12px ui-monospace, Menlo, monospace; margin-bottom: 8px; }
details.help { margin-top: 14px; color: var(--muted); }
details.help summary { cursor: pointer; color: var(--text); margin-bottom: 8px; }
details.help textarea { margin-bottom: 8px; }
.meter { height: 8px; background: var(--panel-2); border-radius: 99px; overflow: hidden; margin-bottom: 10px; }
.meter-fill { height: 100%; background: var(--accent); }

/* ---------- auth */
.auth-card { max-width: 420px; margin: 8vh auto 40px; padding: 34px 32px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; text-align: center; }
.auth-card .btn.big { margin: 18px 0 12px; }
.auth-card .field { text-align: left; margin-top: 18px; }
.auth-card details { text-align: left; }
.logo-big { font-size: 34px; color: var(--accent); line-height: 1; margin-bottom: 12px; }
.dev-box { margin-top: 20px; padding-top: 14px; border-top: 1px dashed var(--line-2); }

/* ---------- review cards */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.review-card { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; color: var(--text); transition: border-color .15s, transform .15s; }
.review-card:hover { border-color: #47505d; text-decoration: none; transform: translateY(-1px); }
.thumb { position: relative; aspect-ratio: 16 / 10; background: #1b1e24; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.badge { position: absolute; top: 8px; font-size: 10.5px; font-weight: 700; letter-spacing: .04em; padding: 2px 7px; border-radius: 5px; background: rgba(10, 12, 15, .75); color: var(--muted); }
.badge.fmt { left: 8px; } .badge.state { right: 8px; } .badge.state.live { color: var(--ok); }
.card-body { padding: 10px 12px 12px; }
.card-title { font-weight: 600; margin-bottom: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-meta { font-size: 12px; color: var(--muted); }

/* ---------- review layout */
.review { display: grid; grid-template-columns: 1fr var(--side-w); height: 100%; }
.stage { position: relative; min-width: 0; background: #1b1e24; overflow: hidden; }
.viewport { position: absolute; inset: 0; }
.viewport canvas { display: block; touch-action: none; }
.side { background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side-head { padding: 14px 16px 12px; border-bottom: 1px solid var(--line); }
.side-head .back { font-size: 12.5px; color: var(--muted); }
.review-title { font-size: 18px; margin: 6px 0 2px; overflow-wrap: anywhere; }
.side-head .meta { color: var(--muted); font-size: 12.5px; margin-bottom: 10px; }
.side-head .desc, .info-sec .desc { white-space: pre-wrap; color: #c8ccd4; font-size: 13px; }
.version-select { width: auto; flex: 1; min-width: 0; height: 28px; padding: 0 8px; font-size: 12.5px; }
.tabs { display: flex; border-bottom: 1px solid var(--line); padding: 0 8px; }
.tab { border: 0; background: none; color: var(--muted); font: inherit; font-weight: 550; padding: 10px 10px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.on { color: var(--text); border-bottom-color: var(--accent); }
.side-body { flex: 1; overflow: auto; padding: 12px 14px 40px; }
.side-pad { padding: 18px 18px 40px; overflow: auto; }
.form-side { overflow: auto; }

/* toolbar + status over the stage */
.toolbar { position: absolute; top: 12px; left: 12px; display: flex; gap: 8px; flex-wrap: wrap; z-index: 3; pointer-events: none; }
.tool-group { display: flex; gap: 2px; padding: 3px; background: rgba(23, 26, 31, .88); border: 1px solid var(--line-2); border-radius: 9px; backdrop-filter: blur(6px); pointer-events: auto; }
.tool { border: 0; background: none; color: #c9cdd5; font: inherit; font-size: 12.5px; font-weight: 550; height: 28px; padding: 0 10px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.tool:hover:not(:disabled) { background: #2a3039; color: #fff; }
.tool.on { background: var(--accent); color: var(--accent-ink); }
.tool:disabled { opacity: .35; cursor: default; }
.tool-select { width: auto; height: 28px; padding: 0 6px; font-size: 12px; background: transparent; border: 0; }
.stage-status { position: absolute; left: 12px; bottom: 12px; right: 12px; display: flex; gap: 10px; align-items: center; font-size: 12px; color: var(--muted); z-index: 3; pointer-events: none; }
.stage-status > * { pointer-events: auto; }
.stage-status > span { background: rgba(17, 19, 23, .75); padding: 4px 9px; border-radius: 6px; }
.stage-status .progress { width: 320px; background: rgba(17, 19, 23, .85); padding: 6px 9px; border-radius: 6px; }

/* overlay: drop zone / loading / snapshot mode */
.stage-overlay { position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; padding: 70px 24px 50px; background: #15181d; overflow: auto; }
.overlay-inner { width: min(620px, 100%); text-align: center; }
.overlay-inner.snap-mode { width: min(1100px, 100%); }
.snapshot { margin: 0 0 18px; }
.snapshot img { max-width: 100%; max-height: 62vh; border-radius: 8px; border: 1px solid var(--line); cursor: zoom-in; display: block; margin: 0 auto; }
.snapshot figcaption { margin-top: 8px; color: var(--muted); font-size: 13px; white-space: pre-wrap; }
.snap-note { max-width: 620px; margin: 0 auto; color: var(--muted); }
.dropzone { border: 1.5px dashed #4a525e; border-radius: 12px; padding: 34px 20px; margin: 16px 0; cursor: pointer; transition: border-color .15s, background .15s; text-align: center; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: rgba(255, 176, 32, .05); }
.dz-icon { font-size: 26px; color: var(--accent); margin-bottom: 6px; }
.dz-title { font-weight: 600; color: var(--text); }
.dz-hint { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.spinner { width: 34px; height: 34px; margin: 0 auto 14px; border: 3px solid #333a44; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { width: 100%; }
.progress-track { height: 6px; background: #2a3039; border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--accent); transition: width .15s; }
.progress-label { font-size: 12px; color: var(--muted); margin-top: 5px; }

/* pins */
.pin-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.pin { position: absolute; left: 0; top: 0; margin: -13px 0 0 -13px; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 13px; border: 2px solid #101216;
  background: var(--accent); color: var(--accent-ink); font: 700 12px/22px system-ui, sans-serif; cursor: pointer; pointer-events: auto; box-shadow: 0 2px 8px rgba(0, 0, 0, .45); transition: opacity .15s, box-shadow .15s; }
.pin:hover { z-index: 2; box-shadow: 0 0 0 3px rgba(255, 176, 32, .35), 0 2px 8px rgba(0, 0, 0, .45); }
.pin.resolved { background: #8b93a1; }
.pin.other { background: #5b9dff; font-size: 10.5px; }
.pin.draft { background: #fff; animation: pulse 1.2s ease-in-out infinite; }
.pin.active { box-shadow: 0 0 0 3px #fff, 0 2px 10px rgba(0, 0, 0, .5); z-index: 3; }
.pin.hidden-behind { opacity: .38; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(255, 255, 255, .25); } }

/* comments */
.comments-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.hint { font-size: 12.5px; color: var(--accent); background: rgba(255, 176, 32, .08); border: 1px solid rgba(255, 176, 32, .25); border-radius: 8px; padding: 8px 10px; }
.composer { background: var(--panel-2); border: 1px solid var(--accent); border-radius: var(--radius); padding: 10px; margin-bottom: 12px; }
.composer-head { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; font-weight: 600; }
.composer textarea { margin-bottom: 6px; }
.thread { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 10px; cursor: pointer; transition: border-color .15s; }
.thread:hover { border-color: #444c58; }
.thread.active { border-color: var(--accent); }
.thread.resolved .body { color: var(--muted); }
.thread-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.author { font-weight: 600; font-size: 13px; }
.time { color: var(--faint); font-size: 12px; }
.thread-head .link { margin-left: auto; }
.thread .body { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0 0 8px; }
.shot { display: block; width: 100%; border-radius: 6px; border: 1px solid var(--line); margin-bottom: 8px; cursor: zoom-in; }
.reply { border-left: 2px solid var(--line-2); padding: 2px 0 2px 10px; margin: 6px 0; }
.reply .body { margin: 0; font-size: 13px; }
.thread-actions { display: flex; gap: 14px; }
.reply-box { margin-top: 8px; cursor: auto; }
.reply-box textarea { margin-bottom: 6px; }
.pin-badge { flex: none; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 11px; display: inline-grid; place-items: center; font-size: 11px; font-weight: 700; background: var(--accent); color: var(--accent-ink); }
.pin-badge.resolved { background: #8b93a1; } .pin-badge.other { background: var(--blue); } .pin-badge.draft { background: #fff; }
.other-version { margin-top: 14px; }
.other-version summary { cursor: pointer; color: var(--muted); font-size: 12.5px; margin-bottom: 8px; }

/* info */
.info-sec { padding: 4px 0 14px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 5px 10px; margin: 0 0 8px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.stats-mini { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.stats-mini dt { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stats-mini dd { margin: 0; font-weight: 650; font-size: 15px; overflow-wrap: anywhere; }
.list { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.list li { padding: 3px 0; border-bottom: 1px dashed #262a31; overflow-wrap: anywhere; }
.history { padding-left: 0; list-style: none; margin: 0; font-size: 13px; }
.history li { padding: 4px 0; }
.history li.current a { color: var(--accent); font-weight: 700; }
.warn-box { background: rgba(255, 176, 32, .08); border: 1px solid rgba(255, 176, 32, .3); color: #f3d79b; border-radius: 8px; padding: 9px 11px; margin: 10px 0 14px; font-size: 12.5px; }
.warn-box p:last-child { margin: 0; }
.cmp.identical, .cmp.geometry, .cmp.similar { color: var(--ok); } .cmp.different { color: var(--warn); }
.preview-box { position: relative; height: 300px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }

/* ---------- modal, toasts, lightbox */
dialog.modal { width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 40px); padding: 0; border: 1px solid var(--line-2); border-radius: 14px; background: var(--panel); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, .55); }
dialog.modal.wide { width: min(980px, calc(100vw - 32px)); }
dialog.modal::backdrop { background: rgba(5, 6, 8, .65); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px 6px 18px; }
.modal-head h2 { margin: 0; }
.modal-body { padding: 8px 18px 16px; overflow: auto; max-height: calc(100vh - 160px); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px 16px; border-top: 1px solid var(--line); }
.modal-actions .btn.danger { margin-right: auto; }
.lightbox-img { display: block; max-width: 100%; max-height: 75vh; margin: 0 auto; border-radius: 6px; }
.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 1000; align-items: center; }
.toast { background: #262b33; border: 1px solid var(--line-2); color: var(--text); padding: 9px 14px; border-radius: 9px; box-shadow: 0 8px 24px rgba(0, 0, 0, .4); max-width: min(560px, 90vw); transition: opacity .3s; }
.toast.ok { border-color: rgba(62, 207, 142, .5); } .toast.warn { border-color: rgba(255, 176, 32, .6); } .toast.error { border-color: rgba(255, 107, 107, .6); }
.toast.out { opacity: 0; }

/* ---------- narrow screens: stack the panel under the viewer */
@media (max-width: 900px) {
  .review { grid-template-columns: 1fr; grid-template-rows: 55vh auto; height: auto; min-height: 100%; }
  body[data-page="r"] main, body[data-page="new"] main { overflow: auto; }
  .side { border-left: 0; border-top: 1px solid var(--line); }
  .side-body { overflow: visible; }
  .inline-form { flex-direction: column; }
  .nav-user span:last-child { display: none; }
}
