:root {
  color-scheme: dark;
  --bg: #0c0f12;
  --surface: #111519;
  --surface-raised: #171c21;
  --line: #293038;
  --line-soft: #20262c;
  --text: #edf0ec;
  --muted: #8e9aa4;
  --accent: #e5b84a;
  --accent-dark: #6c5420;
  --positive: #76b899;
  --negative: #cf796f;
  --font-ui: Inter, "Segoe UI", system-ui, sans-serif;
  --font-display: "Arial Narrow", "Roboto Condensed", Inter, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
}
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(420px, 1fr) 372px;
  grid-template-rows: 58px minmax(0, 1fr);
  width: 100vw;
  height: 100svh;
  background: var(--bg);
}

.topbar {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 260px 1fr 372px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: #0e1114;
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 18px; }
.brand > div { display: flex; flex-direction: column; line-height: 1; }
.brand strong { font-family: var(--font-display); font-size: 18px; letter-spacing: .12em; }
.brand span:not(.brand-mark) { color: var(--muted); font-size: 9px; letter-spacing: .16em; margin-top: 5px; }
.brand-mark {
  width: 20px; height: 20px; display: inline-block; transform: rotate(45deg);
  border: 1px solid var(--accent); position: relative; flex: none;
}
.brand-mark::after { content: ""; position: absolute; inset: 5px; background: var(--accent); }
.brand-mark.large { width: 30px; height: 30px; margin-bottom: 24px; }

.progress-block { display: flex; align-items: center; justify-content: center; gap: 14px; color: var(--muted); font-size: 12px; }
.progress-track { width: min(28vw, 340px); height: 3px; overflow: hidden; background: #272d33; }
.progress-track span { display: block; width: 0; height: 100%; background: var(--accent); transition: width .35s ease; }
.top-actions { height: 100%; display: flex; align-items: stretch; justify-content: flex-end; border-left: 1px solid var(--line); }
.quiet-button, .reviewer-button { border: 0; border-left: 1px solid var(--line); background: transparent; color: var(--muted); padding: 0 18px; }
.quiet-button:hover, .reviewer-button:hover { color: var(--text); background: var(--surface-raised); }
.session-state { display: flex; align-items: center; gap: 7px; padding: 0 14px; color: var(--positive); font-size: 10px; white-space: nowrap; }
.session-state i, .render-quality i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 10px currentColor; }
.session-state.offline { color: var(--negative); }

