/* ── Piclu Stylesheet — base, layout, page chrome ────────────────────────
 *
 * Layered:
 *   1. tokens.css      design tokens (CSS custom properties)
 *   2. components.css  reusable primitives (button, input, card, pill, …)
 *   3. style.css       this file — base reset, layout, page chrome
 *
 * HTML files link all three in order. style.css contains nothing that could
 * be lifted into components.css; everything here is page-shape, not pattern.
 *
 * Charter §7: "The hero is the list, not the product. Most screens have no
 * imagery at all." Everything below is in service of that.
 */

* { box-sizing: border-box; }

/* Skip-link — visible only on keyboard focus. Lets a tab user jump past the
 * header chrome to the page's main content in one keypress. */
.skip-link {
    position: absolute;
    top: -100px;
    left: var(--space-3);
    padding: var(--space-2) var(--space-3);
    background: var(--color-fg);
    color: var(--color-bg);
    border-radius: var(--radius-sm);
    text-decoration: none;
    z-index: 100;
}
.skip-link:focus-visible {
    top: var(--space-3);
    box-shadow: var(--shadow-focus);
    outline: none;
    color: var(--color-bg);
}

html, body { background: var(--color-bg); }

body {
    margin: 0;
    color: var(--color-fg);
    font: var(--text-base)/var(--leading-body) var(--font-sans);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Text selection — replace the OS-default blue/teal with a palette-tuned
 * pale teal so highlights on item rows / inputs read as part of the
 * design system, not a foreign overlay. Charter §7 visual restraint. */
::selection {
    background: var(--color-accent-quiet);
    color: var(--color-fg);
}
::-moz-selection {
    background: var(--color-accent-quiet);
    color: var(--color-fg);
}

/* ── Phase 2 home — wordmark header + unified list + capture strip ────── */

.home-body {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}
.home-body main {
    flex: 1 1 auto;
    width: 100%;
    max-width: var(--content-width);
    margin: 0 auto;
    /* Bottom padding reserves room for the fixed .capture-strip-mount
     * so the last list row doesn't sit underneath the composer when
     * the page scrolls to the end. Calc = mount vertical padding +
     * .field height (44px) + iOS home-indicator safe-area. */
    padding: var(--space-3) var(--space-4)
             calc(44px + var(--space-3) * 2 + env(safe-area-inset-bottom, 0px));
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

/* App header: thin top bar with wordmark left, gear-menu mount right.
 * Replaces the prior nav row per design-doc §"Top nav simplification". */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: var(--content-width);
    margin: 0 auto;
    padding: var(--space-3) var(--space-4);
    box-sizing: border-box;
}
.app-wordmark {
    margin: 0;
    font-size: var(--text-md);
    font-weight: var(--weight-semibold);
    letter-spacing: 0.01em;
}
.app-wordmark a {
    color: var(--color-fg);
    text-decoration: none;
}

.items-list {
    list-style: none;
    margin: 0;
    padding: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface-alt);
    overflow: hidden;
}
/* When the list is empty, drop the wrapper border so the empty-state
 * copy doesn't sit above an orphaned 1px line (UX review finding —
 * "missing element" reading). :has() supported in target browsers. */
.items-list:not(:has(li)) {
    border: none;
    background: transparent;
}

.empty-state {
    text-align: center;
    padding: var(--space-7) var(--space-4);
    color: var(--color-fg);
}
.empty-state p { margin: 0 0 var(--space-2); }
.empty-state .muted { color: var(--color-fg-muted); }

/* Onboarding empty state — shown when the user has zero physical Piclus.
 * Larger top padding (the page is otherwise empty), inline button to
 * /settings/devices that the user can tap directly. */
.empty-state-onboarding {
    padding-top: var(--space-8);
}
.empty-state-onboarding p:first-child {
    font-size: var(--text-md);
    font-weight: var(--weight-semibold);
}
.empty-state-onboarding .btn-primary {
    display: inline-block;
    margin-top: var(--space-3);
}

/* Infra-problem banner (device-offline). Thin, dismissable, sits above
 * the items list. Device-offline is INFORMATIONAL, not erroneous (Manju
 * can't fix it from the home — the cook may have unplugged it, WiFi may
 * have hiccuped). Per charter §"status colors muted, never red-alarm",
 * use the muted-fg palette with a thin neutral border, not the warn
 * tokens. The banner-text is a link to /settings/devices — the only
 * place to act on it. */
.infra-banner {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    background: transparent;
    color: var(--color-fg-muted);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
}
.infra-banner-text {
    flex: 1 1 auto;
    color: var(--color-fg);
    text-decoration: none;
}
.infra-banner-text:hover { color: var(--color-accent); }
.infra-banner-dismiss { color: var(--color-fg-muted); }

