:root {
  --bg: #f5f3ec;
  --card: #ffffff;
  --ink: #18201c;
  --muted: #55605a;
  --line: #dcd8cb;
  --edge: #8a938d; /* outline of anything you can tap */
  --accent: #1a6644;
  --accent-ink: #ffffff;
  --accent-soft: #e2f0e7;
  --out: #a3361f;
  --out-soft: #f8e5df;
  --open: #7d4f05;
  --open-soft: #fbedcc;
  --chip: #eeede5;
  --shadow: 0 1px 2px rgb(27 35 31 / 6%), 0 6px 18px rgb(27 35 31 / 5%);
  color-scheme: light dark;
}

/* Dark colours: when the phone is in dark mode, unless light was chosen on the page... */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #121614;
    --card: #1b211e;
    --ink: #f0f3ee;
    --muted: #a9b3ad;
    --line: #2f3833;
    --edge: #78837c;
    --accent: #66c797;
    --accent-ink: #0c1a13;
    --accent-soft: #1d3327;
    --out: #f09c88;
    --out-soft: #3a211b;
    --open: #ebbb62;
    --open-soft: #3a2e13;
    --chip: #262e2a;
    --shadow: none;
    color-scheme: dark;
  }
}

/* ...and whenever dark was chosen on the page, whatever the phone says. */
:root[data-theme='dark'] {
  --bg: #121614;
  --card: #1b211e;
  --ink: #f0f3ee;
  --muted: #a9b3ad;
  --line: #2f3833;
  --edge: #78837c;
  --accent: #66c797;
  --accent-ink: #0c1a13;
  --accent-soft: #1d3327;
  --out: #f09c88;
  --out-soft: #3a211b;
  --open: #ebbb62;
  --open-soft: #3a2e13;
  --chip: #262e2a;
  --shadow: none;
  color-scheme: dark;
}