.queue-panel, .review-panel { min-height: 0; background: var(--surface); }
.queue-panel { border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.review-panel { border-left: 1px solid var(--line); overflow-y: auto; scrollbar-width: thin; scrollbar-color: #39424a transparent; }
.panel-heading { padding: 20px 18px 14px; display: flex; align-items: flex-end; justify-content: space-between; }
.panel-heading h1 { font-family: var(--font-display); font-size: 21px; letter-spacing: .02em; margin: 3px 0 0; }
.panel-heading > strong { color: var(--accent); font-size: 18px; font-weight: 500; }
.eyebrow { color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .16em; }

.filters { display: grid; gap: 6px; padding: 0 12px 12px; border-bottom: 1px solid var(--line); }
select, input, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 2px; background: #151a1f; color: var(--text);
}
select, input { height: 36px; padding: 0 10px; }
textarea { resize: vertical; padding: 10px; line-height: 1.45; }
select:hover, input:hover, textarea:hover { border-color: #3b4650; }

.queue { overflow-y: auto; min-height: 0; padding-bottom: 30px; scrollbar-width: thin; scrollbar-color: #39424a transparent; }
.queue-item {
  width: 100%; display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; align-items: start;
  padding: 12px 14px; border: 0; border-bottom: 1px solid var(--line-soft); background: transparent; color: var(--text); text-align: left;
  transition: background .16s ease, border-color .16s ease;
}
.queue-item:hover { background: #161b20; }
.queue-item.active { background: #1b2025; border-left: 2px solid var(--accent); padding-left: 12px; }
.queue-index { color: #5e6a74; font-variant-numeric: tabular-nums; font-size: 11px; padding-top: 2px; }
.queue-copy { min-width: 0; }
.queue-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 600; }
.queue-copy span { display: block; color: var(--muted); margin-top: 4px; font-size: 10px; text-transform: uppercase; letter-spacing: .07em; }
.queue-empty { color: var(--muted); padding: 30px 18px; line-height: 1.55; }

.workspace { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) 46px; background: #0f1215; }
.model-heading { min-height: 76px; padding: 13px 18px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--line); }
.model-heading h2 { font-family: var(--font-display); font-size: clamp(18px, 2vw, 28px); line-height: 1; margin: 5px 0 0; overflow-wrap: anywhere; }
.model-heading p { color: var(--muted); font-size: 11px; margin: 7px 0 0; }
.view-tools { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 3px; }
.view-tools button, .navigation-bar button {
  border: 0; background: transparent; color: var(--muted); padding: 7px 9px; font-size: 11px;
}
.view-tools button:hover, .view-tools button.active, .navigation-bar button:hover { color: var(--text); background: var(--surface-raised); }
.view-tools button.active { box-shadow: inset 0 -1px var(--accent); }
.tool-divider { width: 1px; height: 20px; margin: 0 4px; background: var(--line); }

.viewport { min-height: 0; position: relative; overflow: hidden; background: #101317; }
.viewport canvas { width: 100%; height: 100%; display: block; opacity: 0; animation: canvas-in .4s ease forwards; }
@keyframes canvas-in { to { opacity: 1; } }
.viewport-help { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); color: #77838d; font-size: 10px; letter-spacing: .04em; pointer-events: none; white-space: nowrap; }
.render-quality { position: absolute; z-index: 2; top: 12px; left: 12px; display: flex; align-items: center; gap: 7px; padding: 7px 9px; border: 1px solid #334039; background: rgba(13,17,20,.86); color: var(--positive); font-size: 10px; backdrop-filter: blur(6px); }
.render-quality.checking { color: var(--muted); }
.render-quality.warning { border-color: #665936; color: var(--accent); }
.render-quality.error { border-color: #603c39; color: var(--negative); }
.report-render-button { position: absolute; z-index: 2; right: 12px; bottom: 12px; border: 1px solid #3b4650; background: rgba(13,17,20,.86); color: #b6c0c7; padding: 8px 10px; font-size: 10px; backdrop-filter: blur(6px); }
.report-render-button:hover { border-color: var(--negative); color: #e39a91; }
.viewer-loading { position: absolute; inset: 0; z-index: 3; display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); background: #101317; }
.viewer-loading[hidden] { display: none; }
.viewer-loading span { width: 12px; height: 12px; border: 1px solid #4d5963; border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.navigation-bar { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); padding: 0 8px; }
.navigation-bar span { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }

#review-form { display: flex; flex-direction: column; min-height: 100%; }
.review-section { padding: 16px 18px; border-bottom: 1px solid var(--line); }
.verdicts { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 10px; border: 1px solid var(--line); }
.verdicts button { min-height: 54px; border: 0; border-right: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 10px; }
.verdicts button:last-child { border-right: 0; }
.verdicts button span { display: block; font-size: 21px; line-height: 18px; margin-bottom: 5px; }
.verdicts button:hover { color: var(--text); background: var(--surface-raised); }
.verdicts button[data-verdict="dislike"].active { color: var(--negative); background: rgba(207,121,111,.09); }
.verdicts button[data-verdict="neutral"].active { color: var(--accent); background: rgba(229,184,74,.08); }
.verdicts button[data-verdict="like"].active { color: var(--positive); background: rgba(118,184,153,.09); }
.verdicts button[data-verdict="not_evaluable"].active { color: #b6c4cf; background: rgba(142,154,164,.11); }

.scores-section { display: grid; gap: 12px; }
.score-row { display: grid; grid-template-columns: 72px minmax(0, 1fr) 18px; gap: 8px; align-items: center; }
.score-row label { color: var(--muted); font-size: 11px; }
.score-row output { color: var(--accent); font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.score-scale { display: grid; grid-template-columns: repeat(10, 1fr); gap: 2px; }
.score-scale button { height: 18px; padding: 0; border: 1px solid #323b43; background: #1b2126; color: transparent; }
.score-scale button:hover, .score-scale button.active { background: var(--accent); border-color: var(--accent); }
.form-requirement { color: #68747d; font-size: 9px; text-align: right; }
.form-requirement.ready { color: var(--positive); }

.field-label { display: block; margin: 0 0 7px; color: var(--muted); font-size: 11px; }
select + .field-label { margin-top: 14px; }
.spaced-label { margin-top: 14px; }
#asset-style + .field-label { margin-top: 14px; }
.tag-list { display: grid; grid-template-columns: 1fr 1fr; gap: 5px 10px; }
.tag-list label { display: flex; gap: 6px; align-items: center; color: #aeb7be; font-size: 10px; line-height: 1.25; }
.tag-list input { width: 13px; height: 13px; accent-color: var(--accent); }
.section-title { display: flex; justify-content: space-between; }
.section-title #issue-count { color: var(--accent); font-size: 11px; }
.selected-cube { margin-top: 10px; padding: 9px 10px; border-left: 2px solid var(--accent); background: #181e23; font-size: 11px; overflow-wrap: anywhere; }
.selected-cube.empty { border-left-color: #3a444d; color: var(--muted); }
.issue-editor { display: grid; gap: 7px; margin-top: 8px; }
.secondary-action { height: 34px; border: 1px solid #3b4650; background: transparent; color: #c6cdd2; }
.secondary-action:hover { border-color: var(--accent); color: var(--accent); }
.issue-list { display: grid; gap: 6px; margin-top: 8px; }
.issue-item { position: relative; padding: 8px 28px 8px 9px; border: 1px solid var(--line); color: #aeb7be; font-size: 10px; line-height: 1.4; }
.issue-item strong { color: var(--text); display: block; margin-bottom: 2px; }
.issue-item button { position: absolute; right: 5px; top: 5px; width: 20px; height: 20px; border: 0; background: transparent; color: var(--muted); }
.issue-item button:hover { color: var(--negative); }
.comment-section { flex: 1; }
.save-zone { position: sticky; bottom: 0; padding: 12px 18px 16px; background: rgba(17,21,25,.96); backdrop-filter: blur(8px); }
.save-zone p { min-height: 16px; margin: 0 0 7px; color: var(--muted); font-size: 10px; }
.save-zone p.error { color: var(--negative); }
.primary-action { width: 100%; height: 43px; border: 0; background: var(--accent); color: #17130a; font-weight: 750; letter-spacing: .02em; }
.primary-action:hover { background: #f0c65d; }
.primary-action:disabled { cursor: not-allowed; opacity: .45; }

dialog { width: min(420px, calc(100vw - 32px)); border: 1px solid #39434c; border-radius: 0; padding: 0; color: var(--text); background: #12171b; box-shadow: 0 30px 90px rgba(0,0,0,.58); }
dialog::backdrop { background: rgba(6,8,10,.82); backdrop-filter: blur(8px); }
dialog form { padding: 34px; }
dialog h2 { margin: 8px 0 8px; font-family: var(--font-display); font-size: 28px; }
dialog p { color: var(--muted); line-height: 1.5; }
dialog input { margin-bottom: 14px; }
.dialog-error { min-height: 20px; color: var(--negative); font-size: 11px; }
.study-rules { margin: 18px 0; padding: 14px 14px 14px 34px; border: 1px solid var(--line); color: #b3bcc3; font-size: 11px; line-height: 1.55; }
.study-rules li + li { margin-top: 5px; }
.blind-choice { display: grid; grid-template-columns: 18px 1fr; gap: 10px; margin: 6px 0 4px; padding: 12px; border: 1px solid var(--line); color: var(--muted); font-size: 10px; line-height: 1.4; cursor: pointer; }
.blind-choice input { width: 15px; height: 15px; margin: 1px 0 0; accent-color: var(--accent); }
.blind-choice strong { display: block; margin-bottom: 2px; color: var(--text); font-size: 11px; }
.dialog-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; margin-top: 4px; }
.dialog-actions .primary-action, .dialog-actions .secondary-action { height: 43px; }
body.blind-mode .bias-sensitive { display: none; }

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 210px minmax(360px, 1fr) 330px; }
  .topbar { grid-template-columns: 210px 1fr 330px; }
  .tag-list { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  body { overflow: auto; }
  .app-shell { height: auto; min-height: 100svh; grid-template-columns: 1fr; grid-template-rows: 56px 72svh auto; }
  .topbar { position: sticky; top: 0; grid-column: 1; grid-template-columns: 1fr auto; }
  .progress-block { display: none; }
  .top-actions { border: 0; }
  .queue-panel { display: none; }
  .workspace { grid-row: 2; }
  .review-panel { grid-row: 3; border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
  .view-tools { max-width: 220px; }
  .model-heading { padding: 10px 12px; }
  .viewport-help { font-size: 8px; }
  .tag-list { grid-template-columns: 1fr 1fr; }
}
