/* styles.css */
/* Kapai UI. Two looks share this file.
   Hosted pages (paywall, checkout, restore, account) keep the neutral look of :root: green, yellow, and Overpass.
   They override --brand with the developer's color.
   Kapai's own pages (dashboard, sign-in, mailbox, errors) have the class "kapai" on <html>. They get the Racket Club
   identity: the tokens below map to the brand's palette, and racket-club.css has the rules. */

/* The brand's fonts, for Kapai's own pages only. Each family has "Kapai" in its name. An embedded hosted page
   can ask for a font by name (appearance.variables.fontFamily), and a plain name such as Manrope must not give
   a developer's page the brand's file. Hosted pages do not use these families, and a hosted page that opens
   on its own loads none of these files. */
@font-face { font-family: "Kapai Anton"; src: url("/assets/brand/anton.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Kapai Space Grotesk"; src: url("/assets/brand/space-regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Kapai Space Grotesk"; src: url("/assets/brand/space-bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Kapai Manrope"; src: url("/assets/brand/manrope-regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Kapai Manrope"; src: url("/assets/brand/manrope-semibold.ttf") format("truetype"); font-weight: 600 700; font-display: swap; }
@font-face { font-family: "Kapai Manrope"; src: url("/assets/brand/manrope-extrabold.ttf") format("truetype"); font-weight: 800; font-display: swap; }

:root {
  --paper: #f7f8f6;
  --surface: #ffffff;
  --ink: #18201c;
  --muted: #5b6661;
  --line: #dde2de;
  --line-strong: #c4ccc7;
  --green: #0b6e4f;
  --green-ink: #ffffff;
  --green-wash: #e5f1ec;
  --yellow: #f2c230;
  --yellow-ink: #3a2e00;
  --danger: #b42318;
  --danger-wash: #fdecea;
  --brand: var(--green);
  --brand-ink: var(--green-ink);
  --radius-control: 6px;
  --radius-panel: 10px;
  --font: "Overpass", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Overpass Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;

  /* Racket Club. The masters are in docs/brand/racket-club/assets/brand-tokens.css.
     --kapai-tracking-heading is the value of the visual reference for a section heading, the size of a page title here. */
  --kapai-acid: #e9ff45;
  --kapai-carbon: #151515;
  --kapai-newsprint: #f2eedc;
  --kapai-red-ink: #ff523b;
  --kapai-white: #ffffff;
  --kapai-font-display: "Kapai Anton", Impact, sans-serif;
  --kapai-font-label: "Kapai Space Grotesk", system-ui, sans-serif;
  --kapai-font-body: "Kapai Manrope", system-ui, sans-serif;
  --kapai-tracking-heading: -0.015em;
  --kapai-tracking-label: 0.06em;
  --kapai-duration-feedback: 150ms;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #121815;
    --surface: #18201c;
    --ink: #e8eeea;
    --muted: #9aa8a1;
    --line: #2a3530;
    --line-strong: #3a4842;
    --green: #3fb68b;
    --green-ink: #07130e;
    --green-wash: #173027;
    --yellow: #f2c230;
    --yellow-ink: #2a2100;
    --danger: #ff8a7a;
    --danger-wash: #3a1b18;
    color-scheme: dark;
  }
}

/* An embedded page can ask for the dark theme, whatever the device uses. Keep in step with the block above. */
:root[data-theme="dark"] {
  --paper: #121815;
  --surface: #18201c;
  --ink: #e8eeea;
  --muted: #9aa8a1;
  --line: #2a3530;
  --line-strong: #3a4842;
  --green: #3fb68b;
  --green-ink: #07130e;
  --green-wash: #173027;
  --yellow: #f2c230;
  --yellow-ink: #2a2100;
  --danger: #ff8a7a;
  --danger-wash: #3a1b18;
  color-scheme: dark;
}

/* Kapai's own pages. The shared rules keep their token names, and the names map to the brand's palette here.
   --green is the accent of links, current items, and chart bars. --yellow marks a warning.
   The muted and line colors are not in the palette. They come from the brand handbook, and each text pair
   has a contrast of 4.5:1 or more. */
:root.kapai {
  --paper: var(--kapai-newsprint);
  --surface: var(--kapai-white);
  --ink: var(--kapai-carbon);
  --muted: #5c5a50;
  --line: #d2cfc1;
  --line-strong: var(--kapai-carbon);
  --green: var(--kapai-carbon);
  --green-ink: var(--kapai-acid);
  --green-wash: var(--kapai-acid);
  --yellow: var(--kapai-red-ink);
  --yellow-ink: var(--kapai-carbon);
  /* Red ink is too light for text on a light surface, so text takes a darker red. */
  --danger: #b42318;
  --danger-wash: var(--kapai-white);
  --focus: var(--kapai-carbon);
  --radius-control: 4px;
  --radius-panel: 0;
  --font: var(--kapai-font-body);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root.kapai {
    --paper: var(--kapai-carbon);
    --surface: #1f1f1e;
    --ink: var(--kapai-newsprint);
    --muted: #b3af9f;
    --line: #3b3a36;
    --line-strong: #807d72;
    --green: var(--kapai-acid);
    --green-ink: var(--kapai-carbon);
    --green-wash: #2e3212;
    --danger: var(--kapai-red-ink);
    --danger-wash: #1f1f1e;
    --focus: var(--kapai-acid);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.5 var(--font);
  font-feature-settings: "tnum" 1;
}
a { color: var(--green); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; border-radius: 3px; }

h1, h2, h3 { line-height: 1.15; margin: 0 0 0.5em; letter-spacing: -0.01em; }
h1 { font-size: 1.875rem; font-weight: 800; }
h2 { font-size: 1.25rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }
p { margin: 0 0 1em; max-width: 68ch; }
code, kbd, .mono { font-family: var(--mono); font-size: 0.9em; }
small, .muted { color: var(--muted); }
.stack > * + * { margin-top: var(--stack, 1rem); }
.row { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.spread { display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Panels: a border, not a shadow. */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  padding: 1.25rem;
}
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }

/* Buttons */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 2.5rem; padding: 0.5rem 1rem;
  font: 700 0.9375rem/1 var(--font);
  border-radius: var(--radius-control);
  border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink);
  cursor: pointer; text-decoration: none;
}
.button:hover { border-color: var(--ink); }
.button.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.button.primary:hover { filter: brightness(1.08); }
.button.danger { color: var(--danger); }
.button.block { width: 100%; }
.button[disabled], .button[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }

/* Forms */
label { display: block; font-weight: 700; font-size: 0.9375rem; margin-bottom: 0.375rem; }
.hint { display: block; font-weight: 400; color: var(--muted); font-size: 0.875rem; margin-top: 0.25rem; }
input[type="text"], input[type="email"], input[type="url"], input[type="number"], select, textarea {
  width: 100%; min-height: 2.5rem; padding: 0.5rem 0.75rem;
  font: inherit; color: inherit; background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius-control);
}
textarea { min-height: 6rem; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--green); }
/* Keep the strong focus outline on fields too; a faint outline here would hide keyboard focus. */
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--yellow); outline-offset: 1px; }
.field + .field { margin-top: 1rem; }

