/*
 * mobile.css — phone / tablet responsive rules per t_a88cc617 spec
 * (SHA-256 3b7a3d853083249f9f31d8c87112c0629e801566d191cd1353f3aaa2df645a52, run 992).
 *
 * Loaded from Knowledge.dc.html after the inline tokens block. Every rule
 * is scoped inside a media query so desktop (>=921px) is byte-identical
 * to the published live base. Inline `style="display:grid;..."` from the
 * carrier's JS breakpoint logic is supplemented — not replaced — so the
 * carrier's existing `narrow`/`phone` collapse continues to work and we
 * just add the spec's two-row header + drawer geometry + safe-area + 44px
 * touch targets that the JS breakpoints cannot express.
 *
 * SELECTOR DISCIPLINE (pitfall from round-1 review):
 * Browsers serialize inline styles with spaces after colons (top: 0px, not top:0)
 * and rgba with comma-space (rgba(20, 40, 50, 0.35), not rgba(20,40,50,.35)).
 * Selectors that substring-match unserialized source-format NEVER match in
 * the rendered DOM. Every selector below was empirically verified against
 * the rendered DOM via a CDP probe at 390x844, 768x1024, 1440x900 with an
 * authenticated local render (stubbed /knowledge/v1/me — no credentials).
 *
 * The carrier uses the dc-logic framework, which renders the shell at:
 *   body > div#dc-root > div.sc-host > div.flex-row > div[sidebar / main]
 * The sidebar is the only `div[style*="width: 250px"]` in the page; the
 * header is the only `header[style*="position: sticky"][style*="top: 0px"]`.
 * `data-knowledge-auth` is set on <html>, not on a body div, so ancestor
 * selectors under it cannot match. Use direct element selectors instead.
 *
 * Tokens, colors, typography — none of this file touches var(--*).
 */

@media (max-width: 920px) {
  /* ─── §2.1 — Drawer scrim ─────────────────────────────────────────
     The carrier renders a backdrop element via <sc-if value="{{ backdrop }}">
     (line 214-216 of Knowledge.dc.html). When the drawer is open, this
     element exists in the DOM with style="position:fixed;inset:0;...;background:rgba(20, 40, 50, 0.35);..."
     The serialized rgba has spaces (post-colon) and comma-space separators,
     not the source-format compact form. The backdrop is unique when present. */
  div[style*="rgba(20, 40, 50, 0.35)"] {
    background: rgba(18, 40, 50, 0.45) !important;
  }
}

/* ─── §R4 — Explorer phone-template 3-cell row correction (breakpoint
   independent). Carrier sets exGrid = phone ? '26px minmax(0,1fr) 0 0
   78px 0 0' (7 tracks) when `phone = ew < 720`. DOM renders 3 cells at
   phone (selection, name+sub, status) — `<sc-if exWide>` and
   `<sc-if exNotNarrow>` are both false when narrow=true. Auto-placement
   then drops child 3 onto track 3 (0px wide), so the "處理中" status
   pill collapses to width=0. The OLD rule `div[role="table"] > div
   [role="row"][style*="grid-template-columns: 26px "] { grid:
   26px 1fr 78px !important; }` was scoped under @media (max-width:
   720px) and missed 768x1024 + fontScale 1.12 (ew≈685, phone=true but
   viewport CSS media query does not fire). Selector markers used here:
     (a) `[style*="grid-template-columns: 26px "]` matches ONLY the
         phone variant (every other template starts with `28px `).
     (b) `:has(> :nth-child(3):last-child)` confirms exactly 3 direct
         children — desktop 7-cell rows (template starts with `28px`)
         and mid 5-cell rows (same) cannot match; narrow 3-cell rows
         also start with `28px`, cannot match.
   Net: only the actual buggy row is corrected, at every viewport.
   Per R4 directive — replaces the old unconditional phone-only rule;
   preserves D1 viewer and D3 billing (which use different templates). */
div[role="table"][aria-label]:not([aria-label="方案比較"])
  > div[role="row"][style*="grid-template-columns: 26px "]:has(> :nth-child(3):last-child) {
  grid-template-columns: 26px minmax(0, 1fr) 78px !important;
}

