/*
 * framily on the web. The iPhone app's sibling: the same four moods from
 * brand/tokens/themes.json, rounded grouped cards, SF Pro Rounded.
 *
 * Every colour is one of a mood's three roles (--ink, --accent, --ground) or a
 * tint derived from them. The one exception is red, kept for destructive
 * actions only (spec D3).
 *
 * Rules that shape this file (docs/superpowers/specs/2026-09-18-themes.md):
 *  - D1: light uses the brand roles as-is; the dark appearance is the brand's
 *    own reversal (background = ink deepened toward black, raised surfaces =
 *    ink, text = ground). Components only use the semantic tokens below, so no
 *    rule outside this block branches on appearance.
 *  - D2: accent is a fill, never text. Text, links and focus rings use
 *    --text; primary buttons are an accent fill with --on-accent text.
 *
 * Contrast (WCAG AA, computed for all four moods in both appearances, worst
 * case over the page, cards and accent bands):
 *  - The brand's "ink at 60%" secondary text is only 2.7 to 4.2:1, so --text-2
 *    is 86% in light and 80% in dark: at least 4.7:1 and 4.6:1.
 *  - Backyard's ink on its rose accent is 3.4:1, under 4.5, so that mood's
 *    --on-accent is ink deepened 25% toward black (4.7:1). The other three use
 *    ink exactly (6.0:1 and up).
 */

/* The moods. Colour roles only; evening is the default (brand README §3). */
:root,
[data-theme="evening"] {
  --ink: #3d2a57;
  --accent: #f4a15d;
  --ground: #fbf4ea;
  --on-accent-depth: 100%;
}

[data-theme="brunch"] {
  --ink: #124e5c;
  --accent: #ffc947;
  --ground: #eef6f3;
  --on-accent-depth: 100%;
}

[data-theme="nightout"] {
  --ink: #1a1d3b;
  --accent: #c4a7f5;
  --ground: #f1eef9;
  --on-accent-depth: 100%;
}

[data-theme="backyard"] {
  --ink: #2f5a3a;
  --accent: #f28ba0;
  --ground: #f3f6ec;
  --on-accent-depth: 75%;
}

/*
 * Semantic tokens, light appearance. Declared on every [data-theme] element as
 * well as :root because a custom property resolves var() where it is declared:
 * the mood picker draws each option inside its own data-theme, and its
 * --text, --bg and friends have to follow that option's roles, not the page's.
 */
:root,
[data-theme] {
  color-scheme: light;

  --deep: color-mix(in srgb, var(--ink) 55%, black);
  --bg: var(--ground);
  --surface: color-mix(in srgb, var(--ink) 3%, var(--ground));
  --text: var(--ink);
  --text-2: color-mix(in srgb, var(--ink) 86%, transparent);
  /* Text drawn on a --text fill (the "can't go" answer, for one). */
  --on-text: var(--ground);
  --on-accent: color-mix(in srgb, var(--ink) var(--on-accent-depth), black);
  --separator: color-mix(in srgb, var(--ink) 8%, transparent);
  /* Input and option edges: at least 3:1 against the page and cards (WCAG 1.4.11). */
  --control-border: color-mix(in srgb, var(--ink) 65%, transparent);
  --fill: color-mix(in srgb, var(--ink) 7%, transparent);
  --fill-strong: color-mix(in srgb, var(--ink) 14%, transparent);
  --accent-soft: color-mix(in srgb, var(--accent) 15%, transparent);
  --cell: color-mix(in srgb, var(--ink) 9%, var(--ground));
  /* Accent on ground is under 3:1, so a free block also gets an edge. */
  --free-edge: color-mix(in srgb, var(--ink) 55%, var(--accent));
  /* A block that became a plan: a stronger ink wash than an empty block. */
  --plan-wash: color-mix(in srgb, var(--ink) 32%, var(--ground));
  --focus: var(--ink);
  --danger: #c20013;
}

@media (prefers-color-scheme: dark) {
  :root,
  [data-theme] {
    color-scheme: dark;

    --bg: var(--deep);
    --surface: var(--ink);
    --text: var(--ground);
    --text-2: color-mix(in srgb, var(--ground) 80%, transparent);
    --on-text: var(--ink);
    --separator: color-mix(in srgb, var(--ground) 10%, transparent);
    --control-border: color-mix(in srgb, var(--ground) 50%, transparent);
    --fill: color-mix(in srgb, var(--ground) 10%, transparent);
    --fill-strong: color-mix(in srgb, var(--ground) 18%, transparent);
    --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent);
    --cell: color-mix(in srgb, var(--ground) 12%, var(--deep));
    --free-edge: var(--accent);
    --plan-wash: color-mix(in srgb, var(--ground) 34%, var(--deep));
    --focus: var(--ground);
    /* Lighter so it still reads on the brightest ink surface (backyard, 4.6:1). */
    --danger: #ffb3ad;
  }
}