/* Notices and badges */
.notice { border-radius: var(--radius-control); padding: 0.75rem 1rem; border: 1px solid var(--line); background: var(--surface); }
.notice.success { background: var(--green-wash); border-color: transparent; }
.notice.error { background: var(--danger-wash); border-color: transparent; color: var(--danger); }
.badge {
  display: inline-block; padding: 0.125rem 0.5rem; border-radius: 999px;
  font-size: 0.8125rem; font-weight: 700; background: var(--green-wash); color: var(--green);
}
.badge.test { background: var(--yellow); color: var(--yellow-ink); }
.badge.neutral { background: var(--paper); color: var(--muted); border: 1px solid var(--line); }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
th, td { text-align: left; padding: 0.625rem 0.75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 700; color: var(--muted); font-size: 0.8125rem; }
td.num, th.num { text-align: right; }
.table-wrap { overflow-x: auto; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 1rem; }
.stat .value { font-size: 1.75rem; font-weight: 800; line-height: 1.1; }
.stat .label { color: var(--muted); font-size: 0.875rem; }

/* Code */
pre {
  margin: 0; padding: 1rem; overflow-x: auto;
  background: var(--ink); color: var(--paper);
  border-radius: var(--radius-control); font: 0.875rem/1.6 var(--mono);
}

/* ---- Dashboard shell: the masthead on top, then the menu next to the page. The menu is in racket-club.css. ---- */
.shell { display: grid; grid-template-columns: 15rem 1fr; grid-template-rows: auto 1fr; min-height: 100vh; }
.shell > .masthead { grid-column: 1 / -1; }
.shell-main { padding: 2rem clamp(1rem, 4vw, 3rem); max-width: 72rem; width: 100%; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; }
}

/* ---- Fare card: how a price splits ------------------------------------ */
.fare {
  position: relative; max-width: 26rem;
  background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius-panel);
  padding: 1.25rem 1.5rem;
}
.fare::before, .fare::after {
  content: ""; position: absolute; top: 50%; width: 1.25rem; height: 1.25rem; margin-top: -0.625rem;
  background: var(--paper); border: 1px dashed var(--line-strong); border-radius: 50%;
}
.fare::before { left: -0.65rem; clip-path: inset(0 0 0 50%); }
.fare::after { right: -0.65rem; clip-path: inset(0 50% 0 0); }
.fare dl { display: grid; grid-template-columns: 1fr auto; gap: 0.4rem 1rem; margin: 0; }
.fare dt { color: var(--muted); }
.fare dd { margin: 0; text-align: right; font-weight: 700; }
.fare .total { border-top: 2px solid var(--ink); padding-top: 0.5rem; margin-top: 0.25rem; color: var(--ink); font-size: 1.125rem; }
.fare .earn { color: var(--green); }