/* Push-nudge prompt mount: collapses out of the layout when empty so
   the home's flex/gap rhythm isn't displaced by an unused container.
   items.js renderPushPrompt clears + repopulates this mount, so an
   :empty rule is exactly what we want. */
#push-prompt-mount:empty { display: none; }

/* Archive link: subtle "47 resolved →" below the list, charter-quiet. */
.archive-link {
    display: block;
    padding: var(--space-3) var(--space-4);
    color: var(--color-fg-muted);
    text-decoration: none;
    font-size: var(--text-sm);
    text-align: center;
    transition: color var(--motion-quick);
}
.archive-link:hover  { color: var(--color-accent); }
.archive-link:focus-visible {
    outline: none;
    color: var(--color-accent);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-focus);
}

/* Archive stub page (Phase 2 sub-phase C — placeholder for the resolved-
 * items archive surface). */
.archive-stub {
    text-align: center;
    padding: var(--space-7) var(--space-4);
}
.archive-stub h2 {
    font-size: var(--text-lg);
    margin: 0 0 var(--space-3);
}
.archive-back-link {
    color: var(--color-accent);
    text-decoration: none;
}
.archive-back-link:hover { text-decoration: underline; }

/* User-menu popover (gear icon top-right of the home header). */
.user-menu {
    position: relative;
    display: inline-block;
}
.user-menu-trigger {
    color: var(--color-fg-muted);
}
.user-menu-trigger:hover    { color: var(--color-fg); }
.user-menu-trigger[aria-expanded="true"] {
    color: var(--color-accent);
    background: var(--color-surface);
}
.user-menu-pop {
    position: absolute;
    right: 0;
    top: calc(100% + var(--space-1));
    min-width: 220px;
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    padding: var(--space-1);
    z-index: 50;
}
.user-menu-email {
    padding: var(--space-2) var(--space-3);
    color: var(--color-fg-muted);
    font-size: var(--text-xs);
    border-bottom: 1px solid var(--color-border);
    overflow-wrap: anywhere;
}
.user-menu-item {
    display: block;
    width: 100%;
    padding: var(--space-2) var(--space-3);
    color: var(--color-fg);
    text-decoration: none;
    font-size: var(--text-sm);
    text-align: left;
    background: transparent;
    border: none;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background var(--motion-quick);
}
.user-menu-item:hover,
.user-menu-item:focus-visible {
    background: var(--color-surface);
    outline: none;
}
.user-menu-item-button {
    font-family: inherit;
}

/* ── Header ──────────────────────────────────────────────────────────────
 *
 * Quiet, breathing-room. Title left, nav inline, account chip right. */

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--color-border);
    gap: var(--space-4);
    flex-wrap: wrap;
}

header h1 {
    margin: 0;
    font: var(--weight-semibold) var(--text-md)/1 var(--font-sans);
    color: var(--color-fg);
    letter-spacing: -0.01em;
}

#user-info {
    color: var(--color-fg-muted);
    font-size: var(--text-sm);
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
}
#user-info b {
    color: var(--color-fg);
    font-weight: var(--weight-medium);
}

/* Header chrome links (e.g. Sign out) read quieter than inline reveal-style
 * .linky inside content panels — drop the default underline so the header is
 * a single muted register, with hover revealing interaction. */
header .linky { text-decoration: none; }
header .linky:hover { text-decoration: underline; }

#logo a {
    color: var(--color-fg);
    text-decoration: none;
}

/* ── Top nav (Recordings / Devices) ─────────────────────────────────── */

.topnav {
    display: inline-flex;
    gap: var(--space-4);
    margin-left: var(--space-4);
}
.topnav a {
    text-decoration: none;
    color: var(--color-fg-muted);
    font: var(--weight-medium) var(--text-sm)/1 var(--font-sans);
    padding: 4px 0;
    border-bottom: 2px solid transparent;
    transition: color var(--motion-quick), border-color var(--motion-quick);
}
.topnav a:hover { color: var(--color-fg); }
.topnav a:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
    border-radius: var(--radius-sm);
}
.topnav a.active {
    color: var(--color-fg);
    border-bottom-color: var(--color-accent);
}

/* ── Main canvas ────────────────────────────────────────────────────── */

main {
    max-width: var(--content-width);
    margin: 0 auto;
    padding: var(--space-6) var(--space-5);
}

h2 {
    margin: 0 0 var(--space-3);
    font: var(--weight-semibold) var(--text-lg)/var(--leading-tight) var(--font-sans);
    color: var(--color-fg);
    letter-spacing: -0.01em;
}

h3 {
    margin: 0 0 var(--space-3);
    font: var(--weight-semibold) var(--text-base)/1.3 var(--font-sans);
    color: var(--color-fg);
}

