/* everything — the core stylesheet.
 *
 * Material You–style design system shared by the shell and every app. Apps get
 * it for free (the shell loads it) and only add what is specific to them.
 *
 *   1. color: one seed (hue + chroma) → tonal roles, light & dark
 *   2. shape, type, motion tokens
 *   3. base elements
 *   4. shell (top bar, wallpaper, content area)
 *   5. app layout: .app > .side + .pane(s)
 *   6. components: buttons, fields, search, segmented, chips, cards, lists,
 *      menus, dialogs, snackbars, tables, empty states, progress
 *
 * The seed comes from the user's wallpaper (or a chosen color) and is set by
 * theme.js as --seed-h / --seed-c (OKLCH hue in degrees, chroma 0–0.37).
 */

/* ---- 1. color ------------------------------------------------------------------ */
:root {
  --seed-h: 268;
  --seed-c: 0.13;
  /* chroma per palette, derived from the seed like Material's "tonal spot" */
  --pc: clamp(0.02, var(--seed-c), 0.15);          /* primary */
  --sc: calc(var(--pc) * 0.32 + 0.005);             /* secondary */
  --th: calc(var(--seed-h) + 60);                   /* tertiary hue */
  --tc: calc(var(--pc) * 0.55 + 0.01);              /* tertiary */
  --nc: calc(var(--pc) * 0.06 + 0.003);             /* neutral */
  --nvc: calc(var(--pc) * 0.16 + 0.006);            /* neutral variant */
  color-scheme: light;

  --md-primary: oklch(0.49 var(--pc) var(--seed-h));
  --md-on-primary: oklch(1 0 0);
  --md-primary-container: oklch(0.92 calc(var(--pc) * 0.42) var(--seed-h));
  --md-on-primary-container: oklch(0.29 calc(var(--pc) * 0.8) var(--seed-h));
  --md-secondary: oklch(0.5 var(--sc) var(--seed-h));
  --md-on-secondary: oklch(1 0 0);
  --md-secondary-container: oklch(0.915 calc(var(--sc) * 1.1) var(--seed-h));
  --md-on-secondary-container: oklch(0.29 var(--sc) var(--seed-h));
  --md-tertiary: oklch(0.5 var(--tc) var(--th));
  --md-tertiary-container: oklch(0.92 calc(var(--tc) * 0.5) var(--th));
  --md-on-tertiary-container: oklch(0.29 var(--tc) var(--th));
  --md-error: oklch(0.51 0.19 27);
  --md-on-error: oklch(1 0 0);
  --md-error-container: oklch(0.93 0.045 22);
  --md-on-error-container: oklch(0.32 0.12 27);
  --md-success: oklch(0.52 0.12 152);
  --md-success-container: oklch(0.92 0.06 152);
  --md-warning: oklch(0.62 0.13 75);

  --md-surface: oklch(0.987 var(--nc) var(--seed-h));
  --md-surface-dim: oklch(0.89 var(--nc) var(--seed-h));
  --md-surface-container-lowest: oklch(1 0 0);
  --md-surface-container-low: oklch(0.966 var(--nc) var(--seed-h));
  --md-surface-container: oklch(0.948 calc(var(--nc) * 1.2) var(--seed-h));
  --md-surface-container-high: oklch(0.93 calc(var(--nc) * 1.3) var(--seed-h));
  --md-surface-container-highest: oklch(0.912 calc(var(--nc) * 1.4) var(--seed-h));
  --md-on-surface: oklch(0.22 var(--nc) var(--seed-h));
  --md-on-surface-variant: oklch(0.43 var(--nvc) var(--seed-h));
  --md-outline: oklch(0.6 var(--nvc) var(--seed-h));
  --md-outline-variant: oklch(0.86 var(--nvc) var(--seed-h));
  --md-inverse-surface: oklch(0.3 var(--nc) var(--seed-h));
  --md-inverse-on-surface: oklch(0.95 var(--nc) var(--seed-h));
  --md-inverse-primary: oklch(0.82 calc(var(--pc) * 0.8) var(--seed-h));
  --md-scrim: oklch(0.15 0.01 var(--seed-h));
  --md-shadow-rgb: 20 20 30;
  --state: var(--md-on-surface);                    /* state-layer color */
  --wall-scrim: 74%;                                /* how much surface covers the wallpaper */
}

