/* ── Reset & base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #0b0b0e;
    --surface: #121216;
    --surface2: #18181f;
    --surface3: #1e1e28;
    --border: #27273a;
    --border-subtle: #1e1e2a;
    --primary: #a78bfa;
    --primary-dim: #6d57c4;
    --accent: #38bdf8;
    --ok: #4ade80;
    --warn: #facc15;
    --error: #f87171;
    --text: #e2e8f0;
    --text-muted: #8492a6;
    --font: 'Segoe UI', system-ui, sans-serif;
    --font-mono: 'Cascadia Code', 'Fira Code', monospace;
    --radius: 10px;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.35);
    --shadow-md: 0 4px 20px rgba(0,0,0,0.5);
    --glow-primary: 0 0 20px rgba(167,139,250,0.15);
}

html, body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    height: 100%;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--accent); }
h1 {
    font-size: 1.7rem;
    font-weight: 700;
    margin-bottom: 1.4rem;
    background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.01em;
}
h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 1.8rem 0 0.8rem;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
h2::before {
    content: '';
    display: inline-block;
    width: 3px;
    height: 1em;
    background: linear-gradient(180deg, var(--primary), var(--accent));
    border-radius: 2px;
    flex-shrink: 0;
}
code { font-family: var(--font-mono); font-size: 0.85em; background: var(--surface2); padding: 1px 5px; border-radius: 4px; color: var(--accent); }
p { line-height: 1.65; margin-bottom: 0.8rem; color: var(--text-muted); }
.home-tagline { font-size: 1.05rem; color: var(--text); line-height: 1.7; margin-bottom: 0.8rem; }
/* ── Home hero ─────────────────────────────────────────────────────────────── */
.home-hero {
    position: relative;
    padding: 2.2rem 2.2rem 1.6rem;
    margin: -1.5rem -2rem 2rem;
    background: linear-gradient(135deg, rgba(167,139,250,0.07) 0%, rgba(129,140,248,0.04) 50%, transparent 100%);
    border-bottom: 1px solid rgba(167,139,250,0.12);
    overflow: hidden;
}
.home-hero::before {
    content: '';
    position: absolute;
    top: -60px; right: -60px;
    width: 320px; height: 320px;
    background: radial-gradient(ellipse, rgba(167,139,250,0.1) 0%, transparent 70%);
    pointer-events: none;
}
.home-hero-meta {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--primary);
    margin-bottom: 0.7rem;
    opacity: 0.85;
}
.home-hook {
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.55;
    margin: 0 0 1.5rem;
    max-width: 700px;
}
.home-stats-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.stat-pill {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 20px;
    padding: 0.3rem 0.8rem;
    font-size: 0.78rem;
}
.stat-pill-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--ok);
    box-shadow: 0 0 6px var(--ok);
    animation: statusPulse 2.5s ease-in-out infinite;
    flex-shrink: 0;
}
.stat-pill-label { color: var(--text-muted); }
.stat-pill-value { color: var(--text); font-weight: 600; }

/* ── Home sections ──────────────────────────────────────────────────────────── */
.home-section { margin-bottom: 2.5rem; }
.home-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
@media (max-width: 700px) { .home-two-col { grid-template-columns: 1fr; } }

.section-heading {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0 0 1rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.section-heading::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, rgba(167,139,250,0.25) 0%, transparent 100%);
}

/* ── Callout cards ──────────────────────────────────────────────────────────── */
.callout {
    background: linear-gradient(145deg, var(--surface2) 0%, rgba(18,18,26,0.97) 100%);
    border: 1px solid #3a3a50;
    border-radius: 12px;
    padding: 1.3rem 1.5rem;
    position: relative;
    overflow: hidden;
}
.callout::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 3px; height: 100%;
    border-radius: 12px 0 0 12px;
}
.callout-problem::before { background: linear-gradient(180deg, #f87171, #fb923c); }
.callout-solution::before { background: linear-gradient(180deg, var(--primary), var(--accent)); }
.callout-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.6rem;
}
.callout-icon { font-size: 1.1rem; line-height: 1; }
.callout .section-heading { margin: 0; }
.callout p { margin-bottom: 0; font-size: 0.9rem; }
h2.section-heading { color: var(--text-muted); font-size: 0.78rem; margin: 0 0 1rem; }
h2.section-heading::before { display: none; }

/* ── Layout ────────────────────────────────────────────────────────────────── */
.layout { display: flex; height: 100vh; overflow: hidden; position: relative; z-index: 5; }

.sidebar {
    width: 210px;
    min-width: 210px;
    background: rgba(11,11,14,0.3);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-right: 1px solid rgba(255,255,255,0.06);
    display: flex;
    flex-direction: column;
    padding: 1rem 0;
    box-shadow: 2px 0 16px rgba(0,0,0,0.2);
}

.sidebar-header {
    padding: 0.5rem 1.2rem 1.2rem;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 0.5rem;
}

@keyframes logo-gradient-scroll {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes logo-halo-pulse {
    0%   { opacity: 0.08; transform: translate(-50%, -50%) scale(0.88); }
    50%  { opacity: 0.25; transform: translate(-50%, -50%) scale(1.04); }
    100% { opacity: 0.08; transform: translate(-50%, -50%) scale(0.88); }
}

.lain-logo {
    position: relative;
    display: inline-block;
    isolation: isolate;
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: 0.15em;
    background: linear-gradient(90deg, var(--primary), var(--accent), var(--primary));
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: logo-gradient-scroll 3s ease infinite;
}

.lain-logo::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    transform-origin: center center;
    background: radial-gradient(ellipse at center, var(--accent) 0%, var(--primary) 50%, transparent 75%);
    filter: blur(14px);
    border-radius: 50%;
    z-index: -1;
    animation: logo-halo-pulse 6s ease-in-out infinite;
    pointer-events: none;
}

.nav-list { list-style: none; padding: 0; }
.nav-list li a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 1.2rem;
    color: var(--text-muted);
    transition: background 0.18s, color 0.18s, border-color 0.18s;
    border-left: 3px solid transparent;
    font-size: 0.9rem;
}
.nav-list li a:hover {
    background: rgba(167,139,250,0.06);
    color: var(--text);
    border-left-color: rgba(167,139,250,0.3);
}
.nav-list li a.active {
    color: var(--primary);
    border-left-color: var(--primary);
    background: rgba(167,139,250,0.1);
    font-weight: 600;
}
.nav-icon { font-size: 1rem; }

.main-content { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }

.top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.45rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    background: rgba(11,11,14,0.25);
    backdrop-filter: blur(16px);
    font-size: 0.8rem;
    position: sticky;
    top: 0;
    z-index: 10;
}

.agent-status { display: flex; align-items: center; gap: 0.5rem; color: var(--ok); font-weight: 500; }
.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ok);
    box-shadow: 0 0 8px var(--ok);
    animation: statusPulse 2.5s ease-in-out infinite;
}
@keyframes statusPulse {
    0%, 100% { box-shadow: 0 0 6px var(--ok); opacity: 1; }
    50% { box-shadow: 0 0 12px var(--ok); opacity: 0.75; }
}

.content { padding: 1.5rem 2rem; flex: 1; }

