/* ==================================================================
   PetrOS UI: the one look every PetrOS app shares, iOS.

   The source is ~/petros/ui/petros.css. Each app serves a copy at
   /petros.css (Foundry imports src/petros.css), written by
   `~/petros/bin/ui-sync`. Edit the source and run ui-sync, never a
   copy: `ui-sync --check` runs before every deploy and refuses a stale
   one. ui/README.md is the guide, and ui/gallery.html shows every part.

   Each part's selectors weigh about one class (modifiers sit in
   :where()), so an app's own one-class rule, loaded after this file,
   wins.
   ================================================================== */

/* ---------- Tokens: light ---------- */

:root {
  color-scheme: light;

  /* System colors */
  --red: #FF3B30;
  --orange: #FF9500;
  --yellow: #FFCC00;
  --green: #34C759;
  --mint: #00C7BE;
  --teal: #30B0C7;
  --cyan: #32ADE6;
  --blue: #007AFF;
  --indigo: #5856D6;
  --purple: #AF52DE;
  --pink: #FF2D55;
  --brown: #A2845E;
  --gray: #8E8E93;
  --gray-2: #AEAEB2;
  --gray-3: #C7C7CC;
  --gray-4: #D1D1D6;
  --gray-5: #E5E5EA;
  --gray-6: #F2F2F7;

  /* Text */
  --label: #000000;
  --label-2: rgba(60, 60, 67, 0.6);
  --label-3: rgba(60, 60, 67, 0.3);
  --label-4: rgba(60, 60, 67, 0.18);

  /* Fills for controls on any background */
  --fill: rgba(120, 120, 128, 0.2);
  --fill-2: rgba(120, 120, 128, 0.16);
  --fill-3: rgba(118, 118, 128, 0.12);
  --fill-4: rgba(116, 116, 128, 0.08);

  /* Backgrounds: plain screens, and grouped ones (lists in sections) */
  --background: #FFFFFF;
  --background-2: #F2F2F7;
  --background-3: #FFFFFF;
  --grouped: #F2F2F7;
  --grouped-2: #FFFFFF;
  --grouped-3: #F2F2F7;
  /* What sheets, alerts and menus use, a step up in dark */
  --elevated-background: #FFFFFF;
  --elevated-background-2: #F2F2F7;
  --elevated-grouped: #F2F2F7;
  --elevated-grouped-2: #FFFFFF;

  --separator: rgba(60, 60, 67, 0.29);
  --separator-opaque: #C6C6C8;
  --highlight: #D1D1D6;              /* a row while it's pressed */
  --hover: rgba(0, 0, 0, 0.04);      /* a pointer over a control */
  --thumb: #FFFFFF;                  /* the chosen segment */
  --switch-off: rgba(120, 120, 128, 0.16);
  --scrim: rgba(0, 0, 0, 0.25);

  /* Materials: glass for bars, buttons and floating things */
  --glass: rgba(255, 255, 255, 0.7);
  --glass-thick: rgba(250, 250, 252, 0.88);
  --glass-blur: blur(16px) saturate(180%);
  --glass-shadow: inset 0 0.5px 0 rgba(255, 255, 255, 0.9), 0 0 0 0.5px rgba(0, 0, 0, 0.06), 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-float: 0 0 0 0.5px rgba(0, 0, 0, 0.05), 0 10px 36px rgba(0, 0, 0, 0.14), 0 2px 6px rgba(0, 0, 0, 0.05);

  /* Each app's tint, and the text that goes on it. Light text tints
     under 4:1 on white use Apple's high-contrast variant. */
  --app-home: #007AFF;              --app-home-on: #FFFFFF;
  --app-momo: #5856D6;              --app-momo-on: #FFFFFF;
  --app-personalization: #008299;   --app-personalization-on: #FFFFFF;
  --app-foundry: #B25000;           --app-foundry-on: #FFFFFF;
  --app-finances: #248A3D;          --app-finances-on: #FFFFFF;
  --app-display: #D70015;           --app-display-on: #FFFFFF;
  --app-schedule: #AF52DE;          --app-schedule-on: #FFFFFF;
  --app-detector: #D30F45;           --app-detector-on: #FFFFFF;
  --app-arduino: #0C817B;            --app-arduino-on: #FFFFFF;
  --app-library: #7F6545;            --app-library-on: #FFFFFF;
  --app-suma-ethica: #A05A00;        --app-suma-ethica-on: #FFFFFF;
  --app-goals: #0071A4;              --app-goals-on: #FFFFFF;
  --app-school: #4A7B00;             --app-school-on: #FFFFFF;
  --app-career: #B5179E;             --app-career-on: #FFFFFF;
  --app-resume: #4F6182;             --app-resume-on: #FFFFFF;
}