:root[data-theme='light'] {
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

/* Everything is sized in rem, so these two lines set the size of the whole app.
   "Make the text bigger" switches to the second. */
html {
  font-size: 112.5%;
}

html.big {
  font-size: 131.25%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 1rem/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px calc(110px + env(safe-area-inset-bottom));
}

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

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

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

.ic {
  flex: none;
  width: 1.5em;
  height: 1.5em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.loading,
.empty {
  color: var(--muted);
  text-align: center;
  padding: 40px 0;
}

.hint {
  margin: 10px 0 0;
  color: var(--muted);
}

/* ---------- top of each screen ---------- */

.back {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 48px;
  margin: 0 0 12px;
  padding: 6px 18px 6px 8px;
  border: 2px solid var(--edge);
  border-radius: 999px;
  background: var(--card);
  font-weight: 700;
}

.top {
  padding: 0 0 14px;
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  margin-bottom: 12px;
}

.bar .back,
.bar .brand {
  margin: 0;
}

.tools {
  display: flex;
  flex: none;
  gap: 8px;
}

/* Round icon buttons, always in the top right corner. */
.tool {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 2px solid var(--edge);
  border-radius: 50%;
  background: var(--card);
  color: var(--ink);
}

.tool.on {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.tool .ic {
  width: 24px;
  height: 24px;
  stroke-width: 2;
}

/* Small A beside a big A: the usual sign for text size. Fixed size so it never outgrows the button. */
.aa {
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
}

.aa small {
  font-size: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin: 0 0 8px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--muted);
}

.brand img {
  border-radius: 7px;
}

.top h1 {
  margin: 0;
  font-size: 1.7rem;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.top .sub {
  margin: 4px 0 0;
  color: var(--muted);
}

.notice {
  margin: 0 0 14px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--open-soft);
  color: var(--open);
  font-weight: 700;
  white-space: pre-line;
}

.coachbar {
  margin: 0 0 14px;
  padding: 14px 16px 16px;
  border-radius: 16px;
  background: var(--accent-soft);
}

.coachbar p {
  margin: 0;
}

.coachbar .link {
  margin-top: 6px;
}

.sec {
  margin: 26px 2px 10px;
  font-size: 1.15rem;
  line-height: 1.3;
}

/* ---------- buttons and links ---------- */

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 3.2rem;
  padding: 10px 16px;
  border: 2px solid var(--edge);
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn.wide {
  width: 100%;
  margin-top: 12px;
}

.link {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-weight: 700;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.link.danger {
  color: var(--out);
}

select,
input,
textarea {
  width: 100%;
  min-height: 3rem;
  padding: 10px 12px;
  border: 2px solid var(--edge);
  border-radius: 12px;
  background: var(--card);
}

input[type='checkbox'] {
  flex: none;
  width: 24px;
  min-height: 24px;
  height: 24px;
  padding: 0;
  accent-color: var(--accent);
}

/* ---------- a session ---------- */

.card {
  scroll-margin-top: 12px;
  margin-bottom: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.card.mine {
  border: 2px solid var(--accent);
}

.soon {
  margin: 0 0 2px;
  font-weight: 700;
  color: var(--accent);
}

.card h3 {
  margin: 0;
  font-size: 1.3rem;
  line-height: 1.25;
}

.when {
  margin: 4px 0 0;
  font-size: 1.05rem;
}

.state {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.3;
}

.state.good {
  background: var(--accent-soft);
  color: var(--accent);
}

.state.bad {
  background: var(--out-soft);
  color: var(--out);
}

.state.free {
  background: var(--open-soft);
  color: var(--open);
}

/* What just happened, written into the page beside the thing that was tapped. */
.flash {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 12px 0;
  padding: 12px 14px;
  border: 2px solid var(--accent);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  font-weight: 700;
  line-height: 1.35;
  text-align: left;
  scroll-margin: 96px 0;
}

.flash .ic {
  color: var(--accent);
}

.flash.bad {
  border-color: var(--out);
}

.flash.bad .ic {
  color: var(--out);
}

form > .flash,
.top + .flash {
  margin: 0 0 12px;
}

.tally {
  margin: 18px 0 8px;
  font-weight: 700;
}

.tally.quiet {
  margin-top: 14px;
  color: var(--muted);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 2.1rem;
  padding: 4px 13px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--chip);
  font-size: 0.95rem;
}

button.chip {
  min-height: 46px;
  border: 2px solid var(--edge);
}

.chip.me-chip {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.chip.out {
  background: none;
  border: 1px dashed var(--edge);
  color: var(--muted);
}

button.chip.out {
  border: 2px dashed var(--edge);
}

.chip small {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--open);
}

.extras {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  margin-top: 12px;
}

/* ---------- two-week calendar ---------- */

.cal {
  margin-bottom: 14px;
  padding: 16px 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.cal-top {
  margin: 0 4px 10px;
  font-size: 1.15rem;
  font-weight: 700;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.cal-head {
  padding-bottom: 2px;
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
  color: var(--muted);
}

.cal-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-height: 5rem;
  padding: 6px 0;
  border: 2px solid var(--edge);
  border-radius: 12px;
  background: var(--bg);
}

.cal-day.empty {
  border-color: transparent;
  background: none;
  color: var(--muted);
}

.cal-day .num {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.4;
}

.cal-day.today .num {
  min-width: 1.6rem;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  text-align: center;
}

.pip {
  padding: 0 5px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--chip);
  font-size: 0.78rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.6;
  white-space: nowrap;
}

.pip.mine {
  background: var(--accent);
  color: var(--accent-ink);
}

.pip.away {
  border: 1px dashed var(--accent);
  background: none;
  color: var(--accent);
}

.pip.open {
  background: var(--open-soft);
  color: var(--open);
}

.pip.off {
  background: var(--out-soft);
  color: var(--out);
}

.cal-key {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin: 14px 4px 0;
  font-size: 0.9rem;
}

.cal .hint {
  margin: 8px 4px 0;
}

/* ---------- bottom bar ---------- */

.nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 6px max(10px, calc((100% - 540px) / 2)) calc(6px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--card);
}

.nav button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 62px;
  border: 0;
  border-radius: 14px;
  background: none;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.nav button[aria-current] {
  background: var(--accent-soft);
  color: var(--accent);
}

.foot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-top: 30px;
}

/* ---------- welcome and name list ---------- */

.welcome {
  text-align: center;
}

.welcome h1 {
  margin: 10px 0 0;
  font-size: 1.7rem;
}

.welcome > p {
  margin: 6px 0 18px;
  font-size: 1.15rem;
}

.welcome form {
  margin-bottom: 20px;
}

.welcome form input {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-align: center;
}

.names {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.names button {
  min-height: 3.2rem;
  padding: 8px 16px;
  border: 2px solid var(--edge);
  border-radius: 14px;
  background: var(--card);
  font-size: 1.1rem;
  font-weight: 700;
  text-align: left;
}

.names button[aria-pressed='true'] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

/* ---------- sheets (questions that slide up) ---------- */

.veil {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgb(0 0 0 / 55%);
}

.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 90dvh;
  overflow-y: auto;
  padding: 24px 18px calc(22px + env(safe-area-inset-bottom));
  border-radius: 22px 22px 0 0;
  background: var(--bg);
}

.sheet h2 {
  margin: 0 0 8px;
  font-size: 1.5rem;
  line-height: 1.2;
}

.sheet p {
  margin: 0 0 12px;
}

.sheet .what {
  font-size: 1.1rem;
}

.sheet .link {
  margin-top: 8px;
}

/* ---------- manage ---------- */

.panel {
  margin-bottom: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
}

.panel h2 {
  margin: 0 0 10px;
  font-size: 1.1rem;
}

details.panel > summary {
  font-weight: 700;
  cursor: pointer;
}

details.panel > summary small {
  display: block;
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--muted);
}

details.panel[open] > summary {
  margin-bottom: 12px;
}

label,
.lbl {
  display: block;
  margin: 0 0 10px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--muted);
}

label > input,
label > select,
label > textarea {
  margin-top: 4px;
  font-size: 1rem;
  font-weight: 400;
  color: var(--ink);
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 10px;
}

.checks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 10px;
  margin: 4px 0 12px;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  margin: 0;
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--ink);
}

.panel.rows {
  padding: 4px 16px;
}

.row {
  border-bottom: 1px solid var(--line);
}

.row:last-child {
  border-bottom: 0;
}

.row > summary {
  padding: 12px 0;
  font-weight: 700;
  cursor: pointer;
}

.row > summary small {
  display: block;
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--muted);
}

.row.inactive > summary {
  color: var(--muted);
}

.row > form {
  padding: 4px 0 12px;
}

/* A thin line across the very top while a change is being saved. It covers nothing. */
#busy {
  position: fixed;
  inset: 0 0 auto;
  z-index: 30;
  height: 4px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
}

.busy #busy {
  animation: saving 1.2s ease-in-out infinite;
}

.busy main {
  cursor: progress;
}

@keyframes saving {
  0% {
    transform: scaleX(0);
  }
  60% {
    transform: scaleX(0.8);
  }
  100% {
    transform: scaleX(1);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .busy #busy {
    animation: none;
    transform: none;
  }
}

