:root {
  --bg: #0b0e14;
  --surface: #131823;
  --surface-2: #1a2030;
  --line: #232a3a;
  --text: #e9ecf2;
  --muted: #8d95a8;
  --faint: #5d667a;
  --button: #f2f4f8;
  --button-text: #0b0e14;
  --new: #8d95a8;
  --looking: #f5b942;
  --fixed: #3ecf8e;
  --wontfix: #6b7385;
  --live: #ff5d5d;
  --error: #ff7a7a;
  --radius: 14px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #f0f2f5;
    --line: #e3e6ec;
    --text: #12151c;
    --muted: #5f6778;
    --faint: #9aa1b0;
    --button: #12151c;
    --button-text: #ffffff;
    --new: #6b7385;
    --looking: #c58410;
    --fixed: #138a57;
    --wontfix: #9aa1b0;
    --error: #c8323a;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
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;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img, video { display: block; max-width: 100%; }

.top {
  max-width: 760px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 20px 0;
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 650; }
.brand img { border-radius: 7px; }

main { max-width: 760px; margin: 0 auto; padding: 0 20px 80px; }

/* ---------- intro ---------- */
.intro { padding: 44px 0 28px; }
.over {
  margin: 0 0 10px;
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; letter-spacing: .02em; color: var(--muted);
}
.live { width: 8px; height: 8px; border-radius: 50%; background: var(--live); animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
h1 { margin: 0; font-size: clamp(30px, 6vw, 42px); line-height: 1.1; letter-spacing: -.02em; font-weight: 750; }
.intro h1 + .primary { margin-top: 24px; }

.primary {
  border: 0; border-radius: 999px;
  background: var(--button); color: var(--button-text);
  padding: 13px 24px; font-weight: 650; font-size: 16px;
  transition: transform .08s ease, opacity .15s ease;
}
.primary:active { transform: scale(.98); }
.primary:disabled { opacity: .45; cursor: default; }
.primary.wide { width: 100%; }

/* ---------- tabs ---------- */
.tabs {
  position: sticky; top: 0; z-index: 2;
  display: flex; gap: 4px; overflow-x: auto;
  margin: 0; padding: 10px 0;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; border: 0; background: none; color: var(--muted);
  padding: 7px 12px; border-radius: 999px; font-size: 14px; font-weight: 600;
}
.tab span { margin-left: 6px; color: var(--faint); font-weight: 500; }
.tab[aria-pressed="true"] { background: var(--surface-2); color: var(--text); }

/* ---------- board ---------- */
.board { list-style: none; margin: 0; padding: 0; }
.item { padding: 20px 0; border-bottom: 1px solid var(--line); }
.item.flash { animation: flash 2.4s ease-out; }
@keyframes flash { from { background: var(--surface-2); } to { background: transparent; } }
.item-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 650; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-new { color: var(--new); }
.status-looking { color: var(--looking); }
.status-fixed { color: var(--fixed); }
.status-wontfix { color: var(--wontfix); }
.item h3 { margin: 6px 0 0; font-size: 17px; line-height: 1.35; font-weight: 650; overflow-wrap: anywhere; }
.item.is-wontfix h3 { color: var(--muted); }
.details { margin: 6px 0 0; color: var(--muted); white-space: pre-line; overflow-wrap: anywhere; }
.details.clamped { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.more { border: 0; background: none; padding: 0; margin-top: 4px; color: var(--text); font-size: 14px; font-weight: 600; }
.media { display: flex; gap: 8px; margin-top: 12px; overflow-x: auto; scrollbar-width: none; }
.media::-webkit-scrollbar { display: none; }
.thumb {
  position: relative; flex: none; width: 168px; height: 112px; padding: 0; border: 0;
  border-radius: 10px; overflow: hidden; background: var(--surface-2);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .play {
  position: absolute; inset: auto 6px 6px auto;
  padding: 2px 7px; border-radius: 6px; font-size: 12px; font-weight: 650;
  background: rgba(0, 0, 0, .65); color: #fff;
}
.waiting { margin: 10px 0 0; font-size: 13px; color: var(--faint); }
.note { margin: 12px 0 0; padding-left: 12px; border-left: 2px solid var(--line); font-size: 15px; overflow-wrap: anywhere; }
.note b { font-weight: 650; }
.empty { color: var(--muted); text-align: center; padding: 40px 0; }

/* ---------- report sheet ---------- */
dialog { color: var(--text); }
dialog::backdrop { background: rgba(4, 6, 10, .6); }
.sheet {
  width: min(560px, 100vw); max-height: min(92dvh, 900px);
  padding: 0; border: 1px solid var(--line); border-radius: 20px;
  background: var(--surface);
}
.sheet[open] { display: flex; }
.sheet form { display: flex; flex-direction: column; width: 100%; min-height: 0; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 6px; }
.sheet-head h2 { margin: 0; font-size: 19px; font-weight: 700; }
.icon-btn { border: 0; background: var(--surface-2); color: var(--muted); width: 32px; height: 32px; border-radius: 50%; font-size: 14px; }
.sheet-body { padding: 8px 20px 4px; overflow-y: auto; min-height: 0; }
.field { display: block; margin: 0 0 18px; padding: 0; border: 0; min-width: 0; }
legend.label { padding: 0; }
.label { display: block; margin-bottom: 7px; font-size: 14px; font-weight: 600; }
.label em { font-style: normal; font-weight: 500; color: var(--faint); margin-left: 4px; }
input[type="text"], textarea {
  width: 100%; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg); outline: none;
  font-size: 16px; /* no zoom on iPhone */
}
textarea { resize: vertical; min-height: 96px; }
input[type="text"]:focus, textarea:focus { border-color: var(--muted); }
::placeholder { color: var(--faint); }

.drop {
  width: 100%; display: grid; gap: 2px; justify-items: center;
  padding: 18px 14px; border: 1.5px dashed var(--line); border-radius: 12px;
  background: none; text-align: center;
}
.drop strong { font-weight: 650; }
.drop span { font-size: 13px; color: var(--muted); }
.drop.over { border-color: var(--text); background: var(--surface-2); }
.picked { list-style: none; margin: 10px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.picked:empty { display: none; }
.pick { position: relative; aspect-ratio: 4 / 3; border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.pick img, .pick video { width: 100%; height: 100%; object-fit: cover; }
.pick .pick-name { position: absolute; inset: auto 0 0 0; padding: 4px 6px; font-size: 11px; color: #fff; background: rgba(0, 0, 0, .55); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pick .remove {
  position: absolute; top: 5px; right: 5px; width: 24px; height: 24px; border: 0; border-radius: 50%;
  background: rgba(0, 0, 0, .65); color: #fff; font-size: 11px;
}

.segmented { display: flex; gap: 6px; }
.segmented label { flex: 1; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  display: block; text-align: center; padding: 10px 6px;
  border: 1px solid var(--line); border-radius: 12px; font-size: 15px; font-weight: 600; color: var(--muted);
  cursor: pointer;
}
.segmented input:checked + span { border-color: var(--text); color: var(--text); background: var(--surface-2); }
.segmented input:focus-visible + span { outline: 2px solid var(--muted); outline-offset: 2px; }
.turnstile:empty { display: none; }
.turnstile { margin-bottom: 8px; min-height: 0; }

.sheet-foot { padding: 12px 20px max(18px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.error { margin: 0 0 10px; color: var(--error); font-size: 14px; }
.error:empty { display: none; }

.sheet-progress, .sheet-done { padding: 12px 20px 20px; }
.progress-title { margin: 0 0 14px; font-weight: 650; }
.progress-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.progress-row { display: grid; gap: 6px; font-size: 14px; }
.progress-row .row-top { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); }
.progress-row .row-top span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--text); transition: width .25s ease; }
.progress-row.failed .row-top span:last-child { color: var(--error); }
.progress-row.failed .bar i { background: var(--error); }
.sheet-done { text-align: center; padding-top: 24px; }
.done-mark { margin: 0 auto 10px; width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--fixed); font-size: 24px; font-weight: 700; }
.sheet-done h3 { margin: 0 0 6px; font-size: 20px; }
.done-text { margin: 0; color: var(--muted); white-space: pre-line; }

@media (max-width: 600px) {
  .sheet {
    width: 100vw; max-width: 100vw; max-height: 94dvh;
    margin: auto 0 0; border-radius: 20px 20px 0 0; border-bottom: 0;
  }
  .intro { padding-top: 30px; }
  .thumb { width: 112px; height: 84px; }
}

/* ---------- media viewer ---------- */
.viewer {
  width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0;
  padding: 0; border: 0; background: rgba(4, 6, 10, .94);
}
.viewer[open] { display: grid; place-items: center; }
.viewer-stage { width: 100%; height: 100%; display: grid; place-items: center; padding: 56px 12px 24px; }
.viewer-stage img, .viewer-stage video { max-width: 100%; max-height: calc(100dvh - 80px); border-radius: 8px; }
.viewer-close { position: fixed; top: max(14px, env(safe-area-inset-top)); right: 14px; background: rgba(255, 255, 255, .12); color: #fff; z-index: 1; }

@media (prefers-reduced-motion: reduce) {
  .live, .item.flash { animation: none; }
}