/* ── Dashboard ─────────────────────────────────────────────────────────────── */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.card {
    background: linear-gradient(135deg, var(--surface) 0%, rgba(28,28,36,0.9) 100%);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem 1.25rem;
    position: relative;
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.card::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    opacity: 0.6;
}
.card:hover {
    border-color: var(--primary-dim);
    box-shadow: 0 4px 20px rgba(167,139,250,0.12);
    transform: translateY(-1px);
}
.card-title {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 500;
}
.card-value {
    font-size: 1.65rem;
    font-weight: 700;
    margin-top: 0.35rem;
    color: var(--text);
    line-height: 1.1;
}
.status-ok { color: var(--ok); text-shadow: 0 0 12px rgba(74,222,128,0.35); }

/* ── Use-case cards (dashboard) ────────────────────────────────────────────── */
.use-cases-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.use-case-card {
    background: linear-gradient(135deg, var(--surface2) 0%, rgba(18,18,26,0.95) 100%);
    border: 1px solid #3a3a50;
    border-radius: 10px;
    padding: 1.1rem 1.2rem;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.use-case-card:hover {
    border-color: var(--primary-dim);
    box-shadow: 0 4px 16px rgba(167,139,250,0.12);
    transform: translateY(-2px);
}
.use-case-icon { font-size: 1.5rem; margin-bottom: 0.4rem; }
.use-case-title { font-weight: 700; font-size: 0.9rem; margin-bottom: 0.3rem; color: var(--text); }
.use-case-desc { font-size: 0.82rem; color: var(--text-muted); line-height: 1.5; }

/* ── Persona cards ────────────────────────────────────────────────────────── */
.persona-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.persona-card {
    background: linear-gradient(135deg, var(--surface2) 0%, rgba(20,20,28,0.95) 100%);
    border: 1px solid #3a3a50;
    border-radius: 10px;
    padding: 1.2rem 1.3rem;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
    cursor: default;
}
.persona-card:hover {
    border-color: rgba(167,139,250,0.5);
    box-shadow: 0 4px 20px rgba(167,139,250,0.1);
    transform: translateY(-2px);
}
.persona-title {
    font-weight: 700;
    font-size: 0.97rem;
    color: var(--primary);
    margin-bottom: 0.55rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.persona-who { font-size: 0.83rem; color: var(--text-muted); line-height: 1.6; }

/* ── Features grid ───────────────────────────────────────────────────────── */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.feature-card {
    background: linear-gradient(145deg, var(--surface2) 0%, rgba(18,18,26,0.97) 100%);
    border: 1px solid #3a3a50;
    border-radius: 12px;
    padding: 1.2rem 1.3rem;
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    overflow: hidden;
}
.feature-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(167,139,250,0.04) 0%, transparent 60%);
    pointer-events: none;
}
.feature-card:hover {
    border-color: var(--primary);
    transform: translateY(-3px);
    box-shadow: 0 8px 28px rgba(167,139,250,0.15), 0 2px 8px rgba(0,0,0,0.4);
}
.feature-icon {
    font-size: 1.5rem;
    line-height: 1;
    flex-shrink: 0;
    width: 2.4rem;
    height: 2.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(167,139,250,0.1);
    border: 1px solid rgba(167,139,250,0.2);
    border-radius: 8px;
}
.feature-body { flex: 1; min-width: 0; }
.feature-title {
    font-weight: 700;
    font-size: 0.92rem;
    color: var(--accent);
    margin-bottom: 0.5rem;
    letter-spacing: 0.01em;
}
.feature-bullets {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.feature-bullets li {
    font-size: 0.81rem;
    color: var(--text-muted);
    line-height: 1.5;
    padding-left: 0.9rem;
    position: relative;
}
.feature-bullets li::before {
    content: '›';
    position: absolute;
    left: 0;
    color: var(--primary);
    opacity: 0.7;
    font-weight: 700;
}

/* ── Table ─────────────────────────────────────────────────────────────────── */
.lain-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    margin-top: 0.5rem;
}
.lain-table th {
    text-align: left;
    padding: 0.5rem 0.8rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.lain-table td {
    padding: 0.5rem 0.8rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
.lain-table tr:last-child td { border-bottom: none; }
.lain-table tr:hover td { background: var(--surface2); }

/* ── Chat ─────────────────────────────────────────────────────────────────── */
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 130px);
    position: relative;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding: 1rem 0;
}

.chat-message { display: flex; flex-direction: column; }
.chat-message.user { align-items: flex-end; }
.chat-message.assistant { align-items: flex-start; }

/* Wrapper gives the bubble a positioning context for the speak button */
.chat-bubble-wrapper {
    position: relative;
    max-width: 70%;
}
.chat-message.user .chat-bubble-wrapper { align-self: flex-end; }

.chat-bubble {
    width: 100%;
    padding: 0.55rem 0.9rem;
    border-radius: 12px;
    line-height: 1.55;
    font-size: 0.92rem;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* Noise grain — sits inside the bubble, composited before the blur reads it */
.chat-bubble::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    opacity: 0.07;
    mix-blend-mode: overlay;
    border-radius: inherit;
    pointer-events: none;
    z-index: 0;
}

.chat-message.user .chat-bubble { background: rgba(109,87,196,0.5); color: #fff; }
.chat-message.assistant .chat-bubble { background: rgba(24,24,31,0.55); border: 1px solid rgba(39,39,58,0.6); color: var(--text); }

.chat-bubble-time {
    font-size: 0.7rem;
    opacity: 0.45;
    margin-top: 0.2rem;
    padding: 0 0.25rem;
    color: var(--text);
    user-select: none;
}

.thinking { opacity: 0.5; font-style: italic; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 0.4; } 50% { opacity: 0.9; } }

/* ── Thinking bubble + skill activity ───────────────────────────────────── */
.thinking-bubble { display: flex; flex-direction: column; gap: 0; }

.skill-activity-list {
    list-style: none;
    margin: 0.35rem 0 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.18rem;
    border-top: 1px solid rgba(255,255,255,0.07);
    padding-top: 0.35rem;
}

.skill-activity-item {
    font-size: 0.76rem;
    opacity: 0.65;
    padding-left: 1.1rem;
    position: relative;
    line-height: 1.4;
    animation: skillFadeIn 0.25s ease both;
}

.skill-activity-item::before {
    content: '◈';
    position: absolute;
    left: 0;
    opacity: 0.5;
    font-size: 0.6rem;
    top: 0.18rem;
    animation: pulse 1.8s ease-in-out infinite;
}

@keyframes skillFadeIn {
    from { opacity: 0; transform: translateY(3px); }
    to   { opacity: 0.65; transform: translateY(0); }
}

/* ── Fractal noise overlay — above blur, below UI ———————————————— */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 4;
    opacity: 0.10;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ── Thinking aura ───────────────────────────────────────────────────────── */
.lain-thinking-aura {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    opacity: 0.35;
    transition: opacity 0.9s ease;
    overflow: hidden;
}

/* Orbs — background is driven by a Perlin-noise canvas (chat.js _initAura).
   No border-radius/overflow:hidden — the Gaussian envelope already fades to
   transparent, so clipping to a circle would kill the organic irregular edge.
   filter:blur softens the upscaled 128px canvas before compositing (no GPU
   re-quantisation — unlike backdrop-filter this blurs the source, not the dest). */
