/* Stopover dashboard. Desktop: sidebar, then a fixed-width list beside the detail. Up to 900px: a top bar with
   status chips, and one pane at a time — the list, or a selected item's detail with a Back button. */

:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-2: #f1f4ef;
  --sidebar: #eef2eb;
  --ink: #1f332a;
  --muted: #5c6c63;
  --faint: #7d8b83;
  --line: #e0e6df;
  --line-strong: #cfd9cf;
  --green: #255b46;
  --green-hover: #1b4636;
  --green-ink: #ffffff;
  --pale: #e6efe2;
  --selected: #eef5ea;
  --accent: #b6cba7;
  --amber: #8a5d16;
  --amber-bg: #f8ecd6;
  --red: #a1443c;
  --shadow: 0 1px 2px #1b2e2410, 0 8px 24px #1b2e240d;
  --radius: 12px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  color: var(--ink);
  font-synthesis: none;
  -webkit-text-size-adjust: 100%;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0f1513;
    --surface: #151d19;
    --surface-2: #1b2520;
    --sidebar: #121a16;
    --ink: #e4ece7;
    --muted: #a3b2aa;
    --faint: #82918a;
    --line: #26322c;
    --line-strong: #33433b;
    --green: #6ee7b7;
    --green-hover: #a7f3d0;
    --green-ink: #0b1310;
    --pale: #1d2d25;
    --selected: #1b2a23;
    --accent: #3f6b57;
    --amber: #f0c27e;
    --amber-bg: #3a2c15;
    --red: #f19a91;
    --shadow: 0 1px 2px #0006, 0 8px 24px #0004;
  }
}

