:root {
  color-scheme: light dark;
  --bg: #f2f2f5;
  --surface: #ffffff;
  --ink: #0b0b0f;
  --soft: #5e5e66;
  --line: #e6e6eb;
  --sunken: #f2f2f5;
  --gold: #f2b21b;
  --on-gold: #0b0b0f;
  --danger: #d93a3a;
  --success: #1f9d55;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0b0f;
    --surface: #16161c;
    --ink: #f4f4f6;
    --soft: #a2a2ad;
    --line: #2a2a33;
    --sunken: #1e1e25;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

p, dl, dd, h1 { margin: 0; }

a { color: var(--ink); }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px;
}

.soft { color: var(--soft); }

.noscript { padding: 16px; text-align: center; }

/* Header */
.top { background: var(--surface); border-bottom: 1px solid var(--line); }

.top-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
  min-height: 56px;
  padding-top: 8px;
  padding-bottom: 8px;
}

.brand { font-weight: 700; }

.top-right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  min-width: 0;
}

.email {
  min-width: 0;
  max-width: 60vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout { margin: 0; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
}

.btn:disabled { opacity: 0.5; cursor: default; }

.btn-small { padding: 0 14px; }

.btn-gold { background: var(--gold); color: var(--on-gold); }

.btn-quiet { border-color: var(--line); color: var(--ink); }

.btn-danger { border-color: var(--danger); color: var(--danger); }

.tab { border-color: var(--line); background: var(--surface); }

.tab[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}

/* Tabs and toolbar */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 8px;
}

.toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

/* Sign-in and open error */
.auth {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 16px;
}

.auth-card {
  display: grid;
  gap: 12px;
  justify-items: center;
  width: 100%;
  max-width: 420px;
  padding: 24px;
  text-align: center;
}

h1 { font-size: 24px; line-height: 1.2; }

/* Cards and claims */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
}

.claim {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

.claim-body {
  display: grid;
  gap: 16px;
  min-width: 0;
}

@media (min-width: 720px) {
  .claim { grid-template-columns: 260px minmax(0, 1fr); align-items: start; }
}

.proof-link {
  display: block;
  background: var(--sunken);
  border-radius: 12px;
  overflow: hidden;
}

.proof {
  display: block;
  width: 100%;
  height: 260px;
  max-height: 260px;
  object-fit: contain;
}

.facts {
  display: grid;
  grid-template-columns: minmax(96px, max-content) minmax(0, 1fr);
  gap: 8px 16px;
}

.facts dt { color: var(--soft); }

.facts dd {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.stack { display: grid; gap: 8px; }

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.decide-group {
  display: grid;
  gap: 12px;
}

.decide {
  display: grid;
  gap: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.decide-group + .decide-group {
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

label { font-weight: 600; font-size: 14px; }

.field {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

textarea.field { min-height: 80px; resize: vertical; }

.field-error { color: var(--danger); font-size: 14px; }

.field-error[hidden] { display: none; }

.chip {
  padding: 2px 8px;
  border-radius: 8px;
  background: var(--sunken);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.meta { color: var(--soft); overflow-wrap: anywhere; }

.ok { color: var(--success); font-weight: 600; }

.warn { color: var(--danger); font-weight: 600; }

.state {
  padding: 24px 0;
  color: var(--soft);
  text-align: center;
}

.state.error { color: var(--danger); }

/* Toast */
.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  max-width: 420px;
  margin: 0 auto;
  padding: 12px 16px;
  border-radius: 16px;
  background: var(--ink);
  color: var(--bg);
  font-weight: 600;
  text-align: center;
}

.toast:empty { display: none; }

/* Sign-in notices rendered by the server */
.notice {
  max-width: 420px;
  margin: 15vh auto 0;
  padding: 24px 16px;
  text-align: center;
}
.notice h1 { margin: 0 0 8px; font-size: 22px; }
.notice p { margin: 0 0 24px; color: var(--soft); }
.notice .button {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 22px;
  border-radius: 999px;
  background: var(--gold);
  color: var(--on-gold);
  font-weight: 600;
  text-decoration: none;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
