/* tidepage (hosted) — the SPA shell (auth + dashboard).
   Built on the shared design system: editor.css supplies tokens, fonts, base
   styles, `.btn`/`.btn--primary`/`.btn--secondary`, `.badge` and `.avatar`.
   This file layers the auth + dashboard screens on top, on-brand. The editor
   view is a separate page that reuses the desktop chrome wholesale. */

body { background: var(--surface-page); }
/* dvh, not vh: on phones the browser's collapsing toolbars make 100vh taller
   than the visible viewport, which would hide the bottom tab bar. */
#root { min-height: 100dvh; display: flex; flex-direction: column; }

/* Brand lockup: line-only horizon mark + serif wordmark (Newsreader 300,
   first e mirrored), per brand/BRAND_BRIEF.md. */
.brand { display: inline-flex; align-items: center; gap: var(--space-2); font-family: var(--font-display); font-weight: var(--wordmark-weight, 300); font-size: var(--text-xl); letter-spacing: var(--wordmark-tracking, -0.01em); color: var(--text-primary); cursor: pointer; line-height: 1; }
.brand .mark { width: 24px; height: 24px; flex: none; }
.brand .mark svg { width: 100%; height: 100%; display: block; }
.brand .flip-e { display: inline-block; transform: scaleX(-1); }
.brand--lg { font-size: var(--text-2xl, 28px); }
.brand--lg .mark { width: 34px; height: 34px; }

.btn--ghost { --_bg: transparent; --_fg: var(--text-secondary); --_bd: transparent; }
.btn--ghost:hover { --_bg: var(--surface-hover); --_fg: var(--text-primary); }

/* ── auth ─────────────────────────────────────────────────────────────── */
/* Two-pane sign-in: a brand/product panel beside the form. Collapses to the
   form alone on narrow screens. */
.authpage { flex: 1; min-height: 100dvh; display: grid; place-items: center; padding: clamp(20px, 4vw, 48px); background: radial-gradient(115% 115% at 0% 0%, var(--accent-subtle), transparent 52%), var(--surface-inset); }
/* The bounded two-pane card keeps content centred instead of stranded on wide screens. */
.authshell { width: 100%; max-width: 940px; display: grid; grid-template-columns: 1.04fr 0.96fr; align-items: stretch; background: var(--surface-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-xl); box-shadow: var(--shadow-md); overflow: hidden; }
.authpage__main { display: grid; place-items: center; padding: clamp(28px, 4vw, 52px); }

.authbrand { display: flex; flex-direction: column; justify-content: center; gap: var(--space-5); padding: clamp(28px, 4vw, 52px); background: var(--accent-subtle); border-right: 1px solid var(--border-subtle); }
.authbrand > * { width: 100%; }
.authbrand__headline { font-family: var(--font-display); font-weight: 600; font-size: clamp(26px, 2.3vw, 33px); line-height: 1.08; letter-spacing: -0.03em; margin: 0; max-width: 15ch; }
.authbrand__accent { color: var(--accent); }
.authbrand__sub { font-size: var(--text-md); line-height: 1.55; color: var(--text-secondary); margin: 0; max-width: 44ch; }
.authbrand__points { list-style: none; margin: var(--space-2) 0 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.authbrand__points li { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); font-weight: 500; color: var(--text-secondary); }
.authbrand__pt-ic { display: inline-flex; color: var(--accent); }
.authbrand__pt-ic svg { width: 16px; height: 16px; display: block; }

/* Compact product preview inside the brand panel. */
.authmock { background: var(--surface-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); overflow: hidden; max-width: 100%; }
.authmock__bar { display: flex; align-items: center; gap: var(--space-2); padding: 10px 12px; border-bottom: 1px solid var(--border-subtle); }
.authmock__mark { width: 16px; height: 16px; flex: none; }
.authmock__mark svg { width: 100%; height: 100%; display: block; }
.authmock__name { font-family: var(--font-display); font-size: var(--text-sm); font-weight: 500; color: var(--text-primary); }
.authmock__chip { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; color: var(--accent-text); background: var(--accent-subtle); border: 1px solid var(--accent-border); border-radius: var(--radius-full); padding: 2px 7px; }
.authmock__chip svg { width: 12px; height: 12px; display: block; }
.authmock__body { padding: var(--space-4); background: var(--surface-inset); }
.authmock__sel { display: inline-block; margin-bottom: var(--space-4); }
.authmock__h { font-family: var(--font-display); font-size: var(--text-lg); font-weight: 600; letter-spacing: -0.02em; color: var(--text-primary); outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 2px; }
.authmock__kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-2); }
.authmock__kpi { position: relative; display: flex; flex-direction: column; gap: 2px; padding: 10px; background: var(--surface-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); }
.authmock__kpi span { font-size: 10px; color: var(--text-muted); }
.authmock__kpi strong { font-family: var(--font-display); font-size: var(--text-md); font-weight: 600; color: var(--text-primary); letter-spacing: -0.01em; }
.authmock__kpi--sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.authmock__pin { position: absolute; top: -7px; right: -7px; width: 17px; height: 17px; display: grid; place-items: center; border-radius: 50%; background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; box-shadow: var(--shadow-sm); }

.auth { width: 100%; max-width: 340px; margin: auto; display: flex; flex-direction: column; gap: var(--space-5); }
.auth .brand--lg { margin-bottom: var(--space-1); }
.auth__brand { display: none; }  /* shown only when the brand panel is hidden (mobile) */

@media (max-width: 820px) {
  .authshell { grid-template-columns: 1fr; max-width: 400px; }
  .authbrand { display: none; }
  .auth__brand { display: inline-flex; }
}
/* The shell is the card, so the form itself stays flat (no double border/shadow). */
.auth__form { width: 100%; display: flex; flex-direction: column; gap: var(--space-3); }
.auth__title { font-family: var(--font-display); font-weight: 600; font-size: var(--text-xl); letter-spacing: -0.02em; margin: 0 0 var(--space-1); }
.auth__err { color: var(--danger-fg); font-size: var(--text-sm); min-height: 0; }
.auth__err:not(:empty) { min-height: 18px; }
.auth__note { font-size: var(--text-sm); color: var(--text-muted); margin: 0; line-height: 1.5; }
.auth__note:empty { display: none; }
.auth__alt { font-size: var(--text-sm); color: var(--text-muted); margin: var(--space-1) 0 0; }
.auth__alt a { color: var(--text-link); font-weight: 500; text-decoration: none; }
.auth__alt a:hover { text-decoration: underline; }
.auth__form .btn--primary { margin-top: var(--space-1); height: var(--control-md); }

.field { display: flex; flex-direction: column; gap: 5px; font-size: var(--text-xs); color: var(--text-muted); }
.field input { font-family: var(--font-sans); font-size: var(--text-base); color: var(--text-primary); padding: 9px 11px; border: 1px solid var(--border-default); border-radius: var(--radius-md); background: var(--surface-inset); transition: var(--transition-colors); }
.field input::placeholder { color: var(--text-faint); }
.field input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); background: var(--surface-card); }
.auth__show { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); color: var(--text-muted); cursor: pointer; user-select: none; margin-top: -2px; }
.auth__show input { accent-color: var(--accent); cursor: pointer; }
/* "Continue with Google" — a neutral provider button above the email form. */
.btn--google { height: var(--control-md); background: var(--surface-card); color: var(--text-primary); border: 1px solid var(--border-default); text-decoration: none; font-weight: 500; }
.btn--google:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.auth__divider { display: flex; align-items: center; text-align: center; color: var(--text-faint); font-size: var(--text-xs); }
.auth__divider::before, .auth__divider::after { content: ""; flex: 1; height: 1px; background: var(--border-subtle); }
.auth__divider span { padding: 0 var(--space-2); }

/* ── workspace shell: sidebar + main column ───────────────────────────── */
.shell { display: flex; height: 100dvh; overflow: hidden; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content { flex: 1; min-height: 0; overflow-y: auto; }

/* "Confirm your email" strip — informational, not an error: sharing and
   inviting are held back, everything else still works. */
.verifybar { display: flex; align-items: center; gap: var(--space-2); flex: none; padding: 9px var(--space-4); font-size: var(--text-sm); color: var(--text-secondary); background: var(--surface-inset); border-bottom: 1px solid var(--border-subtle); }
.verifybar__ic { display: inline-flex; color: var(--accent); flex: none; }
.verifybar__act { margin-left: auto; flex: none; background: none; border: none; padding: 0; font: inherit; font-weight: 600; color: var(--text-link); cursor: pointer; }
.verifybar__act:hover { text-decoration: underline; }
.verifybar__act[disabled] { opacity: 0.5; cursor: default; text-decoration: none; }

.sidebar { width: 248px; flex: none; display: flex; flex-direction: column; background: var(--surface-card); border-right: 1px solid var(--border-subtle); }
.sb-brand { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-4) var(--space-4) var(--space-2); font-family: var(--font-display); font-weight: var(--wordmark-weight, 300); font-size: var(--text-lg); letter-spacing: var(--wordmark-tracking, -0.01em); color: var(--text-primary); cursor: pointer; line-height: 1; }
.sb-brand .mark { width: 24px; height: 24px; flex: none; }
.sb-brand .mark svg { width: 100%; height: 100%; display: block; }
.sb-brand .flip-e { display: inline-block; transform: scaleX(-1); }

.sb-ws { position: relative; display: flex; align-items: center; gap: var(--space-2); margin: var(--space-2) var(--space-3) var(--space-3); padding: 7px 10px; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); font-size: var(--text-sm); font-weight: 600; color: var(--text-secondary); }
.sb-ws__badge { display: grid; place-items: center; width: 20px; height: 20px; flex: none; border-radius: 5px; background: var(--slate-800); color: var(--white); font-size: 10px; font-weight: 700; }
[data-theme="dark"] .sb-ws__badge { background: var(--slate-200); color: var(--slate-900); }
.sb-ws__name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Switcher variant: an invisible full-size select over the styled row. */
.sb-ws--switch:hover { background: var(--surface-hover); }
.sb-ws__select { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; font: inherit; }
.sb-ws__chev { margin-left: auto; color: var(--text-faint); display: inline-flex; pointer-events: none; }

.sb-nav { flex: 1; overflow-y: auto; padding: 0 var(--space-3) var(--space-3); display: flex; flex-direction: column; gap: 1px; }
/* This column scrolls when it runs out of room — it does *not* squash its rows
   to fit. Without this, `flex-shrink`'s default of 1 makes every row give up
   height before the container ever overflows, so a fixed 44px row renders at
   its 18px line box on exactly the short screens where the touch target
   matters most (a phone with the browser chrome showing). */
