/* ============================================================
   kodo.css — self-contained Kōdō dashboard stylesheet
   Generated for the Go web server (internal/web).

   Contents:
     1. Webfonts (Geist + Geist Mono) — self-hosted @font-face from /static/, no CDN
     2. Design tokens  — colors (light + .theme-dark), typography, spacing
     3. Component CSS  — Card, Button, Badge, Avatar, StatusDot, ActivityRow,
                         StatTile, Banner, Switch, Select, Input, PinInput,
                         ChatBubble, Toast  (classes: .kdo-*)
     4. Layout CSS     — app shell, sidebar, topbar, all dashboard views,
                         Ask drawer  (classes: .kdo-side / .kdo-main / .kdo-view ...)

   The product UI is DARK: put class="theme-dark" on <html> (or <body>).
   Light theme is the default :root scope (marketing / setup surfaces).
   ============================================================ */

/* ---------- 1. Webfonts (self-hosted, offline-tolerant) ----------
   Variable woff2 served from /static/ — the dashboard makes zero external
   font calls. One file per family covers every weight (100–900). */
@font-face {
  font-family: 'Geist';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/static/geist-variable.woff2') format('woff2');
}
@font-face {
  font-family: 'Geist Mono';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/static/geist-mono-variable.woff2') format('woff2');
}

/* ============================================================
   2. DESIGN TOKENS
   ============================================================ */

/* ---- colors ---- */
:root {
  /* ---- Neutral ramp (cool-tinted slate, 0=white → 1000=near-black) ---- */
  --n-0:    #ffffff;
  --n-25:   #fafbfc;
  --n-50:   #f4f6f9;
  --n-100:  #eceff3;
  --n-150:  #e1e6ec;
  --n-200:  #d4dae2;
  --n-300:  #b7c0cc;
  --n-400:  #939dab;
  --n-500:  #6e7886;
  --n-600:  #535d6b;
  --n-700:  #3b434f;
  --n-800:  #272d37;
  --n-850:  #1c212a;
  --n-900:  #141921;
  --n-950:  #0d1116;
  --n-1000: #07090c;

  /* ---- Brand: azure-indigo (network, intelligence, trust) ---- */
  --brand-50:  #eef2ff;
  --brand-100: #dde5ff;
  --brand-200: #bccdff;
  --brand-300: #93acff;
  --brand-400: #6486ff;
  --brand-500: #3f63f5;  /* primary */
  --brand-600: #2f4ee0;
  --brand-700: #2640bd;
  --brand-800: #233a97;
  --brand-900: #1f3477;

  /* ---- Pulse: emerald (healthy, protected, "allow", WhatsApp affinity) ---- */
  --pulse-50:  #e6f9f1;
  --pulse-100: #c4f0de;
  --pulse-200: #92e3c3;
  --pulse-300: #54d1a3;
  --pulse-400: #21b986;
  --pulse-500: #0fa877;  /* allow / healthy */
  --pulse-600: #0b8c63;
  --pulse-700: #0a6f50;

  /* ---- Danger: red ("block", violation) ---- */
  --danger-50:  #fdecec;
  --danger-100: #fbd5d6;
  --danger-200: #f6b0b2;
  --danger-300: #f1888b;
  --danger-500: #ef4d52;  /* block */
  --danger-600: #dc363e;
  --danger-700: #b8262f;

  /* ---- Warning: amber ("silent" / bypass / attention) ---- */
  --warn-50:  #fdf4e3;
  --warn-100: #fbe7bf;
  --warn-200: #f7d488;
  --warn-300: #f6c65f;
  --warn-500: #f5a524;  /* warning */
  --warn-600: #e0890c;
  --warn-700: #b86b08;

  /* ============================================================
     SEMANTIC ALIASES — LIGHT (default)
     ============================================================ */

  /* Surfaces */
  --bg:             var(--n-25);
  --surface:        var(--n-0);
  --surface-2:      var(--n-50);
  --surface-sunken: var(--n-100);
  --surface-inset:  var(--n-50);

  /* Borders / lines */
  --border:         var(--n-150);
  --border-strong:  var(--n-200);
  --border-faint:   var(--n-100);

  /* Text */
  --text:           var(--n-900);
  --text-secondary: var(--n-600);
  --text-muted:     var(--n-500);
  --text-faint:     var(--n-400);
  --text-on-brand:  #ffffff;
  --text-link:      var(--brand-600);

  /* Brand */
  --brand:          var(--brand-500);
  --brand-hover:    var(--brand-600);
  --brand-active:   var(--brand-700);
  --brand-subtle:   var(--brand-50);
  --brand-subtle-2: var(--brand-100);
  --on-brand:       #ffffff;

  /* Status — foreground */
  --allow:          var(--pulse-600);
  --block:          var(--danger-600);
  --warn:           var(--warn-700);
  --info:           var(--brand-600);

  /* Status — subtle fills (badges, pills, banners) */
  --allow-bg:       var(--pulse-50);
  --allow-border:   var(--pulse-200);
  --block-bg:       var(--danger-50);
  --block-border:   var(--danger-200);
  --warn-bg:        var(--warn-50);
  --warn-border:    var(--warn-200);
  --info-bg:        var(--brand-50);
  --info-border:    var(--brand-200);

  /* Interaction */
  --focus-ring:     color-mix(in oklab, var(--brand-500) 45%, transparent);
  --hover-overlay:  color-mix(in oklab, var(--n-1000) 5%, transparent);
  --press-overlay:  color-mix(in oklab, var(--n-1000) 9%, transparent);

  /* WhatsApp surface (conversational interface kit) */
  --wa-bubble-in:   #ffffff;
  --wa-bubble-out:  #d9fdd3;
  --wa-bg:          #efeae2;
  --wa-header:      #f0f2f5;
  --wa-tick:        #53bdeb;
}

/* ============================================================
   SEMANTIC ALIASES — DARK (product dashboard surface)
   Single-selector scope so the compiler indexes it as a theme.
   ============================================================ */