/* ---- Hosted pages (paywall, checkout, restore) ------------------------- */
.hosted { max-width: 46rem; margin: 0 auto; padding: 2rem 1rem 3rem; }
.hosted-head { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1.5rem; }
.hosted-head img { width: 2.5rem; height: 2.5rem; border-radius: 8px; object-fit: cover; }
.hosted-head .app-name { font-size: 1.125rem; font-weight: 800; }
.hosted-foot { margin-top: 2rem; color: var(--muted); font-size: 0.8125rem; text-align: center; }
/* Inside an app's modal: less room around the page, and the app is already on screen. */
/* The modal's Close button sits over the top right corner, so the page starts below it. */
.hosted.embedded { padding: 3rem 1rem 1.5rem; }
.hosted.embedded .hosted-foot { margin-top: 1.25rem; }
.plans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; }
.plan { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-panel); padding: 1.25rem; display: flex; flex-direction: column; gap: 0.75rem; }
.plan.current { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.plan .price { font-size: 1.75rem; font-weight: 800; }
.plan .price small { font-size: 0.875rem; font-weight: 400; }
.plan ul { margin: 0; padding-left: 1.1rem; color: var(--muted); font-size: 0.9375rem; }
.plan .button { margin-top: auto; }
.segmented { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 999px; padding: 3px; background: var(--surface); }
.segmented button, .segmented a { border: 0; background: none; font: 700 0.875rem var(--font); padding: 0.4rem 0.9rem; border-radius: 999px; cursor: pointer; color: var(--ink); text-decoration: none; }
.segmented [aria-pressed="true"], .segmented [aria-current="true"] { background: var(--brand); color: var(--brand-ink); }
@media (max-width: 640px) { .plans { grid-template-columns: 1fr; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* account.css */
/* Account page (/p/:slug/account) and the paywall's email typo hint.
   The tokens come from styles.css. --brand is the developer's color on hosted pages.
   Everything fits a 375 px wide screen: rows wrap, and long emails break. */

.account { max-width: 34rem; margin: 0 auto; }
.account h1, .account h2, .account p { margin-bottom: 0; }
.account h1 { font-size: 1.5rem; }
.account-section.stack > * + * { margin-top: 0.75rem; }
.account-section h2 { font-size: 1.125rem; }

/* A form that holds one button and sits in a row with links. */
.inline-form { display: inline-flex; margin: 0; max-width: 100%; }

.account-plan { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 0.75rem; }
.account-plan strong { font-size: 1.5rem; font-weight: 800; line-height: 1.1; }
.status-line { font-weight: 700; }
.status-line.alert {
  padding: 0.625rem 0.875rem; border-radius: var(--radius-control);
  background: var(--danger-wash); color: var(--danger);
}

.account-email, .device-name, .choice-head strong { overflow-wrap: anywhere; min-width: 0; }
/* Messages on hosted pages can hold a long email. Break it instead of making the page scroll sideways. */
.hosted-message p, .account p { overflow-wrap: break-word; }

/* ---- Devices --------------------------------------------------------------- */
.device-list { list-style: none; margin: 0; padding: 0; }
.device {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 0.75rem;
  padding: 0.75rem 0; border-top: 1px solid var(--line);
}
.device:first-child { border-top: 0; padding-top: 0; }
.device:last-child { padding-bottom: 0; }
.device-info { display: flex; flex-direction: column; gap: 0.125rem; min-width: 0; flex: 1 1 12rem; }
.device-name { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.5rem; }

.account-foot { padding-top: 0.25rem; }

/* ---- Plan choices ---------------------------------------------------------- */
.choices { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; }
.choice {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.5rem;
  padding: 1rem 1.25rem; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-panel);
}
.choice.current { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.choice.current .badge { background: var(--brand); color: var(--brand-ink); }
.choice p { margin: 0; }
.choice-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.25rem 1rem; width: 100%; }
.choice-head span { font-weight: 700; }

/* ---- Paywall: "Did you mean …?" --------------------------------------------- */
.email-hint { max-width: 28rem; }
.email-hint p { margin: 0; overflow-wrap: anywhere; }
/* An email can be longer than the screen, so these buttons wrap their text. */
.email-hint .button { max-width: 100%; white-space: normal; overflow-wrap: anywhere; line-height: 1.25; text-align: center; }

/* billing.css */
/* Billing pages: paywall, checkout, return, restore, and the mock Stripe pages.
   The tokens come from styles.css. --brand is the developer's color on hosted pages. */

/* Keyboard focus must show on any brand color, so hosted pages use the ink color for it. */
.hosted :focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.hosted input:focus-visible { outline-offset: 1px; border-color: var(--ink); }

/* ---- Paywall ------------------------------------------------------------- */
/* Paragraphs keep only the .stack gap above them. */
.paywall h1, .paywall p, .hosted-message p { margin-bottom: 0; }
.segmented a { white-space: nowrap; }
.segmented .saving { font-weight: 400; font-size: 0.8125rem; margin-left: 0.25rem; }
.plan h2 { margin: 0; font-size: 1.125rem; }
.plan .price { margin: 0; line-height: 1.1; }
.plan ul { display: grid; gap: 0.375rem; }
.plan form, .plan .plan-status { margin-top: auto; }
.plan .plan-status { margin-bottom: 0; }
.plan.current .badge { background: var(--brand); color: var(--brand-ink); }
.paywall-restore { font-size: 0.9375rem; }
.paywall-email { max-width: 28rem; }
.paywall-email .notice { margin-top: 0.5rem; }

/* ---- Message pages: errors, done, and restore ------------------------------- */
.hosted-message { max-width: 30rem; margin: 0 auto; }
.hosted-message h1 { font-size: 1.5rem; }
.code-input {
  max-width: 12rem;
  font-family: var(--mono); font-size: 1.5rem; letter-spacing: 0.3em; text-align: center;
}

/* ---- Embedded Stripe Checkout ------------------------------------------- */
.checkout-frame {
  min-height: 32rem; padding: 1rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-panel);
}

/* ---- Mock Stripe pages ---------------------------------------------------- */
.mock-banner {
  max-width: none; margin: 0; padding: 0.625rem 0.875rem;
  background: var(--yellow); color: var(--yellow-ink);
  border-radius: var(--radius-control); font-size: 0.9375rem;
}
.summary {
  display: grid; grid-template-columns: 1fr auto; gap: 0.375rem 1rem;
  margin: 0; padding: 0.75rem 0;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.summary dt { color: var(--muted); }
.summary dd { margin: 0; text-align: right; font-weight: 700; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.field-row .field + .field { margin-top: 0; }
.hosted input[readonly] { background: var(--paper); color: var(--muted); }

/* ---- Narrow screens (360 px and up) ------------------------------------- */
@media (max-width: 420px) {
  .field-row { grid-template-columns: 1fr; }
  .checkout-frame { padding: 0.5rem; }
}

/* Plain links use the ink color: a brand color can be too light for text, and Kapai green would look foreign here. */
.hosted a:not(.button) { color: var(--ink); }

/* customers.css */
/* Dashboard: the Customers list, the Customer page, its confirmation steps, the Devices card, and the Platform page.
   Tokens are in styles.css. Every rule is scoped to .shell, so hosted pages do not change. */

/* ---- Badges ------------------------------------------------------------ */
.shell .badge.warn { background: var(--yellow); color: var(--yellow-ink); }
.shell .badge.alert { background: var(--ink); color: var(--surface); }
.shell .badge.shared { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 2px var(--yellow); }

/* ---- Search and pages -------------------------------------------------- */
.shell .customer-search { max-width: 32rem; }
.shell .customer-search .row { flex-wrap: nowrap; gap: 0.5rem; }
.shell .customer-search input { flex: 1; min-width: 0; }
.shell input[type="search"] {
  width: 100%; min-height: 2.5rem; padding: 0.5rem 0.75rem;
  font: inherit; color: inherit; background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius-control);
}
.shell input[type="search"]:focus { border-color: var(--green); }
.shell .pages { font-size: 0.9375rem; }

/* ---- Customer page ----------------------------------------------------- */
.shell .customer-back { margin: 0; }
.shell .customer-email { margin: 0; overflow-wrap: anywhere; }
.shell .facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.5rem 1.5rem; margin: 0; }
.shell .facts > div { display: contents; }
.shell .facts dt { color: var(--muted); font-size: 0.875rem; font-weight: 700; padding-top: 0.0625rem; }
.shell .facts dd { margin: 0; overflow-wrap: anywhere; }
/* Long device names wrap instead of widening the table. */
.shell .table-wrap td.wrap { white-space: normal; overflow-wrap: anywhere; min-width: 9rem; }

.shell .timeline { list-style: none; margin: 0; padding: 0 0 0 0.25rem; }
.shell .timeline li {
  position: relative; display: flex; flex-direction: column; gap: 0.125rem;
  padding: 0.5rem 0 0.5rem 1rem; border-left: 2px solid var(--line);
  overflow-wrap: anywhere;
}
.shell .timeline li::before {
  content: ""; position: absolute; left: -5px; top: 0.9rem;
  width: 8px; height: 8px; border-radius: 50%; background: var(--green);
}

/* Notices and section text can name a long email address. It must wrap on a 375 px screen. */
.shell .notice, .shell [data-section] p, .shell [data-section] small { overflow-wrap: anywhere; }

/* ---- Confirmation steps ------------------------------------------------ */
.shell .confirm .effect { margin: 0; font-size: 1.125rem; font-weight: 700; overflow-wrap: anywhere; }
/* A button can name a long email address, so its text wraps on a narrow screen. */
.shell .confirm .button { max-width: 100%; line-height: 1.25; text-align: center; overflow-wrap: anywhere; }
.shell .notice.warning { border: 1px solid var(--line); border-left: 4px solid var(--yellow); background: var(--paper); }
.shell .refund-form .field, .shell .email-form .field { max-width: 24rem; }

/* ---- Devices card ------------------------------------------------------ */
.shell .device-buckets td.bucket-bar { width: 60%; min-width: 6rem; }
.shell .device-buckets .meter { margin: 0.5rem 0 0; }

@media (max-width: 480px) {
  .shell .facts { grid-template-columns: 1fr; gap: 0.125rem; }
  .shell .facts > div + div > dt { margin-top: 0.5rem; }
}

/* dashboard.css */
/* Developer dashboard. Tokens and base classes are in styles.css. Keep it quiet: the fare card is the one loud element.
   All CSS files go into one bundle, so element rules here are scoped to .shell (dashboard) or .auth (sign-in). */

/* ---- Shell ------------------------------------------------------------- */
/* Without this, long code or wide tables stretch the grid column past the screen edge. */
.shell-main { min-width: 0; }

/* ---- Sign-in pages ----------------------------------------------------- */
.auth { max-width: 26rem; margin: 0 auto; padding: 3rem 1rem; }

/* ---- Forms ------------------------------------------------------------- */
.field-error { display: block; margin-top: 0.25rem; color: var(--danger); font-size: 0.875rem; font-weight: 700; }
:is(.shell, .auth) :is(input, select, textarea)[aria-invalid="true"] { border-color: var(--danger); }
.shell input[type="color"] {
  width: 4.5rem; height: 2.5rem; padding: 0.25rem;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-control);
  cursor: pointer;
}
.shell textarea { font-family: var(--mono); font-size: 0.875rem; }
.settings .field, .settings fieldset, form .field:has(select#country) { max-width: 40rem; }
.settings input[type="number"] { max-width: 10rem; }

fieldset.choices { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset.choices legend { padding: 0; margin-bottom: 0.5rem; font-weight: 700; font-size: 0.9375rem; }
.choice {
  display: flex; gap: 0.625rem; align-items: flex-start; margin: 0;
  padding: 0.75rem; border: 1px solid var(--line); border-radius: var(--radius-control);
  cursor: pointer;
}
.choice + .choice { margin-top: 0.5rem; }
.choice input { margin: 0.3rem 0 0; accent-color: var(--green); }
.choice:has(input:checked) { border-color: var(--green); background: var(--green-wash); }

/* ---- App tabs ---------------------------------------------------------- */
.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs a {
  padding: 0.5rem 0.75rem; margin-bottom: -1px; white-space: nowrap;
  color: var(--muted); font-weight: 700; text-decoration: none;
  border-bottom: 3px solid transparent;
}
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--green); border-bottom-color: var(--green); }

