:root {
    --bg: #111214;
    --panel: #1a1b1f;
    --panel-2: #222327;
    --line: #2d2f35;
    --ink: #e8e8ea;
    --muted: #8b8d94;
    --accent: #6ea8fe;
    --green: #39b54a;
    --yellow: #e6b422;
    --red: #e03e3e;
    --radius: 8px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
[x-cloak] { display: none !important; }

html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); }
body.no-scroll { overflow: hidden; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.4rem; margin: 0 0 .75rem; }
h2 { font-size: 1.1rem; margin: 0 0 .5rem; }
p { margin: 0 0 .5rem; }
code, .mono { font-family: var(--mono); font-size: .9em; }
kbd { font: 11px var(--mono); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; background: var(--panel-2); color: var(--ink); }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.error { color: #ff8a8a; }
.right { text-align: right; }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: .6rem 1.25rem; border-bottom: 1px solid var(--line); background: var(--panel); }
.brand { color: var(--ink); font-weight: 600; }
.topnav { display: flex; gap: 1rem; align-items: center; }
.topnav form { margin: 0; }
.page { max-width: 1400px; margin: 0 auto; padding: 1.25rem; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.25rem; }
.card.narrow { max-width: 420px; margin: 3rem auto; }
.card.dragging { border-color: var(--accent); background: #1d2430; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.row { display: flex; align-items: center; gap: .5rem; }
.row.space { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.row.gap { gap: .6rem; }
.label { color: var(--muted); font-size: .85em; }
.code { background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: .2rem .5rem; word-break: break-all; }

input[type="text"], input[type="email"], input[type="password"], textarea {
    width: 100%; background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: .5rem .65rem; font: inherit;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
textarea[readonly] { color: var(--muted); font-family: var(--mono); font-size: .85em; resize: vertical; }
label > span { display: block; font-size: .85em; color: var(--muted); margin-bottom: .25rem; }
.title-input { font-size: 1.2rem; font-weight: 600; min-width: 20rem; }
input[type="file"] { color: var(--muted); }

.btn { display: inline-flex; align-items: center; gap: .4rem; background: var(--panel-2); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: .45rem .85rem; font: inherit; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--muted); text-decoration: none; }
.btn.primary { background: var(--accent); color: #0b1220; border-color: transparent; font-weight: 600; }
.btn.small { padding: .25rem .6rem; font-size: .85em; }
.btn:disabled { opacity: .5; cursor: default; }
button.link { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }
button.link.danger { color: #ff8a8a; }

.pill { display: inline-block; border-radius: 999px; padding: .1rem .6rem; font-size: .8em; border: 1px solid var(--line); }
.pill.ok { color: var(--green); border-color: var(--green); }
.pill.off { color: var(--muted); }
.pill.manual { color: var(--accent); border-color: var(--accent); }

.table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { padding: .6rem .9rem; text-align: left; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-weight: 500; font-size: .85em; }
.table tr:last-child td { border-bottom: 0; }

.errors { color: #ff8a8a; margin: .5rem 0 0; padding-left: 1.2rem; }

.lists { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.list textarea { margin-top: .4rem; }
.list.green strong { color: var(--green); }
.list.yellow strong { color: var(--yellow); }
.list.red strong { color: var(--red); }

.dot { display: inline-flex; align-items: center; justify-content: center; min-width: 1.4em; height: 1.4em; padding: 0 .3em; border-radius: 999px; font-size: .8em; background: var(--line); color: var(--ink); }
.dot.green { background: var(--green); color: #052; }
.dot.yellow { background: var(--yellow); color: #431; }
.dot.red { background: var(--red); color: #fff; }
.dot.none { background: transparent; border: 1px solid var(--line); }

.admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.photo-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; border-top: 4px solid var(--line); }
.photo-card.decided-green { border-top-color: var(--green); }
.photo-card.decided-yellow { border-top-color: var(--yellow); }
.photo-card.decided-red { border-top-color: var(--red); }
.photo-card .thumb { background: #000; aspect-ratio: 3 / 2; display: flex; align-items: center; justify-content: center; }
.photo-card .thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.placeholder { color: var(--muted); text-align: center; font-size: .9em; padding: 1rem; }
.placeholder.error { color: #ff8a8a; }
.photo-card .meta { padding: .6rem .8rem; display: flex; flex-direction: column; gap: .4rem; }
.vote { display: flex; gap: .5rem; align-items: baseline; font-size: .85em; border-top: 1px solid var(--line); padding-top: .3rem; }
.vote em { color: var(--muted); }

.swatch { width: 22px; height: 22px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; opacity: .45; }
.swatch.green { background: var(--green); }
.swatch.yellow { background: var(--yellow); }
.swatch.red { background: var(--red); }
.swatch.active { opacity: 1; border-color: #fff; }
.swatch:hover { opacity: .85; }

.stars { display: inline-flex; gap: .1rem; }
.star { background: none; border: 0; color: var(--line); font-size: 1.1rem; cursor: pointer; padding: 0 .05rem; line-height: 1; }
.star.on { color: var(--yellow); }
.star.manual.on { color: var(--accent); }
.stars.big .star { font-size: 1.9rem; }
.stars.small { color: var(--yellow); font-size: .75em; }

.review-head h1 { margin-bottom: .1rem; }
.legend { font-size: .85em; color: var(--muted); }
.legend .dot { min-width: .9em; height: .9em; padding: 0; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .75rem; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 0; cursor: pointer; overflow: hidden; text-align: left; color: var(--ink); border-bottom: 4px solid var(--line); }
.tile img { display: block; width: 100%; height: auto; background: #000; object-fit: contain; }
.tile-meta { display: flex; justify-content: space-between; align-items: center; padding: .35rem .6rem; font-size: .85em; }
.tile.voted-green { border-bottom-color: var(--green); }
.tile.voted-yellow { border-bottom-color: var(--yellow); }
.tile.voted-red { border-bottom-color: var(--red); }
.tile:hover { border-color: var(--muted); }

.viewer { position: fixed; inset: 0; background: rgba(0, 0, 0, .92); z-index: 50; display: flex; align-items: stretch; justify-content: center; }
.viewer-inner { display: grid; grid-template-columns: 3rem 1fr 3rem 300px; width: 100%; height: 100%; }
.viewer-figure { margin: 0; display: flex; align-items: center; justify-content: center; padding: 1rem; min-width: 0; }
.viewer-figure img { max-width: 100%; max-height: calc(100vh - 2rem); object-fit: contain; border: 4px solid transparent; border-radius: 4px; }
.viewer-figure img.frame-green { border-color: var(--green); }
.viewer-figure img.frame-yellow { border-color: var(--yellow); }
.viewer-figure img.frame-red { border-color: var(--red); }
.nav { background: none; border: 0; color: var(--ink); font-size: 3rem; cursor: pointer; opacity: .6; }
.nav:hover { opacity: 1; }
.viewer-panel { background: var(--panel); border-left: 1px solid var(--line); padding: 1rem; display: flex; flex-direction: column; gap: 1rem; overflow-y: auto; }
.choices { display: flex; flex-direction: column; gap: .4rem; }
.choice { display: flex; align-items: center; gap: .6rem; background: var(--panel-2); border: 2px solid var(--line); border-radius: 6px; padding: .55rem .8rem; color: var(--ink); font: inherit; cursor: pointer; text-align: left; }
.choice.green.active { border-color: var(--green); background: #1a2e1d; }
.choice.yellow.active { border-color: var(--yellow); background: #332b12; }
.choice.red.active { border-color: var(--red); background: #341818; }
.choice:disabled { opacity: .5; cursor: default; }

@media (max-width: 900px) {
    .viewer-inner { grid-template-columns: 2.5rem 1fr 2.5rem; grid-template-rows: 1fr auto; }
    .viewer-panel { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); max-height: 45vh; }
    .viewer-figure img { max-height: 50vh; }
    .title-input { min-width: 0; }
}