* { box-sizing: border-box; }
html { scroll-padding-top: 72px; }
body { margin: 0; background: var(--bg); line-height: 1.55; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .6; cursor: wait; }
a { color: var(--green); }
[hidden] { display: none !important; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 26px; line-height: 1.2; letter-spacing: -.02em; margin-bottom: 4px; font-weight: 700; }
h2 { font-size: 22px; line-height: 1.3; letter-spacing: -.015em; font-weight: 700; }
h3 { font-size: 13px; font-weight: 650; letter-spacing: .02em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
p { line-height: 1.6; }
code, pre, .mono, .mono-title { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; line-height: 1.6; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; margin: 0 0 18px; }
code { font-size: 13px; overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.small { font-size: 13px; line-height: 1.55; }
.error { color: var(--red); font-size: 14px; line-height: 1.5; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

/* Buttons */
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 9px 16px; border-radius: 10px; font-size: 14px; font-weight: 600; border: 1px solid transparent; white-space: nowrap; text-decoration: none; transition: background .15s, border-color .15s; }
.primary { background: var(--green); color: var(--green-ink); }
.primary:hover { background: var(--green-hover); }
.secondary { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.secondary:hover { background: var(--surface-2); }
.icon-text span[aria-hidden] { font-size: 16px; line-height: 1; }
.icon-button { border: 0; background: none; color: var(--muted); font-size: 26px; line-height: 1; padding: 4px 10px; border-radius: 8px; }
.icon-button:hover { background: var(--surface-2); }
.subtle-button { display: block; width: 100%; border: 0; background: none; padding: 9px 10px; border-radius: 8px; font-size: 14px; text-align: left; color: var(--muted); }
.subtle-button:hover { background: var(--pale); color: var(--ink); }
.danger { background: var(--surface); border-color: color-mix(in srgb, var(--red) 45%, var(--line-strong)); color: var(--red); }
.danger:hover { background: color-mix(in srgb, var(--red) 10%, var(--surface)); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.copy-small { border: 1px solid var(--line-strong); background: var(--surface); border-radius: 6px; font-size: 12px; padding: 3px 8px; color: var(--muted); }
.copy-small:hover { color: var(--ink); }

/* Layout */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100dvh; }
.sidebar { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 22px; padding: 22px 16px; background: var(--sidebar); border-right: 1px solid var(--line); overflow-y: auto; }
.sidebar-top { display: flex; flex-direction: column; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; font-size: 21px; font-weight: 700; letter-spacing: -.02em; color: var(--ink); text-decoration: none; }
.brand-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: #255b46; color: #fff; font-size: 24px; line-height: 1; }
.connect-button { width: 100%; }
.account-button { display: none; }
.workspace { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.workspace-avatar { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: var(--pale); border: 1px solid var(--line); font-size: 13px; font-weight: 650; }
.workspace strong { display: block; font-size: 14px; }
.workspace div > span { display: block; font-size: 12px; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 12px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--faint); margin: 12px 10px 6px; }
.nav-label:first-child { margin-top: 0; }
.nav-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-height: 40px; padding: 8px 10px; border: 0; border-radius: 8px; background: none; font-size: 14px; text-align: left; color: var(--muted); }
.nav-item > span:first-child { display: flex; align-items: center; gap: 9px; }
.nav-item:hover { background: var(--pale); color: var(--ink); }
.nav-item.active { background: var(--pale); color: var(--ink); font-weight: 650; }
.count { min-width: 24px; padding: 1px 7px; border-radius: 999px; background: var(--surface); font-size: 12px; font-variant-numeric: tabular-nums; text-align: center; color: var(--muted); }
.dot { flex: none; display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.dot.available { background: #3f8a5a; }
.dot.claimed { background: #c98a2e; }
.dot.completed { background: #8c9a92; }
.dot.needs_you { background: #c2553f; }
.sidebar-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 4px; }
.host-links { display: flex; flex-direction: column; gap: 2px; }
.host-links a { display: block; padding: 9px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; font-size: 14px; }
.host-links a:hover, .host-links a:focus-visible { background: var(--pale); }
.usage { margin: 0 0 10px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-size: 13px; }
.usage-title { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 0 0 8px; font-weight: 650; }
.usage-title a { font-size: 12px; font-weight: 600; color: var(--green); }
.usage-item + .usage-item { margin-top: 8px; }
.usage-head { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); }
.usage-head strong { color: var(--ink); font-weight: 600; }
.usage-bar { height: 5px; margin-top: 4px; border-radius: 999px; background: var(--line); overflow: hidden; }
.usage-fill { height: 100%; border-radius: 999px; background: var(--green); }
.usage-fill.low { background: var(--amber); }
.usage-fill.out { background: var(--red); }
.usage-head.out strong { color: var(--red); }
.local-status { display: flex; align-items: center; gap: 8px; margin: 8px 10px 0; font-size: 12px; color: var(--faint); }

.main { min-width: 0; padding: 26px 32px 32px; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.summary { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0; font-size: 14px; color: var(--muted); }
.summary strong { color: var(--ink); }
.filters { display: flex; gap: 10px; margin-bottom: 16px; }
.search-field { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding-left: 12px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; color: var(--faint); }
.search-field:focus-within { border-color: var(--green); }
.search-field > span { font-size: 20px; line-height: 1; }
.search-field input { width: 100%; min-width: 0; border: 0; background: transparent; padding: 10px 10px 10px 0; font-size: 15px; outline: none; }
select { min-height: 42px; max-width: 220px; padding: 8px 32px 8px 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); font-size: 14px; }

/* List beside detail. The list keeps its own scroll, so it stays in view while reading. */
.inbox-layout { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); gap: 20px; align-items: start; }
.list-panel { position: sticky; top: 20px; display: flex; flex-direction: column; max-height: calc(100dvh - 40px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.list-heading { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: 12px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--faint); }
.list { overflow-y: auto; overscroll-behavior: contain; }
.handoff-row { display: block; width: 100%; padding: 14px 16px; border: 0; border-bottom: 1px solid var(--line); border-left: 3px solid transparent; background: var(--surface); text-align: left; }
.handoff-row:hover { background: var(--surface-2); }
.handoff-row.selected { background: var(--selected); border-left-color: var(--green); }
.row-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.row-title { font-size: 15px; font-weight: 650; line-height: 1.4; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mono-title { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 14px; }
.row-top time { flex: none; font-size: 12px; color: var(--faint); white-space: nowrap; }
.row-preview { font-size: 14px; line-height: 1.5; color: var(--muted); margin-bottom: 8px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 12px; color: var(--faint); }
.row-facts { overflow-wrap: anywhere; }
.list-section { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 16px 16px 6px; }
.list-section h2 { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); }
.list-section-note { margin: -2px 16px 6px; font-size: 12px; color: var(--faint); }
.project-label { display: block; width: 100%; padding: 10px 16px 2px; border: 0; background: none; font-size: 12px; font-weight: 650; text-align: left; color: var(--green); }
button.project-label:hover { text-decoration: underline; }
.project-label.none { color: var(--faint); }
.handoff-header { align-items: center; }
.toolbar { display: flex; align-items: center; gap: 8px; min-width: 0; }
.search-field.compact { flex: none; width: 240px; }
.search-field.compact input { padding: 8px 10px 8px 0; font-size: 14px; }
.filter-chip { padding: 6px 12px; border: 1px solid var(--green); border-radius: 999px; background: var(--pale); color: var(--green); font-size: 13px; font-weight: 600; white-space: nowrap; }
.counts { display: inline-flex; gap: 4px; }
.count.alert { background: var(--red); color: #fff; }
.row-bottom { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 12px; color: var(--muted); }
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.5; background: var(--surface-2); color: var(--muted); }
.badge.available { background: var(--pale); color: var(--green); }
.badge.claimed { background: var(--amber-bg); color: var(--amber); }
.badge.completed { background: var(--surface-2); color: var(--muted); }
.badge.needs_you { background: color-mix(in srgb, var(--red) 14%, var(--surface)); color: var(--red); }
.group-heading { position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%; padding: 8px 16px; border: 0; border-bottom: 1px solid var(--line); background: var(--surface-2); font-size: 13px; font-weight: 650; text-align: left; color: var(--ink); }
.group-heading:hover { background: var(--pale); }
.group-heading .count { font-weight: 600; color: var(--muted); }
.group-heading.no-project { color: var(--muted); font-weight: 600; }
.row-note { font-size: 12px; color: var(--amber); }
.project-tag { padding: 1px 7px; border: 1px solid var(--line-strong); border-radius: 6px; font-size: 12px; overflow-wrap: anywhere; }
.agent-route { color: var(--muted); }
.empty-list { padding: 36px 24px; text-align: center; font-size: 14px; color: var(--muted); }
.empty-list strong { display: block; margin-bottom: 6px; font-size: 16px; color: var(--ink); }
.empty-list .button { margin-top: 8px; }
.load-more { flex: none; margin: 12px 16px 16px; }

.detail-panel { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.detail-header { padding: 18px 28px 22px; border-bottom: 1px solid var(--line); }
.detail-header { position: relative; }
.detail-header h2 { padding-right: 40px; }
/* Desktop: the More menu floats top right (there's no Back button). Phones put Back and More on their own row. */
.detail-bar { position: absolute; top: 16px; right: 20px; }
.detail-content > .resume-box { margin-top: 18px; }
.detail-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin: 0 0 14px; font-size: 13px; color: var(--muted); }
.detail-meta .badge { margin-right: 4px; }
.detail-meta .project-tag { margin-left: 6px; background: none; cursor: pointer; color: var(--muted); }
.detail-meta .project-tag:hover { border-color: var(--green); color: var(--green); }
.detail-summary { margin-bottom: 18px; }
.resume-box { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border: 1px solid color-mix(in srgb, var(--green) 35%, var(--line)); border-radius: var(--radius); background: color-mix(in srgb, var(--pale) 60%, var(--surface)); }
.resume-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.resume-text code { font-size: 13px; overflow-wrap: anywhere; color: var(--ink); }
.resume-label { color: var(--green); font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.more-menu { position: relative; margin-left: auto; }
.more-menu summary { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; list-style: none; cursor: pointer; font-size: 20px; line-height: 1; color: var(--muted); }
.more-menu summary::-webkit-details-marker { display: none; }
.more-menu summary:hover, .more-menu[open] summary { background: var(--surface-2); color: var(--ink); }
.more-items { position: absolute; right: 0; top: 38px; z-index: 5; display: flex; flex-direction: column; min-width: 180px; padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); }
.more-items button { padding: 9px 10px; border: 0; border-radius: 6px; background: none; font-size: 14px; text-align: left; }
.more-items button:hover { background: var(--surface-2); }
.more-items .danger-text { color: var(--red); }
.fold { margin-top: 18px; border-top: 1px solid var(--line); }
.fold > summary { padding: 14px 0 2px; font-size: 14px; font-weight: 650; cursor: pointer; color: var(--muted); }
.fold > summary:hover { color: var(--ink); }
.fold-body { padding-bottom: 6px; }
.next-up { align-items: flex-start; text-align: left; max-width: 560px; margin: 0 auto; }
.next-up h2 { margin: 8px 0 10px; }
.next-up-preview { margin: 0 0 18px; }
.next-up-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.back-button { display: none; }
.detail-status { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-size: 13px; color: var(--faint); }
.detail-header h2 { margin-bottom: 8px; overflow-wrap: anywhere; }
.detail-header h2.mono-title { font-size: 20px; }
.detail-route { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-bottom: 18px; font-size: 14px; color: var(--muted); }
.detail-route strong { color: var(--ink); font-weight: 600; }
.detail-route .project-tag { margin-left: 8px; }
.memory-content { font-size: 17px; line-height: 1.6; margin-bottom: 18px; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.id-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 12px; color: var(--faint); }
.id-row code { font-size: 12px; }
.claim-note { margin: 14px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--amber-bg); color: var(--amber); font-size: 14px; }
.detail-content { padding: 4px 28px 28px; }
.glance { margin: 18px 0 6px; padding: 16px 18px; border: 1px solid color-mix(in srgb, var(--green) 35%, var(--line)); border-radius: var(--radius); background: color-mix(in srgb, var(--pale) 60%, var(--surface)); }
.glance-label { display: block; margin-bottom: 6px; color: var(--green); font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.glance-summary { margin: 0; font-size: 16px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.glance-summary + .glance-summary { margin-top: 10px; }
.detail-header .glance { margin: 4px 0 16px; }
.question-card { padding: 14px; margin-bottom: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.question-card.waiting { border-color: color-mix(in srgb, var(--red) 40%, var(--line)); background: var(--surface); }
.question-card > strong { display: block; margin-bottom: 8px; white-space: pre-wrap; overflow-wrap: anywhere; }
.question-card textarea { display: block; width: 100%; min-height: 84px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); resize: vertical; line-height: 1.5; }
.question-card .answer { margin: 0 0 6px; white-space: pre-wrap; overflow-wrap: anywhere; }
.question-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.question-actions .button { min-height: 34px; padding: 6px 12px; }
.glance-next { margin: 8px 0 0; font-size: 15px; }
.glance-facts { margin: 10px 0 0; color: var(--muted); font-size: 13px; }
.memory-summary { margin: 0 0 16px; }
.memory-counts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.count-chip { padding: 5px 12px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); color: var(--ink); font-size: 13px; font-weight: 600; cursor: pointer; }
.count-chip:hover { border-color: var(--green); }
.expiring { margin: 6px 0 0; padding-left: 18px; font-size: 14px; }
.expiring li { margin: 4px 0; }
.link-button { padding: 0; border: 0; background: none; color: var(--green); font: inherit; text-align: left; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.section { padding-top: 22px; }
.section p, .section li { font-size: 15px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; margin-bottom: 6px; }
.section ul { padding-left: 20px; margin: 0; }
.steps { padding-left: 0; margin: 0; list-style: none; counter-reset: step; }
.next-step { position: relative; counter-increment: step; padding: 6px 0 6px 36px; margin-bottom: 4px !important; }
.next-step::before { content: counter(step); position: absolute; left: 0; top: 7px; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--green); color: var(--green-ink); font-size: 13px; font-weight: 700; }
.step-action { display: block; }
.done-when { display: block; font-size: 13px; color: var(--muted); }
.detail-card { padding: 12px 14px; margin-bottom: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; }
.detail-card p:last-child { margin-bottom: 0; }
.detail-card pre { margin: 10px 0 0; font-size: 12px; background: var(--surface); }
.card-label { display: block; margin-bottom: 4px; font-size: 12px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); }
.outcome-card { background: var(--pale); border-color: var(--accent); }
.evidence-ids { margin-top: 6px; font-size: 12px; color: var(--muted); }
.metadata { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px 20px; margin: 0; }
.metadata dt { font-size: 12px; color: var(--faint); margin-bottom: 2px; }
.metadata dd { margin: 0; font-size: 14px; overflow-wrap: anywhere; }
.timeline { list-style: none; padding: 0 !important; margin: 0; }
.timeline li { position: relative; margin-left: 4px; padding: 0 0 14px 16px; border-left: 2px solid var(--line); }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.timeline strong { display: block; font-size: 14px; }
.timeline time, .timeline .small { font-size: 13px; color: var(--muted); }
.raw-details { margin-top: 24px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; }
.raw-details summary { font-size: 14px; font-weight: 600; cursor: pointer; }
.raw-details pre { margin: 12px 0 0; max-height: 600px; overflow: auto; font-size: 12px; }
.trust-note { margin: 20px 0 0; padding-top: 16px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }

.empty-detail { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 460px; padding: 40px 32px; text-align: center; color: var(--muted); }
.empty-icon { display: grid; place-items: center; width: 56px; height: 56px; margin-bottom: 18px; border-radius: 16px; background: var(--pale); color: var(--green); font-size: 32px; }
.empty-detail h2 { color: var(--ink); margin-bottom: 18px; }
.empty-detail > p { max-width: 420px; }
.empty-steps { display: grid; gap: 10px; max-width: 440px; margin: 0 0 22px; padding: 0; list-style: none; text-align: left; }
.empty-steps li { display: grid; grid-template-columns: 72px 1fr; gap: 10px; padding: 10px 14px; border-radius: 10px; background: var(--surface-2); font-size: 14px; }
.empty-steps strong { color: var(--ink); }

/* Dialogs and toasts */
dialog { width: calc(100% - 32px); max-width: 640px; max-height: calc(100dvh - 48px); overflow: auto; padding: 24px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--ink); box-shadow: 0 24px 80px #0b1a1340; }
dialog::backdrop { background: #0f1f1766; backdrop-filter: blur(3px); }
dialog h3 { margin: 18px 0 8px; }
dialog .muted { font-size: 14px; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.dialog-heading h2 { margin: 0; font-size: 20px; }
.copy-row { display: flex; align-items: stretch; gap: 8px; margin-bottom: 4px; }
.copy-row pre { flex: 1; margin: 0; }
.setup-token-link { margin: 0 0 12px; }
.copy-text { width: 100%; min-height: 160px; padding: 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface-2); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; }
.signin-label { display: block; margin: 14px 0 6px; font-size: 14px; font-weight: 600; }
.signin-input { display: block; width: 100%; padding: 10px 12px; margin-bottom: 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); }
.toast { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20; padding: 10px 18px; border-radius: 10px; background: #1f332a; color: #fff; font-size: 14px; box-shadow: 0 8px 30px #0003; }

/* Account sheet (small screens): workspace, host links such as Access tokens, and Sign out. */
.account-identity { display: flex; align-items: center; gap: 12px; min-width: 0; }
.account-identity strong { display: block; font-size: 16px; }
.account-identity span:not(.workspace-avatar) { display: block; font-size: 13px; color: var(--muted); }
.account-links { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.account-link { display: flex; align-items: center; width: 100%; min-height: 48px; padding: 10px 12px; border: 0; border-radius: 10px; background: var(--surface-2); color: var(--ink); font-size: 16px; font-weight: 550; text-align: left; text-decoration: none; }
.account-link:hover { background: var(--pale); }
.account-link.signout { margin-top: 8px; background: none; border: 1px solid var(--line-strong); color: var(--red); justify-content: center; }

/* Medium screens: narrower sidebar and list. */
@media (max-width: 1100px) {
  .app { grid-template-columns: 216px minmax(0, 1fr); }
  .main { padding: 22px 20px 28px; }
  .inbox-layout { grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 16px; }
  .detail-header { padding: 20px 22px 18px; }
  .detail-content { padding: 4px 22px 22px; }
  .filters { flex-wrap: wrap; }
  .filters .search-field { flex-basis: 100%; }
  select { flex: 1; max-width: none; }
  .search-field.compact { width: 180px; }
}

/* Phones and small tablets: a top bar with chips, then one pane at a time. */
@media (max-width: 900px) {
  html { scroll-padding-top: 120px; }
  .app { display: block; }
  .sidebar { position: sticky; top: 0; z-index: 10; height: auto; gap: 10px; padding: 10px 14px 0; padding-top: max(10px, env(safe-area-inset-top)); border-right: 0; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--sidebar) 92%, transparent); backdrop-filter: blur(10px); overflow: visible; }
  .sidebar-top { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; }
  .brand { font-size: 19px; padding: 0; }
  .brand-icon { width: 30px; height: 30px; font-size: 21px; }
  .connect-button { width: auto; min-height: 36px; padding: 6px 12px; font-size: 13px; }
  .workspace, .nav-label, .local-status { display: none; }
  .nav { flex-direction: row; gap: 6px; margin: 0 -14px; padding: 0 14px 10px; overflow-x: auto; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav-item { flex: none; width: auto; min-height: 36px; padding: 6px 12px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); font-size: 14px; white-space: nowrap; }
  .nav-item.active { background: var(--green); border-color: var(--green); color: var(--green-ink); }
  .nav-item.active .count { background: #ffffff33; color: inherit; }
  .nav-item .dot { display: none; }
  .sidebar-bottom { display: none; }
  body.has-account .account-button { display: grid; place-items: center; flex: none; width: 36px; height: 36px; padding: 0; border: 1px solid var(--line-strong); border-radius: 50%; background: var(--surface); font-size: 14px; font-weight: 700; color: var(--ink); }
  .sidebar-top .brand { margin-right: auto; }
  .sidebar-top { gap: 8px; }
  /* A bottom sheet on phones. */
  dialog.sheet { margin: auto 0 0; width: 100%; max-width: none; border-radius: 18px 18px 0 0; padding: 18px 16px max(18px, env(safe-area-inset-bottom)); }

  .main { padding: 16px 14px 28px; }
  h1 { font-size: 23px; }
  .page-header { align-items: center; margin-bottom: 12px; }
  .icon-text { min-width: 40px; padding: 8px 10px; }
  .icon-text .label { display: none; }
  .filters { flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
  .filters .search-field { flex-basis: 100%; }
  .handoff-header { flex-wrap: wrap; }
  .toolbar { flex: 1 1 100%; }
  .search-field.compact { flex: 1; width: auto; }
  .search-field input { font-size: 16px; }  /* 16px stops iOS zooming on focus */
  select { flex: 1; min-width: 0; max-width: none; font-size: 14px; }

  .inbox-layout { display: block; }
  .list-panel { position: static; max-height: none; box-shadow: none; }
  .list { overflow: visible; }
  .handoff-row { padding: 14px; }
  .detail-panel { display: none; box-shadow: none; }
  .empty-detail { min-height: 0; }

  /* Detail open: hide the list and its controls, show the detail full width with a Back button. */
  body.detail-open #handoff-view .page-header, body.detail-open #handoff-view .filters, body.detail-open #handoff-view .list-panel,
  body.memory-open #memory-view .page-header, body.memory-open #memory-view .filters, body.memory-open #memory-view .list-panel { display: none; }
  body.detail-open #detail, body.memory-open #memory-detail { display: block; }
  .back-button { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; margin: -6px 0 10px -8px; padding: 6px 8px; border: 0; border-radius: 8px; background: none; color: var(--green); font-size: 15px; font-weight: 600; }
  .back-button:hover { background: var(--pale); }
  .detail-panel { border-radius: var(--radius); }
  .detail-header { padding: 16px 16px 16px; }
  .detail-content { padding: 0 16px 20px; }
  .detail-header h2 { font-size: 21px; }
  .detail-header h2.mono-title { font-size: 17px; }
  .detail-actions .button { flex: 1; }
  .resume-box .button { flex: 1; }
  .detail-bar { position: static; display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
  .detail-bar .back-button { margin: 0 0 0 -8px; }
  .detail-header h2 { padding-right: 0; }
  .nav-item.active .count.alert { background: var(--red); color: #fff; }
  .metadata { grid-template-columns: 1fr 1fr; }
  .empty-steps li { grid-template-columns: 1fr; gap: 2px; }
  .copy-row { flex-direction: column; }
  dialog { padding: 18px; }
}

@media (prefers-reduced-motion: no-preference) {
  .detail-panel { animation: appear .18s ease; }
  @keyframes appear { from { opacity: .7; transform: translateY(3px); } to { opacity: 1; transform: none; } }
}
