/* Tenshen Shell — redesign tokens, layout, sidebar, workspace header,
   chat dock. Layered on top of beacon.css; scoped to .tn-shell so it
   never bleeds into legacy chrome. */

/* --------------------------------------------------------------------
   Fonts
   ------------------------------------------------------------------ */
/* Inter + Source Serif 4 loaded via Google Fonts in base.html head. */

/* --------------------------------------------------------------------
   Design tokens — light
   ------------------------------------------------------------------ */
html[data-theme="light"], :root {
    --t-surf:        #fbfaf7;
    --t-card:        #ffffff;
    --t-sidebar:     #f5f3ed;
    --t-rail-soft:   #fbfaf7;
    --t-ink:         #15181a;
    --t-mute:        rgba(21,24,26,0.58);
    --t-faint:       rgba(21,24,26,0.38);
    --t-rule:        rgba(21,24,26,0.12);
    --t-soft-bg:     rgba(21,24,26,0.05);
    --t-hover-bg:    #fbfaf7;
    --t-active-bg:   #ffffff;
    --t-input-bg:    #ffffff;
    --t-accent:      oklch(0.58 0.11 45);
    --t-accent-soft: rgba(181,107,63,0.12);
    --t-accent-whisper: rgba(181,107,63,0.045);
    --t-on-ink:      #ffffff;
    --t-avatar-bg:   #15181a;
    --t-avatar-fg:   #ffffff;
    --t-user-bubble: rgba(21,24,26,0.05);
    --t-badge-neutral-bg: rgba(21,24,26,0.08);
    --t-num-badge-bg:     rgba(21,24,26,0.7);
    --t-num-badge-border: #f5f3ed;
    /* Warm-paper dock tint — light only. */
    --t-dock-bg:     #f8f4ec;
    --t-dock-soft:   #f2ede2;
    /* Shadow for floating elements. */
    --t-shadow-sm:   0 1px 2px rgba(0,0,0,0.06);
}

/* --------------------------------------------------------------------
   Design tokens — dark
   ------------------------------------------------------------------ */
html[data-theme="dark"] {
    --t-surf:        #0e1013;
    --t-card:        #161a1e;
    --t-sidebar:     #0a0c0f;
    --t-rail-soft:   #1b1f24;
    --t-ink:         #edeae2;
    --t-mute:        rgba(237,234,226,0.62);
    --t-faint:       rgba(237,234,226,0.38);
    --t-rule:        rgba(237,234,226,0.12);
    --t-soft-bg:     rgba(237,234,226,0.06);
    --t-hover-bg:    rgba(237,234,226,0.04);
    --t-active-bg:   #1f242a;
    --t-input-bg:    #11151a;
    --t-accent:      oklch(0.66 0.12 45);
    --t-accent-soft: rgba(181,107,63,0.18);
    --t-accent-whisper: rgba(181,107,63,0.065);
    --t-on-ink:      #0e1013;
    --t-avatar-bg:   #edeae2;
    --t-avatar-fg:   #0e1013;
    --t-user-bubble: rgba(237,234,226,0.08);
    --t-badge-neutral-bg: rgba(237,234,226,0.1);
    --t-num-badge-bg:     rgba(237,234,226,0.7);
    --t-num-badge-border: #0a0c0f;
    --t-dock-bg:     #161a1e;
    --t-dock-soft:   #1b1f24;
    --t-shadow-sm:   0 1px 2px rgba(0,0,0,0.22);
}

/* --------------------------------------------------------------------
   Shell root — activated by body.tn-shell-active
   ------------------------------------------------------------------ */
body.tn-shell-active {
    background: var(--t-surf);
    color: var(--t-ink);
    font-family: "Inter", system-ui, -apple-system, sans-serif;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    overflow: hidden;
}

.tn-shell {
    display: flex;
    width: 100vw;
    height: 100vh;
    background: var(--t-surf);
    color: var(--t-ink);
    overflow: hidden;
    font-family: "Inter", system-ui, -apple-system, sans-serif;
    font-feature-settings: "cv11", "ss01";
}

/* --------------------------------------------------------------------
   Sidebar
   ------------------------------------------------------------------ */
.tn-sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--t-sidebar);
    border-right: 1px solid var(--t-rule);
    padding: 18px 14px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    transition: width 220ms ease;
}

.tn-sidebar.is-collapsed { width: 56px; padding: 18px 8px; }