.sb-nav > * { flex: none; }
.sb-item { display: flex; align-items: center; gap: 9px; height: 32px; padding: 0 var(--space-2); border-radius: var(--radius-md); font-size: var(--text-sm); font-weight: 500; color: var(--text-secondary); text-decoration: none; cursor: pointer; transition: var(--transition-colors); }
/* A row is a fixed height, so a label that wraps doesn't get taller — it gets
   clipped mid-descender and throws the whole column out. Truncate instead.
   No-op while labels fit (every desktop one does); it matters in the drawer,
   where the same rows are 44px and the type a step larger. */
.sb-item > span:not([class]) { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-item__ic { display: inline-flex; color: var(--text-muted); }
.sb-item:hover { background: var(--surface-hover); color: var(--text-primary); }
.sb-item.is-active { background: var(--accent-subtle); color: var(--accent-text); font-weight: 600; }
.sb-item.is-active .sb-item__ic { color: var(--accent); }

.sb-foot { border-top: 1px solid var(--border-subtle); padding: var(--space-2) var(--space-3) var(--space-3); display: flex; flex-direction: column; gap: 2px; }
.sb-user { display: flex; align-items: center; gap: 9px; padding: 6px var(--space-2); border-radius: var(--radius-md); }
.sb-user__avatar { width: 26px; height: 26px; font-size: 10px; }
.sb-user__who { min-width: 0; flex: 1; line-height: 1.25; }
.sb-user__who b { display: block; font-size: var(--text-sm); font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user__who span { display: block; font-size: var(--text-2xs); color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user__out { flex: none; }

/* ── topbar: just search (and the theme toggle) ───────────────────────── */
/* On touch tiers this same bar becomes the mobile app bar — the drawer button,
   the context title and one contextual action are in the markup at every width
   and hidden here, so desktop is untouched (#233 §4). */
.topbar { display: flex; align-items: center; gap: var(--space-3); height: var(--toolbar-height); flex: none; padding: 0 var(--space-4); background: var(--surface-card); border-bottom: 1px solid var(--border-subtle); }
/* Public shells (blog, examples): the landing page's own nav, rebuilt on the
   app's tokens — sticky, translucent over the page, brand / primary links /
   actions inside a centered 1120px column, sized like landing.css `.nav`. The
   two surfaces share a visitor's session, so they must not look like two
   different sites. Anything here that drifts from `.nav` is a bug. */
/* `.topbar.topbar--public` for the box metrics: the mobile blocks below restyle
   `.topbar` at equal specificity, and this bar must keep its own height there. */
.topbar.topbar--public {
  display: block; height: auto; flex: none; padding: 0;
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--surface-page) 82%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.topbar__in {
  max-width: 1120px; margin: 0 auto; padding: 14px 32px;
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-6);
}
.topbar--public .topbar__left, .topbar--public .topbar__right { display: flex; align-items: center; gap: 14px; }
/* Brand at landing scale (30px mark, 28px wordmark) — the app chrome runs smaller. */
.topbar--public .brand { font-size: var(--text-2xl); }
.topbar--public .brand .mark { width: 30px; height: 30px; }
/* The landing's primary link row, absolute so the section anchors resolve
   against the landing page rather than this one. */
.pubnav { display: flex; align-items: center; gap: 28px; }
.pubnav a { text-decoration: none; color: var(--text-secondary); font-size: var(--text-base); font-weight: var(--weight-medium); transition: var(--transition-colors); }
.pubnav a:hover { color: var(--text-primary); }
.pubnav a[aria-current="page"] { color: var(--text-primary); }
/* The app's buttons run a size smaller than the landing's — match the nav. */
.topbar--public .btn { font-size: var(--text-base); }
.topbar__signin { text-decoration: none; color: var(--text-secondary); font-size: var(--text-base); font-weight: var(--weight-medium); transition: var(--transition-colors); }
.topbar__signin:hover { color: var(--text-primary); }
/* Same breakpoint as the landing nav: below it the link row goes and the
   brand carries the way back, so the two bars still collapse in step. */
@media (max-width: 920px) {
  .pubnav { display: none; }
  .topbar__in { padding: 12px 18px; gap: var(--space-3); }
  .topbar--public .brand { font-size: var(--text-xl); }
  .topbar--public .brand .mark { width: 26px; height: 26px; }
}
.topbar__menu, .topbar__title, .topbar__act { display: none; }
.topbar__side { flex: 1; display: flex; align-items: center; }
.topbar__side--right { justify-content: flex-end; }
.searchbar { display: flex; align-items: center; gap: 9px; width: 100%; max-width: 520px; height: 34px; padding: 0 var(--space-3); border: 1px solid var(--border-default); border-radius: var(--radius-full); background: var(--surface-inset); color: var(--text-muted); font: inherit; font-size: var(--text-sm); cursor: pointer; transition: var(--transition-colors); }
.searchbar:hover { border-color: var(--border-strong); color: var(--text-secondary); }
.searchbar__hint { flex: 1; text-align: left; }
.searchbar kbd, .palette kbd { font-family: var(--font-mono); font-size: 10px; color: var(--text-faint); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); padding: 2px 5px; background: var(--surface-card); }

.wsel { font: inherit; font-size: var(--text-sm); padding: 5px 8px; border: 1px solid var(--border-default); border-radius: var(--radius-md); background: var(--surface-card); color: var(--text-primary); }

/* ── dashboard ────────────────────────────────────────────────────────── */
/* The content column: capped at 1440px (extra width buys more grid columns —
   the auto-fill grids below — never wider cards); beyond the cap, margins grow
   symmetrically. Gutters scale with the viewport. (#197 §5) */
.dash { width: 100%; max-width: 1440px; min-height: calc(100dvh - var(--toolbar-height)); margin: 0 auto; padding: var(--space-6) clamp(var(--space-6), 4vw, 56px) calc(var(--space-6) * 3); border-radius: var(--radius-xl); transition: var(--transition-colors); }
/* The whole workspace is the drop zone — invite the drop while dragging over. */
.dash.is-drop { outline: 2px dashed var(--accent); outline-offset: -10px; background: var(--accent-subtle); }
/* Public pages (blog, examples) sit in the landing page's narrower column, not
   the workspace's 1440px one — the two are reached through the same nav, so a
   wider content well reads as a different site. */
.dash--public { max-width: 1120px; padding-inline: 32px; }
.dash__head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-6); margin-bottom: var(--space-6); }
.dash__eyebrow { font-family: var(--font-mono); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: var(--tracking-caps); color: var(--text-muted); margin: 0 0 6px; }
.dash__head h1 { font-family: var(--font-display); font-weight: 600; font-size: var(--text-xl); letter-spacing: -0.02em; margin: 0; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: var(--space-4); }
.card { position: relative; display: flex; flex-direction: column; background: var(--surface-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); overflow: hidden; cursor: pointer; transition: var(--transition-colors), transform var(--dur-fast) var(--ease-out); }
.card:hover { border-color: var(--accent-border); box-shadow: var(--shadow-md); }
.card:active { transform: translateY(1px); }
.card__thumb { position: relative; height: 132px; overflow: hidden; background: var(--surface-inset); color: var(--text-faint); }

/* Signature: card wave-top — the white body rises into the preview along a
   wavy waterline (BRAND_BRIEF signatures). A teal edge marks open review. */
/* Height is 1px more than the pull-up, so the fill laps *past* the preview's
   bottom edge instead of ending on it. Two antialiased edges on the same
   fractional device pixel don't cancel — they leave a ~25% sliver of the cover
   colour as a hairline under the wave (visible at 125%/150% zoom, and only in
   the rows whose layout lands on a fraction). Overlapping hides it; the extra
   pixel is pulled back off the flow below. */
.card__wave { display: block; width: 100%; height: 14px; margin-top: -13px; margin-bottom: -1px; position: relative; z-index: 1; pointer-events: none; }
.card__wave > path:first-child { fill: var(--surface-card); }
.card__wave-edge { fill: none; stroke: var(--accent); stroke-width: 1.4; }
[data-theme="dark"] .card__wave-edge { stroke: var(--tide-bright); }
.card__thumb-fallback { position: absolute; inset: 0; display: grid; place-items: center; }
.card__thumb svg { width: 34px; height: 34px; }
/* The thumbnail: a headless render of the artifact, painted over the fallback
   glyph once it loads. Top-anchored cover so the document's head reads. */
