/* ==================================================================================================
   Birge design system — foundation (tokens, fonts, base elements, utilities, motion)
   Owner: design-system agent. Feature CSS lives in static/css/pages/<feature>.css and must use the
   tokens below (var(--…)), never raw hex colors.

   Files (all linked from templates/base.html, in this order — no @import chains):
     css/app.css              tokens · @font-face · reset · typography · icons · utilities · motion
     css/core/shell.css       app shell: sidebar, topbar, tab bar, page, layouts (project/settings/auth/marketing)
     css/core/controls.css    buttons, inputs, checkbox/radio/switch, check-circle, segmented, fields, pickers
     css/core/content.css     cards, lists, tables, chips, badges, avatars, progress, skeleton, empty state…
     css/core/overlays.css    menus/popovers, tooltips, modal, drawer, toasts, shortcut sheet
     css/core/domain.css      task card/row, priority, due chip, project/label/user chips, drag & drop
     css/pages/*.css          feature styles (people, projects, tasks, insights, schedule; landing)

   Theme: <html data-theme="system|light|dark">. Colors are defined ONCE with light-dark(); the
   `color-scheme` of :root decides which side applies (system follows the OS).
   Breakpoints (mobile-first, min-width): sm 640 · md 768 · lg 1024 · xl 1280 · 2xl 1536.
   ================================================================================================== */

/* --------------------------------------------------------------------------------------------------
   1. Fonts — Inter (variable, OFL) for platforms without San Francisco. Kyrgyz needs cyrillic-ext
      (ң ө ү). Files: static/fonts/inter/ (from @fontsource-variable/inter 5.3.0).
   -------------------------------------------------------------------------------------------------- */