/* ---------- Tokens: dark (the two blocks match; ui-sync checks) ---------- */

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --red: #FF453A;
    --orange: #FF9F0A;
    --yellow: #FFD60A;
    --green: #30D158;
    --mint: #66D4CF;
    --teal: #40C8E0;
    --cyan: #64D2FF;
    --blue: #0A84FF;
    --indigo: #5E5CE6;
    --purple: #BF5AF2;
    --pink: #FF375F;
    --brown: #AC8E68;
    --gray: #8E8E93;
    --gray-2: #636366;
    --gray-3: #48484A;
    --gray-4: #3A3A3C;
    --gray-5: #2C2C2E;
    --gray-6: #1C1C1E;
    --label: #FFFFFF;
    --label-2: rgba(235, 235, 245, 0.6);
    --label-3: rgba(235, 235, 245, 0.3);
    --label-4: rgba(235, 235, 245, 0.16);
    --fill: rgba(120, 120, 128, 0.36);
    --fill-2: rgba(120, 120, 128, 0.32);
    --fill-3: rgba(118, 118, 128, 0.24);
    --fill-4: rgba(118, 118, 128, 0.18);
    --background: #000000;
    --background-2: #1C1C1E;
    --background-3: #2C2C2E;
    --grouped: #000000;
    --grouped-2: #1C1C1E;
    --grouped-3: #2C2C2E;
    --elevated-background: #1C1C1E;
    --elevated-background-2: #2C2C2E;
    --elevated-grouped: #1C1C1E;
    --elevated-grouped-2: #2C2C2E;
    --separator: rgba(84, 84, 88, 0.65);
    --separator-opaque: #38383A;
    --highlight: #3A3A3C;
    --hover: rgba(255, 255, 255, 0.06);
    --thumb: #636366;
    --switch-off: rgba(120, 120, 128, 0.32);
    --scrim: rgba(0, 0, 0, 0.5);
    --glass: rgba(44, 44, 46, 0.62);
    --glass-thick: rgba(36, 36, 38, 0.88);
    --glass-blur: blur(16px) saturate(180%);
    --glass-shadow: inset 0 0.5px 0 rgba(255, 255, 255, 0.14), 0 0 0 0.5px rgba(255, 255, 255, 0.06), 0 4px 16px rgba(0, 0, 0, 0.3);
    --shadow-float: 0 0 0 0.5px rgba(255, 255, 255, 0.08), 0 10px 36px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.3);
    --app-home: #0A84FF;              --app-home-on: #FFFFFF;
    --app-momo: #5E5CE6;              --app-momo-on: #FFFFFF;
    --app-personalization: #40C8E0;   --app-personalization-on: #000000;
    --app-foundry: #FF9F0A;           --app-foundry-on: #000000;
    --app-finances: #30D158;          --app-finances-on: #000000;
    --app-display: #FF453A;           --app-display-on: #FFFFFF;
    --app-schedule: #BF5AF2;          --app-schedule-on: #FFFFFF;
    --app-detector: #FF375F;           --app-detector-on: #FFFFFF;
    --app-arduino: #63E6E2;            --app-arduino-on: #000000;
    --app-library: #B59469;            --app-library-on: #000000;
    --app-suma-ethica: #FFD60A;        --app-suma-ethica-on: #000000;
    --app-goals: #64D2FF;              --app-goals-on: #000000;
    --app-school: #A8E04A;             --app-school-on: #000000;
    --app-career: #F062D3;             --app-career-on: #000000;
    --app-resume: #9DB3D9;             --app-resume-on: #000000;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --red: #FF453A;
  --orange: #FF9F0A;
  --yellow: #FFD60A;
  --green: #30D158;
  --mint: #66D4CF;
  --teal: #40C8E0;
  --cyan: #64D2FF;
  --blue: #0A84FF;
  --indigo: #5E5CE6;
  --purple: #BF5AF2;
  --pink: #FF375F;
  --brown: #AC8E68;
  --gray: #8E8E93;
  --gray-2: #636366;
  --gray-3: #48484A;
  --gray-4: #3A3A3C;
  --gray-5: #2C2C2E;
  --gray-6: #1C1C1E;
  --label: #FFFFFF;
  --label-2: rgba(235, 235, 245, 0.6);
  --label-3: rgba(235, 235, 245, 0.3);
  --label-4: rgba(235, 235, 245, 0.16);
  --fill: rgba(120, 120, 128, 0.36);
  --fill-2: rgba(120, 120, 128, 0.32);
  --fill-3: rgba(118, 118, 128, 0.24);
  --fill-4: rgba(118, 118, 128, 0.18);
  --background: #000000;
  --background-2: #1C1C1E;
  --background-3: #2C2C2E;
  --grouped: #000000;
  --grouped-2: #1C1C1E;
  --grouped-3: #2C2C2E;
  --elevated-background: #1C1C1E;
  --elevated-background-2: #2C2C2E;
  --elevated-grouped: #1C1C1E;
  --elevated-grouped-2: #2C2C2E;
  --separator: rgba(84, 84, 88, 0.65);
  --separator-opaque: #38383A;
  --highlight: #3A3A3C;
  --hover: rgba(255, 255, 255, 0.06);
  --thumb: #636366;
  --switch-off: rgba(120, 120, 128, 0.32);
  --scrim: rgba(0, 0, 0, 0.5);
  --glass: rgba(44, 44, 46, 0.62);
  --glass-thick: rgba(36, 36, 38, 0.88);
  --glass-blur: blur(16px) saturate(180%);
  --glass-shadow: inset 0 0.5px 0 rgba(255, 255, 255, 0.14), 0 0 0 0.5px rgba(255, 255, 255, 0.06), 0 4px 16px rgba(0, 0, 0, 0.3);
  --shadow-float: 0 0 0 0.5px rgba(255, 255, 255, 0.08), 0 10px 36px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.3);
  --app-home: #0A84FF;              --app-home-on: #FFFFFF;
  --app-momo: #5E5CE6;              --app-momo-on: #FFFFFF;
  --app-personalization: #40C8E0;   --app-personalization-on: #000000;
  --app-foundry: #FF9F0A;           --app-foundry-on: #000000;
  --app-finances: #30D158;          --app-finances-on: #000000;
  --app-display: #FF453A;           --app-display-on: #FFFFFF;
  --app-schedule: #BF5AF2;          --app-schedule-on: #FFFFFF;
  --app-detector: #FF375F;           --app-detector-on: #FFFFFF;
  --app-arduino: #63E6E2;            --app-arduino-on: #000000;
  --app-library: #B59469;            --app-library-on: #000000;
  --app-suma-ethica: #FFD60A;        --app-suma-ethica-on: #000000;
  --app-goals: #64D2FF;              --app-goals-on: #000000;
  --app-school: #A8E04A;             --app-school-on: #000000;
  --app-career: #F062D3;             --app-career-on: #000000;
  --app-resume: #9DB3D9;             --app-resume-on: #000000;
}

/* ---------- Tokens: the same in both themes ---------- */