/* dark scheme: the same roles at dark tones (kept in sync in both blocks) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --md-primary: oklch(0.82 calc(var(--pc) * 0.75) var(--seed-h));
    --md-on-primary: oklch(0.3 calc(var(--pc) * 0.75) var(--seed-h));
    --md-primary-container: oklch(0.38 calc(var(--pc) * 0.75) var(--seed-h));
    --md-on-primary-container: oklch(0.93 calc(var(--pc) * 0.38) var(--seed-h));
    --md-secondary: oklch(0.83 var(--sc) var(--seed-h));
    --md-on-secondary: oklch(0.3 var(--sc) var(--seed-h));
    --md-secondary-container: oklch(0.36 var(--sc) var(--seed-h));
    --md-on-secondary-container: oklch(0.92 var(--sc) var(--seed-h));
    --md-tertiary: oklch(0.83 calc(var(--tc) * 0.75) var(--th));
    --md-tertiary-container: oklch(0.38 calc(var(--tc) * 0.75) var(--th));
    --md-on-tertiary-container: oklch(0.93 calc(var(--tc) * 0.4) var(--th));
    --md-error: oklch(0.8 0.1 22);
    --md-on-error: oklch(0.32 0.12 27);
    --md-error-container: oklch(0.4 0.13 27);
    --md-on-error-container: oklch(0.92 0.04 22);
    --md-success: oklch(0.78 0.11 152);
    --md-success-container: oklch(0.38 0.07 152);
    --md-warning: oklch(0.82 0.12 80);
    --md-surface: oklch(0.175 var(--nc) var(--seed-h));
    --md-surface-dim: oklch(0.175 var(--nc) var(--seed-h));
    --md-surface-container-lowest: oklch(0.145 var(--nc) var(--seed-h));
    --md-surface-container-low: oklch(0.2 var(--nc) var(--seed-h));
    --md-surface-container: oklch(0.22 calc(var(--nc) * 1.2) var(--seed-h));
    --md-surface-container-high: oklch(0.255 calc(var(--nc) * 1.3) var(--seed-h));
    --md-surface-container-highest: oklch(0.29 calc(var(--nc) * 1.4) var(--seed-h));
    --md-on-surface: oklch(0.92 var(--nc) var(--seed-h));
    --md-on-surface-variant: oklch(0.8 var(--nvc) var(--seed-h));
    --md-outline: oklch(0.64 var(--nvc) var(--seed-h));
    --md-outline-variant: oklch(0.4 var(--nvc) var(--seed-h));
    --md-inverse-surface: oklch(0.92 var(--nc) var(--seed-h));
    --md-inverse-on-surface: oklch(0.3 var(--nc) var(--seed-h));
    --md-inverse-primary: oklch(0.49 var(--pc) var(--seed-h));
    --md-shadow-rgb: 0 0 0;
    --wall-scrim: 70%;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --md-primary: oklch(0.82 calc(var(--pc) * 0.75) var(--seed-h));
  --md-on-primary: oklch(0.3 calc(var(--pc) * 0.75) var(--seed-h));
  --md-primary-container: oklch(0.38 calc(var(--pc) * 0.75) var(--seed-h));
  --md-on-primary-container: oklch(0.93 calc(var(--pc) * 0.38) var(--seed-h));
  --md-secondary: oklch(0.83 var(--sc) var(--seed-h));
  --md-on-secondary: oklch(0.3 var(--sc) var(--seed-h));
  --md-secondary-container: oklch(0.36 var(--sc) var(--seed-h));
  --md-on-secondary-container: oklch(0.92 var(--sc) var(--seed-h));
  --md-tertiary: oklch(0.83 calc(var(--tc) * 0.75) var(--th));
  --md-tertiary-container: oklch(0.38 calc(var(--tc) * 0.75) var(--th));
  --md-on-tertiary-container: oklch(0.93 calc(var(--tc) * 0.4) var(--th));
  --md-error: oklch(0.8 0.1 22);
  --md-on-error: oklch(0.32 0.12 27);
  --md-error-container: oklch(0.4 0.13 27);
  --md-on-error-container: oklch(0.92 0.04 22);
  --md-success: oklch(0.78 0.11 152);
  --md-success-container: oklch(0.38 0.07 152);
  --md-warning: oklch(0.82 0.12 80);
  --md-surface: oklch(0.175 var(--nc) var(--seed-h));
  --md-surface-dim: oklch(0.175 var(--nc) var(--seed-h));
  --md-surface-container-lowest: oklch(0.145 var(--nc) var(--seed-h));
  --md-surface-container-low: oklch(0.2 var(--nc) var(--seed-h));
  --md-surface-container: oklch(0.22 calc(var(--nc) * 1.2) var(--seed-h));
  --md-surface-container-high: oklch(0.255 calc(var(--nc) * 1.3) var(--seed-h));
  --md-surface-container-highest: oklch(0.29 calc(var(--nc) * 1.4) var(--seed-h));
  --md-on-surface: oklch(0.92 var(--nc) var(--seed-h));
  --md-on-surface-variant: oklch(0.8 var(--nvc) var(--seed-h));
  --md-outline: oklch(0.64 var(--nvc) var(--seed-h));
  --md-outline-variant: oklch(0.4 var(--nvc) var(--seed-h));
  --md-inverse-surface: oklch(0.92 var(--nc) var(--seed-h));
  --md-inverse-on-surface: oklch(0.3 var(--nc) var(--seed-h));
  --md-inverse-primary: oklch(0.49 var(--pc) var(--seed-h));
  --md-shadow-rgb: 0 0 0;
  --wall-scrim: 70%;
}

/* ---- 2. tokens + short aliases (apps use these) -------------------------------------- */
:root {
  /* aliases: --accent = primary, --surface = the content pane, --bg = behind it */
  --accent: var(--md-primary);
  --on-accent: var(--md-on-primary);
  --accent-2: color-mix(in oklab, var(--md-primary) 88%, var(--md-on-surface));
  --accent-soft: var(--md-secondary-container);
  --on-accent-soft: var(--md-on-secondary-container);
  --bg: var(--md-surface-container);
  --surface: var(--md-surface);
  --surface-2: var(--md-surface-container-high);
  --surface-low: var(--md-surface-container-low);
  --text: var(--md-on-surface);
  --muted: var(--md-on-surface-variant);
  --border: var(--md-outline-variant);
  --hover: color-mix(in srgb, var(--state) 8%, transparent);
  --press: color-mix(in srgb, var(--state) 12%, transparent);
  --danger: var(--md-error);
  --danger-soft: var(--md-error-container);
  --ok: var(--md-success);
  --star: oklch(0.78 0.16 80);

  /* shape */
  --r-xs: 4px; --r-s: 8px; --r-m: 12px; --r-l: 16px; --r-xl: 28px; --r-full: 999px;
  --radius: var(--r-m); --radius-s: var(--r-s);
  --pane-r: 24px;
  /* elevation (M3 uses tone first, shadow second) */
  --shadow: 0 1px 2px rgb(var(--md-shadow-rgb) / .12), 0 1px 3px 1px rgb(var(--md-shadow-rgb) / .06);
  --shadow-2: 0 1px 2px rgb(var(--md-shadow-rgb) / .14), 0 2px 6px 2px rgb(var(--md-shadow-rgb) / .08);
  --shadow-l: 0 4px 8px 3px rgb(var(--md-shadow-rgb) / .12), 0 1px 3px rgb(var(--md-shadow-rgb) / .2);
  /* motion */
  --ease: cubic-bezier(.2, 0, 0, 1);
  --ease-out: cubic-bezier(.05, .7, .1, 1);
  --t-fast: .15s; --t: .25s;
  /* layout */
  --topbar: 64px;
  --side-w: 264px;
  --gap: 12px;
  /* file-type colors: all Material You primary, so they follow the seed color and light/dark */
  --ico-folder: var(--md-primary); --ico-image: var(--md-primary); --ico-video: var(--md-primary);
  --ico-audio: var(--md-primary); --ico-archive: var(--md-primary); --ico-pdf: var(--md-primary);
  --ico-text: var(--md-primary); --ico-code: var(--md-primary);

  font-family: "Google Sans Text", "Google Sans", Roboto, "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px; line-height: 1.43; letter-spacing: .01em;
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ---- 3. base ----------------------------------------------------------------------- */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { overflow: hidden; background: var(--bg); }
#root { height: 100%; }
button, input, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 500; letter-spacing: 0; font-family: "Google Sans", Roboto, "Segoe UI", system-ui, sans-serif; }
h1 { font-size: 22px; line-height: 28px; font-weight: 400; }
h2 { font-size: 16px; line-height: 24px; }
h3 { font-size: 14px; line-height: 20px; }
p { margin: 0 0 .75em; }
::selection { background: color-mix(in srgb, var(--md-primary) 28%, transparent); }
:focus-visible { outline: 2px solid var(--md-primary); outline-offset: 2px; }
code, .mono { font-family: "Roboto Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; }
kbd { font: 500 11.5px/1.6 inherit; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: var(--r-xs); padding: 0 5px; background: var(--surface-low); }
* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--muted) 40%, transparent) transparent; }
.muted { color: var(--muted); }
.grow { flex: 1; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.center { display: grid; place-items: center; height: 100%; padding: 2rem; text-align: center; }
.small { font-size: 12px; }
.hide-s { }
.only-s { display: none; }
.danger-text, .danger-text .icon { color: var(--danger) !important; }
.error { color: var(--danger); min-height: 1em; margin: 8px 0 0; font-size: 13px; }
.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon.small { width: 16px; height: 16px; }
.icon.big { width: 96px; height: 96px; stroke-width: 1; }

/* ---- 4. shell ---------------------------------------------------------------------- */
.shell { display: flex; flex-direction: column; height: 100%; background: var(--bg); transition: background-color var(--t) var(--ease); }
/* the wallpaper shows around the content, softened by the surface tone */
:root.has-wall .shell, :root.has-wall .auth {
  background: linear-gradient(color-mix(in srgb, var(--md-surface-container) var(--wall-scrim), transparent) 0 0),
    var(--wall) center / cover no-repeat fixed, var(--bg);
}
.topbar { height: var(--topbar); flex: none; display: flex; align-items: center; gap: 4px; padding: 0 12px 0 16px; }
.brand { display: flex; align-items: center; gap: 10px; font: 500 20px/1 "Google Sans", Roboto, system-ui, sans-serif; color: var(--text); letter-spacing: 0; }
.brand.big { font-size: 24px; justify-content: center; padding-bottom: 12px; }
.logo { width: 28px; height: 28px; border-radius: 9px; background: var(--md-primary); position: relative; flex: none; }
.logo::after { content: ""; position: absolute; inset: 7px; border: 2.5px solid var(--md-on-primary); border-radius: 50%; }
.brand.big .logo { width: 36px; height: 36px; border-radius: 11px; }
.brand.big .logo::after { inset: 9px; border-width: 3px; }
.appbar { display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.app-icon { position: relative; display: grid; place-items: center; width: 56px; height: 40px; border-radius: var(--r-full); color: var(--muted); flex: none;
  transition: background-color var(--t-fast), color var(--t-fast); }
.app-icon .icon { width: 22px; height: 22px; }
.app-icon:hover { background: var(--hover); color: var(--text); }
.app-icon.active { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.app-icon.active .icon { stroke-width: 2.1; }
.user-btn { display: flex; align-items: center; gap: 8px; padding: 4px 14px 4px 4px; height: 40px; border-radius: var(--r-full); border: 0; background: none; cursor: pointer; }
.user-btn:hover, .user-btn.active { background: var(--hover); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--md-primary); color: var(--md-on-primary); display: grid; place-items: center; font-size: 14px; font-weight: 500; flex: none; }
.avatar.small { width: 24px; height: 24px; font-size: 11px; }
.main { flex: 1; min-height: 0; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.topbar .agent-btn { margin-right: 4px; }
.agent-btn.active { background: var(--md-primary-container); color: var(--md-on-primary-container); }

/* ---- 5. app layout -------------------------------------------------------------------
 * <div class="app">                 full height row
 *   <nav class="side">              navigation drawer, sits on the shell background
 *     .side-head  (h2 + actions)   .side-fab (primary action)   .side-scroll
 *     .side-label  .nav-item[.active] > icon .nav-label .nav-count .nav-more
 *   <section class="pane">          rounded content surface (one or more)
 *     <header class="bar"> .side-toggle  h1 …actions </header>
 * On narrow screens .side becomes an off-canvas drawer: any .side-toggle opens it
 * (wired once in shell.js); the scrim, a nav link or a route change closes it.
 */
.app { display: flex; height: 100%; min-height: 0; gap: var(--gap); padding: 0 var(--gap) var(--gap) 0; position: relative; }
.app.no-side { padding-left: var(--gap); }
.side { width: var(--side-w); flex: none; display: flex; flex-direction: column; min-height: 0; padding: 0 0 0 var(--gap); }
.side-head { display: flex; align-items: center; gap: 4px; padding: 6px 4px 10px 16px; min-height: 52px; }
.side-head h2 { flex: 1; font-size: 18px; font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-fab { align-self: flex-start; margin: 4px 0 14px; }
.side-scroll { flex: 1; overflow-y: auto; min-height: 0; padding-bottom: 12px; display: flex; flex-direction: column; gap: 2px; }
.side-label { font-size: 12px; font-weight: 500; letter-spacing: .05em; color: var(--muted); padding: 18px 16px 6px; display: flex; align-items: center; gap: 4px; }
.side-label .icon-btn { width: 28px; height: 28px; margin: -6px -8px -6px auto; }
.side-foot { padding: 8px 16px 4px; font-size: 12px; color: var(--muted); }
.nav-item { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px 0 16px; border-radius: var(--r-full); color: var(--text);
  border: 0; background: none; cursor: pointer; text-align: left; width: 100%; position: relative; font-weight: 500; letter-spacing: .01em;
  transition: background-color var(--t-fast); }
.nav-item > .icon { color: var(--muted); width: 20px; height: 20px; }
.nav-item:hover { background: var(--hover); }
.nav-item.active { background: var(--md-secondary-container); color: var(--md-on-secondary-container); font-weight: 600; }
.nav-item.active > .icon { color: var(--md-on-secondary-container); }
.nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-count { font-size: 12px; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
.nav-item.active .nav-count { color: var(--md-on-secondary-container); }
.nav-more { display: none; width: 28px; height: 28px; margin-right: -6px; }
.nav-more .icon { width: 18px; height: 18px; }
.nav-item:hover .nav-more, .nav-item:focus-within .nav-more { display: inline-grid; }
.nav-item:hover .nav-more ~ .nav-count, .nav-item:hover .nav-count:has(~ .nav-more) { display: none; }
.pane { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--surface); border-radius: var(--pane-r); overflow: hidden; position: relative; }
.pane.fixed { flex: none; }
.bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px 8px 24px; min-height: 64px; flex: none; }
.bar h1 { font-size: 22px; font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.bar.divided { border-bottom: 1px solid var(--border); }
.side-toggle { display: none !important; }

@media (max-width: 860px) {
  :root { --gap: 8px; --pane-r: 20px; }
  .app { padding-left: var(--gap); }
  .side { position: absolute; z-index: 30; top: 0; bottom: 0; left: 0; width: min(300px, 86vw); padding: 12px; background: var(--md-surface-container-low);
    border-radius: 0 var(--r-l) var(--r-l) 0; box-shadow: var(--shadow-l); transform: translateX(-105%); transition: transform var(--t) var(--ease); }
  .app.side-open .side { transform: none; }
  .app.side-open::after { content: ""; position: absolute; inset: 0; z-index: 29; background: color-mix(in srgb, var(--md-scrim) 32%, transparent); animation: fade var(--t-fast); }
  .side-toggle { display: inline-grid !important; }
  .bar { padding-left: 8px; }
  .hide-s { display: none !important; }
  .only-s { display: inline-grid; }
}

/* simple scrolling page (settings & co) */
.page { overflow: auto; height: 100%; }
.page-inner { max-width: 880px; margin: 0 auto; padding: 24px 24px 64px; }
.page-inner > h1 { font-size: 28px; line-height: 36px; margin: 8px 0 24px; }
.page-inner.narrow { max-width: 480px; padding-top: 8vh; }

/* ---- 6. components --------------------------------------------------------------------- */

/* buttons: .btn (outlined) · .primary (filled) · .tonal · .ghost (text) · .danger · .small · .block */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 20px; border-radius: var(--r-full);
  border: 1px solid var(--md-outline); background: transparent; color: var(--md-primary); cursor: pointer; font-weight: 500; letter-spacing: .01em;
  white-space: nowrap; position: relative; transition: background-color var(--t-fast), box-shadow var(--t-fast); text-decoration: none; }
.btn .icon { width: 18px; height: 18px; margin-left: -4px; }
.btn:hover { background: color-mix(in srgb, var(--md-primary) 8%, transparent); }
.btn:active { background: color-mix(in srgb, var(--md-primary) 12%, transparent); }
.btn:disabled { opacity: .38; cursor: default; background: transparent; box-shadow: none; }
.btn.primary { background: var(--md-primary); border-color: transparent; color: var(--md-on-primary); }
.btn.primary:hover { background: color-mix(in srgb, var(--md-on-primary) 8%, var(--md-primary)); box-shadow: var(--shadow); }
.btn.primary:disabled { background: color-mix(in srgb, var(--md-on-surface) 12%, transparent); color: var(--md-on-surface); }
.btn.tonal { background: var(--md-secondary-container); border-color: transparent; color: var(--md-on-secondary-container); }
.btn.tonal:hover { background: color-mix(in srgb, var(--md-on-secondary-container) 8%, var(--md-secondary-container)); box-shadow: var(--shadow); }
.btn.ghost { border-color: transparent; padding: 0 12px; }
.btn.ghost .icon { margin-left: 0; }
.btn.danger { background: var(--md-error); border-color: transparent; color: var(--md-on-error); }
.btn.danger:hover { background: color-mix(in srgb, var(--md-on-error) 8%, var(--md-error)); }
.btn.small { height: 32px; padding: 0 14px; font-size: 13px; }
.btn.ghost.small { padding: 0 10px; }
.btn.block { width: 100%; height: 44px; }
/* floating action button (extended when it has a label) */
.fab { display: inline-flex; align-items: center; gap: 12px; height: 56px; min-width: 56px; padding: 0 20px 0 16px; border-radius: var(--r-l); border: 0;
  background: var(--md-primary-container); color: var(--md-on-primary-container); font-weight: 500; cursor: pointer; box-shadow: var(--shadow-2);
  transition: box-shadow var(--t-fast), background-color var(--t-fast); white-space: nowrap; }
.fab:hover { box-shadow: var(--shadow-l); background: color-mix(in srgb, var(--md-on-primary-container) 8%, var(--md-primary-container)); }
.fab .icon { width: 24px; height: 24px; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 0; background: none; cursor: pointer; color: var(--muted); flex: none;
  transition: background-color var(--t-fast), color var(--t-fast); text-decoration: none; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn:active { background: var(--press); }
.icon-btn:disabled { opacity: .38; cursor: default; background: none; }
.icon-btn.on { color: var(--md-primary); }
.icon-btn.filled { background: var(--md-primary); color: var(--md-on-primary); }
.icon-btn.tonal { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.icon-btn.small { width: 32px; height: 32px; }
.icon-btn.small .icon { width: 18px; height: 18px; }

/* fields */
.label { display: block; font-size: 12px; font-weight: 500; letter-spacing: .03em; color: var(--muted); margin: 14px 0 6px; }
.input { width: 100%; min-height: 44px; padding: 10px 14px; border: 1px solid var(--md-outline); border-radius: var(--r-s); background: transparent; color: var(--text);
  outline: none; transition: border-color var(--t-fast), box-shadow var(--t-fast); }
.input:hover { border-color: var(--md-on-surface); }
.input:focus { border-color: var(--md-primary); box-shadow: inset 0 0 0 1px var(--md-primary); }
.input::placeholder { color: var(--muted); opacity: .8; }
textarea.input { line-height: 1.5; resize: vertical; }
select.input { appearance: none; padding-right: 36px; cursor: pointer;
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E") right 10px center / 20px no-repeat; }
select.input option { background: var(--md-surface-container-high); color: var(--text); }
.input.small { min-height: 36px; padding: 6px 12px; }
.check { width: 18px; height: 18px; accent-color: var(--md-primary); cursor: pointer; margin: 0; }
/* search bar: <div class="search"> icon + input.search-input */
.search { position: relative; display: flex; align-items: center; min-width: 0; }
.search > .icon { position: absolute; left: 16px; color: var(--muted); width: 20px; height: 20px; pointer-events: none; }
.search-input, .input.search-input { width: 100%; height: 48px; min-height: 0; border: 0; border-radius: var(--r-full); background: var(--md-surface-container-high); padding: 0 18px 0 48px;
  color: var(--text); outline: none; transition: background-color var(--t-fast), box-shadow var(--t-fast); }
.search-input:hover { background: color-mix(in srgb, var(--state) 6%, var(--md-surface-container-high)); border: 0; }
.search-input:focus { background: var(--md-surface-container-lowest); box-shadow: var(--shadow-2); border: 0; }
.search.compact .search-input { height: 40px; padding-left: 42px; }
.search.compact > .icon { left: 13px; width: 18px; height: 18px; }

/* segmented button: <div class="seg"> button(.on) … */
.seg { display: inline-flex; flex: none; border: 1px solid var(--md-outline); border-radius: var(--r-full); overflow: hidden; height: 36px; }
.seg button { border: 0; background: none; padding: 0 14px; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--text); display: inline-flex; align-items: center; gap: 6px; }
.seg button + button { border-left: 1px solid var(--md-outline); }
.seg button:hover { background: var(--hover); }
.seg button.on { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.seg button.on::before { content: ""; width: 12px; height: 7px; border: solid currentColor; border-width: 0 0 2px 2px; transform: translateY(-2px) rotate(-45deg); margin-right: 2px; }
.seg button:disabled { opacity: .38; cursor: default; }
.seg.no-check button.on::before { display: none; }

/* chips: .chip (assist/filter) · .on (selected) */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 14px; border-radius: var(--r-s); border: 1px solid var(--md-outline-variant);
  background: transparent; color: var(--text); font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; max-width: 100%; }
.chip:hover { background: var(--hover); }
.chip.on { background: var(--md-secondary-container); color: var(--md-on-secondary-container); border-color: transparent; }
.chip .icon { width: 16px; height: 16px; }
.badge { display: inline-flex; align-items: center; height: 20px; font-size: 11px; font-weight: 600; padding: 0 8px; border-radius: var(--r-full);
  background: var(--md-secondary-container); color: var(--md-on-secondary-container); white-space: nowrap; }
.badge.error, .badge.danger { background: var(--md-error-container); color: var(--md-on-error-container); }
.badge.tertiary { background: var(--md-tertiary-container); color: var(--md-on-tertiary-container); }

/* cards */
.card { background: var(--md-surface-container-low); border-radius: var(--r-l); padding: 20px 24px; margin-bottom: 16px; }
.card.outlined { background: var(--surface); border: 1px solid var(--border); }
.card.elevated { background: var(--md-surface-container-low); box-shadow: var(--shadow); }
.card h2 { font-size: 16px; margin-bottom: 12px; display: flex; align-items: center; gap: 10px; }
.card h2 .icon { color: var(--md-primary); }

/* lists */
.list-item { display: flex; align-items: center; gap: 16px; min-height: 56px; padding: 8px 16px; color: var(--text); cursor: pointer; position: relative; }
.list-item:hover { background: var(--hover); }
.list-item.active, .list-item.sel { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.divider { height: 1px; background: var(--border); border: 0; margin: 8px 0; }

/* tables */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 8px 12px; border-bottom: 1px solid var(--border); }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.table tr:last-child td { border-bottom: 0; }

/* empty states: <div class="empty"> icon h3 p [button] */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px; padding: 64px 24px; color: var(--muted); flex: 1; }
.empty > .icon { width: 64px; height: 64px; padding: 16px; border-radius: 50%; background: var(--md-surface-container-high); color: var(--md-primary); stroke-width: 1.6; margin-bottom: 8px; }
.empty h2, .empty h3 { color: var(--text); font-size: 22px; line-height: 28px; font-weight: 400; }
.empty p { margin: 0; max-width: 420px; }
.empty .btn { margin-top: 12px; }

/* progress */
.spinner { width: 20px; height: 20px; border: 2.5px solid color-mix(in srgb, var(--md-primary) 22%, transparent); border-top-color: var(--md-primary); border-radius: 50%;
  animation: spin .9s linear infinite; flex: none; }
.spinner.small { width: 14px; height: 14px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { height: 4px; border-radius: 2px; background: var(--md-secondary-container); overflow: hidden; }
.progress > div { height: 100%; background: var(--md-primary); border-radius: 2px; transition: width var(--t) var(--ease); }

/* dialogs */
.modal-back { position: fixed; inset: 0; background: color-mix(in srgb, var(--md-scrim) 40%, transparent); display: grid; place-items: center; padding: 16px; z-index: 50; animation: fade var(--t-fast); }
.modal { background: var(--md-surface-container-high); color: var(--text); border-radius: var(--r-xl); box-shadow: var(--shadow-l); width: 100%; max-width: 440px;
  max-height: calc(100vh - 32px); display: flex; flex-direction: column; animation: pop var(--t) var(--ease-out); }
.modal.wide { max-width: 640px; }
.modal header { display: flex; align-items: center; gap: 8px; padding: 20px 16px 4px 24px; }
.modal header h2 { flex: 1; font-size: 22px; line-height: 28px; font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-body { padding: 8px 24px 16px; overflow: auto; }
.modal-body > .label:first-child { margin-top: 4px; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 8px 24px 24px; }
.modal footer .btn:not(.primary):not(.danger):not(.tonal) { border-color: transparent; padding: 0 12px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.94) translateY(8px); } }

/* menus */
.menu { position: fixed; z-index: 60; min-width: 200px; max-width: 320px; background: var(--md-surface-container); border-radius: var(--r-s); box-shadow: var(--shadow-l);
  padding: 8px 0; animation: menu-in var(--t-fast) var(--ease-out); transform-origin: top; max-height: calc(100vh - 16px); overflow-y: auto; }
@keyframes menu-in { from { opacity: 0; transform: scaleY(.9); } }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 8px 0; }
.menu-item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 0 16px 0 14px; border: 0; background: none; cursor: pointer; text-align: left; color: var(--text); }
.menu-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item:hover, .menu-item:focus { background: var(--hover); outline: none; }
.menu-item .icon { color: var(--muted); }
.menu-item.danger, .menu-item.danger .icon { color: var(--danger); }
.menu-item:disabled { opacity: .38; cursor: default; }

/* snackbars */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 70; align-items: center; pointer-events: none; }
.toast { background: var(--md-inverse-surface); color: var(--md-inverse-on-surface); padding: 14px 20px; border-radius: var(--r-xs); box-shadow: var(--shadow-l);
  max-width: min(560px, 90vw); animation: pop var(--t) var(--ease-out); transition: opacity .3s; }
.toast.error { background: var(--md-error-container); color: var(--md-on-error-container); }
.toast.ok::before { content: "✓  "; color: var(--md-inverse-primary); font-weight: 700; }
.toast.out { opacity: 0; }

/* picker list (shared by dialogs) */
.picker-list { border: 1px solid var(--border); border-radius: var(--r-m); margin: 10px 0; max-height: 300px; overflow: auto; background: var(--surface); }
.picker-item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 8px 16px; border: 0; border-bottom: 1px solid var(--border); background: none; cursor: pointer; text-align: left; color: var(--text); }
.picker-item:last-child { border-bottom: 0; }
.picker-item:hover { background: var(--hover); }
.picker-item span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-empty { padding: 24px; text-align: center; margin: 0; }