p { margin: 0 0 var(--space-3); }

/* Bare anchors get a default appearance via :where() so component classes
 * (.btn-primary, .topnav a, .linky, etc.) always win on the cascade without
 * defensive per-component overrides. The just-fixed CTA hover-collapse was
 * the warning shot — keep this generic rule at zero specificity. */
:where(a) {
    color: var(--color-accent);
    text-decoration: underline;
    text-underline-offset: 3px;
}
:where(a:hover) { color: var(--color-accent-soft); }

form {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

/* ── Recordings: controls strip ─────────────────────────────────────── */

#recordings-controls {
    display: flex;
    gap: var(--space-3);
    align-items: center;
    margin: var(--space-2) 0 var(--space-4);
    flex-wrap: wrap;
}

#filter-chips {
    display: inline-flex;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.status-strip,
#status-strip {
    min-height: 32px;
    margin-bottom: var(--space-3);
}

/* ── Setup status panel (devices.html) ───────────────────────────────────
 *
 * Single live-updating line that replaces the previous step-by-step BLE
 * checklist. Charter §5.1: quiet competence over performative magic. */

.setup-status,
.setup-success,
.setup-error {
    margin: var(--space-4) 0 0;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    font-size: var(--text-base);
}
.setup-status  { background: var(--color-accent-quiet); color: var(--color-fg);  border-color: var(--color-accent-quiet); }
.setup-success { background: var(--color-ok-bg);        color: var(--color-ok);  border-color: var(--color-ok); }
.setup-error   { background: var(--color-err-bg);       color: var(--color-err); border-color: var(--color-err); }

/* Household switcher + label (Decision 31 visual treatment). */
.household-label {
    color: var(--color-fg);
    font-weight: 500;
    padding: 0 var(--space-3);
    font-size: var(--text-sm);
}
.household-label-single {
    /* Decision 31: non-interactive text for single-household users. */
    cursor: default;
}
@media (max-width: 640px) {
    .household-label-default-collapsible {
        display: none;
    }
}
.household-switcher {
    position: relative;
    display: inline-block;
}
.household-switcher-trigger {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: transparent;
    color: var(--color-fg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: var(--text-sm);
}
.household-switcher-trigger:hover {
    background: var(--color-bg-quiet);
}
.household-switcher-caret {
    font-size: 0.75em;
    color: var(--color-fg-quiet);
}
.household-switcher-pop {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: var(--space-2);
    min-width: 200px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 50;
    padding: var(--space-2) 0;
}
.household-switcher-pop.hidden { display: none; }
.household-switcher-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: var(--space-2) var(--space-3);
    background: transparent;
    border: 0;
    color: var(--color-fg);
    cursor: pointer;
    font-size: var(--text-sm);
}
.household-switcher-item:hover { background: var(--color-bg-quiet); }
.household-switcher-item.is-active { font-weight: 600; }
.household-switcher-manage {
    display: block;
    padding: var(--space-2) var(--space-3);
    color: var(--color-accent);
    text-decoration: none;
    border-top: 1px solid var(--color-border);
    margin-top: var(--space-2);
    font-size: var(--text-sm);
}
.household-switcher-manage:hover { background: var(--color-bg-quiet); }

/* Context banner (Decision 32) — calm informational, NOT error-styled.
 * Distinct from .offline-banner so users don't read it as "something is wrong". */
.context-banner {
    position: sticky;
    top: 0;
    z-index: 90;
    margin: 0 0 var(--space-4) 0;
    padding: var(--space-3) var(--space-4);
    background: var(--color-bg-quiet);
    color: var(--color-fg);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    transition: opacity 0.3s ease;
}
.context-banner.is-fading { opacity: 0; }
.context-banner-action {
    color: var(--color-accent);
    text-decoration: underline;
    font-size: var(--text-sm);
}

/* Offline banner on /recordings — appears after a sustained SSE disconnect
 * (15s grace timer). Charter §6 don't lie — tells the user the data they're
 * looking at may be stale, instead of caching a misleading shell. */

.offline-banner {
    margin-bottom: var(--space-4);
    padding: var(--space-3) var(--space-4);
    background: var(--color-warn-bg);
    color: var(--color-warn);
    border: 1px solid var(--color-warn);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
}

/* Session-expired banner — surfaces when /api/me returns 401 on a tab that
 * was previously authed (visibility ping or SSE error cluster). Distinct
 * from .offline-banner: this requires the user to act (re-login) rather
 * than just signaling stale data. Styling is calm-prompt (accent palette)
 * not alarmist — charter §5 calm-competent-operator. */