:root {
  /* An app names itself on <html data-app="…">, which picks its tint. */
  --tint: var(--app-home);
  --on-tint: var(--app-home-on);

  /* The page behind everything, and behind the bars' fade. Plain
     screens set it to var(--background). */
  --page: var(--grouped);

  /* SF Pro on Apple devices, the system face elsewhere. */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro", system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-rounded: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  /* iOS text styles at the default (Large) size, with SF's tracking. */
  --t-large-title: 700 34px/41px var(--font);   --ls-large-title: 0.0118em;
  --t-title-1: 700 28px/34px var(--font);       --ls-title-1: 0.0136em;
  --t-title-2: 700 22px/28px var(--font);       --ls-title-2: -0.0118em;
  --t-title-3: 600 20px/25px var(--font);       --ls-title-3: -0.0225em;
  --t-headline: 600 17px/22px var(--font);      --ls-headline: -0.0253em;
  --t-body: 400 17px/22px var(--font);          --ls-body: -0.0253em;
  --t-callout: 400 16px/21px var(--font);       --ls-callout: -0.0194em;
  --t-subheadline: 400 15px/20px var(--font);   --ls-subheadline: -0.0153em;
  --t-footnote: 400 13px/18px var(--font);      --ls-footnote: -0.0062em;
  --t-caption: 400 12px/16px var(--font);       --ls-caption: 0em;
  --t-caption-2: 400 11px/13px var(--font);     --ls-caption-2: 0.0055em;

  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 26px;     /* list sections, cards, widgets */
  --radius-xl: 34px;     /* sheets, alerts */

  --margin: 16px;        /* the screen's side margin */
  --bar-button: 44px;
  --control: 36px;
  --row: 44px;
  --tabbar-space: calc(96px + env(safe-area-inset-bottom));  /* room under content above a tab bar */

  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);

  /* Glyphs, drawn with mask-image so they take currentColor. */
  --glyph-chevron-right: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 9 15'><path d='M1.75 1.75 7.25 7.5l-5.5 5.75' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  --glyph-chevron-left: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 9 15'><path d='M7.25 1.75 1.75 7.5l5.5 5.75' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  --glyph-chevron-down: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 15 9'><path d='m1.75 1.75 5.75 5.5 5.75-5.5' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  --glyph-chevrons: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 16'><path d='M1.75 5.5 5 2.25 8.25 5.5M1.75 10.5 5 13.75l3.25-3.25' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  --glyph-check: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path d='m2.75 8.5 3.5 3.5 7-7.75' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  --glyph-xmark: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path d='m3.5 3.5 9 9m0-9-9 9' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'/></svg>");
  --glyph-plus: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path d='M8 2.5v11M2.5 8h11' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'/></svg>");
  --glyph-search: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><circle cx='6.8' cy='6.8' r='4.8' fill='none' stroke='black' stroke-width='1.8'/><path d='m10.4 10.4 3.6 3.6' stroke='black' stroke-width='1.8' stroke-linecap='round'/></svg>");
  --glyph-minus: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path d='M2.5 8h11' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'/></svg>");
  --glyph-info: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><circle cx='8' cy='8' r='6.6' fill='none' stroke='black' stroke-width='1.4'/><circle cx='8' cy='5' r='1'/><path d='M8 7.4v4' stroke='black' stroke-width='1.6' stroke-linecap='round'/></svg>");
  --glyph-warning: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path d='M7.1 2.3a1 1 0 0 1 1.8 0l5.6 10a1 1 0 0 1-.9 1.5H2.4a1 1 0 0 1-.9-1.5Z' fill='none' stroke='black' stroke-width='1.4' stroke-linejoin='round'/><path d='M8 6v3.4' stroke='black' stroke-width='1.6' stroke-linecap='round'/><circle cx='8' cy='11.6' r='.95'/></svg>");
  --glyph-ellipsis: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><circle cx='3' cy='8' r='1.5'/><circle cx='8' cy='8' r='1.5'/><circle cx='13' cy='8' r='1.5'/></svg>");
  --glyph-spinner: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><g><rect x='10.8' y='1' width='2.4' height='6.5' rx='1.2'/><rect x='10.8' y='1' width='2.4' height='6.5' rx='1.2' transform='rotate(-45 12 12)' opacity='.86'/><rect x='10.8' y='1' width='2.4' height='6.5' rx='1.2' transform='rotate(-90 12 12)' opacity='.74'/><rect x='10.8' y='1' width='2.4' height='6.5' rx='1.2' transform='rotate(-135 12 12)' opacity='.62'/><rect x='10.8' y='1' width='2.4' height='6.5' rx='1.2' transform='rotate(-180 12 12)' opacity='.5'/><rect x='10.8' y='1' width='2.4' height='6.5' rx='1.2' transform='rotate(-225 12 12)' opacity='.38'/><rect x='10.8' y='1' width='2.4' height='6.5' rx='1.2' transform='rotate(-270 12 12)' opacity='.28'/><rect x='10.8' y='1' width='2.4' height='6.5' rx='1.2' transform='rotate(-315 12 12)' opacity='.2'/></g></svg>");
  /* The same marks as pictures, for places a mask can't go (fields). */
  --img-chevrons: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 16'><path d='M1.75 5.5 5 2.25 8.25 5.5M1.75 10.5 5 13.75l3.25-3.25' fill='none' stroke='%238E8E93' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  --img-search: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><circle cx='6.8' cy='6.8' r='4.8' fill='none' stroke='%238E8E93' stroke-width='1.8'/><path d='m10.4 10.4 3.6 3.6' stroke='%238E8E93' stroke-width='1.8' stroke-linecap='round'/></svg>");
  --img-xmark-white: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path d='m5 5 6 6m0-6-6 6' fill='none' stroke='white' stroke-width='1.8' stroke-linecap='round'/></svg>");
  --img-check-white: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path d='m3.5 8.5 3 3 6-6.75' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/></svg>");
}

:root[data-app="home"] { --tint: var(--app-home); --on-tint: var(--app-home-on); }
:root[data-app="momo"] { --tint: var(--app-momo); --on-tint: var(--app-momo-on); }
:root[data-app="personalization"] { --tint: var(--app-personalization); --on-tint: var(--app-personalization-on); }
:root[data-app="foundry"] { --tint: var(--app-foundry); --on-tint: var(--app-foundry-on); }
:root[data-app="finances"] { --tint: var(--app-finances); --on-tint: var(--app-finances-on); }
:root[data-app="display"] { --tint: var(--app-display); --on-tint: var(--app-display-on); }
:root[data-app="schedule"] { --tint: var(--app-schedule); --on-tint: var(--app-schedule-on); }
:root[data-app="detector"] { --tint: var(--app-detector); --on-tint: var(--app-detector-on); }
:root[data-app="arduino"] { --tint: var(--app-arduino); --on-tint: var(--app-arduino-on); }
:root[data-app="library"] { --tint: var(--app-library); --on-tint: var(--app-library-on); }
:root[data-app="suma-ethica"] { --tint: var(--app-suma-ethica); --on-tint: var(--app-suma-ethica-on); }
:root[data-app="goals"] { --tint: var(--app-goals); --on-tint: var(--app-goals-on); }
:root[data-app="school"] { --tint: var(--app-school); --on-tint: var(--app-school-on); }
:root[data-app="career"] { --tint: var(--app-career); --on-tint: var(--app-career-on); }
:root[data-app="resume"] { --tint: var(--app-resume); --on-tint: var(--app-resume-on); }

@media (min-width: 600px) {
  :root { --margin: 20px; }
}

/* Any element can carry a system color as its tone: tags, icon tiles,
   chart keys. */