.theme-dark {
  --bg:             var(--n-1000);
  --surface:        var(--n-900);
  --surface-2:      var(--n-850);
  --surface-sunken: var(--n-950);
  --surface-inset:  #10141b;

  --border:         var(--n-800);
  --border-strong:  var(--n-700);
  --border-faint:   #181d25;

  --text:           var(--n-50);
  --text-secondary: var(--n-300);
  --text-muted:     var(--n-400);
  --text-faint:     var(--n-500);
  --text-on-brand:  #ffffff;
  --text-link:      var(--brand-300);

  --brand:          var(--brand-500);
  --brand-hover:    var(--brand-400);
  --brand-active:   var(--brand-300);
  --brand-subtle:   color-mix(in oklab, var(--brand-500) 16%, var(--n-900));
  --brand-subtle-2: color-mix(in oklab, var(--brand-500) 26%, var(--n-900));

  --allow:          var(--pulse-400);
  --block:          var(--danger-500);
  --warn:           var(--warn-500);
  --info:           var(--brand-400);

  --allow-bg:       color-mix(in oklab, var(--pulse-500) 16%, var(--n-900));
  --allow-border:   color-mix(in oklab, var(--pulse-500) 38%, var(--n-900));
  --block-bg:       color-mix(in oklab, var(--danger-500) 16%, var(--n-900));
  --block-border:   color-mix(in oklab, var(--danger-500) 40%, var(--n-900));
  --warn-bg:        color-mix(in oklab, var(--warn-500) 15%, var(--n-900));
  --warn-border:    color-mix(in oklab, var(--warn-500) 40%, var(--n-900));
  --info-bg:        color-mix(in oklab, var(--brand-500) 16%, var(--n-900));
  --info-border:    color-mix(in oklab, var(--brand-500) 40%, var(--n-900));

  --focus-ring:     color-mix(in oklab, var(--brand-400) 55%, transparent);
  --hover-overlay:  color-mix(in oklab, #ffffff 6%, transparent);
  --press-overlay:  color-mix(in oklab, #ffffff 10%, transparent);
}

/* ---- typography ---- */
:root {
  /* ---- Families ---- */
  --font-sans: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, monospace;
  --font-display: 'Geist', -apple-system, system-ui, sans-serif;

  /* ---- Type scale (px) ---- */
  --text-2xs:  11px;
  --text-xs:   12px;
  --text-sm:   13px;
  --text-base: 15px;
  --text-md:   16px;
  --text-lg:   18px;
  --text-xl:   21px;
  --text-2xl:  26px;
  --text-3xl:  33px;
  --text-4xl:  42px;
  --text-5xl:  54px;
  --text-6xl:  68px;
  --text-7xl:  88px;

  /* ---- Weights ---- */
  --weight-light:    300;
  --weight-regular:  400;
  --weight-medium:   500;
  --weight-semibold: 600;
  --weight-bold:     700;
  --weight-black:    800;

  /* ---- Line heights ---- */
  --leading-none:    1;
  --leading-tight:   1.12;
  --leading-snug:    1.28;
  --leading-normal:  1.5;
  --leading-relaxed: 1.65;

  /* ---- Letter spacing ---- */
  --tracking-tighter: -0.03em;
  --tracking-tight:   -0.015em;
  --tracking-normal:  0;
  --tracking-wide:    0.02em;
  --tracking-wider:   0.06em;
  --tracking-caps:    0.12em;
}

/* ---- spacing / radius / elevation / motion ---- */
:root {
  /* ---- Spacing (4px base) ---- */
  --space-0:   0;
  --space-1:   2px;
  --space-2:   4px;
  --space-3:   6px;
  --space-4:   8px;
  --space-5:   12px;
  --space-6:   16px;
  --space-7:   20px;
  --space-8:   24px;
  --space-9:   32px;
  --space-10:  40px;
  --space-11:  48px;
  --space-12:  64px;
  --space-13:  80px;
  --space-14:  96px;
  --space-15:  128px;

  /* ---- Radius ---- */
  --radius-xs:   4px;
  --radius-sm:   6px;
  --radius-md:   8px;
  --radius-lg:   12px;
  --radius-xl:   16px;
  --radius-2xl:  20px;
  --radius-3xl:  28px;
  --radius-full: 999px;

  /* ---- Borders ---- */
  --border-width: 1px;

  /* ---- Elevation (light surfaces) ---- */
  --shadow-xs: 0 1px 2px rgba(13, 17, 22, 0.06);
  --shadow-sm: 0 1px 2px rgba(13, 17, 22, 0.06), 0 2px 6px rgba(13, 17, 22, 0.05);
  --shadow-md: 0 2px 4px rgba(13, 17, 22, 0.05), 0 6px 16px rgba(13, 17, 22, 0.08);
  --shadow-lg: 0 8px 24px rgba(13, 17, 22, 0.10), 0 2px 6px rgba(13, 17, 22, 0.06);
  --shadow-xl: 0 18px 48px rgba(13, 17, 22, 0.16), 0 4px 12px rgba(13, 17, 22, 0.08);
  --shadow-brand: 0 6px 20px color-mix(in oklab, var(--brand-500) 30%, transparent);

  /* ---- Elevation (dark surfaces) ---- */
  --shadow-dark-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-dark-md: 0 4px 14px rgba(0, 0, 0, 0.5);
  --shadow-dark-lg: 0 16px 40px rgba(0, 0, 0, 0.6);

  /* ---- Motion ---- */
  --ease-out:    cubic-bezier(0.22, 1, 0.36, 1); /* @kind other */
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1); /* @kind other */
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1); /* @kind other */
  --dur-fast:    120ms; /* @kind other */
  --dur-base:    200ms; /* @kind other */
  --dur-slow:    320ms; /* @kind other */
  --dur-slower:  520ms; /* @kind other */

  /* ---- Layout ---- */
  --container-sm:  640px;
  --container-md:  860px;
  --container-lg:  1100px;
  --container-xl:  1280px;
}

/* ============================================================
   3. COMPONENT CSS  (extracted from the design-system bundle)
   ============================================================ */