:root {
  --radius: 14px;
  --radius-sm: 10px;
  --gutter: 16px;
  --tabbar-h: 56px;

  /* D7: SF Pro Rounded, the brand's system fallback for Nunito. */
  font-family: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
}

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

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

h1 {
  font-size: 28px;
  font-weight: 700;
}

h2 {
  font-size: 20px;
  font-weight: 650;
}

h3 {
  font-size: 17px;
  font-weight: 600;
}

p {
  margin: 0;
}

a {
  color: var(--text);
}

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

/* Component display rules must never beat the hidden attribute. */
[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -100px;
  z-index: 20;
  padding: 10px 14px;
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
}

.skip-link:focus {
  top: 8px;
}

/* ---------- Page chrome ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 6px var(--gutter);
  padding-top: max(6px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--separator);
}

.lockup {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  gap: 7px;
  color: var(--text);
  text-decoration: none;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

/* The brand mark and wordmark (dom.js, and inline in each page). One SVG
   serves every mood and both appearances: the letters take --text (ink, or
   ground in the dark reversal) and the crossbar chip is always --accent. */
.mark,
.wordmark {
  display: block;
  flex: none;
}

.mark-stem,
.wordmark-ink {
  stroke: var(--text);
}

.mark-chip,
.wordmark-chip {
  stroke: var(--accent);
}

.lockup .wordmark {
  width: auto;
  height: 26px;
}

.topbar-context {
  min-width: 0;
  color: var(--text-2);
  font-size: 15px;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The framily switcher (app.js): a native <select> drawn as the header's
   name, so every platform gets its own picker. Shown only with 2+ framilies. */
.topbar-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.switcher {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
}

.switcher-select {
  min-width: 0;
  max-width: 100%;
  min-height: 44px;
  padding: 8px 32px 8px 12px;
  border: 0;
  border-radius: 999px;
  background: var(--fill);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  text-overflow: ellipsis;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

/* Inset, so the header's overflow clipping can't cut the ring off. */
.switcher-select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

.switcher-chevron {
  position: absolute;
  right: 12px;
  color: var(--text);
  pointer-events: none;
}

.app-notice {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px var(--gutter) 0;
}

main {
  display: block;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 20px var(--gutter) 32px;
}

.stack > * + * {
  margin-top: 16px;
}

.stack-sm > * + * {
  margin-top: 8px;
}

.site-footer {
  max-width: 640px;
  margin: 0 auto;
  padding: 8px var(--gutter) 40px;
  color: var(--text-2);
  font-size: 14px;
}

.site-footer a {
  color: var(--text-2);
}

/* ---------- Cards and lists ---------- */

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
}

.card-link {
  display: block;
  color: inherit;
  text-decoration: none;
}

.card-link:hover {
  background: color-mix(in srgb, var(--surface) 94%, var(--text));
}

.section-label {
  margin: 24px 4px 8px;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.list {
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
}

.list > li {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 10px 16px;
}

.list > li + li {
  border-top: 0.5px solid var(--separator);
}

.list .grow {
  flex: 1;
  min-width: 0;
}

.muted {
  color: var(--text-2);
}

.small {
  font-size: 14px;
}

.footnote {
  margin: 8px 4px 0;
  color: var(--text-2);
  font-size: 13px;
}

.lede {
  font-size: 19px;
  color: var(--text-2);
}

/* ---------- Avatars and chips ---------- */

.avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1.5px var(--accent);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
}

.avatar.is-quiet {
  background: var(--fill);
  box-shadow: none;
  color: var(--text-2);
}

/* An assumed yes: on the list, but they have not said so. */
.avatar.is-assumed {
  background: transparent;
  box-shadow: none;
  border: 1.5px dashed var(--accent);
}

/* Stale: the ring goes quiet rather than turning a warning colour (D3). */
.avatar.is-stale {
  box-shadow: inset 0 0 0 1.5px var(--text-2);
}

.avatar.sm {
  width: 28px;
  height: 28px;
  font-size: 13px;
}

.chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.chip.is-quiet {
  background: var(--fill);
  color: var(--text-2);
}

.chip.is-warn {
  background: var(--accent-soft);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.chip.is-danger {
  background: color-mix(in srgb, var(--danger) 14%, transparent);
  color: var(--danger);
}

/* ---------- Buttons and fields ---------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
  padding: 12px 20px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.button.block {
  display: flex;
  width: 100%;
}

.button.secondary {
  background: var(--fill);
  color: var(--text);
}

.button.plain {
  min-height: 44px;
  padding: 10px 12px;
  background: transparent;
  color: var(--text);
}

.button.destructive {
  background: var(--fill);
  color: var(--danger);
}

.button.destructive-solid {
  /* Fixed, not --danger: the lighter dark-mode red fails contrast under white text.
     Destructive red and its white label are the only colours outside the moods (D3). */
  background: #d70015;
  color: #fff;
}

.button:disabled,
.button[aria-disabled="true"] {
  opacity: 0.45;
  cursor: default;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--fill);
  color: var(--text);
  font: inherit;
  font-size: 20px;
  cursor: pointer;
}