.lain-aura-orb {
    position: absolute;
    opacity: 1;
    mix-blend-mode: screen;
    will-change: transform;
    filter: blur(15px);
}
.lain-aura-orb canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* Orb 1 — violet, coin haut-gauche */
.lain-aura-orb-1 {
    width: 130%; height: 120%;
    top: -40%; left: -40%;
    animation: lain-aura-drift-a 47s ease-in-out infinite alternate;
}
/* Orb 2 — teal, coin bas-droit */
.lain-aura-orb-2 {
    width: 120%; height: 110%;
    bottom: -40%; right: -35%;
    animation: lain-aura-drift-b 59s ease-in-out infinite alternate;
}
/* Orb 3 — mauve, coin bas-gauche */
.lain-aura-orb-3 {
    width: 110%; height: 100%;
    bottom: -35%; left: -25%;
    animation: lain-aura-drift-c 53s ease-in-out infinite alternate;
}
/* Orb 4 — bleu, coin haut-droit */
.lain-aura-orb-4 {
    width: 105%; height: 95%;
    top: -30%; right: -30%;
    animation: lain-aura-drift-d 41s ease-in-out infinite alternate;
}

@keyframes lain-aura-drift-a {
    0%   { transform: translate(0,   0)   scale(1);    }
    28%  { transform: translate(4%,  3%)  scale(1.04); }
    55%  { transform: translate(-2%, 6%)  scale(0.97); }
    78%  { transform: translate(5%,  1%)  scale(1.02); }
    100% { transform: translate(2%,  5%)  scale(1.03); }
}
@keyframes lain-aura-drift-b {
    0%   { transform: translate(0,    0)   scale(1);    }
    35%  { transform: translate(-4%,  3%)  scale(1.03); }
    62%  { transform: translate(3%,  -4%)  scale(0.97); }
    85%  { transform: translate(-2%, -2%)  scale(1.02); }
    100% { transform: translate(-5%, -3%)  scale(1.01); }
}
@keyframes lain-aura-drift-c {
    0%   { transform: translate(0,  0)    scale(1);    }
    32%  { transform: translate(3%, -4%)  scale(1.03); }
    60%  { transform: translate(-3%, 3%)  scale(0.98); }
    82%  { transform: translate(4%,  2%)  scale(1.02); }
    100% { transform: translate(2%,  4%)  scale(1.01); }
}
@keyframes lain-aura-drift-d {
    0%   { transform: translate(0,   0)   scale(1);    }
    40%  { transform: translate(-3%, 4%)  scale(1.03); }
    70%  { transform: translate(4%, -2%)  scale(0.97); }
    88%  { transform: translate(-2%, 3%)  scale(1.02); }
    100% { transform: translate(-4%, 2%)  scale(1.02); }
}

@keyframes lain-aura-pulse {
    0%, 100% { 
        opacity: 1; 
        filter: blur(15px) brightness(1);
    }
    50% { 
        opacity: 1; 
        filter: blur(15px) brightness(2.5);
    }
}

.lain-aura-orb.pulsing {
    animation-name: lain-aura-pulse;
    animation-duration: 1.5s;
    animation-timing-function: ease-in-out;
}

/* Make sure the chat content renders above the aura */
.chat-messages { position: relative; z-index: 1; }
.chat-input-area,
.chat-choice-prompt { position: relative; z-index: 1; }

/* ── Images inside sent messages ─────────────────────────────────────────── */
.chat-message-images {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    max-width: 70%;
    margin-bottom: 0.3rem;
}

.chat-message.user .chat-message-images { justify-content: flex-end; }
.chat-message.assistant .chat-message-images { justify-content: flex-start; }

.chat-message-image {
    width: 180px;
    height: 180px;
    object-fit: cover;
    border-radius: 10px;
    border: 2px solid var(--primary-dim);
    background: var(--surface2);
    cursor: zoom-in;
    transition: transform 0.15s, box-shadow 0.15s;
    display: block;
}

.chat-message-image:hover {
    transform: scale(1.03);
    box-shadow: 0 4px 16px rgba(0,0,0,0.35);
}

/* Single image: allow it to be a bit wider */
.chat-message-images:has(.chat-message-image:only-child) .chat-message-image {
    width: 260px;
    height: 220px;
}

/* ── Markdown inside chat bubbles ─────────────────────────────────────────── */
.markdown-body { color: inherit; }
.markdown-body p { margin: 0 0 0.4em; color: inherit; }
.markdown-body p:last-child { margin-bottom: 0; }
.markdown-body ul, .markdown-body ol { margin: 0.3em 0 0.4em 1.3em; padding: 0; }
.markdown-body li { margin-bottom: 0.2em; }
.markdown-body code {
    font-family: 'Consolas', 'Fira Code', monospace;
    font-size: 0.85em;
    background: rgba(0,0,0,0.25);
    padding: 0.1em 0.35em;
    border-radius: 4px;
}
.markdown-body pre {
    background: rgba(0,0,0,0.35);
    border-radius: 6px;
    padding: 0.7rem 1rem;
    overflow-x: auto;
    margin: 0.4em 0;
}
.markdown-body pre code { background: none; padding: 0; font-size: 0.82em; }
.markdown-body h1, .markdown-body h2, .markdown-body h3 {
    font-size: 1em;
    font-weight: 700;
    margin: 0.5em 0 0.2em;
}
.markdown-body a { color: #38bdf8; text-decoration: underline; text-underline-offset: 2px; }
.markdown-body a:hover { text-decoration: none; }
.markdown-body strong { font-weight: 700; }
.markdown-body em { font-style: italic; }
.markdown-body hr { border: none; border-top: 1px solid var(--border); margin: 0.5em 0; }
.markdown-body blockquote {
    border-left: 3px solid var(--primary);
    margin: 0.3em 0;
    padding-left: 0.7em;
    opacity: 0.8;
}

.chat-input-row {
    display: flex;
    gap: 0.6rem;
    padding-top: 0.8rem;
    border-top: 1px solid var(--border);
}

.chat-input {
    flex: 1;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.55rem 0.9rem;
    color: var(--text);
    font-size: 0.92rem;
    outline: none;
    transition: border-color 0.15s;
    resize: none;
    min-height: 2.4rem;
    max-height: 12rem;
    overflow-y: auto;
    line-height: 1.45;
    font-family: inherit;
    field-sizing: content;
}
.chat-input:focus { border-color: var(--primary); }
.chat-input:disabled { opacity: 0.5; }

.btn-send {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0.55rem 1.2rem;
    font-size: 0.92rem;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.15s;
}
.btn-send:hover:not(:disabled) { background: var(--primary-dim); }
.btn-send:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-new-chat {
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.55rem 0.8rem;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-new-chat:hover:not(:disabled) { background: var(--surface3, var(--surface2)); }
.btn-new-chat:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-mic {
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.55rem 0.75rem;
    font-size: 1.05rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
    flex-shrink: 0;
}
.btn-mic:hover:not(:disabled) { background: var(--surface3, var(--surface2)); }
.btn-mic:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-mic--active {
    background: rgba(220, 38, 38, 0.12);
    border-color: #dc2626;
    color: #dc2626;
    animation: mic-pulse 1.4s ease-in-out infinite;
}

@keyframes mic-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.45); }
    50%       { box-shadow: 0 0 0 7px rgba(220, 38, 38, 0); }
}