.session-banner {
    position: sticky;
    top: 0;
    z-index: 100;
    margin: 0 0 var(--space-4) 0;
    padding: var(--space-3) var(--space-4);
    background: var(--color-accent-quiet);
    color: var(--color-fg);
    border-bottom: 1px solid var(--color-accent);
    display: flex;
    gap: var(--space-4);
    align-items: center;
    justify-content: space-between;
    font-size: var(--text-sm);
}
.session-banner-text { flex: 1; }
.session-banner .btn-primary {
    /* Tighter padding than the default to fit the banner row height. */
    padding: 6px 14px;
    font-size: var(--text-sm);
    flex-shrink: 0;
}

/* Install CTA — appears under the success state on devices.html. Charter
 * §5.3 earned-right-to-speak: shown only after first successful setup, only
 * if installation is actually available, and only once (localStorage gate
 * prevents re-pestering). Title is the proposition; buttons are the verbs. */

.install-cta {
    margin-top: var(--space-4);
    padding: var(--space-4);
    background: var(--color-accent-quiet);
    border-radius: var(--radius-md);
}
.install-cta-title {
    margin: 0 0 var(--space-3);
    font: var(--weight-semibold) var(--text-base)/1.4 var(--font-sans);
    color: var(--color-fg);
}

/* In-flight CTA — set while ensureSubscribed() awaits the browser↔push-
 * service handshake (typically 1-3 s). The button stays in place; only
 * its label and a calm opacity pulse change so the user sees "something
 * is happening" without layout shift. */
button.is-loading,
.btn.is-loading {
    cursor: progress;
    animation: cta-pulse 1.4s ease-in-out infinite;
}
@keyframes cta-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.55; }
}
@media (prefers-reduced-motion: reduce) {
    button.is-loading,
    .btn.is-loading { animation: none; }
}

/* Technical-details disclosure — collapsed by default; opt-in for the rare
 * diagnostic moment. Charter §5.5: defaults strong; overrides one tap. */

.setup-details {
    margin-top: var(--space-4);
    color: var(--color-fg-muted);
    font-size: var(--text-sm);
}
.setup-details summary {
    cursor: pointer;
    color: var(--color-fg-muted);
    user-select: none;
}
.setup-details summary:hover { color: var(--color-fg); }
.setup-details summary:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
    border-radius: var(--radius-sm);
}
.setup-details dl {
    margin: var(--space-3) 0 0;
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: var(--space-2) var(--space-4);
}
.setup-details dt { color: var(--color-fg-muted); }
.setup-details dd {
    margin: 0;
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    word-break: break-all;
}

/* ── Login page ──────────────────────────────────────────────────────────
 *
 * Standalone page — no <header>, vertically centred, brand mark plus CTA
 * as the only colour anchors. Type-led wordmark; tagline is factual not
 * poetic; error message appears above the CTA when ?error=… is present.
 *
 * Charter Stage 1 brand-encounter: the user's first Piclu pixel before
 * Google's consent screen. Restraint as proof of charter. */

body.login-body {
    min-height: 100vh;
    min-height: 100svh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-block: var(--space-6);
}

.login-main {
    width: min(100% - 24px, 360px);
}

.login-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-6) var(--space-5);
    box-shadow: var(--shadow-card);
    text-align: center;
}

.login-mark {
    display: block;
    width: 52px;
    height: 52px;
    margin: 0 auto var(--space-4);
}

.login-wordmark {
    margin: 0 0 var(--space-4);
    font: var(--weight-semibold) 32px/1 var(--font-sans);
    color: var(--color-fg);
    letter-spacing: 0;
}

/* Charter Stage-1 promise. Sits between wordmark and CTA — declares what
 * the product does in the user's voice, before the action. Slightly larger
 * than body, slightly muted to keep restraint, italics avoided. */
.login-promise {
    max-width: 26ch;
    margin: 0 auto var(--space-6);
    color: var(--color-fg);
    font: var(--weight-regular) var(--text-base)/1.45 var(--font-sans);
    text-wrap: balance;
}

.login-promise span {
    display: block;
}

.login-cta {
    display: inline-block;
    width: 100%;
    text-align: center;
    padding: 12px 18px;
}

.login-error {
    margin: 0 0 var(--space-4);
    padding: var(--space-3) var(--space-4);
    background: var(--color-err-bg);
    color: var(--color-err);
    border: 1px solid var(--color-err);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    text-align: left;
}

@media (min-width: 480px) {
    body.login-body {
        padding-block: var(--space-8);
    }

    .login-main {
        width: min(100% - 32px, 440px);
    }

    .login-card {
        padding: 40px;
    }

    .login-mark {
        width: 56px;
        height: 56px;
    }

    .login-promise {
        font-size: 18px;
    }
}