:where([data-tone="red"]) { --tone: var(--red); }
:where([data-tone="orange"]) { --tone: var(--orange); }
:where([data-tone="yellow"]) { --tone: var(--yellow); --on-tone: #000000; }
:where([data-tone="green"]) { --tone: var(--green); }
:where([data-tone="mint"]) { --tone: var(--mint); --on-tone: #000000; }
:where([data-tone="teal"]) { --tone: var(--teal); }
:where([data-tone="cyan"]) { --tone: var(--cyan); --on-tone: #000000; }
:where([data-tone="blue"]) { --tone: var(--blue); }
:where([data-tone="indigo"]) { --tone: var(--indigo); }
:where([data-tone="purple"]) { --tone: var(--purple); }
:where([data-tone="pink"]) { --tone: var(--pink); }
:where([data-tone="brown"]) { --tone: var(--brown); }
:where([data-tone="gray"]) { --tone: var(--gray); }
:where([data-tone="tint"]) { --tone: var(--tint); --on-tone: var(--on-tint); }

@media (prefers-contrast: more) {
  :root:not([data-theme="dark"]) {
    --label-2: rgba(60, 60, 67, 0.82);
    --label-3: rgba(60, 60, 67, 0.6);
    --separator: rgba(60, 60, 67, 0.5);
  }
}
@media (prefers-contrast: more) and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --label-2: rgba(235, 235, 245, 0.82);
    --label-3: rgba(235, 235, 245, 0.6);
    --separator: rgba(84, 84, 88, 0.9);
  }
}
@media (prefers-reduced-transparency: reduce) {
  :root { --glass: var(--elevated-grouped-2); --glass-thick: var(--elevated-grouped-2); --glass-blur: none; }
}

/* ---------- Base ---------- */

:where(html) {
  background: var(--page);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  accent-color: var(--tint);
}
:where(body) {
  margin: 0;
  min-height: 100dvh;
  background: var(--page);
  color: var(--label);
  font: var(--t-body);
  letter-spacing: var(--ls-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}
:where(button, input, select, textarea) { font: inherit; letter-spacing: inherit; color: inherit; }
/* The parts set display, so hidden needs the last word. */
[hidden] { display: none !important; }
:where(a) { color: var(--tint); text-decoration: none; }
@media (hover: hover) {
  :where(a:not([class])):hover { text-decoration: underline; text-underline-offset: 0.18em; }
}
:where(:focus-visible) {
  outline: 3px solid color-mix(in srgb, var(--tint) 60%, transparent);
  outline-offset: 2px;
}
::selection { background: color-mix(in srgb, var(--tint) 28%, transparent); }

/* ---------- Text ---------- */

.os-large-title { margin: 0; font: var(--t-large-title); letter-spacing: var(--ls-large-title); color: var(--label); }
.os-title-1 { margin: 0; font: var(--t-title-1); letter-spacing: var(--ls-title-1); }
.os-title-2 { margin: 0; font: var(--t-title-2); letter-spacing: var(--ls-title-2); }
.os-title-3 { margin: 0; font: var(--t-title-3); letter-spacing: var(--ls-title-3); }
.os-headline { margin: 0; font: var(--t-headline); letter-spacing: var(--ls-headline); }
.os-body { margin: 0; font: var(--t-body); letter-spacing: var(--ls-body); }
.os-callout { margin: 0; font: var(--t-callout); letter-spacing: var(--ls-callout); }
.os-subheadline { margin: 0; font: var(--t-subheadline); letter-spacing: var(--ls-subheadline); }
.os-footnote { margin: 0; font: var(--t-footnote); letter-spacing: var(--ls-footnote); }
.os-caption { margin: 0; font: var(--t-caption); letter-spacing: var(--ls-caption); }
.os-caption-2 { margin: 0; font: var(--t-caption-2); letter-spacing: var(--ls-caption-2); }
.os-secondary { color: var(--label-2); }
.os-tertiary { color: var(--label-3); }
.os-num { font-variant-numeric: tabular-nums; }
.os-mono { font-family: var(--font-mono); letter-spacing: 0; }
.os-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.os-sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* A big figure, the way Health and Fitness show one. */
.os-stat { display: grid; gap: 2px; min-width: 0; }
.os-stat-label { font: var(--t-subheadline); letter-spacing: var(--ls-subheadline); color: var(--label-2); }
.os-stat-value {
  font: 700 34px/1.1 var(--font-rounded);
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
  color: var(--label);
}
.os-stat-value :where(small) { font-size: 0.55em; font-weight: 600; color: var(--label-2); margin-left: 0.15em; }

/* ---------- Glyphs ---------- */

.os-glyph {
  display: inline-block;
  flex: none;
  width: 1em;
  height: 1em;
  vertical-align: -0.125em;
  background-color: currentColor;
  -webkit-mask: var(--glyph) center / contain no-repeat;
  mask: var(--glyph) center / contain no-repeat;
}
.os-glyph:where(.chevron-right) { --glyph: var(--glyph-chevron-right); }
.os-glyph:where(.chevron-left) { --glyph: var(--glyph-chevron-left); }
.os-glyph:where(.chevron-down) { --glyph: var(--glyph-chevron-down); }
.os-glyph:where(.chevrons) { --glyph: var(--glyph-chevrons); }
.os-glyph:where(.check) { --glyph: var(--glyph-check); }
.os-glyph:where(.xmark) { --glyph: var(--glyph-xmark); }
.os-glyph:where(.plus) { --glyph: var(--glyph-plus); }
.os-glyph:where(.search) { --glyph: var(--glyph-search); }
.os-glyph:where(.ellipsis) { --glyph: var(--glyph-ellipsis); }
.os-glyph:where(.minus) { --glyph: var(--glyph-minus); }
.os-glyph:where(.info) { --glyph: var(--glyph-info); }
.os-glyph:where(.warning) { --glyph: var(--glyph-warning); }

/* The disclosure chevron at the end of a row. */
.os-chevron {
  display: inline-block;
  flex: none;
  width: 8px;
  height: 13px;
  background-color: var(--label-3);
  -webkit-mask: var(--glyph-chevron-right) center / contain no-repeat;
  mask: var(--glyph-chevron-right) center / contain no-repeat;
}
/* A row's checkmark, when it's the chosen one. */
.os-checkmark {
  display: inline-block;
  flex: none;
  width: 16px;
  height: 16px;
  background-color: var(--tint);
  -webkit-mask: var(--glyph-check) center / contain no-repeat;
  mask: var(--glyph-check) center / contain no-repeat;
}

.os-spinner {
  display: inline-block;
  flex: none;
  width: 20px;
  height: 20px;
  background-color: var(--gray);
  -webkit-mask: var(--glyph-spinner) center / contain no-repeat;
  mask: var(--glyph-spinner) center / contain no-repeat;
  animation: os-spin 0.9s steps(8) infinite;
}
.os-spinner:where(.large) { width: 36px; height: 36px; }
@keyframes os-spin { to { rotate: 1turn; } }

/* ---------- Layout ---------- */

/* A screen's content column. */
.os-page {
  box-sizing: border-box;
  width: 100%;
  max-width: var(--page-width, 1080px);
  margin-inline: auto;
  padding: 0 max(var(--margin), env(safe-area-inset-right)) calc(32px + env(safe-area-inset-bottom)) max(var(--margin), env(safe-area-inset-left));
}
.os-page:where(.readable) { --page-width: 760px; }

/* Cards that fill the row, at least --grid-min wide. */
.os-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--grid-min, 280px)), 1fr));
  gap: 16px;
}

/* A large title, and an optional line under it. */
.os-title-block { display: grid; gap: 2px; padding: 4px 0 16px; }
.os-title-block :where(p:not(.os-large-title)) { margin: 0; font: var(--t-subheadline); letter-spacing: var(--ls-subheadline); color: var(--label-2); }

/* ---------- Navigation bar ---------- */

/* Sticky, see-through, with a soft fade where content slides under it
   (iOS 26). Three slots: leading, title, trailing. */