.card__preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top center; background: #fff; opacity: 0; transition: opacity var(--dur-base) var(--ease-out); }
.card__thumb.is-loaded .card__preview { opacity: 1; }
.card__body { display: flex; flex-direction: column; gap: 5px; padding: var(--space-3) var(--space-4) var(--space-4); }
.card__title { font-weight: var(--weight-semibold); font-size: var(--text-md); color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card__meta { color: var(--text-muted); font-size: var(--text-sm); }
/* "Shared with me" cards: no owned thumbnail — a dashed edge marks them as
   external, and a thin accent stripe stands in for the preview region. */
.card--shared { border-style: dashed; }
.card--shared .card__body { padding-top: var(--space-4); border-top: 3px solid var(--accent-subtle); }
/* Inline rename field — mirrors the title's footprint so the tile doesn't jump. */
.card__title-input { width: 100%; font-family: inherit; font-weight: var(--weight-semibold); font-size: var(--text-md); color: var(--text-primary); background: var(--surface-card); border: 1px solid var(--accent-border); border-radius: var(--radius-sm); padding: 1px var(--space-1); outline: none; box-shadow: var(--ring); }
.card__actions { position: absolute; top: var(--space-2); right: var(--space-2); display: flex; gap: var(--space-1); opacity: 0; transition: opacity var(--dur-fast) var(--ease-standard); }
.card:hover .card__actions, .card:focus-within .card__actions { opacity: 1; }
.card__action { display: grid; place-items: center; width: 26px; height: 26px; border: none; background: color-mix(in srgb, var(--surface-card) 80%, transparent); color: var(--text-muted); cursor: pointer; border-radius: var(--radius-md); transition: var(--transition-colors); }
.card__action:hover { background: var(--surface-hover); color: var(--text-primary); }
.card__action--danger:hover { background: var(--danger-bg); color: var(--danger-fg); }

.empty { grid-column: 1 / -1; text-align: center; color: var(--text-muted); padding: var(--space-6) var(--space-4); }
.empty__sub { font-size: var(--text-sm); max-width: 44ch; margin: 6px auto 0; }

/* ── blog (public articles, reusing the workspace look) ──────────────────── */
.blog__sub { max-width: 62ch; margin: 10px 0 0; color: var(--text-secondary); font-size: var(--text-md); line-height: 1.55; }
.blog__filters { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-bottom: var(--space-5); }
.bchip { font-family: inherit; font-size: var(--text-sm); font-weight: 500; color: var(--text-secondary); background: var(--surface-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-full); padding: 6px 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; width: auto; transition: var(--transition-colors); }
.bchip:hover { border-color: var(--accent-border); color: var(--text-primary); }
.bchip.is-on { background: var(--accent); border-color: var(--accent); color: var(--text-on-accent); }
.bchip--saved { margin-left: auto; }
.bchip svg { width: 14px; height: 14px; }

.bcard__cover { position: relative; height: 134px; padding: var(--space-4); display: flex; flex-direction: column; justify-content: flex-end; color: #fff; overflow: hidden; }
/* The brand mark bleeding out of the corner, cropped to its *waves*: at the old
   offset the screen outline was cut mid-stroke, and the leftover corner arc read
   as a rendering glitch rather than a watermark. -46px lifts the outline clear
   of the cover, so only the wave lines wash in from the top-right. */
.bcard__watermark { position: absolute; right: -16px; top: -50px; opacity: 0.16; filter: brightness(0) invert(1); }
.bcard__watermark svg { width: 96px; height: 96px; }
.bcard__cat { font-family: var(--font-mono); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: var(--tracking-caps); font-weight: 700; }
.bcard__read { font-size: var(--text-xs); opacity: 0.88; margin-top: 2px; }
.bcard__star { position: absolute; top: var(--space-2); right: var(--space-2); display: grid; place-items: center; width: 30px; height: 30px; border: none; border-radius: var(--radius-full); background: color-mix(in srgb, #000 26%, transparent); color: #fff; cursor: pointer; transition: var(--transition-colors); }
.bcard__star:hover { background: color-mix(in srgb, #000 42%, transparent); }
.bcard__star svg { width: 16px; height: 16px; fill: none; }
.bcard__star.is-on svg { fill: #fff; }
.bcard__excerpt { color: var(--text-secondary); font-size: var(--text-sm); line-height: 1.5; margin: 2px 0 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ── dialog ───────────────────────────────────────────────────────────── */
.overlay { position: fixed; inset: 0; background: var(--scrim); display: flex; align-items: center; justify-content: center; z-index: 80; }
.dialog { width: 560px; max-width: 92vw; background: var(--surface-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-xl); padding: var(--space-6); box-shadow: var(--shadow-pop); }
.dialog h2 { font-family: var(--font-display); font-weight: 600; margin: 0 0 4px; font-size: var(--text-lg); }
.dialog__hint { color: var(--text-muted); font-size: var(--text-sm); margin: 0 0 var(--space-3); }
.dialog__ta { width: 100%; height: 200px; font-family: var(--font-mono); font-size: var(--text-xs); padding: var(--space-3); border: 1px solid var(--border-default); border-radius: var(--radius-md); background: var(--surface-inset); color: var(--text-primary); resize: vertical; }
.dialog__ta:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.dialog__row { margin: var(--space-3) 0; font-size: var(--text-sm); color: var(--text-muted); }
.dialog__actions { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-4); }

/* ── new-artifact flow ────────────────────────────────────────────────── */
.dialog--new { width: 600px; }
.newart__opts { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); margin-top: var(--space-4); }
.newart__opt { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left; padding: var(--space-4); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); background: var(--surface-card); cursor: pointer; font: inherit; transition: var(--transition-colors), transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out); }
.newart__opt:hover { border-color: var(--accent-border); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.newart__opt:active { transform: translateY(0); }
.newart__opt.is-drop { border-color: var(--accent); border-style: dashed; background: var(--accent-subtle); box-shadow: var(--ring); }
.newart__opt-ic { display: grid; place-items: center; width: 44px; height: 44px; border-radius: var(--radius-md); background: var(--surface-inset); color: var(--text-secondary); margin-bottom: var(--space-1); }
.newart__opt-ic--accent { background: var(--accent-subtle); color: var(--accent); }
.newart__opt-title { font-weight: var(--weight-semibold); font-size: var(--text-md); color: var(--text-primary); }
.newart__opt-sub { font-size: var(--text-sm); color: var(--text-muted); line-height: 1.4; }
.newart__foot { display: flex; justify-content: center; margin-top: var(--space-4); }
.newart__link { font: inherit; font-size: var(--text-sm); color: var(--text-muted); background: none; border: none; cursor: pointer; padding: 4px 8px; border-radius: var(--radius-sm); transition: var(--transition-colors); }
.newart__link:hover { color: var(--text-primary); background: var(--surface-hover); }

.newart__preview-head { margin-bottom: var(--space-3); }
.newart__preview-head h2 { margin-bottom: 2px; }
.newart__preview-wrap { flex: 1; min-height: 0; border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); overflow: hidden; background: #fff; box-shadow: var(--shadow-sm); }
/* Clips the scaled (oversized) frame box; the iframe scrolls its own content. */
.newart__preview-stage { width: 100%; height: 100%; overflow: hidden; }
/* width/height/transform are set inline as the frame is fitted to the stage;
   margin auto centers it when the screen is wider than the desktop canvas. */
.newart__preview { border: 0; display: block; background: #fff; transform-origin: top left; margin: 0 auto; }

/* Near-fullscreen preview: documents need room, so the modal takes the screen. */
.dialog--preview { width: 96vw; max-width: 1600px; height: 94vh; display: flex; flex-direction: column; padding: var(--space-5); }
.dialog__section { margin-top: var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); align-items: flex-start; }
.dialog__label { font-size: var(--text-2xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: var(--tracking-caps); margin: 0 0 4px; }
.code-box { width: 100%; font-family: var(--font-mono); font-size: var(--text-xs); background: var(--surface-inset); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); padding: var(--space-3); white-space: pre-wrap; word-break: break-all; color: var(--text-secondary); }
.tok-row { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); padding: var(--space-2) 0; border-top: 1px solid var(--border-subtle); font-size: var(--text-sm); }
.tok-row__meta { color: var(--text-muted); font-size: var(--text-2xs); margin-top: 2px; }

/* ── toast ────────────────────────────────────────────────────────────── */
.toast { position: fixed; bottom: var(--space-5); left: 50%; transform: translateX(-50%) translateY(20px); background: var(--slate-900); color: var(--white); padding: 10px var(--space-4); border-radius: var(--radius-lg); font-size: var(--text-sm); box-shadow: var(--shadow-pop); opacity: 0; transition: opacity var(--dur-base), transform var(--dur-base); pointer-events: none; max-width: 80vw; z-index: 90; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast--err { background: var(--danger); }

/* ── "Pending review" section + tile review state ────────────────────────
   Review is normal work, not a warning: the brand reserves amber for
   warnings, so review state reads in the tide accent (teal waterline edge on
   tiles — see .card__wave-edge — and tide chips/CTAs here). */
.review-sec { margin-bottom: var(--space-6); }
.pill-count { font-size: var(--text-2xs); font-weight: 700; color: var(--accent-text); background: var(--accent-subtle); border: 1px solid var(--accent-border); border-radius: var(--radius-full); padding: 2px 9px; }
.sec-label { font-family: var(--font-mono); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: var(--tracking-caps); color: var(--text-muted); margin: 0; }
.sec-head { display: flex; align-items: center; gap: var(--space-2); margin: 0 0 var(--space-3); }
.sec-head__more { margin-left: auto; font-size: var(--text-sm); font-weight: 500; color: var(--text-muted); text-decoration: none; }
.sec-head__more:hover { color: var(--text-primary); }
.home-sec { margin-bottom: var(--space-6); }

.review-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--space-4); }
.rcard { position: relative; display: flex; flex-direction: column; background: var(--surface-card); border: 1px solid var(--accent-border); border-radius: var(--radius-lg); overflow: hidden; cursor: pointer; box-shadow: var(--shadow-sm); transition: var(--transition-colors), transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out); }
.rcard:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); border-color: var(--accent); }
.rcard:active { transform: translateY(0); }
.rcard__row { display: flex; gap: var(--space-3); padding: var(--space-3); }
.rcard__thumb { position: relative; width: 104px; height: 78px; flex: none; border-radius: var(--radius-md); overflow: hidden; border: 1px solid var(--border-subtle); background: var(--surface-inset); }
.rcard__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top center; background: #fff; opacity: 0; transition: opacity var(--dur-base) var(--ease-out); }
.rcard__thumb.is-loaded .rcard__img { opacity: 1; }
.rcard__badge { position: absolute; top: 6px; right: 6px; z-index: 3; display: inline-flex; align-items: center; gap: 4px; font-size: 10px; font-weight: 700; color: var(--text-on-accent); background: var(--accent); padding: 2px 7px; border-radius: var(--radius-full); box-shadow: var(--shadow-sm); }
.rcard__main { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.rcard__title { font-weight: var(--weight-semibold); font-size: var(--text-md); color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rcard__sum { color: var(--text-secondary); font-size: var(--text-sm); margin-top: 4px; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.src { display: inline-flex; align-items: center; gap: 5px; font-size: var(--text-2xs); font-weight: 600; padding: 2px 8px 2px 3px; border-radius: var(--radius-full); }
.src--human { background: var(--surface-inset); color: var(--text-secondary); }
.src--ai { background: var(--accent-subtle); color: var(--accent); padding-left: 8px; }
.src--ai svg { width: 13px; height: 13px; }
.avatar { width: 18px; height: 18px; border-radius: var(--radius-full); display: inline-grid; place-items: center; font-size: 9px; font-weight: 700; color: var(--white); }
.rcard__foot { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); padding: var(--space-2) var(--space-3) var(--space-3); }
.rcard__when { color: var(--text-muted); font-size: var(--text-2xs); }
.rcard__cta { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 14px; border: none; border-radius: var(--radius-md); background: var(--accent); color: var(--text-on-accent); font-weight: 600; font-size: var(--text-sm); transition: var(--transition-colors); }
.rcard__cta:hover { background: var(--accent-hover); }

/* pending-review marker on a tile title */
.card__title .dot { display: inline-block; width: 7px; height: 7px; border-radius: var(--radius-full); background: var(--accent); margin-right: 6px; vertical-align: middle; }

/* ── sources / connectors (issue #113) ─────────────────────────────────── */
.src-sec { margin-top: var(--space-5); }
.src-sec__head { display: flex; align-items: center; gap: 10px; margin-bottom: var(--space-3); }
.src-sec__head h2 { font-size: var(--text-lg); margin: 0; }
.src-conn { border: 1px solid var(--border-default); border-radius: var(--radius-lg); padding: var(--space-4); margin-bottom: var(--space-4); background: var(--surface-card); }
.src-conn__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-3); }
.src-conn__acct { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; }
.src-picker { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: var(--space-3); }
.src-files { display: flex; flex-direction: column; gap: 2px; max-height: 320px; overflow-y: auto; }
.src-file { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; padding: 8px 10px; border: none; border-radius: var(--radius-md); background: transparent; color: var(--text-primary); font: inherit; font-size: var(--text-sm); cursor: pointer; transition: var(--transition-colors); }
.src-file:hover { background: var(--surface-inset); }
.src-file svg { flex: none; color: var(--text-muted); }
.src-file span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── favourites (the star) ────────────────────────────────────────────── */
.card__action--fav.is-fav, .lrow__star.is-fav { color: var(--accent); }
.card__action--fav.is-fav svg, .lrow__star.is-fav svg { fill: var(--accent); }
/* a starred tile keeps its star visible without hover */
.card .card__actions:has(.card__action--fav.is-fav) { opacity: 1; }