/* ── Items (to-do list) ─────────────────────────────────────────────── */

#items-controls {
    margin-bottom: var(--space-4);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

#status-chips {
    display: inline-flex;
    gap: var(--space-2);
    flex-wrap: wrap;
}

/* (.chip / .chip-active legacy filter rules removed — never consumed by
 * any JS/HTML; were silently shadowing primitives.css's .chip per Phase 0
 * code review.) */

#items-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* (day-header removed in Phase 2 sub-phase C — design-doc explicitly
 * drops time separators ("time is implicit in row order"). Recordings
 * admin route still groups by day; if its CSS needs a heading rule it
 * will be added in the recordings-retirement phase.) */

/* Capture strip — WhatsApp-grammar input + dynamic mic/send button.
 * Fixed to the viewport bottom so the strip is always within thumb
 * reach regardless of list length. The translateX(-50%) + max-width
 * pattern keeps the strip aligned with the main column on wide
 * viewports without needing a wrapper element. */
.capture-strip-mount {
    --capture-strip-viewport-shift: 0px;
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%) translateY(var(--capture-strip-viewport-shift));
    width: 100%;
    max-width: var(--content-width);
    background: var(--color-bg);
    padding: var(--space-3) var(--space-4)
             calc(var(--space-3) + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--color-border);
    z-index: 10;
}
.capture-strip {
    display: block;
    position: relative;
}

/* Idle / typing surface — composes .field. Drop the .field gap so the
 * input visually owns the strip and the action button sits flush. */
.capture-idle.field {
    align-items: stretch;
}

/* Recording surface — replaces .capture-idle when the mic is held.
 * Layout (left → right): [●] [0:03] ──────── [← slide to cancel]
 *
 * Visual cues that say "you are recording":
 *   - Accent-quiet background (clearly different from idle field)
 *   - Larger pulsing red dot
 *   - Bolder timer font, normal-fg color
 *   - Border in accent color instead of muted
 *
 * `inset: 0` overlays the idle field exactly (the action button keeps
 * its position underneath via z-index: 1 on .capture-action). */
.capture-recording {
    position: absolute;
    inset: 0;
    background: var(--color-accent-quiet);
    border: 1px solid var(--color-accent);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    padding: 0 var(--space-4);
    gap: var(--space-3);
}
.capture-rec-dot {
    order: 1;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--color-err);
    flex: 0 0 auto;
    animation: capture-pulse 1.4s ease-in-out infinite;
}
.capture-rec-dot.armed {
    background: transparent;
    border: 2px solid var(--color-err);
    animation: none;
}
.capture-rec-timer {
    order: 2;
    font-variant-numeric: tabular-nums;
    color: var(--color-fg);
    font-size: var(--text-base);
    font-weight: var(--weight-semibold);
    min-width: 4ch;
    line-height: 1;
}
.capture-cancel-hint {
    order: 3;
    flex: 1 1 auto;
    text-align: right;
    color: var(--color-fg);
    font-size: var(--text-sm);
    line-height: 1;
    opacity: 0.8;
}
.capture-cancel-hint.armed {
    color: var(--color-err);
    font-weight: var(--weight-semibold);
    opacity: 1;
}
@keyframes capture-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.5; }
}
@media (prefers-reduced-motion: reduce) {
    .capture-rec-dot { animation: none; }
}

/* Action button: locked-geometry circle from primitives, accent-tinted
 * when in send mode. The button itself stays in the same screen position
 * across idle/recording (the recording overlay sits above the input but
 * below the button). */
.capture-action {
    position: relative;
    z-index: 1;
}
.capture-action[disabled] {
    opacity: 0.4;
    cursor: not-allowed;
}

/* .item-row composes the .list-row primitive (display:flex, gap, align,
 * padding); below we only override what differs (border-bottom, hover
 * affordance for the archive button on row hover, and the in-flight
 * variant's pulse). Phase 2 collapsed the row to a single horizontal
 * strip — no expand affordance, no mentions feed, no inline chip strip. */
.item-row {
    border-bottom: 1px solid var(--color-border);
}
.item-row:last-child {
    border-bottom: none;
}

.item-row-done {
    color: var(--color-fg-muted);
    /* Greyscale the entire row — text + chip + checkbox tint included.
     * grayscale(1) drains saturation; opacity dials brightness down so
     * a done row reads as "finished, less salient" without disappearing
     * (still tappable for undo). The checkbox accent-color override
     * complements grayscale() so the tick reads grey, not muted-teal. */
    filter: grayscale(1);
    opacity: 0.55;
}
.item-row-done .item-check {
    accent-color: var(--color-fg-muted);
}