/* ---- Stat tiles -------------------------------------------------------- */
.stat.panel { padding: 1rem 1.125rem; }
.stat .label { margin-bottom: 0.25rem; }
.stat .detail { margin-top: 0.375rem; color: var(--muted); font-size: 0.8125rem; }
.meter { display: block; height: 0.375rem; margin-bottom: 0.375rem; overflow: hidden; background: var(--line); }
.meter > span { display: block; height: 100%; max-width: 100%; background: var(--green); }

/* ---- Tables in panels -------------------------------------------------- */
.panel.flush { padding: 0; }
.panel.flush th:first-child, .panel.flush td:first-child { padding-left: 1.25rem; }
.panel.flush th:last-child, .panel.flush td:last-child { padding-right: 1.25rem; }
.panel.flush tbody tr:last-child > * { border-bottom: 0; }
/* The positioned wrapper keeps .sr-only cells inside the scroll area, so they cannot widen the page. */
.table-wrap { position: relative; }
.table-wrap th, .table-wrap td { white-space: nowrap; }
.shell td form { margin: 0; }
/* The column with a row's button stays in view while a wide table scrolls sideways under it. Its header cell
   stays too, so no other column's label shows above the buttons. The line marks the edge that the rows pass under. */
.shell .table-wrap table:has(td:last-child .button) :is(th, td):last-child {
  position: sticky; right: 0; background: var(--surface); box-shadow: -1px 0 0 var(--line);
}
/* Two lines in one cell, such as a plan and its email. */
.shell td .stack > * { display: block; }
/* A long ID or email wraps when the table is short of room, so the other columns stay in view.
   The least width keeps a short value on one line. */
.shell td code { display: inline-block; min-width: 9rem; white-space: normal; overflow-wrap: anywhere; }
.shell td .stack small { min-width: 10rem; max-width: 13rem; white-space: normal; overflow-wrap: anywhere; }
.shell td .button { min-height: 2rem; padding: 0.375rem 0.75rem; font-size: 0.875rem; white-space: nowrap; }

/* ---- Usage chart ------------------------------------------------------- */
.chart { margin: 0; }
.chart svg { display: block; width: 100%; height: 10rem; }
.chart-axis { stroke: var(--line-strong); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-bar { fill: var(--green); }
.chart-error { fill: var(--danger); }
.chart figcaption { margin-top: 0.5rem; color: var(--muted); font-size: 0.8125rem; }
.key::before {
  content: ""; display: inline-block; width: 0.625rem; height: 0.625rem; margin-right: 0.375rem;
  border-radius: 2px; vertical-align: -1px;
}
.key-requests::before { background: var(--green); }
.key-errors::before { background: var(--danger); }
.shell summary { cursor: pointer; font-weight: 700; color: var(--green); }
.shell details[open] > summary { margin-bottom: 0.75rem; }

/* ---- Pricing: the markup field next to the fare cards ------------------- */
.pricing { display: grid; grid-template-columns: minmax(10rem, 14rem) 1fr; gap: 1.5rem; align-items: start; }
.fares { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 1rem; }
/* On a white panel the ticket takes the paper color, and its notches show the panel behind it. */
.panel .fare { background: var(--paper); }
.panel .fare::before, .panel .fare::after { background: var(--surface); }
.fare h3 { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; margin-bottom: 0.75rem; }
.fare h3 small { font-weight: 400; }
/* One unbroken rule above the total: no gap between the two columns. */
.fare dl { column-gap: 0; }
.fare dd { padding-left: 1rem; }

/* ---- Local mailbox ----------------------------------------------------- */
.mail-body { white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--mono); font-size: 0.875rem; }

/* ---- Notices and empty states ------------------------------------------ */
.notice small { display: block; margin-top: 0.25rem; }

/* ---- Request log (/dashboard/platform/requests) -------------------------- */
.request-log [hidden] { display: none !important; }
.request-log h1 { margin-bottom: 0; }
.request-log > .stack > * + *, .request-log.stack > * + * { margin-top: 0.75rem; }
.crumbs { margin: 0; font-size: 0.875rem; }
.request-log .tabs a { padding: 0.5rem 0.75rem; text-decoration: none; color: var(--ink); border-bottom: 3px solid transparent; }
.request-log .tabs a[aria-current="page"] { border-bottom-color: var(--ink); font-weight: 700; }
/* The period and the filters in one compact row. */
.filters { display: flex; flex-wrap: wrap; gap: 0.5rem 0.75rem; align-items: flex-end; }
.filters label { display: flex; flex-direction: column; gap: 0.125rem; margin: 0; font-size: 0.8125rem; flex: 1 1 9rem; min-width: 0; }
.filters label span { color: var(--muted); font-weight: 700; }
.filters select { min-height: 2.25rem; padding: 0.25rem 0.5rem; }
.filters .button { min-height: 2.25rem; }
.summary-line { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; margin: 0; padding: 0.625rem 0.875rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-control); }
.summary-line .hint { margin: 0; }
.totals, .facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 0.75rem 1.25rem; margin: 0; }
.totals dt, .facts dt { color: var(--muted); font-size: 0.8125rem; }
.totals dd, .facts dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
.totals dd { font-size: 1.25rem; }
.live-row { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; }
.live-row .check { display: flex; gap: 0.5rem; align-items: center; margin: 0; }
.live-row .hint { margin: 0; }
/* The button shows only when the top of the table is above the window, so it stays at the top of the window. */
.live-row .pending { min-height: 2rem; padding: 0.25rem 0.75rem; position: fixed; top: 1rem; left: 50%; transform: translateX(-50%); z-index: 10; box-shadow: 0 2px 8px rgb(0 0 0 / 0.25); }
/* Nine columns in a table that is as wide as its box: the table does not scroll sideways.
   The app, the developer, and the model give way with "…". A time or a number wraps: it is not cut. */
