/* Confirmmo stylesheet. Handcrafted, no framework.

   The identity is the brandbook's: violet, lavender and night blue on ice,
   Plus Jakarta Sans for display and numbers, Nunito Sans for reading. Two
   ideas carry it. The double check is the state vocabulary: a check still
   drawing is a booking being written, one check is booked, a second check
   in green is attendance confirmed by the patient. The appointment card is
   the logo's speech bubble, and nothing else has that shape.

   Tokens come in two tiers: brand primitives (`--c-*`) and roles.
   Components use roles only and never hardcode a colour. Layers keep
   specificity flat: a later layer wins, nothing else.

   Motion answers an action or shows a state. Layout properties never
   animate; transform, opacity, short colour feedback and the stroke of the
   mark do. Nothing can transition across an htmx swap (the settle delay is
   zero), so arriving content animates with keyframes.

   Layers: tokens (custom properties), base (fonts, reset, typography),
   components (buttons, forms, cards, the booking panel, agenda…), surface
   (per-page layouts: public, app, admin, bare, landing). Light theme only. */

@layer tokens, base, components, surface;

/* The appointment card travels from the booking page to the confirmation
   page. Outside the layers and the reduced-motion switch, which does not
   reach the view-transition pseudo-elements. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition {
    navigation: auto;
  }

  ::view-transition-group(root) {
    animation-duration: 200ms;
  }

  ::view-transition-group(consulta) {
    animation-duration: 350ms;
    animation-timing-function: cubic-bezier(0.2, 0, 0, 1);
  }
}

/* ------------------------------------------------------------------ tokens */
@layer tokens {
  :root {
    color-scheme: light;

    /* Brand primitives. Every value but the red is the brandbook's. */
    --c-violeta: #6c63ff;
    --c-violeta-600: #5a50f0;
    --c-lavanda: #b8b3ff;
    --c-lavanda-100: #e4e2ff;
    --c-lavanda-50: #f0efff;
    --c-azul-noite: #17233d;
    --c-gelo: #f7f8fc;
    --c-branco: #ffffff;
    --c-grafite: #252936;
    --c-grafite-600: #4a4f63;
    --c-linha: #e3e5f0;
    --c-linha-400: #cfd3e4;
    --c-linha-600: #8a8fa3;
    --c-menta: #62d6b2;
    --c-menta-200: #a6efd7;
    --c-menta-50: #e3f8f1;
    --c-menta-600: #169a70;
    --c-menta-700: #157055;
    --c-laranja: #e8710a;
    --c-laranja-50: #fff1e3;
    --c-laranja-700: #b45309;
    --c-erro: #c4314b;
    --c-erro-50: #f9eaed;

    /* Roles. White on `--action` is 5.47:1; on the brand violet it is only
       4.32:1, so `--accent` never sits under small text. */
    --bg: var(--c-gelo);
    --surface: var(--c-branco);
    --surface-sunken: var(--c-gelo);
    --text: var(--c-grafite);
    --text-strong: var(--c-azul-noite);
    --text-muted: var(--c-grafite-600);
    --action: var(--c-violeta-600);
    --action-hover: color-mix(in oklab, var(--c-violeta-600) 86%, var(--c-azul-noite));
    --danger-hover: color-mix(in oklab, var(--c-erro) 86%, var(--c-azul-noite));
    --on-action: var(--c-branco);
    --accent: var(--c-violeta);
    --accent-soft: var(--c-lavanda-50);
    --accent-tint: var(--c-lavanda-100);
    --accent-line: var(--c-lavanda);
    --border: var(--c-linha);
    --border-strong: var(--c-linha-400);
    --border-control: var(--c-linha-600);
    --selected-bg: var(--c-violeta-600);
    --selected-text: var(--c-branco);
    --ink: var(--c-azul-noite);
    --on-ink: var(--c-branco);
    --on-accent: var(--c-branco);
    --ok-on-accent: var(--c-menta-200);

    --ok: var(--c-menta-700);
    --ok-bg: var(--c-menta-50);
    --ok-mark: var(--c-menta-600);
    --ok-glow: var(--c-menta);
    --warn: var(--c-laranja-700);
    --warn-bg: var(--c-laranja-50);
    --warn-mark: var(--c-laranja);
    --danger: var(--c-erro);
    --danger-bg: var(--c-erro-50);

    --font-display: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-ui: "Nunito Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

    /* Inputs are never below 1rem: smaller text makes iOS zoom on focus. */
    --t-2xs: 0.75rem;
    --t-xs: 0.8125rem;
    --t-sm: 0.9375rem;
    --t-ui: 1rem;
    --t-body: 1.0625rem;
    --t-h3: 1.25rem;
    --t-h2: 1.5rem;
    --t-h1: 2rem;
    --t-display: 2.75rem;

    --lh-ui: 1.45;
    --lh-body: 1.6;
    --lh-tight: 1.12;

    /* Radius says what a thing is: a control, a card, a status, the card. */
    --radius-control: 8px;
    --radius-chip: 10px;
    --radius-card: 14px;
    --radius-bubble: 20px;
    --radius-pill: 999px;

    --gutter: 1.25rem;
    --measure: 62ch;
    --control: 2.75rem;

    --focus: 2px solid var(--accent);
    --lift: 0 -8px 24px rgb(23 35 61 / 0.08);

    /* Motion: about 100 ms answers a touch, 200 to 300 ms shows a change,
       400 ms is for large movement. Enter decelerating, leave accelerating;
       the spring is for selection only. */
    --d-1: 100ms;
    --d-2: 200ms;
    --d-3: 300ms;
    --d-4: 400ms;
    --ease-out: cubic-bezier(0.2, 0, 0, 1);
    --ease-in: cubic-bezier(0.4, 0, 1, 1);
    --ease-spring: cubic-bezier(0.3, 1.35, 0.5, 1);

    /* The tail of the speech bubble, cut from the logo's own geometry. */
    --tail: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='6 82.5 38 18'><path d='M24 76L15 94L42 76Z' stroke='black' stroke-width='13' stroke-linejoin='round'/></svg>");
  }

  @supports (transition-timing-function: linear(0, 1)) {
    :root {
      --ease-spring: linear(0, 0.35 8%, 0.72 17%, 0.95 27%, 1.04 36%, 1.06 44%, 1.045 53%, 1.02 63%, 1.004 75%, 0.999 87%, 1);
    }
  }

  @media (min-width: 60rem) {
    :root {
      --t-h1: 2.5rem;
      --gutter: 2rem;
    }
  }
}