.icon-button:disabled {
  opacity: 0.35;
  cursor: default;
}

.field {
  display: block;
}

.field label,
.field-label {
  display: block;
  margin: 0 4px 6px;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
}

.input,
.select {
  display: block;
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  border: 1px solid var(--control-border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  /* 17px keeps iOS Safari from zooming the page on focus. */
  font: inherit;
  font-size: 17px;
}

.input.code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 22px;
  letter-spacing: 0.12em;
  text-align: center;
  text-transform: uppercase;
}

.input[aria-invalid="true"] {
  border-color: var(--danger);
}

.field-error {
  margin: 6px 4px 0;
  color: var(--danger);
  font-size: 14px;
}

/* A native segmented control, like UISegmentedControl. */
.segmented {
  display: grid;
  grid-auto-columns: 1fr;
  grid-auto-flow: column;
  gap: 2px;
  padding: 2px;
  border-radius: 11px;
  background: var(--fill);
}

.segmented button {
  min-height: 44px;
  padding: 6px 8px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}

/* The selected segment is a selected indicator, so it takes the accent fill (D2). */
.segmented button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}

/* RSVP buttons: bigger, and the chosen one takes the status colour. */
.rsvp {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.rsvp button {
  min-height: 52px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--fill);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

/* In: the accent fill. Maybe: an accent band with an accent edge. Can't: a
   solid text-coloured fill. Three looks from the mood's roles, no new hues. */
.rsvp button[aria-pressed="true"][data-status="in"] {
  background: var(--accent);
  color: var(--on-accent);
}

.rsvp button[aria-pressed="true"][data-status="maybe"] {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 2px var(--accent);
  color: var(--text);
}

.rsvp button[aria-pressed="true"][data-status="out"] {
  background: var(--text);
  color: var(--on-text);
}

.rsvp button:disabled {
  opacity: 0.45;
  cursor: default;
}

/* ---------- Banners and states ---------- */

.banner {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: 12px;
  /* "Attention" without a new colour (D3): an accent band, text-coloured copy. */
  background: var(--accent-soft);
  color: var(--text);
}

.banner strong {
  display: block;
}

.banner .banner-icon {
  flex: none;
  color: var(--text);
  font-weight: 700;
}

.banner.is-info {
  background: var(--fill);
}

.banner.is-info .banner-icon {
  color: var(--text);
}

.banner.is-error {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
}

.banner.is-error .banner-icon {
  color: var(--danger);
}

.empty {
  padding: 32px 20px;
  text-align: center;
}

.empty .mark {
  margin: 0 auto 14px;
}

.empty p {
  margin-top: 6px;
  color: var(--text-2);
}

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--fill-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: -4px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px 0;
  color: var(--text-2);
}

/* ---------- App shell ---------- */

.app-main {
  padding-bottom: calc(var(--tabbar-h) + 32px + env(safe-area-inset-bottom));
}

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--separator);
}

.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: var(--tabbar-h);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 500;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.tabbar a[aria-current="page"] {
  color: var(--text);
  font-weight: 700;
}

.tabbar svg {
  width: 26px;
  height: 26px;
  padding: 1px 14px;
  box-sizing: content-box;
  border-radius: 999px;
}

/* The selected tab sits on an accent pill: a selected indicator, so a fill (D2). */
.tabbar a[aria-current="page"] svg {
  background: var(--accent);
  color: var(--on-accent);
}

.screen-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin: -8px 0 4px -4px;
  padding: 0 4px;
  color: var(--text);
  text-decoration: none;
  font-size: 17px;
}

/* ---------- Plans ---------- */

.plan-card {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 14px;
  align-items: start;
}

