/* ============================================================================
   MsgYap — Stitch palette (dark)

   Port of the Google Stitch design "MsgYap - Encrypted Messenger".
   Every value below is taken verbatim from the generated Material-3 palette so
   the app matches the design exactly:

     surface              #0a151a      on-surface          #d9e4ec
     surface-container-low #131d23     on-surface-variant  #bccac2
     surface-container     #172127     outline             #86948d
     surface-container-high#212b32     outline-variant     #3d4a44
     surface-container-highest #2c363d primary             #59dcb5
     secondary             #41e575     primary-container   #00a884
     secondary-container   #06c85d     on-primary-container#003427
     tertiary              #6bd3fe     error               #ffb4ab

   Loaded after product-ui.css so it wins on equal specificity.
   Scoped to dark mode: the light theme in product-ui.css is untouched.
   ========================================================================== */

/* Inter, self-hosted. The CSP allows fonts from 'self' only, so the Google
   Fonts <link> used by the Stitch export cannot be used here. One variable
   file covers 400-700. */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/inter-latin-var.woff2') format('woff2');
}

/* The Stitch design system is dark-only by definition (DESIGN.md: "The palette
   operates strictly in dark mode"), so this layer applies regardless of the OS
   preference. Gating it behind prefers-color-scheme meant anyone on a light
   system saw the old light UI and none of the design. */
