:root {
  --bg: #f8f8fa;
  --surface: #fff;
  --text: #1f2230;
  --muted: #5d6275;
  --border: #d6d8e0;
  --accent: #4f46e5;
  --accent-text: #fff;
  --accent-hover: #4338ca;
  --notice: #eef0ff;
  --focus: #4f46e5;
  --danger: #b42318;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15161c;
    --surface: #1e2028;
    --text: #e8e9ef;
    --muted: #a0a4b5;
    --border: #3a3d4a;
    --accent: #6d66f0;
    --accent-text: #fff;
    --accent-hover: #837df5;
    --notice: #23253a;
    --focus: #9a95ff;
    --danger: #d92d20;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.bar, main { max-width: 480px; margin: 0 auto; padding-inline: 16px; }
.bar { display: flex; gap: 4px; padding-block: 12px 4px; }
main { padding-block: 16px 32px; }

button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
}
.icon.small { width: 32px; height: 32px; flex: none; }
.icon:hover, .icon:focus-visible { background: var(--border); color: var(--text); }
.icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon.end { margin-left: auto; }
.icon::after {
  content: attr(data-label);
  position: absolute;
  top: 100%;
  left: 50%;
  translate: -50% 4px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--text);
  color: var(--bg);
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  z-index: 2;
}
.icon.end::after { left: auto; right: 0; translate: 0 4px; }
.icon:hover::after, .icon:focus-visible::after { opacity: 1; }

.notice {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding: 12px 12px 12px 16px;
  background: var(--notice);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}
.notice[hidden] { display: none; }
.notice p { margin: 0; flex: 1; }
#corrupt { flex-direction: column; align-items: stretch; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }

.ask { text-align: center; }
h1 { margin: 24px 0 4px; font-size: 30px; line-height: 1.2; font-weight: 600; }
.when { margin: 0 0 24px; min-height: 1.5em; color: var(--muted); font-size: 14px; }
.answers { display: flex; gap: 12px; }
.answers button { flex: 1; }
button.primary, button.secondary {
  min-height: 56px;
  border-radius: 8px;
  font-size: 20px;
  font-weight: 600;
}
button.primary { background: var(--accent); color: var(--accent-text); border: 0; }
button.primary:hover:not(:disabled) { background: var(--accent-hover); }
button.primary:disabled { opacity: 0.45; cursor: default; }
button.secondary {
  min-height: 40px;
  padding: 0 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 14px;
  font-weight: 500;
}
.saved { height: 24px; margin: 8px 0; color: var(--muted); font-size: 14px; }
textarea {
  display: block;
  width: 100%;
  padding: 12px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  text-align: left;
  resize: vertical;
}
textarea:disabled { opacity: 0.6; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.icon:disabled { opacity: 0.4; cursor: default; }
.icon.tip-up::after { top: auto; bottom: 100%; translate: -50% -4px; }
.icon.tip-up.end::after { translate: 0 -4px; }
.muted { color: var(--muted); font-size: 14px; }
.error { min-height: 1.5em; margin: 0; color: var(--danger); font-size: 14px; }
.link { color: var(--accent); font-size: 14px; }

button.danger {
  min-height: 40px;
  padding: 0 16px;
  background: var(--danger);
  color: #fff;
  border: 0;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
}
button.secondary[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

dialog {
  width: min(480px, calc(100vw - 32px));
  height: min(600px, calc(100dvh - 32px));
  padding: 0;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
}
dialog[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: rgb(0 0 0 / 0.5); }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 8px 8px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 18px; font-weight: 600; }
.modal-body { flex: 1; overflow-y: auto; padding: 16px; outline: none; }
.empty { margin: 0; color: var(--muted); }

.figures { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.figure { display: flex; flex-direction: column; padding: 8px 4px; background: var(--bg); border-radius: 8px; text-align: center; }
.figure strong { font-size: 24px; line-height: 1.2; font-weight: 600; }
.figure span { white-space: nowrap; color: var(--muted); font-size: 12px; }
.chart { display: block; width: 100%; margin: 8px 0 16px; }
.bar-fill { fill: var(--accent); }
.axis { fill: var(--muted); font-size: 8px; }
.axis-line { stroke: var(--border); stroke-width: 1; }
.entries { margin: 0; padding: 0; list-style: none; }
.entry { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 8px 0; border-top: 1px solid var(--border); font-size: 14px; }
.entry.confirming { align-items: center; }
.entry-main { min-width: 0; }
.entry-top { display: flex; gap: 8px; align-items: baseline; }
.answer { font-weight: 600; }
.answer.yes { color: var(--accent); }
.note { margin: 2px 0 0; overflow-wrap: anywhere; white-space: pre-wrap; }

.settings, .about { display: flex; flex-direction: column; gap: 16px; }
.about p { margin: 0; max-width: 65ch; }
.about a { color: var(--accent); }
.field { display: flex; flex-direction: column; gap: 8px; }
.field .label { font-size: 14px; font-weight: 600; }
.field .row { align-items: center; }
.field .preset { min-width: 48px; padding: 0; }
input[type="number"], input[type="time"] {
  min-height: 40px;
  padding: 0 8px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
}
input[type="number"] { width: 72px; }
.actions { display: flex; gap: 4px; padding-top: 8px; border-top: 1px solid var(--border); }
.actions .end { margin-left: auto; }
.panel { display: flex; flex-direction: column; gap: 8px; }
.panel p { margin: 0; }
.settings .muted { margin: 0; min-height: 1.5em; }
