:root {
  --bg: #f4efe6;
  --surface: #fffdf8;
  --ink: #1c1915;
  --muted: #6d645b;
  --line: #e4d9c8;
  --accent: #9a3412;
  --accent-fg: #fff8f4;
  --soft: #f6e6da;
  --sans: "Outfit", ui-sans-serif, system-ui, sans-serif;
  --display: "Fraunces", ui-serif, Georgia, serif;
  --mono: ui-monospace, "SFMono-Regular", "Segoe UI Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

html[data-theme="ink"] {
  --bg: #141210;
  --surface: #211d19;
  --ink: #f6f1ea;
  --muted: #b7aa9e;
  --line: #3c342c;
  --accent: #e7a07a;
  --accent-fg: #1c100c;
  --soft: #3a2a22;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

button, [role="button"] { cursor: pointer; font: inherit; color: inherit; }

button { background: none; border: 0; padding: 0; }

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

::selection { background: var(--soft); color: var(--ink); }

.accent-bar { height: 4px; background: var(--accent); }

.wrap {
  width: min(36rem, 100%);
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

h1.display {
  margin: 0;
  font-family: var(--display);
  font-weight: 560;
  font-style: italic;
  font-size: 3rem;
  letter-spacing: -0.03em;
  line-height: 1;
}

.display { font-family: var(--display); letter-spacing: -0.03em; }

.muted { color: var(--muted); }
.hint, .meta { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.875rem; }
.kicker {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.lede { max-width: 18rem; margin: 0.35rem 0 0; color: var(--muted); font-size: 0.875rem; }

.top {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75rem;
}

.blocked { color: var(--muted); font-size: 0.875rem; margin: 0; }

.card, .button-row, .finished-row, .banner, .note {
  border: 1px solid var(--line);
  background: var(--surface);
}

.card, .note {
  border-radius: 1.5rem;
  padding: 1.25rem 1.25rem 1.15rem;
}

.note { background: var(--soft); border: 0; font-size: 0.875rem; }

.banner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  border-radius: 1rem;
  padding: 0.75rem 1rem;
}

.banner p { margin: 0; }
.banner .title { font-weight: 600; overflow-wrap: anywhere; }

.readout {
  margin: 0.35rem 0 0;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.readout.display { font-family: var(--display); font-size: 3.5rem; letter-spacing: -0.03em; }
.readout.display.long { font-size: 2.25rem; }
.readout.display.compact { font-size: 2.25rem; }
.readout.clear { font-family: var(--sans); font-weight: 600; font-size: 3rem; }
.readout.clear.long { font-size: 2.25rem; }
.readout.clear.compact { font-size: 1.75rem; }
.readout.mono { font-family: var(--mono); font-weight: 500; font-size: 2.75rem; }
.readout.mono.long, .readout.mono.compact { font-size: 1.7rem; }

.card h2 {
  margin: 0.2rem 0 0;
  font-family: var(--display);
  font-size: 1.75rem;
  font-weight: 560;
  letter-spacing: -0.03em;
  overflow-wrap: anywhere;
}

.track { margin-top: 1rem; height: 4px; border-radius: 999px; background: var(--line); overflow: hidden; }
.fill { height: 100%; background: var(--accent); width: 0; }

.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.75rem;
  padding: 0 1rem;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 600;
}

.btn svg, .icon-btn svg {
  width: 1rem;
  height: 1rem;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn-accent { background: var(--accent); color: var(--accent-fg); }
.btn-line { border: 1px solid var(--line); background: var(--surface); }
.btn-ghost { color: var(--muted); }
.btn-danger { color: var(--accent); }

.section-head, .list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.stack { display: flex; flex-direction: column; gap: 0.75rem; }

.button-row {
  display: flex;
  align-items: stretch;
  border-radius: 1.5rem;
  overflow: hidden;
}

.button-main {
  flex: 1;
  min-width: 0;
  padding: 1rem;
  text-align: left;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
}

.button-main strong {
  font-family: var(--display);
  font-size: 1.45rem;
  font-weight: 560;
  letter-spacing: -0.03em;
  overflow-wrap: anywhere;
}

.button-main span, .finished-row p { overflow-wrap: anywhere; }

.icon-btn {
  width: 3.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.live {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
}

.live i {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 999px;
  background: var(--accent);
}

.finished-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  border-radius: 1rem;
  padding: 0.75rem 1rem;
}

.finished-row p { margin: 0; }

.settings { border: 1px solid var(--line); border-radius: 1.5rem; padding: 0.35rem 1rem 0.5rem; }
.settings h2 { margin: 0.85rem 0 0; }

.choice, .setting {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  border-top: 1px solid var(--line);
  padding: 0.75rem 0;
}

.setting {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.choice p, .setting p { margin: 0; }
.choice .label, .setting .label { font-size: 0.875rem; font-weight: 600; }

.pills { display: flex; flex-wrap: wrap; gap: 0.45rem; }

.pill {
  min-height: 2.75rem;
  padding: 0 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 0.875rem;
}

.pill[aria-checked="true"] {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: transparent;
  font-weight: 600;
}

.switch {
  width: 3rem;
  height: 1.75rem;
  border-radius: 999px;
  background: var(--line);
  position: relative;
  flex: none;
}

.switch span {
  position: absolute;
  top: 0.25rem;
  left: 0.25rem;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 999px;
  background: #fffdf8;
  transition: transform 160ms ease;
}

.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"] span { transform: translateX(1.25rem); }

details { color: var(--muted); font-size: 0.875rem; }
details summary { cursor: pointer; color: var(--ink); font-weight: 600; }
details p { margin: 0.6rem 0 0; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

dialog {
  position: fixed;
  inset: auto 0 0 0;
  width: 100%;
  max-width: none;
  max-height: 92dvh;
  margin: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 1.5rem 1.5rem 0 0;
  background: var(--surface);
  color: var(--ink);
  padding: 1.25rem 1.25rem 2rem;
}

dialog::backdrop { background: color-mix(in srgb, var(--ink) 40%, transparent); }

dialog form { display: flex; flex-direction: column; gap: 1.1rem; }

.editor-head, .editor-actions, .row-switch {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.editor-head h2 { margin: 0; font-size: 1.8rem; font-weight: 560; }
.editor-actions { align-items: center; flex-wrap: wrap; }

fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
legend, .field > span:first-child, .label { font-size: 0.875rem; font-weight: 600; }

.field { display: flex; flex-direction: column; gap: 0.3rem; }

input, textarea {
  width: 100%;
  min-height: 2.75rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  padding: 0.55rem 0.75rem;
}

textarea { resize: vertical; }

.parts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.45rem; }
.parts label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.75rem; color: var(--muted); }
.parts input {
  text-align: center;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding-left: 0.2rem;
  padding-right: 0.2rem;
}

.tokens { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.token {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.2rem 0.5rem;
  color: var(--muted);
  font-size: 0.75rem;
  background: var(--surface);
}

.preview {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.preview article {
  border-radius: 1rem;
  background: var(--bg);
  padding: 0.7rem 0.8rem;
}

.preview p { margin: 0; overflow-wrap: anywhere; }

.error { margin: 0; color: var(--accent); font-size: 0.875rem; font-weight: 600; }

.empty {
  border: 1px dashed var(--line);
  border-radius: 1.5rem;
  padding: 2rem 1rem;
  color: var(--muted);
  font-size: 0.875rem;
}

.alerts-on { display: inline-flex; align-items: center; gap: 0.4rem; min-height: 2.75rem; color: var(--accent); font-size: 0.875rem; font-weight: 600; }
.alerts-on svg, .blocked svg { width: 1rem; height: 1rem; stroke: currentColor; fill: none; stroke-width: 2; }

@media (min-width: 640px) {
  .wrap { padding: 2.5rem 1.5rem 4rem; }
  .top { flex-direction: row; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; }
  dialog {
    inset: 0;
    width: min(32rem, calc(100% - 2rem));
    height: fit-content;
    max-height: calc(100dvh - 2rem);
    margin: auto;
    border-bottom: 1px solid var(--line);
    border-radius: 1.5rem;
  }
  .readout.display { font-size: 3.75rem; }
  .readout.clear { font-size: 3.4rem; }
}

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