:root {
  --bg: #14161a;
  --panel: #1c1f26;
  --panel-2: #232833;
  --panel-3: #2b3240;
  --line: #2e3542;
  --text: #e6e9ef;
  --muted: #8b95a7;
  --accent: #4c8dff;
  --accent-soft: #22335a;
  --ok: #3fa86a;
  --ok-soft: #1d3a2a;
  --bad: #e05a5a;
  --bad-soft: #3a2026;
  --skip: #b38b3f;
  --skip-soft: #3a3320;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, sans-serif;
}

button, input, select { font: inherit; }

/* ---------- Верхняя панель ---------- */
#topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.brand h1 { margin: 0; font-size: 16px; letter-spacing: .2px; }
.brand .hint { color: var(--muted); font-size: 12px; }
.actions { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.summary { color: var(--muted); font-size: 12px; }

.btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent-soft); border-color: var(--accent); }
.linklike {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
  text-decoration: underline;
  padding: 2px;
}

/* ---------- Каркас ---------- */
#app { display: flex; height: calc(100vh - 56px); overflow: hidden; }

/* ---------- Боковая панель ---------- */
#sidebar {
  width: 300px;
  min-width: 300px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}
.side-top { padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; border-bottom: 1px solid var(--line); }
#search, #filter {
  width: 100%;
  padding: 8px 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  outline: none;
}
#search:focus, #filter:focus { border-color: var(--accent); }
.progress { color: var(--muted); font-size: 12px; }
.progress b { color: var(--text); }

#case-list {
  list-style: none;
  margin: 0;
  padding: 6px 8px 16px;
  overflow-y: auto;
  flex: 1;
}
#case-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
  border-left: 3px solid transparent;
}
#case-list li:hover { background: var(--panel-2); }
#case-list li.active { background: var(--accent-soft); border-left-color: var(--accent); }
#case-list li[hidden] { display: none; }
#case-list .cid { font-weight: 600; min-width: 44px; }
#case-list .dots { display: flex; gap: 3px; margin-left: auto; }
#case-list .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--line);
}
#case-list .dot.on { background: var(--accent); }
#case-list .mark { width: 16px; text-align: center; font-size: 12px; }
#case-list li.verdict-ok .mark { color: var(--ok); }
#case-list li.verdict-bad .mark { color: var(--bad); }
#case-list li.verdict-skip .mark { color: var(--skip); }
#case-list li.has-label-flag .cid::after { content: "•"; color: var(--muted); margin-left: 2px; }

/* ---------- Основная область ---------- */
#main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

#welcome { margin: auto; text-align: center; color: var(--muted); padding: 40px; }
#welcome p { margin: 6px 0; }
.muted { color: var(--muted); }

#case-view { display: flex; flex-direction: column; height: 100%; overflow: hidden; }

#case-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
#case-title { font-size: 16px; font-weight: 600; flex: 1; }
#case-title .sub { color: var(--muted); font-weight: 400; font-size: 13px; margin-left: 10px; }
.auto { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }

#case-head {
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
#case-head .dist { color: var(--skip); }

#columns-wrap { flex: 1; overflow: auto; padding: 12px; }
#columns {
  display: grid;
  grid-template-columns: repeat(4, minmax(210px, 1fr));
  gap: 12px;
  align-items: start;
}

.period-col {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 120px;
}
.period-col.missing { border-style: dashed; background: transparent; }
.period-head {
  padding: 8px 10px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
}
.period-head .period-name { font-weight: 600; font-size: 13px; }
.period-head .period-folder { color: var(--muted); font-size: 11px; }
.period-head .meta { color: var(--muted); font-size: 11px; margin-top: 4px; }
.period-head .meta .coords { opacity: .8; }
.empty-note { padding: 20px 12px; color: var(--muted); text-align: center; font-size: 13px; }

.cat-title {
  padding: 8px 10px 2px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
}
.photos { display: flex; flex-direction: column; gap: 8px; padding: 4px 8px 8px; }
.photo { margin: 0; background: var(--panel-2); border-radius: 8px; overflow: hidden; }
.photo img {
  display: block;
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  background: #0d0f12;
  cursor: zoom-in;
}
.photo figcaption {
  padding: 4px 8px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.photo.small img { max-height: 120px; }

details.others { border-top: 1px solid var(--line); }
details.others summary {
  padding: 8px 10px;
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
}
details.others summary:hover { color: var(--text); }
.others-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 6px 8px 10px;
}
.others-grid .photo img { max-height: 120px; }
.others-grid .photo figcaption { font-size: 10px; }

/* ---------- Панель вердикта ---------- */
#verdict-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
#verdict-bar .btn.ok { border-color: var(--ok); }
#verdict-bar .btn.ok.active { background: var(--ok-soft); border-color: var(--ok); }
#verdict-bar .btn.bad { border-color: var(--bad); }
#verdict-bar .btn.bad.active { background: var(--bad-soft); border-color: var(--bad); }
#verdict-bar .btn.skip { border-color: var(--skip); }
#verdict-bar .btn.skip.active { background: var(--skip-soft); border-color: var(--skip); }
#comment {
  flex: 1;
  min-width: 180px;
  padding: 8px 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  outline: none;
}
#comment:focus { border-color: var(--accent); }
#review-state { font-size: 12px; }

/* ---------- Лайтбокс ---------- */
#lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .88);
  display: flex;
  flex-direction: column;
  z-index: 100;
}
#lightbox[hidden] { display: none; }
.lb-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(20, 22, 26, .9);
  border-bottom: 1px solid var(--line);
}
#lb-caption { flex: 1; color: var(--text); font-size: 13px; }
.lb-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 12px;
}
.lb-stage img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(35, 40, 51, .85);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 30px;
  line-height: 1;
  width: 46px;
  height: 64px;
  border-radius: 8px;
  cursor: pointer;
}
.lb-nav:hover { border-color: var(--accent); }
#lb-prev { left: 12px; }
#lb-next { right: 12px; }

/* ---------- Загрузка ---------- */
#loading {
  position: fixed;
  inset: 0;
  background: rgba(20, 22, 26, .75);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 200;
  color: var(--text);
}
#loading[hidden] { display: none; }
.spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Узкие экраны ---------- */
@media (max-width: 900px) {
  #sidebar { width: 240px; min-width: 240px; }
  #columns { grid-template-columns: repeat(4, minmax(170px, 1fr)); }
}