.btn-speak {
    position: absolute;
    top: 0.35rem;
    right: 0.4rem;
    background: rgba(6, 6, 18, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    color: var(--text);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 5px;
    padding: 0.1rem 0.4rem;
    font-size: 0.78rem;
    line-height: 1.4;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
    z-index: 2;
}
.chat-bubble-wrapper:hover .btn-speak {
    opacity: 1;
    pointer-events: auto;
}
.btn-speak:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* ── Full-window drag overlay ─────────────────────────────────────────────── */
.lain-drop-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(6, 6, 18, 0.55);
    backdrop-filter: blur(10px) saturate(1.4);
    -webkit-backdrop-filter: blur(10px) saturate(1.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
}

.lain-drop-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.lain-drop-overlay-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 3.5rem 6rem;
    border-radius: 28px;
    border: 2px dashed var(--primary, #6366f1);
    background: rgba(99, 102, 241, 0.06);
    box-shadow:
        0 0 0 1px rgba(99, 102, 241, 0.15),
        0 0 60px rgba(99, 102, 241, 0.25),
        inset 0 0 50px rgba(99, 102, 241, 0.04);
    animation: lain-overlay-pulse 2s ease-in-out infinite;
    transform: scale(1);
    transition: transform 0.18s ease;
}

.lain-drop-overlay.active .lain-drop-overlay-inner {
    transform: scale(1);
}

.lain-drop-overlay-icon {
    width: 72px;
    height: 72px;
    color: var(--primary, #6366f1);
    filter: drop-shadow(0 0 14px rgba(99, 102, 241, 0.7));
    animation: lain-overlay-bob 1.4s ease-in-out infinite;
    flex-shrink: 0;
}

.lain-drop-overlay-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.04em;
    text-shadow: 0 0 24px rgba(99, 102, 241, 0.8), 0 2px 8px rgba(0,0,0,0.4);
}

.lain-drop-overlay-sub {
    font-size: 0.9rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.55);
    letter-spacing: 0.02em;
}

@keyframes lain-overlay-pulse {
    0%, 100% {
        box-shadow:
            0 0 0 1px rgba(99, 102, 241, 0.15),
            0 0 60px rgba(99, 102, 241, 0.25),
            inset 0 0 50px rgba(99, 102, 241, 0.04);
        border-color: var(--primary, #6366f1);
    }
    50% {
        box-shadow:
            0 0 0 2px rgba(99, 102, 241, 0.3),
            0 0 90px rgba(99, 102, 241, 0.45),
            inset 0 0 70px rgba(99, 102, 241, 0.08);
        border-color: rgba(149, 151, 255, 0.9);
    }
}

@keyframes lain-overlay-bob {
    0%, 100% { transform: translateY(0) scale(1);   }
    50%       { transform: translateY(-9px) scale(1.08); }
}

/* ── Image preview strip ──────────────────────────────────────────────────── */
.chat-image-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem 0 0.4rem;
}

.chat-image-thumb {
    position: relative;
    width: 72px;
    height: 72px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.chat-image-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.chat-image-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 0.65rem;
    line-height: 18px;
    text-align: center;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.1s;
}

.chat-image-remove:hover { background: rgba(220, 38, 38, 0.8); }

/* ── Choice prompt ────────────────────────────────────────────────────────── */
.chat-choice-prompt {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding-top: 0.8rem;
    border-top: 1px solid var(--border);
}

.chat-choice-question {
    font-size: 0.92rem;
    color: var(--text-muted);
    font-style: italic;
}

.chat-choice-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.btn-choice {
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--primary);
    border-radius: 20px;
    padding: 0.4rem 1rem;
    font-size: 0.88rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}
.btn-choice:hover {
    background: var(--primary);
    color: #fff;
}

/* ── Config ────────────────────────────────────────────────────────────────── */
.config-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.2rem 1.4rem;
    margin-bottom: 1.2rem;
}

.config-section-secrets {
    border-color: var(--warn);
}

.form-grid {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 0.6rem 1rem;
    align-items: center;
    font-size: 0.88rem;
    margin-top: 0.6rem;
}
.form-grid label { color: var(--text-muted); }

.form-input, .form-select {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.4rem 0.7rem;
    color: var(--text);
    font-size: 0.88rem;
    font-family: var(--font);
    width: 100%;
    outline: none;
    transition: border-color 0.15s;
}
.form-input:focus, .form-select:focus { border-color: var(--primary); }

.form-input-secret { font-family: var(--font-mono); letter-spacing: 0.05em; }

.form-readonly { display: flex; flex-direction: column; gap: 0.2rem; }
.form-hint { font-size: 0.78rem; color: var(--text-muted); }