/* Brand row — TMark + wordmark */
.tn-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px;
    margin-bottom: 16px;
    text-decoration: none;
    color: var(--t-ink);
}
.tn-sidebar.is-collapsed .tn-brand {
    padding: 4px 0;
    justify-content: center;
}
.tn-brand-mark {
    width: 18px; height: 18px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.tn-brand-mark svg { width: 100%; height: 100%; }
.tn-brand-word {
    font-size: 11px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    font-weight: 600;
    color: var(--t-ink);
    white-space: nowrap;
}
.tn-sidebar.is-collapsed .tn-brand-word { display: none; }

/* Workspace toggle (Work / Personal pill) — lives in the workspace header */
.tn-ws-toggle {
    display: inline-flex;
    align-self: flex-start;
    gap: 4px;
    padding: 3px;
    background: var(--t-soft-bg);
    border-radius: 4px;
}
.tn-ws-toggle button {
    appearance: none;
    border: 0;
    background: transparent;
    text-align: center;
    font-size: 11px;
    font-family: inherit;
    padding: 5px 12px;
    margin: 0;
    border-radius: 3px;
    color: var(--t-mute);
    font-weight: 500;
    cursor: pointer;
}
.tn-ws-toggle button.is-active {
    background: var(--t-active-bg);
    color: var(--t-ink);
    font-weight: 550;
    box-shadow: var(--t-shadow-sm);
}
.tn-ws-toggle button:hover:not(.is-active) { color: var(--t-ink); }

/* Nav groups */
.tn-nav-group { display: contents; }

.tn-nav-heading {
    font-size: 10px;
    color: var(--t-faint);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-weight: 600;
    padding: 18px 10px 8px;
}
.tn-sidebar.is-collapsed .tn-nav-heading { display: none; }

.tn-nav-rule {
    display: none;
    height: 1px;
    background: var(--t-rule);
    margin: 14px 8px 8px;
}
.tn-sidebar.is-collapsed .tn-nav-rule { display: block; }

/* Nav item row */
.tn-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border-radius: 4px;
    text-decoration: none;
    color: var(--t-ink);
    font-size: 13px;
    font-weight: 500;
    line-height: 1.25;
    position: relative;
    transition: background 120ms ease, color 120ms ease;
}
.tn-nav-item:hover {
    background: var(--t-hover-bg);
}
.tn-nav-item.is-muted { color: var(--t-mute); }
.tn-nav-item.is-muted:hover { color: var(--t-ink); }
.tn-nav-item.is-active {
    background: var(--t-active-bg);
    color: var(--t-ink);
    font-weight: 550;
    box-shadow: var(--t-shadow-sm);
}
.tn-nav-item .tn-nav-icon {
    width: 16px; height: 16px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: currentColor;
}
.tn-nav-item .tn-nav-icon svg {
    width: 100%; height: 100%;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.tn-nav-item .tn-nav-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tn-nav-item .tn-nav-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 100px;
    background: var(--t-num-badge-bg);
    color: var(--t-num-badge-border);
    line-height: 1.4;
    min-width: 18px;
    text-align: center;
}
.tn-nav-item .tn-nav-badge.is-accent {
    background: var(--t-accent);
    color: #ffffff;
}

.tn-sidebar.is-collapsed .tn-nav-item {
    justify-content: center;
    padding: 8px 0;
}
.tn-sidebar.is-collapsed .tn-nav-item .tn-nav-label,
.tn-sidebar.is-collapsed .tn-nav-item .tn-nav-badge { display: none; }
.tn-sidebar.is-collapsed .tn-nav-item .tn-nav-icon {
    width: 18px; height: 18px;
}

/* Spacer pushes footer/theme to the bottom */
.tn-sidebar-spacer { flex: 1; }