/* -------------------------------------------------------------------- base */
@layer base {
  @font-face {
    font-family: "Plus Jakarta Sans";
    font-style: normal;
    font-weight: 200 800;
    font-display: swap;
    src: url("/static/fonts/plus-jakarta-sans-variable-latin.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
  }

  @font-face {
    font-family: "Nunito Sans";
    font-style: normal;
    font-weight: 200 1000;
    font-display: swap;
    src: url("/static/fonts/nunito-sans-variable-latin.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
  }

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

  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    /* No italic or bolder face is shipped beyond the two files: never fake one. */
    font-synthesis: none;
  }

  html,
  body {
    margin: 0;
  }

  body {
    min-height: 100dvh;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: var(--t-ui);
    line-height: var(--lh-ui);
    -webkit-font-smoothing: antialiased;
  }

  h1,
  h2,
  h3,
  h4 {
    margin: 0;
    color: var(--text-strong);
    font-family: var(--font-display);
    font-weight: 700;
    line-height: var(--lh-tight);
    letter-spacing: -0.015em;
    text-wrap: balance;
  }

  h1 {
    font-size: var(--t-h1);
    font-weight: 800;
    letter-spacing: -0.025em;
  }

  h2 { font-size: var(--t-h2); }
  h3 { font-size: var(--t-h3); }

  p,
  ul,
  ol,
  dl,
  figure {
    margin: 0;
  }

  ul,
  ol {
    padding: 0;
    list-style: none;
  }

  a {
    color: var(--action);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.18em;
  }

  img,
  svg {
    display: block;
    max-width: 100%;
  }

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

  button {
    cursor: pointer;
  }

  strong {
    font-weight: 700;
  }

  small {
    font-size: var(--t-xs);
  }

  time,
  .num {
    font-variant-numeric: tabular-nums;
  }

  ::selection {
    background: var(--accent-tint);
    color: var(--text);
  }

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

  /* The first stop of the keyboard: straight to the page's content. */
  .skip-link {
    position: absolute;
    left: var(--gutter);
    top: 0.5rem;
    z-index: 200;
    padding: 0.625rem 1rem;
    border-radius: var(--radius-control);
    background: var(--ink);
    color: var(--on-ink);
    font-weight: 700;
    text-decoration: none;
    transform: translateY(-200%);
  }

  .skip-link:focus-visible {
    transform: none;
  }

  /* Slot for htmx out-of-band banners; invisible while empty. */
  #flash:empty {
    display: none;
  }

  /* Alpine: hide elements until it has initialised them. */
  [x-cloak] {
    display: none !important;
  }

  @media (hover: hover) {
    a:hover {
      text-decoration-thickness: 2px;
    }
  }

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

/* -------------------------------------------------------------- components */
@layer components {
  /* Prose: notices, confirmation copy, the bio. */
  .voice {
    font-size: var(--t-body);
    line-height: var(--lh-body);
    max-width: var(--measure);
  }

  .voice p + p {
    margin-top: 0.75em;
  }

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

  .small {
    font-size: var(--t-xs);
  }

  .measure {
    max-width: var(--measure);
  }

  .stack {
    display: grid;
    gap: 1rem;
  }

  .stack-sm {
    display: grid;
    gap: 0.5rem;
  }

  .row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
  }

  .row-between {
    justify-content: space-between;
  }

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

  /* The logo: the bubble with its two checks, then the wordmark. -------- */
  .logo {
    display: inline-flex;
    align-items: center;
    color: var(--accent);
  }

  .logo svg {
    height: 1.625rem;
    width: auto;
    overflow: visible;
  }

  .logo .mark-line {
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .logo .mark-check-2 {
    stroke: var(--ok-mark);
  }

  .logo .logo-word {
    fill: currentColor;
  }

  .logo-lg svg {
    height: 2.5rem;
  }

  .logo-sm svg {
    height: 1.125rem;
  }

  /* The state mark: the checks of the logo, saying where a booking stands.
     Drawing = being written, one = booked, two = attendance confirmed.
     `pathLength` is 1 on both paths, so a dash offset of 1 hides a check
     and 0 shows it whole. */
  .ticks {
    display: inline-block;
    flex: none;
    width: 1.5em;
    height: auto;
    overflow: visible;
    fill: none;
    stroke-width: 9;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .ticks-one {
    width: 1.05em;
  }

  .tick-1 {
    stroke: var(--accent);
  }

  .tick-2 {
    stroke: var(--ok-mark);
  }

  .state-mark {
    position: relative;
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 1.6em;
    height: 1.6em;
    font-size: 1.75rem;
    line-height: 1;
  }

  .state-mark .ticks {
    width: 1.35em;
  }

  .state-mark .ticks-one {
    width: 0.95em;
  }

  .state-mark .tick-1,
  .state-mark .tick-2 {
    stroke-dasharray: 1;
    stroke-dashoffset: 0;
  }

  /* Still being written: the check stops halfway and waits there. The
     last frame is the resting one, so reduced motion shows it as it is. */
  .state-mark.is-pending .tick-1 {
    stroke-dashoffset: 0.5;
    animation: draw-half 700ms var(--ease-out) both;
  }

  .state-mark.is-void .tick-1 {
    stroke: var(--border-control);
  }

  /* Just booked: the one signature moment. The check draws, then a single
     ring of mint leaves it. */
  .is-fresh .state-mark .tick-1 {
    animation: draw 450ms var(--ease-out) 300ms both;
  }

  .is-fresh .state-mark .tick-2 {
    animation: draw 450ms var(--ease-out) 600ms both;
  }

  .is-fresh .state-mark::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--ok-glow);
    opacity: 0;
    pointer-events: none;
    animation: ring 700ms var(--ease-out) 650ms both;
  }

  /* A round cap shows as a dot before anything is drawn: hide the stroke
     until the first frame of the draw. */
  @keyframes draw {
    0% {
      stroke-dashoffset: 1;
      opacity: 0;
    }
    1% {
      opacity: 1;
    }
    100% {
      stroke-dashoffset: 0;
      opacity: 1;
    }
  }

  @keyframes draw-half {
    0% {
      stroke-dashoffset: 1;
      opacity: 0;
    }
    1% {
      opacity: 1;
    }
    100% {
      stroke-dashoffset: 0.5;
      opacity: 1;
    }
  }

  @keyframes ring {
    0% {
      opacity: 0.9;
      transform: scale(0.6);
    }
    100% {
      opacity: 0;
      transform: scale(1.5);
    }
  }

  /* Motion primitives ---------------------------------------------------- */

  /* Content that has just arrived rises into place. `--i` staggers a run
     of siblings (chips), 15 ms apart. Replays whenever the element is shown
     again, which is what a day switch wants. */
  .reveal {
    animation: reveal var(--d-2) var(--ease-out) both;
    animation-delay: calc(var(--i, 0) * 15ms);
  }

  @keyframes reveal {
    from {
      opacity: 0;
      transform: translateY(6px);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }

  /* Arriving from the side of travel: `--from` is set by whoever knows the
     direction (a later week or day comes from the right). */
  @keyframes arrive {
    from {
      opacity: 0;
      transform: translate(var(--from, 0), var(--rise, 6px));
    }
    to {
      opacity: 1;
      transform: none;
    }
  }

  /* A chosen chip or tile settles with a small spring. */
  @keyframes pop {
    from {
      transform: scale(0.94);
    }
    to {
      transform: scale(1);
    }
  }

  /* A value that changed rolls in from below. */
  @keyframes roll {
    from {
      opacity: 0;
      transform: translateY(0.5em);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }

  /* The card grows out of its tail. */
  @keyframes bubble-in {
    from {
      opacity: 0;
      transform: scale(0.92);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }

  /* Alpine class transitions (x-transition:enter="t-in" …). */
  .t-in {
    transition: opacity var(--d-2) var(--ease-out), transform var(--d-2) var(--ease-out);
  }

  .t-out {
    transition: opacity 150ms var(--ease-in), transform 150ms var(--ease-in);
  }

  .t-off {
    opacity: 0;
    transform: translate(var(--from, 0), var(--rise, 6px));
  }

  .t-on {
    opacity: 1;
    transform: none;
  }

  .t-below {
    opacity: 0;
    transform: translateY(100%);
  }

  /* A region that htmx reloads. While the request runs (after 150 ms, so a
     fast answer never flickers) the body dims and a violet line runs along
     the top edge. `hx-indicator` points here; the body is `.loadable-body`. */
  .loadable {
    position: relative;
  }

  .loadable::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    border-radius: 1px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    background-size: 40% 100%;
    background-repeat: no-repeat;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--d-1) var(--ease-out) 150ms;
  }

  .loadable.htmx-request::before {
    opacity: 1;
    animation: progress-line 1.1s var(--ease-out) infinite;
  }

  @keyframes progress-line {
    from { background-position: -40% 0; }
    to { background-position: 140% 0; }
  }

  .loadable > .loadable-body {
    transition: opacity var(--d-1) linear;
  }

  .loadable.htmx-request > .loadable-body {
    opacity: 0.5;
    pointer-events: none;
    transition-delay: 150ms;
  }

  /* A button whose request is in flight shows a spinner over its label. */
  .btn.htmx-request,
  .btn[data-disabled-by-htmx] {
    position: relative;
    color: transparent;
  }

  .btn.htmx-request::after,
  .btn[data-disabled-by-htmx]::after {
    content: "";
    position: absolute;
    inset: 0;
    margin: auto;
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    border: 2px solid color-mix(in oklab, var(--on-action) 35%, transparent);
    border-top-color: var(--on-action);
    animation: spin 0.8s linear infinite;
  }

  .btn-secondary.htmx-request::after,
  .btn-quiet.htmx-request::after,
  .btn-danger.htmx-request::after,
  .btn-secondary[data-disabled-by-htmx]::after,
  .btn-quiet[data-disabled-by-htmx]::after,
  .btn-danger[data-disabled-by-htmx]::after {
    border-color: var(--accent-tint);
    border-top-color: var(--action);
  }

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

  /* Top progress bar for native navigations (app.js inserts it). */
  #nav-progress {
    position: fixed;
    inset: 0 0 auto 0;
    height: 3px;
    z-index: 100;
    pointer-events: none;
    background: var(--accent);
    transform: scaleX(0);
    transform-origin: 0 50%;
    transition: transform 6s var(--ease-out);
  }

  #nav-progress.is-active {
    transform: scaleX(0.9);
  }

  /* Buttons ------------------------------------------------------------- */
  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: var(--control);
    padding: 0 1.25rem;
    border: 1px solid var(--action);
    border-radius: var(--radius-control);
    background: var(--action);
    color: var(--on-action);
    font-family: var(--font-display);
    font-size: var(--t-sm);
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color var(--d-1) var(--ease-out), border-color var(--d-1) var(--ease-out), transform var(--d-1) var(--ease-out);
  }

  .btn:active {
    transform: scale(0.97);
  }

  .btn-secondary {
    border-color: var(--accent-line);
    background: var(--surface);
    color: var(--action);
  }

  .btn-quiet {
    border-color: transparent;
    background: transparent;
    color: var(--action);
    padding-inline: 0.75rem;
  }

  .btn-danger {
    border-color: var(--danger);
    background: var(--danger);
    color: var(--on-action);
  }

  .btn-sm {
    min-height: 2.5rem;
    padding-inline: 0.875rem;
    font-size: var(--t-xs);
  }

  .btn-block {
    width: 100%;
  }

  .btn[disabled],
  .btn[aria-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
  }

  .btn-google {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border-control);
  }

  .btn-google svg {
    width: 1.125rem;
    height: 1.125rem;
  }

  .btn .icon {
    width: 1rem;
    height: 1rem;
  }

  @media (hover: hover) {
    .btn:hover {
      background: var(--action-hover);
      border-color: var(--action-hover);
    }

    .btn-secondary:hover,
    .btn-quiet:hover {
      background: var(--accent-soft);
    }

    .btn-secondary:hover {
      border-color: var(--accent);
    }

    .btn-quiet:hover {
      border-color: transparent;
    }

    .btn-danger:hover {
      background: var(--danger-hover);
      border-color: var(--danger-hover);
    }

    .btn-google:hover {
      background: var(--surface-sunken);
      border-color: var(--text-muted);
    }
  }

  /* Pills: status words, never decoration. ------------------------------ */
  .badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.1875rem 0.625rem;
    border-radius: var(--radius-pill);
    background: var(--border);
    color: var(--text-muted);
    font-family: var(--font-display);
    font-size: var(--t-xs);
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
  }

  .badge .icon {
    width: 0.875rem;
    height: 0.875rem;
  }

  .badge-ok { background: var(--ok-bg); color: var(--ok); }
  .badge-atencao { background: var(--warn-bg); color: var(--warn); }
  .badge-erro { background: var(--danger-bg); color: var(--danger); }
  .badge-caneta { background: var(--accent-tint); color: var(--text); }

  /* A status line with a dot: connection state, sync state. */
  .status {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
  }

  .status::before {
    content: "";
    width: 0.625rem;
    height: 0.625rem;
    border-radius: 50%;
    background: var(--border-control);
    flex: none;
  }

  .status-ok::before { background: var(--ok-mark); }
  .status-atencao::before { background: var(--warn-mark); }
  .status-erro::before { background: var(--danger); }

  /* Banners (flash). Success closes itself; errors stay until closed. --- */
  #flash {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 0.5rem var(--gutter) 0;
  }

  .banner {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    max-width: 48rem;
    margin: 0 auto;
    padding: 0.75rem 1rem;
    border: 1px solid;
    border-radius: var(--radius-card);
    font-size: var(--t-sm);
    animation: banner-in var(--d-3) var(--ease-out) both;
  }

  @keyframes banner-in {
    from {
      opacity: 0;
      transform: translateY(-12px);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }

  .banner-ok {
    border-color: color-mix(in oklab, var(--ok-glow) 60%, var(--surface));
    background: var(--ok-bg);
    color: var(--text);
  }

  .banner-error {
    border-color: color-mix(in oklab, var(--danger) 35%, var(--surface));
    background: var(--danger-bg);
    color: var(--text);
  }

  .banner span {
    flex: 1;
  }

  .banner-close {
    flex: none;
    display: grid;
    place-items: center;
    width: 1.75rem;
    height: 1.75rem;
    margin: -0.125rem -0.25rem -0.125rem 0;
    border: 0;
    border-radius: var(--radius-control);
    background: transparent;
    color: inherit;
    font-size: 1.25rem;
    line-height: 1;
  }

  /* Forms ------------------------------------------------------------- */
  .field {
    display: grid;
    gap: 0.375rem;
    align-content: start;
  }

  .field-label {
    font-weight: 700;
  }

  .field-hint {
    color: var(--text-muted);
    font-size: var(--t-xs);
  }

  .field-error {
    color: var(--danger);
    font-size: var(--t-xs);
    font-weight: 600;
    animation: reveal var(--d-2) var(--ease-out);
  }

  .input {
    width: 100%;
    min-height: var(--control);
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-control);
    border-radius: var(--radius-control);
    background: var(--surface);
    color: var(--text);
    font-size: var(--t-ui);
    transition: border-color var(--d-1) var(--ease-out), box-shadow var(--d-1) var(--ease-out);
  }

  .input::placeholder {
    color: color-mix(in oklab, var(--text-muted) 75%, var(--surface));
  }

  .input:focus-visible {
    outline: var(--focus);
    outline-offset: 0;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft);
  }

  textarea.input {
    min-height: 6rem;
    resize: vertical;
    line-height: var(--lh-ui);
  }

  select.input {
    appearance: none;
    padding-right: 2.25rem;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'><path d='M4 6l4 4 4-4' fill='none' stroke='%234a4f63' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/></svg>");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
  }

  .input-sm {
    min-height: 2.5rem;
    padding: 0.25rem 0.5rem;
  }

  .field.has-error .input {
    border-color: var(--danger);
  }

  .check {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    line-height: var(--lh-ui);
  }

  .check input {
    flex: none;
    width: 1.375rem;
    height: 1.375rem;
    margin-top: 0.05rem;
    accent-color: var(--action);
  }

  .check.has-error input {
    outline: 2px solid var(--danger);
    outline-offset: 2px;
  }

  .form-grid {
    display: grid;
    gap: 1rem;
  }

  @media (min-width: 48rem) {
    .form-grid {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .form-grid .span-2 {
      grid-column: span 2;
    }
  }

  .form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    padding-top: 0.5rem;
  }

  fieldset {
    margin: 0;
    padding: 0;
    border: 0;
    min-width: 0;
  }

  legend {
    padding: 0;
    color: var(--text-strong);
    font-family: var(--font-display);
    font-size: var(--t-h3);
    font-weight: 700;
    margin-bottom: 0.75rem;
  }

  /* Cards: a white surface with a hairline, no shadow. ------------------ */
  .card {
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    padding: 1.25rem;
    background: var(--surface);
  }

  .card-title {
    color: var(--text-strong);
    font-family: var(--font-display);
    font-size: var(--t-ui);
    font-weight: 700;
    line-height: var(--lh-tight);
    margin-bottom: 0.75rem;
  }

  .card + .card {
    margin-top: 1rem;
  }

  .card-gap {
    margin-top: 0.75rem;
  }

  /* Section headers inside pages. */
  .section {
    display: grid;
    gap: 1rem;
    /* An anchor lands below the top bar, not under it. */
    scroll-margin-top: 1.5rem;
  }

  .section-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    padding-bottom: 0.625rem;
    border-bottom: 1px solid var(--border);
  }

  /* Links to the sections of a long page. */
  .section-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin: 1rem 0 2rem;
  }

  .section-nav a {
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-pill);
    background: var(--surface);
    color: var(--text);
    font-size: var(--t-xs);
    font-weight: 600;
    text-decoration: none;
  }

  .back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
    font-size: var(--t-sm);
    font-weight: 600;
    text-decoration: none;
  }

  .back-link .icon {
    width: 1rem;
    height: 1rem;
  }

  @media (hover: hover) {
    .section-nav a:hover {
      border-color: var(--accent);
      background: var(--accent-soft);
    }
  }

  /* Tables ------------------------------------------------------------ */
  .table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    background: var(--surface);
  }

  .table {
    width: 100%;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
  }

  /* A narrow screen scrolls the table sideways; it never breaks a name
     over three lines. */
  .table th,
  .table td {
    padding: 0.75rem 1rem;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
  }

  .table th {
    color: var(--text-muted);
    font-size: var(--t-xs);
    font-weight: 700;
    background: var(--surface-sunken);
    white-space: nowrap;
  }

  .table td.num,
  .table th.num {
    text-align: right;
  }

  .table tr:last-child td {
    border-bottom: 0;
  }

  /* Nameplate: who the patient is booking with. ------------------------ */
  .nameplate {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    column-gap: 1rem;
    row-gap: 0.25rem;
    align-items: start;
  }

  .nameplate-photo {
    grid-row: span 3;
    width: 4.5rem;
    height: 4.5rem;
    border-radius: 50%;
    object-fit: cover;
    background: var(--accent-tint);
    border: 3px solid var(--surface);
    outline: 1px solid var(--border-strong);
  }

  .nameplate-initials {
    display: grid;
    place-items: center;
    color: var(--action);
    font-family: var(--font-display);
    font-size: var(--t-h2);
    font-weight: 800;
  }

  .nameplate-name {
    color: var(--text-strong);
    font-family: var(--font-display);
    font-size: 1.625rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    line-height: 1.08;
    text-wrap: balance;
  }

  .nameplate-meta {
    color: var(--text-muted);
    font-size: var(--t-sm);
  }

  .nameplate-meta .num {
    color: var(--text);
  }

  .nameplate-place {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-top: 0.75rem;
    font-size: var(--t-sm);
  }

  .nameplate-place .icon {
    width: 1rem;
    height: 1rem;
    flex: none;
    margin-top: 0.2rem;
    color: var(--accent);
  }

  .nameplate-bio {
    margin-top: 1rem;
    color: var(--text-muted);
    font-size: var(--t-ui);
    line-height: var(--lh-body);
    max-width: var(--measure);
  }

  /* On a phone the place and the bio span the plate's full width. */
  .nameplate-place,
  .nameplate-bio {
    grid-column: 1 / -1;
  }

  /* Beside an appointment, on a phone, the plate says who and no more:
     the appointment is what the page is about. */
  @media (max-width: 59.99rem) {
    .nameplate.is-brief .nameplate-photo {
      width: 3rem;
      height: 3rem;
      font-size: var(--t-ui);
    }

    .nameplate.is-brief .nameplate-name {
      font-size: var(--t-h3);
    }

    .nameplate.is-brief ~ .nameplate-place,
    .nameplate.is-brief ~ .nameplate-bio {
      display: none;
    }
  }

  /* In the sidebar the plate stacks: photo above, then the name at full
     width, so a short name does not wrap beside the photo. */
  @media (min-width: 60rem) {
    .nameplate {
      grid-template-columns: minmax(0, 1fr);
      row-gap: 0.375rem;
    }

    .nameplate-photo {
      grid-row: auto;
      width: 5.5rem;
      height: 5.5rem;
      margin-bottom: 0.75rem;
    }

    .nameplate-name {
      font-size: var(--t-h1);
    }
  }

  /* The booking flow: numbered sections, each ruled off from the next. - */
  .flow {
    display: grid;
    gap: 2rem;
  }

  .step {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
  }

  .step + .step {
    padding-top: 2rem;
    border-top: 1px solid var(--border);
  }

  /* The number sits in the heading at every width. */
  .step-mark {
    display: none;
  }

  .step-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    margin-bottom: 1rem;
  }

  .step-title {
    font-size: var(--t-h3);
    font-weight: 700;
  }

  /* Step numbers are structure, not selection: quiet. */
  .step-num {
    display: inline-grid;
    place-items: center;
    width: 1.625rem;
    height: 1.625rem;
    margin-right: 0.625rem;
    border-radius: 50%;
    background: var(--accent-tint);
    color: var(--text-strong);
    font-size: var(--t-xs);
    font-weight: 700;
    letter-spacing: 0;
    vertical-align: 0.15em;
  }

  .step-single {
    color: var(--text);
  }

  .step-body {
    min-width: 0;
    /* "Continuar" scrolls here: the heading stays in view. */
    scroll-margin-top: 1rem;
  }

  /* The one service of a professional: said once, above the flow. */
  .service-line {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.75rem;
    padding-bottom: 1.5rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border);
  }

  .service-line-name {
    color: var(--text-strong);
    font-family: var(--font-display);
    font-size: var(--t-h3);
    font-weight: 700;
    letter-spacing: -0.015em;
  }

  .service-line-price {
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
  }

  /* Service cards: radios that fill with lavender when chosen. */
  .options {
    display: grid;
    gap: 0.5rem;
  }

  @media (min-width: 48rem) {
    .options {
      grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
    }
  }

  .option {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 1rem;
    align-items: center;
    padding: 0.875rem 1rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-chip);
    background: var(--surface);
    cursor: pointer;
    transition: border-color var(--d-1) var(--ease-out), background-color var(--d-1) var(--ease-out), box-shadow var(--d-1) var(--ease-out);
  }

  .option input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
  }

  .option:has(input:checked) {
    border-color: var(--action);
    background: var(--accent-soft);
    box-shadow: inset 0 0 0 1px var(--action);
  }

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

  .option-name {
    color: var(--text-strong);
    font-family: var(--font-display);
    font-size: var(--t-ui);
    font-weight: 700;
    line-height: var(--lh-tight);
  }

  .option-meta {
    color: var(--text-muted);
    font-size: var(--t-xs);
    margin-top: 0.25rem;
  }

  .option-price {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }

  @media (hover: hover) {
    .option:hover {
      border-color: var(--accent);
    }
  }

  /* The availability panel: a week strip, then the chosen day's times. */
  .when-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
  }

  .when-range {
    flex: 1;
    color: var(--text-strong);
    font-family: var(--font-display);
    font-size: var(--t-ui);
    font-weight: 700;
    text-transform: lowercase;
    white-space: nowrap;
  }

  .when-nav {
    display: grid;
    place-items: center;
    width: var(--control);
    height: var(--control);
    border: 1px solid var(--border-strong);
    border-radius: 50%;
    background: var(--surface);
    color: var(--text);
    transition: border-color var(--d-1) var(--ease-out), transform var(--d-1) var(--ease-out);
  }

  .when-nav:active {
    transform: scale(0.94);
  }

  .when-nav[disabled] {
    opacity: 0.35;
    cursor: not-allowed;
  }

  .when-nav svg {
    width: 1rem;
    height: 1rem;
  }

  /* "Outra data": a quiet button with the native date input laid over it,
     so the tap opens the platform's picker. */
  .when-jump {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    min-height: var(--control);
    padding: 0 0.625rem;
    border-radius: var(--radius-control);
    color: var(--action);
    font-family: var(--font-display);
    font-size: var(--t-xs);
    font-weight: 700;
    cursor: pointer;
  }

  .when-jump input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
  }

  .when-jump:has(input:focus-visible) {
    outline: var(--focus);
    outline-offset: 2px;
  }

  .when-jump .icon {
    width: 1rem;
    height: 1rem;
  }

  @media (hover: hover) {
    .when-nav:hover {
      border-color: var(--accent);
    }

    .when-jump:hover {
      background: var(--accent-soft);
    }
  }

  /* A week that arrives after a click comes from the side of travel: its
     tiles do the moving, the window itself stays still. */
  #availability[data-dir="next"] {
    --from: 18px;
    --rise: 0px;
  }

  #availability[data-dir="prev"] {
    --from: -18px;
    --rise: 0px;
  }

  .strip {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.25rem;
  }

  .tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.125rem;
    min-height: 4.5rem;
    padding: 0.5rem 0.125rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-chip);
    background: var(--surface);
    color: var(--text);
    font-family: var(--font-ui);
    line-height: 1.1;
    transition: border-color var(--d-1) var(--ease-out), background-color var(--d-1) var(--ease-out);
    animation: arrive var(--d-3) var(--ease-out) both;
    animation-delay: var(--wait, 0ms);
  }

  .tile:nth-child(2) { --wait: 20ms; }
  .tile:nth-child(3) { --wait: 40ms; }
  .tile:nth-child(4) { --wait: 60ms; }
  .tile:nth-child(5) { --wait: 80ms; }
  .tile:nth-child(6) { --wait: 100ms; }
  .tile:nth-child(7) { --wait: 120ms; }

  .tile-name {
    font-size: var(--t-xs);
    color: var(--text-muted);
    white-space: nowrap;
  }

  .tile-num {
    position: relative;
    padding-bottom: 0.25rem;
    color: var(--text-strong);
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
  }

  /* Today carries a dot, whether or not it has times. */
  .tile.is-today .tile-num::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: -0.0625rem;
    width: 0.3125rem;
    height: 0.3125rem;
    margin-left: -0.15625rem;
    border-radius: 50%;
    background: var(--accent);
  }

  .tile-count {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
  }

  /* Narrow tiles keep the count and drop the noun (the label has it);
     "amanhã" is the longest name and has to fit. */
  @media (max-width: 40rem) {
    .tile-count .noun {
      display: none;
    }

    .tile-name {
      font-size: var(--t-2xs);
    }
  }

  /* A day with nothing free steps back: no surface, no edge. */
  .tile.is-muted {
    border-color: transparent;
    background: transparent;
  }

  .tile.is-muted .tile-num {
    color: var(--text-muted);
    font-weight: 500;
  }

  /* The entrance stays first in the list: an animation that keeps its
     name is not replayed, so a tile that loses the choice does not blink. */
  .tile[aria-checked="true"] {
    background: var(--selected-bg);
    color: var(--selected-text);
    border-color: var(--selected-bg);
    animation: arrive var(--d-3) var(--ease-out) both, pop var(--d-3) var(--ease-spring);
    animation-delay: var(--wait, 0ms), 0ms;
  }

  .tile[aria-checked="true"] .tile-name,
  .tile[aria-checked="true"] .tile-num,
  .tile[aria-checked="true"] .tile-count {
    color: var(--selected-text);
  }

  .tile[aria-checked="true"].is-today .tile-num::after {
    background: var(--selected-text);
  }

  @media (hover: hover) {
    .tile:hover {
      border-color: var(--accent);
    }

    .tile.is-muted:hover {
      border-color: var(--border-strong);
    }
  }

  .times {
    margin-top: 1.5rem;
    min-height: 9rem;
  }

  /* A later day comes from the right, an earlier one from the left. */
  .times[data-dir="next"] {
    --from: 14px;
    --rise: 0px;
  }

  .times[data-dir="prev"] {
    --from: -14px;
    --rise: 0px;
  }

  .times-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.25rem 1rem;
    margin-bottom: 0.75rem;
  }

  .times-day {
    font-size: var(--t-ui);
    font-weight: 700;
    letter-spacing: -0.01em;
  }

  .times-tz {
    color: var(--text-muted);
    font-size: var(--t-xs);
  }

  .times-groups {
    display: grid;
    gap: 1rem;
  }

  .times-group {
    display: grid;
    gap: 0.375rem;
  }

  .times-label {
    color: var(--text-muted);
    font-size: var(--t-xs);
    font-weight: 600;
  }

  @media (min-width: 30rem) {
    .times-group {
      grid-template-columns: 3.5rem minmax(0, 1fr);
      column-gap: 0.75rem;
      align-items: start;
    }

    .times-label {
      padding-top: 0.75rem;
    }
  }

  .slot-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(4.5rem, 1fr));
    gap: 0.5rem;
  }

  .slot {
    min-height: var(--control);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-chip);
    background: var(--surface);
    color: var(--text-strong);
    font-family: var(--font-display);
    font-size: var(--t-sm);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    transition: border-color var(--d-1) var(--ease-out), background-color var(--d-1) var(--ease-out), color var(--d-1) var(--ease-out);
  }

  .slot:active {
    transform: scale(0.96);
  }

  .slot[aria-pressed="true"] {
    background: var(--selected-bg);
    color: var(--selected-text);
    border-color: var(--selected-bg);
    font-weight: 700;
    animation: reveal var(--d-2) var(--ease-out) both, pop var(--d-3) var(--ease-spring);
    animation-delay: calc(var(--i, 0) * 15ms), 0ms;
  }

  @media (hover: hover) {
    .slot:hover {
      border-color: var(--accent);
      background: var(--accent-soft);
    }

    .slot[aria-pressed="true"]:hover {
      background: var(--selected-bg);
    }
  }

  .times-empty {
    display: grid;
    gap: 0.75rem;
    justify-items: start;
    padding: 0.75rem 0;
    color: var(--text-muted);
    font-size: var(--t-body);
  }

  /* A chosen time that is no longer free, said where the times are. */
  .times-lost {
    margin-bottom: 0.75rem;
    padding: 0.625rem 0.875rem;
    border-radius: var(--radius-chip);
    background: var(--warn-bg);
    color: var(--text);
    font-size: var(--t-sm);
    animation: reveal var(--d-2) var(--ease-out);
  }

  /* Inline panel states: a transient failure with a retry, or the
     professional's WhatsApp when nothing can be booked. */
  .panel-notice {
    padding: 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    background: var(--surface);
    font-size: var(--t-body);
    line-height: var(--lh-body);
  }

  .panel-notice .row {
    margin-top: 0.75rem;
    font-size: var(--t-ui);
  }

  /* The cartão de consulta: the logo's speech bubble, holding the chosen
     appointment and the mark of its state. The only thing with this shape. */
  .ticket {
    --ticket-line: var(--accent);
    position: relative;
    display: grid;
    grid-template-columns: 5.25rem minmax(0, 1fr);
    max-width: 30rem;
    margin-bottom: 1.25rem;
    border: 2px solid var(--ticket-line);
    border-radius: var(--radius-bubble);
    background: var(--surface);
    transform-origin: 1.5rem 100%;
    view-transition-name: consulta;
  }

  .ticket::after {
    content: "";
    position: absolute;
    left: 1.375rem;
    top: calc(100% + 1px);
    width: 2.2rem;
    height: 1.04rem;
    background: var(--ticket-line);
    -webkit-mask: var(--tail) no-repeat 0 0 / 100% 100%;
    mask: var(--tail) no-repeat 0 0 / 100% 100%;
  }

  .ticket.is-arriving {
    animation: bubble-in var(--d-3) var(--ease-out) both;
  }

  .ticket-stub {
    display: grid;
    align-content: center;
    justify-items: center;
    gap: 0.0625rem;
    padding: 1rem 0.5rem;
    border-radius: calc(var(--radius-bubble) - 2px) 0 0 calc(var(--radius-bubble) - 2px);
    background: var(--accent-soft);
    text-align: center;
  }

  .ticket-day {
    color: var(--text-strong);
    font-family: var(--font-display);
    font-size: 2.25rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1;
    font-variant-numeric: tabular-nums;
  }

  .ticket-month,
  .ticket-weekday {
    font-size: var(--t-xs);
    font-weight: 600;
    color: var(--text-muted);
  }

  .ticket-body {
    display: grid;
    gap: 0.3125rem;
    align-content: center;
    min-width: 0;
    padding: 1rem 1.125rem;
  }

  .ticket-service {
    color: var(--text-strong);
    font-family: var(--font-display);
    font-size: var(--t-ui);
    font-weight: 700;
    line-height: var(--lh-tight);
  }

  .ticket-time {
    display: inline-block;
    padding: 0 0.4em;
    border-radius: 6px;
    background: var(--accent-tint);
    color: var(--text-strong);
    font-family: var(--font-display);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
  }

  .ticket-time.is-rolling {
    animation: roll var(--d-2) var(--ease-out);
  }

  .ticket-line {
    color: var(--text-muted);
    font-size: var(--t-sm);
  }

  .ticket-line .num {
    color: var(--text);
  }

  /* The mark sits in the card's corner; the first line makes room. */
  .ticket-mark {
    position: absolute;
    top: 0.625rem;
    right: 0.75rem;
  }

  .ticket-mark .state-mark {
    font-size: 1.375rem;
  }

  .ticket:has(.ticket-mark) .ticket-service {
    padding-right: 2.5rem;
  }

  /* The summary of the choice lives in two places and shows in one: in
     the aside on wide screens, above the form on a phone. */
  .ticket-slot {
    display: grid;
    gap: 0.5rem;
  }

  .ticket-slot-side {
    display: none;
    margin-top: 2rem;
  }

  .ticket-hint {
    color: var(--text-muted);
    font-size: var(--t-sm);
  }

  /* On wide screens the card itself shows in the aside only; what is left
     in the main column is the sentence that asks for a choice. */
  @media (min-width: 60rem) {
    .ticket-slot-side {
      display: grid;
    }

    .ticket-slot-main .ticket {
      display: none;
    }
  }

  /* The booking form under the card: the client's details and the
     consent, in one column at every width. */
  .book-form {
    display: grid;
    gap: 1.125rem;
    max-width: 28rem;
    margin-top: 1.5rem;
  }

  .book-form.htmx-request {
    opacity: 0.7;
    transition: opacity var(--d-1) linear;
  }

  /* A refusal beside the form: the slot went, the cap, try again. */
  .notice-inline {
    margin-top: 1rem;
    padding: 0.875rem 1rem;
    font-size: var(--t-sm);
    animation: reveal var(--d-2) var(--ease-out);
  }

  /* The choice, within reach of the thumb: on a phone the form opens
     below the fold, so the bar says what was picked and leads there. */
  .pickbar {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem var(--gutter) calc(0.75rem + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--lift);
  }

  .pickbar-choice {
    display: grid;
    min-width: 0;
    line-height: 1.25;
  }

  .pickbar-day {
    color: var(--text-muted);
    font-size: var(--t-xs);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .pickbar-time {
    color: var(--text-strong);
    font-family: var(--font-display);
    font-size: var(--t-h3);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
  }

  @media (min-width: 60rem) {
    .pickbar {
      display: none;
    }
  }

  /* The appointment page: the card, and what to do next. A cancelled or
     unconfirmed card loses its colour and its time is struck. */
  .appointment {
    display: grid;
    gap: 1.25rem;
    max-width: 36rem;
    animation: reveal var(--d-3) var(--ease-out);
  }

  /* The fresh page has its own moment: the card arrives by itself. */
  .appointment.is-fresh {
    animation: none;
  }

  .appointment > .badge {
    justify-self: start;
  }

  .appointment-kicker {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-family: var(--font-display);
    font-size: var(--t-sm);
    font-weight: 700;
  }

  .appointment-kicker.is-ok {
    color: var(--ok);
  }

  .appointment-title {
    font-size: var(--t-h1);
    font-weight: 800;
    line-height: var(--lh-tight);
    text-wrap: balance;
  }

  .appointment.is-void .ticket {
    --ticket-line: var(--border-control);
  }

  .appointment.is-void .ticket-stub {
    background: var(--surface-sunken);
  }

  .appointment.is-void .ticket-day,
  .appointment.is-void .ticket-service {
    color: var(--text-muted);
  }

  .appointment.is-void .ticket-time {
    background: transparent;
    color: var(--text-muted);
    text-decoration: line-through;
  }

  .appointment-place,
  .appointment-contact {
    display: grid;
    gap: 0.75rem;
    justify-items: start;
  }

  .appointment-contact {
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
  }

  /* Reschedule and cancel, before the deadline. Cancelling asks inline,
     in the error colour, never with a browser dialog. */
  .appointment-actions {
    display: grid;
    gap: 0.75rem;
    justify-items: start;
  }

  .appointment-confirm {
    display: grid;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border: 1px solid color-mix(in oklab, var(--danger) 35%, var(--surface));
    border-radius: var(--radius-card);
    background: var(--danger-bg);
    animation: reveal var(--d-2) var(--ease-out);
  }

  /* The reschedule page: the strip under its heading, the new choice
     under the strip. */
  .booking > .appointment + .loadable {
    margin-top: 1.75rem;
  }


  .reschedule-choice {
    display: grid;
    gap: 1rem;
    margin-top: 1.5rem;
    scroll-margin-top: 1rem;
  }

  /* Still confirming: the line of the loading panels, drawn slowly. */
  .confirming {
    height: 2px;
    max-width: 30rem;
    border-radius: 1px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    background-size: 40% 100%;
    background-repeat: no-repeat;
    animation: progress-line 1.6s var(--ease-out) infinite;
  }

  /* Agenda list (dashboard) -------------------------------------------- */
  .agenda-head {
    display: grid;
    gap: 0.375rem;
    margin-bottom: 1.5rem;
  }

  .agenda-summary {
    color: var(--text-muted);
    font-size: var(--t-body);
  }

  .agenda-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    min-width: 0;
  }

  /* On a phone the tabs scroll sideways inside their row. */
  .agenda-bar .tabs {
    min-width: 0;
    max-width: 100%;
  }

  .agenda-fresh {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--text-muted);
    font-size: var(--t-xs);
  }

  .tabs {
    display: flex;
    gap: 0.25rem;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .tab {
    flex: none;
    padding: 0.5rem 0.875rem;
    border-radius: var(--radius-pill);
    color: var(--text-muted);
    font-size: var(--t-sm);
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: color var(--d-1) var(--ease-out), background-color var(--d-1) var(--ease-out);
  }

  .tab[aria-current="page"] {
    background: var(--accent-tint);
    color: var(--text-strong);
    font-weight: 700;
  }

  @media (hover: hover) {
    .tab:hover {
      color: var(--text);
      background: var(--accent-soft);
    }

    .tab[aria-current="page"]:hover {
      background: var(--accent-tint);
    }
  }

  .agenda {
    display: grid;
    gap: 1.75rem;
  }

  .agenda-day {
    display: grid;
    gap: 0.5rem;
  }

  .agenda-day-title {
    font-size: var(--t-ui);
    font-weight: 700;
    letter-spacing: -0.01em;
  }

  .agenda-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    column-gap: 0.875rem;
    row-gap: 0.5rem;
    align-items: start;
    padding: 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    background: var(--surface);
  }

  .agenda-time {
    min-width: 4rem;
    padding: 0.375rem 0.5rem;
    border-radius: var(--radius-control);
    background: var(--accent-soft);
    color: var(--text-strong);
    font-family: var(--font-display);
    font-size: var(--t-ui);
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    font-variant-numeric: tabular-nums;
  }

  .agenda-client {
    color: var(--text-strong);
    font-weight: 700;
  }

  .agenda-service {
    color: var(--text-muted);
    font-size: var(--t-sm);
  }

  .agenda-flags {
    grid-column: 2;
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
  }

  .agenda-note {
    grid-column: 2;
    color: var(--text-muted);
    font-size: var(--t-xs);
  }

  .agenda-phone {
    font-size: var(--t-xs);
  }

  /* When the next appointment is, counted by the page's own clock. */
  .agenda-when {
    color: var(--action);
    font-size: var(--t-xs);
    font-weight: 700;
  }

  .agenda-row.is-next {
    border-color: var(--accent-line);
    box-shadow: inset 3px 0 0 var(--accent);
  }

  .agenda-row.is-next .agenda-time {
    background: var(--accent-tint);
  }

  .agenda-row.is-over {
    background: transparent;
  }

  .agenda-row.is-over .agenda-time {
    background: var(--border);
    color: var(--text-muted);
  }

  .agenda-row.is-off .agenda-client,
  .agenda-row.is-off .agenda-time {
    color: var(--text-muted);
    text-decoration: line-through;
  }

  /* Where the day stands: a line across the list at the present hour. */
  .agenda-now {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--action);
    font-family: var(--font-display);
    font-size: var(--t-2xs);
    font-weight: 700;
  }

  .agenda-now::after {
    content: "";
    flex: 1;
    height: 2px;
    border-radius: 1px;
    background: var(--accent);
  }

  @media (min-width: 40rem) {
    .agenda-row {
      grid-template-columns: auto minmax(0, 1fr) auto;
    }

    .agenda-flags {
      grid-column: 3;
      grid-row: 1;
      justify-content: flex-end;
    }

    .agenda-note {
      grid-column: 2 / -1;
    }
  }

  .empty {
    padding: 2rem 0;
    font-size: var(--t-body);
    line-height: var(--lh-body);
    color: var(--text-muted);
    max-width: var(--measure);
  }

  /* Link box: a URL to share, with its copy button. -------------------- */
  .linkbox {
    display: grid;
    gap: 0.5rem;
  }

  .linkbox-url {
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    background: var(--surface-sunken);
    font-size: var(--t-sm);
    overflow-wrap: anywhere;
    user-select: all;
  }

  /* Copied: the button answers with the mark of a thing done. */
  .btn.is-copied {
    border-color: var(--ok-mark);
    background: var(--ok-bg);
    color: var(--ok);
  }

  .btn .copied-mark {
    display: none;
  }

  .btn.is-copied .copied-mark {
    display: inline-block;
  }

  .btn.is-copied .copy-mark {
    display: none;
  }

  .btn.is-copied .copied-mark .tick-1 {
    stroke: var(--ok-mark);
    stroke-dasharray: 1;
    animation: draw var(--d-3) var(--ease-out) both;
  }

  /* Working-hours editor (admin) --------------------------------------- */
  .hours {
    display: grid;
    gap: 0.5rem;
  }

  .hours-day {
    display: grid;
    grid-template-columns: 7rem minmax(0, 1fr);
    column-gap: 0.75rem;
    align-items: start;
    padding: 0.625rem 0;
    border-top: 1px solid var(--border);
  }

  .hours-day-name {
    padding-top: 0.5rem;
    font-weight: 700;
  }

  .hours-list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
  }

  .interval {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.125rem 0.125rem 0.75rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-pill);
    background: var(--surface);
    font-variant-numeric: tabular-nums;
  }

  .interval-remove {
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    line-height: 1;
  }

  .interval-remove .icon {
    width: 1rem;
    height: 1rem;
  }

  .interval-add {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.375rem;
  }

  .interval-add .input {
    width: 6.5rem;
  }

  /* On a phone the day's name sits above its intervals. */
  @media (max-width: 40rem) {
    .hours-day {
      grid-template-columns: minmax(0, 1fr);
      row-gap: 0.375rem;
    }

    .hours-day-name {
      padding-top: 0;
    }
  }

  .hours-none {
    color: var(--text-muted);
    padding-top: 0.5rem;
  }

  @media (hover: hover) {
    .interval-remove:hover {
      color: var(--danger);
      background: var(--danger-bg);
    }
  }

  /* A numbered explanation (onboarding). */
  .numbered {
    padding-left: 1.25rem;
    list-style: decimal;
  }

  .numbered li + li {
    margin-top: 0.5rem;
  }

  /* Icons drawn inline. */
  .icon {
    width: 1.25rem;
    height: 1.25rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  /* The reminder, as the patient gets it: the landing page's one moving
     thing. The button is pressed, the checks draw, attendance is confirmed.
     Decorative: the page says the same in words. */
  /* On `--action`, not the brand violet: white text this small needs the
     darker of the two. */
  .vignette {
    display: grid;
    gap: 0.875rem;
    padding: 1.5rem;
    border-radius: var(--radius-bubble);
    background: var(--action);
    color: var(--on-action);
  }

  .vignette-label {
    font-family: var(--font-display);
    font-size: var(--t-xs);
    font-weight: 700;
  }

  .vignette-message {
    display: grid;
    gap: 0.625rem;
    padding: 1rem;
    border-radius: var(--radius-card);
    background: var(--surface);
    color: var(--text);
    font-size: var(--t-sm);
    line-height: var(--lh-ui);
    animation: reveal var(--d-4) var(--ease-out) 200ms both;
  }

  .vignette-button {
    display: grid;
    place-items: center;
    min-height: 2.5rem;
    border-radius: var(--radius-control);
    background: var(--accent-tint);
    color: var(--text-strong);
    font-family: var(--font-display);
    font-size: var(--t-xs);
    font-weight: 700;
  }

  .vignette-button.is-primary {
    background: var(--ink);
    color: var(--on-ink);
    animation: press 360ms var(--ease-out) 1100ms both;
  }

  .vignette-result {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-display);
    font-size: var(--t-sm);
    font-weight: 700;
    animation: reveal var(--d-3) var(--ease-out) 1500ms both;
  }

  .vignette-result .ticks {
    font-size: 1.125rem;
  }

  .vignette-result .tick-1,
  .vignette-result .tick-2 {
    stroke-dasharray: 1;
  }

  .vignette-result .tick-1 {
    stroke: var(--on-accent);
    animation: draw var(--d-4) var(--ease-out) 1550ms both;
  }

  .vignette-result .tick-2 {
    stroke: var(--ok-on-accent);
    animation: draw var(--d-4) var(--ease-out) 1800ms both;
  }

  @keyframes press {
    0%,
    100% {
      transform: none;
    }
    40% {
      transform: scale(0.96);
    }
  }
}