.os-navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(max-content, 1fr) minmax(0, auto) minmax(max-content, 1fr);
  align-items: center;
  gap: 8px;
  box-sizing: border-box;
  min-height: calc(60px + env(safe-area-inset-top));
  padding: calc(8px + env(safe-area-inset-top)) max(var(--margin), env(safe-area-inset-right)) 8px max(var(--margin), env(safe-area-inset-left));
}
.os-navbar::before {
  content: "";
  position: absolute;
  inset: 0 0 -18px;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(to bottom, var(--page) 0%, color-mix(in srgb, var(--page) 82%, transparent) 55%, transparent 100%);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  -webkit-mask-image: linear-gradient(to bottom, #000 55%, transparent);
  mask-image: linear-gradient(to bottom, #000 55%, transparent);
  opacity: 0;
  transition: opacity 0.2s;
}
/* The fade shows once content scrolls under the bar: by the page's scroll
   where the browser can tell, else when the app sets .is-scrolled. */
.os-navbar:where(.is-scrolled)::before { opacity: 1; }
@supports (animation-timeline: scroll()) {
  .os-navbar:where(:not(.is-scrolled))::before {
    animation: os-fade-in linear both;
    animation-timeline: scroll(root);
    animation-range: 0 24px;
  }
}
.os-navbar-leading, .os-navbar-trailing { display: flex; align-items: center; gap: 8px; min-width: 0; }
.os-navbar-leading { justify-self: start; }
.os-navbar-trailing { justify-self: end; }
.os-navbar-title {
  grid-column: 2;
  min-width: 0;
  margin: 0;
  font: var(--t-headline);
  letter-spacing: var(--ls-headline);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* With a large title on the page, the bar's own title waits until the
   large one scrolls away: by scroll position where the browser can,
   else when the app sets .is-scrolled. */
.os-navbar:where([data-large-title]) .os-navbar-title { opacity: 0; transition: opacity 0.2s; }
.os-navbar:where([data-large-title].is-scrolled) .os-navbar-title { opacity: 1; }
@supports (animation-timeline: scroll()) {
  .os-navbar:where([data-large-title]:not(.is-scrolled)) .os-navbar-title {
    animation: os-fade-in linear both;
    animation-timeline: scroll(root);
    animation-range: 28px 60px;
  }
}
@keyframes os-fade-in { from { opacity: 0; } to { opacity: 1; } }

/* Bar buttons: glass circles and capsules. Prominent ones wear the tint. */
.os-bar-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: none;
  box-sizing: border-box;
  min-width: var(--bar-button);
  height: var(--bar-button);
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: var(--glass);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-shadow);
  color: var(--label);
  font: 500 17px/22px var(--font);
  letter-spacing: var(--ls-body);
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.2s, scale 0.2s var(--ease);
}
.os-bar-button:where(.icon) { width: var(--bar-button); padding: 0; }
.os-bar-button:where(.filled) { background: var(--tint); color: var(--on-tint); font-weight: 600; }
.os-bar-button:where(.destructive) { --tint: var(--red); --on-tint: #FFFFFF; color: var(--red); }
.os-bar-button:where(.destructive.filled) { color: var(--on-tint); }
.os-bar-button :where(svg, .os-glyph) { width: 20px; height: 20px; flex: none; }
.os-bar-button:where(:active:not(:disabled)) { scale: 0.94; opacity: 0.8; }
.os-bar-button:where(:disabled, [aria-disabled="true"]) { opacity: 0.4; cursor: default; }
@media (hover: hover) {
  .os-bar-button:where(:hover:not(:disabled)) { background-image: linear-gradient(var(--hover), var(--hover)); }
}

/* Back: a chevron and where it goes. On a root screen it's "Home". */
.os-back { padding-left: 12px; }
.os-back::before {
  content: "";
  flex: none;
  width: 11px;
  height: 18px;
  background-color: currentColor;
  -webkit-mask: var(--glyph-chevron-left) center / contain no-repeat;
  mask: var(--glyph-chevron-left) center / contain no-repeat;
}

/* ---------- Tab bar and sidebar ---------- */

/* A floating glass capsule at the bottom of a phone or a narrow window.
   Leave var(--tabbar-space) under the content. */
.os-tabbar {
  position: fixed;
  z-index: 60;
  left: 50%;
  bottom: max(12px, calc(env(safe-area-inset-bottom) - 6px));
  translate: -50% 0;
  display: flex;
  max-width: min(520px, calc(100vw - 2 * var(--margin)));
  box-sizing: border-box;
  padding: 4px;
  border-radius: 999px;
  background: var(--glass);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-shadow), 0 8px 30px rgba(0, 0, 0, 0.1);
}
.os-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex: 0 1 72px;
  width: 72px;
  min-width: 0;
  height: 54px;
  padding: 0 8px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--label);
  font: 600 10px/12px var(--font);
  letter-spacing: 0.01em;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.25s var(--ease), color 0.25s;
}
.os-tab :where(svg, .os-glyph, img) { width: 26px; height: 24px; flex: none; }
.os-tab:where([aria-current="page"], [aria-current="true"], [aria-selected="true"], .is-selected) {
  color: var(--tint);
  background: var(--fill-3);
}

/* The iPad and Mac sidebar: the app's sections as rows. */
.os-sidebar { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.os-sidebar-heading {
  margin: 0;
  padding: 18px 12px 6px;
  font: var(--t-footnote);
  font-weight: 600;
  letter-spacing: var(--ls-footnote);
  color: var(--label-2);
}
.os-sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--row);
  padding: 0 12px;
  border: 0;
  border-radius: 14px;
  background: none;
  color: var(--label);
  font: var(--t-body);
  letter-spacing: var(--ls-body);
  text-align: start;
  text-decoration: none;
  cursor: pointer;
}
.os-sidebar-item :where(svg, .os-glyph, img) { width: 22px; height: 22px; flex: none; color: var(--tint); }
.os-sidebar-item :where(.os-badge, .os-cell-detail) { margin-left: auto; }
.os-sidebar-item:where([aria-current="page"], [aria-current="true"], [aria-selected="true"], .is-selected) {
  background: var(--fill-2);
  color: var(--tint);
  font-weight: 600;
}
@media (hover: hover) {
  .os-sidebar-item:where(:hover:not([aria-current="page"], [aria-current="true"], [aria-selected="true"], .is-selected)) { background: var(--fill-4); }
}

/* ---------- Lists ---------- */

/* An inset grouped section: an optional header, the rows, a footer. */
.os-section { margin: 0 0 32px; min-width: 0; }
.os-section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 0 16px 7px;
  font: var(--t-footnote);
  letter-spacing: var(--ls-footnote);
  text-transform: uppercase;
  color: var(--label-2);
}
/* A section's title that reads as a heading, with room for a button. */
.os-section-header:where(.prominent) {
  align-items: center;
  padding: 0 4px 8px;
  font: var(--t-title-3);
  font-weight: 700;
  letter-spacing: var(--ls-title-3);
  text-transform: none;
  color: var(--label);
}
.os-section-footer {
  margin: 0;
  padding: 7px 16px 0;
  font: var(--t-footnote);
  letter-spacing: var(--ls-footnote);
  color: var(--label-2);
}

/* The rows are the list's direct children (or wrap one .os-cell each). */
.os-list {
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--grouped-2);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.os-list > * { position: relative; }
.os-list > * + *::before {
  content: "";
  position: absolute;
  z-index: 1;
  top: 0;
  right: 0;
  left: var(--separator-inset, 16px);
  border-top: 0.5px solid var(--separator);
  pointer-events: none;
}
.os-list > :has(.os-cell-icon) { --separator-inset: 59px; }
.os-list > :has(.os-check) { --separator-inset: 52px; }
/* Full-width rows with no section around them. */
.os-list:where(.plain) { border-radius: 0; background: transparent; overflow: visible; }

.os-cell {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  box-sizing: border-box;
  width: 100%;
  min-height: var(--row);
  margin: 0;
  padding: 11px 16px;
  border: 0;
  background: transparent;
  color: var(--label);
  font: var(--t-body);
  letter-spacing: var(--ls-body);
  text-align: start;
  text-decoration: none;
}
:where(a, button, label, summary).os-cell { cursor: pointer; }
:where(a, button, label, summary).os-cell:active { background: var(--highlight); }
@media (hover: hover) {
  :where(a, button, summary).os-cell:hover { background-color: var(--fill-4); }
}
.os-cell:focus-visible { outline-offset: -3px; }
.os-cell:is(:disabled, [aria-disabled="true"]) { color: var(--label-3); background: transparent; cursor: default; }
.os-cell:where(.action) { color: var(--tint); }
.os-cell:where(.destructive) { color: var(--red); }
.os-cell:where(.centered) { justify-content: center; text-align: center; }