@font-face {
  font-family: "InterVariable";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/inter/inter-cyrillic-ext-wght-normal.251d36f2b5a6.woff2") format("woff2");
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: "InterVariable";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/inter/inter-cyrillic-wght-normal.de93fdc85e3d.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "InterVariable";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/inter/inter-latin-ext-wght-normal.1ad231aac0a8.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308,
    U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113,
    U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "InterVariable";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/inter/inter-latin-wght-normal.260c81a4759b.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304,
    U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* --------------------------------------------------------------------------------------------------
   2. Tokens — r4 «Birge OS». Light/dark: light-dark(); <html data-theme> + data-scheme тандайт.
   Appearance (13-бөлүм): <html data-accent | data-text-size | data-transparency | data-motion>.
   -------------------------------------------------------------------------------------------------- */
:root {
  color-scheme: light dark;

  /* Appearance inputs ---------------------------------------------------------------------------- */
  --text-scale: 1; /* data-text-size: s .94 · m 1 · l 1.08 · xl 1.16 */

  /* Palette — Apple system colors (light, dark). Use via data-color="<name>" → --tone. (r3'тогудай) */
  --c-blue: light-dark(#007aff, #0a84ff);
  --c-indigo: light-dark(#5856d6, #5e5ce6);
  --c-purple: light-dark(#af52de, #bf5af2);
  --c-pink: light-dark(#ff2d55, #ff375f);
  --c-red: light-dark(#ff3b30, #ff453a);
  --c-orange: light-dark(#ff9500, #ff9f0a);
  --c-yellow: light-dark(#ffcc00, #ffd60a);
  --c-green: light-dark(#34c759, #30d158);
  --c-mint: light-dark(#00c7be, #63e6e2);
  --c-teal: light-dark(#30b0c7, #40c8e0);
  --c-cyan: light-dark(#32ade6, #64d2ff);
  --c-brown: light-dark(#a2845e, #ac8e68);
  --c-gray: light-dark(#8e8e93, #8e8e93);
  /* "Ink" variants — accessible text/icon color on tinted (soft) backgrounds (WCAG AA). */
  --c-blue-ink: light-dark(#0040dd, #5eadff);
  --c-indigo-ink: light-dark(#3634a3, #8e8cff);
  --c-purple-ink: light-dark(#8944ab, #da8fff);
  --c-pink-ink: light-dark(#c4093f, #ff6482);
  --c-red-ink: light-dark(#c4000f, #ff6961);
  --c-orange-ink: light-dark(#b83000, #ffb340);
  --c-yellow-ink: light-dark(#8f5100, #ffd426);
  --c-green-ink: light-dark(#1b6f31, #30db5b);
  --c-mint-ink: light-dark(#0a716c, #66d4cf);
  --c-teal-ink: light-dark(#006b80, #5de6ff);
  --c-cyan-ink: light-dark(#00668f, #70d7ff);
  --c-brown-ink: light-dark(#735a3c, #c4a77f);
  --c-gray-ink: light-dark(#636366, #aeaeb2);

  /* Accent fills — 13-бөлүмдөгү 8 вариант (ак текст менен ≥ 4.7:1; Тиркеме C) */
  --accent-indigo: #5b52e6;
  --accent-blue: #0071e3;
  --accent-purple: #a446d2;
  --accent-pink: #e40040;
  --accent-red: #e31011;
  --accent-orange: #b95500;
  --accent-green: #00850e;
  --accent-graphite: #727276;

  /* Surfaces ------------------------------------------------------------------------------------- */
  --bg: light-dark(#edf0f4, #1b1c20); /* барактын фону = обойдун орточо түсү (sticky маскалар, шакектер) */
  --bg-sidebar: light-dark(#f7f8fa, #25262b); /* тунук эмес sidebar (тунуктук азайтылганда) */
  --surface: light-dark(#ffffff, #2b2c31); /* карталар, топтор, талаалар */
  --surface-2: light-dark(#f6f7f9, #323338); /* карта ичиндеги көтөрүңкү: таблица башы, hover сап */
  --surface-sunken: light-dark(#e6e9ee, #222327); /* код блоктору, тунук эмес кудуктар */
  --surface-well: light-dark(rgb(255 255 255 / 0.42), rgb(0 0 0 / 0.2)); /* доска колонкалары: обой аркылуу көрүнгөн тунук кудук */
  --surface-elevated: light-dark(#ffffff, #2c2d32); /* sheet, inspector, alert (тунук эмес негиз) */

  /* Desktop wallpaper (macOS): --bg үстүндөгү төрт жумшак жарык, html'ге fixed тартылат; айнек
     панелдер (sidebar, капсулалар) аны бүдөмүк көрсөтөт. Жарыктар текстти AA'дан төмөн түшүрбөйт. */
  --wp-sky: light-dark(rgb(204 224 255 / 0.68), rgb(66 96 196 / 0.3));
  --wp-lilac: light-dark(rgb(226 216 255 / 0.6), rgb(120 84 190 / 0.24));
  --wp-mint: light-dark(rgb(190 236 220 / 0.6), rgb(30 124 134 / 0.24));
  --wp-peach: light-dark(rgb(255 222 204 / 0.5), rgb(160 96 70 / 0.14));
  --wallpaper:
    radial-gradient(78% 72% at 0% 0%, var(--wp-sky), transparent 75%),
    radial-gradient(64% 66% at 100% 0%, var(--wp-lilac), transparent 75%),
    radial-gradient(70% 74% at 90% 100%, var(--wp-mint), transparent 75%),
    radial-gradient(56% 62% at 10% 100%, var(--wp-peach), transparent 75%),
    var(--bg);
  --mat-sidebar: light-dark(rgb(255 255 255 / 0.5), rgb(40 41 47 / 0.58)); /* desktop sidebar айнеги */
  --surface-overlay: var(--mat-thick); /* менюлар (айнек) */
  --surface-inverse: light-dark(#1d1d1f, #f2f2f2);

  /* Text — ар бир деңгээл AA (≥ 4.5:1) бардык фондордо (Тиркеме C) ------------------------------ */
  --text: light-dark(#1d1d1f, #f2f2f2);
  --text-2: light-dark(#5c5c5c, #b4b4b4); /* экинчи даражадагы текст */
  --text-3: light-dark(#666666, #a6a6a6); /* мета, placeholder, саноолор */
  --text-3-on-fill: light-dark(#5a5a5a, #b2b2b2); /* --fill-* фонундагы үчүнчү текст */
  --text-inverse: light-dark(#ffffff, #1d1d1f);
  --text-on-accent: #ffffff;
  --text-disabled: light-dark(#b0b0b0, #5a5a5a); /* өчүк башкаруу элементтери гана */

  /* Lines & fills (iOS systemFill үй-бүлөсү: боз-көгүш тунук) ------------------------------------ */
  --line: light-dark(rgb(0 0 0 / 0.1), rgb(255 255 255 / 0.1));
  --line-strong: light-dark(rgb(0 0 0 / 0.16), rgb(255 255 255 / 0.17));
  --line-subtle: light-dark(rgb(0 0 0 / 0.06), rgb(255 255 255 / 0.06)); /* саптардын бөлгүчү */
  --fill-1: light-dark(rgb(120 120 120 / 0.08), rgb(140 140 140 / 0.14)); /* hover */
  --fill-2: light-dark(rgb(120 120 120 / 0.14), rgb(140 140 140 / 0.22)); /* тандалган / басылган, издөө талаасы */
  --fill-3: light-dark(rgb(120 120 120 / 0.2), rgb(140 140 140 / 0.3)); /* трек, switch'тин өчүк абалы */
  --card-ring: light-dark(rgb(0 0 0 / 0.06), rgb(255 255 255 / 0.07));
  --card-highlight: light-dark(rgb(255 255 255 / 0), rgb(255 255 255 / 0.05)); /* караңгы карталардын үстүңкү жарык кыры */

  /* Accent (демейки Birge indigo; 13-бөлүм: 8 вариант) ------------------------------------------- */
  --accent: light-dark(#5b52e6, #6660ee); /* ак текст менен 5.5 / 4.7 : 1 */
  --accent-solid: var(--accent-indigo); /* караңгы темада да ушул бойдон (иконка плиткалары, аватарлар) */
  --accent-hover: color-mix(in oklab, var(--accent) 90%, black);
  --accent-pressed: color-mix(in oklab, var(--accent) 80%, black);
  --accent-ink: light-dark(#4b44d6, #9a94ff); /* шилтемелер, accent текст */
  --accent-soft: color-mix(in srgb, var(--accent) 14%, transparent);
  --accent-softer: color-mix(in srgb, var(--accent) 8%, transparent);
  --focus-ring: color-mix(in srgb, var(--accent) 40%, transparent); /* жумшак halo */
  --focus-outline: light-dark(color-mix(in srgb, var(--accent) 85%, transparent), var(--accent-ink)); /* ≥ 3:1 */
  --selection-bg: var(--accent); /* тандалган сап / менюнун пункту (macOS) */
  --selection-fg: #ffffff;
  --selection-muted: var(--fill-2); /* терезе же тизме фокуста эмес кездеги тандоо */

  /* Sidebar ------------------------------------------------------------------------------------- */
  --sidebar-icon: var(--accent); /* macOS: sidebar иконкалары accent түстө */
  --sidebar-selection: light-dark(rgb(0 0 0 / 0.075), rgb(255 255 255 / 0.11));
  --sidebar-hover: light-dark(rgb(0 0 0 / 0.04), rgb(255 255 255 / 0.06));

  /* Semantic ------------------------------------------------------------------------------------ */
  --success: var(--c-green);
  --success-ink: var(--c-green-ink);
  --warning: var(--c-orange);
  --warning-ink: var(--c-orange-ink);
  --danger: var(--c-red);
  --danger-ink: var(--c-red-ink);
  --danger-solid: #e0281e; /* ак текст алып жүрүүчү фон: 4.7:1 */
  --info: var(--c-blue);
  --info-ink: var(--c-blue-ink);
  --badge-bg: var(--danger-solid); /* iOS кызыл бейджи (tab bar, коңгуроо) */
  --switch-on: var(--accent); /* телефондо — жашыл (төмөндө) */

  /* Data viz ------------------------------------------------------------------------------------ */
  --chart-muted: light-dark(color-mix(in srgb, var(--accent) 30%, var(--surface)), color-mix(in srgb, var(--accent) 55%, var(--surface)));
  --chart-strong: light-dark(var(--accent), #8b85ff);
  --chart-grid: var(--line-subtle);
  --chart-axis: var(--text-3);
  --chart-track: var(--fill-2);

  /* Brand --------------------------------------------------------------------------------------- */
  --brand-gradient: linear-gradient(135deg, #3aa0ff 0%, #5e5ce6 55%, #b254f2 100%);

  /* Materials (4-бөлүм) ------------------------------------------------------------------------ */
  --mat-ultrathin: light-dark(rgb(255 255 255 / 0.42), rgb(58 59 66 / 0.42));
  --mat-thin: light-dark(rgb(255 255 255 / 0.58), rgb(54 55 62 / 0.56));
  --mat-regular: light-dark(rgb(255 255 255 / 0.72), rgb(48 49 55 / 0.74));
  --mat-thick: light-dark(rgb(251 251 253 / 0.86), rgb(45 46 52 / 0.88));
  --mat-chrome: light-dark(rgb(246 247 250 / 0.8), rgb(36 37 42 / 0.78));
  --mat-filter: blur(24px) saturate(180%);
  --mat-filter-strong: blur(40px) saturate(190%);
  --glass-rim: inset 0 0.5px 0 light-dark(rgb(255 255 255 / 0.9), rgb(255 255 255 / 0.16)),
    inset 0 0 0 0.5px light-dark(rgb(255 255 255 / 0.5), rgb(255 255 255 / 0.07));
  --glass-border: light-dark(rgb(0 0 0 / 0.08), rgb(255 255 255 / 0.1));
  --glass-sheen: linear-gradient(180deg, light-dark(rgb(255 255 255 / 0.5), rgb(255 255 255 / 0.07)) 0%, transparent 42%);
  /* r3 аттары (alias) — эски CSS иштей берсин */
  --glass-bg: var(--mat-regular);
  --glass-bg-strong: var(--mat-thick);
  --header-bg: var(--mat-chrome);
  --glass-filter: var(--mat-filter);
  --glass-line: var(--glass-border);
  --scrim: light-dark(rgb(0 0 0 / 0.2), rgb(0 0 0 / 0.5));
  --scrim-light: light-dark(rgb(0 0 0 / 0.08), rgb(0 0 0 / 0.3)); /* планшет sidebar'ы, context menu */
  --tooltip-bg: light-dark(rgb(255 255 255 / 0.96), rgb(52 52 56 / 0.96));
  --tooltip-fg: light-dark(#1d1d1f, #f5f5f7);
  --island-bg: light-dark(rgb(28 28 30 / 0.92), rgb(58 58 62 / 0.92)); /* status island: эки темада тең караңгы капсула */
  --island-fg: #ffffff;
  --segmented-thumb: light-dark(#ffffff, #636366); /* iOS segmented / switch thumb */
  --segmented-thumb-shadow: 0 1px 2px rgb(0 0 0 / 0.1), 0 2px 6px rgb(0 0 0 / 0.06), inset 0 0.5px 0 rgb(255 255 255 / 0.2);
  --switch-thumb: #ffffff; /* iOS: эки темада тең ак */
  --tick-read: #8ff5ff; /* чат: «окулду» белгиси accent көбүкчөдө (12.17; ≥ 4.5:1 ар бир accent көбүкчөдө, Тиркеме C) */

  /* Elevation — жумшак, катмарлуу көлөкөлөр --------------------------------------------------- */
  --shadow-xs: 0 1px 1px light-dark(rgb(0 0 0 / 0.04), rgb(0 0 0 / 0.3));
  --shadow-sm: 0 1px 2px light-dark(rgb(0 0 0 / 0.05), rgb(0 0 0 / 0.32)),
    0 2px 6px light-dark(rgb(0 0 0 / 0.04), rgb(0 0 0 / 0.2));
  --shadow-md: 0 2px 6px light-dark(rgb(0 0 0 / 0.05), rgb(0 0 0 / 0.3)),
    0 8px 24px light-dark(rgb(0 0 0 / 0.08), rgb(0 0 0 / 0.36));
  --shadow-lg: 0 4px 12px light-dark(rgb(0 0 0 / 0.07), rgb(0 0 0 / 0.34)),
    0 18px 48px light-dark(rgb(0 0 0 / 0.14), rgb(0 0 0 / 0.5));
  --shadow-xl: 0 10px 30px light-dark(rgb(0 0 0 / 0.1), rgb(0 0 0 / 0.4)),
    0 32px 80px light-dark(rgb(0 0 0 / 0.22), rgb(0 0 0 / 0.6));
  --shadow-control: 0 0.5px 1px light-dark(rgb(0 0 0 / 0.08), rgb(0 0 0 / 0.3)),
    0 1px 2px light-dark(rgb(0 0 0 / 0.04), rgb(0 0 0 / 0.2));
  --shadow-accent: 0 1px 2px color-mix(in srgb, var(--accent) 35%, transparent),
    0 4px 12px color-mix(in srgb, var(--accent) 22%, transparent);
  --shadow-lift: 0 12px 28px light-dark(rgb(0 0 0 / 0.16), rgb(0 0 0 / 0.55)),
    0 2px 6px light-dark(rgb(0 0 0 / 0.08), rgb(0 0 0 / 0.4)); /* сүйрөлүп/көтөрүлүп жаткан нерсе */

  /* Radii — концентрдүү система (3.4) ------------------------------------------------------------ */
  --radius-xs: 6px; /* kbd, кичине чиптер таблицада */
  --radius-sm: 8px; /* меню пункттары, sidebar саптары (панелдин ичинде) */
  --radius-md: 10px; /* талаалар, select'тер, popover ичиндеги пункттар */
  --radius-lg: 14px; /* меню/popover панели */
  --radius-xl: 20px;
  --radius-2xl: 26px;
  --radius-full: 999px;
  --radius-control: 10px; /* input, select, textarea */
  --radius-button: 999px; /* БАРДЫК баскычтар — капсула */
  --radius-card: 16px; /* карталар, inset grouped топтор */
  --radius-board-card: 12px; /* доска картасы (колонка 18 − 6 padding) */
  --radius-widget: 22px; /* башкы беттин виджеттери, stat плиткалар */
  --radius-panel: 18px; /* калкыма панелдер: sidebar, inspector */
  --radius-sheet: 24px; /* desktop'тогу sheet/modal, alert */
  --radius-menu: 14px; /* меню, popover, context menu */

  /* Spacing (4px тор) — ӨЗГӨРБӨЙТ: --space-0-5 … --space-20 */
  --space-0-5: 0.125rem;
  --space-1: 0.25rem;
  --space-1-5: 0.375rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;

  /* Typography (5-бөлүм) ------------------------------------------------------------------------- */
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "InterVariable", "Inter",
    "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "SF Pro Display", -apple-system, BlinkMacSystemFont, "InterVariable", "Inter",
    "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-rounded: ui-rounded, "SF Pro Rounded", var(--font-display); /* чоң сандар (виджеттер) */
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --fs-2xs: calc(0.6875rem * var(--text-scale)); /* 11 */
  --fs-xs: calc(0.75rem * var(--text-scale)); /* 12 */
  --fs-sm: calc(0.8125rem * var(--text-scale)); /* 13 */
  --fs-md: calc(0.875rem * var(--text-scale)); /* 14 — desktop'тогу негизги текст */
  --fs-lg: calc(0.9375rem * var(--text-scale)); /* 15 */
  --fs-xl: calc(1.0625rem * var(--text-scale)); /* 17 */
  --fs-title-3: calc(1.25rem * var(--text-scale)); /* 20 */
  --fs-title-2: calc(1.375rem * var(--text-scale)); /* 22 */
  --fs-title-1: calc(1.75rem * var(--text-scale)); /* 28 */
  --fs-large: calc(2.125rem * var(--text-scale)); /* 34 */
  --fs-display: clamp(2.5rem, 1.5rem + 3.6vw, 4.25rem);
  /* Apple text styles — компоненттер ушуларды колдонот (телефондо чоңоет, 3.2) */
  --type-caption2: var(--fs-2xs); /* 11 */
  --type-caption: var(--fs-xs); /* 12 */
  --type-footnote: var(--fs-xs); /* 12 */
  --type-subhead: var(--fs-sm); /* 13 */
  --type-callout: var(--fs-sm); /* 13 */
  --type-body: var(--fs-md); /* 14 */
  --type-headline: var(--fs-md); /* 14, weight 600 */
  --type-title3: var(--fs-xl); /* 17 */
  --type-title2: var(--fs-title-3); /* 20 */
  --type-title1: calc(1.5rem * var(--text-scale)); /* 24 */
  --type-large: calc(1.875rem * var(--text-scale)); /* 30 */
  --fs-body: var(--type-body);
  --lh-tight: 1.15;
  --lh-snug: 1.3;
  --lh-normal: 1.45;
  --tracking-tight: -0.022em; /* ≥ 28 px */
  --tracking-snug: -0.012em; /* 17–24 px */
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;

  /* Motion (7-бөлүм) ---------------------------------------------------------------------------- */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in: cubic-bezier(0.5, 0, 0.75, 0);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  /* Spring'дер (Тиркеме B: түзүлүшү). Узактыгы = толук токтоо убактысы. */
  --spring-snappy: linear(0, 0.0406, 0.1364, 0.2577, 0.3851, 0.5066, 0.6155, 0.7088, 0.7859, 0.8477, 0.8957, 0.9319, 0.9585, 0.9774, 0.9903, 0.9986, 1.0037, 1.0064, 1.0076, 1.0077, 1.0072, 1.0063, 1.0054, 1.0044, 1.0035, 1.0027, 1);
  --spring-smooth: linear(0, 0.0225, 0.0775, 0.1509, 0.2328, 0.3167, 0.3984, 0.4752, 0.5457, 0.6093, 0.6659, 0.7157, 0.7591, 0.7966, 0.8289, 0.8564, 0.8799, 0.8997, 0.9165, 0.9306, 0.9424, 0.9523, 0.9606, 0.9674, 0.9731, 0.9779, 0.9818, 0.985, 0.9877, 0.9899, 0.9917, 0.9932, 0.9945, 0.9955, 0.9963, 0.997, 0.9975, 1);
  --spring-bouncy: linear(0, 0.0197, 0.0716, 0.1456, 0.2336, 0.3287, 0.4257, 0.5204, 0.6098, 0.6918, 0.7652, 0.8293, 0.8841, 0.9297, 0.9667, 0.9958, 1.0179, 1.0338, 1.0446, 1.051, 1.0539, 1.0541, 1.0521, 1.0487, 1.0443, 1.0393, 1.0341, 1.0289, 1.0238, 1.0191, 1.0149, 1.0111, 1.0079, 1.0051, 1.0029, 1.0011, 0.9997, 0.9986, 0.9979, 0.9974, 0.9971, 0.9971, 0.9971, 0.9972, 0.9975, 0.9977, 1);
  --spring-sheet: linear(0, 0.0161, 0.0574, 0.115, 0.1821, 0.254, 0.3269, 0.3984, 0.4667, 0.5306, 0.5896, 0.6434, 0.6918, 0.735, 0.7732, 0.8069, 0.8363, 0.8618, 0.8838, 0.9028, 0.919, 0.9328, 0.9445, 0.9543, 0.9626, 0.9695, 0.9753, 0.9801, 0.984, 0.9873, 0.9899, 0.9921, 0.9938, 0.9952, 0.9964, 0.9973, 1);
  --dur-snappy: 390ms;
  --dur-smooth: 540ms;
  --dur-bouncy: 670ms;
  --dur-sheet: 520ms;
  /* r3 аттары — spring'дерге багытталат */
  --ease-spring: var(--spring-bouncy);
  --ease-spring-soft: var(--spring-snappy);
  --ease-sheet: var(--spring-sheet);
  --dur-1: 100ms; /* түс, hover, басуу */
  --dur-2: 180ms; /* fade, меню жабылышы, tooltip */
  --dur-3: 280ms; /* орто: индикатор, thumb, панель */
  --dur-4: 420ms; /* чоң: drawer, барак */
  --dur-reveal: 560ms; /* теманы алмаштыруу */
  --stagger: 24ms;

  /* Layers -------------------------------------------------------------------------------------- */
  --z-raised: 2;
  --z-sticky: 20;
  --z-scrim: 39;
  --z-sidebar: 40;
  --z-tabbar: 45;
  --z-inspector: 50;
  --z-overlay: 60;
  --z-tooltip: 90;
  --z-island: 95;
  --z-progress: 100;

  /* Layout -------------------------------------------------------------------------------------- */
  --sidebar-w: 248px; /* sidebar ПАНЕЛИНИН туурасы (8.3: колдонуучу 220–320 сүйрөп өзгөртөт) */
  --sidebar-inset: 8px; /* панелдин терезе четинен аралыгы (desktop) */
  --sidebar-col: calc(var(--sidebar-w) + 2 * var(--sidebar-inset)); /* grid колонкасы */
  --rail-w: 60px; /* жыйылган sidebar панели */
  --rail-col: calc(var(--rail-w) + 2 * var(--sidebar-inset));
  --topbar-h: 52px;
  --subbar-h: 44px;
  --tabbar-h: 62px; /* телефондун калкыма tab bar'ы */
  --inspector-w: clamp(400px, 36vw, 580px);
  --page-pad-x: 16px;
  --page-pad-y: 20px;
  --content-max: 1200px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);

  /* Controls ------------------------------------------------------------------------------------ */
  --control-h: 32px;
  --control-h-sm: 28px;
  --control-h-xs: 24px;
  --control-h-lg: 40px;
  --row-h: 30px; /* sidebar, меню пункттары */
  --row-h-list: 40px; /* тизме саптары */
  --hit-min: 44px; /* сенсордук максаттын минимуму */
  --icon-stroke: 2;

  /* Small glyph masks (use with `mask: var(--check-mask) center / contain no-repeat` + background) — r3'тогудай */
  --check-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
  --chevron-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 18 6-6-6-6'/%3E%3C/svg%3E");
  --chevron-left-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m15 18-6-6 6-6'/%3E%3C/svg%3E");

  /* Default tone ------------------------------------------------------------------------------- */
  --tone: var(--c-gray);
  --tone-solid: #8e8e93;
  --tone-ink: var(--c-gray-ink);
  --tone-soft: color-mix(in srgb, var(--tone) 14%, transparent);
  --tone-softer: color-mix(in srgb, var(--tone) 8%, transparent);
  --tone-line: color-mix(in srgb, var(--tone) 32%, transparent);
  --tone-on: #ffffff;
  --tone-gradient: linear-gradient(180deg, color-mix(in oklab, var(--tone-solid) 78%, white) 0%, var(--tone-solid) 100%);
}

:root[data-theme="light"],
:root[data-scheme="light"] { color-scheme: light; }
:root[data-theme="dark"],
:root[data-scheme="dark"] { color-scheme: dark; }

/* Сенсор (iOS HIG: 44 px максаттар) */
@media (pointer: coarse) {
  :root {
    --control-h: 40px;
    --control-h-sm: 34px;
    --control-h-xs: 30px;
    --control-h-lg: 50px;
    --row-h: 44px;
    --row-h-list: 52px;
    --switch-on: var(--c-green); /* iOS switch — жашыл */
  }
}

/* Телефон = iOS: ошол эле обой, 17 px негизги текст, 44 px nav bar */
@media (max-width: 767px) {
  :root {
    --surface-elevated: light-dark(#ffffff, #2c2d32);
    --topbar-h: 44px;
    --type-footnote: calc(0.8125rem * var(--text-scale)); /* 13 */
    --type-subhead: calc(0.9375rem * var(--text-scale)); /* 15 */
    --type-callout: calc(1rem * var(--text-scale)); /* 16 */
    --type-body: calc(1.0625rem * var(--text-scale)); /* 17 */
    --type-headline: calc(1.0625rem * var(--text-scale)); /* 17, 600 */
    --type-title3: calc(1.25rem * var(--text-scale)); /* 20 */
    --type-title2: calc(1.375rem * var(--text-scale)); /* 22 */
    --type-title1: calc(1.75rem * var(--text-scale)); /* 28 */
    --type-large: calc(2.125rem * var(--text-scale)); /* 34 */
  }
}
@media (min-width: 768px) {
  :root { --page-pad-x: 24px; --page-pad-y: 24px; }
}
@media (min-width: 1280px) {
  :root { --page-pad-x: 32px; --page-pad-y: 28px; }
}

/* Текст өлчөмү (Dynamic Type) */
:root[data-text-size="s"] { --text-scale: 0.94; }
:root[data-text-size="l"] { --text-scale: 1.08; }
:root[data-text-size="xl"] { --text-scale: 1.16; }

/* Терезе фокусту жоготкондо (macOS неактивдүү терезеси) — 8.8 */
:root.is-window-inactive {
  --sidebar-icon: var(--text-3);
  --selection-bg: var(--selection-muted);
  --selection-fg: var(--text);
}

/* Accent варианттары (13-бөлүм). Ар бир fill ак текст менен ≥ 4.7:1, ink ≥ 4.8:1 (Тиркеме C). */
:root[data-accent="blue"] { --accent: var(--accent-blue); --accent-solid: var(--accent-blue); --accent-ink: light-dark(#005cdf, #4da3ff); --chart-strong: light-dark(var(--accent-blue), #4da3ff); }
:root[data-accent="purple"] { --accent: var(--accent-purple); --accent-solid: var(--accent-purple); --accent-ink: light-dark(#9636c3, #cc6ffd); --chart-strong: light-dark(var(--accent-purple), #cc6ffd); }
:root[data-accent="pink"] { --accent: var(--accent-pink); --accent-solid: var(--accent-pink); --accent-ink: light-dark(#cc002e, #ff617a); --chart-strong: light-dark(var(--accent-pink), #ff617a); }
:root[data-accent="red"] { --accent: var(--accent-red); --accent-solid: var(--accent-red); --accent-ink: light-dark(#ce0000, #ff6554); --chart-strong: light-dark(var(--accent-red), #ff6554); }
:root[data-accent="orange"] { --accent: var(--accent-orange); --accent-solid: var(--accent-orange); --accent-ink: light-dark(#aa4700, #e57d00); --chart-strong: light-dark(var(--accent-orange), #e57d00); }
:root[data-accent="green"] { --accent: var(--accent-green); --accent-solid: var(--accent-green); --accent-ink: light-dark(#007700, #00af42); --chart-strong: light-dark(var(--accent-green), #00af42); }
:root[data-accent="graphite"] { --accent: var(--accent-graphite); --accent-solid: var(--accent-graphite); --accent-ink: light-dark(#65656a, #97979c); --chart-strong: light-dark(var(--accent-graphite), #97979c); }

/* Тунуктукту азайтуу: колдонуучу жөндөөсү + ОС жөндөөсү + backdrop-filter жок браузер */
:root[data-transparency="reduced"] {
  --mat-ultrathin: var(--surface-elevated);
  --mat-thin: var(--bg-sidebar);
  --mat-sidebar: var(--bg-sidebar);
  --mat-regular: var(--surface-elevated);
  --mat-thick: var(--surface-elevated);
  --mat-chrome: light-dark(#f6f7fa, #26272c);
  --mat-filter: none;
  --mat-filter-strong: none;
  --glass-sheen: none;
}
@media (prefers-reduced-transparency: reduce) {
  :root {
    --mat-ultrathin: var(--surface-elevated);
    --mat-thin: var(--bg-sidebar);
    --mat-sidebar: var(--bg-sidebar);
    --mat-regular: var(--surface-elevated);
    --mat-thick: var(--surface-elevated);
    --mat-chrome: light-dark(#f6f7fa, #26272c);
    --mat-filter: none;
    --mat-filter-strong: none;
    --glass-sheen: none;
  }
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :root {
    --mat-ultrathin: var(--surface-elevated);
    --mat-thin: var(--bg-sidebar);
    --mat-sidebar: var(--bg-sidebar);
    --mat-regular: var(--surface-elevated);
    --mat-thick: var(--surface-elevated);
    --mat-chrome: light-dark(#f6f7fa, #26272c);
  }
}

/* Жогорку контраст (ОС жөндөөсү) */
@media (prefers-contrast: more) {
  :root {
    --line: light-dark(rgb(0 0 0 / 0.3), rgb(255 255 255 / 0.32));
    --line-strong: light-dark(rgb(0 0 0 / 0.45), rgb(255 255 255 / 0.5));
    --line-subtle: light-dark(rgb(0 0 0 / 0.18), rgb(255 255 255 / 0.2));
    --card-ring: var(--line);
    --text-2: light-dark(#3a3a3f, #d1d1d6);
    --text-3: light-dark(#48484d, #c7c7cc);
    --mat-thin: var(--bg-sidebar);
    --mat-sidebar: var(--bg-sidebar);
    --mat-regular: var(--surface-elevated);
    --mat-thick: var(--surface-elevated);
    --mat-chrome: light-dark(#f6f7fa, #26272c);
    --mat-filter: none;
  }
}

/* linear() жок браузерлер — spring'дердин cubic-bezier жакындашуусу */
@supports not (transition-timing-function: linear(0, 1)) {
  :root {
    --spring-snappy: cubic-bezier(0.2, 1.1, 0.35, 1);
    --spring-smooth: cubic-bezier(0.22, 1, 0.36, 1);
    --spring-bouncy: cubic-bezier(0.34, 1.4, 0.64, 1);
    --spring-sheet: cubic-bezier(0.32, 0.72, 0, 1);
  }
}

/* Кыймылды азайтуу: ОС жөндөөсү ЖЕ колдонуучунун жөндөөсү (13-бөлүм) */
@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-1: 1ms; --dur-2: 1ms; --dur-3: 1ms; --dur-4: 1ms; --dur-reveal: 1ms; --stagger: 0ms;
    --dur-snappy: 1ms; --dur-smooth: 1ms; --dur-bouncy: 1ms; --dur-sheet: 1ms;
    --spring-snappy: linear; --spring-smooth: linear; --spring-bouncy: linear; --spring-sheet: linear;
  }
}
:root[data-motion="reduced"] {
  --dur-1: 1ms; --dur-2: 1ms; --dur-3: 1ms; --dur-4: 1ms; --dur-reveal: 1ms; --stagger: 0ms;
  --dur-snappy: 1ms; --dur-smooth: 1ms; --dur-bouncy: 1ms; --dur-sheet: 1ms;
  --spring-snappy: linear; --spring-smooth: linear; --spring-bouncy: linear; --spring-sheet: linear;
}
/* Колдонуучу «кыймылды азайт» тандаса — keyframe анимациялар да токтойт (медиа-суроосуз) */
:root[data-motion="reduced"] *,
:root[data-motion="reduced"] *::before,
:root[data-motion="reduced"] *::after {
  animation-duration: 1ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 1ms !important;
  scroll-behavior: auto !important;
}
/* Өзгөчөлүктөр: спиннер маалымат берет — жайыраак айлана берет; toast'тун убакыт тилкеси жашырылат */
:root[data-motion="reduced"] .spinner i {
  animation-duration: 2s !important;
  animation-iteration-count: infinite !important;
}
:root[data-motion="reduced"] .toast__progress { display: none !important; }

/* --------------------------------------------------------------------------------------------------
   3. Color tones — any element with data-color="<palette name>" sets --tone (vivid), --tone-ink
      (readable text), --tone-soft / --tone-softer (tinted backgrounds), --tone-line (borders) and
      --tone-solid (saturated fill that keeps its light-mode value in dark mode — avatars, icon tiles,
      solid chips with white text, like iOS) and --tone-on (text on a solid tone). Components read
      these variables.
   -------------------------------------------------------------------------------------------------- */
[data-color="blue"] { --tone: var(--c-blue); --tone-ink: var(--c-blue-ink); --tone-solid: #007aff; }
[data-color="indigo"] { --tone: var(--c-indigo); --tone-ink: var(--c-indigo-ink); --tone-solid: #5856d6; }
[data-color="purple"] { --tone: var(--c-purple); --tone-ink: var(--c-purple-ink); --tone-solid: #af52de; }
[data-color="pink"] { --tone: var(--c-pink); --tone-ink: var(--c-pink-ink); --tone-solid: #ff2d55; }
[data-color="red"] { --tone: var(--c-red); --tone-ink: var(--c-red-ink); --tone-solid: #ff3b30; }
[data-color="orange"] { --tone: var(--c-orange); --tone-ink: var(--c-orange-ink); --tone-solid: #ff9500; }
[data-color="yellow"] { --tone: var(--c-yellow); --tone-ink: var(--c-yellow-ink); --tone-solid: #ffcc00; }
[data-color="green"] { --tone: var(--c-green); --tone-ink: var(--c-green-ink); --tone-solid: #34c759; }
[data-color="mint"] { --tone: var(--c-mint); --tone-ink: var(--c-mint-ink); --tone-solid: #00c7be; }
[data-color="teal"] { --tone: var(--c-teal); --tone-ink: var(--c-teal-ink); --tone-solid: #30b0c7; }
[data-color="cyan"] { --tone: var(--c-cyan); --tone-ink: var(--c-cyan-ink); --tone-solid: #32ade6; }
[data-color="brown"] { --tone: var(--c-brown); --tone-ink: var(--c-brown-ink); --tone-solid: #a2845e; }
[data-color="gray"] { --tone: var(--c-gray); --tone-ink: var(--c-gray-ink); --tone-solid: #8e8e93; }
[data-color="accent"] { --tone: var(--accent); --tone-ink: var(--accent-ink); --tone-solid: var(--accent-solid); }
[data-color] {
  --tone-soft: color-mix(in srgb, var(--tone) 14%, transparent);
  --tone-softer: color-mix(in srgb, var(--tone) 8%, transparent);
  --tone-line: color-mix(in srgb, var(--tone) 32%, transparent);
  --tone-on: #ffffff;
  --tone-gradient: linear-gradient(180deg, color-mix(in oklab, var(--tone-solid) 78%, white) 0%, var(--tone-solid) 100%);
}
[data-color="yellow"],
[data-color="mint"] { --tone-on: rgb(0 0 0 / 0.78); }

/* --------------------------------------------------------------------------------------------------
   4. Reset & base elements
   -------------------------------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  tab-size: 4;
  scroll-padding-top: calc(var(--topbar-h) + var(--safe-top) + 16px);
  scrollbar-color: var(--fill-3) transparent;
  hanging-punctuation: first last;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: transparent; /* обой html'де (shell.css) — canvas'ка fixed тартылат */
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-normal);
  font-synthesis-weight: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-snug);
  letter-spacing: var(--tracking-snug);
  text-wrap: balance;
}
p,
ul,
ol,
dl,
dd,
figure,
blockquote,
pre {
  margin: 0;
}
ul[role="list"],
ol[role="list"],
ul.plain,
ol.plain {
  list-style: none;
  padding: 0;
}
p {
  text-wrap: pretty;
}

a {
  color: inherit;
  text-decoration: none;
}
img,
video,
canvas,
picture {
  display: block;
  max-width: 100%;
}
img {
  height: auto;
}
svg {
  flex-shrink: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}
button:disabled {
  cursor: not-allowed;
}
input,
select,
textarea {
  margin: 0;
}
table {
  border-collapse: collapse;
}
hr {
  height: 0;
  margin: var(--space-4) 0;
  border: 0;
  border-top: 1px solid var(--line);
}
code,
kbd,
samp,
pre {
  font-family: var(--font-mono);
  font-size: 0.92em;
}
abbr[title] {
  text-decoration: underline dotted;
  cursor: help;
}
[hidden] {
  display: none !important;
}
[x-cloak] {
  display: none !important;
}
dialog {
  color: inherit;
}

/* Focus: visible accent outline (keyboard only) — :focus-visible is set by the native-feel rules below. */
:focus {
  outline: none;
}

/* Native feel (r4): chrome text is not selectable; controls use the arrow cursor (macOS). */
:where(button, [role="button"], .btn, .nav-item, .tabbar__item, .menu__item, .segmented__item, .view-tab, summary, .task-card, .task-row, .list-item) {
  cursor: default;
}
:where(.sidebar, .topbar, .subbar, .tabbar, .menu__panel, .btn, .segmented, .chip) {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
/* …but fields inside chrome stay editable/selectable (older iOS Safari blocks typing otherwise). */
:where(.sidebar, .topbar, .subbar, .tabbar, .menu__panel) :where(input, textarea, [contenteditable="true"]) {
  -webkit-user-select: text;
  user-select: text;
}
:where(.prose a, a.link, .link) { cursor: pointer; }
::selection { background: color-mix(in srgb, var(--accent) 26%, transparent); }
:focus-visible {
  outline: 2.5px solid var(--focus-outline);
  outline-offset: 1.5px;
}

/* Thin, subtle scrollbars for inner scroll containers (overlay scrollbars on macOS/iOS anyway). */
* {
  scrollbar-width: thin;
}

/* Links in running text */
.link,
.prose a {
  color: var(--accent-ink);
  text-decoration: none;
  border-radius: 2px;
}
.link:hover,
.prose a:hover {
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

/* --------------------------------------------------------------------------------------------------
   4b. Materials — Liquid Glass. Колдонуу: 4.1-таблица. Айнек тек калкыма катмарларда.
   -------------------------------------------------------------------------------------------------- */
.glass,
.glass--thin,
.glass--regular,
.glass--thick,
.glass--chrome {
  -webkit-backdrop-filter: var(--mat-filter);
  backdrop-filter: var(--mat-filter);
  border: 0.5px solid var(--glass-border);
  box-shadow: var(--glass-rim), var(--shadow-md);
}
.glass,
.glass--regular { background: var(--glass-sheen), var(--mat-regular); }
.glass--thin { background: var(--glass-sheen), var(--mat-thin); box-shadow: var(--glass-rim), var(--shadow-sm); }
.glass--thick { background: var(--glass-sheen), var(--mat-thick); box-shadow: var(--glass-rim), var(--shadow-lg); }
.glass--chrome { background: var(--mat-chrome); box-shadow: var(--glass-rim), var(--shadow-lg); }

/* Капсула: toolbar'дагы баскычтар тобу (8.5) */
.glass-capsule {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 36px;
  padding: 2px;
  border-radius: var(--radius-full);
  background: var(--glass-sheen), var(--mat-thin);
  -webkit-backdrop-filter: var(--mat-filter);
  backdrop-filter: var(--mat-filter);
  border: 0.5px solid var(--glass-border);
  box-shadow: var(--glass-rim), var(--shadow-sm);
}
.glass-capsule > .btn--icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
}

/* Reduce transparency (user setting or OS): no blur anywhere — also on the r3 components that still
   hard-code a backdrop-filter until their phase moves them onto --mat-filter. */
:root[data-transparency="reduced"] *,
:root[data-transparency="reduced"] *::before,
:root[data-transparency="reduced"] *::after {
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}
@media (prefers-reduced-transparency: reduce) {
  *,
  *::before,
  *::after {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }
}

/* --------------------------------------------------------------------------------------------------
   5. Typography helpers
   -------------------------------------------------------------------------------------------------- */
.display {
  font-family: var(--font-display);
  font-size: var(--fs-display);
  font-weight: var(--fw-bold);
  line-height: 1.05;
  letter-spacing: -0.03em;
}
/* r4 · 5.3: Apple text styles. Sizes come from --type-* (they grow on phones and with
   data-text-size); use these in new markup. */
.t-large { font-family: var(--font-display); font-size: var(--type-large); font-weight: var(--fw-bold); line-height: 1.12; letter-spacing: var(--tracking-tight); }
.t-title1 { font-family: var(--font-display); font-size: var(--type-title1); font-weight: var(--fw-bold); line-height: 1.2; letter-spacing: var(--tracking-tight); }
.t-title2 { font-family: var(--font-display); font-size: var(--type-title2); font-weight: var(--fw-semibold); line-height: 1.25; letter-spacing: var(--tracking-snug); }
.t-title3 { font-size: var(--type-title3); font-weight: var(--fw-semibold); line-height: 1.3; letter-spacing: var(--tracking-snug); }
.t-headline { font-size: var(--type-headline); font-weight: var(--fw-semibold); line-height: 1.35; }
.t-body { font-size: var(--type-body); line-height: var(--lh-normal); }
.t-callout { font-size: var(--type-callout); line-height: 1.4; }
.t-subhead { font-size: var(--type-subhead); line-height: 1.4; color: var(--text-2); }
.t-footnote { font-size: var(--type-footnote); line-height: 1.35; color: var(--text-3); }
.t-caption { font-size: var(--type-caption); font-weight: var(--fw-medium); line-height: 1.3; letter-spacing: 0.005em; }
.t-caption2 { font-size: var(--type-caption2); font-weight: var(--fw-medium); line-height: 1.25; letter-spacing: 0.005em; }
.t-number { font-family: var(--font-rounded); font-variant-numeric: tabular-nums; font-weight: var(--fw-bold); letter-spacing: -0.01em; }
@media (max-width: 767px) {
  .t-large { line-height: 1.2; }
  .t-body { line-height: 1.3; }
}

/* r3 names, kept for existing markup — now on the r4 scale (same metrics as the .t-* styles). */
.large-title {
  font-family: var(--font-display);
  font-size: var(--type-large);
  font-weight: var(--fw-bold);
  line-height: 1.12;
  letter-spacing: var(--tracking-tight);
}
.title-1 {
  font-family: var(--font-display);
  font-size: var(--type-title1);
  font-weight: var(--fw-bold);
  line-height: 1.2;
  letter-spacing: var(--tracking-tight);
}
.title-2 {
  font-family: var(--font-display);
  font-size: var(--type-title2);
  font-weight: var(--fw-semibold);
  line-height: 1.25;
  letter-spacing: var(--tracking-snug);
}
.title-3 {
  font-size: var(--type-title3);
  font-weight: var(--fw-semibold);
  line-height: 1.3;
  letter-spacing: var(--tracking-snug);
}
.headline {
  font-size: var(--type-headline);
  font-weight: var(--fw-semibold);
  line-height: 1.35;
}
@media (max-width: 767px) {
  .large-title { line-height: 1.2; }
}
.subhead {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
}
.eyebrow {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.02em;
  color: var(--text-2);
}
.text-2xs { font-size: var(--fs-2xs); }
.text-xs { font-size: var(--fs-xs); }
.text-sm { font-size: var(--fs-sm); }
.text-md { font-size: var(--fs-md); }
.text-lg { font-size: var(--fs-lg); }
.text-xl { font-size: var(--fs-xl); }
.text-2 { color: var(--text-2); }
.text-3 { color: var(--text-3); }
.text-accent { color: var(--accent-ink); }
.text-danger { color: var(--danger-ink); }
.text-success { color: var(--success-ink); }
.text-tone { color: var(--tone-ink); }
.fw-medium { font-weight: var(--fw-medium); }
.fw-semibold { font-weight: var(--fw-semibold); }
.fw-bold { font-weight: var(--fw-bold); }
.tabular { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); }
.nowrap { white-space: nowrap; }
.truncate {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.line-clamp-2,
.line-clamp-3 {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}
.line-clamp-3 {
  -webkit-line-clamp: 3;
  line-clamp: 3;
}

/* Rich text (markdown output) */
.prose {
  font-size: var(--fs-md);
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.prose > * + * {
  margin-top: 0.75em;
}
.prose h1,
.prose h2,
.prose h3 {
  margin-top: 1.25em;
  font-size: var(--fs-xl);
}
.prose ul,
.prose ol {
  padding-left: 1.4em;
}
.prose li + li {
  margin-top: 0.25em;
}
.prose blockquote {
  padding-left: var(--space-3);
  border-left: 3px solid var(--line-strong);
  color: var(--text-2);
}
.prose code {
  padding: 0.1em 0.35em;
  border-radius: 5px;
  background: var(--fill-1);
}
.prose pre {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
  overflow-x: auto;
}
.prose pre code {
  padding: 0;
  background: none;
}
.prose img {
  border-radius: var(--radius-md);
}
.prose .mention {
  padding: 0 0.25em;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: var(--fw-medium);
}

/* --------------------------------------------------------------------------------------------------
   6. Icons — {% icon "name" size=16 %} renders <svg class="icon"><use href="sprite#name"/></svg>.
      Color = currentColor. Stroke width: --icon-stroke (default 2, in 24-unit space).
   -------------------------------------------------------------------------------------------------- */
.icon {
  display: inline-block;
  flex-shrink: 0;
  vertical-align: middle;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon--thin {
  --icon-stroke: 1.6;
}
.icon--bold {
  --icon-stroke: 2.4;
}
.icon.spin {
  animation: spin 0.9s linear infinite;
}
/* r4 · 6.2: the selected destination's glyph is "filled" (iOS .fill symbols) — closed outlines get a
   soft tint of the stroke color (the sprite's symbols read fill: var(--icon-fill, none)). */
.tabbar__item.is-active .icon,
.nav-item.is-active > .icon {
  --icon-fill: currentColor;
  fill-opacity: 0.18;
}

/* --------------------------------------------------------------------------------------------------
   7. Layout utilities (small, composable — prefer components for anything bigger)
   -------------------------------------------------------------------------------------------------- */
.stack {
  display: flex;
  flex-direction: column;
  gap: var(--stack-gap, var(--space-3));
}
.stack-xs { --stack-gap: var(--space-1); }
.stack-sm { --stack-gap: var(--space-2); }
.stack-lg { --stack-gap: var(--space-5); }
.stack-xl { --stack-gap: var(--space-8); }
.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--cluster-gap, var(--space-2));
}
.row {
  display: flex;
  align-items: center;
  gap: var(--row-gap, var(--space-2));
  min-width: 0;
}
.row--between { justify-content: space-between; }
.row--end { justify-content: flex-end; }
.row--top { align-items: flex-start; }
.spacer { flex: 1 1 auto; }
.grow { flex: 1 1 auto; min-width: 0; }
.shrink-0 { flex-shrink: 0; }
.grid-auto {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(var(--grid-min, 260px), 100%), 1fr));
  gap: var(--grid-gap, var(--space-4));
}
.container {
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
}
.container--narrow { --content-max: 760px; }
.container--medium { --content-max: 960px; }
.container--wide { --content-max: 1440px; }
.w-full { width: 100%; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }

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

/* Responsive visibility */
@media (max-width: 639px) {
  .hide-xs { display: none !important; }
}
@media (max-width: 767px) {
  .hide-mobile { display: none !important; }
}
@media (min-width: 768px) {
  .only-mobile { display: none !important; }
}
@media (max-width: 1023px) {
  .only-desktop { display: none !important; }
}
@media (min-width: 1024px) {
  .hide-desktop { display: none !important; }
}
@media (pointer: fine) { .only-touch { display: none !important; } }

/* Platform-aware modifier key: <span class="mod-key"></span>K → ⌘K on Apple, Ctrl K elsewhere. */
.mod-key::before {
  content: "Ctrl\00a0";
}
:root.is-apple .mod-key::before {
  content: "\2318";
}

/* --------------------------------------------------------------------------------------------------
   8. Motion — keyframes, scroll reveal, page (view) transitions
   -------------------------------------------------------------------------------------------------- */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes fade-in {
  from {
    opacity: 0;
  }
}
@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}
@keyframes pop {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.18);
  }
  100% {
    transform: scale(1);
  }
}
@keyframes shimmer {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(100%);
  }
}

/* Scroll reveal: [data-reveal] fades/slides in once visible (app.js adds .is-revealed and staggers
   siblings through --reveal-delay). Content is never hidden without JS (base.html drops
   .js-reveal if app.js did not start) or with reduced motion. */
@media (prefers-reduced-motion: no-preference) {
  :root.js-reveal [data-reveal]:not(.is-revealed) {
    opacity: 0;
    transform: translateY(12px);
  }
  :root.js-reveal [data-reveal] {
    transition:
      opacity var(--dur-4) var(--ease-out) var(--reveal-delay, 0ms),
      transform var(--dur-4) var(--ease-out) var(--reveal-delay, 0ms);
  }
}

/* Cross-document page transitions (Chrome/Edge/Safari 18+). Named parts of the app shell
   (view-transition-name: sidebar, tabbar — see shell.css) stay put; the page content (`page`)
   fades out quickly and the new one rises in; the project view-tab indicator morphs between tabs.
   Names must be unique per page — do not reuse these names in feature CSS. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition {
    navigation: auto;
  }
  ::view-transition-group(root) {
    animation-duration: 200ms;
  }
  /* Kept short: the page is not clickable while a view transition runs. */
  ::view-transition-old(page) {
    animation: 110ms var(--ease-out) both vt-fade-out;
  }
  ::view-transition-new(page) {
    animation: 240ms var(--ease-out) 40ms both vt-rise-in;
  }
  ::view-transition-group(view-tab-indicator) {
    animation-duration: 380ms;
    animation-timing-function: var(--ease-spring);
  }
}
/* Theme switch (same-document view transition started by App.theme.set): only the root is
   captured and the new theme spreads from the control as a circle (app.js animates clip-path on
   ::view-transition-new(root), ~520 ms). Reduced motion / no View Transitions → instant. */
:root.vt-theme * {
  view-transition-name: none !important;
}
:root.vt-theme::view-transition-group(root) {
  animation: none;
}
:root.vt-theme::view-transition-image-pair(root) {
  isolation: auto;
}
:root.vt-theme::view-transition-old(root),
:root.vt-theme::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}
@keyframes vt-fade-in {
  from {
    opacity: 0;
  }
}
@keyframes vt-fade-out {
  to {
    opacity: 0;
  }
}
@keyframes vt-rise-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* htmx: content swapped in by a user action settles in (app.js adds .swap-enter to the target of
   innerHTML swaps that are not polling/morph/dialog swaps; opt out with [data-no-enter]). */
@media (prefers-reduced-motion: no-preference) {
  .swap-enter {
    animation: swap-enter var(--dur-3) var(--ease-out);
  }
}
@keyframes swap-enter {
  from {
    opacity: 0.35;
    transform: translateY(4px);
  }
}

/* Phones: iOS push / pop (r4 · 7.6). Types are added in base.html (pagereveal). */
@media (max-width: 767px) and (prefers-reduced-motion: no-preference) {
  html:active-view-transition-type(push, pop) {
    --vt-dur: var(--dur-smooth);
  }
  html:active-view-transition-type(push, pop)::view-transition-group(page) {
    animation: none;
  }
  html:active-view-transition-type(push)::view-transition-old(page) {
    animation: var(--vt-dur) var(--spring-smooth) both vt-push-old;
  }
  html:active-view-transition-type(push)::view-transition-new(page) {
    animation: var(--vt-dur) var(--spring-smooth) both vt-push-new;
  }
  html:active-view-transition-type(pop)::view-transition-old(page) {
    z-index: 1;
    animation: var(--vt-dur) var(--spring-smooth) both vt-pop-old;
  }
  html:active-view-transition-type(pop)::view-transition-new(page) {
    animation: var(--vt-dur) var(--spring-smooth) both vt-pop-new;
  }
  html:active-view-transition-type(tab)::view-transition-old(page) {
    animation: 90ms ease-out both vt-fade-out;
  }
  html:active-view-transition-type(tab)::view-transition-new(page) {
    animation: 160ms ease-out both vt-fade-in;
  }
}
@keyframes vt-push-old {
  to {
    transform: translateX(-30%);
    opacity: 0.55;
  }
}
@keyframes vt-push-new {
  from {
    transform: translateX(100%);
  }
}
@keyframes vt-pop-old {
  to {
    transform: translateX(100%);
  }
}
@keyframes vt-pop-new {
  from {
    transform: translateX(-30%);
    opacity: 0.55;
  }
}