/* Theme toggle (above footer) */
.tn-theme-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    margin: 0 0 2px;
    border: 1px solid transparent;
    background: transparent;
    border-radius: 4px;
    color: var(--t-mute);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    text-align: left;
    width: 100%;
}
.tn-theme-toggle:hover { background: var(--t-hover-bg); color: var(--t-ink); }
.tn-theme-toggle-icon {
    width: 16px; height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.tn-theme-toggle-icon svg {
    width: 100%; height: 100%;
    fill: none; stroke: currentColor;
    stroke-width: 1.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.tn-theme-toggle-label { white-space: nowrap; }
.tn-sidebar.is-collapsed .tn-theme-toggle {
    justify-content: center;
    padding: 8px 0;
}
.tn-sidebar.is-collapsed .tn-theme-toggle-label { display: none; }

/* Sidebar footer — avatar + user identity */
.tn-sidebar-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-top: 1px solid var(--t-rule);
    margin-top: 2px;
    text-decoration: none;
    color: var(--t-ink);
}
.tn-sidebar-footer:hover { background: var(--t-hover-bg); }
.tn-avatar {
    width: 26px; height: 26px;
    border-radius: 100px;
    background: var(--t-avatar-bg);
    color: var(--t-avatar-fg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
    flex-shrink: 0;
    text-transform: uppercase;
}
.tn-sidebar-footer-body {
    flex: 1;
    min-width: 0;
    line-height: 1.25;
}
.tn-sidebar-footer-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--t-ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tn-sidebar-footer-role {
    font-size: 10px;
    color: var(--t-faint);
    white-space: nowrap;
}
.tn-sidebar.is-collapsed .tn-sidebar-footer {
    justify-content: center;
    padding: 8px 0;
}
.tn-sidebar.is-collapsed .tn-sidebar-footer-body { display: none; }

/* Sidebar collapse toggle button (bottom of sidebar) */
.tn-sidebar-collapse-btn {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--t-faint);
    cursor: pointer;
    padding: 8px;
    margin: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-family: inherit;
}
.tn-sidebar-collapse-btn:hover { color: var(--t-ink); }
.tn-sidebar-collapse-btn svg {
    width: 14px; height: 14px;
    transition: transform 220ms ease;
}
.tn-sidebar.is-collapsed .tn-sidebar-collapse-btn svg { transform: rotate(180deg); }

/* --------------------------------------------------------------------
   Main column (workspace + chat dock)
   ------------------------------------------------------------------ */
.tn-main {
    flex: 1;
    display: flex;
    min-width: 0;
    min-height: 0;
    height: 100vh;
}

.tn-workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

/* Workspace header (top strip) */
.tn-ws-header {
    padding: 12px 28px;
    border-bottom: 1px solid var(--t-rule);
    background: var(--t-card);
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 53px;
    flex-shrink: 0;
    gap: 12px;
}
.tn-ws-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}
.tn-ws-header-eyebrow {
    font-size: 10px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--t-mute);
    font-weight: 600;
    white-space: nowrap;
}
.tn-ws-header-title {
    font-size: 13px;
    font-weight: 550;
    color: var(--t-ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tn-ws-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}
.tn-header-btn {
    appearance: none;
    margin: 0;
    padding: 6px 12px;
    font-size: 12px;
    border: 1px solid var(--t-rule);
    background: var(--t-card);
    color: var(--t-mute);
    border-radius: 4px;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    line-height: 1.3;
}
.tn-header-btn:hover { color: var(--t-ink); border-color: var(--t-ink); }
.tn-header-btn.is-primary {
    background: var(--t-ink);
    color: var(--t-on-ink);
    border-color: var(--t-ink);
    font-weight: 500;
}
.tn-header-btn.is-primary:hover { opacity: 0.9; }

/* Workspace body — scroll container for page content */
.tn-ws-body {
    flex: 1;
    overflow: auto;
    min-height: 0;
    background: var(--t-surf);
}

/* Page container inside workspace body — fills most of the available
   workspace width. Dock (420px) + sidebar (220px) already constrain the
   outer container on typical viewports, so .tn-page bumps up to 1120px
   to avoid leaving dead zones on either side. Pages that want a
   narrower reading column can opt in via .tn-page--narrow. */
.tn-page {
    max-width: 1120px;
    margin: 0 auto;
    padding: 32px 40px;
    width: 100%;
    box-sizing: border-box;
}
.tn-page--wide { max-width: 1280px; }
.tn-page--narrow { max-width: 720px; }

/* --------------------------------------------------------------------
   Chat dock
   ------------------------------------------------------------------ */
.tn-dock {
    width: 420px;
    flex-shrink: 0;
    border-left: 1px solid var(--t-rule);
    background: var(--t-dock-bg);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

/* Drag handle on the dock's left edge. The dock's default width (420px)
   is the minimum; dragging leftward widens it. Persisted to
   localStorage under tn_dock_width. Hidden at ≤1024px because the
   whole dock hides there. */
.tn-dock-resizer {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 6px;
    cursor: col-resize;
    z-index: 10;
    background: transparent;
    transition: background 120ms ease;
}
.tn-dock-resizer:hover,
.tn-dock-resizer.is-dragging { background: var(--t-accent-soft); }
body.tn-dock-dragging {
    cursor: col-resize;
    user-select: none;
}
body.tn-dock-dragging iframe { pointer-events: none; }
.tn-dock-header {
    padding: 12px 18px;
    border-bottom: 1px solid var(--t-rule);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--t-dock-bg);
    height: 53px;
    flex-shrink: 0;
}
.tn-dock-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}
.tn-dock-brand-chip {
    width: 22px; height: 22px;
    border-radius: 2px;
    background: var(--t-ink);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.tn-dock-brand-chip svg { width: 12px; height: 12px; stroke: var(--t-on-ink); }
.tn-dock-brand-name {
    font-size: 13px;
    font-weight: 550;
    letter-spacing: -0.005em;
    color: var(--t-ink);
}

/* Dock tabs — Chat / Decide / All */
.tn-dock-tabs {
    display: flex;
    border-bottom: 1px solid var(--t-rule);
    background: var(--t-dock-bg);
    flex-shrink: 0;
}
.tn-dock-tab {
    flex: 1;
    appearance: none;
    border: 0;
    background: transparent;
    margin: 0;
    padding: 6px 16px 8px;
    text-align: center;
    font-size: 12px;
    font-weight: 500;
    color: var(--t-mute);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    display: inline-flex;
    gap: 6px;
    align-items: center;
    justify-content: center;
    user-select: none;
    font-family: inherit;
    line-height: 1.3;
}
.tn-dock-tab.is-active {
    color: var(--t-ink);
    border-bottom-color: var(--t-ink);
    font-weight: 600;
}
.tn-dock-tab .tn-tab-badge {
    font-size: 10px;
    padding: 1px 6px;
    background: var(--t-badge-neutral-bg);
    color: var(--t-mute);
    border-radius: 100px;
    font-weight: 600;
    line-height: 1.4;
}
.tn-dock-tab .tn-tab-badge.is-accent {
    background: var(--t-accent);
    color: #ffffff;
}

/* Dock panes (shared layout) */
.tn-dock-pane {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    display: none;
    flex-direction: column;
    min-height: 0;
}
.tn-dock-pane.is-active { display: flex; }

/* Decide / All — empty / placeholder styling */
.tn-dock-placeholder {
    padding: 24px 20px;
    color: var(--t-mute);
    font-size: 13px;
    line-height: 1.55;
}
.tn-dock-placeholder-title {
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--t-faint);
    font-weight: 600;
    margin-bottom: 10px;
}

/* Decide pane — wraps the real decision cards (styled in
   tenshen-briefing.css). Only the list wrapper lives here; the card
   surface, choices, and hover treatments are in .tn-decision*. */
