:root {
  color-scheme: light dark;
  --bg: #f5f4f0;
  --paper: #fff;
  --fg: #141414;
  --muted: #6b6a66;
  --line: #dddad3;
  --soft: #ebe9e3;
  --accent: #d1360f;
  --new: #ffef99;
  --warn: #c0261a;
  --ok: #1d7a3a;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101113;
    --paper: #17181b;
    --fg: #f1f0ed;
    --muted: #9b9a96;
    --line: #2b2c30;
    --soft: #1e1f23;
    --accent: #ff6b45;
    --new: #3f3812;
    --warn: #ff8a7d;
    --ok: #6fd38d;
  }
}

* { box-sizing: border-box; }

html { font-size: 16px; }
@media (min-width: 1600px) { html { font-size: 19px; } }

body {
  margin: 0;
  font: 1rem/1.5 var(--sans);
  color: var(--fg);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

h1, h2, p { margin: 0; }
h1, h2 { line-height: 1.1; letter-spacing: -0.02em; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

button {
  font: inherit;
  color: var(--fg);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
button.link {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}
button.link:hover { color: var(--fg); }

/* Small uppercase section labels. */
.label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}

.brand { font-family: var(--mono); font-weight: 600; letter-spacing: -0.01em; }
.status:empty { display: none; }
.small { font-size: 0.875rem; color: var(--muted); }

/* Large label/value facts, used for the newest scan and on the phone. */
.facts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr));
  gap: 20px 32px;
}
.fact { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.fact .k { font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.fact .v { font-size: 1.15rem; font-weight: 600; overflow-wrap: anywhere; }
.fact .v.mono { font-weight: 500; }
.fact .v.warn, td.warn, .sub.warn { color: var(--warn); }

/* ---------- Screen with the QR code ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px clamp(16px, 3vw, 48px);
  border-bottom: 1px solid var(--line);
  font-size: 0.95rem;
}
.topbar .brand { margin-right: auto; }
.count { color: var(--muted); font-variant-numeric: tabular-nums; }
.live { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.live::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
}
.live.on { color: var(--fg); }
.live.on::before { background: var(--accent); }

.board {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(0, 1.4fr);
  gap: clamp(32px, 5vw, 96px);
  width: 100%;
  max-width: 1900px;
  margin: 0 auto;
  padding: clamp(24px, 4vw, 64px) clamp(16px, 3vw, 48px);
}

.code { position: sticky; top: 24px; align-self: start; }
.code h1 { font-size: clamp(2.4rem, 4.6vw, 4.8rem); letter-spacing: -0.035em; line-height: 1; }
.code h1 span {
  display: block;
  max-width: 22em;
  margin-top: 0.6em;
  font-size: clamp(1rem, 1.35vw, 1.4rem);
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.4;
  color: var(--muted);
}
.qr { margin-top: clamp(24px, 4vh, 48px); }
.qr svg { display: block; width: min(100%, 60vh); height: auto; }
.url { margin-top: 16px; font-family: var(--mono); font-size: clamp(1.05rem, 1.6vw, 1.6rem); font-weight: 600; overflow-wrap: anywhere; }
.code .link { margin-top: 6px; font-size: 0.875rem; }

.feed { min-width: 0; }
.latest {
  margin: 0 -20px 48px;
  padding: 20px;
  border-top: 3px solid var(--fg);
  transition: background-color 1.2s;
}
.latest.new { background: var(--new); }
.latest-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.latest-device { font-size: clamp(1.8rem, 3vw, 3.2rem); }
.latest-time { color: var(--muted); white-space: nowrap; }
.latest-sub { margin: 6px 0 28px; color: var(--muted); font-size: clamp(1rem, 1.3vw, 1.3rem); }
.latest .fact .v { font-size: clamp(1.05rem, 1.35vw, 1.4rem); }
.waiting { font-size: clamp(1.4rem, 2.2vw, 2.2rem); color: var(--muted); padding: 24px 0; letter-spacing: -0.01em; }

/* Earlier scans: one row each, click for everything. */
#list { border-top: 1px solid var(--line); }
#list details { border-bottom: 1px solid var(--line); transition: background-color 1.2s; }
#list details.new { background: var(--new); }
#list details[open] { background: var(--soft); }
#list summary {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1.5fr) minmax(0, 1.1fr) minmax(0, 1.5fr) 9rem;
  gap: 16px;
  padding: 12px 8px;
  cursor: pointer;
  list-style: none;
}
#list summary::-webkit-details-marker { display: none; }
#list summary:hover { background: var(--soft); }
#list summary > span { display: flex; flex-direction: column; min-width: 0; }
#list .main { font-weight: 600; overflow-wrap: anywhere; }
#list .sub { font-size: 0.875rem; color: var(--muted); overflow-wrap: anywhere; }
#list .time .main, #list .ip .main { font-weight: 400; color: var(--muted); white-space: nowrap; }
#list .sub.ip-inline { display: none; }

table { border-collapse: collapse; }
th, td { text-align: left; vertical-align: top; }
td.mono { font-size: 0.95em; }

.details { margin: 4px 8px 20px calc(5.5rem + 24px); font-size: 0.9rem; }
.details th { font-weight: 400; color: var(--muted); padding: 3px 24px 3px 0; white-space: nowrap; }
.details td { padding: 3px 0; overflow-wrap: anywhere; }

/* ---------- Phone after scanning ---------- */

.scan { max-width: 680px; margin: 0 auto; padding: 24px 20px 56px; }
.scan > .brand { font-size: 0.875rem; color: var(--muted); margin-bottom: 28px; }
.scan h1 { font-size: clamp(2.1rem, 9vw, 3rem); letter-spacing: -0.035em; line-height: 1.02; }
.lead { font-size: 1.1rem; margin: 16px 0 20px; }
.scan .status {
  padding: 10px 14px;
  background: var(--paper);
  border-left: 3px solid var(--line);
  color: var(--muted);
}
.scan .status.ok { border-left-color: var(--ok); color: var(--fg); }
.scan .status.fail { border-left-color: var(--warn); color: var(--fg); }

.key {
  margin: 28px 0 40px;
  padding-top: 20px;
  border-top: 3px solid var(--fg);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
}
.key .v { font-size: 1.35rem; }
.key:empty { display: none; }

.facts { width: 100%; border-top: 1px solid var(--line); }
.facts tr { border-bottom: 1px solid var(--line); }
.facts th { width: 40%; padding: 10px 16px 10px 0; font-weight: 400; color: var(--muted); }
.facts td { padding: 10px 0; font-weight: 600; overflow-wrap: anywhere; }
.facts tr[data-key="ua"] td { font-weight: 400; font-size: 0.8rem; color: var(--muted); }

.info { margin-top: 48px; }
.info h2 { font-size: 1.5rem; margin: 36px 0 12px; }
.info p + p { margin-top: 12px; }
.tips { margin: 0; padding: 0; list-style: none; counter-reset: tip; }
.tips li {
  counter-increment: tip;
  display: grid;
  grid-template-columns: 2.2rem 1fr;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.tips li:last-child { border-bottom: 1px solid var(--line); }
.tips li::before { content: counter(tip, decimal-leading-zero); font-family: var(--mono); color: var(--accent); font-weight: 600; }
.scan > .small { margin-top: 48px; }

/* ---------- Narrower screens ---------- */

@media (max-width: 1200px) {
  .board { grid-template-columns: minmax(280px, 1fr) minmax(0, 1.3fr); }
}

@media (max-width: 1440px) {
  #list summary { grid-template-columns: 4.8rem minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1.4fr); }
  #list .ip { display: none; }
  #list .sub.ip-inline { display: block; }
  .details { margin-left: calc(4.8rem + 24px); }
}

@media (max-width: 900px) {
  .topbar { gap: 16px; flex-wrap: wrap; }
  .board { grid-template-columns: 1fr; gap: 40px; }
  .code { position: static; }
  .qr svg { width: min(100%, 340px); }
  .latest { margin: 0 -16px 36px; padding: 16px; }
  #list summary { grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 12px 4px; }
  #list .time { grid-column: 2; grid-row: 1; text-align: right; }
  #list .device { grid-column: 1; grid-row: 1; }
  #list .browser, #list .place { grid-column: 1 / -1; }
  #list .browser .main, #list .place .main { font-weight: 400; }
  .details { margin: 0 4px 16px; }
  .details th { white-space: normal; }
}

@media (max-width: 480px) {
  .topbar .count { display: none; }
  .facts tr { display: block; padding: 10px 0; }
  .facts th, .facts td { display: block; width: auto; padding: 0; }
  .facts th { font-size: 0.85rem; }
  .facts td { font-size: 1.05rem; margin-top: 2px; }
}