.requests-table { container-type: inline-size; }
.requests-table table { table-layout: fixed; font-size: 0.8125rem; }
.requests-table th, .requests-table td { padding: 0.4rem 0.5rem; overflow: hidden; text-overflow: ellipsis; }
.requests-table thead th, .requests-table td.when, .requests-table td.num { white-space: normal; }
.requests-table td.num { overflow-wrap: anywhere; }
.requests-table thead th { vertical-align: bottom; }
.requests-table .c-when { width: 9.5rem; }
.requests-table .c-status { width: 4.5rem; }
.requests-table .c-credits { width: 5.5rem; }
.requests-table .c-model { width: 6.5rem; }
.requests-table .c-in { width: 7.5rem; }
.requests-table .c-out { width: 7.5rem; }
.requests-table .c-ms { width: 4.25rem; }
.requests-table .app-name, .requests-table .developer { display: block; overflow: hidden; text-overflow: ellipsis; }
.requests-table .developer { color: var(--muted); font-size: 0.75rem; font-weight: 400; }
.requests-table .group-start { border-left: 1px solid var(--line); }
.requests-table th[scope="colgroup"] { text-align: center; }
.requests-table .part { display: inline-block; min-width: 4.25em; color: var(--muted); }
.requests-table .compact { display: none; }
.panel.flush.requests-table th:first-child, .panel.flush.requests-table td:first-child { padding-left: 0.875rem; }
td[data-status="error"] { color: var(--danger); font-weight: 700; }
td[data-status="cut"], td[data-status="stopped"] { font-weight: 700; }
.table-wrap .empty { padding: 1rem 1.25rem; margin: 0; color: var(--muted); }
/* A payload can be long: it scrolls in its own box until "Expand", and its lines wrap until "Do not wrap lines". */
pre.code { max-height: 22rem; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; border-bottom: 3px dashed var(--line-strong); }
pre.code.expanded { max-height: none; }
pre.code.nowrap { white-space: pre; overflow-wrap: normal; }
.payload-head { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.payload-head h3 { margin: 0 auto 0 0; }
.payload-head .button { min-height: 2rem; padding: 0.25rem 0.75rem; font-size: 0.875rem; }
.request-log details > summary { cursor: pointer; font-weight: 700; }
.request-log details[open] > summary { margin-bottom: 0.75rem; }

/* In a box that is too narrow for the nine columns, such as a phone or a small window next to the menu:
   one compact row for each request (time, status, app, credits, and one line with the tokens, the model, and the time). */
@container (max-width: 54rem) {
  .requests-table thead, .requests-table colgroup, .requests-table .developer { display: none; }
  .requests-table table, .requests-table tbody { display: block; }
  .requests-table tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.125rem 0.75rem; padding: 0.5rem 0.875rem; border-bottom: 1px solid var(--line); }
  .requests-table tr > td { display: block; padding: 0; border: 0; }
  .panel.flush.requests-table td:first-child { padding-left: 0; }
  .requests-table td.wide { display: none; }
  .requests-table td.compact { display: block; grid-column: 1 / -1; grid-row: 3; color: var(--muted); white-space: normal; }
  .requests-table td.when { grid-column: 1; grid-row: 1; }
  .requests-table td.app { grid-column: 1; grid-row: 2; }
  .requests-table td[data-status] { grid-column: 2; grid-row: 1; text-align: right; }
  .requests-table td.credits { grid-column: 2; grid-row: 2; }
  .requests-table td.credits::after { content: " credits"; color: var(--muted); font-weight: 400; }
}
@media (max-width: 640px) {
  .totals, .facts { grid-template-columns: 1fr 1fr; }
  .facts > div:has(dd:not(:empty)) { min-width: 0; }
}

@media (max-width: 760px) {
  .pricing { grid-template-columns: 1fr; }
}

/* hosted.css */
/* Hosted pages: one column and one set of components for the three displays.
   <html data-display="…"> selects the frame, the fonts, and the sizes:
   - "page": a page of its own. The app's name is above the column.
   - "embedded": a frame in the app's modal. The modal's close button is over the top of the frame.
   - "app": the app's own web view, in a sheet with a native header and footer (spec 2, 3d, and 6).
   This file comes after account.css and billing.css in the bundle, so its rules win at the same specificity. */

[data-display] {
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --column: 584px;
  --text-title: 1.5rem;
  --lh-title: 1.2;
  --text-body: 1rem;
  --lh-body: 1.5;
  --text-small: 0.875rem;
  --lh-small: 1.4;
  --text-section: 1.0625rem;
  --weight-title: 800;
  --weight-strong: 700;
  --control-height: 2.5rem;
  --radius-option: var(--radius-panel);
}

/* The app's sheet: the system font and the token sizes of spec 2, in points (CSS pixels in a web view). */
:root[data-display="app"] {
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --text-title: 20px;
  --lh-title: 25px;
  --text-body: 13px;
  --lh-body: 18px;
  --text-small: 12px;
  --lh-small: 17px;
  --text-section: 12px;
  --weight-title: 600;
  --weight-strong: 600;
  --control-height: 32px;
  --radius-control: 6px;
  --radius-panel: 12px;
  --radius-option: 8px;
  /* Opaque system-like surfaces. Each text pair has a contrast of 4.5:1 or more. */
  --paper: #f5f5f7;
  --surface: #ffffff;
  --ink: #1d1d1f;
  --muted: #5c5c61;
  --line: #d8d8dc;
  --line-strong: #b4b4ba;
  --danger: #c0261b;
  --danger-wash: #fdeceb;
  --green-wash: #e7f3ea;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root[data-display="app"]:not([data-theme="light"]) {
    --paper: #1e1e1e;
    --surface: #2b2b2d;
    --ink: #f2f2f4;
    --muted: #a9a9b0;
    --line: #3e3e42;
    --line-strong: #5d5d63;
    --danger: #ff8a7a;
    --danger-wash: #3a1d1a;
    --green-wash: #1d3325;
    color-scheme: dark;
  }
}

/* The session can ask for the dark theme, whatever the device uses. Keep in step with the block above. */
:root[data-display="app"][data-theme="dark"] {
  --paper: #1e1e1e;
  --surface: #2b2b2d;
  --ink: #f2f2f4;
  --muted: #a9a9b0;
  --line: #3e3e42;
  --line-strong: #5d5d63;
  --danger: #ff8a7a;
  --danger-wash: #3a1d1a;
  --green-wash: #1d3325;
  color-scheme: dark;
}

[data-display="app"] body { font-size: var(--text-body); line-height: var(--lh-body); }

