:root {
  color-scheme: light dark;

  --bg: light-dark(#f6f4ef, #18181b);
  --surface: light-dark(#ffffff, #232327);
  --text: light-dark(#1c1c1f, #ececef);
  --muted: light-dark(#6b6b73, #9a9aa3);
  --border: light-dark(#dcd9d2, #3a3a40);
  --accent: light-dark(#2f6f4f, #7fd1a5);
  --accent-text: light-dark(#ffffff, #10261a);
  --error: light-dark(#b3261e, #f2b8b5);

  accent-color: var(--accent);
  font-family: system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

main {
  max-inline-size: 36rem;
  margin-inline: auto;
  padding: 2rem 1rem 4rem;
}

/* Top bar: title on the left, small actions on the right */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
h1 { margin: 0; font-size: 1.5rem; }
.topbar-actions { display: flex; align-items: center; gap: 0.25rem; }

button.small { font-size: 0.8rem; padding: 0.35rem 0.7rem; }
button.icon { font-size: 1.1rem; line-height: 1; padding: 0.3rem 0.55rem; }
button[aria-expanded="true"] { border-color: var(--accent); }

.sync { margin-block: 0.25rem 1.25rem; font-size: 0.8rem; color: var(--muted); min-block-size: 1lh; }
.sync.error { color: var(--error); }

/* ⋮ menu */
#menu {
  margin: 0.25rem 0 0;
  padding: 0.3rem;
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.18);
  /* Below the ⋮ button, right-aligned to it (implicit anchor comes from commandfor) */
  inset: auto;
  position-area: block-end span-inline-start;
  position-try-fallbacks: flip-block;
}
#menu [focusgroup] { display: flex; flex-direction: column; }
#menu hr { inline-size: 100%; margin: 0.25rem 0; border: 0; border-block-start: 1px solid var(--border); }
#menu hr[hidden] { display: none; }
#menu button {
  border: 0;
  background: transparent;
  text-align: start;
  font-size: 0.9rem;
  padding: 0.5rem 0.8rem;
  border-radius: 0.4rem;
  white-space: nowrap;
}
@media (hover: hover) {
  #menu button:hover:not(:disabled) { background: var(--bg); }
}

/* Sections */
.block { margin-block-start: 1.75rem; }
.section-title {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
#unranked-block .actions { justify-content: start; margin-block: 0.25rem 0; }
#action-hint { text-align: start; }

button, input { font: inherit; color: inherit; }

button {
  cursor: pointer;
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  background: var(--surface);
}
/* Mouse only (on touch screens :hover sticks after a tap), and never on disabled buttons. */
@media (hover: hover) {
  button:hover:not(:disabled) { border-color: var(--accent); }
}
:where(button, input):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

/* Add form */
#form-add { display: flex; gap: 0.5rem; margin-block-end: 0.5rem; }
#form-add input {
  flex: 1;
  min-inline-size: 0;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  background: var(--surface);
}

/* Lists */
#items, #ranking { padding: 0; margin-block: 0.6rem; list-style: none; }

#items li, #ranking li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.8rem;
  margin-block-end: 0.4rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.6rem;
}
#items li span { flex: 1; overflow-wrap: anywhere; }
button.remove {
  padding: 0.2rem 0.6rem;
  border: 0;
  background: transparent;
  color: var(--muted);
}

/* Ranking */
#ranking { counter-reset: pos; }
#ranking li { counter-increment: pos; }
#ranking li::before {
  content: counter(pos);
  min-inline-size: 1.8rem;
  font-weight: 700;
  color: var(--accent);
}
#ranking label { flex: 1; display: flex; gap: 0.6rem; align-items: center; cursor: pointer; overflow-wrap: anywhere; }

/* Bought: moved to the end, greyed out, ✓ instead of a number (numbers count only what's left). */
#ranking li.bought {
  counter-increment: none;
  background: transparent;
  color: var(--muted);
}
#ranking li.bought::before { content: "✓"; color: var(--muted); }
#ranking li.bought label { text-decoration: line-through; }


/* Comparison */
.question { font-size: 1.15rem; font-weight: 600; text-align: center; }

.duel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-block: 1rem;
}
.option {
  min-block-size: 9rem;
  padding: 1rem;
  font-size: 1.2rem;
  font-weight: 600;
  overflow-wrap: anywhere;
  border-width: 2px;
  transition: translate 0.1s, scale 0.1s, border-color 0.1s;
}
@media (hover: hover) {
  .option:hover:not(:disabled) { translate: 0 -2px; }
}
.option:active { scale: 0.97; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-block: 1rem;
}

.progress-label { display: block; margin-block-start: 1.5rem; font-size: 0.9rem; color: var(--muted); text-align: center; }
progress { display: block; inline-size: 100%; margin-block: 0.4rem; }

.hint { color: var(--muted); font-size: 0.85rem; text-align: center; }

.sr-only {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .option { transition: none; }
}