/* color swatches */
.swatches { display: flex; flex-wrap: wrap; gap: 12px; }
.swatch { position: relative; width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--sw); cursor: pointer; display: grid; place-items: center;
  color: #fff; box-shadow: inset 0 0 0 1px rgb(0 0 0 / .1); transition: transform var(--t-fast) var(--ease); padding: 0; }
.swatch:hover { transform: scale(1.06); }
.swatch.on { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--sw); }
.swatch.custom { background: conic-gradient(#e44, #ec3, #4c6, #3ae, #84e, #e4a, #e44); }
.swatch.custom.on { background: var(--sw); }
.swatch .icon { filter: drop-shadow(0 0 2px rgb(0 0 0 / .5)); }
.swatch input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
/* Material-You style palette swatch: quarter of each role around a circle */
.swatch.palette { background: conic-gradient(var(--s1) 0 25%, var(--s2) 0 50%, var(--s3) 0 75%, var(--s4) 0); }

/* sign-in */
.auth { display: grid; place-items: center; height: 100%; padding: 16px; background: var(--bg); }
.auth-card { width: 100%; max-width: 400px; background: var(--md-surface-container-low); border-radius: var(--r-xl); padding: 36px 32px 28px; box-shadow: var(--shadow-2); display: flex; flex-direction: column; }
.auth-card .btn { margin-top: 20px; }

@media (max-width: 720px) {
  :root { --topbar: 56px; }
  .topbar { padding: 0 6px 0 10px; gap: 0; }
  .brand-name, .user-name { display: none; }
  .user-btn { padding: 4px; }
  .app-icon { width: 48px; }
}