/* ---- The column: the same left edge on every page, also for the app's name above it ---- */
.hosted {
  max-width: calc(var(--column) + 2 * var(--space-6));
  margin: 0 auto;
  padding: var(--space-8) var(--space-6);
  font-size: var(--text-body);
  line-height: var(--lh-body);
}
/* The modal's close button is 8 + 32 px over the top of the frame. */
.hosted.embedded { padding: 48px var(--space-6) var(--space-6); }
/* The sheet's native header is above the web view, so the page needs no more room at the top. */
[data-display="app"] .hosted { padding: var(--space-6); }
.hosted-head { margin-bottom: var(--space-6); display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
/* The way back to the app: at the end of the header, with a touch target of 44 px. */
.hosted-head .back-to-app { margin-inline-start: auto; min-height: 44px; display: inline-flex; align-items: center; }
.hosted .hosted-message, .hosted .account { max-width: none; margin: 0; }

.hosted h1 { font-size: var(--text-title); line-height: var(--lh-title); font-weight: var(--weight-title); margin: 0; }
.hosted h2 { font-size: var(--text-section); font-weight: var(--weight-strong); margin: 0; }
.hosted p { margin: 0; max-width: none; }
.hosted .muted, .hosted small, .hosted .hint { color: var(--muted); font-size: var(--text-small); line-height: var(--lh-small); }
.page.stack > * + * { margin-top: var(--space-5); }
.hosted .stack.lead > * + * { margin-top: var(--space-1); }
.hosted form.stack > * + * { margin-top: var(--space-4); }


/* One primary action for each step. Actions wrap on a narrow screen. */
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); }
.hosted .button { min-height: var(--control-height); padding: 0 var(--space-4); font-size: var(--text-body); line-height: 1.2; }
/* In the sheet, controls and values are regular. Semibold is only for headings, the plan's name, and the selected choice. */
[data-display="app"] .button { font-weight: 400; }
[data-display="app"] label, [data-display="app"] .field-error, [data-display="app"] .badge,
[data-display="app"] .option-name, [data-display="app"] .option-price, [data-display="app"] .current-plan p:first-child,
[data-display="app"] .summary dd, [data-display="app"] .choice-head span { font-weight: 400; }
[data-display="app"] .option:has(input:checked) .option-name,
[data-display="app"] .option:has(input:checked) .option-price { font-weight: 600; }

/* ---- Fields: the label above, the error next to the field ---- */
.hosted label { font-size: var(--text-body); font-weight: var(--weight-strong); margin-bottom: var(--space-1); }
.hosted input[type="text"], .hosted input[type="email"] { min-height: var(--control-height); font-size: var(--text-body); padding: 0 var(--space-3); }
.hosted .field .hint { margin-top: var(--space-1); }
.hosted input[aria-invalid="true"] { border-color: var(--danger); }
.field-error { margin-top: var(--space-1); color: var(--danger); font-size: var(--text-small); line-height: var(--lh-small); font-weight: var(--weight-strong); }
.hosted .code-input { max-width: 12rem; font-size: calc(var(--text-body) * 1.4); letter-spacing: 0.3em; text-align: center; }
.hosted .notice { padding: var(--space-3) var(--space-4); font-size: var(--text-body); line-height: var(--lh-body); }
.hosted .notice > p + p { margin-top: var(--space-2); }

