:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --surface: #fffdf8;
  --surface-2: #f0eee8;
  --ink: #1f2529;
  --muted: #6f777f;
  --line: #d7d2c8;
  --accent: #9f1d2b;
  --accent-2: #006a67;
  --shadow: 0 18px 36px rgba(31, 37, 41, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { overflow-x: hidden; }
body { margin: 0; min-width: 320px; color: var(--ink); background: var(--bg); }
button, input { font: inherit; }
input[type="range"] { width: 100%; min-width: 0; display: block; accent-color: var(--accent-2); }
h1, h2, h3, p, dl { margin: 0; }
.app-shell { min-height: 100vh; display: grid; grid-template-rows: auto 1fr; }
.topbar {
  min-height: 76px;
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(280px, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.94);
  position: sticky;
  top: 0;
  z-index: 2;
}
.brand { display: flex; align-items: center; min-width: 0; gap: 12px; }
.brand-mark {
  width: 42px; height: 42px; display: grid; place-items: center;
  background: var(--ink); color: var(--surface); border-radius: 6px; font-weight: 800;
}
h1 { font-size: 18px; line-height: 1.2; }
.brand p, .meta-line { color: var(--muted); font-size: 12px; }
.searchbar { display: grid; grid-template-columns: 1fr 44px; gap: 8px; }
.searchbar input {
  width: 100%; height: 44px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--surface); color: var(--ink); padding: 0 14px; outline: none;
}
.searchbar input:focus { border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(0, 106, 103, 0.14); }
.layout-tools { display: flex; gap: 8px; justify-content: flex-end; }
.password-panel {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(260px, 420px);
  gap: 14px;
  align-items: end;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: #09090d;
  color: #e8e8f0;
}
.password-panel[hidden] { display: none; }
.password-panel h2 { margin: 0 0 4px; font-size: 16px; }
.password-panel p { color: #9b9cab; font-size: 12px; }
.password-form { display: grid; grid-template-columns: 1fr 84px; gap: 8px; }
.password-form input {
  width: 100%; height: 44px; border: 1px solid #2a2a38; border-radius: 6px;
  background: #050507; color: #e8e8f0; padding: 0 12px; outline: none;
}
.password-error { grid-column: 1 / -1; min-height: 18px; }
.icon-button, .tool-button, .mini-button {
  border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); cursor: pointer;
}
.icon-button { height: 44px; display: grid; place-items: center; font-size: 13px; font-weight: 760; }
.primary { background: var(--accent); border-color: var(--accent); color: white; }
.mini-button { min-height: 30px; padding: 0 9px; font-size: 12px; }
.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 0.52fr) minmax(420px, 1.34fr) minmax(420px, 1.12fr);
  gap: 14px;
  padding: 14px;
  min-height: 0;
  align-items: start;
}
.app-shell.sidebar-collapsed .workspace { grid-template-columns: minmax(420px, 1fr) minmax(520px, 1.75fr); }
.app-shell.results-collapsed .workspace { grid-template-columns: minmax(300px, 0.45fr) minmax(620px, 1.7fr); }
.app-shell.sidebar-collapsed.results-collapsed .workspace { grid-template-columns: minmax(680px, 1fr); }
.app-shell.sidebar-collapsed .sidebar, .app-shell.results-collapsed .results-pane { display: none; }
.sidebar, .results-pane, .preview-pane { min-width: 0; width: 100%; }
.sidebar { display: grid; align-content: start; gap: 14px; }
.panel, .results-pane, .preview-pane {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow);
}
.panel { padding: 14px; overflow: hidden; }
.panel-title, .pane-head h2 { font-size: 13px; font-weight: 760; text-transform: uppercase; color: #3a4147; }
.note { margin-top: 10px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.stats-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.stats-grid div { border: 1px solid var(--line); border-radius: 6px; padding: 10px; background: var(--surface-2); }
.stats-grid dt { color: var(--muted); font-size: 11px; }
.stats-grid dd { margin: 2px 0 0; font-size: 20px; font-weight: 760; overflow-wrap: anywhere; }
.slider-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 12px; color: var(--muted); font-size: 13px; }
.slider-row strong { color: var(--ink); font-size: 13px; }
.results-pane, .preview-pane { display: grid; grid-template-rows: auto 1fr; min-height: calc(100vh - 104px); overflow: hidden; }
.pane-head {
  min-height: 52px; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line);
}
.pane-head span, .pane-head a { color: var(--muted); font-size: 12px; }
.preview-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: flex-end; }
.results-list { display: grid; align-content: start; gap: 8px; overflow: auto; padding: 12px; }
.result-card {
  width: 100%; display: grid; gap: 8px; padding: 12px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: inherit; text-align: left;
}
.result-card:hover { border-color: var(--accent-2); }
.result-card.active { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.result-card h3 { font-size: 15px; line-height: 1.3; }
.result-card p { color: #3f474e; font-size: 13px; line-height: 1.45; }
.score-line { display: flex; flex-wrap: wrap; gap: 10px; color: var(--muted); font-size: 11px; }
.quality-line { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-top: 8px; min-height: 24px; color: var(--muted); font-size: 12px; }
.quality-line.compact { margin-top: 0; min-height: 20px; font-size: 11px; }
.quality-badge {
  display: inline-flex; align-items: center; min-height: 22px; padding: 0 7px;
  border: 1px solid rgba(0, 106, 103, 0.34); border-radius: 5px;
  background: rgba(0, 106, 103, 0.1); color: var(--ink); font-weight: 700; line-height: 1;
}
.quality-meta { color: var(--muted); }
.preview { overflow: auto; padding: 18px; }
.preview h3 { font-size: 22px; line-height: 1.22; max-width: 780px; }
.preview .meta-line { margin-top: 8px; }
.preview p { margin-top: 18px; max-width: 980px; white-space: pre-wrap; line-height: 1.62; font-size: 15px; }
.app-shell.results-collapsed .preview p, .app-shell.sidebar-collapsed.results-collapsed .preview p { max-width: 1120px; font-size: 17px; }
.image-panel { margin-top: 18px; }
.image-carousel { display: grid; gap: 10px; margin-top: 10px; }
.image-stage {
  display: grid; place-items: center; width: min(760px, 100%); max-height: 520px;
  border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: var(--surface-2);
}
.image-stage img { width: 100%; max-height: 520px; display: block; object-fit: contain; }
.image-thumbs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.thumb-button {
  flex: 0 0 92px; width: 92px; height: 68px; padding: 0;
  border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: var(--surface-2); cursor: pointer;
}
.thumb-button.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(159, 29, 43, 0.16); }
.thumb-button img { width: 100%; height: 100%; display: block; object-fit: cover; }
.eval-panel { margin-top: 18px; }
.eval-summary { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; color: var(--muted); font-size: 12px; }
.eval-summary strong { color: var(--ink); }
.eval-table { width: 100%; margin-top: 10px; border-collapse: collapse; font-size: 13px; }
.eval-table th, .eval-table td { border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: left; }
.image-panel .empty-state, .eval-panel .empty-state { min-height: 92px; }
.empty-state {
  display: grid; place-items: center; min-height: 180px; color: var(--muted);
  border: 1px dashed var(--line); border-radius: 8px; padding: 18px; text-align: center;
}
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
@media (max-width: 980px) {
  .workspace { grid-template-columns: minmax(280px, 360px) minmax(420px, 1fr); }
  .app-shell.sidebar-collapsed .workspace,
  .app-shell.results-collapsed .workspace,
  .app-shell.sidebar-collapsed.results-collapsed .workspace { grid-template-columns: 1fr; }
  .preview-pane { grid-column: 1 / -1; min-height: 460px; }
}
@media (max-width: 820px) {
  .topbar { grid-template-columns: 1fr; }
  .layout-tools { justify-content: stretch; }
  .layout-tools .mini-button { flex: 1; }
  .workspace { grid-template-columns: 1fr; }
  .results-pane, .preview-pane { min-height: 420px; }
}
