:root {
  --bg: #16181d;
  --card: #1f2229;
  --line: #2e323b;
  --text: #e8e6e1;
  --muted: #9a9ca3;
  --accent: #e0a458;
  --accent-text: #1a1408;
  --ok: #7cbf8e;
  --warn: #e07a6a;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f2ee; --card: #ffffff; --line: #dedad2; --text: #22231f;
    --muted: #6d6e68; --accent: #b86e1c; --accent-text: #ffffff; --ok: #2e7d4a; --warn: #b3412f;
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) 16px calc(16px + env(safe-area-inset-bottom));
  max-width: 520px; margin: 0 auto;
}
button, input, select, textarea { font: inherit; color: inherit; }

.bar { display: flex; align-items: center; justify-content: space-between; padding: 14px 0 10px; }
.bar h1 { font-size: 1.25rem; margin: 0; letter-spacing: .02em; }
.pill { font-size: .8rem; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.pill.warn { color: var(--warn); border-color: var(--warn); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin: 12px 0; }
.card h2 { font-size: .95rem; margin: 0 0 8px; color: var(--muted); font-weight: 600; }
label { display: block; margin: 12px 0 6px; font-weight: 600; font-size: .95rem; }
label:first-child { margin-top: 0; }
.hint { color: var(--muted); font-weight: 400; font-size: .9rem; margin: 6px 0; }

.events { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.events button, .choices button, .score button {
  min-height: 48px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); cursor: pointer; touch-action: manipulation;
}
.events button[aria-pressed="true"], .choices button[aria-pressed="true"], .score button[aria-pressed="true"] {
  background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 700;
}
.choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.score { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }

input, select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg);
}
#mgOther { margin-top: 8px; }
textarea { resize: vertical; }

.when { margin: 12px 0; }
.link { background: none; border: 0; padding: 4px 0; color: var(--muted); cursor: pointer; }
.link b { color: var(--text); }
#whenInput { margin-top: 6px; }

.primary { width: 100%; border: 0; border-radius: 12px; padding: 12px; background: var(--accent); color: var(--accent-text); font-weight: 700; cursor: pointer; }
.primary.big { min-height: 56px; font-size: 1.1rem; }
.primary:disabled { opacity: .35; }

.recent { list-style: none; margin: 0; padding: 0; }
.recent li { display: flex; gap: 10px; align-items: baseline; padding: 8px 0; border-top: 1px solid var(--line); }
.recent li:first-child { border-top: 0; }
.recent .t { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 6.2em; font-size: .9rem; }
.recent .d { flex: 1; overflow-wrap: anywhere; }
.recent .s { font-size: .85rem; }
.recent .s.sent { color: var(--ok); }
.recent .s.queued { color: var(--muted); }
.recent .s.rejected { color: var(--warn); }
.recent .x { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0 4px; }
.recent .empty { color: var(--muted); }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(20px + env(safe-area-inset-bottom));
  max-width: 488px; margin: 0 auto; padding: 12px 14px; border-radius: 12px;
  background: var(--text); color: var(--bg); font-weight: 600; text-align: center;
}
.foot { display: flex; justify-content: space-between; color: var(--muted); font-size: .8rem; padding: 8px 0; }