/* ----------------------------------------------------------------- surface */
@layer surface {
  /* Public booking page: nameplate beside the flow on wide screens. ----- */
  .public {
    max-width: 68rem;
    margin: 0 auto;
    padding: 1.5rem var(--gutter) 3rem;
    display: grid;
    gap: 2rem;
  }

  /* Room for the bar that carries the choice. */
  .public.has-pick {
    padding-bottom: calc(6rem + env(safe-area-inset-bottom));
  }

  .public-side {
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    animation: reveal var(--d-3) var(--ease-out) both;
  }

  .public-main {
    min-width: 0;
  }

  .credit {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: var(--t-xs);
  }

  .credit a {
    color: inherit;
  }

  .credit-by {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
  }

  @media (min-width: 60rem) {
    .public {
      grid-template-columns: 20rem minmax(0, 1fr);
      column-gap: 4rem;
      row-gap: 3rem;
      padding-top: 3rem;
    }

    .public.has-pick {
      padding-bottom: 3rem;
    }

    .public-side {
      position: sticky;
      top: 2rem;
      align-self: start;
      padding-bottom: 0;
      border-bottom: 0;
    }

    .credit {
      grid-column: 1 / -1;
    }
  }

  /* Unavailable and simple public notices. */
  .notice {
    max-width: 36rem;
    padding: 1.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    background: var(--surface);
    font-size: var(--t-body);
    line-height: var(--lh-body);
  }

  .notice.notice-inline {
    padding: 0.875rem 1rem;
    border-color: color-mix(in oklab, var(--warn-mark) 35%, var(--surface));
    background: var(--warn-bg);
    font-size: var(--t-sm);
  }

  .notice-actions {
    margin-top: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: var(--t-ui);
  }

  /* Top bar shared by the dashboard and the admin. --------------------- */
  .topbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.625rem var(--gutter);
    border-bottom: 1px solid var(--border);
    background: var(--surface);
  }

  .wordmark {
    display: inline-flex;
    align-items: center;
    margin-right: auto;
    border-radius: var(--radius-control);
    text-decoration: none;
  }

  .topbar-user {
    color: var(--text-muted);
    font-size: var(--t-sm);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar form {
    display: contents;
  }

  /* Dashboard: agenda plus a side column. ------------------------------ */
  .page {
    max-width: 68rem;
    margin: 0 auto;
    padding: 2rem var(--gutter) 3rem;
  }

  .app {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 2rem;
  }

  .app-main {
    min-width: 0;
  }

  .app-side {
    display: grid;
    gap: 1rem;
    align-content: start;
  }

  .app-side .card + .card {
    margin-top: 0;
  }

  @media (min-width: 60rem) {
    .app {
      grid-template-columns: minmax(0, 1fr) 19rem;
      column-gap: 3rem;
    }

    .app-side {
      order: 2;
    }
  }

  /* Admin: a rail on wide screens, a top row of links otherwise. ------- */
  .admin {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1.5rem;
    max-width: 80rem;
    margin: 0 auto;
    padding: 1.5rem var(--gutter) 3rem;
  }

  .rail {
    display: flex;
    gap: 0.25rem;
    overflow-x: auto;
  }

  .rail a {
    flex: none;
    padding: 0.5rem 0.875rem;
    border-radius: var(--radius-control);
    color: var(--text-muted);
    font-weight: 600;
    text-decoration: none;
  }

  .rail a[aria-current="page"] {
    background: var(--accent-tint);
    color: var(--text-strong);
    font-weight: 700;
  }

  .admin-main {
    min-width: 0;
    max-width: 64rem;
  }

  @media (hover: hover) {
    .rail a:hover {
      color: var(--text);
      background: var(--accent-soft);
    }

    .rail a[aria-current="page"]:hover {
      background: var(--accent-tint);
    }
  }

  @media (min-width: 60rem) {
    .admin {
      grid-template-columns: 13rem minmax(0, 1fr);
      column-gap: 3rem;
    }

    .rail {
      flex-direction: column;
      align-self: start;
      position: sticky;
      top: 1.5rem;
      overflow: visible;
    }
  }

  .admin .section + .section {
    margin-top: 2.5rem;
  }

  /* Bare pages: login, onboarding, errors. ----------------------------- */
  .bare {
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 2rem var(--gutter);
  }

  .bare-card {
    width: 100%;
    max-width: 26rem;
    display: grid;
    gap: 1.25rem;
    padding: 1.75rem;
    animation: reveal var(--d-3) var(--ease-out) both;
  }

  .bare-card .wordmark {
    margin-right: 0;
    justify-self: start;
  }

  .bare-wide {
    max-width: 36rem;
  }

  .error-code {
    color: var(--accent-line);
    font-family: var(--font-display);
    font-weight: 800;
    font-size: var(--t-display);
    letter-spacing: -0.03em;
    line-height: 1;
  }

  /* Landing: what the product is, said once, beside the reminder it
     sends. ------------------------------------------------------------- */
  .landing {
    min-height: 100dvh;
    max-width: 68rem;
    margin: 0 auto;
    padding: 2rem var(--gutter) 3rem;
    display: grid;
    align-content: center;
    gap: 2.5rem;
  }

  .landing-copy {
    display: grid;
    gap: 1.25rem;
    justify-items: start;
  }

  .landing-title {
    font-size: clamp(2.25rem, 9vw, 3.75rem);
    letter-spacing: -0.035em;
    line-height: 1.02;
  }

  .landing-lead {
    color: var(--text-muted);
    font-size: 1.1875rem;
    line-height: var(--lh-body);
    max-width: 34rem;
  }

  .landing .vignette {
    width: 100%;
    max-width: 24rem;
  }

  .landing-foot {
    color: var(--text-muted);
    font-size: var(--t-xs);
  }

  .landing-foot a {
    color: inherit;
  }

  @media (min-width: 60rem) {
    .landing {
      grid-template-columns: minmax(0, 1fr) 24rem;
      align-items: center;
      column-gap: 5rem;
    }

    .landing-foot {
      grid-column: 1 / -1;
    }
  }
}