.tn-decide-list {
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* Dock composer (footer) */
.tn-dock-footer {
    padding: 10px 14px 14px;
    border-top: 1px solid var(--t-rule);
    background: var(--t-dock-soft);
    flex-shrink: 0;
}
.tn-dock-composer {
    padding: 10px 12px;
    background: var(--t-dock-bg);
    border: 1px solid var(--t-rule);
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
}
.tn-dock-composer-slash {
    color: var(--t-accent);
    font-weight: 700;
    font-size: 13px;
}
.tn-dock-composer-placeholder {
    flex: 1;
    color: var(--t-faint);
}
.tn-dock-composer-kbd {
    font-size: 10px;
    padding: 2px 6px;
    border: 1px solid var(--t-rule);
    color: var(--t-mute);
    background: var(--t-rail-soft);
    border-radius: 2px;
    font-family: "JetBrains Mono", "SF Mono", monospace;
    white-space: nowrap;
}

/* --------------------------------------------------------------------
   Chat pane (wraps the existing beaconAssistant chat DOM)
   ------------------------------------------------------------------ */
/* The dock's chat pane becomes the host for the existing chat UI. The
   legacy .beacon-split / .beacon-split-chat / .beacon-assistant-mobile
   containers are overridden to display: contents so their children
   inherit the dock layout. */
.tn-dock .beacon-split,
.tn-dock .beacon-split-content,
.tn-dock .beacon-main { display: contents; }

.tn-dock .beacon-split-chat {
    background: transparent;
    border: 0;
    width: 100%;
    min-width: 0;
    min-height: 0;
    padding: 0;
    position: static;
    display: flex;
    flex: 1;
    flex-direction: column;
    height: auto;
    max-height: none;
    overflow: visible;
}

.tn-dock .ba-panel-header { display: none; }
.tn-dock .ba-messages {
    padding: 14px 18px;
    flex: 1;
    overflow-y: auto;
}
.tn-dock .ba-empty-state {
    padding: 24px 20px;
    color: var(--t-mute);
}
.tn-dock .beacon-assistant-bar {
    position: static;
    border: 0;
    background: transparent;
    padding: 0;
    margin: 0;
}
.tn-dock .ba-bar-inner {
    padding: 10px 14px 8px;
    border-top: 1px solid var(--t-rule);
    background: var(--t-dock-soft);
    display: flex;
    max-width: none;
    margin: 0;
    gap: 0;
}
/* Unified composer pill — input + send as one visual unit. */
.tn-dock .tn-composer {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--t-dock-bg);
    border: 1px solid var(--t-rule);
    border-radius: 12px;
    padding: 4px 4px 4px 12px;
    transition: border-color 140ms ease, box-shadow 140ms ease;
}
.tn-dock .tn-composer:focus-within {
    border-color: var(--t-accent);
    box-shadow: 0 0 0 3px var(--t-accent-soft);
}
/* Input: transparent; the pill owns the chrome. */
.tn-dock .ba-input {
    background: transparent !important;
    border: 0 !important;
    border-radius: 0 !important;
    padding: 4px 4px !important;
    box-shadow: none !important;
    min-height: 0 !important;
    max-height: 160px !important;
}
.tn-dock .ba-input:focus {
    border: 0 !important;
    box-shadow: none !important;
}
/* Send: compact icon button flush inside the pill. */
.tn-dock .ba-send-btn {
    padding: 0 !important;
    width: 34px !important;
    height: 34px !important;
    border-radius: 9px !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin: 0 !important;
    font-size: 0.72rem !important;
    line-height: 1;
}
.tn-dock .ba-send-btn svg { width: 15px; height: 15px; }
.tn-dock .ba-send-btn:hover:not(:disabled) {
    transform: none;
    box-shadow: none;
    filter: brightness(1.08);
}
.tn-dock .ba-send-btn:active:not(:disabled) {
    transform: none;
}
/* Below-input chips flow into the composer background — no seam. */
.tn-dock .ba-below-input {
    padding: 4px 14px 12px;
    background: var(--t-dock-soft);
    border-top: 0 !important;
}
/* Hide mobile-only beacon chat wrapper inside the dock */
.tn-dock .beacon-assistant-mobile { display: none; }

/* --------------------------------------------------------------------
   Hide legacy chrome when shell is active
   ------------------------------------------------------------------ */
body.tn-shell-active .primary-nav,
body.tn-shell-active .workspace-bar,
body.tn-shell-active #pwa-install-banner.legacy-banner { display: none !important; }

/* Disable legacy split-chat aside when dock owns the chat. */
body.tn-shell-active > .beacon-main { display: none !important; }

/* --------------------------------------------------------------------
   Mobile top bar (shown only at ≤480px)
   ------------------------------------------------------------------ */
.tn-mobile-topbar {
    display: none;
    padding: 8px 12px;
    min-height: 56px;
    border-bottom: 1px solid var(--t-rule);
    background: var(--t-card);
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}
.tn-mobile-topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 40px;
}
.tn-mobile-topbar-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--t-ink);
    line-height: 40px;
}

/* Mobile workspace segmented toggle — sits in the topbar-left slot,
   mirrors the sidebar pill visually but sized for a 40px topbar button
   row. Defined outside the media query because the selector is already
   mobile-only (the topbar itself is hidden on desktop). */
.tn-mobile-ws {
    display: inline-flex;
    padding: 2px;
    background: var(--t-soft-bg);
    border-radius: 6px;
    gap: 2px;
    height: 32px;
}
.tn-mobile-ws-opt {
    appearance: none;
    border: 0;
    background: transparent;
    padding: 0 10px;
    border-radius: 4px;
    color: var(--t-mute);
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.01em;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 120ms ease, color 120ms ease;
}
.tn-mobile-ws-opt.is-active {
    background: var(--t-active-bg);
    color: var(--t-ink);
    font-weight: 600;
    box-shadow: var(--t-shadow-sm);
}
.tn-mobile-ws-opt:hover:not(.is-active) { color: var(--t-ink); }