.secret-field { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.secret-field .form-input { flex: 1; min-width: 0; }

.secret-badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
}
.secret-badge-set   { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.secret-badge-unset { background: var(--surface2); color: var(--text-muted); }

.secrets-notice {
    font-size: 0.83rem;
    color: var(--text-muted);
    background: color-mix(in srgb, var(--warn) 8%, transparent);
    border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
    border-radius: 6px;
    padding: 0.5rem 0.8rem;
    margin-bottom: 0.8rem;
}
.secrets-notice strong { color: var(--warn); }

.save-row { display: flex; justify-content: flex-end; margin-top: 0.4rem; }
.btn-save { padding: 0.55rem 2rem; font-size: 0.92rem; }

.btn-danger {
    background: transparent;
    border: 1px solid var(--error);
    color: var(--error);
    border-radius: 6px;
    padding: 0.25rem 0.7rem;
    font-size: 0.78rem;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-danger:hover { background: color-mix(in srgb, var(--error) 15%, transparent); }
.btn-sm { padding: 0.2rem 0.6rem; font-size: 0.75rem; }

.feedback {
    border-radius: 6px;
    padding: 0.5rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.88rem;
}
.feedback-ok    { background: color-mix(in srgb, var(--ok)    12%, transparent); color: var(--ok);    border: 1px solid color-mix(in srgb, var(--ok)    30%, transparent); }
.feedback-error { background: color-mix(in srgb, var(--error) 12%, transparent); color: var(--error); border: 1px solid color-mix(in srgb, var(--error) 30%, transparent); }


.search-row { display: flex; gap: 0.6rem; margin-bottom: 1rem; }

.status-stub {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 4px;
    background: var(--surface2);
    color: var(--warn);
    font-size: 0.8rem;
}

/* ── Spinner ───────────────────────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid color-mix(in srgb, var(--primary) 30%, transparent);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
    margin-right: 0.35rem;
}
.spinner-sm { width: 12px; height: 12px; }

/* ── Ollama install banner ──────────────────────────────────────────────────── */
.ollama-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 1rem;
    padding: 0.9rem 1.1rem;
    margin-bottom: 1.1rem;
    border-radius: 8px;
    border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
    background: color-mix(in srgb, var(--warn) 8%, transparent);
}
.ollama-banner-body { flex: 1 1 260px; }
.ollama-banner-body strong { color: var(--warn); display: block; margin-bottom: 0.3rem; }
.ollama-banner-body p { margin: 0 0 0.4rem; font-size: 0.88rem; color: var(--text-muted); }
.ollama-banner-actions { display: flex; align-items: center; gap: 0.75rem; flex-shrink: 0; }
.ollama-install-output {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
}
.ollama-status {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.88rem;
    padding: 0.4rem 0.7rem;
    border-radius: 6px;
    margin-bottom: 0.8rem;
}
.ollama-status-ok {
    color: var(--ok);
    background: color-mix(in srgb, var(--ok) 10%, transparent);
    border: 1px solid color-mix(in srgb, var(--ok) 25%, transparent);
}
.ollama-status-checking {
    color: var(--text-muted);
    background: var(--surface2);
    border: 1px solid var(--border);
}
.btn-link {
    font-size: 0.85rem;
    color: var(--primary);
    text-decoration: none;
    opacity: 0.85;
}
.btn-link:hover { opacity: 1; text-decoration: underline; }

/* ── Ollama URL test row ────────────────────────────────────────────────────── */
.url-test-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.url-test-row .form-input { flex: 1; min-width: 0; }
.btn-test {
    flex-shrink: 0;
    padding: 0.35rem 0.75rem;
    font-size: 0.82rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    transition: background 0.15s;
}
.btn-test:hover:not(:disabled) { background: var(--surface3, var(--surface2)); border-color: var(--primary); }
.btn-test:disabled { opacity: 0.45; cursor: not-allowed; }
.reach-badge {
    font-size: 0.8rem;
    padding: 2px 8px;
    border-radius: 999px;
    white-space: nowrap;
    align-self: center;
}
.reach-ok      { background: color-mix(in srgb, var(--ok)    12%, transparent); color: var(--ok);         border: 1px solid color-mix(in srgb, var(--ok)    28%, transparent); }
.reach-err     { background: color-mix(in srgb, var(--error) 12%, transparent); color: var(--error);      border: 1px solid color-mix(in srgb, var(--error) 28%, transparent); cursor: help; }
.reach-checking{ background: var(--surface2);                                   color: var(--text-muted);  border: 1px solid var(--border); }

/* ── Scrollbar ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Agent Trace ─────────────────────────────────────────────────── */
.trace-details {
    max-width: 660px;
    margin-top: 0.3rem;
    font-size: 0.78rem;
}
.trace-summary {
    cursor: pointer;
    color: var(--text-muted);
    user-select: none;
    padding: 0.15rem 0.3rem;
    border-radius: 4px;
}
.trace-summary:hover { color: var(--primary); }
.trace-body {
    margin-top: 0.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    border-left: 2px solid var(--border);
    padding-left: 0.7rem;
}
.trace-event {
    display: grid;
    grid-template-columns: 80px 70px 1fr;
    gap: 0.3rem;
    align-items: baseline;
}
.trace-type {
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: 1px 5px;
    border-radius: 3px;
    white-space: nowrap;
}
.trace-time {
    color: var(--text-muted);
    font-size: 0.7rem;
    font-family: monospace;
}
.trace-content {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: monospace;
    font-size: 0.75rem;
    color: var(--text);
}
/* per-type colours */
.trace-thought     .trace-type { background: color-mix(in srgb, #a78bfa 15%, transparent); color: #a78bfa; }
.trace-action      .trace-type { background: color-mix(in srgb, var(--primary) 15%, transparent); color: var(--primary); }
.trace-actioninput .trace-type { background: color-mix(in srgb, #60a5fa 15%, transparent); color: #60a5fa; }
.trace-observation .trace-type { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.trace-finalanswer .trace-type { background: color-mix(in srgb, #34d399 15%, transparent); color: #34d399; }
.trace-warning     .trace-type { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }
.trace-info        .trace-type { background: var(--surface2); color: var(--text-muted); }
.trace-llminput      .trace-type { background: color-mix(in srgb, #f59e0b 15%, transparent); color: #f59e0b; }
.trace-llmoutput     .trace-type { background: color-mix(in srgb, #a78bfa 15%, transparent); color: #a78bfa; }
.trace-systemprompt  .trace-type { background: color-mix(in srgb, #94a3b8 15%, transparent); color: #94a3b8; }

/* ── Sessions panel (sidebar conversations) ───────────────────────────────── */
.sessions-panel {
    margin-top: auto;
    border-top: 1px solid var(--border);
    padding-top: 0.6rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sessions-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.3rem 1.2rem 0.4rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.sessions-list {
    list-style: none;
    padding: 0;
    overflow-y: auto;
    max-height: 220px;
}

.session-item {
    display: flex;
    align-items: stretch;
}

.session-item .session-link {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    padding: 0.4rem 0.6rem 0.4rem 1.2rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    border-left: 3px solid transparent;
    transition: background 0.13s, color 0.13s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
.session-item .session-link:hover { background: var(--surface2); color: var(--text); }
.session-item .session-link.active { color: var(--primary); border-left-color: var(--primary); background: var(--surface2); }

/* Keep backward-compat for pinned MainSession (no .session-item wrapper) */
.sessions-list li .session-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    padding: 0.4rem 1.2rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    border-left: 3px solid transparent;
    transition: background 0.13s, color 0.13s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sessions-list li .session-link:hover { background: var(--surface2); color: var(--text); }
.sessions-list li .session-link.active { color: var(--primary); border-left-color: var(--primary); background: var(--surface2); }

.btn-archive-session {
    flex-shrink: 0;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0 0.5rem;
    font-size: 0.72rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.13s, color 0.13s;
    line-height: 1;
}
.session-item:hover .btn-archive-session { opacity: 1; }
.btn-archive-session:hover { color: var(--danger, #e05); }

.session-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.session-unread {
    flex-shrink: 0;
    min-width: 18px;
    height: 18px;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    animation: pulse-badge 1.5s ease-in-out infinite;
}

.unread-badge {
    min-width: 18px;
    height: 18px;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

@keyframes pulse-badge {
    0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--primary) 60%, transparent); }
    50%       { box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 0%, transparent); }
}

/* ── Chat read-only sessions ───────────────────────────────────────────────── */
.chat-readonly-banner {
    padding: 0.6rem 1rem;
    border-top: 1px solid var(--border);
    font-size: 0.82rem;
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
}

/* Reply button shown on each assistant bubble in read-only task sessions */
.btn-reply-inline {
    display: inline-block;
    margin-top: 0.45rem;
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
    border-radius: 6px;
    padding: 0.2rem 0.65rem;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.13s, color 0.13s;
    opacity: 0.75;
}
.btn-reply-inline:hover:not(:disabled) {
    background: var(--primary);
    color: #fff;
    opacity: 1;
}
.btn-reply-inline:disabled { opacity: 0.3; cursor: not-allowed; }

/* ── Schedule connector field ──────────────────────────────────────────────── */
.schedule-connector-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}
.schedule-connector-row .form-input { flex: 1; min-width: 100px; }

/* ── Schedule ──────────────────────────────────────────────────────────────── */
.schedule-empty {
    text-align: center;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: 8px;
    margin-bottom: 1rem;
}

.schedule-form-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.4rem;
    margin-top: 1.4rem;
}

.schedule-textarea {
    resize: vertical;
    min-height: 72px;
    font-family: var(--font);
}

.schedule-cron-helpers {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.4rem;
}

.schedule-cron-preset {
    font-size: 0.75rem;
    padding: 2px 9px;
    border-radius: 4px;
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}
.schedule-cron-preset:hover { background: var(--surface); color: var(--primary); border-color: var(--primary); }

.schedule-toggle { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; font-size: 0.88rem; color: var(--text); }
.schedule-toggle input[type=checkbox] { accent-color: var(--primary); width: 16px; height: 16px; }

.schedule-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}
.schedule-badge-ok       { background: color-mix(in srgb, var(--ok)    12%, transparent); color: var(--ok);    border: 1px solid color-mix(in srgb, var(--ok)    28%, transparent); }
.schedule-badge-error    { background: color-mix(in srgb, var(--error) 12%, transparent); color: var(--error); border: 1px solid color-mix(in srgb, var(--error) 28%, transparent); }
.schedule-badge-disabled { background: var(--surface2); color: var(--text-muted); border: 1px solid var(--border); }
.schedule-badge-pending  { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent); }
.schedule-badge-running  { background: color-mix(in srgb, #f59e0b 14%, transparent); color: #d97706; border: 1px solid color-mix(in srgb, #f59e0b 32%, transparent); animation: badge-pulse 1.4s ease-in-out infinite; }
@keyframes badge-pulse   { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

.text-muted-sm { font-size: 0.8rem; color: var(--text-muted); }

.btn-icon {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 5px;
    padding: 2px 7px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
    margin-left: 2px;
}
.btn-icon:hover:not(:disabled) { background: var(--surface2); color: var(--primary); border-color: var(--primary); }
.btn-icon:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-icon-danger:hover:not(:disabled) { color: var(--error); border-color: var(--error); }

/* ── Visual schedule builder ───────────────────────────────────────────────── */
.sched-builder {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.sched-freq-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.sched-pill {
    padding: 0.3rem 0.9rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text-muted);
    font-size: 0.82rem;
    cursor: pointer;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.sched-pill:hover { border-color: var(--primary); color: var(--text); }
.sched-pill-active {
    background: color-mix(in srgb, var(--primary) 18%, transparent);
    border-color: var(--primary);
    color: var(--primary);
    font-weight: 600;
}

.sched-secondary {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    min-height: 2rem;
}
.sched-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}
.sched-select-sm {
    width: auto !important;
    min-width: 0;
    padding: 0.3rem 0.5rem;
}
.sched-preview {
    font-size: 0.78rem;
    color: var(--accent);
    white-space: nowrap;
    margin-left: auto;
    font-style: italic;
}

/* ── Memory timeline ───────────────────────────────────────────────────────── */
.mem-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin-bottom: 0.9rem;
    flex-wrap: wrap;
}

.mem-crumb {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.82rem;
    cursor: pointer;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    transition: color 0.12s, background 0.12s;
}
.mem-crumb:hover { color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, transparent); }
.mem-crumb-active { color: var(--primary) !important; font-weight: 600; }

.mem-crumb-sep {
    color: var(--text-muted);
    font-size: 0.78rem;
    user-select: none;
}

.mem-timeline-row {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    margin-bottom: 0.55rem;
    flex-wrap: wrap;
}

.mem-timeline-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    min-width: 42px;
}

.mem-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.mem-pill {
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 6px;
    padding: 0.25rem 0.75rem;
    font-size: 0.82rem;
    cursor: pointer;
    transition: background 0.13s, color 0.13s, border-color 0.13s;
    font-weight: 500;
}
.mem-pill:hover { background: var(--surface); color: var(--text); border-color: var(--primary); }
.mem-pill-active {
    background: color-mix(in srgb, var(--primary) 18%, transparent);
    border-color: var(--primary);
    color: var(--primary);
}

.mem-content-panel {
    margin-top: 1.4rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.mem-content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface2);
}

.mem-content-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.mem-content-body {
    padding: 1.2rem 1.4rem;
    font-size: 0.9rem;
    line-height: 1.7;
    max-height: 60vh;
    overflow-y: auto;
}

.mem-content-empty {
    color: var(--text-muted);
    font-style: italic;
}

/* Wider headings inside recap markdown */
.mem-content-body.markdown-body h1 { font-size: 1.3em; }
.mem-content-body.markdown-body h2 { font-size: 1.1em; }
.mem-content-body.markdown-body h3 { font-size: 1em; }

/* ── Workspace browser ──────────────────────────────────────────────────────── */
.workspace-page {
    /* Pull back the .content padding so the browser fills edge-to-edge vertically */
    margin: -1.5rem -2rem;
    height: calc(100vh - 88px); /* 100vh minus top-row (~44px) + top-row border + a sliver */
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.workspace-browser {
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    min-height: 0;
    padding: 1rem 1.5rem;
}

.workspace-split {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
    flex: 1 1 0;
    min-height: 0;
}

.workspace-split.has-preview {
    grid-template-columns: 1fr 1fr;
}

/* Explorer (left pane) */
.workspace-explorer {
    display: flex;
    flex-direction: column;
    gap: .75rem;
    min-height: 0;
    overflow: hidden;
}

.workspace-toolbar {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    flex-wrap: wrap;
}

.workspace-root-hint {
    font-size: .75rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.workspace-crumbs {
    flex-shrink: 0;
}

.workspace-entries {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
    flex: 1 1 0;
    padding-right: .25rem;
}

.workspace-empty {
    color: var(--text-muted);
    font-style: italic;
    padding: .5rem 0;
}

.workspace-entry {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .45rem .75rem;
    border-radius: var(--radius);
    border: 1px solid transparent;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    text-align: left;
    font-size: .9rem;
    transition: background .15s, border-color .15s;
    width: 100%;
}

.workspace-entry:hover,
.workspace-entry.active {
    background: var(--surface3);
    border-color: var(--border);
}

.workspace-entry.active {
    border-color: var(--primary-dim);
}

.workspace-entry-dir {
    font-weight: 500;
}

.workspace-icon {
    flex-shrink: 0;
    font-size: 1rem;
    width: 1.4rem;
    text-align: center;
    font-family: var(--font-mono);
    color: var(--accent);
}

.workspace-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.workspace-size {
    flex-shrink: 0;
    font-size: .75rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* Preview (right pane) */
.workspace-preview {
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border);
    padding-left: 1rem;
    min-height: 0;
    overflow: hidden;
    flex: 1 1 0;
}

.workspace-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-bottom: .5rem;
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.workspace-preview-title-group {
    display: flex;
    align-items: center;
    gap: .4rem;
    overflow: hidden;
    flex: 1;
    min-width: 0;
}

.workspace-edit-inline-btn {
    flex-shrink: 0;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: .95rem;
    line-height: 1;
    padding: .1rem .2rem;
    border-radius: 4px;
    opacity: .6;
    transition: opacity .15s, color .15s;
}
.workspace-edit-inline-btn:hover { opacity: 1; color: var(--primary); }

.workspace-preview-actions {
    display: flex;
    align-items: center;
    gap: .4rem;
    flex-shrink: 0;
}

.workspace-action-btn {
    background: var(--surface3);
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    font-size: .8rem;
    padding: .2rem .55rem;
    border-radius: 5px;
    transition: background .15s, color .15s;
}
.workspace-action-btn:hover:not(:disabled) { background: var(--surface2); color: var(--text); }
.workspace-action-btn:disabled { opacity: .5; cursor: not-allowed; }

.workspace-save-btn {
    color: var(--ok);
    border-color: var(--ok);
}
.workspace-save-btn:hover:not(:disabled) { background: rgba(74,222,128,.1); color: var(--ok); }

.workspace-editor {
    flex: 1 1 0;
    resize: none;
    margin-top: .75rem;
    padding: .75rem 1rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: .82rem;
    line-height: 1.55;
    outline: none;
    width: 100%;
    overflow-y: auto;
}
.workspace-editor:focus { border-color: var(--primary-dim); box-shadow: 0 0 0 2px rgba(167,139,250,.15); }

.workspace-wysiwyg {
    flex: 1 1 0;
    margin-top: .75rem;
    overflow: hidden;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

/* ── Toast UI Editor integration ─────────────────────────────────────────── */

.workspace-wysiwyg .toastui-editor-defaultUI {
    height: 100%;
    display: flex;
    flex-direction: column;
    border: none !important;
}
.workspace-wysiwyg .toastui-editor-main,
.workspace-wysiwyg .toastui-editor-main-container {
    flex: 1 1 0 !important;
    overflow: hidden;
}
.workspace-wysiwyg .toastui-editor-ww-container {
    height: 100% !important;
}

/* ── Dark palette adjustments ─────────────────────────────────────────────── */
.workspace-wysiwyg .toastui-editor-dark .toastui-editor-toolbar,
.workspace-wysiwyg .toastui-editor-dark .toastui-editor-mode-switch {
    background-color: #1c1c27 !important;
    border-color: var(--border) !important;
}

/* Background */
.workspace-wysiwyg .toastui-editor-dark .toastui-editor-ww-container,
.workspace-wysiwyg .toastui-editor-dark .toastui-editor-md-container,
.workspace-wysiwyg .toastui-editor-dark .ProseMirror {
    background-color: #17171f !important;
}

/* Markdown mode: fill full height, no gap */
.workspace-wysiwyg .toastui-editor-dark .toastui-editor-md-container,
.workspace-wysiwyg .toastui-editor-md-container {
    height: 100% !important;
    flex: 1 1 0 !important;
    background-color: #17171f !important;
}
.workspace-wysiwyg .toastui-editor-dark .toastui-editor-md-container .CodeMirror,
.workspace-wysiwyg .toastui-editor-md-container .CodeMirror {
    background-color: #17171f !important;
    color: #ddddf0 !important;
    height: 100% !important;
}
.workspace-wysiwyg .toastui-editor-md-container .CodeMirror-scroll {
    background-color: #17171f !important;
}

/* ── TEXT: force readable light color on everything inside ProseMirror ──── */
.workspace-wysiwyg .toastui-editor-dark .ProseMirror {
    color: #ddddf0 !important;
    font-size: .9rem !important;
    line-height: 1.75 !important;
    caret-color: var(--primary) !important;
}
.workspace-wysiwyg .toastui-editor-dark .ProseMirror p,
.workspace-wysiwyg .toastui-editor-dark .ProseMirror li,
.workspace-wysiwyg .toastui-editor-dark .ProseMirror span:not([class]),
.workspace-wysiwyg .toastui-editor-dark .ProseMirror td,
.workspace-wysiwyg .toastui-editor-dark .ProseMirror th,
.workspace-wysiwyg .toastui-editor-dark .ProseMirror blockquote {
    color: #ddddf0 !important;
}

/* Headings */
.workspace-wysiwyg .toastui-editor-dark .ProseMirror h1,
.workspace-wysiwyg .toastui-editor-dark .ProseMirror h2,
.workspace-wysiwyg .toastui-editor-dark .ProseMirror h3,
.workspace-wysiwyg .toastui-editor-dark .ProseMirror h4 {
    color: var(--primary) !important;
    border-bottom: 1px solid var(--border) !important;
    padding-bottom: .2em !important;
}

/* Links */
.workspace-wysiwyg .toastui-editor-dark .ProseMirror a { color: var(--accent) !important; }

/* Inline code */
.workspace-wysiwyg .toastui-editor-dark .ProseMirror code {
    background: #292938 !important;
    color: #e8a87c !important;
    border-radius: 3px !important;
    padding: .1em .4em !important;
}

/* Code blocks */
.workspace-wysiwyg .toastui-editor-dark .ProseMirror pre {
    background: #1a1a28 !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius) !important;
    padding: .75rem 1rem !important;
}
.workspace-wysiwyg .toastui-editor-dark .ProseMirror pre code {
    background: transparent !important;
    color: #c8c8e8 !important;
    padding: 0 !important;
}

/* Blockquote */
.workspace-wysiwyg .toastui-editor-dark .ProseMirror blockquote {
    border-left: 3px solid var(--primary-dim) !important;
    margin-left: 0 !important;
    padding-left: 1em !important;
    color: #9898b8 !important;
}

/* Task list checkboxes */
.workspace-wysiwyg .toastui-editor-dark .ProseMirror .task-list-item input {
    accent-color: var(--primary) !important;
}

/* Table */
.workspace-wysiwyg .toastui-editor-dark .ProseMirror table { border-collapse: collapse !important; }
.workspace-wysiwyg .toastui-editor-dark .ProseMirror td,
.workspace-wysiwyg .toastui-editor-dark .ProseMirror th {
    border: 1px solid var(--border) !important;
    padding: .3em .6em !important;
}
.workspace-wysiwyg .toastui-editor-dark .ProseMirror th {
    background: #1c1c2e !important;
    color: var(--primary) !important;
}

/* Active mode tab accent */
.workspace-wysiwyg .toastui-editor-dark .toastui-editor-mode-switch .tab-item.active {
    border-top: 2px solid var(--primary) !important;
    color: var(--primary) !important;
}

/* ── Mode switch footer full restyle ─────────────────────────────────────── */
/* Target with and without .toastui-editor-dark to catch all render states  */
.workspace-wysiwyg .toastui-editor-mode-switch {
    background: #1c1c27 !important;
    border-top: 1px solid var(--border) !important;
    padding: 0 !important;
    height: 30px !important;
    display: flex !important;
    align-items: stretch !important;
    justify-content: flex-end !important;
}
.workspace-wysiwyg .toastui-editor-mode-switch .tab-item {
    background: transparent !important;
    border: none !important;
    border-left: 1px solid var(--border) !important;
    border-radius: 0 !important;
    color: #6a6a8a !important;
    font-size: .75rem !important;
    font-weight: 500 !important;
    letter-spacing: .03em !important;
    padding: 0 1rem !important;
    cursor: pointer !important;
    transition: color .15s, background .15s !important;
    display: flex !important;
    align-items: center !important;
}
.workspace-wysiwyg .toastui-editor-mode-switch .tab-item:hover {
    background: #24243a !important;
    color: #c0c0e0 !important;
}
.workspace-wysiwyg .toastui-editor-mode-switch .tab-item.active {
    background: transparent !important;
    color: var(--primary) !important;
    border-top: 2px solid var(--primary) !important;
    font-weight: 600 !important;
}

/* Hide status bar */
.workspace-wysiwyg .toastui-editor-status-bar { display: none !important; }

.workspace-save-ok {
    font-size: .8rem;
    color: var(--ok);
    margin-top: .4rem;
}

.workspace-preview-title {
    font-weight: 600;
    font-family: var(--font-mono);
    font-size: .9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--primary);
}

.workspace-close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: .15rem .3rem;
    border-radius: 4px;
    flex-shrink: 0;
}
.workspace-close-btn:hover { background: var(--surface3); color: var(--text); }

.workspace-preview-content {
    flex: 1 1 0;
    overflow: auto;
    margin-top: .75rem;
    font-family: var(--font-mono);
    font-size: .8rem;
    line-height: 1.55;
    white-space: pre;
    color: var(--text);
    background: var(--surface2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    padding: .75rem 1rem;
}

.workspace-preview-loading,
.workspace-preview-error {
    margin-top: .75rem;
    font-style: italic;
    color: var(--text-muted);
}
.workspace-preview-error { color: var(--error); }

.workspace-preview-md {
    flex: 1 1 0;
    overflow-y: auto;
    margin-top: .75rem;
    padding: 1rem 1.25rem;
    background: var(--surface2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    font-size: .88rem;
    line-height: 1.7;
    /* override .mem-content-body max-height which caps at 60vh */
    max-height: none;
}

/* ── CSV table preview ─────────────────────────────────────────────────────── */
.workspace-preview-csv {
    flex: 1 1 0;
    overflow: auto;
    margin-top: .75rem;
}
.workspace-csv-wrapper {
    width: 100%;
    height: 100%;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    background: var(--surface2);
}
.workspace-csv-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .8rem;
    font-family: var(--font-mono);
    white-space: nowrap;
}
.workspace-csv-table thead tr {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--surface3);
}
.workspace-csv-table th {
    padding: .45rem .75rem;
    text-align: left;
    font-weight: 600;
    color: var(--text);
    border-bottom: 2px solid var(--border-subtle);
    border-right: 1px solid var(--border-subtle);
}
.workspace-csv-table th:last-child,
.workspace-csv-table td:last-child { border-right: none; }
.workspace-csv-table td {
    padding: .35rem .75rem;
    color: var(--text);
    border-bottom: 1px solid var(--border-subtle);
    border-right: 1px solid var(--border-subtle);
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.workspace-csv-table tbody tr:hover { background: var(--surface3); }
.workspace-csv-table tbody tr:last-child td { border-bottom: none; }
.workspace-csv-table a {
    color: var(--accent);
    text-decoration: none;
}
.workspace-csv-table a:hover { text-decoration: underline; }
/* ── Browser Remote Control ─────────────────────────────────────────────────── */

.browser-panel {
    display: flex;
    flex-direction: column;
    gap: 0;
    height: calc(100vh - 8rem);
    min-height: 400px;
}

.browser-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.75rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius, 8px) var(--radius, 8px) 0 0;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.browser-tab-select {
    padding: 0.28rem 0.5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 5px;
    color: var(--text);
    font-size: 0.82rem;
    min-width: 70px;
    max-width: 160px;
}

.btn-browser {
    padding: 0.28rem 0.75rem;
    font-size: 0.82rem;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: opacity 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
}
.btn-browser:hover  { opacity: 0.82; }
.btn-browser-connect { background: var(--primary); color: #fff; }
.btn-browser-stop    { background: var(--error, #e53e3e); color: #fff; }
.btn-browser-nav {
    background: var(--surface3, #2a2a3a);
    color: var(--text);
    padding: 0.28rem 0.55rem;
    min-width: 1.8rem;
    font-size: 0.85rem;
    line-height: 1;
}
.btn-browser-close { font-size: 1rem; font-weight: 700; }
.btn-browser-nav:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}
.btn-browser-close:not(:disabled):hover {
    background: var(--error, #e53e3e);
    color: #fff;
    opacity: 1;
}

.browser-url-input {
    flex: 1;
    min-width: 120px;
    padding: 0.28rem 0.55rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 5px;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.browser-url-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 25%, transparent);
}
.browser-url-input:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.browser-fps {
    font-size: 0.7rem;
    color: var(--ok, #22c55e);
    font-family: var(--font-mono);
    flex-shrink: 0;
}

.browser-connecting {
    color: var(--text-muted);
    font-style: italic;
}

.browser-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid color-mix(in srgb, var(--primary) 25%, transparent);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: browser-spin 0.7s linear infinite;
}

@keyframes browser-spin {
    to { transform: rotate(360deg); }
}

.browser-error {
    font-size: 0.75rem;
    color: var(--error, #e53e3e);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.browser-viewport {
    flex: 1;
    overflow: auto;
    background: #111;
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius, 8px) var(--radius, 8px);
    outline: none;
    position: relative;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
}

.browser-viewport:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 25%, transparent);
}

.browser-frame-hidden {
    display: none !important;
}

.browser-viewport img {
    display: block;
    width: 100%;
    height: auto;
    cursor: crosshair;
    user-select: none;
    -webkit-user-drag: none;
    flex-shrink: 0;
}

.browser-idle,
.browser-loading {
    width: 100%;
    padding: 3rem 2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.95rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.browser-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    opacity: 0.65;
    font-family: var(--font-mono);
    margin-top: 0.6rem;
}

/* ── Login page ─────────────────────────────────────────────────────────────── */
.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
    padding: 2rem;
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md), var(--glow-primary);
    padding: 2.5rem 2.25rem;
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.login-logo {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: var(--primary);
    text-align: center;
    text-shadow: 0 0 20px rgba(167,139,250,0.4);
}

.login-title {
    font-size: 1.3rem;
    font-weight: 700;
    text-align: center;
    margin: 0;
    background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: center;
    margin: 0;
    line-height: 1.5;
}

.login-error {
    background: rgba(248, 113, 113, 0.12);
    border: 1px solid rgba(248, 113, 113, 0.3);
    border-radius: 6px;
    color: var(--error);
    padding: 0.6rem 0.9rem;
    font-size: 0.88rem;
}

.login-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.login-field label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.login-btn {
    width: 100%;
    justify-content: center;
    padding: 0.65rem 1rem;
    font-size: 0.95rem;
    margin-top: 0.25rem;
}

/* ── Top bar user badge ──────────────────────────────────────────────────────── */
.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.topbar-username {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.01em;
}

/* ── Nav footer (sign-out) ───────────────────────────────────────────────────── */
.nav-footer {
    margin-top: auto;
    padding: 0.9rem 1rem 1rem;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.nav-user {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 120px;
}

.nav-signout {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    border: 1px solid var(--border-subtle);
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
}

.nav-signout:hover {
    color: var(--error);
    border-color: rgba(248, 113, 113, 0.4);
    background: rgba(248, 113, 113, 0.06);
}