/* A Settings-style icon: white glyph on a tone. */
.os-cell-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 29px;
  height: 29px;
  border-radius: 8px;
  background: var(--tone, var(--tint));
  color: #FFFFFF;
}
.os-cell-icon :where(svg, .os-glyph) { width: 18px; height: 18px; }
.os-cell-icon :where(img) { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.os-cell-content { display: flex; flex-direction: column; gap: 1px; flex: 1 1 auto; min-width: 0; }
.os-cell-title { min-width: 0; }
.os-cell-subtitle {
  font: var(--t-subheadline);
  letter-spacing: var(--ls-subheadline);
  color: var(--label-2);
}
/* A value keeps its width (the title gives way first) up to 60% of the
   row, then truncates. */
.os-cell-detail {
  flex: none;
  max-width: 60%;
  margin-left: auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--label-2);
  text-align: end;
  font-variant-numeric: tabular-nums;
}
.os-cell-content + .os-cell-detail { margin-left: 0; }
/* Two classes' weight, so the parts' own margin: 0 can't undo it. */
.os-cell > :is(.os-switch, .os-chevron, .os-checkmark, .os-segmented, .os-button, .os-popup, .os-tag, .os-badge) { margin-left: auto; }
.os-cell > :is(.os-switch, .os-segmented, .os-button, .os-popup) { margin-block: -6px; }
.os-cell > .os-cell-content ~ :is(.os-switch, .os-chevron, .os-checkmark, .os-segmented, .os-button, .os-popup, .os-tag, .os-badge) { margin-left: 0; }
.os-cell > .os-cell-detail ~ :is(.os-chevron, .os-checkmark) { margin-left: -6px; }

/* A field inside a row: the row's label on the left, the value right. */
.os-cell-input {
  flex: 1 1 auto;
  min-width: 0;
  margin: -11px 0;
  padding: 11px 0;
  border: 0;
  background: transparent;
  color: var(--label);
  font: inherit;
  letter-spacing: inherit;
  text-align: end;
  outline: none;
}
.os-cell-input::placeholder { color: var(--label-3); }
.os-cell-input:where(:only-child, .leading) { text-align: start; }
select.os-cell-input {
  -webkit-appearance: none;
  appearance: none;
  flex: 0 1 auto;
  margin-left: auto;
  padding-right: 18px;
  color: var(--label-2);
  background: var(--img-chevrons) right center / 9px 14px no-repeat;
  cursor: pointer;
}
select.os-cell-input:focus-visible { outline: 3px solid color-mix(in srgb, var(--tint) 60%, transparent); outline-offset: 2px; border-radius: 6px; }
textarea.os-cell-input { min-height: 88px; resize: vertical; text-align: start; }

/* ---------- Tables ---------- */

/* For data with columns. Sits inside a .os-list-like card. */
.os-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.os-table :where(th) {
  padding: 10px 16px 6px;
  font: var(--t-footnote);
  letter-spacing: var(--ls-footnote);
  text-transform: uppercase;
  text-align: start;
  color: var(--label-2);
  font-weight: 400;
}
.os-table :where(td) {
  padding: 11px 16px;
  border-top: 0.5px solid var(--separator);
  vertical-align: middle;
}
.os-table :where(tbody tr:first-child td) { border-top: 0; }
.os-table :where(thead + tbody tr:first-child td) { border-top: 0.5px solid var(--separator); }
.os-table :where(.end) { text-align: end; }
@media (hover: hover) {
  .os-table :where(tbody tr.is-link:hover) { background: var(--fill-4); cursor: pointer; }
}

/* ---------- Cards ---------- */

.os-card {
  box-sizing: border-box;
  min-width: 0;
  padding: 16px;
  border-radius: var(--radius-lg);
  background: var(--card, var(--grouped-2));
  color: var(--label);
}
.os-card:where(.flush) { padding: 0; overflow: hidden; }
:where(a).os-card { display: block; text-decoration: none; }
:where(a, button).os-card:active { background: var(--highlight); }
.os-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 10px;
  font: var(--t-headline);
  letter-spacing: var(--ls-headline);
}
.os-card-header :where(.os-glyph, svg) { color: var(--tone, var(--tint)); }

/* ---------- Buttons ---------- */

/* Gray capsule with tint text; .filled, .tinted, .plain, .gray and .glass
   change the fill; .small, .large, .icon and .block the size. */
.os-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: none;
  box-sizing: border-box;
  min-height: var(--control);
  margin: 0;
  padding: 7px 16px;
  border: 0;
  border-radius: 999px;
  background-color: var(--fill-3);
  color: var(--tint);
  font: 500 17px/22px var(--font);
  letter-spacing: var(--ls-body);
  text-transform: none;
  white-space: nowrap;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.2s, background-color 0.2s;
}
.os-button :where(svg, .os-glyph) { width: 1.1em; height: 1.1em; flex: none; }
.os-button:where(.filled) { background-color: var(--tint); color: var(--on-tint); font-weight: 600; }
.os-button:where(.tinted) { background-color: color-mix(in srgb, var(--tint) 15%, transparent); }
.os-button:where(.plain) { background-color: transparent; padding-inline: 8px; }
.os-button:where(.gray) { color: var(--label); }
.os-button:where(.glass) {
  background-color: var(--glass);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-shadow);
  color: var(--label);
}
.os-button:where(.destructive) { --tint: var(--red); --on-tint: #FFFFFF; }
.os-button:where(.small) { min-height: 28px; padding: 4px 12px; font-size: 15px; line-height: 20px; letter-spacing: var(--ls-subheadline); }
.os-button:where(.large) { min-height: 50px; padding: 14px 24px; font-weight: 600; }
.os-button:where(.block) { display: flex; width: 100%; }
.os-button:where(.icon) { width: var(--control); padding: 0; }
.os-button:where(.icon.small) { width: 28px; }
.os-button:where(.icon.large) { width: 50px; }
.os-button:where(:active:not(:disabled, [aria-disabled="true"])) { opacity: 0.6; transition-duration: 0s; }
.os-button:where(:disabled, [aria-disabled="true"]) { opacity: 0.38; cursor: default; }
@media (hover: hover) {
  .os-button:where(:hover:not(:disabled, [aria-disabled="true"])) { background-image: linear-gradient(var(--hover), var(--hover)); }
}

/* A count, the way app icons show one. */
.os-badge {
  display: inline-grid;
  place-items: center;
  box-sizing: border-box;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--tone, var(--red));
  color: #FFFFFF;
  font: 600 13px/1 var(--font);
  font-variant-numeric: tabular-nums;
  text-transform: none;
}
/* A small capsule label: a status, a tag, a filter. */
.os-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  box-sizing: border-box;
  height: 24px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--tone, var(--gray)) 16%, transparent);
  color: color-mix(in srgb, var(--tone, var(--gray)) 72%, var(--label));
  font: 600 13px/1 var(--font);
  letter-spacing: var(--ls-footnote);
  text-transform: none;
  white-space: nowrap;
}
:where(button).os-tag { cursor: pointer; }
.os-tag:where([aria-pressed="true"], .is-selected) { background: var(--tone, var(--tint)); color: var(--on-tone, #FFFFFF); }
.os-tag:where([aria-pressed="true"], .is-selected):not([data-tone]) { color: var(--on-tint); }

/* ---------- Controls ---------- */

.os-input {
  box-sizing: border-box;
  width: 100%;
  min-height: var(--row);
  margin: 0;
  padding: 0 14px;
  border: 0;
  border-radius: 12px;
  background: var(--fill-3);
  color: var(--label);
  font: var(--t-body);
  letter-spacing: var(--ls-body);
}
.os-input::placeholder { color: var(--label-3); }
.os-input:focus-visible { outline-offset: 0; }
textarea.os-input { min-height: 88px; padding: 11px 14px; resize: vertical; }
select.os-input {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 34px;
  background: var(--fill-3) var(--img-chevrons) right 14px center / 9px 14px no-repeat;
  cursor: pointer;
}
input[type="file"].os-input { padding: 9px 14px; }

/* A pop-up button: a <select> as a capsule, for a filter or a choice
   outside a list. .tinted (or .is-active) while it narrows something. */
.os-popup {
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
  max-width: 100%;
  min-height: var(--control);
  margin: 0;
  padding: 7px 32px 7px 14px;
  border: 0;
  border-radius: 999px;
  background: var(--fill-3) var(--img-chevrons) right 13px center / 9px 14px no-repeat;
  color: var(--label);
  font: 500 17px/22px var(--font);
  letter-spacing: var(--ls-body);
  text-overflow: ellipsis;
  cursor: pointer;
}
.os-popup:where(.small) { min-height: 28px; padding: 4px 28px 4px 12px; font-size: 15px; line-height: 20px; letter-spacing: var(--ls-subheadline); background-position: right 11px center; }
.os-popup:where(.tinted, .is-active) { background-color: color-mix(in srgb, var(--tint) 15%, transparent); color: var(--tint); }
.os-popup:focus-visible { outline-offset: 0; }

/* A label over a field, for forms that aren't lists. */
.os-field { display: grid; gap: 6px; min-width: 0; }
.os-field-label { padding: 0 4px; font: var(--t-footnote); letter-spacing: var(--ls-footnote); color: var(--label-2); }

.os-search {
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
  width: 100%;
  height: var(--control);
  margin: 0;
  padding: 0 14px 0 36px;
  border: 0;
  border-radius: 999px;
  background: var(--fill-3) var(--img-search) 13px center / 16px 16px no-repeat;
  color: var(--label);
  font: var(--t-body);
  letter-spacing: var(--ls-body);
}
.os-search::placeholder { color: var(--label-2); }
.os-search::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
  width: 17px;
  height: 17px;
  margin: 0 -4px 0 8px;
  border-radius: 50%;
  background: var(--gray) var(--img-xmark-white) center / 15px 15px no-repeat;
  cursor: pointer;
}
.os-search:focus-visible { outline-offset: 0; }

.os-switch {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  display: inline-block;
  flex: none;
  width: 51px;
  height: 31px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--switch-off);
  cursor: pointer;
  transition: background-color 0.25s;
}
.os-switch::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 3px 1px rgba(0, 0, 0, 0.06), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
  transition: translate 0.3s var(--ease);
}
.os-switch:where(:checked, [aria-checked="true"], [aria-pressed="true"]),
:where([aria-checked="true"], [aria-pressed="true"]) > .os-switch { background: var(--switch-on, var(--green)); }
.os-switch:where(:checked, [aria-checked="true"], [aria-pressed="true"])::before,
:where([aria-checked="true"], [aria-pressed="true"]) > .os-switch::before { translate: 20px 0; }
.os-switch:where(:disabled, [aria-disabled="true"]) { opacity: 0.4; cursor: default; }