/* Mobile bottom tabs — 5 destinations */
.tn-mobile-tabbar {
    display: none;
    border-top: 1px solid var(--t-rule);
    background: var(--t-card);
    padding: 6px 4px 10px;
    flex-shrink: 0;
    gap: 0;
}
.tn-mobile-tab {
    flex: 1;
    appearance: none;
    border: 0;
    background: transparent;
    padding: 8px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    color: var(--t-mute);
    cursor: pointer;
    position: relative;
    text-decoration: none;
    font-family: inherit;
}
.tn-mobile-tab.is-active { color: var(--t-ink); }
.tn-mobile-tab-icon { width: 16px; height: 16px; }
.tn-mobile-tab-icon svg {
    width: 100%; height: 100%;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.tn-mobile-tab-label {
    font-size: 10px;
    font-weight: 500;
}
.tn-mobile-tab.is-active .tn-mobile-tab-label { font-weight: 600; }
.tn-mobile-tab-dot {
    position: absolute;
    top: 4px;
    right: 28%;
    width: 6px; height: 6px;
    border-radius: 100px;
    background: var(--t-accent);
}

/* --------------------------------------------------------------------
   Card / article helpers for page bodies
   ------------------------------------------------------------------ */
.tn-card {
    background: var(--t-card);
    border: 1px solid var(--t-rule);
    border-radius: 4px;
    margin-bottom: 18px;
}
.tn-card-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--t-rule);
    background: var(--t-rail-soft);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--t-mute);
    font-weight: 600;
}
.tn-card-body { padding: 20px 24px; }

.tn-section-label {
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--t-mute);
    font-weight: 600;
}
.tn-section-label.is-faint { color: var(--t-faint); }

/* Today task row — used on dashboard */
.tn-today-list {
    background: var(--t-card);
    border: 1px solid var(--t-rule);
    border-radius: 4px;
    overflow: hidden;
}
.tn-today-row {
    display: grid;
    grid-template-columns: 18px auto 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid var(--t-rule);
}
.tn-today-row:last-child { border-bottom: 0; }
.tn-today-row:hover { background: var(--t-hover-bg); }
.tn-today-row .tn-today-check {
    width: 14px; height: 14px;
    accent-color: var(--t-accent);
    margin: 0;
}
.tn-today-row .tn-today-pri {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 2px;
    font-weight: 700;
    letter-spacing: 0.04em;
    background: var(--t-soft-bg);
    color: var(--t-mute);
}
.tn-today-row .tn-today-pri.is-p1 { background: var(--t-accent); color: #ffffff; }
.tn-today-row .tn-today-pri.is-p2 { background: var(--t-accent-soft); color: var(--t-ink); }
.tn-today-row .tn-today-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--t-ink);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.tn-today-row .tn-today-title:hover { text-decoration: underline; }
.tn-today-row.is-done .tn-today-title {
    text-decoration: line-through;
    color: var(--t-faint);
}
.tn-today-row .tn-today-meta {
    font-size: 11px;
    color: var(--t-faint);
    white-space: nowrap;
}
.tn-today-row .tn-today-meta.is-overdue { color: var(--t-accent); }

/* --------------------------------------------------------------------
   Responsive
   ------------------------------------------------------------------ */
@media (max-width: 1180px) {
    .tn-dock { width: 360px; }
}

@media (max-width: 1024px) {
    /* Tablet — sidebar collapses to icon rail, dock hidden. */
    .tn-sidebar { width: 56px; padding: 18px 8px; }
    .tn-sidebar .tn-brand-word,
    .tn-sidebar .tn-nav-label,
    .tn-sidebar .tn-nav-badge,
    .tn-sidebar .tn-nav-heading,
    .tn-sidebar .tn-sidebar-footer-body,
    .tn-sidebar .tn-theme-toggle-label { display: none; }
    .tn-sidebar .tn-brand { justify-content: center; padding: 4px 0; }
    .tn-sidebar .tn-nav-item { justify-content: center; padding: 8px 0; }
    .tn-sidebar .tn-nav-rule { display: block; }
    .tn-sidebar .tn-theme-toggle { justify-content: center; padding: 8px 0; }
    .tn-sidebar .tn-sidebar-footer { justify-content: center; padding: 8px 0; }
    .tn-dock { display: none; }
    .tn-ws-header { padding: 12px 18px; }
    .tn-page { padding: 24px 28px; }
}

/* Close button lives in the dock header. Hidden by default and flipped
   to a visible icon-button inside the ≤640px media query below. Must be
   declared BEFORE that query — equal-specificity rules lose to later
   source order, so placing this after would nullify the mobile flip. */
.tn-dock-close { display: none; }