/* ── Home: compact recent cards ───────────────────────────────────────── */
.recent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--space-3); }
.mini-card { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2); background: var(--surface-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); cursor: pointer; box-shadow: var(--shadow-xs); transition: var(--transition-colors), box-shadow var(--dur-fast) var(--ease-out); }
.mini-card:hover { border-color: var(--accent-border); box-shadow: var(--shadow-md); }
.mini-card__thumb { position: relative; width: 72px; height: 52px; flex: none; display: grid; place-items: center; border-radius: var(--radius-md); border: 1px solid var(--border-subtle); background: var(--surface-inset); color: var(--text-faint); overflow: hidden; }
.mini-card__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top center; background: #fff; }
.mini-card__main { min-width: 0; }
.mini-card__title { font-weight: var(--weight-semibold); font-size: var(--text-sm); color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-card__meta { color: var(--text-muted); font-size: var(--text-2xs); margin-top: 2px; }

/* ── filters row (view toggle; tags/sort arrive with folders) ─────────── */
.filters { display: flex; align-items: center; gap: var(--space-2); margin: 0 0 var(--space-3); }
/* The chips + sort are wrapped so the phone tier can scroll them while the view
   toggle stays pinned; `contents` keeps this one flex line on desktop (#234). */
.filters__scroll { display: contents; }
.filters__spacer { flex: 1; }
.view-seg .seg__btn { width: 32px; }
.seg__btn--label { display: inline-flex; align-items: center; gap: 6px; width: auto; padding: 0 12px; font-size: var(--text-sm); font-weight: 500; }

/* ── list view ────────────────────────────────────────────────────────── */
.list { background: var(--surface-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-xs); }
.lrow { display: grid; grid-template-columns: 26px 34px 24px minmax(0, 1fr) 190px 150px 96px 40px; align-items: center; gap: var(--space-2); height: 46px; padding: 0 var(--space-2); border-bottom: 1px solid var(--border-subtle); cursor: pointer; transition: var(--transition-colors); }
.lrow:last-child { border-bottom: 0; }
.lrow:hover { background: var(--surface-hover); }
.lrow--head { height: 34px; cursor: default; background: var(--surface-inset); font-family: var(--font-mono); font-size: 9.5px; text-transform: uppercase; letter-spacing: var(--tracking-caps); color: var(--text-muted); }
.lrow--head:hover { background: var(--surface-inset); }
.lrow__star { display: grid; place-items: center; width: 28px; height: 28px; margin-left: 4px; border: none; background: none; border-radius: var(--radius-sm); color: var(--text-faint); cursor: pointer; transition: var(--transition-colors); }
.lrow__star:hover { background: var(--surface-active); color: var(--text-secondary); }
.lrow__icon { display: inline-flex; color: var(--text-muted); }
/* The name and the meta cells are wrapped in the markup so a phone can stack
   them into a two-line touch row; on desktop the wrappers aren't boxes at all,
   so the grid still lays out the same eight columns it always did (#234). */
.lrow__main, .lrow__meta { display: contents; }
.lrow__name { font-weight: var(--weight-semibold); font-size: var(--text-sm); color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lrow__when { font-size: var(--text-sm); color: var(--text-muted); }
.lrow__status { display: flex; }
.lrow__actions { display: flex; justify-content: flex-end; gap: var(--space-1); opacity: 0; transition: opacity var(--dur-fast) var(--ease-standard); }
.lrow:hover .lrow__actions, .lrow:focus-within .lrow__actions { opacity: 1; }
.chip-review { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 8px; border-radius: var(--radius-full); background: var(--accent-subtle); border: 1px solid var(--accent-border); color: var(--accent-text); font-size: var(--text-2xs); font-weight: 600; }
.chip-review__dot { width: 6px; height: 6px; border-radius: var(--radius-full); background: var(--accent); }
/* The phone-tier list row lives in the responsive block at the end of this
   file — it has to be declared after `.lrow__tags` to win (a media query adds
   no specificity, and the original ≤760px rule lost that cascade). */

/* ── search palette (⌘K) ──────────────────────────────────────────────── */
.pal-scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 95; }
.palette { position: fixed; left: 50%; top: 84px; transform: translateX(-50%); width: 640px; max-width: calc(100vw - 32px); background: var(--surface-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-xl); box-shadow: var(--shadow-pop); z-index: 96; overflow: hidden; }
.palette__input { display: flex; align-items: center; gap: 11px; padding: 14px var(--space-4); border-bottom: 1px solid var(--border-subtle); color: var(--text-muted); }
/* Both belong to the phone tier's full-screen search: the field becomes a pill
   beside a back button. Neither is a box on desktop (#234). */
.palette__pill { display: contents; }
.palette__back { display: none; }
.palette__field { flex: 1; border: 0; outline: 0; background: none; font: inherit; font-size: var(--text-md); color: var(--text-primary); }
.palette__field::placeholder { color: var(--text-faint); }
.palette__scopes { display: flex; gap: 6px; padding: var(--space-2) var(--space-4) 2px; }
/* A chip is a pill of fixed height: its label has to stay on one line, or the
   text breaks out of the pill ("Shared with / me"). The row gives up width
   before the label does — it scrolls itself rather than squeezing them. */
.palette__scopes .fchip { flex: none; }
.fchip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 11px; border-radius: var(--radius-full); border: 1px solid var(--border-default); background: var(--surface-card); font: inherit; font-size: var(--text-xs); font-weight: 500; color: var(--text-secondary); white-space: nowrap; cursor: pointer; transition: var(--transition-colors); }
.fchip:hover { background: var(--surface-hover); }
.fchip.is-on { background: var(--accent-subtle); border-color: var(--accent-border); color: var(--accent-text); font-weight: 600; }
.palette__body { max-height: 420px; overflow-y: auto; padding: var(--space-1) var(--space-2) var(--space-2); }
.palette__note { padding: var(--space-4); text-align: center; color: var(--text-muted); font-size: var(--text-sm); }
.pgroup__label { font-family: var(--font-mono); font-size: 9.5px; text-transform: uppercase; letter-spacing: var(--tracking-caps); color: var(--text-faint); padding: var(--space-2) var(--space-2) 4px; }
.prow { display: flex; align-items: center; gap: 11px; padding: 8px var(--space-2); border-radius: var(--radius-md); cursor: pointer; }
.prow.is-active { background: var(--surface-hover); }
.prow__ic { display: inline-flex; color: var(--text-muted); flex: none; }
.prow__main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 1px; }
.prow__title { font-size: var(--text-sm); font-weight: 550; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prow__title mark { background: var(--highlight-bg); color: var(--highlight-fg); border-radius: 2px; padding: 0 1px; font-weight: 700; }
.prow__path { font-size: var(--text-2xs); color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette__foot { display: flex; align-items: center; gap: var(--space-4); padding: 8px var(--space-4); border-top: 1px solid var(--border-subtle); background: var(--surface-inset); font-size: var(--text-2xs); color: var(--text-muted); }
.palette__foot kbd { margin-right: 3px; }

/* ── settings ─────────────────────────────────────────────────────────── */
.settings { display: flex; gap: var(--space-6); align-items: flex-start; }
.set-nav { width: 190px; flex: none; display: flex; flex-direction: column; gap: 1px; position: sticky; top: 0; }
.set-panel { flex: 1; min-width: 0; max-width: 640px; }
.set-card { background: var(--surface-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); padding: var(--space-5); margin-bottom: var(--space-4); box-shadow: var(--shadow-xs); }
.set-card h3 { display: flex; align-items: center; gap: 9px; margin: 0 0 4px; font-size: var(--text-md); font-weight: 650; color: var(--text-primary); }
.set-card h3 svg { color: var(--text-secondary); }
.set-card > p { margin: 0 0 var(--space-3); font-size: var(--text-sm); color: var(--text-secondary); line-height: 1.5; }
.set-row { display: flex; align-items: center; gap: var(--space-3); padding: 11px 0; border-top: 1px solid var(--border-subtle); }
.set-row__main { flex: 1; min-width: 0; }
.set-row__main b { display: block; font-size: var(--text-sm); font-weight: 600; color: var(--text-primary); }
.set-row__main span { display: block; font-size: var(--text-xs); color: var(--text-muted); margin-top: 1px; }
.set-row__avatar { width: 26px; height: 26px; font-size: 10px; flex: none; }
.role-chip { font-family: var(--font-mono); font-size: 9.5px; text-transform: uppercase; letter-spacing: var(--tracking-caps); color: var(--text-muted); border: 1px solid var(--border-subtle); border-radius: var(--radius-full); padding: 2px 9px; }
.set-invite { display: flex; gap: var(--space-2); align-items: center; margin-bottom: var(--space-3); }
.set-input { flex: 1; font: inherit; font-size: var(--text-sm); color: var(--text-primary); padding: 7px 11px; border: 1px solid var(--border-default); border-radius: var(--radius-md); background: var(--surface-inset); }
.set-input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); background: var(--surface-card); }
.note { font-size: var(--text-xs); color: var(--text-muted); line-height: 1.5; margin: var(--space-2) 0 0; }
.src-cta { display: flex; gap: var(--space-2); align-items: center; margin-top: var(--space-3); }
@media (max-width: 820px) { .settings { flex-direction: column; } .set-nav { width: 100%; flex-direction: row; flex-wrap: wrap; position: static; } }