/* Archive surface override: the .item-row-done base rule greys/fades a
 * row; on /archive the user is reviewing the resolved list to maybe
 * uncheck some, so restore full saturation + normal checkbox accent. */
#archive-list .item-row-done {
    filter: none;
    opacity: 1;
    color: inherit;
}
#archive-list .item-row-done .item-check {
    accent-color: var(--color-accent);
}

/* Tick-to-resolve exit: toggleStatus adds this class on open→done, then
 * waits for the animation before renderUnifiedList rebuilds the list
 * without the row. The collapse IS the completion signal — an instant
 * vanish is too easy to miss mid-list (change blindness). max-height
 * starts at a fixed value because a row can wrap to 2-3 lines and you
 * can't animate from height:auto. */
.item-row-leaving {
    animation: item-row-collapse 280ms ease-in forwards;
    overflow: hidden;
    pointer-events: none;
}
@keyframes item-row-collapse {
    0%   { max-height: 160px; opacity: 1; }
    45%  { max-height: 160px; opacity: 0; transform: translateX(8px); }
    100% { max-height: 0; opacity: 0; transform: translateX(8px);
           padding-top: 0; padding-bottom: 0; border-bottom-width: 0; }
}
@media (prefers-reduced-motion: reduce) {
    /* No motion, but keep a ~instant duration so animationend still fires
     * and toggleStatus doesn't fall back to its 320ms timeout. */
    .item-row-leaving { animation-duration: 1ms; }
}

/* In-flight: subtle motion to signal "the brain is working" — applied
 * to Items with LastAction=processing (brain pre-creates the row before
 * the LLM round trip, then enriches when done). Respects
 * prefers-reduced-motion via tokens.css's --motion-* override. */
.item-row-in-flight {
    background: color-mix(in srgb, var(--color-accent) 3%, var(--color-bg));
    animation: row-pulse 1.6s ease-in-out infinite;
}
@keyframes row-pulse {
    0%, 100% { background: color-mix(in srgb, var(--color-accent) 3%, var(--color-bg)); }
    50%      { background: color-mix(in srgb, var(--color-accent) 8%, var(--color-bg)); }
}
@media (prefers-reduced-motion: reduce) {
    .item-row-in-flight { animation: none; }
}

/* Voice-pending: the row has audio clip refs but no user text and no
 * structured content yet — covers both PROCESSING-no-text (LLM still
 * working) and UNPARSED-no-text (LLM done, structured nothing). The
 * single affordance below replaces both prior dead-end states: a play
 * glyph + "Tap to listen and transcribe" hint inline with the headline,
 * row-tap auto-plays the clip and opens the textarea. Subtle accent
 * left-border keeps the row visible without filler copy. */
.item-row-voice-pending {
    border-left: 3px solid color-mix(in srgb, var(--color-accent) 50%, transparent);
    padding-left: calc(var(--space-3) - 3px);
}
.item-voice-pending {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    color: color-mix(in srgb, var(--color-accent) 70%, var(--color-fg-muted));
    cursor: pointer;
    font-size: var(--text-base);
}
.item-voice-pending svg {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
}
.item-voice-pending-text {
    font-style: italic;
}

.item-check {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
    cursor: pointer;
    accent-color: var(--color-accent);
}
.item-check:disabled {
    cursor: default;
    opacity: 0.4;
}

.item-body {
    flex: 1 1 auto;
    min-width: 0;
}

.item-headline-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

/* .item-text is the editable headline — rendered as a <button> so it's
 * keyboard-reachable (Enter/Space activate native), but visually a plain
 * text affordance that morphs to a textarea on click.
 *
 * font-weight is pinned to regular because the base `button` rule in
 * components.css sets `font: var(--weight-medium) ...` via the font
 * shorthand — without this override, every row name renders at 500,
 * which read as "heavier than required" against the warm cream bg. */
.item-text {
    font-size: var(--text-base);
    font-weight: var(--weight-regular);
    line-height: 1.4;
    cursor: text;
    word-wrap: break-word;
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
    color: inherit;
    font-family: inherit;
    text-align: left;
    display: inline;
}
.item-text:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
    border-radius: var(--radius-sm);
}
/* (item-text-done / item-text-archived both removed — the home renders
 * no terminal rows inline; archive.js styles its own headlines.) */
.item-text-muted {
    color: var(--color-fg-muted);
    font-style: italic;
}
/* Uncertainty hint — set when item.text contains `~~uncertain~~`
 * markers from the v1 transcribe prompt's self-review pass. Visual
 * is a faint warm-dotted underline that says "your eyes wanted here"
 * without crowding the row. Only the home sets data-attention, and the
 * home only renders open rows, so no done-row suppression is needed. */