@media (max-width: 720px) {
  /* ─── §2.2 — Drawer geometry ──────────────────────────────────────
     The sidebar is the only element with width: 250px (serialized form
     has a space after the colon). Spec: 100dvh + min(320px, 85vw) +
     safe-area + 44px touch targets. */
  div[style*="width: 250px"] {
    width: min(320px, 85vw) !important;
    flex-basis: min(320px, 85vw) !important;
    height: calc(100dvh / var(--kz, 1)) !important;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }

  /* Nav items: 36px → 44px tap target (spec §3.1) */
  div[style*="width: 250px"] nav button {
    min-height: 44px !important;
    padding: 12px 10px !important;
  }

  /* Drawer close button: 30px → 44px (spec §3.1).
     The drawer close button renders with aria-label="關閉" (L.close resolves
     to a non-empty string). The lang button does NOT have aria-label
     rendered (verified empirically) — so this selector safely targets only
     the close button. */
  div[style*="width: 250px"] button[aria-label] {
    min-width: 44px !important;
    min-height: 44px !important;
  }

  /* ─── §2.2 — Header two-row on phone ──────────────────────────────
     The carrier's header is the only <header> in the page, with the
     serialized style `position: sticky; top: 0px;`. The framework renders
     inline styles with spaces (post-colon) — substring `position:sticky`
     does NOT match. */
  header[style*="position: sticky"][style*="top: 0px"]:not([style*="display: none"]) {
    display: grid !important;
    grid-template-columns: auto minmax(0, 1fr) auto !important;
    grid-template-rows: auto !important;
    grid-template-areas:
        "hamburger search" !important;
    align-items: center !important;
    row-gap: 6px !important;
    column-gap: 8px !important;
    padding-top: calc(8px + env(safe-area-inset-top)) !important;
    padding-left: 10px !important;
    padding-right: 10px !important;
    padding-bottom: 8px !important;
  }

  /* Hamburger button: <header>'s first direct button child (line 222 of
     Knowledge.dc.html — `<button onClick="{{ openNav }}" aria-label="...">☰</button>`).
     The hamburger has border-radius: 10px (rounded square), so we can
     also disambiguate from the lang button by its lack of pill shape, but
     `first-of-type` is sufficient since it's the only first button child
     of <header>. */
  header > button:first-of-type {
    grid-area: hamburger;
    width: 44px !important;
    height: 44px !important;
    min-width: 44px;
    min-height: 44px;
  }

  /* Search wrapper (the div with relative position around the input).
     Serialized style is `flex: 1 1 0%; min-width: 0px; position: relative; ...`.
     The substring `position: relative` (with space) matches; the source
     format `position:relative` (no space) does NOT match. */
  header > div[style*="position: relative"] {
    grid-area: search;
    min-width: 0 !important;
    width: 100% !important;
  }

  /* Lang toggle button — the only <header> button child with border-radius:
     999px (pill shape). The hamburger has border-radius: 10px (rounded
     square). `header > button[style*="border-radius: 999px"]` is unique.
     Note: aria-label and title attribute selectors were tried but the
     framework does not render them for this button (verified empirically). */
  header > button[style*="border-radius: 999px"] {
    grid-area: lang;
    width: 44px !important;
    height: 44px !important;
    min-width: 44px;
    min-height: 44px;
    padding: 0 !important;
  }

  /* ─── §3.4 — Search palette detached from input ────────────────────
     The search palette (when open) lives inside the search wrapper DIV
     with serialized style `position: absolute; top: 44px; left: 0px; right: 0px; ...`.
     Use the space-suffixed selector to match the rendered DOM. */
  header > div[style*="position: relative"] > div[style*="position: absolute"] {
    position: fixed !important;
    left: 8px !important;
    right: 8px !important;
    top: 64px !important;
  }

  /* ─── §3.6 — Page container safe-area bottom padding ─────────────── */
  main {
    padding-bottom: calc(40px + env(safe-area-inset-bottom)) !important;
  }

  /* ─── §4.5 — Chat composer safe-area + iOS zoom guard ──────────────
     The carrier has no <form> elements (chat composer is a <div>).
     The composer container is rendered with style
     "flex: 0 0 auto; position: sticky; bottom: 0; ..." (line 1513 of
     Knowledge.dc.html). The composer already has position: sticky from
     inline style, so we only need to add safe-area padding.
     The actual chat input is a <textarea> (line 1515) — we set its
     font-size to 16px to prevent iOS auto-zoom on focus. */
  main div[style*="position: sticky"][style*="bottom: 0px"] {
    padding-bottom: env(safe-area-inset-bottom) !important;
  }

  main textarea {
    font-size: calc(16px * var(--kts, 1)) !important;
  }

  /* ─── §4.1 — Overview stats grid: 4 → 2 columns on phone ──────────
     Carrier sets statCols = ew < 560 ? 1fr : ew < 900 ? 2 cols.
     At ≤720 the carrier is already 2-col. Spec wants 2-col explicitly.
     Source-format `repeat(4` does NOT match serialized `repeat(4,`; we use
     the comma suffix.

     SCOPED (RUN-992 fix for D3 billing comparison): the original generic
     selector `[style*="repeat(4,"]` ALSO matched the billing comparison
     rows (cmpGrid = '116px repeat(4, minmax(76px, 1fr))') on phone and
     collapsed the 5-track row to repeat(2, 1fr) — header values then
     wrapped into the wrong plan columns. The overview stats grid is the
     only element with `repeat(4, minmax(0, 1fr))` (note `minmax(0, 1fr)`,
     not `minmax(76px, 1fr)`), and lives inside the overview route only.
     We narrow the selector to the overview cards' wrapper so the billing
     comparison keeps its 5 tracks and horizontal-scrolls inside its
     overflow wrapper as the spec requires. */
  [style*="repeat(4, minmax(0, 1fr)"] {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  /* ─── §4.8 — Sources card stats (3-col dl) ──────────────────────────
     Serialized form: `grid-template-columns: repeat(3, ...)` (space after
     colon, comma after digit). */
  dl[style*="repeat(3,"] {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  /* ─── §4.11 — Usage bucket grid (3-col) ───────────────────────────
     Serialized form: `grid-template-columns: repeat(3, minmax(0, 1fr))`. */
  [style*="repeat(3, minmax(0, 1fr)"] {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  /* ─── §4.12 — Billing 3-col plans → 1-col on phone ───────────────── */
  [style*="repeat(3, minmax(0, 1fr)"] {
    grid-template-columns: 1fr !important;
  }

  /* ─── §4.7 — Timeline row 110px 1fr → 1fr (date above title) ────────
     Carrier already collapses to single column on narrow via JS. */

  /* ─── §4.9 — Jobs / §4.10 Trash / §4.13 Settings tabs pill ─────────
     Allow horizontal scroll rather than wrap for tab pills. Serialized
     form has spaces: `display: flex; ... flex-wrap: wrap;`. */
  [style*="display: flex"][style*="flex-wrap: wrap"] > button[style*="border-radius: 999px"] {
    flex: 0 0 auto;
  }
}

@media (max-width: 920px) and (min-width: 721px) {
  /* ─── §1 — Tablet (721-920) ───────────────────────────────────────
     Carrier's `narrow` already collapses many things to 1fr; we only
     add what the carrier doesn't (page padding, dialog geometry). */

  /* §3.4 — Search palette detached */
  header > div[style*="position: relative"] > div[style*="position: absolute"] {
    position: fixed !important;
    left: 8px !important;
    right: 8px !important;
    top: 64px !important;
  }

  /* §3.6 — Page padding safe-area */
  main {
    padding-bottom: calc(40px + env(safe-area-inset-bottom)) !important;
  }
}

/* ─── §3.4 — Dialog bottom sheet on phone ────────────────────────────
   The carrier has no active <dialog> usage; .k-panel is defined-but-unused.
   This rule covers any future bottom-sheet usage (e.g., theme picker
   anchored outside the trigger). The upload dialog renders with
   `role="dialog"` and is positioned centered — we leave it centered on
   phone (the dialog width is already min(880px, 100%) which fits a 390px
   viewport at 100% width).
   2026-10-09: not the recordings/chat modals (.knr overlay = full-screen backdrop
   that centres its own card); forcing top:auto + 88dvh on the backdrop pushed
   the card's bottom (and its buttons) off-screen. */
@media (max-width: 720px) {
  .k-panel,
  [role="dialog"]:not(.knr):not(.kfb-dlg) {   /* .kfb-dlg = knConfirm/knAlert: centred card on phones too (owner 11-15 方案 C) */
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    top: auto !important;
    max-height: calc(88dvh / var(--kz, 1)) !important;
    border-radius: var(--r-card, 16px) var(--r-card, 16px) 0 0 !important;
    padding-bottom: env(safe-area-inset-bottom) !important;
  }

  /* ─── RUN-992 §D1 — Peek/doc-viewer dialog on phone ───────────────
     The peek dialog (`openDoc`) is rendered as a centered modal
     (`position:fixed; inset:0; display:grid; place-items:center`). Its
     inner panel is `display:flex; flex-direction:column` with a header
     row (`display:flex; align-items:flex-start; gap:12px`) containing an
     icon, the title block, and a row of action buttons + close. On
     short viewports (390x420 with keyboard, 390x844 portrait) the
     flex header lets the action buttons wrap below the title, but the
     title block's `flex:1;min-width:0` still allows the meta line to
     wrap into a tall vertical strip, leaving <80px for the body — the
     preview becomes a thin sliver and scroll is constrained.

     SCOPE: only `[data-peek]` dialog. Other modals (upload, onboarding,
     duplicate, memory, conversation, security, etc.) keep their own
     styles — verified by SUPERVISOR note RUN-992 (don't broaden global
     dialog selectors).

     Fix: convert the inner header to a 2-row grid (title row full-width,
     actions row below). Keep the close button at the top-right (44px tap
     target). Force the body to `min-height:0; overflow:auto` so its
     inner `overflow:auto` actually scrolls when the keyboard eats
     viewport height. The peek dialog itself keeps the centered
     bottom-sheet geometry from the rule above (≤720 base). */
  [data-peek] {
    padding: 0 !important;
    align-items: end !important;
  }
  /* Inner panel: stack title-row + actions-row, give the body room to
     scroll. The inner panel is the first child div of the [data-peek]. */
  [data-peek] > div {
    width: 100% !important;
    max-height: calc(92dvh / var(--kz, 1)) !important;
    border-radius: var(--r-card, 16px) var(--r-card, 16px) 0 0 !important;
  }
  /* Header row (data-peek-header) — vertical stack. */
  [data-peek-header] {
    display: grid !important;
    grid-template-columns: auto minmax(0, 1fr) auto !important;
    grid-template-rows: auto auto !important;
    grid-template-areas:
      "icon  title  close"
      "acts  acts   acts" !important;
    align-items: start !important;
    row-gap: 10px !important;
    column-gap: 10px !important;
    padding: 12px 14px !important;
  }
  /* Icon (first span with aria-hidden inside the header). */
  [data-peek-header] > span[aria-hidden="true"] {
    grid-area: icon !important;
    font-size: calc(18px * var(--kts, 1)) !important;
    line-height: 1.4 !important;
  }
  /* Title block (the inner div with name+badge and meta lines).
     EXCLUDE [data-peek-actions]: the actions div is also a direct child
     of the header, but it has its own grid-area rule below. Without this
     exclusion the title-block rule has higher specificity (1 attr + 1
     element > 1 attr) and clobbers the actions layout. */
  [data-peek-header] > div:not([data-peek-actions]) {
    grid-area: title !important;
    min-width: 0 !important;
  }
  [data-peek-header] > div:not([data-peek-actions]) > div:first-child {
    flex-wrap: wrap !important;
  }
  [data-peek-header] > div:not([data-peek-actions]) > div:last-child {
    text-wrap: pretty !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
  }
  /* Actions container — full-width row of action buttons + close. */
  [data-peek-actions] {
    grid-area: acts !important;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 7px !important;
    justify-content: flex-start !important;
    overflow-x: auto !important;
  }
  /* Close button — the LAST button inside data-peek-actions. */
  [data-peek-actions] > button[aria-label] {
    grid-area: close !important;
    margin-left: auto !important;
    min-width: 44px !important;
    min-height: 44px !important;
    width: 44px !important;
    height: 44px !important;
  }
  /* Body (any direct child block of the inner panel other than the
     header). Allow inner content to scroll when viewport is short. */
  [data-peek] > div > *:not([data-peek-header]) {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
}

/* ─── §5.2 — Recordings player hit area ──────────────────────────────── */
@media (max-width: 720px) {
  /* Player SVG nodes — enlarge hit area to ≥24px (spec §5.1). */
  svg[role="button"] rect[fill="transparent"] {
    cursor: pointer;
  }
}

/* ─── §5.4 — Route-specific layout guards (M-A graph side panel,
   M-B billing route) ─────────────────────────────────────────────
   Live probe at 390x844 (mobile-postaction results-390.json) found:
     M-A: graph route side panel forces innerWidth to 429 (parent
          flex-row grows because the sidebar's `position:fixed`
          marker is stripped on re-render — the carrier re-renders
          after route change without setting all the common base
          fields, so the sidebar falls into normal flex flow at
          320px width and pushes everything past 390).
     M-B: same root cause — billing route sees 109 elements
          overflow because the flex-row contains the sidebar.
   Fix: at ≤720, force the sidebar back out of flow (override the
   inline `position:` value with `!important`), and force the
   flex-row + main to be exactly viewport-width. Per-route guard
   for graph filter+canvas+inspector 3-col grid and the billing
   plan-matrix wrapper (which has overflow-x:auto and a 474px
   min-width). */

@media (max-width: 720px) {
  /* Always pin the sidebar out of flow on phone — the carrier's
     `position:{{ sidePos }}` interpolation loses `sidePos` on the
     post-route re-render, leaving the inline style empty
     (computed: static). Forcing `fixed` + `translateX(-100%)` keeps
     the drawer fully off-screen when closed (the previous -260px
     left a 60px strip at the left edge because the drawer is 320px
     wide — that strip masked page content even with overflow-x:hidden
     up the chain), and removes the drawer's footprint from the
     flex-row entirely. */
  div[style*="width: 250px"] {
    position: fixed !important;
    height: calc(100dvh / var(--kz, 1)) !important;
    /* Re-assert the mobile width (CSS already sets min(320px, 85vw),
       but explicit here so the inline `width:250px` from the
       carrier template doesn't slip through on re-render). */
    width: min(320px, 85vw) !important;
    flex-basis: min(320px, 85vw) !important;
  }

  /* When the drawer is OPEN the carrier inserts a scrim sibling with
     inline style containing `rgba(20, 40, 50, 0.35)` (serialized with
     spaces — match the serialized form, not the source compact form).
     The body has the scrim only while navOpen is true at narrow
     viewport; use :has() to flip the drawer transform back to 0 so
     the user sees the full drawer and tap targets. The carrier's own
     inline transform translateX(0) (sideTx='0px' on open) is
     suppressed by the !important above; we restore it here. */
  body:has(div[style*="rgba(20, 40, 50, 0.35)"]) div[style*="width: 250px"] {
    transform: translateX(0) !important;
  }
  /* 2026-10-07: key the closed state off the drawer's own inline transform
     (translateX(0px) only while navOpen) — WebKit does not always re-run the
     :has() rule above, which left the drawer off-screen after a tap. */
  div[style*="width: 250px"]:not([style*="translateX(0px)"]) {
    transform: translateX(-100%) !important;
  }

  /* The flex-row that contains the sidebar — constrain to viewport
     width. The inline `display:flex;align-items:stretch` stays,
     but we cap its overall width to 100vw so any leaked child
     (sidebar, leaked panels) can't widen the document. */
  body > div#dc-root > div.sc-host > div[style*="display: flex"] {
    max-width: 100vw !important;
    width: auto !important;
    /* Hide any horizontal overflow at the row level — sidebar is
       out of flow (above rule) so the only children here are
       <main> plus read-only banner. Their content is clipped. */
    overflow-x: hidden !important;
  }

  /* The flex-row's only flex child after the sidebar is `position:fixed`
     is `<main>` — constrain main to 100% of the row. */
  body > div#dc-root > div.sc-host > div[style*="display: flex"] > main {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
  }

  /* Main and any of its immediate inner containers must never
     exceed viewport width — chain of `max-width: 100%` keeps
     every level clipped. */
  main,
  main > div,
  main > div > div {
    max-width: 100% !important;
    width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  /* Clip horizontal overflow at every level so off-edge children
     (e.g., the billing plan-matrix with min-width:474px, or any
     auto-fit grid that picks a wider track) do not visually bleed
     past the viewport edge. The plan-matrix wrapper itself still
     has its own overflow-x:auto for in-card horizontal scroll. */
  body,
  body > div#dc-root,
  body > div#dc-root > div.sc-host,
  body > div#dc-root > div.sc-host > div,
  main {
    overflow-x: hidden !important;
  }

  /* §5.4.1 — Graph route (知識圖譜). The carrier sets gCols to
     '1fr' at phone, but the filter/canvas/inspector wrapper uses
     `display:grid` with explicit `grid-template-columns: 1fr` and
     gap. We don't need to override the carrier; we just need to
     make sure no descendant uses a fixed-width track that pushes
     past 100vw. The graph filter bar and canvas SVG already use
     width:100%. The inspector sheet (`position:fixed; left:0;
     right:0; bottom:0`) is a bottom-sheet — no overflow. We do
     need to clip the page-level scroll area in case any panel
     overflows. */
  main div[style*="grid-template-columns: 1fr"] {
    max-width: 100% !important;
  }
  /* The 3-column variant used at mid/desktop is unreachable at
     phone because `narrow || mid` is true (mid needs ew<1200;
     at 390 with fontScale 1.12 we have ew=348< 1200, so mid=true,
     meaning the ternary `narrow || mid ? '1fr' : '212px minmax(0,1fr)
     330px'` evaluates to '1fr' anyway). The defensive rule below
     neutralises the 3-col pattern if it ever leaks through. */
  div[style*="grid-template-columns: 212px"],
  div[style*="grid-template-columns:212px"] {
    grid-template-columns: 1fr !important;
  }
  /* The graph filter panel (first column of the grid) must never
     overflow horizontally on its own — its descendants include
     range sliders and kind-list rows. */
  div[style*="grid-template-columns: 1fr"] > div[style*="border-radius: 16px"]:first-child,
  div[style*="grid-template-columns: 1fr"] > div:first-child {
    max-width: 100% !important;
    min-width: 0 !important;
  }
  /* Graph search input on the page header — inline
     `width:190px` lives on the graph search row. Cap it. */
  main input[style*="width: 190px"],
  main input[style*="width:190px"] {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  /* §5.4.2 — Billing route (帳務). The billing summary cards use
     `repeat(auto-fit, minmax(212px, 1fr))` which is fine on a
     390vw. The `buyKinds` (subscription vs credits) panel uses
     `1fr` at narrow so it stacks. The tier-feats grid also uses
     auto-fit minmax(240px,1fr). The plan matrix wrapper has
     overflow-x:auto with min-width:474px — at phone we already
     have horizontal scroll inside the wrapper, which is allowed.
     The meter table uses `minmax(0,1fr) 0 84px 0 0` (5-col) which
     fits at 390. The cmpGrid is `116px repeat(3,minmax(76px,1fr))`
     = 116+3*76=344px which fits. Belt-and-braces: shrink the
     plan-matrix table itself so its bounding rect doesn't extend
     past iw. The overflow-x:auto wrapper still allows in-card
     horizontal scroll on swipe. */
  main div[role="table"] {
    min-width: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
  }
  /* The meter/credit rows have inline `minmax(0,1fr) 0 84px 0 0`
     (5-col) and `0 minmax(0,1fr) 0 58px 0` (ledger). Those keep
     at 84px and 58px — fine at 390. */

  /* ─── RUN-992 §D3 — Billing comparison on phone ───────────────────
     The cmpGrid template `116px repeat(4, minmax(76px, 1fr))` gives the
     plan-matrix a natural width of 116 + 4*76 = 420px (plus 4*8px gaps
     = 32px = 452px), which exceeds the 360-430 phone viewport. The
     table lives inside an `overflow-x:auto` wrapper that lets the user
     scroll horizontally to compare plans. After the §D3 fix above
     removed the over-broad `[style*="repeat(4,"]` rule, the rows now
     keep all 5 tracks at minimum 76px width per plan column — exactly
     the spec intent. We add a defensive guard so no other rule can
     collapse this specific row back to 2 tracks. The marker is the
     unique starting `116px ` (no other table starts with 116px). */
  div[role="table"] > div[role="row"][style*="grid-template-columns: 116px "] {
    grid-template-columns: 116px repeat(4, minmax(76px, 1fr)) !important;
    min-width: max(var(--cmp-min, 452px), 100%) !important;
  }
  /* The plan-matrix table itself must NOT shrink below cmpMinW, and its
     wrapper must allow horizontal scroll. The wrapper is the parent of
     the role="table" with aria-label "方案比較". */
  div[role="table"][aria-label="方案比較"] {
    min-width: 0 !important;
    width: max-content !important;
  }

  }

/* ─── Reduced motion respect ────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
/* ─── 2026-10-04: touch targets on phones ───────────────────────────────
   Many controls rendered under 32px tall on a phone. Apple/Google guidance is
   ~44px; 40px keeps dense toolbars usable without breaking their layout. */
@media (max-width: 760px) {
  main button, main [role="button"], main select, [role="dialog"] button,
  nav button, aside button {
    min-height: 40px;
  }
  main input[type="checkbox"], [role="dialog"] input[type="checkbox"] {
    width: 22px !important;
    height: 22px !important;
  }
  main input[type="text"], main input[type="search"], main input:not([type]), main textarea, main select {
    font-size: calc(16px * var(--kts, 1)) !important; /* stops iOS zooming into the field on focus */
  }
}

/* Phones: the page is never wider than the screen (login overlay included). */
@media (max-width: 920px) {
  html, body { max-width: 100%; overflow-x: clip; }
  iframe { max-width: 100%; }
}

/* ─── 2026-10-07: news pages fill the screen on phones ─────────────────
   The root is CSS-zoomed for the text-size setting (--kz, set by applyScale).
   WebKit lays a nested iframe out in unzoomed pixels, so the news frame came
   out narrower than the screen inside and wider than its window (sideways
   scrolling inside the news page, blue edges around it). Cancelling the zoom
   on the frame itself makes its window exactly the visible area. The page
   around it gets no padding and no scroll of its own, so a swipe always
   scrolls the news, never the blue page behind it. */
@media (max-width: 920px) {
  main:has(> div > iframe[data-knowledge-news-host]) {
    padding: 0 !important;
    overflow: hidden !important;
  }
  html, body { overscroll-behavior-x: none; }
}
/* Every width: the news frame never takes the page zoom (the text-size
   setting); news pages scale only their text instead (news-host/pages,
   --kn-ts), so their layout keeps its widths. */
iframe[data-knowledge-news-host] {
  zoom: calc(1 / var(--kz, 1));
  width: 100% !important;
  min-width: 0 !important;
  max-width: none !important;
  height: 100% !important;
}

/* ─── 2026-10-10 v2: 「開啟左側選單」 in the Wharf × Coterie language ──────
   Trigger: a round glass button (Coterie's top-bar buttons): hairline ring,
   soft long shadow, two ink lines plus a short gold middle line that reaches
   full length when pressed. The pages build it with different classes and
   inner spans (kn-menu-btn in the template/chat/recordings/admin, k??-menu in
   the React pages); the spans are hidden and the glyph is drawn here, so a
   theme only swaps the tokens. News pages draw the same button inside their
   frame (news-host/pages/*.html, script data-kn-ui). New page modules with
   their own k??-menu class must be added to these lists. */
:is(.kn-menu-btn, .kov-menu, .kne-menu, .kgx-menu, .kjc-menu, .knq-menu, .ktl-menu, .kns-menu, .knt-menu, .knu-menu, .knb-menu, .kno-menu, .kvo-menu) {
  position: relative; flex: 0 0 auto !important;
  display: inline-block !important; vertical-align: middle;
  width: 44px !important; height: 44px !important; min-width: 44px !important; min-height: 44px !important;
  padding: 0 !important; border: 0 !important; border-radius: 50% !important;
  background: color-mix(in oklab, var(--surface, #fff) 86%, transparent) !important;
  -webkit-backdrop-filter: blur(12px) saturate(1.3); backdrop-filter: blur(12px) saturate(1.3);
  box-shadow: 0 0 0 1px color-mix(in oklab, var(--ink, #1E3038) 11%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, .75),
    0 12px 24px -16px color-mix(in oklab, var(--ink, #1E3038) 60%, transparent) !important;
  cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none;
  transition: transform .35s cubic-bezier(.22, 1, .36, 1), box-shadow .3s ease !important;
}
:is(.kn-menu-btn, .kov-menu, .kne-menu, .kgx-menu, .kjc-menu, .knq-menu, .ktl-menu, .kns-menu, .knt-menu, .knu-menu, .knb-menu, .kno-menu, .kvo-menu) > * { display: none !important; }
:is(.kn-menu-btn, .kov-menu, .kne-menu, .kgx-menu, .kjc-menu, .knq-menu, .ktl-menu, .kns-menu, .knt-menu, .knu-menu, .knb-menu, .kno-menu, .kvo-menu)::before,
:is(.kn-menu-btn, .kov-menu, .kne-menu, .kgx-menu, .kjc-menu, .knq-menu, .ktl-menu, .kns-menu, .knt-menu, .knu-menu, .knb-menu, .kno-menu, .kvo-menu)::after {
  content: ""; position: absolute; left: 11px; top: 11px; width: 22px; height: 22px; pointer-events: none;
  -webkit-mask: var(--kn-glyph) center / 22px 22px no-repeat; mask: var(--kn-glyph) center / 22px 22px no-repeat;
  transform-origin: 4px 50%; transition: transform .45s cubic-bezier(.22, 1, .36, 1);
}
:is(.kn-menu-btn, .kov-menu, .kne-menu, .kgx-menu, .kjc-menu, .knq-menu, .ktl-menu, .kns-menu, .knt-menu, .knu-menu, .knb-menu, .kno-menu, .kvo-menu)::before {
  --kn-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22 22' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round'%3E%3Cpath d='M4 6.5h14M4 15.5h14'/%3E%3C/svg%3E");
  background: var(--ink, #1E3038);
}
:is(.kn-menu-btn, .kov-menu, .kne-menu, .kgx-menu, .kjc-menu, .knq-menu, .ktl-menu, .kns-menu, .knt-menu, .knu-menu, .knb-menu, .kno-menu, .kvo-menu)::after {
  --kn-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22 22' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M4 11h7'/%3E%3C/svg%3E");
  background: var(--accent, #B3924F);
}
:is(.kn-menu-btn, .kov-menu, .kne-menu, .kgx-menu, .kjc-menu, .knq-menu, .ktl-menu, .kns-menu, .knt-menu, .knu-menu, .knb-menu, .kno-menu, .kvo-menu):active { transform: scale(.92) !important; }
:is(.kn-menu-btn, .kov-menu, .kne-menu, .kgx-menu, .kjc-menu, .knq-menu, .ktl-menu, .kns-menu, .knt-menu, .knu-menu, .knb-menu, .kno-menu, .kvo-menu):active::after { transform: scaleX(2); }
@media (hover: hover) {
  :is(.kn-menu-btn, .kov-menu, .kne-menu, .kgx-menu, .kjc-menu, .knq-menu, .ktl-menu, .kns-menu, .knt-menu, .knu-menu, .knb-menu, .kno-menu, .kvo-menu):hover::after { transform: scaleX(2); }
}
:is(.kn-menu-btn, .kov-menu, .kne-menu, .kgx-menu, .kjc-menu, .knq-menu, .ktl-menu, .kns-menu, .knt-menu, .knu-menu, .knb-menu, .kno-menu, .kvo-menu):focus-visible {
  outline: none; box-shadow: 0 0 0 2px var(--surface, #fff), 0 0 0 4px var(--accent, #B3924F) !important;
}

h1 .kn-menu-btn { margin-right: 10px; }
/* 2026-11-14 owner 18:04 「Icon 與分頁名稱間的空格不用這麼大」: menu button → title = 10 px, the title's middle on the button's
   middle — exactly the news tab (新聞探索 frame-head.js: .nx-row gap 10px, items centred). Each page's header row has its own
   flex gap (8–30 px); the button's right margin takes it back to 10 px. Rows that align their items to the top get the title
   block moved down by half the difference between the 44 px button and the title line (33.6 px × --kts). A new page header: make it
   gap 10px + align-items center, or add its row here. QA: staging/qa/title-menu-check.mjs (asserts these gaps). */
:is(.kdm-head, .kov-coh__top, .kvo-head, .krt-hd, .kwh-hd, .klg-hd, .knt-coh__top, .knu-coh__top) > :is(.kn-menu-btn, .kov-menu, .kvo-menu, .knt-menu, .knu-menu) { margin-right: -8px; }
:is(.kls-hd, .kns-top) > :is(.kn-menu-btn, .kns-menu) { margin-right: -6px; }
:is(.ktp-home__hd, .ksn-hd, .khm-hd, .ksl-hd, .ksg-hd, .knb-ph__t, .knc-rail__t) > .kn-menu-btn { margin-right: -2px; }
.klt-hd > .kn-menu-btn { margin-right: 2px; }
.kse-coh > .kno-menu { margin-right: -20px; }
:is(.krt-hd, .kwh-hd, .ktp-home__hd, .ksn-hd, .kpo-hd__t, .khm-hd, .ksl-hd, .kpm-home__hd, .kls-hd, .ksg-hd, .krh-hd) > .kn-menu-btn + * { margin-top: calc((44px - 33.6px * var(--kts, 1)) / 2); }
h1[style*="display: flex"] .kn-menu-btn { margin-right: 0; }
/* 帳務: the long subtitle inside the h2 pushed the title under the button. */
.knb-coh > .knb-menu + h2 { flex: 1 1 0 !important; min-width: 0; }
.knb-coh > .knb-menu { align-self: flex-start; margin-top: 2px; }
@media (max-width: 920px) {
  /* Search opened from the drawer: the bar returns as one row. */
  header > div[style*="position: relative"] > div[style*="position: absolute"] { top: 60px !important; }
}

/* ─── 2026-10-09: recordings + chat pages fill the screen on phones ────
   (knowledge-data/chat-ui.js uses the same frame.)
   knowledge-data/recordings-ui.js scrolls its own panes (transcript, notes)
   and pins the player / ask box, so <main> gets no padding and never
   scrolls; only the home-indicator inset is kept free. */
@media (max-width: 920px) {
  main:has([data-kn-recordings]), main:has([data-kn-chat]), main:has([data-kn-frame]) {
    padding: 0 0 env(safe-area-inset-bottom) !important;
    overflow: hidden !important;
  }
}

/* ─── 2026-10-10 v2: the drawer (phones + tablets, sideMode 'drawer') ────
   Wharf's sidebar as a floating card: rounded glass panel with a warm gold
   glow, brand tile, search field, quiet group labels, 46px rows whose current
   page is a night (--btn-bg) block with a gold icon, logo chips for the
   publications, and the account as a card at the foot. It slides in with an
   easeOutQuint and its rows rise in one after another; the page behind is
   dimmed and blurred. Every colour is a theme token; sizes × --kts. */
html body div[data-kn-side="drawer"][style] {
  --kn-hair: color-mix(in oklab, var(--ink) 10%, transparent);
  --kn-ease: cubic-bezier(.22, 1, .36, 1);
  position: fixed !important; z-index: 70 !important;
  left: calc(10px + env(safe-area-inset-left)) !important;
  top: calc(10px + env(safe-area-inset-top)) !important;
  bottom: calc(10px + env(safe-area-inset-bottom)) !important;
  height: auto !important; max-height: none !important;
  width: min(330px, calc(100vw - 54px)) !important; flex-basis: auto !important;
  padding: 0 !important; overflow: hidden;
  border: 1px solid color-mix(in oklab, var(--surface) 70%, transparent) !important; border-radius: 28px !important;
  background:
    radial-gradient(130% 55% at 100% 0%, color-mix(in oklab, var(--accent) 17%, transparent), transparent 62%),
    radial-gradient(90% 40% at 0% 100%, color-mix(in oklab, var(--accent2, var(--accent)) 8%, transparent), transparent 70%),
    var(--surface) !important;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .6) inset, 0 40px 80px -30px color-mix(in oklab, var(--ink) 55%, transparent),
    0 0 0 1px var(--kn-hair) !important;
  transition: transform .5s var(--kn-ease), opacity .35s ease !important;
}
html body div[data-kn-side="drawer"][style]:not([style*="translateX(0px)"]) {
  transform: translateX(calc(-100% - 40px)) !important; opacity: .6;
}
html body div[data-kn-side="drawer"][style*="translateX(0px)"] { transform: none !important; opacity: 1; }

/* head: brand tile + name, round close */
div[data-kn-side="drawer"] [data-kn-side-head] { padding: 18px 16px 10px 18px !important; gap: 12px !important; align-items: center !important; }
div[data-kn-side="drawer"] [data-kn-side-close] {
  position: relative; flex: none; width: 40px !important; height: 40px !important; min-width: 40px !important; min-height: 40px !important;
  padding: 0 !important; border: 0 !important; border-radius: 50% !important; font-size: 0 !important; color: transparent !important;
  background: color-mix(in oklab, var(--surface) 80%, transparent) !important;
  box-shadow: 0 0 0 1px var(--kn-hair), 0 8px 16px -12px color-mix(in oklab, var(--ink) 50%, transparent);
  transition: transform .3s var(--kn-ease);
}
div[data-kn-side="drawer"] [data-kn-side-close]::before {
  content: ""; position: absolute; inset: 0; margin: auto; width: 18px; height: 18px; background: var(--ink);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round'%3E%3Cpath d='M4.5 4.5l9 9M13.5 4.5l-9 9'/%3E%3C/svg%3E") center / 18px no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round'%3E%3Cpath d='M4.5 4.5l9 9M13.5 4.5l-9 9'/%3E%3C/svg%3E") center / 18px no-repeat;
}
div[data-kn-side="drawer"] [data-kn-side-close]:active { transform: scale(.9) rotate(90deg); }

/* search field — a real input: the drawer searches in place (2026-10-10).
   One line at every text size: the placeholder is cut with an ellipsis. */
div[data-kn-side="drawer"] [data-kn-side-qwrap]::before {
  content: ""; position: absolute; left: 31px; top: 14px; width: 18px; height: 18px; pointer-events: none; background: var(--muted);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round'%3E%3Ccircle cx='8' cy='8' r='5.6'/%3E%3Cpath d='M15.5 15.5l-3.4-3.4'/%3E%3C/svg%3E") center / 18px no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round'%3E%3Ccircle cx='8' cy='8' r='5.6'/%3E%3Cpath d='M15.5 15.5l-3.4-3.4'/%3E%3C/svg%3E") center / 18px no-repeat;
}
html body div[data-kn-side="drawer"] [data-kn-side-search] {
  display: block; box-sizing: border-box; height: 46px; padding: 0 42px 0 44px !important; margin: 0;
  border: 1px solid var(--kn-hair) !important; border-radius: 15px !important; outline: none;
  background: color-mix(in oklab, var(--surface2) 72%, transparent) !important; color: var(--ink) !important;
  font: 500 calc(14px * var(--kts, 1))/1 var(--font-body) !important;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; -webkit-appearance: none; appearance: none;
  transition: border-color .2s, box-shadow .2s, background-color .2s;
}
div[data-kn-side="drawer"] [data-kn-side-search]::placeholder { color: var(--muted); opacity: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
div[data-kn-side="drawer"] [data-kn-side-search]::-webkit-search-cancel-button,
div[data-kn-side="drawer"] [data-kn-side-search]::-webkit-search-decoration { -webkit-appearance: none; display: none; }
html body div[data-kn-side="drawer"] [data-kn-side-search]:focus {
  background: var(--surface) !important; border-color: color-mix(in oklab, var(--accent) 70%, transparent) !important;
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 22%, transparent);
}
div[data-kn-side="drawer"] [data-kn-side-qclear] {
  position: absolute; right: 23px; top: 7px; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%; cursor: pointer;
  background: color-mix(in oklab, var(--ink) 7%, transparent);
}
html body div[data-kn-side="drawer"] [data-kn-side-qclear] { min-width: 32px !important; min-height: 32px !important; }
div[data-kn-side="drawer"] [data-kn-side-qclear]::before {
  content: ""; position: absolute; inset: 0; margin: auto; width: 14px; height: 14px; background: var(--ink);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'%3E%3Cpath d='M5 5l8 8M13 5l-8 8'/%3E%3C/svg%3E") center / 14px no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'%3E%3Cpath d='M5 5l8 8M13 5l-8 8'/%3E%3C/svg%3E") center / 14px no-repeat;
}

/* results in the drawer: they replace the menu while there is a query */
div[data-kn-side="drawer"] [data-kn-side-nav][data-searching="true"] > :not([data-kn-side-results]) { display: none !important; }
div[data-kn-side="drawer"] [data-kn-side-results] { display: flex; flex-direction: column; gap: 2px; padding: 4px 0 8px; animation: kn-side-rise .35s var(--kn-ease) backwards; }
div[data-kn-side="drawer"] .kn-sq-modes { display: flex; gap: 4px; padding: 4px; margin: 0 2px 8px; border-radius: 999px; background: color-mix(in oklab, var(--ink) 5%, transparent); }
div[data-kn-side="drawer"] .kn-sq-modes > button {
  flex: 1; min-height: 34px; border: 0; border-radius: 999px; background: transparent; cursor: pointer;
  font: 500 calc(12.5px * var(--kts, 1))/1.2 var(--font-body); color: var(--muted); white-space: nowrap;
  transition: background-color .3s var(--kn-ease), color .3s;
}
div[data-kn-side="drawer"] .kn-sq-modes > button[aria-pressed="true"] { background: var(--btn-bg); color: var(--btn-text); font-weight: 600; }
div[data-kn-side="drawer"] .kn-sq-hit {
  display: flex; align-items: center; gap: 11px; width: 100%; min-height: 54px; padding: 8px 10px; border: 0; border-radius: 15px;
  background: transparent; cursor: pointer; text-align: left; color: var(--ink); transition: background-color .2s, transform .3s var(--kn-ease);
}
div[data-kn-side="drawer"] .kn-sq-hit:hover, div[data-kn-side="drawer"] .kn-sq-hit:focus-visible { background: color-mix(in oklab, var(--ink) 6%, transparent); }
div[data-kn-side="drawer"] .kn-sq-hit:active { transform: scale(.985); }
div[data-kn-side="drawer"] .kn-sq-ic { flex: 0 0 32px; height: 32px; display: grid; place-items: center; border-radius: 10px; background: var(--accent2-soft); font-size: calc(15px * var(--kts, 1)); }
div[data-kn-side="drawer"] .kn-sq-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
div[data-kn-side="drawer"] .kn-sq-txt b { font: 600 calc(14px * var(--kts, 1))/1.35 var(--font-body); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
div[data-kn-side="drawer"] .kn-sq-txt small { font: 400 calc(12px * var(--kts, 1))/1.4 var(--font-body); color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
div[data-kn-side="drawer"] .kn-sq-kind { flex: none; font: 500 calc(11px * var(--kts, 1))/1.3 var(--font-body); color: var(--muted); }
div[data-kn-side="drawer"] .kn-sq-phead { padding: 12px 10px 4px; margin-top: 4px; border-top: 1px solid var(--border); font: 600 calc(11px * var(--kts, 1))/1.5 var(--font-body); color: var(--muted); }
div[data-kn-side="drawer"] .kn-sq-pnote { padding: 8px 10px 2px; font: 400 calc(12px * var(--kts, 1))/1.6 var(--font-body); color: var(--muted); }
div[data-kn-side="drawer"] .kn-sq-state { padding: 18px 10px; text-align: center; font: 400 calc(13px * var(--kts, 1))/1.6 var(--font-body); color: var(--muted); }
div[data-kn-side="drawer"] .kn-sq-state[data-busy="true"]::before {
  content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 8px; vertical-align: -1px; border-radius: 50%;
  border: 2px solid var(--kn-hair); border-top-color: var(--accent); animation: spin .8s linear infinite;
}

/* nav: quiet labels, 46px rows, night block for the current page */
div[data-kn-side="drawer"] [data-kn-side-nav] { padding: 4px 10px 14px !important; scrollbar-width: none; }
div[data-kn-side="drawer"] [data-kn-side-nav]::-webkit-scrollbar { display: none; }
div[data-kn-side="drawer"] [data-kn-side-label] {
  padding: 16px 12px 7px !important; font: 500 calc(12px * var(--kts, 1))/1 var(--font-body) !important;
  letter-spacing: .06em !important; text-transform: none !important; color: var(--muted) !important;
}
div[data-kn-side="drawer"] [data-kn-side-rule] { display: none; }
html body div[data-kn-side="drawer"] [data-kn-side-item] {
  position: relative; min-height: 46px !important; padding: 0 12px !important; margin: 0 0 2px !important; gap: 12px !important;
  border-radius: 15px !important; background: transparent !important; color: var(--ink) !important;
  font: 500 calc(14.5px * var(--kts, 1))/1.3 var(--font-body) !important; letter-spacing: 0;
  transition: background-color .25s ease, color .25s ease, transform .3s var(--kn-ease);
}
html body div[data-kn-side="drawer"] [data-kn-side-item]:active { transform: scale(.98); background: color-mix(in oklab, var(--ink) 6%, transparent) !important; }
html body div[data-kn-side="drawer"] [data-kn-side-item][aria-current="page"] {
  background: var(--btn-bg) !important; color: var(--btn-text) !important; font-weight: 600 !important;
  box-shadow: 0 12px 22px -14px color-mix(in oklab, var(--btn-bg) 95%, transparent), inset 0 1px 0 rgba(255, 255, 255, .1);
}
div[data-kn-side="drawer"] [data-kn-side-item] > span[aria-hidden] { width: 28px !important; flex: 0 0 28px !important; }
div[data-kn-side="drawer"] [data-kn-side-item] svg { width: 19px; height: 19px; stroke: var(--muted); transition: stroke .25s; }
div[data-kn-side="drawer"] [data-kn-side-item][aria-current="page"] svg { stroke: var(--accent); }
div[data-kn-side="drawer"] [data-kn-side-item="news"] img {
  flex: none; width: 28px !important; height: 28px !important; padding: 0; object-fit: contain;
  border-radius: 0; background: none; box-shadow: none;
}
div[data-kn-side="drawer"] [data-kn-side-item] span[style*="border-radius: 999px"] {
  display: inline-grid; place-items: center; min-width: 22px; height: 21px; padding: 0 7px !important;
  font: 600 calc(11.5px * var(--kts, 1))/1 var(--font-body) !important; background: var(--accent) !important; color: var(--btn-bg) !important;
}

/* account card at the foot */
div[data-kn-side="drawer"] [data-kn-side-foot] {
  margin: 0 10px 10px; border: 1px solid var(--kn-hair) !important; border-radius: 20px;
  background: color-mix(in oklab, var(--surface2) 75%, transparent) !important;
}
div[data-kn-side="drawer"] [data-kn-side-me] { padding: 10px 12px 10px 10px !important; gap: 11px !important; border-radius: 20px; }
div[data-kn-side="drawer"] [data-kn-side-me] > div:first-child {
  width: 40px !important; height: 40px !important; font: 600 calc(14px * var(--kts, 1))/1 var(--font-body) !important;
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px color-mix(in oklab, var(--accent) 55%, transparent);
}
div[data-kn-side="drawer"] [data-kn-side-me] > div:nth-child(2) > div:first-child { font: 600 calc(14px * var(--kts, 1))/1.3 var(--font-body) !important; }
div[data-kn-side="drawer"] [data-kn-side-me] > div:nth-child(2) > div:nth-child(2) { font: 400 calc(12px * var(--kts, 1))/1.35 var(--font-body) !important; }
div[data-kn-side="drawer"] [data-kn-side-me] > span:last-child {
  position: relative; width: 30px; height: 30px; flex: none; border-radius: 50%; font-size: 0 !important; color: transparent !important;
  background: var(--surface); box-shadow: 0 0 0 1px var(--kn-hair);
}
div[data-kn-side="drawer"] [data-kn-side-me] > span:last-child::before {
  content: ""; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px; background: var(--ink);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 6l3-3 3 3M5 10l3 3 3-3'/%3E%3C/svg%3E") center / 16px no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 6l3-3 3 3M5 10l3 3 3-3'/%3E%3C/svg%3E") center / 16px no-repeat;
}
div[data-kn-side="drawer"] [data-kn-side-acct].kn-acct { left: 0; right: 0; width: auto; bottom: calc(100% + 8px); }

/* opening: head, search and rows rise in one after another. Fill 'backwards'
   only: a held transform would make the foot the containing block of the
   account card's fixed click-outside layer. */
@keyframes kn-side-rise { from { opacity: 0; transform: translateX(-14px); } }
div[data-kn-side="drawer"][style*="translateX(0px)"] :is([data-kn-side-head], [data-kn-side-qwrap], [data-kn-side-foot]) { animation: kn-side-rise .55s var(--kn-ease) backwards; }
div[data-kn-side="drawer"][style*="translateX(0px)"] [data-kn-side-qwrap] { animation-delay: .04s; }
div[data-kn-side="drawer"][style*="translateX(0px)"] [data-kn-side-foot] { animation-delay: .18s; }
div[data-kn-side="drawer"][style*="translateX(0px)"] [data-kn-side-nav] > * { animation: kn-side-rise .55s var(--kn-ease) backwards; animation-delay: .3s; }
div[data-kn-side="drawer"][style*="translateX(0px)"] [data-kn-side-nav] > :nth-child(1) { animation-delay: 0.078s; }
div[data-kn-side="drawer"][style*="translateX(0px)"] [data-kn-side-nav] > :nth-child(2) { animation-delay: 0.096s; }
div[data-kn-side="drawer"][style*="translateX(0px)"] [data-kn-side-nav] > :nth-child(3) { animation-delay: 0.114s; }
div[data-kn-side="drawer"][style*="translateX(0px)"] [data-kn-side-nav] > :nth-child(4) { animation-delay: 0.132s; }
div[data-kn-side="drawer"][style*="translateX(0px)"] [data-kn-side-nav] > :nth-child(5) { animation-delay: 0.150s; }
div[data-kn-side="drawer"][style*="translateX(0px)"] [data-kn-side-nav] > :nth-child(6) { animation-delay: 0.168s; }
div[data-kn-side="drawer"][style*="translateX(0px)"] [data-kn-side-nav] > :nth-child(7) { animation-delay: 0.186s; }
div[data-kn-side="drawer"][style*="translateX(0px)"] [data-kn-side-nav] > :nth-child(8) { animation-delay: 0.204s; }
div[data-kn-side="drawer"][style*="translateX(0px)"] [data-kn-side-nav] > :nth-child(9) { animation-delay: 0.222s; }
div[data-kn-side="drawer"][style*="translateX(0px)"] [data-kn-side-nav] > :nth-child(10) { animation-delay: 0.240s; }
div[data-kn-side="drawer"][style*="translateX(0px)"] [data-kn-side-nav] > :nth-child(11) { animation-delay: 0.258s; }
div[data-kn-side="drawer"][style*="translateX(0px)"] [data-kn-side-nav] > :nth-child(12) { animation-delay: 0.276s; }
div[data-kn-side="drawer"][style*="translateX(0px)"] [data-kn-side-nav] > :nth-child(13) { animation-delay: 0.294s; }
div[data-kn-side="drawer"][style*="translateX(0px)"] [data-kn-side-nav] > :nth-child(14) { animation-delay: 0.312s; }

/* the page behind: dimmed and softly blurred, fading in */
@keyframes kn-scrim-in { from { opacity: 0; } }
div[data-kn-scrim][style] {
  background: color-mix(in oklab, var(--btn-bg) 32%, transparent) !important;
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  animation: kn-scrim-in .35s ease both;
}
@media (prefers-reduced-motion: reduce) {
  html body div[data-kn-side="drawer"][style], div[data-kn-side="drawer"] * { transition: none !important; animation: none !important; }
  div[data-kn-scrim][style] { animation: none; }
}

/* ─── 2026-10-10: account card (點左下角姓名) — desktop rail + drawer ─────
   Wharf × Coterie: a night hero (avatar, name, email), night segmented pills
   for text size / language, rows for theme / plan / settings, a sign-out pill.
   Theme tokens only; every font size × --kts. */
.kn-acct {
  --ka-hair: color-mix(in oklab, var(--ink) 10%, transparent);
  --ka-ease: cubic-bezier(.22, 1, .36, 1);
  position: absolute; left: 12px; bottom: calc(100% + 8px); z-index: 79; width: 304px; box-sizing: border-box;
  overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none;
  padding: 8px; border-radius: 24px; border: 1px solid var(--ka-hair);
  background: radial-gradient(120% 40% at 100% 100%, color-mix(in oklab, var(--accent) 10%, transparent), transparent 70%), var(--surface);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .55) inset, 0 34px 70px -28px color-mix(in oklab, var(--ink) 55%, transparent), 0 0 0 1px var(--ka-hair);
  text-align: left; color: var(--ink);
  animation: kn-acct-in .38s var(--ka-ease) both;
}
.kn-acct::-webkit-scrollbar { display: none; }
@keyframes kn-acct-in { from { opacity: 0; transform: translateY(12px) scale(.97); } }
.kn-acct > * { animation: kn-acct-rise .5s var(--ka-ease) backwards; }
.kn-acct > :nth-child(2) { animation-delay: .04s; } .kn-acct > :nth-child(3) { animation-delay: .08s; }
.kn-acct > :nth-child(4) { animation-delay: .12s; } .kn-acct > :nth-child(5) { animation-delay: .16s; }
@keyframes kn-acct-rise { from { opacity: 0; transform: translateY(8px); } }
.kn-acct button { font-family: var(--font-body); -webkit-tap-highlight-color: transparent; }

.kn-acct-hero {
  position: relative; display: grid; grid-template-columns: 48px minmax(0, 1fr) 32px; column-gap: 12px; align-items: center;
  padding: 16px 14px 16px 16px; border-radius: 18px; overflow: hidden; color: var(--btn-text);
  background: radial-gradient(90% 120% at 100% 0%, color-mix(in oklab, var(--accent) 34%, transparent), transparent 60%), var(--btn-bg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), 0 14px 26px -18px color-mix(in oklab, var(--btn-bg) 95%, transparent);
}
.kn-acct-av {
  width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center;
  font: 600 calc(16px * var(--kts, 1))/1 var(--font-body);
  box-shadow: 0 0 0 2px var(--btn-bg), 0 0 0 3.5px color-mix(in oklab, var(--accent) 70%, var(--btn-text));
}
.kn-acct-av:not([style*="url("]) { background: var(--btn-text) !important; color: var(--btn-bg) !important; }
.kn-acct-id { min-width: 0; }
.kn-acct-name { font: 600 calc(16px * var(--kts, 1))/1.25 var(--font-body); letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kn-acct-mail { margin-top: 3px; font: 400 calc(12px * var(--kts, 1))/1.35 var(--font-body); opacity: .66; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kn-acct-x {
  align-self: center; width: 32px; height: 32px; border: 0; padding: 0; border-radius: 50%; cursor: pointer;
  background: color-mix(in oklab, var(--btn-text) 12%, transparent); position: relative; transition: background-color .2s, transform .3s var(--ka-ease);
}
.kn-acct-x::before { content: ""; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px; background: var(--btn-text);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5.5 5.5l9 9M14.5 5.5l-9 9'/%3E%3C/svg%3E") center / 16px no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5.5 5.5l9 9M14.5 5.5l-9 9'/%3E%3C/svg%3E") center / 16px no-repeat; }
.kn-acct-x:hover { background: color-mix(in oklab, var(--btn-text) 20%, transparent); } .kn-acct-x:active { transform: scale(.9) rotate(90deg); }

.kn-acct-k { flex: 1; min-width: 0; font: 500 calc(12px * var(--kts, 1))/1.4 var(--font-body); letter-spacing: .04em; color: var(--muted); }

.kn-acct-sec { display: flex; flex-direction: column; gap: 12px; padding: 14px 8px 12px; }
.kn-acct-seg .kn-acct-k { display: block; margin: 0 0 7px 4px; }
.kn-acct-pills { display: flex; padding: 4px; border-radius: 999px; background: color-mix(in oklab, var(--ink) 5%, transparent); }
.kn-acct-pills > button {
  flex: 1; min-width: 0; min-height: 34px; padding: 6px 4px; border: 0; border-radius: 999px; cursor: pointer; background: transparent;
  font: 500 calc(12.5px * var(--kts, 1))/1.3 var(--font-body); color: var(--muted);
  transition: background-color .3s var(--ka-ease), color .3s, box-shadow .3s;
}
.kn-acct-pills > button:hover { color: var(--ink); }
.kn-acct-pills > button[aria-pressed="true"] {
  background: var(--btn-bg); color: var(--btn-text); font-weight: 600;
  box-shadow: 0 8px 16px -10px color-mix(in oklab, var(--btn-bg) 90%, transparent), inset 0 1px 0 rgba(255, 255, 255, .1);
}

.kn-acct-list { display: flex; flex-direction: column; padding: 4px 0; border-top: 1px solid var(--ka-hair); }
.kn-acct-item {
  display: flex; align-items: center; gap: 11px; width: 100%; min-height: 44px; padding: 0 10px; margin: 1px 0;
  border: 0; border-radius: 13px; background: transparent; cursor: pointer; text-align: left; color: var(--ink);
  transition: background-color .2s, transform .3s var(--ka-ease);
}
.kn-acct-item:hover, .kn-acct-item[aria-expanded="true"] { background: color-mix(in oklab, var(--ink) 5%, transparent); }
.kn-acct-item:active { transform: scale(.985); }
.kn-acct-ic { flex: 0 0 20px; width: 20px; height: 20px; background: var(--muted); -webkit-mask: center / 19px no-repeat; mask: center / 19px no-repeat; }
.kn-acct-ic[data-ic='theme'] { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 2.8a7.2 7.2 0 1 0 0 14.4c1 0 1.5-.7 1.5-1.4 0-.9-.8-1.2-.8-2.1 0-.8.6-1.4 1.4-1.4h1.7a3.4 3.4 0 0 0 3.4-3.4c0-3.4-3.2-6.1-7.2-6.1Z'/%3E%3Ccircle cx='6.4' cy='9' r='.9' fill='black'/%3E%3Ccircle cx='9' cy='6.1' r='.9' fill='black'/%3E%3Ccircle cx='12.6' cy='6.6' r='.9' fill='black'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 2.8a7.2 7.2 0 1 0 0 14.4c1 0 1.5-.7 1.5-1.4 0-.9-.8-1.2-.8-2.1 0-.8.6-1.4 1.4-1.4h1.7a3.4 3.4 0 0 0 3.4-3.4c0-3.4-3.2-6.1-7.2-6.1Z'/%3E%3Ccircle cx='6.4' cy='9' r='.9' fill='black'/%3E%3Ccircle cx='9' cy='6.1' r='.9' fill='black'/%3E%3Ccircle cx='12.6' cy='6.6' r='.9' fill='black'/%3E%3C/svg%3E"); }
.kn-acct-ic[data-ic='usage'] { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 16.5h14'/%3E%3Cpath d='M5.5 13.5v-3M10 13.5V6M14.5 13.5V9'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 16.5h14'/%3E%3Cpath d='M5.5 13.5v-3M10 13.5V6M14.5 13.5V9'/%3E%3C/svg%3E"); }
.kn-acct-ic[data-ic='usage2'] { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 15.5l4.2-4.7 3.1 2.6L17 6'/%3E%3Cpath d='M13 6h4v4'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 15.5l4.2-4.7 3.1 2.6L17 6'/%3E%3Cpath d='M13 6h4v4'/%3E%3C/svg%3E"); }
.kn-acct-ic[data-ic='settings'] { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 6.5h14M3 13.5h14'/%3E%3Ccircle cx='8' cy='6.5' r='2.1' fill='white'/%3E%3Ccircle cx='13' cy='13.5' r='2.1' fill='white'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 6.5h14M3 13.5h14'/%3E%3Ccircle cx='8' cy='6.5' r='2.1' fill='white'/%3E%3Ccircle cx='13' cy='13.5' r='2.1' fill='white'/%3E%3C/svg%3E"); }
.kn-acct-ic[data-ic='billing'] { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2.5' y='5' width='15' height='10' rx='2'/%3E%3Cpath d='M2.5 8.5h15M5.5 12H9'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2.5' y='5' width='15' height='10' rx='2'/%3E%3Cpath d='M2.5 8.5h15M5.5 12H9'/%3E%3C/svg%3E"); }
.kn-acct-ic[data-ic='out'] { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 3.5H5A1.5 1.5 0 0 0 3.5 5v10A1.5 1.5 0 0 0 5 16.5h3'/%3E%3Cpath d='M12.5 6.5 16 10l-3.5 3.5M16 10H8'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 3.5H5A1.5 1.5 0 0 0 3.5 5v10A1.5 1.5 0 0 0 5 16.5h3'/%3E%3Cpath d='M12.5 6.5 16 10l-3.5 3.5M16 10H8'/%3E%3C/svg%3E"); }
.kn-acct-ic[data-ic='size'] { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='8.5' cy='8.5' r='5.6'/%3E%3Cpath d='M12.6 12.6 17 17M8.5 6.3v4.4M6.3 8.5h4.4'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='8.5' cy='8.5' r='5.6'/%3E%3Cpath d='M12.6 12.6 17 17M8.5 6.3v4.4M6.3 8.5h4.4'/%3E%3C/svg%3E"); }
.kn-acct-ic[data-ic='lang'] { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='10' cy='10' r='7'/%3E%3Cpath d='M3 10h14M10 3c2 2.2 2.9 4.5 2.9 7S12 14.8 10 17M10 3C8 5.2 7.1 7.5 7.1 10S8 14.8 10 17'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='10' cy='10' r='7'/%3E%3Cpath d='M3 10h14M10 3c2 2.2 2.9 4.5 2.9 7S12 14.8 10 17M10 3C8 5.2 7.1 7.5 7.1 10S8 14.8 10 17'/%3E%3C/svg%3E"); }
.kn-acct-seg .kn-acct-k { display: flex; align-items: center; gap: 7px; }
.kn-acct-seg .kn-acct-k .kn-acct-ic { flex-basis: 16px; width: 16px; height: 16px; -webkit-mask-size: 16px; mask-size: 16px; }
.kn-acct-lbl { flex: 1; min-width: 0; font: 500 calc(13.5px * var(--kts, 1))/1.3 var(--font-body); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kn-acct-val { flex: none; max-width: 46%; font: 400 calc(12px * var(--kts, 1))/1.3 var(--font-body); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kn-acct-dots { display: inline-flex; flex: none; }
.kn-acct-dots > span { width: 13px; height: 13px; border-radius: 50%; box-shadow: 0 0 0 1.5px var(--surface), 0 0 0 2.5px var(--ka-hair); }
.kn-acct-dots > span + span { margin-left: -3px; }
.kn-acct-chev { flex: 0 0 14px; width: 14px; height: 14px; background: var(--muted); -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 5.5 12.5 10 8 14.5'/%3E%3C/svg%3E") center / 14px no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 5.5 12.5 10 8 14.5'/%3E%3C/svg%3E") center / 14px no-repeat; transition: transform .3s var(--ka-ease); }
.kn-acct-chev[data-down="1"] { transform: rotate(90deg); }
.kn-acct-chev[data-down="1"][data-open="true"] { transform: rotate(-90deg); }
.kn-acct-chev[data-open="true"]:not([data-down]) { transform: rotate(180deg); }

.kn-acct-foot { padding: 6px 0 2px; border-top: 1px solid var(--ka-hair); }
.kn-acct-out {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 44px; margin-top: 4px;
  border: 1px solid color-mix(in oklab, var(--danger) 30%, transparent); border-radius: 999px; cursor: pointer;
  background: transparent; color: var(--danger); font: 600 calc(13.5px * var(--kts, 1))/1.3 var(--font-body);
  transition: background-color .2s, transform .3s var(--ka-ease);
}
.kn-acct-out .kn-acct-ic { background: var(--danger); flex-basis: 18px; width: 18px; height: 18px; }
.kn-acct-out:hover { background: color-mix(in oklab, var(--danger) 9%, transparent); }
.kn-acct-out:active { transform: scale(.98); }
.kn-acct :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* desktop rail: publication logos a little larger; the YT mark sits beside the name */
/* the rail never moves: without a transform it stops being the containing block of
   its fixed children, so the account card's click-outside layer covers the whole
   window (it was only the 250px rail, so clicks on the page never closed it) */
div[data-kn-side="rail"][style] { transform: none !important; }
div[data-kn-side="rail"] [data-kn-side-item="news"] img { width: 22px !important; height: 22px !important; }

/* theme flyout opened from the card */
.kn-theme-fly { border-radius: 18px !important; border-color: color-mix(in oklab, var(--ink) 10%, transparent) !important; padding: 8px !important;
  box-shadow: 0 30px 60px -24px color-mix(in oklab, var(--ink) 55%, transparent) !important; animation: kn-acct-in .3s cubic-bezier(.22, 1, .36, 1) both !important; }
.kn-theme-fly > button { border-radius: 12px !important; padding: 9px 10px !important; }
.kn-theme-fly > button[aria-selected="true"] { background: color-mix(in oklab, var(--accent) 16%, transparent) !important; border-color: transparent !important; }

@media (max-width: 720px) {
  .kn-acct { width: auto; right: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .kn-acct, .kn-acct *, .kn-theme-fly { animation: none !important; transition: none !important; }
}

/* ─── 2026-10-10: sidebar head = a greeting (左上角打招呼) ────────────────
   Coterie people style: an illustrated face (side-greet.js, a different one
   every visit) with a waving hand, "早安，<name>！" and a short second line.
   Text wraps (balanced) instead of being cut off. The whole card → 總覽. */
[data-kn-side] [data-kn-side-head] { padding: 14px 12px 8px !important; align-items: flex-start !important; }
div[data-kn-side="drawer"] [data-kn-side-head] { padding: 16px 14px 8px 12px !important; align-items: center !important; }
.kn-brand {
  --kb-ease: cubic-bezier(.22, 1, .36, 1);
  flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 12px;
  margin: 0; padding: 8px 10px 8px 8px; border: 0; border-radius: 18px; cursor: pointer; text-align: left;
  background: transparent; color: var(--ink); font-family: var(--font-body); -webkit-tap-highlight-color: transparent;
  transition: background-color .25s var(--kb-ease), box-shadow .25s var(--kb-ease);
}
@media (hover: hover) { .kn-brand:hover { background: color-mix(in oklab, var(--ink) 4.5%, transparent); box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--ink) 7%, transparent); } }
.kn-brand:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.kn-brand-face {
  position: relative; flex: 0 0 46px; width: 46px; height: 46px; border-radius: 50%;
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px color-mix(in oklab, var(--accent) 55%, transparent), 0 10px 18px -12px color-mix(in oklab, var(--ink) 60%, transparent);
  animation: kn-face-in .7s cubic-bezier(.34, 1.56, .64, 1) backwards;
  transition: transform .35s var(--kb-ease);
}
.kn-brand-face img { display: block; width: 100%; height: 100%; border-radius: 50%; user-select: none; -webkit-user-drag: none; }
.kn-brand:active .kn-brand-face { transform: scale(.94); }
@keyframes kn-face-in { from { opacity: 0; transform: scale(.6) rotate(-10deg); } }
/* the waving hand: waves on arrival and again on hover */
.kn-brand-wave {
  position: absolute; right: -7px; bottom: -4px; width: 22px; height: 22px; display: grid; place-items: center;
  border-radius: 50%; background: var(--surface); box-shadow: 0 0 0 1px color-mix(in oklab, var(--ink) 8%, transparent), 0 4px 10px -6px color-mix(in oklab, var(--ink) 60%, transparent);
  font: normal calc(12px * var(--kts, 1))/1 "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  transform-origin: 70% 80%; animation: kn-wave 1.6s .45s ease-in-out both;
}
@media (hover: hover) { .kn-brand:hover .kn-brand-wave { animation: kn-wave2 1s ease-in-out; } }
@keyframes kn-wave { 0% { opacity: 0; transform: scale(.3); } 18% { opacity: 1; transform: scale(1.1) rotate(0); } 30% { transform: rotate(18deg); } 42% { transform: rotate(-10deg); } 54% { transform: rotate(16deg); } 66% { transform: rotate(-6deg); } 78%, 100% { transform: rotate(0); } }
@keyframes kn-wave2 { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(18deg); } 40% { transform: rotate(-10deg); } 60% { transform: rotate(14deg); } 80% { transform: rotate(-4deg); } }
.kn-brand-tx { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 3px; animation: kn-greet-rise .6s .12s var(--kb-ease) backwards; }
@keyframes kn-greet-rise { from { opacity: 0; transform: translateY(6px); } }
.kn-brand-name {
  display: block; min-width: 0; overflow-wrap: anywhere; text-wrap: pretty;
  font: 600 calc(15px * var(--kts, 1))/1.3 var(--font-body); letter-spacing: -.005em; color: var(--ink);
}
.kn-brand-sub {
  display: block; min-width: 0; overflow-wrap: anywhere; text-wrap: balance;
  font: 400 calc(12px * var(--kts, 1))/1.35 var(--font-body); letter-spacing: .02em; color: var(--muted);
}
.kn-brand-hi, .kn-brand-who { display: block; }
/* 2026-10-21 (CLS): the name arrives with /v1/me after the first paint; its line is kept meanwhile, so the whole
   side menu below the greeting no longer drops by one line on every page load */
.kn-brand-who:empty::before { content: "\00a0"; }
.kn-brand-sub:empty { display: none; }
.kn-brand[data-ro="true"] .kn-brand-face { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--danger); }
.kn-brand[data-ro="true"] .kn-brand-wave { display: none; }
div[data-kn-side="drawer"] .kn-brand-face { flex-basis: 50px; width: 50px; height: 50px; }
div[data-kn-side="drawer"] .kn-brand-name { font-size: calc(16px * var(--kts, 1)); }
@media (prefers-reduced-motion: reduce) { .kn-brand, .kn-brand-face, .kn-brand-wave, .kn-brand-tx { transition: none; animation: none; } }

/* 2026-10-22: the sidebar's 新聞 group is 新聞探索 alone, a navIcon line icon like the 知識作業 items (新聞研究 lives in 新聞探索) */