/* ── folders + tags (phase 2) ─────────────────────────────────────────── */
/* sidebar sections */
.sb-organizer { margin-top: var(--space-2); }
.sb-sec { display: flex; align-items: center; font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; letter-spacing: var(--tracking-caps); color: var(--text-faint); margin: var(--space-4) var(--space-2) 4px; }
.sb-sec__btn { display: grid; place-items: center; width: 20px; height: 20px; margin-left: auto; border: none; background: none; border-radius: var(--radius-sm); color: var(--text-faint); cursor: pointer; transition: var(--transition-colors); }
.sb-sec__btn:hover { background: var(--surface-hover); color: var(--text-secondary); }
.sb-item--tree { height: 30px; font-weight: 400; }
.sb-item__chev { display: grid; place-items: center; width: 16px; height: 16px; flex: none; border: none; background: none; border-radius: var(--radius-sm); color: var(--text-faint); cursor: pointer; padding: 0; }
.sb-item__chev:hover { background: var(--surface-active); color: var(--text-secondary); }
.sb-item__chev--none { pointer-events: none; }
.sb-item__label { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-item__count { margin-left: auto; font-size: var(--text-2xs); color: var(--text-faint); }
.sb-item--tag { height: 30px; font-weight: 400; }
.sb-tagdot { width: 8px; height: 8px; border-radius: var(--radius-full); flex: none; margin: 0 4px; }
.sb-item.is-drop { background: var(--accent-subtle); box-shadow: inset 0 0 0 1.5px var(--accent); }

/* tag chips */
.tagchip { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 8px; border-radius: var(--radius-full); border: 1px solid var(--border-subtle); background: var(--surface-card); font-size: var(--text-2xs); font-weight: 500; color: var(--text-secondary); max-width: 110px; }
.tagchip__dot { width: 7px; height: 7px; border-radius: var(--radius-full); flex: none; }
.tagchip__name { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tagchip--more { color: var(--text-muted); }
.card__tags { display: flex; gap: 4px; margin-top: 7px; flex-wrap: wrap; }
.lrow__tags { display: flex; gap: 4px; overflow: hidden; }
.tagdot-lg { display: inline-block; width: 12px; height: 12px; border-radius: var(--radius-full); margin-right: 9px; }

/* ⋯ menu */
.pmenu { position: fixed; z-index: 98; min-width: 200px; background: var(--surface-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); box-shadow: var(--shadow-pop); padding: 5px; }
.pmenu__item { display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px; border: none; background: none; border-radius: var(--radius-md); font: inherit; font-size: var(--text-sm); font-weight: 500; color: var(--text-secondary); cursor: pointer; text-align: left; transition: var(--transition-colors); }
.pmenu__item svg { color: var(--text-muted); }
.pmenu__item:hover { background: var(--surface-hover); color: var(--text-primary); }
.pmenu__item--danger:hover { background: var(--danger-bg); color: var(--danger-fg); }
.pmenu__item--danger:hover svg { color: var(--danger-fg); }

/* move / tags dialogs */
.dialog--organize { width: 420px; }
.pick-list { display: flex; flex-direction: column; gap: 2px; max-height: 320px; overflow-y: auto; margin-top: var(--space-2); }
.pick-row { display: flex; align-items: center; gap: 9px; width: 100%; padding: 9px 12px; border: none; background: none; border-radius: var(--radius-md); font: inherit; font-size: var(--text-sm); font-weight: 500; color: var(--text-primary); cursor: pointer; text-align: left; transition: var(--transition-colors); }
.pick-row svg { color: var(--text-muted); flex: none; }
.pick-row:hover { background: var(--surface-hover); }
.pick-row--check { cursor: pointer; }
.pick-row--check input { accent-color: var(--accent); }

/* tag editor */
.tag-editor { display: flex; align-items: center; gap: var(--space-3); margin-top: var(--space-2); }
.swatches { display: flex; gap: 7px; flex: none; }
.swatch { width: 22px; height: 22px; border-radius: var(--radius-full); border: 2px solid transparent; cursor: pointer; padding: 0; }
.swatch.is-on { border-color: var(--text-primary); box-shadow: inset 0 0 0 2px var(--surface-card); }
.btn--danger-ghost { color: var(--danger-fg); margin-right: auto; }
.btn--danger-ghost:hover { --_bg: var(--danger-bg); --_fg: var(--danger-fg); }

/* list extras: select checkbox, folder rows */
.lrow__checkwrap { display: grid; place-items: center; }
.lrow__check { accent-color: var(--accent); width: 14px; height: 14px; cursor: pointer; opacity: 0; transition: opacity var(--dur-fast) var(--ease-standard); }
.lrow:hover .lrow__check, .lrow__check:checked, .lrow.is-selected .lrow__check { opacity: 1; }
.lrow.is-selected { background: var(--accent-subtle); }
.lrow--folder .lrow__icon--folder { color: var(--text-secondary); }
.lrow.is-drop { background: var(--accent-subtle); box-shadow: inset 0 0 0 1.5px var(--accent); }

/* bulk bar */
.bulkbar { position: sticky; bottom: var(--space-4); display: flex; align-items: center; gap: var(--space-2); width: fit-content; margin: var(--space-4) auto 0; padding: 8px 14px; background: var(--surface-card); border: 1px solid var(--border-default); border-radius: var(--radius-full); box-shadow: var(--shadow-pop); z-index: 30; }
.bulkbar[hidden] { display: none; }
.bulkbar__count { font-size: var(--text-sm); font-weight: 600; color: var(--text-primary); padding-right: var(--space-2); }

/* folder tiles (tile view) + breadcrumbs + misc */
.folder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: var(--space-3); margin-bottom: var(--space-4); }
.folder-tile { display: flex; align-items: center; gap: 9px; padding: 11px 14px; background: var(--surface-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); font: inherit; font-size: var(--text-sm); font-weight: 600; color: var(--text-primary); cursor: pointer; box-shadow: var(--shadow-xs); transition: var(--transition-colors), box-shadow var(--dur-fast) var(--ease-out); }
.folder-tile svg { color: var(--text-secondary); flex: none; }
.folder-tile:hover { border-color: var(--accent-border); box-shadow: var(--shadow-md); }
.folder-tile.is-drop { background: var(--accent-subtle); border-color: var(--accent); }
.folder-tile__name { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.folder-tile__count { margin-left: auto; font-size: var(--text-2xs); color: var(--text-faint); }
.crumbs { display: flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: var(--tracking-caps); color: var(--text-muted); margin: 0 0 6px; }
.crumbs a { color: var(--text-muted); text-decoration: none; }
.crumbs a:hover { color: var(--text-primary); }
.crumbs .sep { color: var(--text-faint); }
.dash__head-actions { display: flex; align-items: center; gap: var(--space-2); }
.wsel--sm { font-size: var(--text-xs); padding: 4px 7px; }
.prow__dot { width: 10px; height: 10px; border-radius: var(--radius-full); }
.btn--sm { height: 28px; padding: 0 11px; font-size: var(--text-xs); }

/* ── phase 2.2 (issue #197) ─────────────────────────────────────────────── */

/* Dark mode: the page (#080D0C) and card (#0F1614) surfaces are nearly the
   same value, so anything that reads as a raised object on the page needs the
   raised surface + a stronger edge to separate (the same fix the editor's
   badges needed — see the #58 note in renderer/app.css). Frame chrome
   (sidebar, topbar, dialogs on the scrim) keeps --surface-card. */
[data-theme="dark"] .card,
[data-theme="dark"] .rcard,
[data-theme="dark"] .mini-card,
[data-theme="dark"] .list,
[data-theme="dark"] .folder-tile,
[data-theme="dark"] .set-card { background: var(--surface-raised); border-color: var(--border-default); }
[data-theme="dark"] .card__wave > path:first-child { fill: var(--surface-raised); }
/* --surface-hover equals the raised surface in dark, so hovers/inset chrome on
   raised objects step one further to stay visible. */
[data-theme="dark"] .lrow:hover { background: var(--surface-active); }
[data-theme="dark"] .lrow--head, [data-theme="dark"] .lrow--head:hover { background: var(--surface-inset); }

/* Sidebar: the Inbox badge (actionable count) + the External subtree. */
.sb-item__count--attn { margin-left: auto; font-size: var(--text-2xs); font-weight: 600; color: var(--accent-text); background: var(--accent-subtle); border: 1px solid var(--accent-border); border-radius: var(--radius-full); padding: 0 7px; }
.sb-item--sub2 { padding-left: 44px; font-weight: 400; height: 30px; }
.sb-item--more { color: var(--text-faint); font-size: var(--text-xs); }
.sb-item__star { margin-left: auto; display: inline-flex; color: var(--accent); }
.sb-item__star svg { width: 11px; height: 11px; fill: var(--accent); }

/* Inbox rows: tasks + new-for-you (shared, with derived read state). */
.trow { display: flex; align-items: center; gap: var(--space-3); padding: 10px var(--space-3) 10px var(--space-2); border-bottom: 1px solid var(--border-subtle); cursor: pointer; transition: var(--transition-colors); }
.trow:last-child { border-bottom: 0; }
.trow:hover { background: var(--surface-hover); }
[data-theme="dark"] .trow:hover { background: var(--surface-active); }
.trow > .trow__ic { display: inline-flex; color: var(--text-muted); flex: none; margin-left: 4px; }
.trow__main { flex: 1; min-width: 0; }
.trow__title { font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trow__meta { font-size: var(--text-xs); color: var(--text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trow__side { display: flex; align-items: center; gap: var(--space-2); flex: none; }
.trow__when { font-size: var(--text-xs); color: var(--text-muted); }
.dot-new { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; margin-left: 6px; }
.dot-new--off { background: var(--border-strong); }

/* Status + assignee chips (Inbox tasks, External draft/PR state). */
.chip-st { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 8px; border-radius: var(--radius-full); background: var(--surface-inset); border: 1px solid var(--border-subtle); color: var(--text-secondary); font-size: var(--text-2xs); font-weight: 600; white-space: nowrap; }
.chip-st--open { background: var(--accent-subtle); border-color: var(--accent-border); color: var(--accent-text); }
.chip-assignee { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px 0 3px; border-radius: var(--radius-full); border: 1px solid var(--border-subtle); background: var(--surface-card); font-size: var(--text-2xs); font-weight: 500; color: var(--text-secondary); white-space: nowrap; }
.chip-assignee .avatar { width: 16px; height: 16px; font-size: 7px; }
.chip-assignee--ai .avatar { background: var(--accent-text); }
[data-theme="dark"] .chip-assignee { background: var(--surface-raised); }

/* External: the repo view's mono source chip + branch picker. */
.chip-src { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 8px; border-radius: var(--radius-full); background: var(--surface-inset); border: 1px solid var(--border-subtle); color: var(--text-muted); font-family: var(--font-mono); font-size: 9.5px; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.branch-pick { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 10px; border: 1px solid var(--border-default); border-radius: var(--radius-md); background: var(--surface-card); color: var(--text-secondary); }
.branch-pick svg { color: var(--text-muted); flex: none; }
.branch-pick select { border: none; background: none; color: var(--text-primary); font-family: var(--font-mono); font-size: var(--text-xs); outline: none; max-width: 180px; }

/* The task dialog's description field. */
.dialog__ta--task { width: 100%; min-height: 110px; resize: vertical; font: inherit; font-size: var(--text-sm); line-height: 1.5; color: var(--text-primary); background: var(--surface-inset); border: 1px solid var(--border-default); border-radius: var(--radius-md); padding: var(--space-2) var(--space-3); }
.dialog__ta--task:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); background: var(--surface-card); }
.dialog--prompt { width: 440px; }
.dialog--prompt form { display: flex; flex-direction: column; align-items: stretch; gap: var(--space-2); }
.dialog--prompt .dialog__label { display: block; margin: 0; }
.dialog--prompt .set-input { width: 100%; }

/* Section caption under an Inbox lane / the External file list. */
.sec-note { font-size: var(--text-xs); color: var(--text-muted); line-height: 1.5; margin: var(--space-2) 0 0; max-width: 72ch; }

/* ── search: in-document hits + the waiting wave (phase 3, issue #189) ──── */

/* An in-document row leads with the matched *text*, so it wraps to two lines
   and the page it lives in sits underneath. */
.prow__snippet { font-size: var(--text-sm); color: var(--text-secondary); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.prow__snippet mark { background: var(--highlight-bg); color: var(--highlight-fg); border-radius: 2px; padding: 0 1px; font-weight: 650; }

/* The brand's waiting signature: a standing wave whose crests swing through
   the line in place (never a travelling spinner). The path is drawn once; only
   its amplitude animates, via scaleY through zero. */
.wave-wait { display: flex; align-items: center; justify-content: center; padding: var(--space-5) var(--space-4); color: var(--accent); }
.wave-wait svg { width: 120px; height: 12px; overflow: visible; }
.wave-wait__path { transform-box: fill-box; transform-origin: 50% 50%; animation: wave-breathe 1.7s ease-in-out infinite; }
@keyframes wave-breathe {
  0%   { transform: scaleY(1); }
  50%  { transform: scaleY(-1); }
  100% { transform: scaleY(1); }
}
/* Reduced motion: hold the wave mid-swing rather than animating it (the
   reference impl renders a static 0.85 amplitude). */
@media (prefers-reduced-motion: reduce) {
  .wave-wait__path { animation: none; transform: scaleY(0.85); }
}
/* The wave sits between the scope chips and the results, so instant title
   matches stay readable while the full-text query is still running. */
.palette__wave:empty { display: none; }
.palette__wave .wave-wait { padding: 9px var(--space-4); }
.palette__wave svg { width: 100%; max-width: 220px; }

/* ── Sharing a folder (#222) ───────────────────────────────────────────────
   A folder has no link of its own — access to it is grants that cascade to the
   pages inside — so this is the people list and nothing else. Mirrors the page
   share dialog's metrics (`src/renderer/app.css`, .share-row) so the two read as
   the same surface even though they live in different shells. */
.fsh { width: 520px; padding: 0; overflow: hidden; }
.fsh__head { display: flex; align-items: center; gap: var(--space-2); padding: 15px 18px 13px; }
.fsh__title { flex: 1; min-width: 0; margin: 0; font-family: var(--font-display); font-weight: 500; font-size: 19px; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fsh__title span { color: var(--text-muted); font-weight: 400; }
.fsh__body { padding: 0 18px 16px; }
.fsh__label { font-family: var(--font-mono); font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: var(--tracking-caps); color: var(--text-faint); margin: 4px 0 4px; }
.fsh__invite { display: flex; align-items: center; gap: var(--space-2); padding-bottom: 12px; }
.fsh__input { flex: 1; min-width: 0; height: 34px; padding: 0 11px; border: 1px solid var(--border-default); border-radius: var(--radius-md); background: var(--surface-inset); color: var(--text-primary); font-family: var(--font-sans); font-size: var(--text-sm); }
.fsh__input::placeholder { color: var(--text-faint); }
.fsh__input:focus-visible { outline: none; box-shadow: var(--ring); }
.fsh__role { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 var(--space-1) 0 var(--space-2); border: 1px solid var(--border-default); border-radius: var(--radius-md); background: var(--surface-card); color: var(--text-primary); font-family: var(--font-sans); font-size: var(--text-xs); font-weight: 550; cursor: pointer; white-space: nowrap; transition: var(--transition-colors); }
.fsh__role:hover { background: var(--surface-hover); }
.fsh__role-chev { display: inline-flex; align-items: center; justify-content: center; width: 13px; height: 13px; color: var(--text-faint); }
.fsh__role:focus-visible { outline: none; box-shadow: var(--ring); }
.fsh__add { flex: none; height: 34px; padding: 0 var(--space-3); }
.fsh__list { display: flex; flex-direction: column; }
.fsh__row { display: flex; align-items: center; gap: 11px; padding: 7px 8px 7px 10px; margin: 0 -8px 0 -10px; border-radius: var(--radius-md); }
.fsh__row:hover { background: var(--surface-hover); }
.fsh__av { flex: none; }
.fsh__av--guest { background: var(--surface-sunken); color: var(--text-muted); box-shadow: var(--shadow-hairline); }
.fsh__who { flex: 1; min-width: 0; }
.fsh__name { font-size: var(--text-sm); font-weight: 550; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fsh__name em { font-style: normal; font-weight: 400; color: var(--text-muted); }
.fsh__meta { font-size: var(--text-2xs); color: var(--text-muted); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fsh__fixed { flex: none; font-size: var(--text-xs); color: var(--text-muted); padding-right: 42px; }
.fsh__x { flex: none; width: 28px; height: 28px; }
.fsh__x svg { width: 14px; height: 14px; }
.fsh__empty { font-size: var(--text-xs); color: var(--text-muted); line-height: 1.45; margin: 2px 0 0; }
.fsh__shortcuts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--space-3); }
.fsh__chip { display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 11px; border: 1px solid var(--border-default); border-radius: var(--radius-full); background: var(--surface-card); color: var(--text-secondary); font-family: var(--font-sans); font-size: var(--text-xs); cursor: pointer; transition: var(--transition-colors); }
.fsh__chip:hover { background: var(--surface-hover); color: var(--text-primary); }
.fsh__note { font-size: var(--text-2xs); color: var(--text-muted); line-height: 1.45; margin: var(--space-3) 0 0; }
/* Rich menu items: a label plus one line of consequence (the access rungs). */
.pmenu__item--rich { align-items: flex-start; }
.pmenu__main { display: flex; flex-direction: column; min-width: 0; }
.pmenu__label { font-size: var(--text-sm); font-weight: 600; color: var(--text-primary); }
.pmenu__sub { font-size: var(--text-2xs); font-weight: 400; color: var(--text-muted); margin-top: 2px; line-height: 1.45; white-space: normal; }
.pmenu__item--on .pmenu__label { color: var(--accent-text); }
.pmenu__item--on .pmenu__label::after { content: " ✓"; color: var(--accent-text); }
.pmenu__item--danger .pmenu__label { color: var(--danger-fg); }
.pmenu__item--blocked { cursor: not-allowed; }
.pmenu__item--blocked:hover { background: none; }
.pmenu__item--blocked .pmenu__label { color: var(--text-faint); }

/* ── bottom sheet — the phone tier's ⋯ menu (#234, mockups/mobile-sheet.png)
   Built from the same item list as `.pmenu`; only the presentation differs.
   It is only ever opened on the phone tier (`isPhone()` decides), so nothing
   here is inside a media query — the component simply isn't reached above it. */
.sheet-scrim { position: fixed; inset: 0; z-index: 97; background: var(--scrim); opacity: 0; transition: opacity var(--dur-base) var(--ease-standard); }
.sheet-scrim.is-open { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 98;
  max-height: 86dvh; overflow-y: auto;
  background: var(--surface-card); border-radius: var(--sheet-radius) var(--sheet-radius) 0 0;
  box-shadow: var(--shadow-pop);
  /* Clears the home indicator, the way the drawer's footer does. */
  padding-bottom: calc(var(--safe-bottom) + 22px);
  transform: translateY(100%);
  transition: transform var(--dur-base) var(--ease-out);
}
.sheet.is-open { transform: none; }
.sheet__grab { display: block; width: 36px; height: 4px; margin: 8px auto 6px; border-radius: 2px; background: var(--border-default); }
.sheet__head { display: flex; align-items: center; gap: var(--space-3); padding: 6px 18px 12px; border-bottom: 1px solid var(--border-subtle); }
.sheet__head-ic { display: inline-flex; color: var(--text-muted); flex: none; }
.sheet__head-main { min-width: 0; }
.sheet__title { font-size: var(--text-base); font-weight: 650; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet__meta { margin-top: 2px; font-size: var(--text-xs); color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet__rows { padding: 6px 0; }
.sheet-row { display: flex; align-items: center; gap: 14px; width: 100%; min-height: var(--sheet-row); padding: 6px 18px; border: 0; background: none; font: inherit; font-size: var(--text-base); font-weight: 500; color: var(--text-primary); text-align: left; cursor: pointer; }
.sheet-row:active { background: var(--surface-hover); }
.sheet-row__ic { display: inline-flex; color: var(--text-muted); flex: none; }
.sheet-row__main { display: flex; flex-direction: column; min-width: 0; }
.sheet-row__sub { font-size: var(--text-xs); font-weight: 400; color: var(--text-muted); margin-top: 2px; line-height: 1.45; white-space: normal; }
.sheet-row.is-on .sheet-row__label { color: var(--accent-text); }
.sheet-row.is-on .sheet-row__label::after { content: " ✓"; }
.sheet-row.is-danger, .sheet-row.is-danger .sheet-row__ic { color: var(--danger-fg); }
.sheet-row.is-blocked { color: var(--text-faint); cursor: not-allowed; }
.sheet-sep { height: 1px; background: var(--border-subtle); margin: 6px 0; }
@media (prefers-reduced-motion: reduce) {
  .sheet, .sheet-scrim { transition: none; }
}
/* A folder tile's ⋯ — the tile is a button, so its actions overlay it in a
   wrapper rather than nesting (Share/Rename/Delete were list-view only). */
.folder-tile-wrap { position: relative; display: flex; }
.folder-tile-wrap .folder-tile { flex: 1; min-width: 0; }
.folder-tile__actions { position: absolute; top: 50%; right: 8px; transform: translateY(-50%); opacity: 0; transition: opacity var(--dur-fast) var(--ease-standard); }
.folder-tile-wrap:hover .folder-tile__actions,
.folder-tile-wrap:focus-within .folder-tile__actions { opacity: 1; }
.fsh__foot { display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-4); padding-top: var(--space-3); border-top: 1px solid var(--border-subtle); }
.fsh__copy { height: 34px; padding: 0 var(--space-3); gap: 6px; }
/* A shared-item row states what it is — a page or a whole folder (#222). */
.trow__ic { display: inline-flex; align-items: center; color: var(--text-muted); flex: none; }

/* ══ Responsive frame — mobile M1 (#233) ═════════════════════════════════
   Three tiers per design-package/tokens/breakpoints.css: desktop ≥1024px,
   tablet 768–1023px, phone <768px. Everything below lives inside a max-width
   query, so the desktop rendering is byte-identical to before.

     tablet  the sidebar becomes an overlay drawer; the topbar keeps its
             search pill and gains the drawer button; content goes full-width
     phone   drawer + bottom tab bar; the topbar becomes the app bar
             (drawer · context title · one action); single-column layouts

   The drawer and the tab bar are the *same* sidebar markup and the same
   destinations as desktop — one DOM, a different frame. ─────────────────── */

/* The two touch-tier surfaces are in the DOM at every width, inert until a
   query below turns them on. */
.drawer-scrim, .tabbar { display: none; }

@media (max-width: 1023px) {
  /* ── Sidebar → overlay drawer ─────────────────────────────────────────── */
  .sidebar {
    position: fixed; z-index: 60; top: 0; bottom: 0; left: 0;
    width: min(var(--drawer-width), 86vw);
    padding: var(--safe-top) 0 var(--safe-bottom) var(--safe-left);
    border-right: 0; border-radius: 0 var(--radius-xl) var(--radius-xl) 0;
    box-shadow: var(--shadow-pop);
    /* Closed: off-canvas *and* out of the tab order (visibility, not just a
       transform — an off-screen sidebar you can still tab into is a trap). */
    transform: translateX(-100%); visibility: hidden;
    transition: transform var(--dur-base) var(--ease-out), visibility var(--dur-base) step-end;
  }
  .shell.is-drawer .sidebar {
    transform: none; visibility: visible;
    transition: transform var(--dur-base) var(--ease-out), visibility 0s;
  }
  .drawer-scrim {
    display: block; position: fixed; inset: 0; z-index: 55; background: var(--scrim);
    opacity: 0; pointer-events: none; transition: opacity var(--dur-base) var(--ease-standard);
  }
  .shell.is-drawer .drawer-scrim { opacity: 1; pointer-events: auto; }

  /* Drawer rows grow to the 44px touch target the design system already
     specifies (--control-lg); the tree/tag rows stay one step tighter.
     The paddings below are the drawn ones (docs/mockups/mobile-shared.css):
     the drawer is a wider surface than the desktop rail, so it carries more
     air — and the footer clears the home indicator. */
  /* `min-height` as well as `height`: a touch target that some future flex
     context can shrink is not a touch target. */
  .sb-item { height: var(--control-lg); min-height: var(--control-lg); font-size: var(--text-base); }
  .sb-item--tree, .sb-item--tag, .sb-item--sub, .sb-item--sub2 { height: 40px; min-height: 40px; }
  .sb-ws { height: var(--control-lg); }
  .sb-sec__btn { width: 32px; height: 32px; }
  .sb-brand { padding: 14px 18px 10px; }
  .sb-nav { padding: 2px 14px 12px; }
  .sb-foot { padding: 10px 14px 26px; }
  .sb-user { padding: var(--space-2); }
  .sb-user__avatar { width: 32px; height: 32px; font-size: 11px; }

  /* The drawer button appears in the topbar; the search pill stays. */
  .topbar { gap: 6px; padding: 0 var(--space-2); }
  .topbar__menu {
    display: grid; place-items: center; flex: none;
    width: var(--control-lg); height: var(--control-lg);
    border: 0; border-radius: var(--radius-md); background: none;
    color: var(--text-secondary); cursor: pointer; transition: var(--transition-colors);
  }
  .topbar__menu:hover, .topbar__menu:active { background: var(--surface-hover); color: var(--text-primary); }
  /* The pill loses its centring spacers and sits beside the drawer button,
     keeping its desktop measure rather than stretching across the tablet. */
  .topbar__side { display: none; }
  .searchbar { height: var(--control-md); }
}

@media (max-width: 767px) {
  /* ── Top app bar: drawer · context · one action ────────────────────────── */
  .topbar { height: var(--appbar-height); }
  .searchbar { display: none; }  /* search is a tab down here */
  .topbar__title {
    display: flex; align-items: center; justify-content: center; gap: var(--space-2);
    flex: 1; min-width: 0;
    font-size: var(--text-base); font-weight: 600; color: var(--text-primary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  /* Home shows the wordmark instead of a title, and it reads as a lockup on
     the left rather than a centred label. */
  .topbar__title--brand { justify-content: flex-start; font-family: var(--font-display); font-weight: var(--wordmark-weight, 300); font-size: var(--text-lg); letter-spacing: var(--wordmark-tracking, -0.01em); }
  .topbar__title .flip-e { display: inline-block; transform: scaleX(-1); }
  .topbar__act {
    display: grid; place-items: center; flex: none;
    width: var(--control-lg); height: var(--control-lg);
    border: 0; border-radius: var(--radius-md); background: none;
    color: var(--text-secondary); text-decoration: none; cursor: pointer;
  }
  .topbar__act:active { background: var(--surface-hover); }
  .topbar__side--right { display: none; }

  /* ── Bottom tab bar: the four many-times-a-day destinations ───────────── */
  .tabbar {
    display: flex; align-items: stretch; flex: none;
    background: var(--surface-card); border-top: 1px solid var(--border-subtle);
    padding-bottom: var(--safe-bottom);
  }
  .tab {
    position: relative; flex: 1; min-width: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    height: var(--tabbar-height); padding: 0 2px;
    border: 0; background: none; font: inherit; font-size: var(--text-2xs); font-weight: 550;
    color: var(--text-muted); text-decoration: none; cursor: pointer;
  }
  .tab:active { background: var(--surface-hover); }
  .tab__ic { display: inline-flex; color: var(--text-muted); }
  .tab.is-active { color: var(--accent-text); font-weight: 650; }
  .tab.is-active .tab__ic { color: var(--accent); }
  .tab__badge {
    position: absolute; top: 4px; left: 50%; margin-left: 5px;
    min-width: 16px; height: 16px; padding: 0 4px;
    display: grid; place-items: center;
    border-radius: var(--radius-full); background: var(--accent); color: var(--text-on-accent);
    font-size: 9.5px; font-weight: 700; line-height: 1;
  }

  /* ── Content: single column, tighter gutters ──────────────────────────── */
  .dash {
    min-height: calc(100dvh - var(--appbar-height) - var(--tabbar-height));
    padding: var(--space-5) var(--space-4) var(--space-8);
  }
  .dash__head { flex-direction: column; align-items: stretch; gap: var(--space-3); margin-bottom: var(--space-5); }
  /* One step down the scale — the desktop 28px heading is oversized on a
     390px screen. (The mockup draws 24px; the type scale's steps here are 22
     and 28, and staying on the scale beats matching the drawing exactly.) */
  .dash__head h1 { font-size: var(--text-xl); }
  .dash__head-actions { display: flex; }
  /* 44px, not the mockup's 40px: §8's touch rule (every hit target ≥44px)
     outranks the drawing on a control you tap.
     The two cases pull opposite ways once the head stacks. Inside the actions
     row, `flex: 1` splits the width between buttons — right. But a button that
     is a direct child of the head is now a flex item in a *column*, where
     `flex: 1` means basis-0 in the vertical axis: it overrides the height and
     collapses the button to its 20px line box. It stretches to full width from
     `align-items: stretch` anyway, so it wants no flex at all. */
  .dash__head-actions .btn { flex: 1; justify-content: center; height: var(--control-lg); }
  .dash__head > .btn { flex: none; justify-content: center; height: var(--control-lg); min-height: var(--control-lg); }
  .crumbs { flex-wrap: wrap; }

  /* ── Say each thing once ──────────────────────────────────────────────
     The app bar names the screen down here, so the body stops repeating it:
     the heading goes, and so does a breadcrumb line that is *only* the root
     crumb (the same word again). A real trail — the path into a folder — is
     navigation, not a label, so it stays. Home is exempt by construction: it
     never sets `has-appbar-title`, because its app bar carries the wordmark. */
  .has-appbar-title .dash__head h1 { display: none; }
  .has-appbar-title .dash__head .crumbs:not(:has(.sep)) { display: none; }
  /* An action the app bar already offers isn't offered twice. */
  .is-appbar-dup { display: none; }

  /* The column header goes — a phone list has no columns to label. The row
     itself is rebuilt as a two-line touch row in the M2 block below. */
  .lrow--head { display: none; }
  /* Favourites/tiles go 2-up; anything with a wide row keeps one column. */
  .grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-3); }
  .review-grid, .recent-grid, .folder-grid { grid-template-columns: minmax(0, 1fr); }
  .newart__opts { grid-template-columns: 1fr; }

  .filters .fchip, .filters .wsel, .filters .seg { flex: none; }

  /* ── Touch sizing: auth + settings inputs and buttons ─────────────────── */
  .field input, .auth__form .btn--primary, .btn--google { height: var(--control-lg); }
  .auth__form .btn { height: var(--control-lg); }
  .set-card .btn, .set-card .wsel, .set-input { min-height: var(--control-lg); }
  .set-input { min-width: 0; }
  .set-row { padding: var(--space-3) 0; }
  /* Email + role + Invite don't fit one phone line — let them wrap instead of
     scrolling the workspace column sideways. */
  .set-invite, .src-cta, .dialog__actions { flex-wrap: wrap; }
  .set-invite .set-input { flex: 1 1 100%; }
  .verifybar { align-items: flex-start; }
  .verifybar__act { flex: none; }

  /* Full-height overlays clear the notch and the home indicator. */
  .overlay { padding: calc(var(--safe-top) + var(--space-3)) var(--space-3) calc(var(--safe-bottom) + var(--space-3)); }
  .dialog { padding: var(--space-4); max-height: 100%; overflow-y: auto; }
  .dialog--preview { width: 100%; height: 100%; max-width: none; padding: var(--space-3); }
  .palette { top: calc(var(--safe-top) + var(--space-3)); }
  /* Four scope chips don't fit a phone's width. The row scrolls rather than
     compressing them into two-line pills. */
  .palette__scopes { overflow-x: auto; scrollbar-width: none; }
  .palette__scopes::-webkit-scrollbar { display: none; }
  .toast { bottom: calc(var(--safe-bottom) + var(--tabbar-height) + var(--space-3)); }
}

/* ══ Workspace on touch — mobile M2 (#234) ══════════════════════════════
   M1 made the frame fit a phone; this makes the *contents* of it tappable.
   Four surfaces, all measured against docs/mockups/mobile-files.png,
   mobile-sheet.png and mobile-search.png:

     row      two lines (title / review chip · tags · age), ≥56px, with the
              star and ⋯ always visible at 44px
     chips    a scroll-snapping row that bleeds off the left edge, with the
              list⇄tile toggle pinned rather than pushed off the right
     sheets   every dialog docks to the bottom edge (the ⋯ menus become real
              bottom sheets — see `.sheet` above)
     search   a full-screen takeover instead of the desktop ⌘K palette

   Only the phone tier is touched; tablet and desktop keep the M1 frame. ── */

/* Nothing may exist only behind hover (§8 rule 2). This is keyed on the input
   device rather than the width, so a touch tablet is covered too — and so a
   new hover-revealed affordance inherits the fix instead of needing one. */
@media (hover: none) {
  .lrow__actions, .card__actions, .folder-tile__actions, .lrow__check { opacity: 1; }
}

@media (max-width: 767px) {
  /* ── The two-line touch row ────────────────────────────────────────────
     The grid becomes a flex line: icon · (title over meta) · star · ⋯. The
     wrappers that were `display: contents` on desktop turn into the two
     lines here. `min-height`, not `height`: a wrapped title grows the row
     rather than spilling out of it. */
  .lrow {
    display: flex; align-items: center; gap: var(--space-3);
    height: auto; min-height: var(--touch-row);
    padding: 8px 6px 8px 14px;
  }
  /* Declared after `.lrow` above, or the flex display would revive the column
     header a phone has no columns to label. */
  .lrow--head { display: none; }
  /* Folder rows carry empty cells for the columns they don't fill; with no
     grid to sit in they'd just be gaps. */
  .lrow > span:empty { display: none; }
  .lrow__main { display: block; flex: 1; min-width: 0; }
  .lrow__meta {
    display: flex; align-items: center; gap: 7px; margin-top: 3px;
    min-width: 0; overflow: hidden;
    font-size: var(--text-xs); color: var(--text-muted); white-space: nowrap;
  }
  /* `block`, not the inline span it is on desktop: an inline box doesn't clip,
     so a long title ran straight out of the row. */
  .lrow__name { display: block; font-size: var(--text-sm); overflow: hidden; }
  /* The chips are whole or absent — a half-drawn tag reads as a rendering
     fault. The age gives way instead. */
  .lrow__when { flex: 0 1 auto; min-width: 0; font-size: inherit; overflow: hidden; text-overflow: ellipsis; }
  /* The review chip leads the meta line — it's the one thing on it that asks
     for something (mockups/mobile-files.png). */
  .lrow__status { order: -1; }
  .lrow__status:empty { display: none; }
  .lrow__tags { display: flex; gap: 5px; flex: none; }
  .lrow__tags .tagchip { height: 18px; }
  /* A folder says what it holds on the same line as its name. */
  .lrow--folder .lrow__main { display: flex; align-items: baseline; gap: var(--space-2); }
  .lrow--folder .lrow__meta { margin-top: 0; flex: none; }
  /* Star and ⋯ are always visible here, and both are real touch targets. They
     also move to the trailing edge (`order`), where a thumb is — the leading
     star is a desktop column, and the drawing puts both after the title. */
  .lrow__star, .lrow__actions .card__action {
    width: var(--control-lg); height: var(--control-lg); min-height: var(--control-lg); flex: none;
  }
  .lrow__star { order: 1; margin-left: 0; }
  .lrow__actions { order: 2; flex: none; }
  /* A permanent checkbox column is a desktop list. Selection is entered from
     the row's own sheet ("Select"), and only then do the boxes appear. */
  .list:not(.is-selecting) .lrow__checkwrap { display: none; }
  .card__actions .card__action { width: var(--control-lg); height: var(--control-lg); }
  /* A long press is a gesture here, not a text selection or an OS callout. */
  .lrow, .card, .folder-tile { -webkit-touch-callout: none; user-select: none; }
  /* A folder tile keeps room for the ⋯ that is now always drawn over it —
     without it the button simply covers the page count. */
  .folder-tile { min-height: var(--touch-row); padding-right: 46px; }
  /* The `hover: none` rule above is the general one; this repeats it for the
     phone width because a narrow window on a hover-capable machine is a touch
     surface often enough — and because it is the form a diagnostic running in
     a desktop browser can actually measure. */
  .lrow__actions, .card__actions, .folder-tile__actions, .lrow__check { opacity: 1; }

  /* ── Filter chip row ──────────────────────────────────────────────────
     The chips scroll and snap; the view toggle sits outside that scroller so
     a workspace with many tags can't push it off the screen (§10.1). The row
     bleeds off the left edge so a scrolled chip reads as continuing past it. */
  .filters { overflow: visible; }
  .filters__scroll {
    display: flex; align-items: center; gap: var(--space-2);
    flex: 1; min-width: 0;
    overflow-x: auto; scrollbar-width: none;
    margin-left: calc(var(--space-4) * -1); padding: 2px 0 2px var(--space-4);
    scroll-snap-type: x proximity; scroll-padding-left: var(--space-4);
    /* An edge fade says "there is more", without a scrollbar to say it. */
    mask-image: linear-gradient(to right, #000 calc(100% - 18px), transparent);
  }
  .filters__scroll::-webkit-scrollbar { display: none; }
  .filters__spacer { display: none; }
  .filters .fchip { height: 32px; padding: 0 14px; font-size: var(--text-sm); scroll-snap-align: start; }
  .filters .wsel { min-height: 32px; }
  .view-seg { flex: none; margin-left: auto; }
  .view-seg .seg__btn { width: 38px; height: 32px; }

  /* ── Dialogs dock to the bottom edge ──────────────────────────────────
     Same content, sheet posture: a centred 92vw card is a desktop shape, and
     on a phone it puts its buttons in the middle of the screen. The grab
     handle is drawn, not marked up — it's an affordance, not content. */
  .overlay { align-items: flex-end; justify-content: stretch; padding: 0; }
  .dialog {
    width: 100%; max-width: none; max-height: 88dvh; overflow-y: auto;
    border-radius: var(--sheet-radius) var(--sheet-radius) 0 0; border-bottom: 0;
    padding: var(--space-2) var(--space-4) calc(var(--safe-bottom) + 22px);
  }
  .dialog::before {
    content: ""; display: block; width: 36px; height: 4px; margin: 8px auto 12px;
    border-radius: 2px; background: var(--border-default);
  }
  .dialog__actions { padding-top: var(--space-2); }
  .dialog__actions .btn { flex: 1; min-height: var(--control-lg); justify-content: center; }
  /* Pick rows (move-to-folder, tags) are list rows too. */
  .pick-row { min-height: var(--sheet-row); }
  /* ── …and can be pulled back down ─────────────────────────────────────
     The handle promises a gesture; `sheet-drag.ts` is the gesture. The
     browser has to stay out of it, or the drag scrolls the workspace behind
     the scrim instead of moving the sheet — which is what makes a sheet feel
     stuck. `none` on the surfaces the drag owns outright; the dialog keeps
     `pan-y` because it may have more content than screen, and `contain` stops
     it chaining into the page when it reaches its own end. */
  .sheet, .sheet-scrim, .overlay { touch-action: none; overscroll-behavior: contain; }
  .dialog { touch-action: pan-y; overscroll-behavior: contain; }

  /* The import preview stays the full-screen takeover M1 made it. */
  .dialog--preview {
    width: 100%; height: 100dvh; max-height: none; border-radius: 0;
    padding: calc(var(--safe-top) + var(--space-3)) var(--space-3) calc(var(--safe-bottom) + var(--space-3));
  }
  .dialog--preview::before { display: none; }

  /* ── Search: a full-screen takeover ───────────────────────────────────
     The desktop palette is a keyboard surface — an "esc" badge, arrow-key
     hints, a floating card. On a phone search is a place you go: it fills the
     screen, the field is a pill beside a back button, and the way out is that
     button rather than a key nobody has. */
  .palette {
    position: fixed; inset: 0; top: 0; left: 0; transform: none;
    width: 100%; max-width: none; height: 100dvh;
    display: flex; flex-direction: column;
    border: 0; border-radius: 0; box-shadow: none;
    padding-top: var(--safe-top);
  }
  .pal-scrim { display: none; }
  .palette__input { gap: var(--space-2); padding: 8px 8px 8px 4px; }
  .palette__input > kbd { display: none; }
  .palette__back {
    display: grid; place-items: center; flex: none;
    width: var(--control-lg); height: var(--control-lg);
    border: 0; border-radius: var(--radius-md); background: none;
    color: var(--text-secondary); cursor: pointer;
  }
  .palette__back:active { background: var(--surface-hover); }
  .palette__pill {
    display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0;
    height: 40px; padding: 0 14px;
    border: 1px solid var(--border-default); border-radius: var(--radius-full);
    background: var(--surface-inset); color: var(--text-muted);
  }
  /* The pill takes the focus ring, so the field inside it doesn't draw a second
     box within the first. */
  .palette__pill:focus-within { border-color: var(--accent-border); box-shadow: var(--ring); }
  .palette__pill .palette__field:focus, .palette__pill .palette__field:focus-visible { outline: 0; box-shadow: none; }
  /* 16px, not a scale step: search autofocuses, and anything smaller makes the
     browser zoom the page as it does (see the field block at the end). */
  .palette__field { font-size: var(--field-touch); }
  .palette__scopes {
    gap: var(--space-2); padding: 12px var(--space-4) 8px;
    scroll-snap-type: x proximity; scroll-padding-left: var(--space-4);
  }
  .palette__scopes .fchip { height: 32px; padding: 0 14px; font-size: var(--text-sm); scroll-snap-align: start; }
  .palette__body { flex: 1; max-height: none; padding-bottom: calc(var(--safe-bottom) + var(--space-3)); }
  .palette__foot { display: none; }
  .prow { min-height: var(--touch-row); padding: 11px 12px; }

  /* Multi-select's bar docks above the tab bar instead of sticking to the
     bottom of a column that scrolls under it. */
  .bulkbar {
    position: fixed; left: var(--space-3); right: var(--space-3); z-index: 45;
    bottom: calc(var(--safe-bottom) + var(--tabbar-height) + var(--space-3));
    width: auto; margin: 0; max-width: none;
    flex-wrap: wrap; justify-content: center; border-radius: var(--radius-lg);
  }
}

/* ══ Fields never trigger the browser's focus zoom (phone tier) ═════════
   A phone browser zooms the page into a text field whose type is under 16px
   the moment it takes focus; the page is then wider than the screen and
   scrolled off its own left edge. Search autofocuses, so the takeover opened
   already zoomed, with its own back button cut off — and every other field
   did the same thing one tap later. The UI scale tops out at 15px, so on this
   tier every field is pinned to the threshold. A browser constant, not a
   scale step.

   Deliberately the last block in the file: it has to outrank the tier rules
   above that set a smaller size on the very same fields. */
@media (max-width: 767px) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),
  textarea, select,
  .field input, .set-input, .palette__field, .dialog__ta, .dialog__ta--task,
  .wsel, .wsel--sm {
    font-size: var(--field-touch);
  }
}
