/* Mobile first: every rule is correct at 320-390px; the one media query only widens the page. */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #16181d;
  --muted: #5b6270;
  --border: #d9dce2;
  --accent: #1f5fd1;
  --accent-text: #ffffff;
  --final: #1b7f3b;
  --review: #a35c00;
  --error-bg: #fdecec;
  --error-text: #9b1c1c;
  --radius: 10px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --surface: #1b1e24;
    --text: #e8eaee;
    --muted: #a0a7b4;
    --border: #2f343d;
    --accent: #5b8ff0;
    --accent-text: #0b0d10;
    --final: #4cc278;
    --review: #f0a640;
    --error-bg: #3a1717;
    --error-text: #ffb4b4;
  }
}

* { box-sizing: border-box; }

/* Author display rules (.card is a grid) would otherwise override the hidden attribute. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.top {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 52px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.top h1 {
  margin: 0;
  font-size: 1.05rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pill {
  flex: none;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  color: var(--muted);
}
.pill[data-state="ready"] { color: var(--final); border-color: var(--final); }
.pill[data-state="down"] { color: var(--error-text); border-color: var(--error-text); }

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 12px 16px 32px;
  display: grid;
  gap: 12px;
}

.note { margin: 0; color: var(--muted); font-size: 0.875rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: grid;
  gap: 14px;
  min-width: 0;
}

.field { display: grid; gap: 6px; }
.label { font-weight: 600; }
.hint { color: var(--muted); font-size: 0.8rem; }

input[type="password"],
input[type="file"] {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}
input[type="file"] { padding: 8px; }
input[type="file"]::file-selector-button {
  min-height: 32px;
  margin-right: 10px;
  padding: 4px 12px;
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}
input:focus-visible,
.button:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.button {
  min-height: 48px;
  width: 100%;
  font: inherit;
  font-weight: 600;
  color: var(--accent-text);
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
.button:disabled { opacity: 0.6; cursor: progress; }

.error {
  margin: 0;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--error-bg);
  color: var(--error-text);
  overflow-wrap: anywhere;
}

.photo { position: relative; line-height: 0; }
.photo img {
  display: block;
  width: 100%;
  height: auto; /* natural aspect, so the percentage boxes line up with the plates */
  border-radius: 8px;
  background: var(--bg);
}
.boxes { position: absolute; inset: 0; pointer-events: none; }
.box { position: absolute; border: 3px solid var(--review); border-radius: 4px; }
.box.final { border-color: var(--final); }
.tag {
  position: absolute;
  top: -3px;
  left: -3px;
  padding: 2px 6px;
  font: 600 0.75rem/1.2 system-ui, sans-serif;
  color: #fff;
  background: var(--review);
  border-radius: 4px 0 4px 0;
}
.box.final .tag { background: var(--final); }

.summary { margin: 0; font-weight: 600; }

.plates { margin: 0; padding: 0; list-style: none; display: grid; gap: 12px; }
.plate { border: 1px solid var(--border); border-radius: 8px; padding: 12px; display: grid; gap: 10px; }
.plate-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.plate-text {
  font: 700 1.4rem/1.2 ui-monospace, "Cascadia Mono", Consolas, monospace;
  letter-spacing: 0.04em;
  overflow-wrap: anywhere;
}

.chip {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid currentColor;
}
.chip.final { color: var(--final); }
.chip.review { color: var(--review); }
.chip.muted { color: var(--muted); font-weight: 400; }

.reasons { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }

.facts,
.meta {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(0, 11rem) minmax(0, 1fr);
  gap: 4px 12px;
  font-size: 0.9rem;
}
.facts dt,
.meta dt { color: var(--muted); }
.facts dd,
.meta dd { margin: 0; overflow-wrap: anywhere; }

.raw summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; color: var(--muted); }
.raw pre {
  margin: 0;
  padding: 12px;
  max-height: 50vh;
  overflow: auto;
  font-size: 0.8rem;
  line-height: 1.4;
  background: var(--bg);
  border-radius: 8px;
}

@media (min-width: 640px) {
  .page { padding-top: 20px; gap: 16px; }
  .top h1 { font-size: 1.15rem; }
}
