/* ═══════════════════════════════════════════════════════════════════════
   Replaroo — screens
   Layout for the agent app. Built desktop-first as a fixed three-pane
   workspace, then collapsed to one pane at a time on a phone, because the
   phone build IS the agent app and cannot be an afterthought.
   ═══════════════════════════════════════════════════════════════════════ */

/* ══════════════════════════════════════════════════════════════════════
   AUTH PAGES
   ══════════════════════════════════════════════════════════════════════ */

.auth-shell {
    min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr;
}
.auth-side {
    position: relative; overflow: hidden;
    background: linear-gradient(155deg, #4F46E5 0%, #6D28D9 55%, #9333EA 100%);
    color: #fff; padding: 56px 52px;
    display: flex; flex-direction: column; justify-content: space-between;
}
.auth-side::before,
.auth-side::after {
    content: ""; position: absolute; border-radius: 50%;
    background: rgba(255, 255, 255, .09); pointer-events: none;
}
.auth-side::before { width: 460px; height: 460px; top: -180px; right: -140px; }
.auth-side::after  { width: 320px; height: 320px; bottom: -130px; left: -90px;
                     background: rgba(255, 255, 255, .06); }

.auth-brand { display: flex; align-items: center; gap: 11px; font-size: 19px; font-weight: 700; }
.auth-mark {
    width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
    background: rgba(255, 255, 255, .18); backdrop-filter: blur(6px);
}
.auth-pitch { position: relative; z-index: 1; max-width: 420px; }
.auth-pitch h2 { font-size: 33px; line-height: 1.2; margin-bottom: 14px; letter-spacing: -.03em; }
.auth-pitch p { font-size: 15.5px; line-height: 1.65; color: rgba(255, 255, 255, .82); }
.auth-points { list-style: none; margin: 26px 0 0; padding: 0; display: grid; gap: 12px; }
.auth-points li {
    display: flex; align-items: flex-start; gap: 10px;
    font-size: 14px; color: rgba(255, 255, 255, .92);
}
.auth-points svg { flex: none; margin-top: 2px; opacity: .9; }
.auth-foot { position: relative; z-index: 1; font-size: 13px; color: rgba(255, 255, 255, .62); }

.auth-main {
    display: grid; place-items: center; padding: 40px 28px; background: var(--bg);
}
.auth-card { width: 100%; max-width: 392px; }
.auth-card h1 { margin-bottom: 6px; }
.auth-card > p.muted { margin-bottom: 26px; font-size: 14.5px; }

.auth-alert {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 11px 14px; margin-bottom: 18px;
    background: var(--red-soft); color: #B91C1C;
    border-radius: var(--r-sm); font-size: 13.5px; line-height: 1.5;
}
[data-theme="dark"] .auth-alert { color: #FCA5A5; }
.auth-alert-good { background: var(--green-soft); color: #047857; }
[data-theme="dark"] .auth-alert-good { color: #6EE7B7; }

.auth-links {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: 20px; font-size: 13.5px;
}

@media (max-width: 900px) {
    .auth-shell { grid-template-columns: 1fr; }
    .auth-side { display: none; }
}

/* ══════════════════════════════════════════════════════════════════════
   APP SHELL
   ══════════════════════════════════════════════════════════════════════ */

.app {
    display: grid;
    grid-template-columns: var(--rail) var(--list-w) 1fr;
    height: 100vh; height: 100dvh;
    overflow: hidden;
}
.app.has-panel { grid-template-columns: var(--rail) var(--list-w) 1fr var(--panel-w); }

/* A grid or flex child defaults to min-height:auto, which means it refuses to
   shrink below its content. One long conversation then pushes the whole grid
   past 100vh and the PAGE scrolls instead of the message list. Setting
   min-height:0 on every column and every scrolling child is what makes the
   three panes scroll independently, the way an inbox has to. */
.app > * { min-height: 0; min-width: 0; }
.list-col, .thread-col, .panel { min-height: 0; }
.conv-list, .msgs, .panel { min-height: 0; }

/* Belt and braces: the app shell owns the viewport, so nothing behind it can
   scroll and produce a second scrollbar. */
body.app-shell { overflow: hidden; height: 100vh; height: 100dvh; }

/* ── left rail ───────────────────────────────────────────────────── */

.rail {
    background: var(--surface); border-right: 1px solid var(--line);
    display: flex; flex-direction: column; align-items: center;
    padding: 12px 0 10px; gap: 4px; z-index: 3;
}
.rail-mark {
    width: 36px; height: 36px; border-radius: 11px; margin-bottom: 10px;
    display: grid; place-items: center; color: #fff;
    background: var(--brand-gradient); box-shadow: var(--brand-glow);
    font-weight: 700; font-size: 15px;
}
.rail-btn {
    position: relative; width: 42px; height: 42px; border-radius: var(--r-md);
    display: grid; place-items: center; color: var(--muted);
    border: none; background: transparent; cursor: pointer;
    transition: background var(--fast), color var(--fast);
}
.rail-btn:hover { background: var(--surface-3); color: var(--ink); }
.rail-btn.active { background: var(--brand-soft); color: var(--brand); }
.rail-btn .count {
    position: absolute; top: 4px; right: 4px; min-width: 17px; height: 17px;
    padding: 0 4px; border-radius: var(--r-full);
    background: var(--red); color: #fff;
    font-size: 10px; font-weight: 700; line-height: 17px; text-align: center;
    border: 2px solid var(--surface);
}
.rail-spacer { flex: 1; }
.rail-avatar { cursor: pointer; border: none; background: none; padding: 0; }

/* tooltip on the rail */
.rail-btn[data-tip]:hover::after {
    content: attr(data-tip); position: absolute; left: calc(100% + 10px);
    padding: 5px 10px; border-radius: var(--r-xs);
    background: #171A26; color: #fff; font-size: 12px; font-weight: 500;
    white-space: nowrap; z-index: 40; pointer-events: none;
    box-shadow: var(--shadow-md);
}

/* ── conversation list column ────────────────────────────────────── */

.list-col {
    background: var(--surface); border-right: 1px solid var(--line);
    display: flex; flex-direction: column; min-width: 0; z-index: 2;
}

.list-head { padding: 12px 14px 10px; border-bottom: 1px solid var(--line); }
.list-title-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; margin-bottom: 10px;
}
.list-title { font-size: 16px; font-weight: 660; letter-spacing: -.02em; }

.search-wrap { position: relative; margin-bottom: 9px; }
.search-wrap svg {
    position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
    color: var(--faint); pointer-events: none;
}
.search-wrap input {
    padding-left: 32px; background: var(--surface-3); border-color: transparent;
    font-size: 13.5px;
}
.search-wrap input:focus { background: var(--surface); }

.seg {
    display: flex; gap: 2px; padding: 2.5px;
    background: var(--surface-3); border-radius: var(--r-sm);
}
.seg button {
    flex: 1; padding: 5.5px 8px; border: none; border-radius: var(--r-xs);
    background: transparent; color: var(--muted); cursor: pointer;
    font: inherit; font-size: 12.5px; font-weight: 570;
    transition: background var(--fast), color var(--fast);
    display: flex; align-items: center; justify-content: center; gap: 5px;
}
.seg button:hover { color: var(--ink); }
.seg button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-xs); }
.seg .n {
    font-size: 10.5px; font-weight: 700; padding: 0 4px; border-radius: var(--r-full);
    background: var(--line); color: var(--ink-2); min-width: 15px;
}
.seg button.active .n { background: var(--brand-soft); color: var(--brand-700); }

.filter-bar {
    display: flex; gap: 6px; padding: 8px 14px; border-bottom: 1px solid var(--line);
    overflow-x: auto; scrollbar-width: none;
}
.filter-bar::-webkit-scrollbar { display: none; }
.chip {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 10px; border-radius: var(--r-full);
    background: var(--surface-3); border: 1px solid transparent;
    color: var(--ink-2); font-size: 12px; font-weight: 560;
    cursor: pointer; white-space: nowrap; flex: none;
    transition: all var(--fast);
}
.chip:hover { background: var(--line); }
.chip.active { background: var(--brand-soft); color: var(--brand-700); border-color: var(--brand-200); }
[data-theme="dark"] .chip.active { color: var(--brand-300); border-color: var(--brand-800); }

.conv-list { flex: 1; overflow-y: auto; overscroll-behavior: contain; }

.conv {
    display: flex; gap: 11px; padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    cursor: pointer; position: relative;
    transition: background var(--fast);
}
.conv:hover { background: var(--surface-2); }
.conv.active { background: var(--brand-soft); }
.conv.active::before {
    content: ""; position: absolute; left: 0; top: 0; bottom: 0;
    width: 3px; background: var(--brand);
}
.conv.unread .conv-name { font-weight: 680; }
.conv.unread .conv-preview { color: var(--ink-2); font-weight: 500; }

.conv-body { flex: 1; min-width: 0; }
.conv-top {
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px; margin-bottom: 2px;
}
.conv-name { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.conv-time { font-size: 11px; color: var(--faint); flex: none; }
.conv-preview {
    font-size: 12.5px; color: var(--muted); line-height: 1.45;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.conv-meta { display: flex; align-items: center; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.conv-unread {
    min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r-full);
    background: var(--brand); color: #fff;
    font-size: 10.5px; font-weight: 700; line-height: 18px; text-align: center; flex: none;
}
.conv-waiting { color: var(--amber); font-weight: 600; }
.conv-note-icon { color: var(--muted); }

.prio {
    width: 4px; border-radius: var(--r-full); flex: none; align-self: stretch;
    margin: 2px 0;
}
.prio-urgent { background: var(--red); }
.prio-high   { background: var(--amber); }
.prio-medium { background: var(--brand-400); }
.prio-low    { background: var(--line-2); }

/* ── thread column ───────────────────────────────────────────────── */

.thread-col {
    display: flex; flex-direction: column; min-width: 0;
    background: var(--bg);
}

.thread-head {
    height: var(--topbar); flex: none;
    display: flex; align-items: center; gap: 12px;
    padding: 0 16px; background: var(--surface);
    border-bottom: 1px solid var(--line); z-index: 2;
}
.thread-who { flex: 1; min-width: 0; }
.thread-name { font-size: 14.5px; font-weight: 640; letter-spacing: -.01em; }
.thread-sub { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.thread-actions { display: flex; align-items: center; gap: 6px; flex: none; }

.msgs {
    flex: 1; overflow-y: auto; padding: 20px 22px 8px;
    display: flex; flex-direction: column; gap: 3px;
    overscroll-behavior: contain;
}

.day-split {
    display: flex; align-items: center; gap: 12px;
    margin: 18px 0 14px; color: var(--faint); font-size: 11.5px; font-weight: 600;
}
.day-split::before, .day-split::after {
    content: ""; flex: 1; height: 1px; background: var(--line);
}

.msg { display: flex; gap: 9px; max-width: 76%; margin-bottom: 9px; }
.msg-in  { align-self: flex-start; }
.msg-out { align-self: flex-end; flex-direction: row-reverse; }

.bubble {
    padding: 9px 13px; border-radius: var(--r-lg);
    font-size: 14px; line-height: 1.55; word-wrap: break-word;
    white-space: pre-wrap; box-shadow: var(--shadow-xs);
}
.msg-in .bubble {
    background: var(--surface); color: var(--ink);
    border: 1px solid var(--line); border-bottom-left-radius: var(--r-xs);
}
.msg-out .bubble {
    background: var(--brand); color: #fff; border-bottom-right-radius: var(--r-xs);
}
.msg-out.is-system .bubble { background: var(--brand-500); }

/* A private note must never be mistaken for something the shopper saw. */
.msg-note { align-self: flex-end; flex-direction: row-reverse; max-width: 76%; }
.msg-note .bubble {
    background: var(--amber-soft); color: #92400E;
    border: 1px dashed #FCD34D; border-bottom-right-radius: var(--r-xs);
}
[data-theme="dark"] .msg-note .bubble { color: #FCD34D; border-color: #78350F; }
.note-tag {
    display: flex; align-items: center; gap: 5px; margin-bottom: 4px;
    font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
    opacity: .85;
}

.msg-meta {
    display: flex; align-items: center; gap: 5px; margin-top: 3px;
    font-size: 11px; color: var(--faint);
}
.msg-out .msg-meta { justify-content: flex-end; }

.activity {
    align-self: center; max-width: 80%; text-align: center;
    margin: 6px 0; padding: 4px 12px; border-radius: var(--r-full);
    background: var(--surface-3); color: var(--muted);
    font-size: 11.5px; font-weight: 500;
}

.attach {
    display: flex; align-items: center; gap: 9px; margin-top: 6px;
    padding: 8px 11px; border-radius: var(--r-sm);
    background: rgba(255, 255, 255, .16); font-size: 12.5px;
}
.msg-in .attach { background: var(--surface-3); }
.attach-img { display: block; border-radius: var(--r-md); margin-top: 6px; max-height: 260px; }

/* rating card */
.csat-card {
    align-self: center; text-align: center; margin: 12px 0;
    padding: 16px 20px; border-radius: var(--r-lg);
    background: var(--surface); border: 1px solid var(--line);
    box-shadow: var(--shadow-sm); max-width: 320px;
}
.csat-stars { display: flex; gap: 5px; justify-content: center; margin-top: 10px; }
.csat-star {
    width: 34px; height: 34px; border: none; background: none; cursor: pointer;
    color: var(--line-2); transition: color var(--fast), transform var(--fast);
}
.csat-star:hover, .csat-star.on { color: var(--amber); transform: scale(1.12); }

/* typing */
.typing-row {
    display: flex; align-items: center; gap: 9px;
    padding: 4px 22px 10px; color: var(--muted); font-size: 12.5px;
    min-height: 26px;
}
.typing-dots { display: inline-flex; gap: 3px; }
.typing-dots i {
    width: 5px; height: 5px; border-radius: 50%; background: var(--faint);
    animation: bounce 1.3s infinite;
}
.typing-dots i:nth-child(2) { animation-delay: .16s; }
.typing-dots i:nth-child(3) { animation-delay: .32s; }
@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: .5; }
    30% { transform: translateY(-4px); opacity: 1; }
}
.typing-preview {
    font-style: italic; color: var(--faint);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 380px;
}

/* ── composer ────────────────────────────────────────────────────── */

.composer {
    flex: none; padding: 10px 16px 14px; background: var(--surface);
    border-top: 1px solid var(--line);
}
.composer.note-mode { background: var(--amber-soft); }
[data-theme="dark"] .composer.note-mode { background: #2A1F0C; }

.composer-tabs { display: flex; gap: 3px; margin-bottom: 8px; }
.composer-tab {
    padding: 5px 12px; border: none; border-radius: var(--r-xs);
    background: transparent; color: var(--muted); cursor: pointer;
    font: inherit; font-size: 12.5px; font-weight: 600;
    display: flex; align-items: center; gap: 6px;
    transition: background var(--fast), color var(--fast);
}
.composer-tab:hover { background: var(--surface-3); color: var(--ink); }
.composer-tab.active { background: var(--surface-3); color: var(--ink); }
.composer-tab.note.active { background: #FDE68A; color: #92400E; }

.composer-box {
    border: 1px solid var(--line-2); border-radius: var(--r-md);
    background: var(--surface); transition: border-color var(--fast), box-shadow var(--fast);
}
.composer-box:focus-within { border-color: var(--brand-500); box-shadow: 0 0 0 3.5px var(--brand-soft); }

.composer textarea {
    border: none; background: transparent; padding: 11px 13px 4px;
    min-height: 46px; max-height: 220px; resize: none; font-size: 14px;
}
.composer textarea:focus { box-shadow: none; }

.composer-tools {
    display: flex; align-items: center; gap: 3px; padding: 5px 8px 7px;
}
.composer-tools .spacer { flex: 1; }
.tool-btn {
    width: 30px; height: 30px; border: none; border-radius: var(--r-xs);
    background: transparent; color: var(--muted); cursor: pointer;
    display: grid; place-items: center; transition: background var(--fast), color var(--fast);
}
.tool-btn:hover { background: var(--surface-3); color: var(--ink); }

.send-hint { font-size: 11px; color: var(--faint); margin-right: 8px; }

.pending-files { display: flex; gap: 7px; flex-wrap: wrap; padding: 0 8px 6px; }
.pending-file {
    display: flex; align-items: center; gap: 7px; padding: 5px 9px;
    background: var(--surface-3); border-radius: var(--r-sm); font-size: 12px;
}
.pending-file button {
    border: none; background: none; color: var(--muted); cursor: pointer;
    padding: 0; display: grid; place-items: center;
}

/* saved-reply picker */
.canned-pop {
    position: absolute; bottom: 100%; left: 0; right: 0; margin-bottom: 8px;
    max-height: 260px; overflow-y: auto; z-index: 30;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--r-md); box-shadow: var(--shadow-lg);
}
.canned-item { padding: 9px 13px; cursor: pointer; border-bottom: 1px solid var(--line); }
.canned-item:last-child { border-bottom: none; }
.canned-item:hover, .canned-item.on { background: var(--brand-soft); }
.canned-code { font-size: 12px; font-weight: 700; color: var(--brand); font-family: var(--mono); }
.canned-text { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* ── right panel ─────────────────────────────────────────────────── */

.panel {
    background: var(--surface); border-left: 1px solid var(--line);
    overflow-y: auto; min-width: 0;
}
.panel-section { padding: 16px; border-bottom: 1px solid var(--line); }
.panel-section h4 {
    display: flex; align-items: center; justify-content: space-between;
    font-size: 11px; font-weight: 700; letter-spacing: .08em;
    text-transform: uppercase; color: var(--faint); margin-bottom: 12px;
}
.panel-contact { text-align: center; padding: 22px 16px 18px; }
.panel-contact .avatar { margin: 0 auto 10px; }
.panel-contact h3 { font-size: 15.5px; margin-bottom: 2px; }

.kv { display: flex; gap: 10px; padding: 5px 0; font-size: 13px; align-items: flex-start; }
.kv dt { flex: none; width: 84px; color: var(--muted); font-size: 12.5px; }
.kv dd { margin: 0; flex: 1; min-width: 0; color: var(--ink); word-break: break-word; }

.cart-line {
    display: flex; justify-content: space-between; gap: 10px;
    padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 13px;
}
.cart-line:last-child { border-bottom: none; }
.cart-total {
    display: flex; justify-content: space-between; margin-top: 9px;
    padding-top: 9px; border-top: 1px solid var(--line-2);
    font-weight: 700; font-size: 14px;
}

.trail-item {
    display: block; padding: 6px 0 6px 15px; position: relative;
    font-size: 12.5px; color: var(--ink-2); border-left: 2px solid var(--line);
}
.trail-item::before {
    content: ""; position: absolute; left: -4px; top: 12px;
    width: 6px; height: 6px; border-radius: 50%; background: var(--line-2);
}
.trail-item:hover { color: var(--brand); }

.label-pick {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px; border-radius: var(--r-full); cursor: pointer;
    font-size: 12px; font-weight: 570; border: 1px solid var(--line-2);
    background: var(--surface); color: var(--ink-2);
    transition: all var(--fast);
}
.label-pick:hover { border-color: var(--faint); }
.label-pick.on { color: #fff; border-color: transparent; }

/* ══════════════════════════════════════════════════════════════════════
   SETTINGS
   ══════════════════════════════════════════════════════════════════════ */

.settings-shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.settings-nav {
    background: var(--surface); border-right: 1px solid var(--line);
    padding: 16px 12px; display: flex; flex-direction: column; gap: 2px;
}
.settings-back {
    display: flex; align-items: center; gap: 8px; padding: 8px 10px; margin-bottom: 12px;
    color: var(--muted); font-size: 13px; font-weight: 570; border-radius: var(--r-sm);
}
.settings-back:hover { background: var(--surface-3); color: var(--ink); text-decoration: none; }

.settings-group { margin: 14px 0 4px; padding: 0 10px; }
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: var(--r-sm);
    color: var(--ink-2); font-size: 13.5px; font-weight: 540;
    transition: background var(--fast), color var(--fast);
}
.nav-item:hover { background: var(--surface-3); color: var(--ink); text-decoration: none; }
.nav-item.active { background: var(--brand-soft); color: var(--brand-700); font-weight: 600; }
[data-theme="dark"] .nav-item.active { color: var(--brand-300); }
.nav-item svg { flex: none; opacity: .8; }

.settings-main { padding: 30px 34px 60px; overflow-y: auto; max-width: 100%; }
.settings-inner { max-width: 880px; }
.settings-head { margin-bottom: 26px; }
.settings-head h1 { margin-bottom: 5px; }
.settings-head p { color: var(--muted); font-size: 14.5px; max-width: 620px; }

.section { margin-bottom: 28px; }
.section-title {
    display: flex; align-items: center; justify-content: space-between;
    gap: 14px; margin-bottom: 12px;
}
.section-title h2 { font-size: 16.5px; }
.section-title p { margin: 3px 0 0; font-size: 13px; color: var(--muted); }

.row-item {
    display: flex; align-items: center; gap: 13px;
    padding: 13px 18px; border-bottom: 1px solid var(--line);
}
.row-item:last-child { border-bottom: none; }
.row-item:hover { background: var(--surface-2); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-size: 14px; font-weight: 600; }
.row-sub { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.row-actions { display: flex; gap: 6px; flex: none; }

.store-access {
    display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px;
}

/* the branding editor: controls left, live preview right */
.brand-grid { display: grid; grid-template-columns: 1fr 380px; gap: 26px; align-items: start; }
.preview-sticky { position: sticky; top: 24px; }
.preview-stage {
    background: linear-gradient(160deg, #EEF1F8 0%, #E4E8F3 100%);
    border-radius: var(--r-xl); padding: 26px 22px; min-height: 470px;
    position: relative; overflow: hidden; border: 1px solid var(--line);
}
[data-theme="dark"] .preview-stage { background: linear-gradient(160deg, #1A1E2C 0%, #12151F 100%); }
.preview-stage::before {
    content: ""; position: absolute; inset: 0;
    background-image: radial-gradient(circle at 1px 1px, rgba(0,0,0,.05) 1px, transparent 0);
    background-size: 18px 18px; pointer-events: none;
}

.snippet-box {
    position: relative; background: #12141F; color: #D9DEEC;
    border-radius: var(--r-md); padding: 16px 18px;
    font-family: var(--mono); font-size: 12.5px; line-height: 1.65;
    overflow-x: auto; white-space: pre;
}
.snippet-copy { position: absolute; top: 10px; right: 10px; }

.step {
    display: flex; gap: 14px; padding: 16px 0; border-bottom: 1px solid var(--line);
}
.step:last-child { border-bottom: none; }
.step-n {
    flex: none; width: 26px; height: 26px; border-radius: 50%;
    display: grid; place-items: center; font-size: 12.5px; font-weight: 700;
    background: var(--brand-soft); color: var(--brand-700);
}
.step h4 { margin-bottom: 4px; }
.step p { margin: 0; font-size: 13.5px; color: var(--muted); }

.stat-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 14px;
}
.stat {
    padding: 16px 18px; border-radius: var(--r-lg);
    background: var(--surface); border: 1px solid var(--line);
}
.stat-label {
    font-size: 11.5px; font-weight: 640; letter-spacing: .05em;
    text-transform: uppercase; color: var(--faint); margin-bottom: 7px;
}
.stat-value { font-size: 27px; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; }
.stat-sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; }

.bar-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.bar-name { width: 150px; flex: none; font-size: 13px; font-weight: 550; }
.bar-track { flex: 1; height: 9px; background: var(--surface-3); border-radius: var(--r-full); overflow: hidden; }
.bar-fill { height: 100%; border-radius: var(--r-full); background: var(--brand-gradient); }
.bar-value { width: 52px; text-align: right; font-size: 13px; font-weight: 640; flex: none; }

/* ══════════════════════════════════════════════════════════════════════
   PHONE  — the agent app
   ══════════════════════════════════════════════════════════════════════ */

.mobile-only { display: none; }
.back-btn { display: none; }

@media (max-width: 1180px) {
    .app.has-panel { grid-template-columns: var(--rail) var(--list-w) 1fr; }
    .panel { position: fixed; right: 0; top: 0; bottom: 0; width: 330px; z-index: 60;
             box-shadow: var(--shadow-xl); }
    .app:not(.panel-open) .panel { display: none; }
}

@media (max-width: 860px) {
    .app, .app.has-panel { grid-template-columns: 1fr; }
    .rail {
        flex-direction: row; order: 3; width: 100%; height: 58px;
        border-right: none; border-top: 1px solid var(--line);
        padding: 0 6px; justify-content: space-around;
        padding-bottom: env(safe-area-inset-bottom);
        height: calc(58px + env(safe-area-inset-bottom));
    }
    .rail-mark, .rail-spacer { display: none; }
    .rail-btn { width: 52px; height: 46px; }
    .rail-btn[data-tip]:hover::after { display: none; }

    .list-col { order: 1; border-right: none; }
    .thread-col { order: 2; }

    /* one pane at a time */
    .app[data-view="list"] .thread-col { display: none; }
    .app[data-view="thread"] .list-col { display: none; }

    .panel { width: 100%; }
    .back-btn { display: grid; }
    .mobile-only { display: initial; }
    .desktop-only { display: none !important; }

    .msg { max-width: 88%; }
    .msgs { padding: 14px 12px 6px; }
    .composer { padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); }

    .settings-shell { grid-template-columns: 1fr; }
    .settings-nav {
        flex-direction: row; overflow-x: auto; border-right: none;
        border-bottom: 1px solid var(--line); padding: 8px;
    }
    .settings-nav .settings-group, .settings-back span { display: none; }
    .nav-item { white-space: nowrap; }
    .settings-main { padding: 20px 16px 60px; }
    .brand-grid { grid-template-columns: 1fr; }
    .preview-sticky { position: static; }
}

/* Installed-app polish: no rubber-band, respect the notch. */
@media (display-mode: standalone) {
    body { overscroll-behavior: none; }
    .thread-head { padding-top: env(safe-area-inset-top); height: calc(var(--topbar) + env(safe-area-inset-top)); }
    .list-head { padding-top: calc(12px + env(safe-area-inset-top)); }
}

.install-nudge {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px; margin: 10px 14px; border-radius: var(--r-md);
    background: var(--brand-gradient); color: #fff; font-size: 13px;
    box-shadow: var(--brand-glow);
}
.install-nudge button {
    margin-left: auto; border: none; background: rgba(255,255,255,.2); color: #fff;
    padding: 5px 11px; border-radius: var(--r-xs); font: inherit; font-weight: 600;
    cursor: pointer; flex: none;
}
