/* Palette: bathroom tile and cleaning-cupboard colours.
   tile    #eef3f2  background, like a tiled wall
   grout   #d3dfdc  tile lines and borders
   ink     #12343b  deep teal text
   soap    #bfe3da  mint highlights (swapped turns, bars)
   sponge  #f5c842  the one action colour
   overdue #c8382b  late turns */

:root {
  --tile: #eef3f2;
  --surface: #ffffff;
  --grout: #d3dfdc;
  --ink: #12343b;
  --ink-soft: #4b6a70;
  --soap: #bfe3da;
  --sponge: #f5c842;
  --sponge-ink: #3a2c00;
  --overdue: #c8382b;
  --overdue-bg: #fbe3df;
  --radius-lg: 22px;
  --radius-sm: 10px;
  --display: "Bricolage Grotesque", "Arial Narrow", system-ui, sans-serif;
  --body: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --tile: #0f2226;
    --surface: #16302f;
    --grout: #26464a;
    --ink: #e4f1ee;
    --ink-soft: #9fbcbb;
    --soap: #2d5e57;
    --sponge: #f5c842;
    --overdue: #ff8a7a;
    --overdue-bg: #4a1f1a;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--tile);
  color: var(--ink);
  font: 17px/1.5 var(--body);
}

h1, h2 { font-family: var(--display); font-weight: 800; line-height: 1.1; margin: 0; }
h2 { font-size: 1.35rem; }

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

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

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Top bar */
.bar {
  max-width: 720px; margin: 0 auto; padding: 18px 16px 8px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { font-size: 1.1rem; font-weight: 500; letter-spacing: 0.01em; }

main { max-width: 720px; margin: 0 auto; padding: 0 16px 64px; }

/* Buttons */
button { cursor: pointer; border: 0; border-radius: 999px; padding: 10px 18px; }
button:disabled { opacity: 0.55; cursor: progress; }
.primary { background: var(--sponge); color: var(--sponge-ink); font-weight: 700; }
.primary:hover { filter: brightness(0.96); }
.ghost { background: transparent; border: 1.5px solid var(--grout); }
.ghost:hover { border-color: var(--ink-soft); }
.small { padding: 6px 14px; font-size: 0.9rem; }

/* Hero: the name on the wall */
.hero {
  position: relative; overflow: hidden;
  margin: 8px 0 28px; padding: 28px 24px 30px;
  background: var(--surface); border-radius: var(--radius-lg);
  border: 1.5px solid var(--grout);
}
.tiles {
  position: absolute; inset: 0; pointer-events: none; opacity: 0.6;
  background-image:
    linear-gradient(var(--grout) 1.5px, transparent 1.5px),
    linear-gradient(90deg, var(--grout) 1.5px, transparent 1.5px);
  background-size: 56px 56px;
  -webkit-mask-image: linear-gradient(120deg, transparent 35%, #000 100%);
          mask-image: linear-gradient(120deg, transparent 35%, #000 100%);
}
.hero > *:not(.tiles) { position: relative; }
.hero-lead { margin: 0; color: var(--ink-soft); font-size: 1.05rem; }
.hero-name {
  margin: 2px 0 10px;
  font-family: var(--display); font-weight: 800;
  font-size: clamp(3.4rem, 15vw, 6.5rem); line-height: 0.95;
  letter-spacing: -0.03em; overflow-wrap: anywhere;
}
.hero-when { margin: 0; font-size: 1.2rem; font-weight: 700; }
.hero-status { margin: 6px 0 0; color: var(--ink-soft); }
.hero.is-overdue .hero-status {
  display: inline-block; margin-top: 10px; padding: 4px 12px; border-radius: 999px;
  background: var(--overdue-bg); color: var(--overdue); font-weight: 700;
}
.hero.is-today .hero-status { color: var(--ink); font-weight: 700; }
#doneBtn { font-size: 1.1rem; padding: 14px 28px; }

@media (prefers-reduced-motion: no-preference) {
  .hero-name.pop { animation: pop 420ms cubic-bezier(.2, .9, .3, 1.3); }
  @keyframes pop { from { transform: translateY(12px) scale(0.96); opacity: 0; } }
}

/* Sections */
.block { margin: 0 0 32px; }
.block-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.block h2 { margin-bottom: 10px; }
.block-head h2 { margin-bottom: 0; }
.block-head { margin-bottom: 10px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.hint { color: var(--ink-soft); margin: 0 0 10px; font-size: 0.95rem; }

/* Upcoming turns */
.turns { list-style: none; margin: 0; padding: 0; border-top: 1.5px solid var(--grout); }
.turn {
  display: grid; grid-template-columns: 8.5rem 1fr auto; align-items: center; gap: 10px;
  padding: 12px 4px; border-bottom: 1.5px solid var(--grout);
}
.turn-date { color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.turn-name { font-weight: 700; font-size: 1.08rem; min-width: 0; overflow-wrap: anywhere; }
.turn-tag { font-size: 0.82rem; padding: 2px 10px; border-radius: 999px; background: var(--soap); }
.turn.is-current .turn-name::after { content: " (now)"; font-weight: 400; color: var(--ink-soft); }
.swapping .turn { cursor: pointer; border-radius: var(--radius-sm); }
.swapping .turn:hover { background: var(--surface); }
.turn.is-picked { background: var(--soap); }
.more-btn { margin-top: 10px; }

/* Tally bars */
.tally { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.tally li { display: grid; grid-template-columns: 6.5rem 1fr 2.5rem; align-items: center; gap: 10px; }
.tally .bar-track { height: 14px; border-radius: 999px; background: var(--surface); border: 1.5px solid var(--grout); overflow: hidden; }
.tally .bar-fill { display: block; height: 100%; background: var(--ink); border-radius: 999px; min-width: 0; }
.tally .count { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.tally .covers { grid-column: 2 / -1; margin-top: -6px; font-size: 0.85rem; color: var(--ink-soft); }
.tally .gone { color: var(--ink-soft); }

/* History */
.history { list-style: none; margin: 0; padding: 0; }
.history li { padding: 10px 0; border-bottom: 1.5px solid var(--grout); }
.history .h-main { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.history .h-who { font-weight: 700; }
.history .h-date { color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.history .h-extra { color: var(--ink-soft); font-size: 0.92rem; }
.history .late { color: var(--overdue); }
.empty { color: var(--ink-soft); padding: 10px 0; }

/* Members */
.members { list-style: none; margin: 0 0 12px; padding: 0; counter-reset: m; }
.member {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 0; border-bottom: 1.5px solid var(--grout);
}
.member-name { font-weight: 700; flex: 1 1 8rem; }
.member.is-inactive .member-name { color: var(--ink-soft); font-weight: 400; text-decoration: line-through; }
.member-actions { display: flex; gap: 6px; }
.icon-btn { padding: 4px 10px; min-width: 2.4rem; }
.add-form { display: flex; gap: 8px; margin-bottom: 8px; }
.add-form input { flex: 1; min-width: 0; }

input, select {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--grout); background: var(--surface);
}
.add-form input { width: auto; }

/* Edit controls only show once unlocked */
body:not(.can-edit) .edit-only { display: none !important; }

/* Dialogs */
dialog {
  border: 0; border-radius: var(--radius-lg); padding: 0; width: min(92vw, 420px);
  background: var(--surface); color: var(--ink);
}
dialog::backdrop { background: rgba(18, 52, 59, 0.45); }
dialog form { padding: 24px; display: grid; gap: 8px; }
dialog h2 { margin-bottom: 4px; }
dialog p { margin: 0 0 6px; color: var(--ink-soft); }
dialog label { font-weight: 700; margin-top: 6px; }
.optional { font-weight: 400; color: var(--ink-soft); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.form-error { color: var(--overdue) !important; font-weight: 700; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 999px;
  background: var(--ink); color: var(--tile); font-weight: 700; z-index: 10;
}
.toast.is-error { background: var(--overdue); color: #fff; }

@media (max-width: 480px) {
  .turn { grid-template-columns: 7.6rem 1fr auto; }
  .hero { padding: 22px 18px 24px; }
}

/* Hero: plan, nudge and the secondary actions */
.hero-plan { margin: 10px 0 0; font-weight: 700; }
.hero-plan::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 8px; border-radius: 50%; background: var(--sponge); }
.hero-nudge {
  display: inline-block; margin: 10px 0 0; padding: 4px 12px; border-radius: var(--radius-sm);
  background: var(--soap); font-size: 0.95rem;
}
.hero-actions #doneBtn { margin-top: 22px; }
.hero-more { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.hero-more .ghost { background: var(--surface); }
.turn-tags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.turn-tag.is-plan { background: var(--sponge); color: var(--sponge-ink); }