@media (max-width: 640px) {
    /* Mobile — bottom tabs + slide-in sidebar drawer + slide-in chat overlay. */
    .tn-shell {
        flex-direction: column;
        height: 100vh;
        /* Needed as containing block for the absolutely/fixed overlays so
           the scrim and drawers are measured against the shell, not the
           viewport — keeps everything layered correctly even when the
           mobile topbar is present. */
        position: relative;
    }
    .tn-mobile-topbar { display: flex; }
    .tn-mobile-tabbar { display: flex; }
    .tn-main { height: auto; flex: 1; min-height: 0; }
    .tn-ws-header { display: none; }
    /* overscroll-behavior: none disables iOS's native rubber-band bounce
       entirely on this scroller. `contain` only stops scroll chaining; the
       bounce still animates and visually "eats" the pull gesture before
       our touchmove preventDefault can claim it. `none` is the value that
       actually frees the gesture for our PTR handler. */
    .tn-ws-body { padding: 0; overscroll-behavior: none; }
    .tn-page { padding: 18px 18px 24px; }

    /* Sidebar becomes a left-edge drawer. Off-screen by default, slides in
       when .tn-shell gets .is-mobile-sidebar-open. */
    .tn-sidebar {
        display: flex;
        position: fixed;
        top: 0; left: 0;
        width: 84vw; max-width: 320px;
        height: 100vh;
        z-index: 70;
        transform: translateX(-100%);
        transition: transform 220ms ease;
        box-shadow: 0 0 32px rgba(0, 0, 0, 0.28);
        /* Force expanded layout — the ≤1024px rule earlier forced the
           collapsed rail, which we don't want inside the drawer. */
        padding: 22px 18px;
    }
    .tn-sidebar .tn-brand-word,
    .tn-sidebar .tn-nav-label,
    .tn-sidebar .tn-nav-badge,
    .tn-sidebar .tn-nav-heading,
    .tn-sidebar .tn-sidebar-footer-body,
    .tn-sidebar .tn-theme-toggle-label { display: revert; }
    .tn-sidebar .tn-brand { justify-content: flex-start; }
    .tn-sidebar .tn-nav-item { justify-content: flex-start; padding: 10px 12px; }
    .tn-sidebar .tn-nav-rule { display: none; }
    .tn-sidebar .tn-theme-toggle { justify-content: flex-start; padding: 10px 12px; }
    .tn-sidebar .tn-sidebar-footer { justify-content: flex-start; padding: 10px 12px; }
    /* Collapse button has no meaning inside a drawer. */
    .tn-sidebar-collapse-btn { display: none; }

    .tn-shell.is-mobile-sidebar-open .tn-sidebar { transform: translateX(0); }

    /* Chat dock becomes a right-edge full-screen overlay. */
    .tn-dock {
        display: flex;
        position: fixed;
        top: 0; left: 0;
        width: 100vw;
        height: 100vh;
        max-width: none;
        border-left: 0;
        z-index: 70;
        transform: translateX(100%);
        transition: transform 220ms ease;
        box-shadow: 0 0 32px rgba(0, 0, 0, 0.28);
    }
    .tn-dock-resizer { display: none; }
    .tn-shell.is-mobile-chat-open .tn-dock { transform: translateX(0); }
    /* Drop the dock's desktop drop-shadow on mobile — the shadow ends
       up trailing across the workspace during the 220ms slide-out and
       reads as the content "darkening" while the dock closes. */
    .tn-dock { box-shadow: none; }
    /* Lift the dock header below the iOS status bar when installed as
       a PWA. `black-translucent` lets content render under the status
       bar, which would otherwise cover the close button. */
    .tn-dock-header { padding-top: calc(12px + env(safe-area-inset-top, 0px)); }
    /* The header's "New" button is redundant on mobile — the chat
       pane footer already surfaces History / New / Settings within
       thumb reach. Hide the desktop one so the close button has room
       to breathe. */
    .tn-dock-header .tn-header-btn { display: none; }
    .tn-dock-close {
        display: inline-flex;
        width: 40px;
        height: 40px;
        padding: 0;
        /* Zero Pico's 1rem margin-bottom, otherwise the flex-parent
           stretches and align-items:center pushes the icon above the
           header's top edge. */
        margin: 0;
        border: 0;
        background: transparent;
        color: var(--t-ink);
        border-radius: 6px;
        align-items: center;
        justify-content: center;
    }
    .tn-dock-close:active { background: var(--t-hover-bg); }
    .tn-dock-close svg { width: 20px; height: 20px; stroke-width: 1.8; }

    /* Shared scrim behind whichever surface is open. Sits below the
       drawers (z-index 70) but above the rest of the shell. */
    .tn-mobile-scrim {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.45);
        z-index: 65;
    }

    /* Lock the page behind the overlay so vertical scrolling targets
       the drawer, not the page underneath. */
    body.tn-mobile-overlay-open {
        overflow: hidden;
    }

    /* Pull-to-refresh indicator pinned below the topbar. Hidden until
       the JS flips ptrState off 'idle'; x-show removes the inline
       display: none so the display: flex here takes over. */
    .tn-ptr {
        position: absolute;
        top: 56px;             /* aligns with .tn-mobile-topbar min-height */
        left: 0;
        right: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        padding: 8px 0;
        pointer-events: none;
        z-index: 60;
        color: var(--t-mute);
        font-size: 10px;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        font-weight: 600;
        transform: translateY(0);
        will-change: transform, opacity;
    }
    .tn-ptr.is-ready { color: var(--t-accent); }
    .tn-ptr.is-refreshing { color: var(--t-accent); }
    .tn-ptr.is-refreshing .tn-ptr-spinner {
        animation: tn-ptr-spin 0.7s linear infinite;
        border-top-color: var(--t-accent);
    }
}

