:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #15181d;
  --muted: #5b6472;
  --line: #dde1e7;
  --accent: #0b6e6e;
  --accent-text: #ffffff;
  --sel: #dff1f0;
  --ok-t: #1d7a3e;   --ok-b: #e3f4e8;
  --no-t: #b42318;   --no-b: #fde7e5;
  --part-t: #9a6700; --part-b: #fff4d6;
  --err-t: #b42318;  --err-b: transparent;
  --info-t: #3d4a5c; --info-b: #e8ecf2;
  --run-t: #1f5fbf;  --run-b: #e3edfb;
  --skip-t: #6b7280; --skip-b: #eef0f3;
  --banner: #b42318;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --card: #181c22;
    --text: #eef1f5;
    --muted: #a3acb9;
    --line: #2a3038;
    --accent: #3fb6b2;
    --accent-text: #04201f;
    --sel: #1d3a3a;
    --ok-t: #7fdc9f;   --ok-b: #163524;
    --no-t: #ff9b92;   --no-b: #3b1a17;
    --part-t: #f2c35a; --part-b: #3a2e0e;
    --err-t: #ff9b92;  --err-b: transparent;
    --info-t: #b9c4d4; --info-b: #232b36;
    --run-t: #8fb8f5;  --run-b: #172a45;
    --skip-t: #a3acb9; --skip-b: #232830;
    --banner: #8f1d14;
  }
}

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

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

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  font-size: 20px;
  line-height: 1.45;
  background: #f4f5f7;
  background: var(--bg);
  color: #15181d;
  color: var(--text);
}

#js-warning {
  margin: 0;
  padding: 14px 24px;
  background: #b42318;
  color: #ffffff;
  font-weight: 700;
}

.banner {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 20;
  margin: 0;
  padding: 14px 24px;
  background: #b42318;
  background: var(--banner);
  color: #ffffff;
  font-weight: 600;
}

.page {
  max-width: 1500px;
  margin: 0 auto;
  padding: 24px 24px 40px;
}

h1 { font-size: 40px; line-height: 1.15; margin: 0 0 8px; }
h2 { font-size: 28px; line-height: 1.2; margin: 36px 0 16px; }
h3 { margin: 0; }

.subtitle { margin: 0 0 8px; color: var(--muted); }
.how-title { font-size: 22px; margin: 20px 0 6px; }
.how { margin: 0 0 12px; padding-left: 28px; }
.how li { margin: 4px 0; }
.tip { margin: 0 0 8px; color: var(--muted); }
.restored { margin: 8px 0 0; font-size: 18px; color: var(--muted); }

.linkbtn {
  background: none;
  border: 0;
  padding: 8px 4px;
  font: inherit;
  font-weight: 600;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
  touch-action: manipulation;
}

/* Grid with an old-browser fallback: plain stacked cards first. */
.grid > .card { margin-bottom: 20px; }

@supports (display: grid) {
  .grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
    gap: 20px;
  }
  .grid > .card { margin-bottom: 0; }
}

.card {
  background: #ffffff;
  background: var(--card);
  border: 1px solid #dde1e7;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 24px;
  min-width: 0;
}

.card-head {
  display: -webkit-box;
  display: flex;
  -webkit-box-pack: justify;
  justify-content: space-between;
  -webkit-box-align: start;
  align-items: flex-start;
  margin-bottom: 6px;
}

.card-title { font-size: 24px; line-height: 1.25; font-weight: 700; margin: 0 12px 0 0; }

.why { font-size: 18px; color: var(--muted); margin: 0 0 10px; }
.detail { margin: 0 0 10px; word-wrap: break-word; }
.detail:empty { display: none; }
.card p { margin-top: 0; }
.live { margin: 12px 0 0; word-wrap: break-word; }
.live:empty { display: none; }
.note { margin: 12px 0 0; font-size: 18px; color: var(--muted); }
.question { margin: 16px 0 8px; font-weight: 600; }