.kdo-avatar { position: relative; display: inline-flex; align-items: center; justify-content: center;
      color: #fff; font-family: var(--font-sans); font-weight: var(--weight-semibold); border-radius: 50%;
      flex-shrink: 0; letter-spacing: 0.01em; }
    .kdo-avatar--sm { width: 28px; height: 28px; font-size: 11px; }
    .kdo-avatar--md { width: 38px; height: 38px; font-size: 14px; }
    .kdo-avatar--lg { width: 52px; height: 52px; font-size: 18px; }
    .kdo-avatar__status { position: absolute; right: -1px; bottom: -1px; width: 32%; height: 32%;
      border-radius: 50%; border: 2px solid var(--surface); }
    .kdo-avatar__status--online { background: var(--pulse-500); }
    .kdo-avatar__status--offline { background: var(--n-400); }
    .kdo-avatar__status--blocked { background: var(--danger-500); }
  

    .kdo-badge { display: inline-flex; align-items: center; gap: 5px; font-family: var(--font-sans);
      font-size: var(--text-xs); font-weight: var(--weight-semibold); line-height: 1.4;
      padding: 2px 8px; border-radius: var(--radius-xs); border: 1px solid transparent; white-space: nowrap; }
    .kdo-badge__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
    .kdo-badge--block { background: var(--block-bg); color: var(--block); border-color: var(--block-border); }
    .kdo-badge--allow { background: var(--allow-bg); color: var(--allow); border-color: var(--allow-border); }
    .kdo-badge--warn  { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-border); }
    .kdo-badge--person { background: var(--info-bg); color: var(--info); border-color: var(--info-border); }
    .kdo-badge--category { background: var(--surface-sunken); color: var(--text-secondary); border-color: var(--border); }
    .kdo-badge--age { background: var(--surface-sunken); color: var(--text-muted); border-color: var(--border); font-family: var(--font-mono); }
    .kdo-badge--neutral { background: var(--surface-sunken); color: var(--text-secondary); border-color: var(--border); }
  

    .kdo-btn {
      display: inline-flex; align-items: center; justify-content: center; gap: var(--space-4);
      font-family: var(--font-sans); font-weight: var(--weight-semibold); line-height: 1;
      border: 1px solid transparent; border-radius: var(--radius-md); cursor: pointer;
      white-space: nowrap; transition: background var(--dur-fast) var(--ease-out),
        border-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out),
        transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
      -webkit-tap-highlight-color: transparent; user-select: none;
    }
    .kdo-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus-ring); }
    .kdo-btn:active:not(:disabled) { transform: translateY(0.5px) scale(0.99); }
    .kdo-btn:disabled { opacity: 0.45; cursor: not-allowed; }
    .kdo-btn__icon { display: inline-flex; }
    .kdo-btn__icon svg { display: block; width: 1.15em; height: 1.15em; }

    .kdo-btn--sm { font-size: var(--text-sm); padding: 7px 12px; border-radius: var(--radius-sm); }
    .kdo-btn--md { font-size: var(--text-base); padding: 10px 16px; }
    .kdo-btn--lg { font-size: var(--text-md); padding: 13px 22px; border-radius: var(--radius-lg); }
    .kdo-btn--full { width: 100%; }

    .kdo-btn--primary { background: var(--brand); color: var(--on-brand); }
    .kdo-btn--primary:hover:not(:disabled) { background: var(--brand-hover); }
    .kdo-btn--primary:active:not(:disabled) { background: var(--brand-active); }

    .kdo-btn--secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
    .kdo-btn--secondary:hover:not(:disabled) { background: var(--surface-2); border-color: var(--n-300); }

    .kdo-btn--ghost { background: transparent; color: var(--text-secondary); }
    .kdo-btn--ghost:hover:not(:disabled) { background: var(--hover-overlay); color: var(--text); }

    .kdo-btn--danger { background: var(--danger-500); color: #fff; }
    .kdo-btn--danger:hover:not(:disabled) { background: var(--danger-600); }

    .kdo-btn--success { background: var(--pulse-500); color: #fff; }
    .kdo-btn--success:hover:not(:disabled) { background: var(--pulse-600); }
  

    .kdo-iconbtn { display: inline-flex; align-items: center; justify-content: center;
      border: 1px solid transparent; border-radius: var(--radius-md); cursor: pointer; color: var(--text-secondary);
      transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out),
        border-color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
      -webkit-tap-highlight-color: transparent; }
    .kdo-iconbtn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus-ring); }
    .kdo-iconbtn:active:not(:disabled) { transform: scale(0.93); }
    .kdo-iconbtn:disabled { opacity: 0.4; cursor: not-allowed; }
    .kdo-iconbtn svg { display: block; width: 1.25em; height: 1.25em; }
    .kdo-iconbtn--sm { width: 30px; height: 30px; font-size: 14px; }
    .kdo-iconbtn--md { width: 38px; height: 38px; font-size: 16px; }
    .kdo-iconbtn--lg { width: 46px; height: 46px; font-size: 19px; border-radius: var(--radius-lg); }
    .kdo-iconbtn--ghost:hover:not(:disabled) { background: var(--hover-overlay); color: var(--text); }
    .kdo-iconbtn--subtle { background: var(--surface-2); color: var(--text-secondary); }
    .kdo-iconbtn--subtle:hover:not(:disabled) { background: var(--surface-sunken); color: var(--text); }
    .kdo-iconbtn--solid { background: var(--brand); color: var(--on-brand); }
    .kdo-iconbtn--solid:hover:not(:disabled) { background: var(--brand-hover); }
    .kdo-iconbtn--danger { background: var(--block-bg); color: var(--block); border-color: var(--block-border); }
    .kdo-iconbtn--danger:hover:not(:disabled) { background: var(--danger-500); color: #fff; border-color: var(--danger-500); }
  

    .kdo-status { display: inline-flex; align-items: center; gap: 7px; font-family: var(--font-sans);
      font-size: var(--text-sm); color: var(--text-secondary); }
    .kdo-status__dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; position: relative; }
    .kdo-status__dot--ok { background: var(--pulse-500); }
    .kdo-status__dot--down { background: var(--danger-500); }
    .kdo-status__dot--warn { background: var(--warn-500); }
    .kdo-status__dot--idle { background: var(--n-400); }
    .kdo-status__dot.is-pulse::after { content: ''; position: absolute; inset: 0; border-radius: 50%;
      background: var(--pulse-500); animation: kdo-status-pulse 1.8s var(--ease-out) infinite; }
    @keyframes kdo-status-pulse { 0% { transform: scale(1); opacity: 0.6; } 70%,100% { transform: scale(2.6); opacity: 0; } }
    @media (prefers-reduced-motion: reduce) { .kdo-status__dot.is-pulse::after { animation: none; } }
  

    .kdo-banner { display: flex; align-items: flex-start; gap: 12px; font-family: var(--font-sans);
      padding: 13px 14px; border-radius: var(--radius-lg); border: 1px solid; }
    .kdo-banner__icon { display: inline-flex; flex-shrink: 0; margin-top: 1px; }
    .kdo-banner__icon svg { width: 18px; height: 18px; display: block; }
    .kdo-banner__body { flex: 1; min-width: 0; }
    .kdo-banner__title { font-size: var(--text-base); font-weight: var(--weight-semibold); line-height: 1.35; }
    .kdo-banner__text { font-size: var(--text-sm); line-height: 1.45; opacity: 0.92; margin-top: 2px; }
    .kdo-banner__action { flex-shrink: 0; }
    .kdo-banner__close { background: transparent; border: 0; cursor: pointer; color: inherit; opacity: 0.6;
      padding: 2px; display: inline-flex; border-radius: var(--radius-xs); }
    .kdo-banner__close:hover { opacity: 1; }
    .kdo-banner--info  { background: var(--info-bg); border-color: var(--info-border); color: var(--info); }
    .kdo-banner--allow { background: var(--allow-bg); border-color: var(--allow-border); color: var(--allow); }
    .kdo-banner--warn  { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn); }
    .kdo-banner--block { background: var(--block-bg); border-color: var(--block-border); color: var(--block); }
    .kdo-banner__text, .kdo-banner__title { color: var(--text); }
  

    .kdo-toast { display: inline-flex; align-items: flex-start; gap: 11px; font-family: var(--font-sans);
      background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl);
      padding: 12px 16px 12px 13px; box-shadow: var(--shadow-lg); min-width: 240px; max-width: 380px; }
    .kdo-toast__mark { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
      width: 28px; height: 28px; border-radius: 9px; background: var(--brand); color: #fff; }
    .kdo-toast--allow .kdo-toast__mark { background: var(--pulse-500); }
    .kdo-toast--block .kdo-toast__mark { background: var(--danger-500); }
    .kdo-toast--warn  .kdo-toast__mark { background: var(--warn-500); }
    .kdo-toast__body { flex: 1; min-width: 0; }
    .kdo-toast__title { font-size: var(--text-base); font-weight: var(--weight-semibold); color: var(--text); line-height: 1.35; }
    .kdo-toast__text { font-size: var(--text-sm); color: var(--text-secondary); line-height: 1.45; margin-top: 1px; }
  

    .kdo-field { display: flex; flex-direction: column; gap: 6px; font-family: var(--font-sans); }
    .kdo-field__label { font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--text-secondary); }
    .kdo-field__msg { font-size: var(--text-xs); color: var(--text-muted); }
    .kdo-field__msg.is-error { color: var(--block); }
    .kdo-input { display: flex; align-items: center; gap: 8px; background: var(--surface);
      border: 1px solid var(--border-strong); border-radius: var(--radius-md);
      transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out); }
    .kdo-input--sm { padding: 0 10px; }
    .kdo-input--md { padding: 0 12px; }
    .kdo-input--lg { padding: 0 14px; }
    .kdo-input__icon { display: inline-flex; color: var(--text-muted); }
    .kdo-input__icon svg { display: block; width: 16px; height: 16px; }
    .kdo-input__el { flex: 1; width: 100%; border: 0; outline: none; background: transparent;
      color: var(--text); font-family: var(--font-sans); }
    .kdo-input--sm .kdo-input__el { font-size: var(--text-sm); padding: 7px 0; }
    .kdo-input--md .kdo-input__el { font-size: var(--text-base); padding: 9px 0; }
    .kdo-input--lg .kdo-input__el { font-size: var(--text-md); padding: 12px 0; }
    .kdo-input__el::placeholder { color: var(--text-faint); }
    .kdo-input:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--focus-ring); }
    .kdo-input.is-error { border-color: var(--danger-500); }
    .kdo-input.is-error:focus-within { box-shadow: 0 0 0 3px color-mix(in oklab, var(--danger-500) 35%, transparent); }
  

    .kdo-pin { display: inline-flex; gap: 10px; }
    .kdo-pin__box { width: 52px; height: 60px; text-align: center; font-family: var(--font-mono);
      font-size: 24px; font-weight: var(--weight-semibold); color: var(--text); background: var(--surface);
      border: 1.5px solid var(--border-strong); border-radius: var(--radius-lg); outline: none;
      transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out),
        background var(--dur-fast) var(--ease-out); caret-color: var(--brand); }
    .kdo-pin__box.is-filled { border-color: var(--brand); background: var(--brand-subtle); }
    .kdo-pin__box:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--focus-ring); }
  

    .kdo-select { position: relative; display: flex; align-items: center; background: var(--surface);
      border: 1px solid var(--border-strong); border-radius: var(--radius-md);
      transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out); }
    .kdo-select:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--focus-ring); }
    .kdo-select__el { appearance: none; -webkit-appearance: none; width: 100%; border: 0; outline: none;
      background: transparent; color: var(--text); font-family: var(--font-sans); cursor: pointer;
      padding-right: 30px; }
    .kdo-select--sm .kdo-select__el { font-size: var(--text-sm); padding: 7px 30px 7px 10px; }
    .kdo-select--md .kdo-select__el { font-size: var(--text-base); padding: 9px 30px 9px 12px; }
    .kdo-select--lg .kdo-select__el { font-size: var(--text-md); padding: 12px 30px 12px 14px; }
    .kdo-select__chevron { position: absolute; right: 10px; display: inline-flex; color: var(--text-muted);
      pointer-events: none; }
    .kdo-select__chevron svg { width: 16px; height: 16px; }
    .kdo-select__el option { color: #141921; }
  

    .kdo-switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer;
      font-family: var(--font-sans); font-size: var(--text-base); color: var(--text); user-select: none; }
    .kdo-switch.is-disabled { opacity: 0.5; cursor: not-allowed; }
    .kdo-switch__input { position: absolute; opacity: 0; width: 0; height: 0; }
    .kdo-switch__track { position: relative; display: inline-block; background: var(--n-300);
      border-radius: var(--radius-full); transition: background var(--dur-base) var(--ease-out); flex-shrink: 0; }
    .kdo-switch__thumb { position: absolute; top: 50%; left: 2px; transform: translateY(-50%);
      background: #fff; border-radius: 50%; box-shadow: var(--shadow-sm);
      transition: left var(--dur-base) var(--ease-spring); }
    .kdo-switch--sm .kdo-switch__track { width: 32px; height: 18px; }
    .kdo-switch--sm .kdo-switch__thumb { width: 14px; height: 14px; }
    .kdo-switch--md .kdo-switch__track { width: 42px; height: 24px; }
    .kdo-switch--md .kdo-switch__thumb { width: 20px; height: 20px; }
    .kdo-switch__input:checked + .kdo-switch__track { background: var(--brand); }
    .kdo-switch--sm .kdo-switch__input:checked + .kdo-switch__track .kdo-switch__thumb { left: 16px; }
    .kdo-switch--md .kdo-switch__input:checked + .kdo-switch__track .kdo-switch__thumb { left: 20px; }
    .kdo-switch__input:focus-visible + .kdo-switch__track { box-shadow: 0 0 0 3px var(--focus-ring); }
  

    .kdo-actrow { display: grid; grid-template-columns: 64px 92px 1fr auto 64px; align-items: center; gap: 12px;
      padding: 9px 4px; border-bottom: 1px solid var(--border-faint); font-family: var(--font-sans); }
    .kdo-actrow__time { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-faint); }
    .kdo-actrow__person { display: inline-block; font-size: var(--text-xs); font-weight: var(--weight-semibold);
      color: var(--info); background: var(--info-bg); border: 1px solid var(--info-border);
      padding: 2px 8px; border-radius: var(--radius-xs); }
    .kdo-actrow__ip { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-faint); }
    .kdo-actrow__domain { font-family: var(--font-mono); font-size: var(--text-sm); color: var(--text-secondary);
      overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .kdo-actrow__catbadge { font-size: var(--text-2xs); color: var(--text-muted); background: var(--surface-sunken);
      border: 1px solid var(--border); padding: 2px 7px; border-radius: var(--radius-xs); white-space: nowrap; }
    .kdo-actrow__action { font-size: var(--text-2xs); font-weight: var(--weight-bold); text-align: center;
      padding: 3px 0; border-radius: var(--radius-xs); letter-spacing: .04em; }
    .kdo-actrow__action--allow { color: var(--allow); background: var(--allow-bg); }
    .kdo-actrow__action--block { color: var(--block); background: var(--block-bg); }
  

    .kdo-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl);
      font-family: var(--font-sans); color: var(--text); overflow: hidden; }
    .kdo-card.is-elevated { box-shadow: var(--shadow-md); }
    .kdo-card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px;
      padding: 15px 18px; border-bottom: 1px solid var(--border-faint); }
    .kdo-card__title { margin: 0; font-size: var(--text-base); font-weight: var(--weight-semibold); color: var(--text); }
    .kdo-card__trailing { display: inline-flex; align-items: center; gap: 8px; color: var(--text-muted); }
    .kdo-card__body--none { padding: 0; }
    .kdo-card__body--sm { padding: 12px; }
    .kdo-card__body--md { padding: 18px; }
    .kdo-card__body--lg { padding: 24px; }
  

    .kdo-bubble-wrap { display: flex; margin: 3px 0; }
    .kdo-bubble-wrap--parent { justify-content: flex-end; }
    .kdo-bubble-wrap--kodo { justify-content: flex-start; }
    .kdo-bubble { position: relative; max-width: 78%; padding: 7px 10px 6px; border-radius: 12px;
      font-family: var(--font-sans); box-shadow: 0 1px 0.5px rgba(11,20,26,0.13); }
    .kdo-bubble--kodo { background: var(--wa-bubble-in); border-top-left-radius: 4px; }
    .kdo-bubble--parent { background: var(--wa-bubble-out); border-top-right-radius: 4px; }
    .kdo-bubble__text { font-size: 14.2px; line-height: 1.4; color: #111b21; white-space: pre-wrap; word-wrap: break-word; }
    .kdo-bubble__meta { display: flex; align-items: center; justify-content: flex-end; gap: 3px; margin-top: 1px; }
    .kdo-bubble__time { font-size: 11px; color: #667781; }
    .kdo-bubble__tick { color: #8696a0; display: inline-flex; }
    .kdo-bubble__tick.is-read { color: var(--wa-tick); }
    .kdo-bubble__text b, .kdo-bubble__text strong { font-weight: var(--weight-semibold); }
  

    .kdo-stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl);
      padding: 18px 18px 16px; font-family: var(--font-sans); }
    .kdo-stat__value { font-size: var(--text-4xl); font-weight: var(--weight-bold); line-height: 1;
      letter-spacing: var(--tracking-tight); color: var(--text); font-variant-numeric: tabular-nums; }
    .kdo-stat__value--block { color: var(--block); }
    .kdo-stat__value--allow { color: var(--allow); }
    .kdo-stat__value--brand { color: var(--brand); }
    .kdo-stat__label { font-size: var(--text-sm); color: var(--text-muted); margin-top: 6px; }
    .kdo-stat__delta { font-size: var(--text-xs); font-weight: var(--weight-medium); margin-top: 8px;
      font-variant-numeric: tabular-nums; }
    .kdo-stat__delta.is-up { color: var(--allow); }
    .kdo-stat__delta.is-down { color: var(--block); }

/* ============================================================
   4. LAYOUT CSS  (app shell + dashboard views + Ask drawer)
   ============================================================ */
* { box-sizing: border-box; }
  html, body { margin: 0; height: 100%; }
  body { font-family: var(--font-sans); background: var(--bg); color: var(--text);
    -webkit-font-smoothing: antialiased; }

  /* density tokens */
  :root { --kdo-gap: 18px; --kdo-cardpad: 18px; --kdo-rowpad: 14px; }
  html[data-density="compact"] { --kdo-gap: 12px; --kdo-cardpad: 13px; --kdo-rowpad: 9px; }

  /* ---- accent / colour treatments ---- */
  html[data-accent="emerald"] { --brand: var(--pulse-500); --brand-hover: var(--pulse-600);
    --brand-active: var(--pulse-700); --brand-subtle: var(--pulse-50); --on-brand: #fff; }
  html.theme-dark[data-accent="emerald"] { --brand-hover: var(--pulse-400); --brand-active: var(--pulse-300);
    --brand-subtle: color-mix(in oklab, var(--pulse-500) 18%, var(--n-900)); }

  html[data-accent="slate"] { --brand: var(--n-700); --brand-hover: var(--n-800);
    --brand-active: var(--n-900); --brand-subtle: var(--n-100); --on-brand: #fff; }
  html.theme-dark[data-accent="slate"] { --brand: var(--n-200); --brand-hover: #fff; --brand-active: #fff;
    --brand-subtle: var(--n-800); --on-brand: var(--n-950); }

  /* ===================== App frame ===================== */
  .kdo-app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }

  /* ---- Sidebar ---- */
  .kdo-side { display: flex; flex-direction: column; gap: 18px; padding: 18px 14px;
    background: var(--surface); border-right: 1px solid var(--border); position: sticky; top: 0; height: 100vh; }
  .kdo-side__brand { display: flex; align-items: center; gap: 11px; padding: 4px 6px 2px; }
  .kdo-side__word { font-size: 21px; font-weight: 700; letter-spacing: -0.02em; }
  .kdo-side__tag { margin-left: auto; font-size: 10px; font-weight: 600; letter-spacing: .12em;
    text-transform: uppercase; color: var(--text-faint); }
  .kdo-nav { display: flex; flex-direction: column; gap: 2px; }
  .kdo-nav__item { display: flex; align-items: center; gap: 11px; padding: 9px 11px; border: 0; cursor: pointer;
    background: transparent; color: var(--text-secondary); border-radius: var(--radius-md); font-family: var(--font-sans);
    font-size: var(--text-base); font-weight: var(--weight-medium); text-align: left; width: 100%;
    transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out); }
  .kdo-nav__item i, .kdo-nav__item svg { width: 18px; height: 18px; }
  .kdo-nav__item:hover { background: var(--hover-overlay); color: var(--text); }
  .kdo-nav__item.is-active { background: var(--brand-subtle); color: var(--brand-active); }
  .kdo-nav__badge { margin-left: auto; background: var(--block-bg); color: var(--block); font-size: 11px;
    font-weight: 700; min-width: 18px; height: 18px; border-radius: 9px; display: inline-flex;
    align-items: center; justify-content: center; padding: 0 5px; border: 1px solid var(--block-border); }
  .kdo-side__section { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .14em;
    color: var(--text-faint); padding: 0 8px; margin-bottom: -6px; }
  .kdo-side__family { display: flex; flex-direction: column; gap: 1px; }
  .kdo-side__person { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: var(--radius-md);
    border: 0; background: transparent; width: 100%; cursor: pointer; font-family: var(--font-sans); text-align: left;
    color: var(--text); transition: background var(--dur-fast); }
  .kdo-side__person:hover { background: var(--hover-overlay); }
  .kdo-side__person.is-active { background: var(--brand-subtle); }
  .kdo-side__pname { font-size: var(--text-base); }
  .kdo-side__page { margin-left: auto; font-size: var(--text-xs); color: var(--text-faint); font-family: var(--font-mono); }
  .kdo-side__foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px;
    padding-top: 12px; border-top: 1px solid var(--border-faint); }

  /* theme toggle */
  .kdo-themetog { display: inline-flex; align-items: center; gap: 6px; padding: 3px; border-radius: var(--radius-full);
    background: var(--surface-sunken); border: 1px solid var(--border); }
  .kdo-themetog button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    border: 0; background: transparent; color: var(--text-muted); cursor: pointer; padding: 6px 8px;
    border-radius: var(--radius-full); font-family: var(--font-sans); font-size: var(--text-xs); font-weight: 600;
    transition: background var(--dur-fast), color var(--dur-fast); }
  .kdo-themetog button i, .kdo-themetog button svg { width: 14px; height: 14px; }
  .kdo-themetog button.is-on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); }
  html.theme-dark .kdo-themetog button.is-on { box-shadow: none; background: var(--surface-2); }

  /* ===================== Main ===================== */
  .kdo-main { min-width: 0; display: flex; flex-direction: column; }
  .kdo-topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px;
    padding: 12px 30px; background: color-mix(in oklab, var(--bg) 82%, transparent);
    backdrop-filter: blur(10px); border-bottom: 1px solid var(--border-faint); }
  .kdo-topbar__crumb { font-size: var(--text-sm); color: var(--text-muted); display: flex; align-items: center; gap: 7px; }
  .kdo-topbar__crumb b { color: var(--text); font-weight: 600; }
  .kdo-topbar__spacer { flex: 1; }
  .kdo-topbar__pill { display: inline-flex; align-items: center; gap: 7px; font-size: var(--text-xs);
    color: var(--text-secondary); padding: 5px 11px; border-radius: var(--radius-full);
    background: var(--surface); border: 1px solid var(--border); }
  .kdo-content { padding: 26px 30px 60px; max-width: 1220px; width: 100%; }

  .kdo-view__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
  .kdo-view__title { margin: 0; font-size: var(--text-3xl); font-weight: var(--weight-bold); letter-spacing: var(--tracking-tight); }
  .kdo-view__sub { margin: 5px 0 0; color: var(--text-muted); font-size: var(--text-base); }
  .kdo-view__actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

  /* ---- Today ---- */
  .kdo-today__cardhead { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
  .kdo-today__h2 { margin: 0; font-size: var(--text-lg); font-weight: var(--weight-semibold); }
  .kdo-today__total { font-size: var(--text-sm); color: var(--text-muted); font-variant-numeric: tabular-nums; }
  .kdo-today__lines { display: flex; flex-direction: column; }
  .kdo-today__line { display: flex; gap: 14px; padding: var(--kdo-rowpad) 0; border-top: 1px solid var(--border-faint);
    cursor: pointer; transition: background var(--dur-fast); border-radius: 8px; margin: 0 -8px; padding-left: 8px; padding-right: 8px; }
  .kdo-today__line:hover { background: var(--hover-overlay); }
  .kdo-today__line:first-child { border-top: none; }
  .kdo-today__lbody { flex: 1; min-width: 0; }
  .kdo-today__lhead { display: flex; align-items: center; gap: 8px; }
  .kdo-today__lname { font-size: var(--text-md); font-weight: var(--weight-semibold); }
  .kdo-today__lsum { margin: 4px 0 0; color: var(--text-secondary); font-size: var(--text-base); line-height: 1.5; }
  .kdo-today__chev { align-self: center; color: var(--text-faint); }
  .kdo-today__chev svg, .kdo-today__chev i { width: 18px; height: 18px; }

  .kdo-qa-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
  .kdo-qa { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; text-align: left;
    padding: 15px; border-radius: var(--radius-xl); border: 1px solid var(--border); background: var(--surface);
    cursor: pointer; font-family: var(--font-sans); color: var(--text); text-decoration: none;
    transition: border-color var(--dur-fast), transform var(--dur-fast), background var(--dur-fast); }
  .kdo-qa:hover { border-color: var(--brand); transform: translateY(-1px); background: var(--surface-2); }
  .kdo-qa__icon { width: 36px; height: 36px; border-radius: 10px; background: var(--brand-subtle); color: var(--brand-active);
    display: inline-flex; align-items: center; justify-content: center; margin-bottom: 6px; }
  .kdo-qa__icon i, .kdo-qa__icon svg { width: 19px; height: 19px; }
  .kdo-qa__title { font-size: var(--text-base); font-weight: var(--weight-semibold); }
  .kdo-qa__hint { font-size: var(--text-xs); color: var(--text-muted); }

  .kdo-statusbar { display: flex; align-items: center; gap: 22px; padding: 13px 18px; border-radius: var(--radius-lg);
    background: var(--surface); border: 1px solid var(--border); font-size: var(--text-sm); flex-wrap: wrap; }
  .kdo-statusbar__spacer { flex: 1; }
  .kdo-statusbar__note { color: var(--text-faint); font-family: var(--font-mono); font-size: var(--text-xs); }

  /* ---- generic stacks / grids ---- */
  .kdo-stack { display: flex; flex-direction: column; gap: var(--kdo-gap); }
  .kdo-stats4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
  .kdo-grid2 { display: grid; grid-template-columns: 1.45fr 1fr; gap: var(--kdo-gap); align-items: start; }
  .kdo-col { display: flex; flex-direction: column; gap: var(--kdo-gap); }
  /* let grid/flex children shrink below their content so a wide row (activity
     feed, top-blocked bars) can't force horizontal scroll on narrow screens */
  .kdo-grid2 > *, .kdo-col, .kdo-card { min-width: 0; }
  .kdo-mini { font-size: var(--text-xs); color: var(--text-muted); font-family: var(--font-mono); }

  /* family table */
  .kdo-fam__head, .kdo-fam__row { display: grid; grid-template-columns: 1.4fr auto 40px 70px 64px; align-items: center; gap: 10px; }
  .kdo-fam__head { font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: .08em; color: var(--text-faint);
    padding: 0 0 8px; border-bottom: 1px solid var(--border-faint); }
  .kdo-fam__row { padding: var(--kdo-rowpad) 0; border-bottom: 1px solid var(--border-faint); cursor: pointer;
    transition: background var(--dur-fast); border-radius: 8px; margin: 0 -8px; padding-left: 8px; padding-right: 8px; }
  .kdo-fam__row:last-child { border-bottom: none; }
  .kdo-fam__row:hover { background: var(--hover-overlay); }
  .kdo-fam__who { display: flex; align-items: center; gap: 9px; }
  .kdo-fam__name { font-size: var(--text-base); font-weight: var(--weight-medium); }
  .kdo-fam__num { font-size: var(--text-sm); color: var(--text-secondary); font-variant-numeric: tabular-nums; text-align: right; }

  .kdo-sys { display: flex; flex-direction: column; gap: 11px; }
  .kdo-sys__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  .kdo-sys__detail { font-size: var(--text-xs); color: var(--text-muted); font-family: var(--font-mono); white-space: nowrap; }
  .kdo-top { display: flex; flex-direction: column; }
  .kdo-top__row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border-faint); }
  .kdo-top__row:last-child { border-bottom: none; }
  .kdo-top__dom { font-family: var(--font-mono); font-size: var(--text-sm); color: var(--text-secondary);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .kdo-top__bar { flex: 1; height: 6px; border-radius: 3px; background: var(--surface-sunken); overflow: hidden; }
  .kdo-top__barfill { height: 100%; background: var(--block); border-radius: 3px; }
  .kdo-top__count { font-size: var(--text-sm); color: var(--block); font-weight: var(--weight-semibold);
    font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }

  /* ---- prose summary (calm overview) ---- */
  .kdo-prose { font-size: var(--text-md); line-height: 1.7; color: var(--text-secondary); }
  .kdo-prose b { color: var(--text); font-weight: 600; }
  .kdo-prose__line { padding: 12px 0; border-top: 1px solid var(--border-faint); }
  .kdo-prose__line:first-child { border-top: none; }

  /* ---- bar chart (hourly) ---- */
  .kdo-hours { display: flex; align-items: flex-end; gap: 3px; height: 96px; padding-top: 6px; }
  .kdo-hours__h { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; }
  .kdo-hours__wrap { height: 74px; width: 100%; display: flex; flex-direction: column; justify-content: flex-end; }
  .kdo-hours__bar { width: 100%; border-radius: 3px 3px 0 0; background: var(--brand);
    transition: filter var(--dur-fast); min-height: 1px; }
  .kdo-hours__bar:hover { filter: brightness(1.15); }
  .kdo-hours__lab { font-size: 9px; color: var(--text-faint); font-family: var(--font-mono); }

  /* category breakdown bars */
  .kdo-catbar { display: flex; flex-direction: column; gap: 11px; }
  .kdo-catbar__row { display: grid; grid-template-columns: 110px 1fr 48px; align-items: center; gap: 12px; }
  .kdo-catbar__name { font-size: var(--text-sm); color: var(--text-secondary); text-transform: capitalize; }
  .kdo-catbar__track { height: 8px; border-radius: 4px; background: var(--surface-sunken); overflow: hidden; }
  .kdo-catbar__fill { height: 100%; border-radius: 4px; }
  .kdo-catbar__val { font-size: var(--text-xs); color: var(--text-muted); text-align: right; font-variant-numeric: tabular-nums; }

  /* ---- generic data table ---- */
  .kdo-tbl { width: 100%; border-collapse: collapse; }
  .kdo-tbl th { text-align: left; font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: .07em;
    color: var(--text-faint); font-weight: 600; padding: 0 10px 9px; border-bottom: 1px solid var(--border-faint); }
  .kdo-tbl td { padding: var(--kdo-rowpad) 10px; border-bottom: 1px solid var(--border-faint); font-size: var(--text-sm); vertical-align: middle; }
  .kdo-tbl tr:last-child td { border-bottom: none; }
  .kdo-tbl tbody tr { transition: background var(--dur-fast); }
  .kdo-tbl tbody tr.is-click { cursor: pointer; }
  .kdo-tbl tbody tr.is-click:hover { background: var(--hover-overlay); }
  .kdo-tbl__mono { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-muted); }
  .kdo-tbl__dev { display: flex; align-items: center; gap: 10px; }
  .kdo-tbl__devicon { width: 30px; height: 30px; border-radius: 8px; background: var(--surface-sunken);
    display: inline-flex; align-items: center; justify-content: center; color: var(--text-muted); flex-shrink: 0; }
  .kdo-tbl__devicon i, .kdo-tbl__devicon svg { width: 16px; height: 16px; }
  .kdo-tbl__name { font-weight: 600; font-size: var(--text-base); white-space: nowrap; }
  .kdo-linkish { color: var(--text-link); text-decoration: none; }
  .kdo-linkish:hover { text-decoration: underline; }

  /* ---- rules ---- */
  .kdo-rule { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center; padding: var(--kdo-rowpad) 0;
    border-top: 1px solid var(--border-faint); }
  .kdo-rule:first-child { border-top: none; }
  .kdo-rule__label { font-size: var(--text-base); font-weight: 600; }
  .kdo-rule__detail { font-size: var(--text-sm); color: var(--text-muted); margin-top: 3px; }
  .kdo-rule__meta { display: flex; align-items: center; gap: 8px; margin-top: 7px; flex-wrap: wrap; }
  .kdo-chiprow { display: flex; flex-wrap: wrap; gap: 7px; }
  .kdo-time { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-secondary);
    background: var(--surface-sunken); border: 1px solid var(--border); padding: 2px 7px; border-radius: var(--radius-xs);
    white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; }
  .kdo-time i, .kdo-time svg { width: 13px; height: 13px; }

  .kdo-person__cardrow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
  .kdo-person__hero { display: flex; align-items: center; gap: 16px; }
  .kdo-person__meta { display: flex; align-items: center; gap: 8px; margin-top: 6px; }

  /* placeholder */
  .kdo-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
    text-align: center; padding: 50px 20px; color: var(--text-muted); }
  .kdo-empty i, .kdo-empty svg { width: 26px; height: 26px; color: var(--text-faint); }

  /* ---- Ask Kōdō drawer ---- */
  .kdo-ask { position: fixed; inset: 0; background: rgba(0,0,0,0.45); display: flex; justify-content: flex-end;
    opacity: 0; pointer-events: none; transition: opacity var(--dur-base) var(--ease-out); z-index: 60; }
  .kdo-ask.is-open { opacity: 1; pointer-events: auto; }
  .kdo-ask__panel { width: 410px; max-width: 92vw; background: var(--wa-bg); height: 100%; display: flex; flex-direction: column;
    transform: translateX(20px); transition: transform var(--dur-base) var(--ease-out); }
  .kdo-ask.is-open .kdo-ask__panel { transform: translateX(0); }
  .kdo-ask__head { display: flex; align-items: center; gap: 11px; padding: 13px 16px; background: var(--wa-header); }
  .kdo-ask__title { font-size: var(--text-base); font-weight: var(--weight-semibold); color: #111b21; }
  .kdo-ask__sub { font-size: var(--text-xs); color: #667781; }
  .kdo-ask__close { margin-left: auto; background: transparent; border: 0; cursor: pointer; color: #54656f; padding: 4px; }
  .kdo-ask__log { flex: 1; overflow-y: auto; padding: 16px 14px; display: flex; flex-direction: column; gap: 2px;
    background-image: radial-gradient(circle, rgba(17,27,33,.04) 1px, transparent 1px); background-size: 18px 18px; }
  .kdo-ask__form { display: flex; gap: 8px; padding: 12px; background: var(--wa-header); }
  .kdo-ask__input { flex: 1; border: 0; border-radius: var(--radius-full); padding: 11px 16px; font-family: var(--font-sans);
    font-size: var(--text-base); background: #fff; color: #111b21; outline: none; }
  .kdo-ask__send { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--pulse-500); color: #fff;
    cursor: pointer; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
  .kdo-ask__chips { display: flex; gap: 6px; padding: 0 12px 10px; background: var(--wa-header); flex-wrap: wrap; }
  .kdo-ask__chip { font-size: var(--text-xs); border: 1px solid #d1d7db; background: #fff; color: #3b4a54;
    border-radius: var(--radius-full); padding: 5px 11px; cursor: pointer; font-family: var(--font-sans); }
  .kdo-ask__chip:hover { background: #f0f2f5; }

  .kdo-fade { animation: kdoFade var(--dur-base) var(--ease-out) both; }
  @keyframes kdoFade { from { opacity: 0.5; transform: translateY(6px); } to { opacity: 1; transform: none; } }
  @media (prefers-reduced-motion: reduce) { .kdo-fade { animation: none; } }

  /* --- mobile nav: hamburger toggle + off-canvas sidebar drawer --- */
  .kdo-navtoggle { display: none; align-items: center; justify-content: center;
    width: 38px; height: 38px; flex: 0 0 auto; border-radius: var(--radius-md);
    background: transparent; border: 1px solid var(--border); color: var(--text); cursor: pointer; }
  .kdo-navtoggle:hover { background: var(--surface-sunken); }
  .kdo-nav-backdrop { display: none; }

  @media (max-width: 1080px) {
    .kdo-app { grid-template-columns: 1fr; }
    .kdo-navtoggle { display: inline-flex; }
    .kdo-side {
      position: fixed; top: 0; left: 0; bottom: 0; width: 250px; z-index: 60;
      transform: translateX(-100%);
      transition: transform 200ms var(--ease-out, ease);
      box-shadow: 0 0 48px rgba(0,0,0,.55);
    }
    .kdo-app.nav-open .kdo-side { transform: translateX(0); }
    .kdo-nav-backdrop {
      display: block; position: fixed; inset: 0; z-index: 50;
      background: rgba(0,0,0,.5); opacity: 0; pointer-events: none;
      transition: opacity 200ms ease;
    }
    .kdo-app.nav-open .kdo-nav-backdrop { opacity: 1; pointer-events: auto; }
    .kdo-qa-grid, .kdo-stats4 { grid-template-columns: 1fr 1fr; }
    .kdo-grid2, .kdo-person__cardrow { grid-template-columns: 1fr; }
  }

  /* phones: let the view + card headers stack instead of clipping */
  @media (max-width: 640px) {
    .kdo-view__head { flex-wrap: wrap; }
    .kdo-today__cardhead { flex-wrap: wrap; align-items: flex-start; }
    .kdo-statusbar { flex-wrap: wrap; }
    .kdo-content { padding: 20px 16px 48px; }
    /* collapse activity rows to time · domain · action so they never overflow */
    .kdo-actrow { grid-template-columns: 54px 1fr auto; gap: 8px; }
    .kdo-actrow__src, .kdo-actrow__cat { display: none; }
    .kdo-actrow__domain { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  }

/* ============================================================
   5. HANDOFF SHELL SUPPLEMENTS
   Small additions used by the server-side shell (kodoshell.go):
   the brand squircle mark + anchor resets for the sidebar nav,
   which is rendered with <a> instead of the prototype's <button>.
   ============================================================ */

  /* Brand pulse mark — squircle that wraps the inline EKG SVG. */
  .kdo-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--brand);
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
  .kdo-topbar .kdo-mark, .kdo-ask__head .kdo-mark { width: 34px; height: 34px; border-radius: 10px; }

  /* Sidebar nav items are <a> in the server shell — strip link styling. */
  a.kdo-nav__item { text-decoration: none; }
  a.kdo-nav__item.is-active { color: var(--brand-active); }

  /* Sidebar footer link (parent guide / theme). */
  .kdo-themetog-link { display: inline-flex; align-items: center; gap: 10px; padding: 7px 8px;
    border-radius: var(--radius-md); color: var(--text-secondary); text-decoration: none;
    font-size: var(--text-sm); transition: background var(--dur-fast); }
  .kdo-themetog-link:hover { background: var(--hover-overlay); color: var(--text); }
  .kdo-themetog-link i, .kdo-themetog-link svg { width: 16px; height: 16px; }

  /* Generic activity feed wrapper used on overview/person pages. */
  .kdo-act { display: flex; flex-direction: column; }