.item-row[data-attention="1"] .item-text {
    text-decoration: underline dotted color-mix(in srgb, var(--color-warn) 55%, transparent);
    text-decoration-thickness: 1.5px;
    text-underline-offset: 4px;
}

.item-edit {
    width: 100%;
    font-size: var(--text-base);
    line-height: 1.4;
    padding: var(--space-2);
    border: 1px solid var(--color-accent, #1F6B6B);
    border-radius: var(--radius-md);
    resize: vertical;
    min-height: 60px;
    font-family: inherit;
}

.item-meta {
    font-size: var(--text-xs);
    color: var(--color-fg-muted);
}

/* (.item-archive rules removed in Phase 2 review pass — the × archive
 * button was dropped per design-doc decision #8 in Phase 2 sub-phase
 * A; the CSS lingered until the review caught it.) */
.item-archive.confirming:hover {
    background: #803629;
    border-color: #803629;
}

#empty-state {
    padding: var(--space-6);
    text-align: center;
    color: var(--color-fg-muted);
}

/* ── v12 two-state Item layout ─────────────────────────────────────────
 *
 * Each Item row carries a collapsed summary (name + structured chips +
 * urgency + play-all + chevron) and an optional expanded mentions feed
 * (one card per attached clip). The expand-in-place pattern (Q5) avoids
 * popups / nav and keeps audio playback context.
 */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* (Phase 2 sub-phase C dead-code cleanup: item-chips (the structured-
 * attribute chip strip), chip-attr / chip-attr-label / chip-revoked /
 * chip-done (modifiers on the strip), and urgency-badge / urgency-low /
 * urgency-high removed — items.js no longer renders any of these per
 * design-doc decision: brain's `·`-rendered text is the canonical row
 * surface; no per-attribute chip strip, no urgency emphasis.) */