/* ---- Plans: one offer with a row for each billing period ---- */
.options { display: grid; gap: var(--space-2); min-width: 0; margin: 0; padding: 0; border: 0; }
.hosted .option {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--space-3);
  min-height: 44px; margin: 0; padding: var(--space-3) var(--space-4);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-option);
  font-weight: 400; cursor: pointer;
}
/* The radio button marks the choice. The outline in the accent color adds to it. */
.option:has(input:checked) { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.option input { width: 16px; height: 16px; margin: 0; accent-color: var(--brand); }
.option-name { font-weight: var(--weight-strong); }
.option-price { font-weight: var(--weight-strong); font-variant-numeric: tabular-nums; text-align: right; }
.current-plan p:first-child { font-weight: var(--weight-strong); }
.current-plan p + p { margin-top: var(--space-1); }
.hosted .plan-credits > p { font-weight: var(--weight-strong); font-variant-numeric: tabular-nums; }
.hosted .features { display: grid; gap: 2px; margin: 0; padding-left: 1.1rem; color: var(--muted); font-size: var(--text-small); line-height: var(--lh-small); }
.hosted .terms { color: var(--muted); font-size: var(--text-small); line-height: var(--lh-small); }
.hosted .paywall-email { max-width: none; }

/* ---- Payment ---- */
.hosted .summary { padding: var(--space-3) 0; }
.hosted .checkout-frame { min-height: 30rem; }
[data-display="app"] .checkout-frame { padding: 0; border: 0; background: none; }
/* 16 px between the price summary (or the loading line) and Stripe's form. */
[data-display="app"] .page.stack > .checkout-frame { margin-top: var(--space-4); }

/* ---- Account: a compact settings page ---- */
.hosted .panel { padding: var(--space-4); border-radius: var(--radius-panel); }
.hosted .account-section.stack > * + * { margin-top: var(--space-3); }
.hosted .account-plan strong { font-size: calc(var(--text-section) + 5px); font-weight: var(--weight-strong); }
[data-display="app"] .account-plan strong { font-size: 17px; }
.hosted .status-line { font-weight: 400; }
/* A line that needs the user to act: the 16 px warning symbol, an 8 px gap, and text in the normal color. */
.hosted .status-line.alert { display: flex; align-items: flex-start; gap: var(--space-2); padding: 0; background: none; color: var(--ink); }
.hosted .status-line > div > p + p, .hosted .usage > p + p { margin-top: 2px; }
.warning-icon { flex: none; margin-top: 1px; color: #b25000; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .warning-icon { color: #ff9f0a; } }
:root[data-theme="dark"] .warning-icon { color: #ff9f0a; }
.settings { display: grid; margin: 0; }
.settings > div { display: grid; gap: 2px; padding: var(--space-3) 0; border-top: 1px solid var(--line); }
.settings > div:first-child { border-top: 0; padding-top: 0; }
.settings > div:last-child { padding-bottom: 0; }
.settings dt { color: var(--muted); font-size: var(--text-small); }
.settings dd { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-1) var(--space-3); margin: 0; }
.settings dd > span { overflow-wrap: anywhere; min-width: 0; }
.hosted .device-info small { display: block; }
.hosted .account-foot { padding-top: 0; }

/* "Remove…" opens its confirm step in place: one block under the device's name, as wide as the row. */
.confirm > summary { list-style: none; }
.confirm > summary::-webkit-details-marker { display: none; }
.confirm[open] { flex-basis: 100%; }
.confirm[open] > summary { display: none; }
.confirm-body { padding: var(--space-3) var(--space-4); border-radius: var(--radius-control); background: var(--danger-wash); }
.confirm-question { font-weight: var(--weight-strong); }
.confirm-body > p + p { margin-top: var(--space-1); }
.confirm-body > .actions { margin-top: var(--space-4); }

/* The credit meter: 30 ticks, gap 2px. Tick width (W - 58px) / 30, height 1.5 times the width in 8px to 16px,
   radius half the width. The pale tick is the dark tick at 22%. Dark mode lightens the accent by 30% with white,
   so the pale tick keeps 3:1 with the dark tick (packages/sdk/src/ui/ticks.test.ts computes it). */
.ticks { --tick: var(--brand); container-type: inline-size; display: grid; grid-template-columns: repeat(30, 1fr); gap: 2px; margin: var(--space-2) 0; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ticks { --tick: color-mix(in srgb, var(--brand) 70%, white); } }
:root[data-theme="dark"] .ticks { --tick: color-mix(in srgb, var(--brand) 70%, white); }
.ticks > i {
  display: block; height: 10px; border-radius: 3px;
  /* An older browser drops a rule that it cannot read, and keeps the rule before it. */
  height: clamp(8px, round((100cqw - 58px) / 20, 1px), 16px); border-radius: calc((100cqw - 58px) / 60);
  background: color-mix(in srgb, var(--tick) 22%, transparent); transition: background-color 120ms ease-out;
}
.ticks > i[data-on] { background: var(--tick); }
@media (prefers-reduced-motion: reduce) { .ticks > i { transition: none; } }

/* ---- Confirmation ---- */
.pending { display: flex; align-items: center; gap: var(--space-2); }
.spinner {
  flex: none; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--line-strong); border-top-color: var(--ink);
  animation: kapai-spin 0.8s linear infinite;
}
@keyframes kapai-spin { to { transform: rotate(360deg); } }

.hosted .hosted-foot { margin-top: var(--space-8); text-align: left; font-size: var(--text-small); }
.hosted.embedded .hosted-foot { margin-top: var(--space-6); }

@media (max-width: 420px) {
  .hosted { padding-left: var(--space-4); padding-right: var(--space-4); }
  /* The sheet keeps its 24 point padding (spec 6), also at 360 points wide. */
  [data-display="app"] .hosted { padding: var(--space-6); }
}

/* racket-club.css */
/* Racket Club: the identity of Kapai's own pages (dashboard, sign-in, local mailbox, and their error pages).
   The fonts and tokens are in styles.css. Each rule here starts with .kapai, the class on <html> of those pages,
   so the hosted pages inside a developer's app keep their look. This file is the last one in the bundle.

   The rules of the guide are in docs/brand/racket-club/references/visual.md. In short:
   - Anton is for page titles. Space Grotesk is for navigation and labels. Manrope is for reading and controls.
   - Acid is a background. It is never a text color on a light surface.
   - The masthead is the one loud element. Text and controls stay level and plain.
   - A current item has the Acid mark, in light and in dark mode. A second sign shows it without color. */

/* ---- Base -------------------------------------------------------------- */
.kapai ::selection { background: var(--kapai-carbon); color: var(--kapai-acid); }
/* Carbon on a light surface, Acid on a dark one. The gap keeps the outline apart from a control of the same color. */
.kapai :focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

.kapai h1 {
  font: 400 clamp(2.25rem, 6vw, 3rem)/1.05 var(--kapai-font-display);
  letter-spacing: var(--kapai-tracking-heading); text-transform: uppercase; overflow-wrap: anywhere;
}
/* A developer's app name keeps its own capitals. */
.kapai h1.app-title { text-transform: none; }
.kapai .panel h1 { font-size: 2.25rem; }
.kapai h2 { font: 700 1.25rem/1.2 var(--kapai-font-label); letter-spacing: -0.02em; }
.kapai h3 { font: 700 1rem/1.2 var(--kapai-font-label); letter-spacing: -0.01em; }

/* ---- Masthead ---------------------------------------------------------- */
.kapai .masthead {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  min-height: 4rem; padding: 0.75rem clamp(1rem, 4vw, 1.5rem);
  background: var(--kapai-acid); border-bottom: 2px solid var(--kapai-carbon);
}
/* 124 px wide: the lockup must not be narrower than 120 px. */
.kapai .masthead-logo { display: block; line-height: 0; }
.kapai .masthead-logo img { display: block; width: 7.75rem; height: auto; }
@media (prefers-color-scheme: dark) {
  .kapai .masthead { background: var(--kapai-carbon); border-bottom-color: var(--kapai-acid); }
}

/* ---- Menu: all the rules of the dashboard's menu are in this block -------
   Top level: Apps, with each app one level below it, and Payouts. Then the Admin group of an operator.
   Apart from the navigation: the local mailbox, then the account. On a phone, a button opens the menu. */
.kapai .shell-nav { padding: 1.25rem 1rem; background: var(--surface); border-right: 1px solid var(--line-strong); }
/* A long list of apps scrolls in the menu, so Payouts, Admin, and the account stay in reach. */
.kapai .menu { position: sticky; top: 1.25rem; max-height: calc(100vh - 2.5rem); overflow-y: auto; }
.kapai .menu > summary { display: none; }
/* :where keeps this reset weaker than the rules of the label and the mailbox below. */
.kapai .menu :where(ul, p) { list-style: none; margin: 0; padding: 0; }
.kapai .menu a {
  display: flex; align-items: center; min-height: 2.5rem; padding: 0.375rem 0.75rem;
  font: 400 0.9375rem/1.4 var(--kapai-font-label); color: var(--ink); text-decoration: none;
}
.kapai .menu a:hover { background: var(--paper); }
.kapai .menu a[aria-current="page"] {
  background: var(--kapai-acid); color: var(--kapai-carbon); font-weight: 700;
  box-shadow: inset 3px 0 0 var(--kapai-carbon);
}
/* The menu scrolls, so an outline outside a link gets cut. Acid focus on the Acid mark is not visible. */
.kapai .menu a:focus-visible { outline-offset: -3px; }
.kapai .menu a[aria-current="page"]:focus-visible { outline-color: var(--kapai-carbon); }
/* One level down: the apps hang from a rule below the Apps link. */
.kapai .menu-sub { margin: 0.125rem 0 0.25rem 0.75rem; border-left: 2px solid var(--line); }
.kapai .menu-sub a { min-height: 2.25rem; padding-left: 0.875rem; font-size: 0.875rem; }
/* A long list of apps scrolls on its own, so Payouts, Admin, and the account stay in view.
   A line at an edge of the list shows that more apps are beyond that edge.
   shortcut: 31.5rem and 23rem are the measured heights of the masthead and the rest of the menu, with and
   without the Admin group. Measure them again when the menu gets more items. */
.kapai .menu-sub {
  max-height: max(9rem, calc(100vh - 31.5rem)); overflow-y: auto;
  background:
    linear-gradient(var(--surface), var(--surface)) top / 100% 2px no-repeat local,
    linear-gradient(var(--surface), var(--surface)) bottom / 100% 2px no-repeat local,
    linear-gradient(var(--ink), var(--ink)) top / 100% 2px no-repeat scroll,
    linear-gradient(var(--ink), var(--ink)) bottom / 100% 2px no-repeat scroll;
}
.kapai .menu:not(:has(.menu-admin)) .menu-sub { max-height: max(9rem, calc(100vh - 23rem)); }
.kapai .menu-label {
  padding: 0 0.75rem 0.375rem; color: var(--muted);
  font: 700 0.75rem/1.4 var(--kapai-font-label); letter-spacing: var(--kapai-tracking-label); text-transform: uppercase;
}
.kapai .menu-admin { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
/* The group that holds the current page: its label is bold Ink, and so is the rule of its apps. */
.kapai .menu-group:has([aria-current="page"]) > :is(a, .menu-label) { font-weight: 700; color: var(--ink); }
.kapai .menu-group:has(.menu-sub [aria-current="page"]) > .menu-sub { border-left-color: var(--ink); }
/* The local mailbox is a tool of this server, not a part of the product. */
.kapai .menu-tool { margin-top: 1rem; padding-top: 0.5rem; border-top: 1px dashed var(--line-strong); }
.kapai .menu-tool a { min-height: 2.25rem; font-size: 0.8125rem; color: var(--muted); }
.kapai .shell-account {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.5rem;
  margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line);
}
.kapai .shell-account small { overflow-wrap: anywhere; }
@media (max-width: 760px) {
  .kapai .shell-nav { padding: 0 1rem; border-right: 0; border-bottom: 1px solid var(--line-strong); }
  .kapai .menu { position: static; max-height: none; overflow: visible; }
  .kapai .menu-sub, .kapai .menu:not(:has(.menu-admin)) .menu-sub { max-height: none; }
  .kapai .menu[open] { padding-bottom: 1rem; }
  .kapai .menu > summary {
    display: flex; align-items: center; gap: 0.75rem; min-height: 2.75rem; cursor: pointer; list-style: none;
    font: 700 0.9375rem/1.4 var(--kapai-font-label);
  }
  .kapai .menu > summary::-webkit-details-marker { display: none; }
  .kapai .menu > summary::after {
    content: ""; flex: none; margin-left: auto; width: 0.5rem; height: 0.5rem;
    border-right: 2px solid; border-bottom: 2px solid; transform: translateY(-2px) rotate(45deg);
  }
  .kapai .menu[open] > summary::after { transform: translateY(2px) rotate(-135deg); }
  .kapai .menu-here { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 400; color: var(--muted); }
  /* Touch targets of at least 44 px. */
  .kapai .menu a { min-height: 2.75rem; }
  .kapai .shell-account { flex-direction: row; align-items: center; justify-content: space-between; }
}

.kapai .tabs { gap: 0; border-bottom: 2px solid var(--ink); }
.kapai .tabs a {
  display: flex; align-items: center; min-height: 2.75rem; padding: 0.5rem 0.875rem; margin-bottom: 0;
  font: 700 0.9375rem/1.4 var(--kapai-font-label); border-bottom: 0;
}
.kapai .tabs a[aria-current="page"] { background: var(--kapai-acid); color: var(--kapai-carbon); box-shadow: inset 0 3px 0 var(--kapai-carbon); }

/* ---- Panels ------------------------------------------------------------ */
.kapai .panel { border-color: var(--line-strong); }
/* The poster panel: a hard shadow, for the sign-in pages and the empty states. */
.kapai :is(.auth .panel, .empty-state) { border: 2px solid var(--green); box-shadow: 6px 6px 0 var(--green); }
.kapai .auth .panel { padding: 1.75rem 1.5rem; }
.kapai .empty-state { max-width: 44rem; margin-right: 6px; }
.kapai .empty-state h2 {
  font: 400 2rem/1.05 var(--kapai-font-display); letter-spacing: var(--kapai-tracking-heading); text-transform: uppercase;
}

/* ---- Buttons ----------------------------------------------------------- */
.kapai .button {
  min-height: 2.75rem; padding: 0.5rem 1.125rem;
  font: 600 0.9375rem/1.2 var(--font);
  border: 2px solid var(--ink);
  transition: background-color var(--kapai-duration-feedback), color var(--kapai-duration-feedback), border-color var(--kapai-duration-feedback);
}
.kapai .button:hover { background: var(--ink); color: var(--surface); }
.kapai .button.primary { border-color: var(--brand); }
.kapai .button.primary:hover { filter: none; background: var(--brand-ink); color: var(--brand); }
.kapai .button.danger { border-color: var(--danger); }
.kapai .button.danger:hover { background: var(--danger); color: var(--surface); }

/* ---- Forms ------------------------------------------------------------- */
.kapai label, .kapai fieldset.choices legend { font-weight: 600; }
.kapai :is(input[type="text"], input[type="email"], input[type="url"], input[type="number"], input[type="search"], select) { min-height: 2.75rem; }
/* The hosted account page has a .choice class too, with a column layout. Here the radio button stays next to its label. */
.kapai .choice { flex-direction: row; border-color: var(--line-strong); }
.kapai .choice:has(input:checked) { background: transparent; border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }

/* ---- Notices and badges ------------------------------------------------ */
.kapai .notice { border-color: var(--line-strong); border-radius: 0; }
.kapai .notice.success { background: var(--kapai-acid); color: var(--kapai-carbon); border-color: var(--kapai-carbon); }
/* Red ink is for an interruption. Carbon text on it has a contrast of 5.6:1. */
.kapai .notice.error { background: var(--kapai-red-ink); color: var(--kapai-carbon); border-color: var(--kapai-carbon); font-weight: 600; }
.kapai .notice:is(.success, .error) :is(small, a) { color: inherit; }
.kapai .badge {
  padding: 0.1875rem 0.5rem; border-radius: 2px; white-space: nowrap;
  font: 700 0.75rem/1.4 var(--kapai-font-label); letter-spacing: var(--kapai-tracking-label); text-transform: uppercase;
  background: var(--kapai-acid); color: var(--kapai-carbon);
}
.kapai .badge.neutral { background: transparent; color: var(--muted); border-color: currentColor; }
.kapai .badge.test { background: var(--brand); color: var(--brand-ink); }

/* ---- Tables and numbers ------------------------------------------------- */
.kapai thead th {
  font: 700 0.75rem/1.4 var(--kapai-font-label); letter-spacing: var(--kapai-tracking-label); text-transform: uppercase;
  border-bottom-color: var(--line-strong);
}
.kapai tbody th { color: var(--ink); font-size: inherit; font-weight: 600; }
@media (max-width: 480px) {
  .kapai :is(th, td) { padding-left: 0.5rem; padding-right: 0.5rem; }
}
.kapai .stat .label { font: 700 0.75rem/1.4 var(--kapai-font-label); letter-spacing: var(--kapai-tracking-label); text-transform: uppercase; }
.kapai .stat .value { letter-spacing: -0.01em; }

/* ---- Code -------------------------------------------------------------- */
.kapai pre { background: var(--kapai-carbon); color: var(--kapai-newsprint); border: 1px solid var(--line-strong); border-radius: 0; }

/* ---- Fare card: the line that the developer earns has the Acid mark ------ */
.kapai .fare .earn { background: var(--kapai-acid); color: var(--kapai-carbon); padding: 0.25rem 0.5rem; }
.kapai .fare dt.earn { margin-left: -0.5rem; }
.kapai .fare dd.earn { margin-right: -0.5rem; }