/* A round check, the way Reminders marks a task. Checkbox or radio. */
.os-check {
  -webkit-appearance: none;
  appearance: none;
  display: inline-block;
  flex: none;
  box-sizing: border-box;
  width: 22px;
  height: 22px;
  margin: 0;
  padding: 0;
  border: 1.5px solid var(--gray-3);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}
.os-check:where(:checked, [aria-checked="true"], [aria-pressed="true"]) {
  border-color: var(--tone, var(--tint));
  background: var(--tone, var(--tint)) var(--img-check-white) center / 60% 60% no-repeat;
}
.os-check:where(:disabled) { opacity: 0.4; cursor: default; }

/* Segments: buttons with aria-pressed (or -selected, -checked), or
   labels around radios. */
.os-segmented {
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  box-sizing: border-box;
  min-width: 0;
  margin: 0;
  padding: 2px;
  border: 0;
  border-radius: 999px;
  background: var(--fill-3);
}
.os-segmented:where(.block) { display: grid; width: 100%; }
.os-segmented > :where(legend) {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
.os-segmented > :where(:not(legend)) {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-sizing: border-box;
  min-width: 0;
  height: 30px;
  margin: 0;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--label);
  font: 500 14px/18px var(--font);
  letter-spacing: -0.01em;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.2s, box-shadow 0.2s;
}
.os-segmented > :where([aria-pressed="true"], [aria-selected="true"], [aria-checked="true"], [aria-current="page"], [aria-current="true"], .is-selected, :has(> input:checked)) {
  background: var(--thumb);
  font-weight: 600;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 3px 1px rgba(0, 0, 0, 0.04), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
}
.os-segmented > * > :where(input[type="radio"], input[type="checkbox"]) {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.os-segmented > :where(:has(> input:focus-visible)) {
  outline: 3px solid color-mix(in srgb, var(--tint) 60%, transparent);
  outline-offset: 1px;
}

.os-progress {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 4px;
  border: 0;
  border-radius: 2px;
  background: var(--fill-2);
  color: var(--tint);
  overflow: hidden;
}
.os-progress::-webkit-progress-bar { background: var(--fill-2); border-radius: 2px; }
.os-progress::-webkit-progress-value { background: var(--tint); border-radius: 2px; }
.os-progress::-moz-progress-bar { background: var(--tint); border-radius: 2px; }
/* The same bar from a div, with a <span style="width: 40%"> inside. */
.os-bar {
  display: block;
  height: 6px;
  border-radius: 999px;
  background: var(--fill-2);
  overflow: hidden;
}
.os-bar > :where(span) {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--tone, var(--tint));
}

/* ---------- Sheets, alerts, menus, toasts ---------- */

/* A <dialog>: slides up from the bottom on a phone, a centered form
   sheet on a wider screen. Header (three slots), then a body that
   scrolls. */