/* --------------------------------------------------------------------
   Mobile shell controls — topbar icon buttons, scrim, unread badge,
   chat overlay close button. Defined outside the media query so the
   badge animation works for the desktop dock too if we ever re-use it.
   ------------------------------------------------------------------ */
.tn-mobile-topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}
.tn-mobile-icon-btn {
    position: relative;
    appearance: none;
    border: 1px solid var(--t-rule);
    background: var(--t-card);
    color: var(--t-ink);
    border-radius: 6px;
    padding: 0;
    width: 40px;
    height: 40px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.tn-mobile-icon-btn:hover { background: var(--t-hover-bg); }
.tn-mobile-icon-btn:active { background: var(--t-rail-soft); }
/* Spin the icon while a refresh reload is in flight. Brief flash only —
   the page is already reloading, so this mostly acknowledges the tap. */
.tn-mobile-icon-btn.is-spinning svg { animation: tn-ptr-spin 0.7s linear infinite; }

/* Primary chat CTA — text + icon, styled as the accent action in the topbar.
   Intentionally larger than the sibling icon buttons so it reads as the
   primary surface-to-assistant entry point on mobile. */
.tn-mobile-chat-btn {
    position: relative;
    appearance: none;
    border: 1px solid var(--t-accent);
    background: var(--t-accent);
    color: #ffffff;
    border-radius: 6px;
    padding: 0 14px;
    height: 40px;
    min-width: 40px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.01em;
    transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}
.tn-mobile-chat-btn:hover { filter: brightness(1.05); }
.tn-mobile-chat-btn:active { transform: translateY(1px); }
.tn-mobile-chat-btn-label { line-height: 1; }

.tn-mobile-chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 17px;
    height: 17px;
    padding: 0 5px;
    border-radius: 100px;
    background: #ffffff;
    color: var(--t-accent);
    font-size: 10px;
    font-weight: 700;
    line-height: 17px;
    text-align: center;
    box-shadow: 0 0 0 2px var(--t-card);
    pointer-events: none;
}

/* Pull-to-refresh indicator — hidden on desktop. Scoped to a min-width
   query so it doesn't override the mobile @media's `display: flex` via
   source-order cascade (both have the same specificity, and the bare
   rule appeared later, which kept the indicator hidden on mobile too). */
@media (min-width: 641px) {
    .tn-ptr { display: none; }
}
.tn-ptr-spinner {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid var(--t-rule);
    border-top-color: currentColor;
    display: block;
    transform-origin: 50% 50%;
}
@keyframes tn-ptr-spin {
    to { transform: rotate(360deg); }
}

/* Scrim default (no-op outside mobile). Keeping the declaration here so
   Alpine's x-show toggles don't surprise us if CSS ever differs. */
.tn-mobile-scrim { display: block; }

/* --------------------------------------------------------------------
   Utilities
   ------------------------------------------------------------------ */
.tn-hidden { display: none !important; }
.tn-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;
}

/* Accent highlight — matches <span style="background: accentSoft"> in JSX. */
.tn-hl {
    background: var(--t-accent-soft);
    padding: 1px 3px;
    border-radius: 1px;
}

/* ============================================================
   Calendar ribbon (continuous scroll, sticky left rail)
   ============================================================ */
.calendar-ribbon {
  max-width: 960px;
  margin: 0 auto;
  padding: 44px 48px 120px;
}

.ribbon-mast {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 32px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--t-rule);
  margin-bottom: 28px;
}
.ribbon-title {
  font-family: "Source Serif 4", serif;
  font-weight: 500;
  font-size: 40px;
  line-height: 1.05;
  letter-spacing: -0.012em;
  margin: 4px 0 0;
}
.ribbon-title em { font-style: italic; color: var(--t-accent-ink, oklch(0.42 0.09 45)); }

.ribbon-nav { display: flex; gap: 6px; }

.ribbon {
  display: grid;
  grid-template-columns: 116px 1fr;
}

.ribbon-rail {
  position: sticky;
  top: 30px;
  height: fit-content;
  padding-right: 24px;
  border-right: 1px solid var(--t-rule);
}
.ribbon-rail .rail-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--t-faint);
  margin-bottom: 14px;
}
.rail-link {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 7px 0;
  border-top: 1px solid rgba(21,24,26,0.06);
  text-decoration: none;
  color: inherit;
}
.rail-link:first-of-type { border-top: 0; }
.rail-link:hover { color: var(--t-accent-ink, oklch(0.42 0.09 45)); }
.rail-link.is-today .rail-dow { color: var(--t-accent-ink, oklch(0.42 0.09 45)); font-weight: 600; }
.rail-link.is-empty .rail-dow { font-style: italic; color: var(--t-faint); }
.rail-dow { font-family: "Source Serif 4", serif; font-weight: 500; font-size: 13.5px; }
.rail-dom { font-variant-numeric: tabular-nums; font-size: 11px; color: var(--t-faint); }
.rail-meta { margin-top: 24px; padding-top: 16px; border-top: 1px solid rgba(21,24,26,0.06); font-size: 11.5px; color: var(--t-mute); }
.rail-meta-muted { color: var(--t-faint); font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; }

.flow { padding-left: 40px; min-width: 0; }