/* Status pills */
.pill {
  display: inline-block;
  padding: 3px 14px;
  border: 2px solid transparent;
  border-radius: 999px;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
}
.pill-ok { color: var(--ok-t); background: var(--ok-b); }
.pill-no { color: var(--no-t); background: var(--no-b); }
.pill-part { color: var(--part-t); background: var(--part-b); }
.pill-err { color: var(--err-t); background: var(--err-b); border-color: var(--err-t); }
.pill-info { color: var(--info-t); background: var(--info-b); }
.pill-run { color: var(--run-t); background: var(--run-b); }
.pill-skip { color: var(--skip-t); background: var(--skip-b); }

/* Buttons */
.actions { display: -webkit-box; display: flex; flex-wrap: wrap; margin: 8px -6px -6px; }
.actions > * { margin: 6px; }
.ask { margin-top: 8px; }
.ask .actions, .card > .actions { margin-top: 6px; }

.btn {
  min-height: 60px;
  padding: 0 28px;
  border: 2px solid transparent;
  border-radius: 14px;
  font-family: inherit;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
.btn-secondary {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}
.btn[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--sel);
  color: var(--text);
}
.btn:disabled { opacity: 0.5; cursor: default; }

/* Controls inside cards */
.field {
  display: block;
  width: 100%;
  min-height: 60px;
  margin-top: 8px;
  padding: 0 16px;
  font-family: inherit;
  font-size: 24px;
  color: var(--text);
  background: var(--bg);
  border: 2px solid var(--line);
  border-radius: 14px;
}
select.field { font-size: 20px; }
.player { display: block; width: 100%; margin-top: 12px; }
.preview { display: block; max-width: 100%; max-height: 360px; margin-top: 12px; border-radius: 12px; background: #000000; }
.meter { height: 20px; margin-top: 10px; border-radius: 10px; background: var(--line); overflow: hidden; }
.meter-fill { height: 100%; width: 0; background: var(--accent); }

.tile-ask { display: -webkit-box; display: flex; -webkit-box-align: center; align-items: center; }
.tile-icon { width: 56px; height: 56px; margin-right: 16px; border-radius: 12px; -webkit-flex-shrink: 0; flex-shrink: 0; }

.chips { list-style: none; margin: 8px 0 0; padding: 0; display: -webkit-box; display: flex; flex-wrap: wrap; }
.chips li {
  margin: 0 8px 8px 0;
  padding: 2px 14px;
  border: 2px solid var(--line);
  border-radius: 999px;
  font-size: 18px;
  color: var(--muted);
}
.chips li.got { border-color: var(--ok-t); color: var(--ok-t); font-weight: 600; }
.chips li.miss { color: var(--no-t); }

.ua {
  margin: 8px 0 0;
  font-family: ui-monospace, Consolas, "Courier New", monospace;
  font-size: 14px;
  color: var(--muted);
  word-break: break-all;
}

.report {
  margin: 14px 0 0;
  padding: 14px;
  font-family: ui-monospace, Consolas, "Courier New", monospace;
  font-size: 18px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-wrap: break-word;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
}

/* Sticky bottom bar */
.bar {
  position: -webkit-sticky;
  position: sticky;
  bottom: 0;
  z-index: 10;
  background: #ffffff;
  background: var(--card);
  border-top: 1px solid var(--line);
}
.progress { height: 6px; background: var(--line); }
.progress-fill { height: 100%; width: 0; background: var(--accent); }
.bar-inner {
  max-width: 1500px;
  margin: 0 auto;
  padding: 10px 24px;
  display: -webkit-box;
  display: flex;
  -webkit-box-pack: justify;
  justify-content: space-between;
  -webkit-box-align: center;
  align-items: center;
}
.bar-left { min-width: 0; margin-right: 16px; font-weight: 600; }
.bar-status { display: block; font-size: 16px; font-weight: 400; color: var(--muted); }
.bar-status:empty { display: none; }

@media (max-width: 900px) {
  @supports (display: grid) {
    .grid { grid-template-columns: 1fr; }
  }
}

@media (max-width: 600px) {
  .page { padding-left: 16px; padding-right: 16px; }
  .bar-inner { padding-left: 16px; padding-right: 16px; }
  #js-warning, .banner { padding-left: 16px; padding-right: 16px; }
  .card { padding: 18px; }
}