.os-sheet {
  --grouped: var(--elevated-grouped);
  --grouped-2: var(--elevated-grouped-2);
  --background: var(--elevated-background);
  --background-2: var(--elevated-background-2);
  --page: var(--grouped);
  position: fixed;
  inset: auto 0 0;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  max-height: calc(100dvh - env(safe-area-inset-top) - 10px);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  background: var(--grouped);
  color: var(--label);
  box-shadow: var(--shadow-float);
  overflow: hidden;
}
.os-sheet[open] { display: flex; flex-direction: column; animation: os-sheet-up 0.45s var(--ease); }
.os-sheet::backdrop { background: var(--scrim); animation: os-fade-in 0.3s ease; }
.os-sheet:focus-visible, .os-alert:focus-visible { outline: none; }
@media (min-width: 700px) {
  .os-sheet {
    inset: 0;
    width: min(var(--sheet-width, 560px), calc(100vw - 48px));
    height: fit-content;
    max-height: min(820px, calc(100dvh - 48px));
    margin: auto;
    border-radius: var(--radius-xl);
  }
  .os-sheet:where(.wide) { --sheet-width: 820px; }
  .os-sheet[open] { animation-name: os-sheet-in; animation-duration: 0.35s; }
}
.os-sheet > :where(form) { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; margin: 0; }
@keyframes os-sheet-up { from { translate: 0 100%; } }
@keyframes os-sheet-in { from { opacity: 0; translate: 0 24px; scale: 0.98; } }
.os-grabber {
  flex: none;
  width: 36px;
  height: 5px;
  margin: 6px auto -4px;
  border-radius: 3px;
  background: var(--label-3);
}
@media (min-width: 700px) { .os-grabber { display: none; } }
.os-sheet-header {
  flex: none;
  display: grid;
  grid-template-columns: minmax(max-content, 1fr) minmax(0, auto) minmax(max-content, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 60px;
  padding: 10px 16px 6px;
}
.os-sheet-header > :first-child { justify-self: start; }
.os-sheet-header > :last-child { justify-self: end; }
.os-sheet-title {
  grid-column: 2;
  min-width: 0;
  margin: 0;
  font: var(--t-headline);
  letter-spacing: var(--ls-headline);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.os-sheet-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px 16px calc(24px + env(safe-area-inset-bottom));
}
@media (min-width: 700px) { .os-sheet-body { padding-bottom: 24px; } }

/* A centered alert: a title, a message, and capsule buttons. */
.os-alert {
  --grouped-2: var(--elevated-grouped-2);
  box-sizing: border-box;
  width: min(320px, calc(100vw - 48px));
  margin: auto;
  padding: 22px 20px 16px;
  border: 0;
  border-radius: var(--radius-xl);
  background: var(--glass-thick);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow-float);
  color: var(--label);
  text-align: center;
}
.os-alert[open] { animation: os-alert-in 0.3s var(--ease); }
.os-alert::backdrop { background: var(--scrim); }
@keyframes os-alert-in { from { opacity: 0; scale: 1.08; } }
.os-alert :where(h2) { margin: 0 0 4px; font: var(--t-headline); letter-spacing: var(--ls-headline); }
.os-alert :where(p) { margin: 0; font: var(--t-subheadline); letter-spacing: var(--ls-subheadline); color: var(--label-2); }
.os-alert-actions { display: flex; gap: 8px; margin-top: 20px; }
.os-alert-actions > * { flex: 1 1 0; }
.os-alert-actions:where(.stacked) { flex-direction: column; }

/* A menu or popover. Rows are .os-menu-item; <hr> splits groups. */
.os-menu {
  box-sizing: border-box;
  min-width: 220px;
  max-width: min(320px, calc(100vw - 32px));
  margin: 0;
  padding: 6px;
  border: 0;
  border-radius: 22px;
  background: var(--glass-thick);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow-float);
  color: var(--label);
}
.os-menu:where(:popover-open, [open], .is-open) { animation: os-menu-in 0.22s var(--ease-out); }
@keyframes os-menu-in { from { opacity: 0; scale: 0.94; } }
.os-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  box-sizing: border-box;
  width: 100%;
  min-height: var(--row);
  margin: 0;
  padding: 10px 14px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: var(--label);
  font: var(--t-body);
  letter-spacing: var(--ls-body);
  text-align: start;
  text-decoration: none;
  cursor: pointer;
}
.os-menu-item > :where(svg, .os-glyph, kbd) { order: 1; margin-left: auto; }
/* In a menu with a chosen item, the check sits in a column before the text. */
.os-menu:has(.os-checkmark) .os-menu-item { position: relative; padding-left: 42px; }
.os-menu-item > .os-checkmark { position: absolute; left: 16px; top: 50%; translate: 0 -50%; margin: 0; }
.os-menu-item :where(svg, .os-glyph) { width: 19px; height: 19px; flex: none; }
.os-menu-item :where(kbd) { font: var(--t-subheadline); color: var(--label-2); }
.os-menu-item:where(:hover, :focus-visible, [aria-selected="true"], .is-active) { background: var(--fill-3); outline: none; }
.os-menu-item:where(.destructive) { color: var(--red); }
.os-menu-item:where(:disabled, [aria-disabled="true"]) { color: var(--label-3); cursor: default; }
.os-menu :where(hr) { height: 0; margin: 5px 14px; border: 0; border-top: 0.5px solid var(--separator); }
.os-menu-label { margin: 0; padding: 8px 14px 4px; font: var(--t-footnote); letter-spacing: var(--ls-footnote); color: var(--label-2); }

/* A glass capsule that drops in at the top of the screen. */
.os-toasts {
  position: fixed;
  z-index: 1000;
  top: calc(10px + env(safe-area-inset-top));
  left: 50%;
  translate: -50% 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: calc(100vw - 32px);
  pointer-events: none;
}
/* Make the stack popover="manual" and call showPopover() again after a
   sheet opens: only the top layer can sit above a modal dialog. */
.os-toasts:where([popover]) {
  inset: calc(10px + env(safe-area-inset-top)) auto auto 50%;
  height: auto;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  overflow: visible;
}
.os-toast {
  display: flex;
  align-items: center;
  gap: 10px;
  box-sizing: border-box;
  max-width: 100%;
  min-height: 44px;
  padding: 11px 20px;
  border-radius: 999px;
  background: var(--glass-thick);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow-float);
  color: var(--label);
  font: 600 15px/20px var(--font);
  letter-spacing: var(--ls-subheadline);
  pointer-events: auto;
  animation: os-toast-in 0.45s var(--ease) both;
}
.os-toast > :where(svg, .os-glyph) { width: 18px; height: 18px; flex: none; color: var(--tint); }
.os-toast:where(.error) > :where(svg, .os-glyph) { color: var(--red); }
.os-toast :where(button) { margin-right: -8px; }
.os-toast:where(.leaving) { animation: os-toast-out 0.3s var(--ease) both; }
@keyframes os-toast-in { from { opacity: 0; translate: 0 -24px; scale: 0.9; } }
@keyframes os-toast-out { to { opacity: 0; translate: 0 -16px; scale: 0.92; } }

/* ---------- Empty and loading states ---------- */

.os-empty {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 48px 24px;
  text-align: center;
  color: var(--label-2);
}
.os-empty > :where(svg, .os-glyph, .os-empty-symbol) { width: 48px; height: 48px; margin-bottom: 8px; color: var(--label-3); }
.os-empty :where(h2, h3) { margin: 0; font: var(--t-title-3); font-weight: 700; letter-spacing: var(--ls-title-3); color: var(--label); }
.os-empty :where(p) { margin: 0; max-width: 36ch; font: var(--t-subheadline); letter-spacing: var(--ls-subheadline); }
.os-empty > :where(.os-button) { margin-top: 12px; }

/* A placeholder that shimmers while data loads. */
.os-skeleton {
  border-radius: var(--radius-sm);
  background: linear-gradient(100deg, var(--fill-3) 30%, var(--fill-4) 50%, var(--fill-3) 70%) 0 0 / 300% 100%;
  animation: os-shimmer 1.4s linear infinite;
}
@keyframes os-shimmer { from { background-position: 100% 0; } to { background-position: -50% 0; } }

@media (prefers-reduced-motion: reduce) {
  .os-sheet[open], .os-alert[open], .os-menu, .os-toast, .os-skeleton, .os-sheet::backdrop { animation: none; }
  .os-spinner { animation-duration: 1.6s; }
  .os-switch::before, .os-tab, .os-bar-button { transition: none; }
}