.sep { padding: 28px 0 14px; }
.sep:first-child { padding-top: 8px; }
.sep-line { display: flex; align-items: baseline; gap: 14px; margin-bottom: 4px; }
.sep-dow { font-family: "Source Serif 4", serif; font-weight: 500; font-size: 26px; letter-spacing: -0.005em; }
.sep-date { font-family: "Source Serif 4", serif; font-style: italic; font-size: 14px; color: var(--t-mute); }
.sep-count { margin-left: auto; font-size: 10px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--t-faint); }
.sep.is-today .sep-dow { color: var(--t-accent-ink, oklch(0.42 0.09 45)); }
.sep-rule { height: 1px; background: var(--t-ink); margin-top: 6px; }
.sep.is-empty .sep-dow { color: var(--t-faint); font-style: italic; }
.sep-empty-note { font-family: "Source Serif 4", serif; font-style: italic; font-size: 13.5px; color: var(--t-faint); margin-top: 6px; }

.item {
  display: block;
  position: relative;
  padding: 16px 0 16px 92px;
  border-bottom: 1px solid rgba(21,24,26,0.06);
  text-decoration: none;
  color: inherit;
}
.item:hover { background: rgba(181,107,63,0.035); }
.item-time { position: absolute; left: 0; top: 18px; font-variant-numeric: tabular-nums; font-size: 11.5px; font-weight: 500; color: var(--t-ink); }
.item-dur { display: block; font-weight: 400; color: var(--t-faint); margin-top: 2px; font-size: 10.5px; }
.item-title { font-size: 16px; font-weight: 500; letter-spacing: -0.008em; margin: 0 0 4px; }
.item-meta { font-size: 12.5px; color: var(--t-mute); display: flex; flex-wrap: wrap; gap: 6px 14px; }
.item-meta .bullet { color: var(--t-faint); }
.item-link { color: var(--t-accent-ink, oklch(0.42 0.09 45)); font-weight: 500; }
.item-link::before { content: "↳ "; color: var(--t-faint); }

.ribbon-end { margin-top: 48px; padding-top: 22px; border-top: 1px solid var(--t-rule); text-align: center; font-family: "Source Serif 4", serif; font-style: italic; font-size: 13px; color: var(--t-faint); }

@media (max-width: 768px) {
  .calendar-ribbon { padding: 24px 16px 80px; }
  .ribbon { grid-template-columns: 1fr; }
  .ribbon-rail { display: none; }
  .flow { padding-left: 0; }
  .item { padding-left: 80px; }
}

/* ============================================================
   Integrations panel
   ============================================================ */
.integrations-panel { padding: 28px 32px; margin-top: 32px; }
.integrations-title { font-family: "Source Serif 4", serif; font-weight: 500; font-size: 24px; margin: 4px 0 20px; }
.integration-card { border: 1px solid var(--t-rule); border-radius: 4px; padding: 18px 20px; margin-bottom: 14px; }
.integration-card.is-coming-soon { opacity: 0.65; }
.integration-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.integration-eyebrow { font-size: 10px; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase; color: var(--t-faint); }
.integration-name { font-family: "Source Serif 4", serif; font-weight: 500; font-size: 18px; margin: 0; }
.integration-name em { font-style: italic; }
.integration-body { font-size: 13.5px; color: var(--t-mute); margin: 4px 0 14px; }
.integration-actions { display: flex; justify-content: flex-end; }
.integration-disconnect { font-size: 12px; color: var(--t-faint); text-decoration: none; }
.integration-disconnect:hover { color: var(--t-ink); }
.integrations-footnote { margin-top: 6px; font-family: "Source Serif 4", serif; font-style: italic; font-size: 12.5px; color: var(--t-mute); }

/* ============================================================
   Meeting detail
   ============================================================ */
.meeting-detail { max-width: 820px; margin: 0 auto; padding: 44px 48px 120px; }
.md-mast { padding-bottom: 18px; border-bottom: 1px solid var(--t-rule); margin-bottom: 24px; }
.md-title { font-family: "Source Serif 4", serif; font-weight: 500; font-size: 36px; margin: 6px 0 8px; letter-spacing: -0.01em; }
.md-meta { font-size: 13px; color: var(--t-mute); display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.md-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 24px; }
.md-section { margin-bottom: 26px; }
.md-section .t-eyebrow { margin-bottom: 8px; display: block; }
.md-attendees { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.md-empty { font-family: "Source Serif 4", serif; font-style: italic; color: var(--t-faint); }
.md-preread-body { font-family: "Source Serif 4", serif; font-size: 15.5px; line-height: 1.65; color: var(--t-ink); }
.md-preread-body h2 { font-size: 18px; font-weight: 600; margin-top: 18px; }

/* ============================================================
   Person page recent meetings
   ============================================================ */
.person-meetings { padding: 20px 24px; margin: 24px 0; }
.person-meeting-list { list-style: none; padding: 0; margin: 10px 0 0; }
.person-meeting-item { display: grid; grid-template-columns: 140px 1fr auto; gap: 14px; padding: 8px 0; align-items: baseline; text-decoration: none; color: inherit; border-top: 1px solid rgba(21,24,26,0.06); }
.person-meeting-list li:first-child .person-meeting-item { border-top: 0; }
.pm-time { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--t-mute); }
.pm-title { font-size: 14px; font-weight: 500; }
.pm-link { font-size: 11.5px; color: var(--t-accent-ink, oklch(0.42 0.09 45)); }
.person-meeting-more { display: inline-block; margin-top: 12px; font-family: "Source Serif 4", serif; font-style: italic; color: var(--t-accent-ink, oklch(0.42 0.09 45)); font-size: 13px; }