.plan-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.date-badge {
  display: grid;
  place-items: center;
  padding: 6px 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--on-accent);
  line-height: 1.1;
}

.date-badge .dow {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.date-badge .dom {
  font-size: 22px;
  font-weight: 700;
}

.plan-card.is-cancelled .date-badge {
  background: var(--fill);
  color: var(--text-2);
}

.plan-card.is-cancelled h3 {
  text-decoration: line-through;
  color: var(--text-2);
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin-top: 6px;
  color: var(--text-2);
  font-size: 14px;
}

.counts {
  display: flex;
  gap: 8px;
}

.counts > div {
  flex: 1;
  padding: 10px 6px;
  border-radius: var(--radius-sm);
  background: var(--fill);
  text-align: center;
}

.counts strong {
  display: block;
  font-size: 22px;
}

.counts span {
  color: var(--text-2);
  font-size: 13px;
}

.guest-status {
  color: var(--text-2);
  font-size: 14px;
}

.guest-status.is-assumed {
  font-style: italic;
}

/* ---------- Availability grid ---------- */

.week-bar {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.week-bar .week-label {
  text-align: center;
}

.week-bar .week-label strong {
  display: block;
  font-size: 16px;
}

.week-bar .week-label span {
  color: var(--text-2);
  font-size: 13px;
}

.grid-wrap {
  /* Buttons fill their whole track so the tappable area includes the gaps;
     the visible block is drawn inset inside it. */
  margin: 0 calc(var(--gutter) * -0.5);
}

.avail-grid {
  display: grid;
  grid-template-columns: 60px repeat(7, minmax(0, 1fr));
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.avail-grid[aria-busy="true"] {
  opacity: 0.5;
}

.day-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 40px;
  line-height: 1.15;
}

.day-head .dow {
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
}

.day-head .dom {
  font-size: 14px;
}

.day-head.is-today .dom {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 22px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
}

.part-label {
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 50px;
  padding-left: 4px;
  line-height: 1.15;
}

.part-label span:first-child {
  font-size: 13px;
  white-space: nowrap;
  font-weight: 500;
}

.part-label span:last-child {
  color: var(--text-2);
  font-size: 11px;
}

.cell {
  position: relative;
  display: block;
  width: 100%;
  height: 50px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.cell::before {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: 9px;
  background: var(--cell);
  transition: background-color 0.15s ease;
}

.cell[aria-pressed="true"]::before {
  background: var(--accent);
  box-shadow: inset 0 0 0 1.5px var(--free-edge);
}

/* Free time entered some other way (the precise editor, or a rule) that
   does not map onto one block: shown, never changed from here. */
.cell.is-partial::after {
  content: "";
  position: absolute;
  right: 7px;
  bottom: 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

.cell[aria-pressed="true"].is-partial::after {
  background: var(--on-accent);
}

.cell.is-locked {
  cursor: not-allowed;
}

.cell.is-locked::before {
  background: repeating-linear-gradient(
    -45deg,
    var(--fill-strong) 0 4px,
    var(--fill) 4px 8px
  );
}

.cell .lock {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--text-2);
}

/* Going to a plan then: drawn as a plan, the stronger wash plus the brand's
   crossbar as a small accent chip ("the one block that became a plan"). */
.cell.is-going {
  cursor: pointer;
}

.cell.is-going::before {
  background: var(--plan-wash);
  box-shadow: none;
}

.going-chip {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
  transform: translate(-50%, -50%);
}

.cell:focus-visible {
  outline: none;
}

.cell:focus-visible::before {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
}

.cell.is-past::before {
  opacity: 0.55;
}

.save-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  margin-top: 8px;
  color: var(--text-2);
  font-size: 14px;
}

.save-status .button {
  flex: none;
  white-space: nowrap;
}

/* Not saved yet is attention, not danger: text colour, weight, and the retry (D3). */
.save-status.is-failed {
  color: var(--text);
  font-weight: 600;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 4px;
  color: var(--text-2);
  font-size: 13px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  background: var(--cell);
}

.swatch.is-free {
  background: var(--accent);
}

.swatch.is-locked {
  background: repeating-linear-gradient(-45deg, var(--fill-strong) 0 3px, var(--fill) 3px 6px);
}

.swatch.is-going {
  position: relative;
  background: var(--plan-wash);
}

.swatch.is-going::after {
  content: "";
  position: absolute;
  top: 5px;
  left: 3px;
  width: 8px;
  height: 4px;
  border-radius: 999px;
  background: var(--accent);
}

.going-dialog .going-when {
  color: var(--text);
  font-weight: 600;
}

/* ---------- Find a time ---------- */

/* The best window is the "everyone's free" highlight: an accent band and edge. */
.window-card.is-best {
  background: color-mix(in srgb, var(--accent) 15%, var(--surface));
  box-shadow: inset 0 0 0 2px var(--accent);
}

.window-card + .window-card {
  margin-top: 10px;
}

.window-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.window-score {
  font-size: 20px;
  font-weight: 700;
}

.window-score.is-everyone {
  color: var(--text);
}

.people-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 12px 0 10px;
  padding: 0;
  list-style: none;
}

/* ---------- Framily ---------- */

.invite-code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.button-row .button {
  flex: 1 1 140px;
}

/* ---------- Settings ---------- */

.button.compact {
  flex: none;
  min-height: 44px;
  padding: 8px 14px;
  font-size: 15px;
}

.list > li.framily-item {
  padding: 4px 12px 4px 0;
  gap: 4px;
}

.framily-pick {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 12px;
  min-width: 0;
  min-height: 60px;
  padding: 8px 8px 8px 16px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
}

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

button.framily-pick:hover {
  background: var(--fill);
}

.framily-row-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.framily-row-name {
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The current framily's check sits on an accent disc: a selected indicator, so a fill (D2). */
.framily-current {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
}

.row-link {
  flex: 1;
  color: var(--text);
}

/* ---------- Mood picker ---------- */

/*
 * Each option carries its own data-theme, so everything inside it (surface,
 * text, the mark) is drawn in that mood's colours, whatever the page's mood
 * is: people choose by feel (brand README §5 rule 4). The radio itself is
 * visually hidden but real, so arrow keys, labels and screen readers work.
 */
.mood-picker {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.mood-option {
  position: relative;
  display: grid;
  grid-template-columns: 52px 1fr 24px;
  align-items: center;
  gap: 14px;
  min-height: 72px;
  padding: 10px 16px 10px 12px;
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--control-border);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.mood-option:has(input:checked) {
  box-shadow: inset 0 0 0 2.5px var(--text);
}

.mood-option:has(input:focus-visible) {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.mood-tile {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--separator);
}

.mood-name {
  display: block;
  font-weight: 700;
}

.mood-tagline {
  display: block;
  color: var(--text-2);
  font-size: 15px;
}

/* The check: an accent disc when chosen (a selected indicator, so a fill). */
.mood-check {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px var(--control-border);
  color: transparent;
}

.mood-option:has(input:checked) .mood-check {
  background: var(--accent);
  box-shadow: none;
  color: var(--on-accent);
}

.mood-screen .lede {
  margin: 8px 0 20px;
  font-size: 17px;
}

.mood-screen .mark {
  margin-bottom: 14px;
}

/* ---------- Dialog ---------- */

dialog {
  width: min(360px, calc(100vw - 2 * var(--gutter)));
  padding: 20px;
  border: 0;
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  text-align: center;
}

/* A neutral scrim, not a brand colour; ::backdrop does not reliably inherit
   custom properties, so it cannot follow the mood anyway. */
dialog::backdrop {
  background: rgb(0 0 0 / 0.4);
}

dialog h2 {
  font-size: 18px;
}

dialog p {
  margin-top: 8px;
  color: var(--text-2);
  font-size: 15px;
}

dialog .button-row {
  margin-top: 18px;
}

/* ---------- Landing and legal ---------- */

.hero {
  padding: 28px 0 8px;
  text-align: center;
}

.hero .mark {
  margin: 0 auto 18px;
}

.hero h1 {
  font-size: 32px;
}

.hero .lede {
  margin-top: 10px;
}

.feature-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.feature-list li {
  display: flex;
  gap: 12px;
  padding: 10px 0;
}

.feature-list li + li {
  border-top: 0.5px solid var(--separator);
}

.feature-list .dot {
  flex: none;
  width: 10px;
  height: 10px;
  margin-top: 7px;
  border-radius: 50%;
  background: var(--accent);
}

.prose h2 {
  margin: 28px 0 8px;
}

.prose p,
.prose ul {
  margin: 0 0 12px;
}

.prose ul {
  padding-left: 22px;
}

.prose li + li {
  margin-top: 6px;
}

.todo {
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--text);
  font-weight: 600;
}

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

@media (min-width: 700px) {
  :root {
    --gutter: 24px;
  }

  .tabbar {
    left: 50%;
    right: auto;
    width: 480px;
    bottom: 16px;
    transform: translateX(-50%);
    border: 0.5px solid var(--separator);
    border-radius: 20px;
    padding-bottom: 0;
  }
}