@media all {
  :root { color-scheme: dark; }

  :root {
    /* --- Stitch palette, verbatim --- */
    --st-surface: #0a151a;
    --st-surface-lowest: #060f15;
    --st-surface-low: #131d23;
    --st-surface-container: #172127;
    --st-surface-high: #212b32;
    --st-surface-highest: #2c363d;
    --st-on-surface: #d9e4ec;
    /* One authoritative height for the bottom tab bar. It was 64px here while
       product-ui.css hardcoded 70px, so anything reserving --nav-h (the chat
       pane, the FAB) was 6px short and the composer sat under the bar. */
    --nav-h: 70px;
    --st-on-surface-variant: #bccac2;
    --st-outline: #86948d;
    --st-outline-variant: #3d4a44;
    --st-primary: #59dcb5;
    --st-primary-container: #00a884;
    --st-on-primary-container: #003427;
    --st-secondary: #41e575;
    --st-secondary-container: #06c85d;
    --st-tertiary: #6bd3fe;
    --st-error: #ffb4ab;

    /* --- map onto the app's own tokens --- */
    --bg: var(--st-surface);
    --panel: var(--st-surface-low);
    --card: var(--st-surface-container);
    --ink: var(--st-on-surface);
    --ink-soft: var(--st-on-surface-variant);
    --line: var(--st-outline-variant);
    --text: var(--st-on-surface);
    --text-muted: var(--st-on-surface-variant);
    --sub: var(--st-on-surface-variant);
    --accent: var(--st-primary);
    --accent-dark: var(--st-primary-container);
    --accent-soft: rgba(0, 168, 132, .16);
    --header-bg: var(--st-surface-high);
    --side-bg: var(--st-surface);
    --chat-bg: var(--st-surface);
    --bubble-in: var(--st-surface-container);
    --bubble-out: rgba(0, 168, 132, .18);
    --tick-read: var(--st-tertiary);
    --tick-sent: var(--st-outline);
    --danger: var(--st-error);
    --brand-grad: linear-gradient(135deg, #00a884, #59dcb5);
  }

  /* ---------- base ---------- */
  html, body {
    background: var(--st-surface);
    color: var(--st-on-surface);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  }

  .main, .mobile-content { background: var(--st-surface); }
  .sidebar, .chat-list, .side-foot, .cat-pills { background: var(--st-surface); }

  /* ---------- top app bar ---------- */
  .side-head, .chat-head, .mobile-head {
    background: var(--st-surface-high);
    border-bottom: 1px solid rgba(61, 74, 68, .5);
    box-shadow: none;
  }
  .mobile-title,
  .brand-name,
  .side-head .brand {
    color: var(--st-primary);
    font-weight: 700;
    letter-spacing: -.01em;
  }
  .me-chip { color: var(--st-on-surface); }
  .me-chip:hover { background: rgba(23, 33, 39, .8); }
  #net-chip { border-radius: 999px; }

  /* ---------- search ---------- */
  .search {
    background: var(--st-surface-container);
    border: 1px solid rgba(61, 74, 68, .3);
    border-radius: 8px;
    color: var(--st-on-surface);
  }
  .search::placeholder { color: var(--st-outline); }

  /* ---------- sector pills ---------- */
  .cat-pill {
    background: var(--st-surface-high);
    border: 1px solid rgba(61, 74, 68, .4);
    color: var(--st-on-surface);
    border-radius: 999px;
    font-weight: 500;
  }
  .cat-pill:hover { border-color: rgba(89, 220, 181, .5); }
  .cat-pill.active {
    background: var(--st-primary-container);
    border-color: var(--st-primary-container);
    color: var(--st-on-primary-container);
    font-weight: 700;
  }

  /* ---------- chat list ---------- */
  .chat-item {
    background: var(--st-surface);
    border-bottom: 1px solid rgba(23, 33, 39, .6);
  }
  .chat-item:nth-child(even) { background: rgba(19, 29, 35, .2); }
  .chat-item:hover { background: rgba(33, 43, 50, .4); }
  .chat-item.active { background: rgba(33, 43, 50, .8); }

  .ci-name { color: var(--st-on-surface); font-weight: 600; font-size: 16px; }
  .ci-preview { color: var(--st-on-surface-variant); font-size: 13px; }
  .ci-time { color: var(--st-outline); font-size: 11px; font-weight: 500; }

  /* unread rows: bold green timestamp like the design */
  .chat-item.unread-row .ci-time,
  .chat-item.is-unread .ci-time { color: var(--st-secondary); font-weight: 700; }

  .unread {
    background: var(--st-primary-container);
    color: var(--st-on-primary-container);
    box-shadow: none;
    font-weight: 700;
  }

  .avatar {
    border: 1px solid rgba(61, 74, 68, .4);
    box-shadow: none;
  }

  .list-empty { color: var(--st-on-surface-variant); }

  /* ---------- floating action button ---------- */
  .fab {
    background: var(--st-primary-container);
    color: var(--st-on-primary-container);
    border: 1px solid rgba(65, 229, 117, .2);
    box-shadow: 0 10px 24px rgba(0, 0, 0, .45);
  }

  /* ---------- bottom navigation ---------- */
  .tab-nav {
    background: var(--st-surface-container);
    border-top: 1px solid var(--st-outline-variant);
    box-shadow: 0 -6px 18px rgba(0, 0, 0, .25);
  }
  .tab-nav-item { color: var(--st-on-surface-variant); }
  .tab-nav-item.active {
    background: rgba(0, 168, 132, .2);
    color: var(--st-primary);
    border-radius: 999px;
  }
  .tab-nav-item.active span { color: var(--st-primary); }

  /* ---------- thread ----------
     Values taken from the Stitch chat screen code.html:
       date chip     bg #182229, uppercase label-xs
       incoming      bg #202C33, border outline-variant/30, r=16 tail 4
       outgoing      bg #005C4B, border primary/20
       banner        bg #182229, text #FFD279/90, lock #facc15
       wallpaper     #0b141a + 24px dot grid rgba(89,220,181,.04) */
  .chat-pane {
    background-color: #0b141a;
    background-image:
      radial-gradient(rgba(89, 220, 181, .04) 1px, transparent 0),
      radial-gradient(rgba(255, 255, 255, .02) 1px, #0b141a 0);
    background-size: 24px 24px, 12px 12px;
    background-position: 0 0, 12px 12px;
  }
  .chat-pane::before { display: none; }

  .chat-head {
    background: var(--st-surface-high);
    border-bottom: 1px solid rgba(61, 74, 68, .5);
  }
  .ch-name { color: #e9edef; font-weight: 700; }
  .ch-sub { color: #86948d; font-size: 11px; letter-spacing: .02em; }
  .ch-e2e {
    color: var(--st-primary);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .03em;
    margin-left: 4px;
  }

  .day-sep {
    background: #182229;
    border: 1px solid rgba(61, 74, 68, .3);
    color: var(--st-on-surface-variant);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    border-radius: 8px;
    padding: 4px 12px;
    box-shadow: none;
  }

  /* the built-in "messages are end-to-end encrypted" note */
  .sysnote {
    background: #182229;
    border: 1px solid rgba(61, 74, 68, .4);
    border-radius: 12px;
    color: rgba(255, 210, 121, .9);
    font-size: 13px;
    line-height: 17px;
    padding: 12px;
    max-width: 92%;
    margin: 4px auto;
    box-shadow: none;
  }
  .sysnote svg, .sysnote .ic { color: #facc15; }

  .messages { padding: 12px; }
  .msg-row { margin: 4px 0; }

  .bubble {
    max-width: 82%;
    padding: 12px;
    border-radius: 16px;
    box-shadow: none;
    border: 1px solid transparent;
  }
  .bubble.in {
    background: #202c33;
    border-color: rgba(61, 74, 68, .3);
    border-top-left-radius: 4px;
    color: #e9edef;
  }
  .bubble.out {
    background: #005c4b;
    border-color: rgba(89, 220, 181, .2);
    border-top-right-radius: 4px;
    color: #e9edef;
  }
  .bubble .text { color: #e9edef; font-size: 14px; line-height: 1.45; }
  .bubble .meta, .bubble .meta span { color: #86948d; font-size: 10px; }
  .bubble .sender { color: var(--st-primary); font-weight: 600; font-size: 12px; }

  /* read receipts: delivered grey -> read blue */
  .ticks.sent, .ticks.delivered { color: #86948d; }
  .ticks.read { color: #53bde8; }
  .ticks.queued { color: #86948d; }

  /* ---------- composer ---------- */
  .composer {
    background: var(--st-surface-container);
    border-top: 1px solid rgba(61, 74, 68, .5);
    padding: 8px 10px;
  }
  .composer textarea,
  .composer input {
    /* --st-surface-high (#212b32) is the darkest surface that still sits above
       the bar; it lifts the muted #86948d placeholder to 4.56:1. The old
       #2a3942 was lighter and left the placeholder at only 3.76:1. */
    background: var(--st-surface-high);
    color: var(--st-on-surface);
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 11px 16px;
    box-shadow: none;
  }
  /* Placeholder stays on the muted outline token so it can never drift back
     onto the typed-text colour. Covers the input variant too, not just the
     textarea, so any composer that renders an <input> behaves the same. */
  .composer textarea::placeholder,
  .composer input::placeholder { color: var(--st-outline); }
  /* Pin the focused fill to the resting composer surface. style.css used to
     paint :focus white, which put the on-surface text on #fff. Declaring the
     fill here (equal specificity, loaded later) makes this layer the winner no
     matter what the base sheet does. */
  .composer textarea:focus,
  .composer input:focus {
    background: var(--st-surface-high);
    color: var(--st-on-surface);
    box-shadow: none;
    border-color: rgba(89, 220, 181, .35);
  }
  .composer .send {
    background: var(--st-primary-container);
    color: var(--st-on-primary-container);
    box-shadow: none;
  }

  /* ---------- generic surfaces used across screens ---------- */
  .settings-card, .auth-card, .modal {
    background: var(--st-surface-low);
    border-color: var(--st-outline-variant);
  }
  .settings-item { border-color: rgba(61, 74, 68, .5); }
  .info-banner, .encrypt-banner {
    background: rgba(0, 168, 132, .12);
    border-color: rgba(0, 168, 132, .3);
    color: var(--st-primary);
  }
  .btn.primary {
    background: var(--st-primary-container);
    color: var(--st-on-primary-container);
    box-shadow: none;
  }
  .btn.ghost {
    background: var(--st-surface-high);
    border-color: var(--st-outline-variant);
    color: var(--st-on-surface);
  }
  .chip.ok {
    background: rgba(6, 200, 93, .16);
    color: var(--st-secondary);
  }
  /* The dashboard emits .chip.err for "Expired" / "Trial ended", but only .ok
     was styled, so a lapsed subscription rendered in the same brand mint as a
     healthy one. */
  .chip.warn {
    background: rgba(214, 158, 46, .16);
    color: #e0b350;
  }
  .chip.err {
    background: rgba(207, 102, 121, .18);
    color: #ef8fa1;
  }

  /* ---------- status badges, timestamps, nav, FAB ----------
     These still carried the old purple/light palette:
       --accent-text #5A4BD1  -> GROUP chip, active rows
       .time-pill             -> green pill around the timestamp
       .badge-*               -> Material pastel chips
       .tab-nav-item.active   -> #ece9ff blob behind the icon
       .fab                   -> purple gradient                                 */
  :root { --accent-text: var(--st-primary); }

  .badge-group, .badge-business, .badge-verified, .badge-child-safe {
    background: var(--st-surface-high);
    color: var(--st-primary);
    border: 1px solid rgba(61, 74, 68, .5);
    font-size: 9px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    letter-spacing: .04em;
    text-transform: uppercase;
  }
  .badge-business { color: var(--st-tertiary); }
  .badge-child-safe { color: var(--st-secondary); }

  /* timestamps are plain muted text in the design, not a pill */
  .time-pill {
    background: transparent;
    border: 0;
    padding: 0;
    color: var(--st-outline);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: .02em;
  }
  .chat-item:hover .time-pill { color: var(--st-on-surface-variant); }
  .chat-item:has(.unread) .time-pill {
    color: var(--st-secondary);
    font-weight: 700;
  }

  .av-wrap .dot {
    background: var(--st-secondary-container);
    border-color: var(--st-surface);
  }

  .icon-btn {
    background: transparent;
    border: 0;
    color: var(--st-on-surface-variant);
  }
  .icon-btn:hover { background: rgba(33, 43, 50, .8); color: var(--st-on-surface); }

  .tab-nav-item.active .tab-icon {
    background: rgba(0, 168, 132, .2);
    border-radius: 999px;
    color: var(--st-primary);
  }
  .tab-nav-item.active span { color: var(--st-primary); }

  .fab {
    width: 56px;
    height: 56px;
    background: var(--st-primary-container);
    background-image: none;
    color: var(--st-on-primary-container);
    border: 1px solid rgba(65, 229, 117, .2);
    box-shadow: 0 4px 12px rgba(0, 0, 0, .4);
  }

  /* footer encryption note: quiet centred text, as in the design */
  .encrypt-banner {
    background: transparent;
    border: 0;
    color: var(--st-outline);
    text-align: center;
    font-size: 10px;
    line-height: 14px;
    letter-spacing: .04em;
    font-weight: 600;
    padding: 10px 24px;
    opacity: .75;
  }

  /* ---------- attachment card inside a bubble ---------- */
  .file-card {
    background: rgba(0, 0, 0, .22);
    border-color: rgba(255, 255, 255, .12);
    color: #e9edef;
  }
  .file-card:hover { background: rgba(0, 0, 0, .3); box-shadow: none; }
  .file-card b { color: #e9edef; font-weight: 600; }
  .file-card .fc-sub { color: rgba(233, 237, 239, .7); }
  .file-card .fc-icon { color: var(--st-primary); }
  .file-card .btn.small {
    background: var(--st-primary-container);
    color: var(--st-on-primary-container);
    border: 0;
  }
  .file-preview {
    background: rgba(0, 168, 132, .14) !important;
    border: 1px solid rgba(0, 168, 132, .3);
    color: var(--st-on-surface);
  }
  .img-msg { border-color: rgba(255, 255, 255, .12); }

  /* ---------- no scrollbars on the pill row ---------- */
  .cat-pills { scrollbar-width: none; -ms-overflow-style: none; }
  .cat-pills::-webkit-scrollbar { display: none; }

  /* ---------- keep nav labels readable on very narrow screens ---------- */
  .tab-nav-item { padding: 6px 4px; min-width: 0; }
  .tab-nav-item span { font-size: 10px; letter-spacing: 0; white-space: nowrap; }
  .tab-nav-item > span:last-child { overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

  /* ---------- contrast fixes ----------
     Light-theme values were leaking into the dark surfaces and made text
     effectively invisible:
       --muted-strong #55606B  -> .hint / .set-h / .fc-sub   (2.66:1)
       .btn white on --accent  -> white on mint              (1.70:1)
       .section-label #087f92  -> 3.93:1                                    */
  :root { --muted-strong: var(--st-on-surface-variant); }

  .hint,
  .set-h,
  .fc-sub,
  .row-sub,
  .kv span,
  .sheet-body p,
  .modal .hint,
  .settings-modal .hint {
    color: var(--st-on-surface-variant);
  }

  .section-label {
    color: var(--st-primary);
    font-weight: 700;
  }

  /* default button was white text on the mint accent — unreadable */
  .btn {
    background: var(--st-surface-high);
    color: var(--st-on-surface);
    border: 1px solid var(--st-outline-variant);
    box-shadow: none;
  }
  .btn:hover { background: var(--st-surface-highest); box-shadow: none; }
  .btn.primary {
    background: var(--st-primary-container);
    color: var(--st-on-primary-container);
    border-color: transparent;
  }
  .btn.ghost {
    background: transparent;
    color: var(--st-primary);
    border: 1px solid var(--st-outline-variant);
  }
  .btn.ghost:hover { background: rgba(0, 168, 132, .12); }
  .btn.link { background: none; color: var(--st-primary); }
  .btn.danger { background: var(--st-error); color: #690005; }
  .btn[data-disabled] { opacity: .45; }

  /* ---------- form controls ----------
     style.css paints every input white and the dark overrides in
     product-ui.css are gated behind prefers-color-scheme, so on a light-mode
     device the auth screen showed a white username field next to a dark
     password field. This applies everywhere, unconditionally. */
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),
  textarea,
  select {
    background: var(--st-surface-container);
    color: var(--st-on-surface);
    border: 1.5px solid var(--st-outline-variant);
  }
  input::placeholder,
  textarea::placeholder {
    color: var(--st-outline);
  }
  input:not([type="checkbox"]):not([type="radio"]):focus,
  textarea:focus,
  select:focus {
    background: var(--st-surface-high);
    border-color: rgba(89, 220, 181, .45);
    box-shadow: none;
    outline: none;
  }
  .auth-card input,
  .auth-card textarea,
  .auth-panel .card-form input,
  .auth-panel .card-form textarea {
    background: var(--st-surface-container);
    border-color: var(--st-outline-variant);
    color: var(--st-on-surface);
  }

  /* ---------- organisation dashboard (full page) ---------- */
  .dash-root {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 90;
    background: var(--st-surface);
    color: var(--st-on-surface);
    overflow: auto;
  }
  .dash-root.open { display: block; }
  body.dash-open { overflow: hidden; }
  .dash-loading { padding: 40px 20px; text-align: center; color: var(--st-outline); font-size: 13px; }

  .dash {
    display: grid;
    grid-template-columns: 232px minmax(0, 1fr);
    min-height: 100%;
  }
  .dash-solo { grid-template-columns: 1fr; }

  .dash-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 16px 12px;
    background: var(--st-surface-low);
    border-right: 1px solid var(--st-outline-variant);
    position: sticky;
    top: 0;
    align-self: start;
    max-height: 100vh;
  }
  .dash-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; }
  .dash-brand-name { color: var(--st-primary); font-weight: 700; font-size: 15px; }
  .dash-brand-sub { color: var(--st-on-surface-variant); font-size: 11px; }
  .dash-nav nav { display: flex; flex-direction: column; gap: 2px; }
  .dash-nav-item {
    text-align: left;
    padding: 9px 12px;
    border-radius: 10px;
    background: none;
    border: 0;
    color: var(--st-on-surface-variant);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
  }
  .dash-nav-item:hover { background: rgba(33, 43, 50, .7); color: var(--st-on-surface); }
  .dash-nav-item.active { background: rgba(0, 168, 132, .18); color: var(--st-primary); }
  .dash-exit {
    margin-top: auto;
    padding: 9px 12px;
    border-radius: 10px;
    background: none;
    border: 1px solid var(--st-outline-variant);
    color: var(--st-on-surface-variant);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
  }

  .dash-main { padding: 20px 22px 60px; max-width: 1040px; width: 100%; }
  .dash-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
  .dash-head h1 { font-size: 20px; font-weight: 700; color: var(--st-on-surface); margin: 0 0 4px; letter-spacing: -.01em; }
  .dash-sub { color: var(--st-on-surface-variant); font-size: 12px; margin: 0; }

  .dash-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
  .dash-stat {
    background: var(--st-surface-low);
    border: 1px solid var(--st-outline-variant);
    border-radius: 12px;
    padding: 12px 14px;
  }
  .dash-stat-label { color: var(--st-outline); font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
  .dash-stat-value { color: var(--st-on-surface); font-size: 20px; font-weight: 700; margin-top: 4px; }
  .dash-stat-hint { color: var(--st-on-surface-variant); font-size: 11px; margin-top: 2px; }

  .dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
  .dash-card {
    background: var(--st-surface-low);
    border: 1px solid var(--st-outline-variant);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 12px;
  }
  .dash-card h2 { font-size: 13px; font-weight: 700; color: var(--st-on-surface); margin: 0 0 10px; text-transform: uppercase; letter-spacing: .05em; }

  .dash-kv { display: flex; justify-content: space-between; gap: 14px; padding: 7px 0; border-bottom: 1px solid rgba(61, 74, 68, .35); }
  .dash-kv span { color: var(--st-outline); font-size: 12px; }
  .dash-kv b { color: var(--st-on-surface); font-size: 12.5px; text-align: right; font-weight: 600; }
  .dash-card .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; word-break: break-all; color: var(--st-primary); }

  .dash-table { display: flex; flex-direction: column; }
  .dash-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(61, 74, 68, .3);
  }
  .dash-row:last-child { border-bottom: 0; }
  .dash-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
  .dash-row-main b { color: var(--st-on-surface); font-size: 13.5px; font-weight: 600; }
  .dash-row-sub { color: var(--st-on-surface-variant); font-size: 11.5px; }
  .dash-price { color: var(--st-primary); font-weight: 700; font-size: 14px; }
  .dash-price small { color: var(--st-outline); font-weight: 500; font-size: 10.5px; }

  .dash-form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
  .dash-form input, .dash-form select, .dash-form textarea {
    /* width floor only applies to the wrapping row layout; see .dash-form-col */
    flex: 1 1 170px;
    background: var(--st-surface-container);
    border: 1px solid var(--st-outline-variant);
    border-radius: 10px;
    color: var(--st-on-surface);
    padding: 9px 12px;
    font-size: 13px;
    font-family: inherit;
  }
  .dash-form-col { flex-direction: column; }
  /* In a column the flex basis becomes a HEIGHT, so a 170px floor turned every
     field into a 170px-tall box. Reset the basis and let content size them. */
  .dash-form-col input,
  .dash-form-col select,
  .dash-form-col textarea {
    flex: 0 0 auto;
    width: 100%;
    min-height: 40px;
  }
  .dash-form-col textarea { min-height: 84px; resize: vertical; }
  .dash-form-col label { color: var(--st-on-surface-variant); font-size: 12px; font-weight: 600; display: flex; flex-direction: column; gap: 5px; }

  .dash-cycle { display: flex; gap: 6px; margin: 12px 0; }
  .dash-plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
  .dash-plan {
    border: 1px solid var(--st-outline-variant);
    border-radius: 12px;
    padding: 12px;
    background: var(--st-surface-container);
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .dash-plan.current { border-color: rgba(0, 168, 132, .6); box-shadow: 0 0 0 1px rgba(0, 168, 132, .25) inset; }
  .dash-plan-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
  .dash-plan-head b { color: var(--st-on-surface); font-size: 14px; }
  .dash-plan-sub { color: var(--st-on-surface-variant); font-size: 11px; }

  .dash-org {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    width: 100%; text-align: left;
    padding: 12px 0;
    background: none; border: 0; border-bottom: 1px solid rgba(61, 74, 68, .3);
    color: var(--st-on-surface); cursor: pointer;
  }
  .dash-org b { font-size: 14px; }
  .dash-org-sub { display: block; color: var(--st-on-surface-variant); font-size: 11.5px; margin-top: 2px; }

  .dash-checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
  .dash-checklist li { font-size: 12.5px; padding-left: 22px; position: relative; color: var(--st-on-surface-variant); }
  .dash-checklist li::before { position: absolute; left: 0; top: 0; font-weight: 700; }
  .dash-checklist li.done::before { content: '✓'; color: var(--st-secondary); }
  .dash-checklist li.todo::before { content: '○'; color: var(--st-outline); }

  .dash-feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
  .dash-feed li { display: flex; flex-direction: column; gap: 1px; }
  .dash-feed b { color: var(--st-on-surface); font-size: 12.5px; font-weight: 600; }
  .dash-feed span { color: var(--st-outline); font-size: 11px; }

  @media (max-width: 720px) {
    /* One column means the two children become two grid ROWS. The desktop rule
       align-self:start left the nav at its natural height inside a stretched
       row, which opened a ~200px dead gap above the page heading. */
    .dash {
      grid-template-columns: 1fr;
      grid-template-rows: minmax(0, 1fr);
      align-content: stretch;
    }
    /* The section switcher becomes a bottom bar on phones so the same place
       always works for jumping between sections, matching the main app's tab
       bar. It is out of the grid flow now, so the body reserves its height. */
    .dash-nav {
      position: fixed;
      left: 0; right: 0; bottom: 0; top: auto;
      z-index: 95;
      align-self: stretch;
      flex-direction: row;
      align-items: center;
      gap: 6px;
      overflow-x: auto;
      border-right: 0;
      border-top: 1px solid var(--st-outline-variant);
      border-bottom: 0;
      max-height: none;
      padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
      box-shadow: 0 -6px 18px rgba(0, 0, 0, .28);
      scrollbar-width: none;
      -ms-overflow-style: none;
    }
    .dash-nav::-webkit-scrollbar { display: none; }
    /* The brand block is redundant once the bar sits at the bottom. */
    .dash-brand { display: none; }
    .dash-nav nav { flex-direction: row; gap: 4px; }
    .dash-nav-item { white-space: nowrap; padding: 7px 10px; font-size: 12px; }
    .dash-exit { margin: 0 0 0 auto; white-space: nowrap; }
    .dash-main { padding: 14px 14px calc(92px + env(safe-area-inset-bottom)); }
  }

  /* ---------- organisation workspace ---------- */
  .ws-modal { max-width: 560px; width: 100%; max-height: 86vh; overflow-y: auto; }
  .ws-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
  .ws-title b { color: var(--st-on-surface); font-size: 16px; }
  .ws-title .fc-sub { color: var(--st-on-surface-variant); font-size: 11.5px; margin-top: 2px; }
  .ws-tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 6px 0 12px; }
  .ws-tabs::-webkit-scrollbar { display: none; }
  .ws-tab {
    flex: none;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--st-surface-high);
    border: 1px solid rgba(61, 74, 68, .4);
    color: var(--st-on-surface-variant);
    font-size: 12px; font-weight: 600;
  }
  .ws-tab.active {
    background: var(--st-primary-container);
    border-color: var(--st-primary-container);
    color: var(--st-on-primary-container);
  }
  .ws-body { display: flex; flex-direction: column; gap: 4px; }
  .ws-form { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
  .ws-form label { color: var(--st-on-surface-variant); font-size: 12px; font-weight: 600; }
  .ws-form input, .ws-form select {
    margin-top: 5px; width: 100%;
    background: var(--st-surface-container);
    border: 1px solid var(--st-outline-variant);
    border-radius: 10px;
    color: var(--st-on-surface);
    padding: 10px 12px;
    font-size: 14px;
  }
  .ws-error {
    background: rgba(255, 180, 171, .12);
    border: 1px solid rgba(255, 180, 171, .35);
    color: var(--st-error);
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 12.5px;
    margin-bottom: 8px;
  }
  .ws-modal .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; word-break: break-all; color: var(--st-primary); }
  .ws-modal .kv { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid rgba(61, 74, 68, .35); }
  .ws-modal .kv span { color: var(--st-outline); font-size: 12px; }
  .ws-modal .kv b { color: var(--st-on-surface); font-size: 12.5px; text-align: right; }
  .status-item {
    background: var(--st-surface-low);
    border: 1px solid var(--st-outline-variant);
  }
  .status-item p { color: var(--st-on-surface); }
  .status-item .st-meta { color: var(--st-outline); }
  .st-viewers {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(61, 74, 68, .5);
    font-size: 11px;
    line-height: 15px;
    color: var(--st-on-surface-variant);
  }
  .st-viewers b { color: var(--st-primary); font-weight: 600; }
  .st-viewers .ic { color: var(--st-outline); }

  /* ---------- developer chrome ----------
     The transport chip used to read "relay connected" on the home screen. The
     Stitch header has no such element, "relay" is internal jargon, and it sits
     under a lock icon telling users their messages go through a server. Hide it
     while healthy; only surface it when the link is actually down. */
  #net-chip.chip.ok { display: none; }
  #net-chip.chip.warn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 180, 171, .14);
    border: 1px solid rgba(255, 180, 171, .35);
    color: var(--st-error);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .02em;
    padding: 3px 8px;
    border-radius: 999px;
  }

  /* build stamp: legible on dark instead of #77718e on #faf9ff */
  .proto-badge {
    background: var(--st-surface-container);
    color: var(--st-outline);
    border: 1px solid rgba(61, 74, 68, .5);
    border-radius: 8px;
  }

  /* ---------- app header: brand + E2EE chip + handle ---------- */
  .app-head,
  .side-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 56px;
    padding: 7px 14px;
    background: var(--st-surface-high);
    border-bottom: 1px solid rgba(61, 74, 68, .5);
  }
  .brand-block { display: flex; align-items: center; gap: 10px; min-width: 0; }
  .brand-shield {
    width: 32px; height: 32px; border-radius: 999px;
    display: inline-flex; align-items: center; justify-content: center;
    background: rgba(0, 168, 132, .2);
    border: 1px solid rgba(89, 220, 181, .3);
    color: var(--st-primary);
    flex: none;
  }
  .brand-text { display: flex; flex-direction: column; min-width: 0; }
  .brand-row { display: flex; align-items: center; gap: 6px; }
  .brand-name {
    color: var(--st-primary);
    font-size: 18px; font-weight: 700;
    letter-spacing: -.01em; line-height: 22px;
  }
  .e2ee-chip {
    display: inline-flex; align-items: center; gap: 3px;
    padding: 1px 6px; border-radius: 999px;
    background: var(--st-surface-container);
    border: 1px solid rgba(61, 74, 68, .6);
    color: var(--st-primary);
    font-size: 9px; font-weight: 700;
    letter-spacing: .04em; text-transform: uppercase;
  }
  .brand-handle {
    display: flex; align-items: center; gap: 4px;
    color: var(--st-on-surface-variant);
    font-size: 10px; font-weight: 500; letter-spacing: .02em;
  }
  .side-head-actions { display: flex; align-items: center; gap: 8px; }
  .side-head .me-chip { padding: 0; background: none; }

  /* persistent search row (design: always visible under the header) */
  .head-search {
    display: flex; align-items: center; gap: 8px;
    margin: 6px 12px 8px;
    padding: 7px 10px;
    background: var(--st-surface-container);
    border: 1px solid rgba(61, 74, 68, .35);
    border-radius: 8px;
  }
  .hs-icon { color: var(--st-outline); display: inline-flex; flex: none; }
  .hs-input {
    flex: 1; min-width: 0;
    background: none; border: 0; outline: none;
    color: var(--st-on-surface);
    font-size: 13px;
    font-family: inherit;
  }
  .hs-input::placeholder { color: var(--st-outline); }
  .hs-kbd {
    color: var(--st-outline);
    background: var(--st-surface-high);
    border: 1px solid rgba(61, 74, 68, .5);
    border-radius: 4px;
    font-size: 9px; font-weight: 600;
    padding: 1px 5px;
    white-space: nowrap;
    flex: none;
  }

  /* sector pill counters */
  .pill-count {
    font-style: normal;
    font-size: 10px; font-weight: 700;
    padding: 0 5px;
    border-radius: 999px;
    background: rgba(0, 0, 0, .25);
    margin-left: 4px;
    color: var(--st-on-surface-variant);
  }
  .cat-pill.active .pill-count {
    background: rgba(0, 52, 39, .25);
    color: var(--st-on-primary-container);
  }

  /* archived banner row */
  .archived-row {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 14px;
    background: var(--st-surface-low);
    border-bottom: 1px solid rgba(23, 33, 39, .8);
    cursor: pointer;
  }
  .archived-row:hover { background: rgba(33, 43, 50, .6); }
  .ar-icon { color: var(--st-primary); display: inline-flex; }
  .ar-label { flex: 1; color: var(--st-on-surface); font-size: 15px; font-weight: 600; }
  .ar-count {
    color: var(--st-primary);
    background: rgba(0, 168, 132, .2);
    border: 1px solid rgba(89, 220, 181, .25);
    border-radius: 999px;
    font-size: 10px; font-weight: 700;
    padding: 1px 7px;
  }
  .ar-chev { color: var(--st-outline); font-size: 15px; line-height: 1; }

  /* security status strip */
  .sec-strip {
    display: flex; align-items: center; gap: 6px;
    padding: 5px 14px 7px;
    border-bottom: 1px solid rgba(33, 43, 50, .5);
    font-size: 10px;
    color: var(--st-outline);
  }
  .sec-dot {
    width: 6px; height: 6px; border-radius: 999px;
    background: var(--st-secondary-container);
    box-shadow: 0 0 0 3px rgba(6, 200, 93, .12);
    flex: none;
  }
  .sec-text { flex: 1; }
  .sec-right { color: var(--st-primary); font-weight: 700; }

  /* row density to match the design */
  .chat-item { min-height: 68px; padding: 9px 14px; }
  .chat-item .avatar { width: 48px; height: 48px; }
  .ci-name { font-size: 15.5px; }

  /* keep the footer note clear of the floating button */
  .encrypt-banner { padding: 10px 88px 14px 24px; text-align: left; }
  @media (max-width: 420px) { .encrypt-banner { padding-right: 76px; } }

  /* the assistant tile still used the old purple gradient */
  .avatar.ai-avatar {
    background: linear-gradient(135deg, #00a884, #59dcb5) !important;
    color: var(--st-on-primary-container) !important;
  }

  /* compact active pill in the bottom bar */
  .tab-nav-item.active {
    background: rgba(0, 168, 132, .2);
    border-radius: 14px;
  }

  /* ---------- save-contact prompt ----------
     Free-text name now, not a fixed list: "Amma", "Mom", "Bhai", any language. */
  .rel-input {
    width: 100%;
    margin: 14px 0 4px;
    padding: 11px 13px;
    min-height: 44px;
    border-radius: 12px;
    border: 1.5px solid var(--st-outline-variant);
    background: var(--st-surface-container);
    color: var(--st-on-surface);
    font: inherit;
    outline: none;
  }
  .rel-input::placeholder { color: var(--st-outline); }
  .rel-input:focus { border-color: rgba(89, 220, 181, .45); background: var(--st-surface-high); }
  .rel-modal .row { margin-top: 10px; display: flex; gap: 8px; }
}

  /* Missed-call count on the grouped call row (audit: calls screen). */
  .si-count {
    display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 6px;
    border-radius: 999px; font-size: 11px; font-weight: 700; line-height: 18px;
    text-align: center; background: rgba(207, 102, 121, .18); color: #ef8fa1;
  }
