:root {
  color-scheme: dark;
  --bg: #12100c;
  --bg-2: #1c1814;
  --chip: #26211b;
  --ink: #f7f2ea;
  --muted: #d2c4b2;
  --line: rgba(255, 214, 170, 0.16);
  --accent: #ff8a1e;
  --accent-2: #ffd27a;
  --ink-on-accent: #1a1006;
  --track: #3a3228;
  --stub: #4a3d2e;
  --glow: rgba(255, 150, 40, 0.22);
  --shadow: 0 24px 50px rgba(0, 0, 0, 0.28);
  --danger: #ffb4a2;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4efe6;
  --bg-2: #fffaf3;
  --chip: #fffdf9;
  --ink: #1d1712;
  --muted: #5c5146;
  --line: rgba(48, 28, 8, 0.14);
  --accent: #e25e00;
  --accent-2: #ff9a3c;
  --ink-on-accent: #1a1006;
  --track: #efe4d4;
  --stub: #e4d5c4;
  --glow: rgba(255, 140, 40, 0.16);
  --shadow: 0 18px 40px rgba(80, 40, 0, 0.08);
  --danger: #9d2c1a;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  padding-bottom: 72px;
  background:
    radial-gradient(880px 380px at 50% -120px, var(--glow), transparent 70%),
    var(--bg);
  color: var(--ink);
  font: 16px/1.5 ui-sans-serif, system-ui, sans-serif;
}

.skip {
  position: absolute;
  left: 12px;
  top: -48px;
  background: var(--accent);
  color: var(--ink-on-accent);
  padding: 8px 12px;
  border-radius: 8px;
  z-index: 4;
}

.skip:focus { top: 12px; }

:focus { outline: none; }

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

.top, #app, noscript {
  width: min(40rem, calc(100% - 32px));
  margin-left: auto;
  margin-right: auto;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 22px 0 8px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: inherit;
  text-decoration: none;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

.brand svg {
  width: 22px;
  height: 22px;
  color: var(--accent);
}

#theme, .ghost, .primary, .icon, .choice, .sample, .recent a {
  font: inherit;
  color: inherit;
}

#theme, .ghost, .icon {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
}

#theme { min-height: 40px; }

a.primary, a.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  cursor: pointer;
}

.primary {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  color: var(--ink-on-accent);
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 700;
  cursor: pointer;
  min-height: 48px;
}

.ghost { min-height: 48px; cursor: pointer; }

h1, .sample-q {
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-weight: 560;
  letter-spacing: -0.03em;
  line-height: 1.12;
  overflow-wrap: break-word;
}

h1 {
  margin: 0 0 10px;
  font-size: clamp(2rem, 5vw, 3.25rem);
}

.kicker {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.lede, .hint, .meta, .loading, .empty {
  color: var(--muted);
}

.lede { margin: 0 0 22px; max-width: 38rem; }

.sheet, .sample, .recent {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.sheet { padding: 18px; margin-bottom: 16px; }

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 650;
  margin: 14px 0 6px;
}

label:first-child { margin-top: 0; }

input {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--chip);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  min-height: 48px;
}

.linkbox { margin-top: 12px; }

.opt-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.opt-row input { width: auto; flex: 1; min-width: 0; }

.icon {
  flex: 0 0 auto;
  min-height: 48px;
  padding: 8px 12px;
}

.form-error {
  color: var(--danger);
  margin: 8px 0;
}

.hint { margin: 8px 0 14px; }

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

.sample {
  display: block;
  width: 100%;
  text-align: left;
  text-decoration: none;
  padding: 16px 18px;
  margin-bottom: 16px;
}

.sample-q {
  display: block;
  font-size: 1.45rem;
  color: var(--ink);
  margin-bottom: 10px;
}

.mini {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px;
  gap: 8px;
  align-items: center;
  margin: 6px 0;
  color: var(--ink);
  font-size: 0.92rem;
}

.mini-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.mini-bar, .bar {
  display: block;
  height: 8px;
  border-radius: 999px;
  background: var(--track);
  overflow: hidden;
}

.mini-bar > span, .bar > span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.choice {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--chip);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px 12px 16px;
  margin-bottom: 10px;
  cursor: pointer;
  box-shadow: inset 4px 0 0 var(--stub);
}

.choice[aria-pressed="true"] {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  box-shadow: inset 4px 0 0 var(--accent);
}

.choice-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.name { font-weight: 650; overflow-wrap: break-word; }

.pct, .meta { font-variant-numeric: tabular-nums; }

.pct { font-weight: 700; flex: 0 0 auto; }

.meta { display: block; margin-top: 6px; font-size: 0.85rem; }

.choice.leading .bar > span { opacity: 1; }

.choice:not(.leading) .bar > span { opacity: 0.72; }

.recent { padding: 8px; margin-bottom: 28px; }

.recent h2 {
  margin: 8px 10px;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.recent a {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  text-decoration: none;
  padding: 12px 10px;
  border-radius: 12px;
}

.recent a:hover, .sample:hover, .choice:hover, .primary:hover, .ghost:hover, #theme:hover {
  filter: brightness(1.06);
}

.recent .qbit { overflow-wrap: break-word; min-width: 0; flex: 1; }

.fold-wrap {
  margin: 4px 0 32px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.fold-wrap summary { cursor: pointer; font-weight: 650; }

.fold {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.fold input { flex: 1; min-width: 0; width: auto; }

.status {
  position: fixed;
  z-index: 5;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 24px);
  margin: 0;
  text-align: center;
}

.status:empty { display: none; }

.status:not(:empty) {
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.loading, .empty { margin: 12px 0 24px; }

@media (max-width: 640px) {
  .top, #app, noscript { width: min(40rem, calc(100% - 24px)); }
  .fold, .row-actions { flex-direction: column; }
  .sheet .primary, .sheet .ghost, .row-actions .primary, .row-actions .ghost, .fold .ghost { width: 100%; }
  .fold input { width: 100%; }
  .mini { grid-template-columns: minmax(0, 1fr) 56px; }
}

@media (prefers-reduced-motion: reduce) {
  .bar > span, .mini-bar > span { transition: none; }
}