/* Circular play / stop button used on items, mentions, orphans. */
.play-button {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--color-accent, #1F6B6B);
    background: var(--color-bg);
    color: var(--color-accent, #1F6B6B);
    cursor: pointer;
    font-size: var(--text-md);
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.play-button.small { width: 28px; height: 28px; font-size: var(--text-sm); }
.play-button.playing {
    background: var(--color-accent, #1F6B6B);
    color: white;
}
.play-button:hover { box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-accent, #1F6B6B) 20%, transparent); }

/* (Phase 2 sub-phase C dead-code cleanup: expand-toggle, mentions-feed,
 * mention-card, mention-meta, mention-time, mention-body, mention-diff,
 * mention-diff-text, diff-chips, diff-chip, diff-chip-set, diff-chip-clear
 * removed — the per-clip mentions-feed expand affordance is gone with the
 * unified-list rewrite (single audio handle plays-all FIFO instead). The
 * play-button family below is still consumed by recordings.js, kept.) */

.muted { color: var(--color-fg-muted); }
.small { font-size: var(--text-xs); }

/* (Phase 2 sub-phase C dead-code cleanup: orphan-section, history-section,
 * section-heading, section-hint, history-toggle, history-row, history-body
 * removed — all consumers retired with the unified-list rewrite. The
 * /api/items/{id}/archive endpoint persists for forensic admin use; the
 * UI surfaces it through the "N resolved →" link to /archive instead.) */

/* ── Settings sections (notifications + household) ───────────────────
 *
 * Composes with .card from components.css for the shared card chrome
 * (background/border/radius/padding/shadow). This file only adds the
 * settings-page-specific heading/label/h3 rules below. The HTML side
 * uses `<section class="card settings-section">` so both rules apply.
 *
 * .card carries margin-bottom for its standalone use; inside the
 * flex-gap parent of .home-body main, gap already spaces sections so
 * the per-card margin would double the gap. Override here.
 */
.home-body main > .card { margin-bottom: 0; }
.settings-section > h2 {
    margin: 0 0 var(--space-2);
    font: var(--weight-semibold) var(--text-md)/1.3 var(--font-sans);
    color: var(--color-fg);
}
.settings-section > h2 + p.muted {
    margin: 0 0 var(--space-4);
}
.settings-section > h3 {
    margin: var(--space-5) 0 var(--space-3);
    font: var(--weight-semibold) var(--text-sm)/1.3 var(--font-sans);
    color: var(--color-fg-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.settings-section label {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}
.settings-section label > .row {
    align-items: stretch;
}
.settings-section label > .row > input[type=text] {
    flex: 1 1 auto;
    min-width: 0;
}
.settings-section-danger {
    border-color: var(--color-border-strong);
    background: var(--color-bg);
}
.settings-section-danger > h2 {
    color: var(--color-err);
}
/* Drop nested-card chrome when .step is inside a .card-wrapped section so
 * we don't get card-in-card on the devices page. */
.card .step {
    background: transparent;
    border: 0;
    padding: 0;
    margin: 0;
    box-shadow: none;
}

/* ── People list (settings-household) ───────────────────────────────── */

.people-list,
.invites-list,
.devices-list {
    display: flex;
    flex-direction: column;
}
.people-row,
.invite-row,
.device-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--color-border);
    flex-wrap: wrap;
}
.people-row:last-child,
.invite-row:last-child,
.device-row:last-child {
    border-bottom: 0;
}
.people-row-info,
.invite-row-actions,
.people-row-actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
}
.people-row-info { flex: 1 1 auto; min-width: 0; }
.people-row-name {
    font: var(--weight-medium) var(--text-base)/1.3 var(--font-sans);
    color: var(--color-fg);
    word-break: break-all;
}
.people-row-meta,
.invite-row-meta,
.device-row-meta {
    font-size: var(--text-sm);
}
.people-row-actions {
    margin-left: auto;
    flex-shrink: 0;
}

/* Invite row: link input is full-width on its own line, actions wrap below */
.invite-row {
    align-items: flex-start;
    flex-direction: column;
}
.invite-link-input {
    width: 100%;
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    color: var(--color-fg-muted);
    transition: border-color var(--motion-quick), color var(--motion-quick);
}
.invite-link-input:hover { border-color: var(--color-border-strong); }
.invite-link-input:focus-visible {
    outline: none;
    border-color: var(--color-accent);
    color: var(--color-fg);
    box-shadow: var(--shadow-focus);
}
.invite-row-actions { margin-left: 0; }

/* Just-created highlight — set transiently by settings-household.js after
 * the invite-create POST returns and loadInvites() refreshes the list.
 * The pale teal wash + tight inset border draws the eye without layout
 * shift. The class self-removes after ~2.4 s; the fade-out is the
 * acknowledgment. */
.invite-row-just-created {
    background: var(--color-accent-quiet);
    border-radius: var(--radius-md);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--color-accent) 30%, transparent);
    padding: var(--space-3);
    animation: invite-fresh-fade 2.4s ease-out forwards;
}
@keyframes invite-fresh-fade {
    0%   { background: var(--color-accent-quiet); }
    80%  { background: var(--color-accent-quiet); }
    100% { background: transparent; box-shadow: none; }
}
@media (prefers-reduced-motion: reduce) {
    .invite-row-just-created { animation: none; }
}

.device-row-name {
    font: var(--weight-medium) var(--text-base)/1.3 var(--font-sans);
    color: var(--color-fg);
}

/* ── Invite landing (anonymous-friendly card) ──────────────────────── */

/* Override .home-body main { flex: 1 1 auto; width: 100% } so the card
 * sizes to content + viewport. Width must be `auto` (not 100%) so that
 * non-zero side margins don't push the card outside its parent — the
 * pattern that produced the right-edge-overflow regression in the first
 * mobile fix attempt. */
.home-body main.invite-landing,
.home-body main.auth-unavailable {
    flex: 0 0 auto;
    width: auto;
    max-width: 480px;
    margin: var(--space-7) auto var(--space-5);
    padding: var(--space-6);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    display: block;
    gap: 0;
}
.invite-landing h1,
.auth-unavailable h1 {
    margin: 0 0 var(--space-3);
    font: var(--weight-semibold) var(--text-lg)/1.25 var(--font-sans);
    color: var(--color-fg);
}
.invite-landing p,
.auth-unavailable p {
    margin: 0 0 var(--space-4);
    color: var(--color-fg-muted);
    line-height: var(--leading-body);
}
.invite-landing p:last-child,
.auth-unavailable p:last-child { margin-bottom: 0; }
.invite-landing #action-row,
.auth-unavailable .row {
    display: flex;
    gap: var(--space-3);
    align-items: center;
    flex-wrap: wrap;
}

/* ── Mobile ─────────────────────────────────────────────────────────── */

@media (max-width: 600px) {
    header {
        padding: var(--space-3) var(--space-4);
    }
    .topnav {
        margin-left: 0;
        width: 100%;
        order: 3;
    }
    main {
        padding: var(--space-4) var(--space-3);
    }
    .rec-row {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-2);
    }
    .btn-delete { margin-left: 0; align-self: stretch; }
    .settings-section { padding: var(--space-4); }
    .people-row {
        align-items: flex-start;
        flex-direction: column;
    }
    .people-row-actions { margin-left: 0; }
    /* Specificity must match the non-mobile rule (.home-body main.invite-landing)
     * or this override silently loses the cascade and the card stretches edge-to-edge. */
    .home-body main.invite-landing,
    .home-body main.auth-unavailable {
        margin: var(--space-4) var(--space-3);
        padding: var(--space-4);
    }
}
