:root {
  color-scheme: light dark;
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface-2: #eceae4;
  --text: #1b1a17;
  --muted: #6a665d;
  --line: #dad6cc;
  --accent: #3d5afe;
  --accent-strong: #2a43d6;
  --on-accent: #ffffff;
  --good: #16794a;
  --good-bg: #e3f4ea;
  --bad: #c0362c;
  --bad-bg: #fbe7e5;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgb(0 0 0 / .05), 0 6px 20px rgb(0 0 0 / .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --tap: 52px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111214;
    --surface: #1b1c1f;
    --surface-2: #26272b;
    --text: #ecebe8;
    --muted: #a19d94;
    --line: #34353a;
    --accent: #7b8cff;
    --accent-strong: #9aa7ff;
    --on-accent: #0d0f1a;
    --good: #5bd394;
    --good-bg: #13301f;
    --bad: #ff8178;
    --bad-bg: #3a1714;
    --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 6px 20px rgb(0 0 0 / .3);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; text-wrap: balance; }
p { margin: 0 0 1em; }
a { color: var(--accent); }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.pre { white-space: pre-line; }
.loading { color: var(--muted); text-align: center; padding: 48px 16px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-lg { min-height: var(--tap); font-size: 1.0625rem; width: 100%; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-danger { color: var(--bad); }
.btn-danger.armed { background: var(--bad); border-color: var(--bad); color: #fff; }

.field { display: grid; gap: 6px; font-weight: 600; }
.field > span { font-size: .875rem; color: var(--muted); }
input, textarea, select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 400;
}
textarea { resize: vertical; min-height: 80px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 2px; }

.chip {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: .8125rem;
  font-weight: 600;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow);
  z-index: 100;
  animation: toast-in .2s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
