/* ============================================
   TERMINAL CSS (v2)
   Theme-agnostic design using semantic --t-* variables.
   To add a new theme: (1) define a body.theme-<name> block
   that sets all --t-* variables, (2) add the name to the
   validation check in the `theme` command.
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Ubuntu+Mono:ital,wght@0,400;0,700;1,400;1,700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ── Theme Palettes ────────────────────────── */

body.theme-catppuccin {
    --t-bg:            #11111b;
    --t-terminal-bg:   #1e1e2e;
    --t-panel-bg:      #181825;
    --t-text:          #cdd6f4;
    --t-text-dim:      #a6adc8;
    --t-accent:        #b4befe;
    --t-green:         #a6e3a1;
    --t-blue:          #89b4fa;
    --t-red:           #f38ba8;
    --t-yellow:        #f9e2af;
    --t-teal:          #94e2d5;
    --t-pink:          #f5c2e7;
    --t-glow:          none;
    --t-glow-strong:   none;
    --t-link:          #89b4fa;

    /* Chat */
    --chat-user-color: #cdd6f4;
    --chat-ai-color:   #a6e3a1;

    /* Snake */
    --t-snake-head:    #a6e3a1;
    --t-snake-tail:    #45475a;
    --t-snake-food:    #f5c2e7;
    --t-snake-board-border: #585b70;
    --t-snake-board-bg:     rgba(24, 24, 37, 0.95);
    --t-snake-multiplier:   #f9e2af;
}

body.theme-matrix {
    --t-bg:            #000000;
    --t-terminal-bg:   #0d0d0d;
    --t-panel-bg:      #0a1a0a;
    --t-text:          #00ff41;
    --t-text-dim:      #7aad7a;
    --t-accent:        #00ff41;
    --t-green:         #00ff41;
    --t-blue:          #00b8ff;
    --t-red:           #bf00ff;
    --t-yellow:        #ffcc00;
    --t-teal:          #00F7FF;
    --t-pink:          #ff00ff;
    --t-glow:          0 0 4px currentColor;
    --t-glow-strong:   0 0 8px currentColor;
    --t-link:          #00b8ff;

    /* Locked/dim effect: use --t-text-dim + opacity for illegible blur on locked items */

    /* Chat — white distinct from matrix green */
    --chat-user-color: #e0e0e0;
    --chat-ai-color:   #00ff41;

    /* Snake */
    --t-snake-head:    #39ff14;
    --t-snake-tail:    #003b00;
    --t-snake-food:    #ff00ff;
    --t-snake-board-border: #00ff41;
    --t-snake-board-bg:     rgba(0, 0, 0, 0.95);
    --t-snake-multiplier:   #ffcc00;
}

/* ── Base ──────────────────────────────────── */

html {
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
}

body {
    font-family: 'Ubuntu Mono', 'Courier New', monospace;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    transition: background-color 0.3s;
    background-color: var(--t-bg);
}

/* ── Theme Transition Overlay ─────────────── */

.theme-fade {
    position: fixed;
    inset: 0;
    background: black;
    opacity: 0;
    pointer-events: none;
    z-index: 9999;
    transition: opacity 0.25s ease-out;
}

.theme-fade.active {
    opacity: 1;
    transition: opacity 0.2s ease-in;
}

/* ── Layout ────────────────────────────────── */

.container {
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: 10px;
}

.terminal {
    flex: 1;
    border-radius: 8px;
    padding: 15px;
    font-size: 14px;
    line-height: 1.4;
    overflow: hidden;
    position: relative;
    background-color: var(--t-terminal-bg);
    color: var(--t-text);
    text-shadow: var(--t-glow);
}

.terminal-content {
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 2;
}

.terminal-lines {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;           /* Firefox */
    -ms-overflow-style: none;        /* IE/Edge */
}
.terminal-lines::-webkit-scrollbar {
    display: none;                   /* Chrome/Safari */
}

/* Push content to bottom in game mode; chat mode starts from top */
.terminal-lines::before {
    content: '';
    flex: 1;
}
.chat-active .terminal-lines::before {
    display: none;
}

.line {
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
    min-height: 1.4em;
    flex-shrink: 0;
}

.input-line {
    display: flex;
    flex-wrap: wrap;
}

.input-line .prompt {
    flex-shrink: 0;
}

.input-field {
    background: transparent;
    border: none;
    outline: none;
    color: inherit;
    font-family: inherit;
    font-size: inherit;
    flex: 1;
    min-width: 50px;
    caret-color: transparent;
    text-shadow: var(--t-glow);
}

.hidden-input {
    position: fixed;
    top: -9999px;
    left: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
    font-size: 16px; /* >=16px prevents mobile browser auto-zoom on focus */
}

.shop-focus {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

/* ── Prompt ────────────────────────────────── */

.prompt-user {
    color: var(--t-green);
    text-shadow: var(--t-glow-strong);
}

.prompt-host {
    color: var(--t-blue);
}

.prompt-path {
    color: var(--t-accent);
}

.prompt-symbol {
    color: var(--t-text);
}

.prompt-segment {
    display: inline-block;
    padding: 1px 7px;
    margin-right: 2px;
    border: 1px solid rgba(128, 128, 128, 0.45);
    border-radius: 999px;
    background-color: rgba(128, 128, 128, 0.14);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

/* ── Output ────────────────────────────────── */

.output-error {
    color: var(--t-red);
    text-shadow: var(--t-glow);
}

.output-dir {
    color: var(--t-blue);
    text-shadow: var(--t-glow);
}

.output-file {
    color: var(--t-text);
}

.output-exec {
    color: var(--t-green);
}

.output-link {
    color: var(--t-teal);
    text-shadow: var(--t-glow);
}

/* ── Three.js Scene Canvas ─────────────────── */

.scene-canvas {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    width: 100%;
    height: 100%;
    opacity: 0;
}
.scene-canvas.scene-fade-cinematic {
    transition: opacity 12s ease-in;
    opacity: 1;
}
.scene-canvas.scene-fade-quick {
    transition: opacity 3s ease-in;
    opacity: 1;
}

/* ── Matrix Rain ───────────────────────────── */

.matrix-rain {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
    opacity: 0;
    transition: opacity 1s;
}

body.theme-matrix .matrix-rain.active {
    opacity: 0.15;
}

.rain-column {
    position: absolute;
    font-size: 14px;
    line-height: 1.3;
    color: var(--t-green);
    text-shadow: 0 0 8px var(--t-green);
    white-space: nowrap;
    writing-mode: vertical-rl;
    text-orientation: upright;
    will-change: transform;
}

.rain-head {
    color: #fff;
    text-shadow: 0 0 12px #fff, 0 0 25px var(--t-green), 0 0 40px var(--t-green);
    opacity: 1 !important;
}

/* ── Shared Overlay Base ──────────────────── */

.overlay-container {
    position: absolute;
    inset: 0;
    display: none;
    background-color: var(--t-terminal-bg);
    color: var(--t-text);
}

.overlay-key {
    background-color: var(--t-accent);
    color: var(--t-terminal-bg);
    text-shadow: none;
    padding: 1px 4px;
    border-radius: 2px;
}

.overlay-footer {
    padding: 8px 12px;
    color: var(--t-text-dim);
    border-top: 1px solid color-mix(in srgb, var(--t-accent) 60%, var(--t-panel-border));
}

.shop-shell,
.email-shell,
.market-shell {
    display: flex;
    border-radius: 8px;
    overflow: hidden;
}

.shop-item-row-selected,
.market-row-selected {
    background: color-mix(in srgb, var(--t-accent) 23%, transparent);
    color: var(--t-text);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--t-accent) 48%, transparent);
}

/* ── Shop Overlay ──────────────────────────── */

.shop-overlay {
    z-index: 100;
    overflow: hidden;
    line-height: 1.4;
    font-family: inherit;
    font-size: 14px;
    text-shadow: var(--t-glow);
}

.shop-overlay.active {
    display: flex;
}

.shop-content {
    flex: 1;
    overflow: hidden;
    user-select: none;
    padding: 10px;
    display: flex;
}

.shop-gold { color: var(--t-yellow); text-shadow: var(--t-glow); }
.shop-xp { color: var(--t-teal); }
.shop-item-selected { background-color: var(--t-panel-bg); }
.shop-item-owned { color: var(--t-text-dim); }
.shop-item-affordable { color: var(--t-green); }
.shop-item-expensive { color: var(--t-red); }
.shop-item-locked { color: var(--t-text-dim); opacity: 0.5; }
.shop-lore { color: var(--t-pink); font-style: italic; }
.shop-keeper { color: var(--t-yellow); }
.shop-border { color: var(--t-text-dim); }
.shop-shell {
    flex: 1;
    flex-direction: column;
    border: 1px solid color-mix(in srgb, var(--t-accent) 75%, var(--t-panel-border));
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--t-accent) 30%, transparent), 0 0 14px color-mix(in srgb, var(--t-accent) 20%, transparent);
    background: color-mix(in srgb, var(--t-panel-bg) 92%, transparent);
}

.shop-header {
    padding: 10px 12px;
    border-bottom: 1px solid color-mix(in srgb, var(--t-accent) 65%, var(--t-panel-border));
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.shop-title {
    margin: 0;
    font-size: 1rem;
    letter-spacing: 0.06em;
    color: var(--t-accent);
}

.shop-metrics {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.shop-metric {
    border: 1px solid color-mix(in srgb, var(--t-accent) 45%, var(--t-panel-border));
    border-radius: 999px;
    padding: 3px 9px;
    background: color-mix(in srgb, var(--t-terminal-bg) 80%, transparent);
}

.shop-categories {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 10px 12px 0;
}

.shop-category {
    border: 1px solid color-mix(in srgb, var(--t-accent) 40%, var(--t-panel-border));
    border-radius: 8px;
    padding: 6px 10px;
    color: var(--t-text-dim);
    background: color-mix(in srgb, var(--t-terminal-bg) 78%, transparent);
}

.shop-category-active {
    color: var(--t-text);
    background: color-mix(in srgb, var(--t-accent) 24%, transparent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--t-accent) 45%, transparent);
}

.shop-category-locked {
    opacity: 0.3;
    cursor: not-allowed;
    border-color: transparent;
}

.shop-main {
    flex: 1;
    min-height: 0;
    display: flex;
    gap: 10px;
    padding: 10px 12px 0;
}

.shop-list-panel,
.shop-detail-panel {
    border: 1px solid color-mix(in srgb, var(--t-accent) 55%, var(--t-panel-border));
    border-radius: 8px;
    background: color-mix(in srgb, var(--t-terminal-bg) 84%, transparent);
}

.shop-list-panel {
    width: 38%;
    min-width: 220px;
    padding: 8px;
    overflow: hidden;
}

.shop-detail-panel {
    flex: 1;
    padding: 10px 12px;
    overflow: auto;
}

.shop-item-row {
    padding: 6px 8px;
    border-radius: 4px;
    color: var(--t-text-dim);
    margin-bottom: 2px;
}

.shop-item-line {
    display: flex;
    align-items: center;
    gap: 8px;
}

.shop-item-marker {
    min-width: 14px;
    text-align: center;
}

.shop-item-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.shop-item-price {
    font-size: 0.88rem;
}

.shop-detail-top {
    color: var(--t-yellow);
    margin-bottom: 8px;
}

.shop-keeper-quote {
    color: var(--t-text-dim);
}

.shop-detail-title {
    font-weight: 700;
    color: var(--t-text);
    margin-bottom: 4px;
}

.shop-detail-desc {
    color: var(--t-text-dim);
    margin-bottom: 8px;
}

.shop-meta {
    border-top: 1px solid color-mix(in srgb, var(--t-accent) 50%, var(--t-panel-border));
    margin-top: 8px;
    padding-top: 8px;
    display: grid;
    gap: 6px;
}

.shop-status-box {
    margin-top: 10px;
    border: 1px solid color-mix(in srgb, var(--t-accent) 55%, var(--t-panel-border));
    border-radius: 6px;
    padding: 8px 10px;
    background: color-mix(in srgb, var(--t-terminal-bg) 80%, transparent);
}

.shop-status-result {
    color: var(--t-teal);
}

.shop-empty {
    color: var(--t-text-dim);
    padding: 4px;
}



/* ── Email Overlay ─────────────────────────── */

.email-overlay {
    z-index: 101;
}

.email-overlay.active {
    display: block;
}

.email-content {
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 10px;
    box-sizing: border-box;
    user-select: none;
}

.email-shell {
    flex: 1;
    min-height: 0;
    border: 1px solid color-mix(in srgb, var(--t-accent) 75%, var(--t-panel-border));
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, rgba(0, 0, 0, 0) 26%),
        var(--t-panel-bg);
    box-shadow:
        0 0 0 1px color-mix(in srgb, var(--t-accent) 35%, transparent),
        0 0 18px color-mix(in srgb, var(--t-accent) 28%, transparent);
}

.email-sidebar {
    width: 34%;
    min-width: 240px;
    border-right: 1px solid color-mix(in srgb, var(--t-accent) 70%, var(--t-panel-border));
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: color-mix(in srgb, var(--t-terminal-bg) 82%, transparent);
}

.email-header {
    padding: 10px 12px;
    border-bottom: 1px solid color-mix(in srgb, var(--t-accent) 70%, var(--t-panel-border));
    color: var(--t-yellow);
    text-shadow: var(--t-glow);
    letter-spacing: 0.3px;
}

.email-list {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    padding: 6px;
    border: 1px solid color-mix(in srgb, var(--t-accent) 62%, var(--t-panel-border));
    border-radius: 8px;
    margin: 8px;
    background: color-mix(in srgb, var(--t-terminal-bg) 86%, transparent);
}

.email-row {
    padding: 6px 8px;
    border-radius: 4px;
    margin-bottom: 2px;
    color: var(--t-text-dim);
    border: 1px solid transparent;
}

.email-row .email-subject-preview {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.email-row-selected {
    background: color-mix(in srgb, var(--t-accent) 22%, transparent);
    color: var(--t-text);
    border-color: color-mix(in srgb, var(--t-accent) 85%, var(--t-text));
    box-shadow:
        inset 0 0 0 1px color-mix(in srgb, var(--t-accent) 55%, transparent),
        0 0 8px color-mix(in srgb, var(--t-accent) 22%, transparent);
    border-left-width: 3px;
}

.email-row-arriving {
    animation: email-row-arrive 0.8s ease-out;
}

.article-tier-blog_reader {
    border-left: 3px solid var(--t-green);
}

.article-tier-premium_blog {
    border-left: 3px solid var(--t-yellow);
}

.article-tier-article_wire_max {
    border-left: 3px solid var(--t-pink);
}

.email-row-unread .email-dot {
    color: var(--t-accent);
    text-shadow: var(--t-glow-strong);
}

.email-row-read .email-dot {
    color: var(--t-text-dim);
}

.email-reader {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: color-mix(in srgb, var(--t-panel-bg) 92%, transparent);
}

.email-reader-header {
    padding: 10px 12px;
    border-bottom: 1px solid color-mix(in srgb, var(--t-accent) 70%, var(--t-panel-border));
    color: var(--t-teal);
    font-weight: 600;
}

.email-reader-meta {
    padding: 8px 12px 4px;
    color: var(--t-text-dim);
}

.email-meta-divider {
    height: 1px;
    margin: 8px 12px;
    background: color-mix(in srgb, var(--t-accent) 65%, var(--t-panel-border));
    box-shadow: 0 0 8px color-mix(in srgb, var(--t-accent) 28%, transparent);
}

.email-reader-body {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 10px 12px;
    line-height: 1.45;
    border: 1px solid color-mix(in srgb, var(--t-accent) 58%, var(--t-panel-border));
    border-radius: 8px;
    margin: 0 12px 12px;
    background: color-mix(in srgb, var(--t-terminal-bg) 88%, transparent);
    box-shadow: inset 0 0 14px color-mix(in srgb, var(--t-accent) 12%, transparent);
}

.email-reader-empty {
    color: var(--t-text-dim);
}

.email-reader-body p {
    margin: 0 0 10px;
}

.email-reader-body h1,
.email-reader-body h2,
.email-reader-body h3 {
    color: var(--t-yellow);
    margin: 0 0 8px;
}

.email-reader-body strong {
    color: var(--t-text);
    font-weight: 700;
}

.email-reader-body .email-provider {
    font-weight: 700;
}

.email-reader-body .email-provider-openai {
    color: #22c55e;
}

.email-reader-body .email-provider-claude {
    color: #f59e0b;
}

.email-reader-body .email-provider-deepseek {
    color: #38bdf8;
}

.email-reader-body code {
    background: color-mix(in srgb, var(--t-terminal-bg) 70%, transparent);
    border: 1px solid color-mix(in srgb, var(--t-panel-border) 65%, transparent);
    color: var(--t-teal);
    padding: 1px 5px;
    border-radius: 4px;
}

.email-reader-body pre {
    margin: 8px 0 10px;
    background: color-mix(in srgb, var(--t-terminal-bg) 78%, transparent);
    border: 1px solid color-mix(in srgb, var(--t-accent) 40%, transparent);
    border-radius: 6px;
    padding: 10px;
    overflow-x: auto;
}

.email-reader-body pre code {
    border: none;
    background: transparent;
    padding: 0;
    color: var(--t-green);
}

.email-reader-body ul {
    margin: 0 0 10px 18px;
    padding: 0;
}



.email-newmail-banner {
    margin-bottom: 8px;
    padding: 8px 10px;
    border: 1px solid color-mix(in srgb, var(--t-accent) 55%, var(--t-panel-border));
    border-radius: 8px;
    background: color-mix(in srgb, var(--t-accent) 25%, transparent);
    color: var(--t-text);
    animation: email-newmail-pop 0.55s ease-out;
}

@keyframes email-newmail-pop {
    0% {
        opacity: 0;
        transform: translateY(-6px) scale(0.98);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes email-row-arrive {
    0% {
        background: color-mix(in srgb, var(--t-accent) 45%, transparent);
        border-color: color-mix(in srgb, var(--t-accent) 90%, var(--t-panel-border));
        transform: translateX(-4px);
    }
    100% {
        background: transparent;
        border-color: transparent;
        transform: translateX(0);
    }
}

/* ── Discovery Notification ──────────────── */

.discovery-notification {
    color: var(--t-teal);
    text-shadow: var(--t-glow);
}

/* ── Chat Cinema Boot ─────────────────────── */

.cinema-banner {
    color: var(--t-yellow);
    text-shadow: var(--t-glow-strong);
    letter-spacing: 0.4px;
}

.cinema-phase {
    color: var(--t-accent);
    text-shadow: var(--t-glow);
    font-weight: bold;
}

.cinema-cmd {
    color: var(--t-teal);
    text-shadow: var(--t-glow);
}

.cinema-ok {
    color: var(--t-green);
    text-shadow: var(--t-glow);
}

.cinema-warn {
    color: var(--t-yellow);
    text-shadow: var(--t-glow);
}

.cinema-error {
    color: var(--t-red);
    text-shadow: var(--t-glow-strong);
    font-weight: bold;
}

.cinema-dim {
    color: var(--t-text-dim);
    opacity: 0.95;
}

.cinema-teal {
    color: var(--t-teal);
}

.cinema-log {
    color: var(--t-text);
}

.cinema-progress-label {
    color: var(--t-accent);
}

.cinema-progress-bar {
    color: var(--t-green);
    text-shadow: var(--t-glow-strong);
}

.cinema-progress-pct {
    color: var(--t-teal);
    font-weight: bold;
}

/* ── Snake Game Overlay ────────────────────── */

.snake-overlay {
    position: absolute;
    inset: 0;
    display: none;
    z-index: 100;
}

.snake-overlay.active {
    display: block;
}

.snake-overlay canvas {
    width: 100%;
    height: 100%;
}

.snake-scoreboard {
    position: absolute;
    top: 10px;
    right: 10px;
    font-family: 'DejaVu Sans Mono', 'Cascadia Mono', 'SFMono-Regular', 'Consolas', 'Liberation Mono', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.4;
    color: var(--t-text);
    background-color: var(--t-snake-board-bg);
    border: 1px solid var(--t-snake-board-border);
    border-radius: 4px;
    padding: 8px;
    white-space: pre;
    z-index: 101;
    text-shadow: var(--t-glow);
}

.snake-multiplier {
    position: absolute;
    top: 10px;
    left: 10px;
    font-family: 'DejaVu Sans Mono', 'Cascadia Mono', 'SFMono-Regular', 'Consolas', 'Liberation Mono', 'Courier New', monospace;
    font-size: 24px;
    font-weight: bold;
    color: var(--t-snake-multiplier);
    text-shadow: var(--t-glow-strong);
    z-index: 101;
    display: none;
}

.snake-multiplier.active {
    display: block;
}

/* ── Market Overlay ───────────────────────── */

.market-overlay {
    z-index: 102;
}

.market-overlay.active {
    display: block;
}

.market-content {
    height: 100%;
    padding: 10px;
}

.market-shell {
    height: 100%;
    flex-direction: column;
    border: 1px solid color-mix(in srgb, var(--t-accent) 70%, var(--t-panel-border));
    background: color-mix(in srgb, var(--t-panel-bg) 95%, transparent);
}

.market-header {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px 12px 8px;
    border-bottom: 1px solid color-mix(in srgb, var(--t-accent) 55%, var(--t-panel-border));
}

.market-title {
    color: var(--t-accent);
    font-weight: 700;
    letter-spacing: 0.05em;
}

.market-metrics {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    color: var(--t-yellow);
}

.market-main {
    flex: 1;
    min-height: 0;
    display: flex;
    gap: 10px;
    padding: 10px 12px;
}

.market-left {
    width: 55%;
    min-width: 280px;
    border: 1px solid color-mix(in srgb, var(--t-accent) 50%, var(--t-panel-border));
    border-radius: 8px;
    padding: 10px;
    overflow: auto;
    background: color-mix(in srgb, var(--t-terminal-bg) 84%, transparent);
}

.market-right {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.market-ticket,
.market-quote {
    border: 1px solid color-mix(in srgb, var(--t-accent) 50%, var(--t-panel-border));
    border-radius: 8px;
    padding: 10px;
    background: color-mix(in srgb, var(--t-terminal-bg) 84%, transparent);
}

.market-ticket-title,
.market-quote-title {
    color: var(--t-accent);
    margin-bottom: 6px;
    font-weight: 700;
}

.market-quote-line {
    color: var(--t-text-dim);
    margin-bottom: 6px;
}

.market-spark {
    letter-spacing: 1px;
    color: var(--t-green);
}

.market-table-head {
    color: var(--t-text-dim);
    margin-bottom: 6px;
}

.market-row {
    white-space: pre;
    border-radius: 4px;
    padding: 3px 6px;
    margin-bottom: 2px;
}

.market-buy {
    color: var(--t-green);
}

.market-sell {
    color: var(--t-red);
}

.market-footer {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.market-flash {
    margin: 0 12px 10px;
    border: 1px solid color-mix(in srgb, var(--t-accent) 50%, var(--t-panel-border));
    border-radius: 6px;
    padding: 8px 10px;
    color: var(--t-text);
    background: color-mix(in srgb, var(--t-accent) 18%, transparent);
}

@media (max-width: 900px) {
    .shop-main, .market-main { flex-direction: column; }
    .shop-list-panel, .market-left { width: 100%; min-width: 0; }
    .shop-list-panel { max-height: 38%; }
    .market-left { max-height: 42%; }
    .email-shell { flex-direction: column; }
    .email-sidebar { width: 100%; min-width: 0; min-height: 180px; border-right: none; border-bottom: 1px solid var(--t-panel-border); }
}

/* ── autoResearch overlay ────────────────────── */
.auto-research-overlay { z-index: 103; }
.auto-research-overlay.active { display: flex; }

.auto-research-content {
    flex: 1;
    overflow: hidden;
    user-select: none;
    padding: 10px;
    display: flex;
}

.auto-research-shell {
    flex: 1;
    display: flex;
    flex-direction: column;
    border: 1px solid color-mix(in srgb, var(--t-accent) 75%, var(--t-panel-border));
    border-radius: 8px;
    background: color-mix(in srgb, var(--t-panel-bg) 92%, transparent);
    overflow: hidden;
}

.auto-research-header {
    padding: 8px 16px;
    border-bottom: 1px solid color-mix(in srgb, var(--t-accent) 40%, transparent);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.auto-research-title { color: var(--t-accent); font-weight: bold; }

.auto-research-tree { flex: 1; overflow-y: auto; padding: 8px 16px; }

.auto-research-node { padding: 4px 8px; margin: 2px 0; border-radius: 4px; white-space: pre-wrap; }

.auto-research-node-locked { color: var(--t-text-dim); opacity: 0.5; }
.auto-research-node-available { color: var(--t-text); }
.auto-research-node-researching { color: var(--t-yellow); }
.auto-research-node-completed { color: var(--t-green); }

.auto-research-node-selected {
    background: color-mix(in srgb, var(--t-accent) 23%, transparent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--t-accent) 48%, transparent);
}

.auto-research-progress {
    display: inline-block; width: 120px; height: 8px;
    background: color-mix(in srgb, var(--t-text-dim) 20%, transparent);
    border-radius: 4px; overflow: hidden; vertical-align: middle; margin-left: 8px;
}

.auto-research-progress-fill { height: 100%; background: var(--t-accent); border-radius: 4px; }

.auto-research-footer {
    padding: 8px 16px;
    border-top: 1px solid color-mix(in srgb, var(--t-accent) 40%, transparent);
    display: flex; gap: 16px; color: var(--t-text-dim);
}

.auto-research-flash { color: var(--t-red); }

/* ── Chat Blocks ─────────────────────────── */

.line:has(.chat-block) {
    white-space: normal;
    min-height: auto;
    /* 50% on wide screens, grows to 90% on narrow (phone) screens */
    max-width: 50%;
    margin-left: 25%;
    margin-right: 25%;
}

/* Chat mode: match the input line */
.chat-active .line.input-line {
    max-width: 50%;
    margin-left: 25%;
    margin-right: 25%;
}

/* Gradually widen on smaller screens */
@media (max-width: 1200px) {
    .line:has(.chat-block),
    .chat-active .line.input-line {
        max-width: 65%;
        margin-left: 17.5%;
        margin-right: 17.5%;
    }
}
@media (max-width: 900px) {
    .line:has(.chat-block),
    .chat-active .line.input-line {
        max-width: 80%;
        margin-left: 10%;
        margin-right: 10%;
    }
}
@media (max-width: 600px) {
    .line:has(.chat-block),
    .chat-active .line.input-line {
        max-width: 90%;
        margin-left: 5%;
        margin-right: 5%;
    }
}

/* Top padding so first message isn't flush against the edge */
.chat-active .terminal-lines {
    padding-top: 24px;
}

.chat-block {
    background-color: rgba(30, 30, 46, 0.45);
    background-color: color-mix(in srgb, var(--t-terminal-bg) 45%, transparent);
    -webkit-backdrop-filter: blur(12px) saturate(1.2);
    backdrop-filter: blur(12px) saturate(1.2);
    border-radius: 8px;
    padding: 12px 16px;
    margin: 8px 0;
    color: var(--t-text);
    line-height: 1.5;
    overflow: hidden;
    /* Don't force full width — shrink to content */
    display: inline-block;
    max-width: 100%;
}

/* Make the .line a block container so inline-block chat-block left-aligns naturally */
.line:has(.chat-block) {
    display: block;
}

/* ── User messages: white text + white accent bar ── */
.chat-block:has(.chat-block-input) {
    border-left: 3px solid var(--chat-user-color);
    color: var(--chat-user-color);
    text-shadow: 0 0 3px rgba(255, 255, 255, 0.12);
}

/* ── AI messages: green text, no accent bar ── */
.chat-block:has(.chat-block-output) {
    border-left: none;
    color: var(--chat-ai-color);
}

body.theme-matrix .chat-block:has(.chat-block-output) {
    box-shadow: 0 0 5px rgba(0, 255, 65, 0.2);
}
body.theme-matrix .chat-block:has(.chat-block-input) {
    box-shadow: 0 0 4px rgba(255, 255, 255, 0.1);
}

/* High-contrast moods need more opaque chat blocks for readability */
.scene-active[data-mood="chaos"] .chat-block,
.scene-active[data-mood="electric"] .chat-block,
.scene-active[data-mood="synthwave"] .chat-block {
    background-color: rgba(30, 30, 46, 0.85);
}

.chat-block-input {
    padding: 0;
    font-family: inherit;
    font-size: inherit;
}

.chat-block-output {
    padding: 0;
    font-family: inherit;
    font-size: inherit;
    line-height: 1.5;
}

.chat-block-output .chat-label {
    opacity: 0.6;
    font-size: 12px;
    margin-bottom: 6px;
}

/* Markdown rendered in chat blocks */
.chat-block-output h1,
.chat-block-output h2,
.chat-block-output h3 {
    margin: 0.5em 0 0.3em;
    font-weight: bold;
}

.chat-block-output h1 { font-size: 1.2em; }
.chat-block-output h2 { font-size: 1.1em; }
.chat-block-output h3 { font-size: 1.0em; }

.chat-block-output p {
    margin: 0.4em 0;
}

.chat-block-output ul,
.chat-block-output ol {
    margin: 0.4em 0;
    padding-left: 1.5em;
}

.chat-block-output table {
    border-collapse: collapse;
    margin: 0.5em 0;
    font-size: 13px;
}

.chat-block-output th,
.chat-block-output td {
    border: 1px solid rgba(128, 128, 128, 0.3);
    padding: 4px 8px;
    text-align: left;
}

.chat-block-output th {
    font-weight: bold;
}

.chat-block-output code {
    font-family: inherit;
    padding: 1px 4px;
    border-radius: 3px;
    background-color: rgba(128, 128, 128, 0.15);
}

.chat-block-output pre {
    margin: 0.5em 0;
    padding: 8px;
    border-radius: 4px;
    overflow-x: auto;
    background-color: rgba(0, 0, 0, 0.2);
}

.chat-block-output pre code {
    background: none;
    padding: 0;
}

.chat-block-output a {
    color: var(--t-link);
    text-decoration: underline;
}

/* Chat loading indicator */
.chat-loading {
    display: inline-block;
}

.chat-loading span {
    animation: chatBlink 1.4s infinite;
    opacity: 0.2;
}

.chat-loading span:nth-child(2) { animation-delay: 0.2s; }
.chat-loading span:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatBlink {
    0%, 80%, 100% { opacity: 0.2; }
    40% { opacity: 1; }
}

/* Chat block entrance animation — gentle ease for fluid feel */
@keyframes chatSlideUp {
    0% {
        opacity: 0;
        transform: translateY(12px);
    }
    40% {
        opacity: 0.6;
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-block.chat-animate-in {
    animation: chatSlideUp 0.5s cubic-bezier(0.25, 0.1, 0.25, 1) forwards;
}

/* Softer entrance for the loading-dots block (replaced in place by the
   answer, so it gets a short fade rather than the full slide) */
@keyframes chatFadeInUp {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-block.chat-enter-soft {
    animation: chatFadeInUp 0.3s ease-out forwards;
}

/* End-of-reveal markdown swap: quick settle, NOT the entrance animation —
   the block has been on screen the whole time */
@keyframes chatFinalize {
    from { opacity: 0.55; }
    to { opacity: 1; }
}

.chat-block.chat-finalize-fade {
    animation: chatFinalize 0.18s ease-out forwards;
}

/* Raw streamed text before the markdown swap — keep paragraph breaks */
.chat-stream-raw {
    white-space: pre-wrap;
}

/* ── Chat highlight (inline word emphasis) ── */
.chat-highlight {
    color: #5af0e6;
    text-shadow: 0 0 6px rgba(90, 240, 230, 0.3);
    font-weight: 500;
}

/* ── Chat heading styles (marked.js renderer) ── */
.chat-heading {
    font-weight: bold;
    display: block;
    margin: 0.4em 0 0.2em;
}
.chat-heading-1 { color: #5af0e6; font-size: 1.2em; }
.chat-heading-2 { color: #50fa7b; font-size: 1.1em; }
.chat-heading-3 { color: #f1fa8c; font-size: 1.0em; }

/* ── Chat list with tree guides ── */
.chat-list {
    margin: 0.3em 0;
}
.chat-list-item {
    padding-left: 0.5em;
    line-height: 1.6;
}
.chat-tree-guide::before {
    content: '├── ';
    color: #6272a4;
}
.chat-list-item:last-child .chat-tree-guide::before {
    content: '└── ';
}

/* ── Chat inline code (marked.js renderer) ── */
.chat-inline-code {
    color: #50fa7b;
    background: rgba(80, 250, 123, 0.1);
    padding: 1px 4px;
    border-radius: 3px;
    font-family: inherit;
}

/* ── Chat code block (marked.js renderer) ── */
.chat-code-block {
    border: 1px solid #44475a;
    border-radius: 4px;
    padding: 8px 12px;
    margin: 4px 0;
    background: rgba(68, 71, 90, 0.4);
    overflow-x: auto;
}

/* ── Chat links (marked.js renderer) ── */
.chat-link {
    color: #8be9fd;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.chat-link:hover {
    color: #5af0e6;
}

/* ── Chat project image (inline) ── */
.chat-project-image {
    max-width: 100%;
    border-radius: 4px;
    margin-top: 8px;
    border: 1px solid #44475a;
    opacity: 0;
    animation: chatImageFadeIn 0.8s cubic-bezier(0.25, 0.1, 0.25, 1) forwards;
}

@keyframes chatImageFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Chat Mobile Responsive ──────────────────── */
@media (max-width: 768px) {
    .chat-block-output {
        font-size: 0.92em;
        line-height: 1.6;
    }
}

/* ── Chat Welcome State ──────────────────────── */
.chat-welcome-line {
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
    max-height: 500px;
    overflow: hidden;
}
.chat-welcome-line.chat-welcome-fadeout {
    opacity: 0 !important;
    transform: translateY(-30px);
    max-height: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    overflow: hidden;
    transition: opacity 1.2s ease-in, transform 1.2s ease-in, max-height 1.8s ease-in-out 0.6s, padding 1.8s ease-in-out 0.6s, margin 1.8s ease-in-out 0.6s;
}

.chat-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 20px;
    opacity: 0;
    gap: 12px;
    /* Quick mode (return visits): 3s fade synced with scene-fade-quick */
    transition: opacity 3s ease-out;
}
.chat-welcome.chat-welcome-visible {
    opacity: 0.5;
}
/* Cinematic mode (first visit): delayed start, longer fade synced with 12s scene fade */
.chat-welcome.chat-welcome-cinematic {
    transition: opacity 5s ease-out 4s;
}

.chat-welcome-icon {
    font-size: 2em;
    opacity: 0.6;
}

.chat-welcome-title {
    font-size: 1.1em;
    color: var(--t-accent);
}

.chat-welcome-hint {
    font-size: 0.85em;
    opacity: 0;
    max-width: 400px;
    /* Quick mode */
    transition: opacity 2s ease-out 1.5s;
}
.chat-welcome.chat-welcome-cinematic .chat-welcome-hint {
    /* Cinematic: appears after the main card has started fading in */
    transition: opacity 3s ease-out 7s;
}
.chat-welcome.chat-welcome-visible .chat-welcome-hint {
    opacity: 1;
}

.chat-welcome-session {
    font-size: 0.8em;
    opacity: 0;
    margin-top: 4px;
    /* Quick mode */
    transition: opacity 2s ease-out 2.5s;
}
.chat-welcome.chat-welcome-cinematic .chat-welcome-session {
    /* Cinematic: last element to appear */
    transition: opacity 3s ease-out 9s;
}
.chat-welcome.chat-welcome-visible .chat-welcome-session {
    opacity: 1;
}

/* ── Chat prompt marker (white > for user) ──── */
.chat-prompt-user {
    color: var(--chat-user-color);
    font-weight: bold;
}

/* ── Chat Input Zone Separator ───────────────── */
.line.input-line.chat-input-zone {
    border-top: 1px solid rgba(128, 128, 128, 0.15);
    padding-top: 8px;
    margin-top: 4px;
    color: var(--chat-user-color);
    text-shadow: 0 0 3px rgba(255, 255, 255, 0.12);
}

/* ── Input cursor (blinking block) ───────────── */
.input-cursor {
    display: inline-block;
    width: 0.55em;
    height: 1.05em;
    margin-left: 1px;
    background: var(--t-text);
    vertical-align: text-bottom;
    animation: cursorBlink 1.06s steps(2, start) infinite;
}

@keyframes cursorBlink {
    to { visibility: hidden; }
}

/* Busy state: dim, steady — request or reveal in flight */
.input-cursor.input-cursor-busy {
    animation: none;
    opacity: 0.3;
}

/* ── Ambient idle effects (chat-ambient.js) ──── */

/* Erratic cursor blink */
.input-cursor.input-cursor-glitch {
    animation: cursorGlitchBlink 0.6s steps(3, jump-none) infinite;
}

@keyframes cursorGlitchBlink {
    0% { visibility: visible; opacity: 1; }
    30% { visibility: hidden; }
    45% { visibility: visible; opacity: 0.5; }
    60% { visibility: hidden; }
    100% { visibility: visible; opacity: 1; }
}

/* Ghost keystrokes in the prompt — faint, clearly not the user's text */
.input-ghost {
    color: var(--t-text-dim);
    opacity: 0.45;
    text-shadow: none;
}

/* Transient background-process murmur above the input zone */
.chat-ambient-line {
    position: absolute;
    bottom: 44px;
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    max-width: 80%;
    color: var(--t-text-dim);
    font-size: 12px;
    opacity: 0;
    pointer-events: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 1.2s ease, transform 1.2s ease;
    z-index: 3;
}

.chat-ambient-line.visible {
    opacity: 0.5;
    transform: translateX(-50%) translateY(0);
}

/* Re-shimmer an existing highlight word */
.chat-highlight.chat-highlight-pulse {
    animation: highlightPulse 2.4s ease-in-out;
}

@keyframes highlightPulse {
    0%, 100% { text-shadow: 0 0 6px rgba(90, 240, 230, 0.3); }
    40% { text-shadow: 0 0 14px rgba(90, 240, 230, 0.9), 0 0 28px rgba(90, 240, 230, 0.4); }
}

.chat-input-zone .input-field {
    color: var(--chat-user-color);
    text-shadow: 0 0 3px rgba(255, 255, 255, 0.12);
}

.chat-input-zone .prompt-user,
.chat-input-zone .prompt-host,
.chat-input-zone .prompt-symbol {
    color: var(--chat-user-color);
    text-shadow: 0 0 3px rgba(255, 255, 255, 0.12);
}

/* ── Chat Effects ──────────────────────────── */

/* CRT Glitch */
.chat-effect-crt {
    animation: crtFlicker 0.15s infinite;
    text-shadow:
        2px 0 rgba(255, 0, 0, 0.6),
        -2px 0 rgba(0, 255, 255, 0.6);
}

.chat-effect-crt::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0) 0px,
        rgba(0, 0, 0, 0) 1px,
        rgba(0, 0, 0, 0.15) 1px,
        rgba(0, 0, 0, 0.15) 2px
    );
    pointer-events: none;
    z-index: 1;
}

@keyframes crtFlicker {
    0%   { opacity: 1; }
    30%  { opacity: 0.92; }
    50%  { opacity: 1; }
    70%  { opacity: 0.96; }
    100% { opacity: 1; }
}

/* Screen Shake */
.chat-effect-shake {
    animation: chatShake 0.5s ease-in-out;
}

@keyframes chatShake {
    0%, 100% { transform: translate(0, 0); }
    10%      { transform: translate(-3px, 1px); }
    20%      { transform: translate(3px, -2px); }
    30%      { transform: translate(-2px, 3px); }
    40%      { transform: translate(2px, -1px); }
    50%      { transform: translate(-3px, 2px); }
    60%      { transform: translate(3px, 1px); }
    70%      { transform: translate(-1px, -3px); }
    80%      { transform: translate(2px, 2px); }
    90%      { transform: translate(-2px, -1px); }
}

/* Redact Reveal */
.chat-effect-redact {
    position: relative;
    display: inline;
}

.chat-effect-redact::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--t-text, #cdd6f4);
    animation: redactReveal 1.5s ease-out forwards;
    pointer-events: none;
}

@keyframes redactReveal {
    0%   { opacity: 1; }
    70%  { opacity: 1; }
    100% { opacity: 0; }
}

/* Scanlines */
.chat-effect-scanlines {
    position: relative;
}

.chat-effect-scanlines::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0) 0px,
        rgba(0, 0, 0, 0) 2px,
        rgba(0, 0, 0, 0.08) 2px,
        rgba(0, 0, 0, 0.08) 4px
    );
    animation: scanlineScroll 0.3s linear infinite;
    pointer-events: none;
    z-index: 1;
}

@keyframes scanlineScroll {
    0%   { transform: translateY(0); }
    100% { transform: translateY(4px); }
}

/* Flicker */
.chat-effect-flicker {
    animation: terminalFlicker 0.08s steps(2) infinite;
}

@keyframes terminalFlicker {
    0%   { opacity: 1; }
    25%  { opacity: 0.3; }
    50%  { opacity: 0.85; }
    75%  { opacity: 0.15; }
    100% { opacity: 1; }
}

/* ASCII Border */
.chat-effect-ascii-border {
    position: relative;
    border: 1px solid var(--t-text, #cdd6f4);
    padding: 4px 8px;
    margin: 4px 0;
    box-shadow:
        inset 2px 2px 0 var(--t-text, #cdd6f4),
        inset -2px -2px 0 var(--t-text, #cdd6f4);
}

.chat-effect-ascii-border::before {
    content: '/* \2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550 */';
    display: block;
    color: var(--t-dim, #6c7086);
    margin-bottom: 2px;
    font-family: inherit;
}

.chat-effect-ascii-border::after {
    content: '/* \2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550\2550 */';
    display: block;
    color: var(--t-dim, #6c7086);
    margin-top: 2px;
    font-family: inherit;
}

/* ── VHS Tracking ─────────────────────────────── */
@keyframes vhsTrackingScroll {
    0%   { transform: translateY(-100%); }
    100% { transform: translateY(calc(100vh + 100%)); }
}

.chat-effect-vhs-distort {
    animation: vhsDistort 0.15s steps(2) infinite;
}

@keyframes vhsDistort {
    0%   { transform: translate(0); }
    25%  { transform: translate(2px, 0); }
    50%  { transform: translate(-1px, 0); }
    75%  { transform: translate(3px, 0); }
    100% { transform: translate(0); }
}

/* ── Hologram Flicker ─────────────────────────── */
.chat-effect-hologram {
    color: rgba(100, 220, 255, 0.9) !important;
    text-shadow:
        0 0 10px rgba(0, 200, 255, 0.6),
        0 0 20px rgba(0, 150, 255, 0.3),
        0 0 40px rgba(0, 100, 255, 0.15);
    filter: saturate(0.5) brightness(1.2);
}

.chat-effect-hologram * {
    color: inherit !important;
}

@keyframes hologramScan {
    0%   { transform: translateY(0); }
    100% { transform: translateY(6px); }
}

/* ── Signal Lost Blink ────────────────────────── */
@keyframes signalBlink {
    0%   { opacity: 1; }
    49%  { opacity: 1; }
    50%  { opacity: 0; }
    100% { opacity: 0; }
}

/* ── Phosphor Decay ───────────────────────────── */
.chat-effect-phosphor {
    color: rgba(50, 255, 50, 0.95) !important;
    text-shadow:
        0 0 5px rgba(0, 255, 0, 0.8),
        0 0 15px rgba(0, 255, 0, 0.5),
        0 0 30px rgba(0, 255, 0, 0.25),
        0 0 50px rgba(0, 200, 0, 0.1);
    transition: color 0.3s ease-in, text-shadow 0.3s ease-in;
}

.chat-effect-phosphor * {
    color: inherit !important;
    text-shadow: inherit !important;
}

/* ── Terminal Tips Overlay ─────────────────────── */
.terminal-tips-overlay {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 200;
    max-width: 380px;
    display: none;
}
.terminal-tips-overlay.visible {
    display: block;
}
.tip-banner {
    background: var(--t-bg-secondary, #1e2030);
    border: 1px solid var(--t-accent, #89b4fa);
    border-radius: 6px;
    padding: 10px 14px;
    font-family: 'Courier New', monospace;
    font-size: 0.82rem;
    color: var(--t-text, #cdd6f4);
    display: flex;
    align-items: flex-start;
    gap: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.tip-warning {
    border-color: var(--t-yellow, #f9e2af);
}
.tip-icon {
    flex-shrink: 0;
    color: var(--t-accent, #89b4fa);
}
.tip-warning .tip-icon {
    color: var(--t-yellow, #f9e2af);
}
.tip-message {
    flex: 1;
    line-height: 1.4;
}
.tip-close {
    background: none;
    border: none;
    color: var(--t-text-dim, #6c7086);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0;
    flex-shrink: 0;
    line-height: 1;
}
.tip-close:hover { color: var(--t-text, #cdd6f4); }

/* ── Multi-terminal Mux ─────────────────────────────────────── */

#mux-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

#mux-tabbar {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px 8px 0;
    background: var(--t-terminal-bg);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    min-height: 30px;
    flex-shrink: 0;
    overflow-x: auto;
    scrollbar-width: none;
}
#mux-tabbar::-webkit-scrollbar { display: none; }

.mux-tab {
    padding: 4px 10px;
    border-radius: 4px 4px 0 0;
    cursor: pointer;
    font-size: 12px;
    color: var(--t-text-dim);
    background: rgba(255,255,255,0.05);
    border: 1px solid transparent;
    border-bottom: none;
    white-space: nowrap;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.1s;
}
.mux-tab:hover { background: rgba(255,255,255,0.1); color: var(--t-text); }
.mux-tab--active {
    background: var(--t-terminal-bg);
    border-color: rgba(255,255,255,0.12);
    color: var(--t-text);
}
.mux-tab--add { font-size: 16px; padding: 2px 8px; }
.mux-tab-close { opacity: 0.4; font-size: 14px; line-height: 1; cursor: pointer; }
.mux-tab-close:hover { opacity: 1; color: var(--t-red); }
.mux-tab-rename {
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--t-accent);
    color: var(--t-text);
    font-size: 12px;
    font-family: inherit;
    width: 80px;
    outline: none;
}

#mux-panes {
    flex: 1;
    display: flex;
    overflow: hidden;
}
.mux-layout-split-h { flex-direction: row; }
.mux-layout-split-v { flex-direction: column; }
.mux-layout-single  { flex-direction: column; }

.mux-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 8px;
    position: relative;
    min-width: 0;
}

.mux-resize-handle {
    width: 4px;
    background: rgba(255,255,255,0.06);
    cursor: col-resize;
    flex-shrink: 0;
    transition: background 0.15s;
}
.mux-resize-handle:hover { background: var(--t-accent); }
.mux-layout-split-v .mux-resize-handle { width: auto; height: 4px; cursor: row-resize; }

.mux-hidden-input {
    position: absolute;
    left: -9999px;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}

.arc-terminal-panel {
    border: 1px solid var(--t-border);
    background: rgba(8, 12, 20, 0.9);
    border-radius: 8px;
    padding: 8px;
    position: relative;
    overflow: hidden;
}

.arc-terminal-pulse {
    position: absolute;
    inset: -30%;
    background: radial-gradient(circle at 30% 40%, color-mix(in srgb, var(--t-accent) 35%, transparent) 0%, transparent 60%),
                radial-gradient(circle at 70% 60%, color-mix(in srgb, var(--t-blue) 30%, transparent) 0%, transparent 65%);
    animation: arcPulse 3.2s ease-in-out infinite;
    opacity: 0.45;
    pointer-events: none;
}

.arc-terminal-head {
    position: relative;
    z-index: 1;
}

.arc-dim {
    color: var(--t-text-dim);
    position: relative;
    z-index: 1;
}

.arc-grid-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    position: relative;
    z-index: 1;
}

.arc-shell {
    position: relative;
    overflow: hidden;
}

.arc-shell > *:not(.arc-flux) {
    position: relative;
    z-index: 1;
}

.arc-list {
    overflow: auto;
}

.arc-reader {
    position: relative;
}

.arc-flux {
    position: absolute;
    width: 52vmin;
    height: 52vmin;
    border-radius: 999px;
    pointer-events: none;
    filter: blur(20px);
    mix-blend-mode: screen;
    z-index: 0;
}

.arc-flux-one {
    background: radial-gradient(circle at 30% 30%, color-mix(in srgb, var(--t-accent) 52%, transparent) 0%, transparent 68%);
    animation: arcFluxDriftA 3.6s ease-in-out infinite alternate;
}

.arc-flux-two {
    background: radial-gradient(circle at 70% 70%, color-mix(in srgb, var(--t-teal) 45%, transparent) 0%, transparent 70%);
    animation: arcFluxDriftB 4.2s ease-in-out infinite alternate;
}

.arc-grid-block {
    display: inline-block;
    margin: 4px 6px 8px 0;
    vertical-align: top;
}

.arc-grid-block-selected .arc-canvas {
    border-color: color-mix(in srgb, var(--t-accent) 85%, var(--t-text));
    box-shadow:
        0 0 0 1px color-mix(in srgb, var(--t-accent) 35%, transparent),
        0 0 14px color-mix(in srgb, var(--t-accent) 20%, transparent);
}

.arc-grid-label {
    color: var(--t-text-dim);
    font-size: 11px;
    margin-bottom: 4px;
}

.arc-canvas {
    border: 1px solid var(--t-border);
    border-radius: 4px;
    display: block;
}

@keyframes arcPulse {
    0% { transform: scale(1) translate3d(0,0,0); opacity: 0.35; }
    50% { transform: scale(1.05) translate3d(1%, -1%, 0); opacity: 0.55; }
    100% { transform: scale(1) translate3d(0,0,0); opacity: 0.35; }
}

@keyframes arcFluxDriftA {
    0% { transform: translate3d(-2%, -2%, 0) scale(0.98) rotate(0deg); }
    100% { transform: translate3d(2%, 1%, 0) scale(1.04) rotate(6deg); }
}

@keyframes arcFluxDriftB {
    0% { transform: translate3d(2%, 2%, 0) scale(1.02) rotate(0deg); }
    100% { transform: translate3d(-1%, -2%, 0) scale(0.96) rotate(-6deg); }
}

/* ── Mobile Chat Input Bar ────────────────── */

.mobile-chat-bar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: var(--t-terminal-bg);
    border-top: 1px solid color-mix(in srgb, var(--t-accent) 40%, var(--t-panel-border));
    padding: 8px 10px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    gap: 8px;
    align-items: center;
    font-family: 'Ubuntu Mono', 'Courier New', monospace;
    font-size: 14px;
    color: var(--t-text);
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.4);
}

.mobile-chat-bar .mcb-prompt {
    flex-shrink: 0;
    white-space: nowrap;
    opacity: 0.8;
}

.mobile-chat-bar .mcb-prompt .prompt-user {
    color: var(--t-green);
}

.mobile-chat-bar .mcb-prompt .prompt-host {
    color: var(--t-blue);
}

.mobile-chat-bar .mcb-prompt .prompt-symbol {
    color: var(--t-text);
}

.mobile-chat-bar .mcb-input {
    flex: 1;
    min-width: 0;
    background: color-mix(in srgb, var(--t-bg) 60%, var(--t-terminal-bg));
    border: 1px solid color-mix(in srgb, var(--t-accent) 30%, transparent);
    border-radius: 4px;
    padding: 8px 10px;
    color: var(--t-text);
    font-family: 'Ubuntu Mono', 'Courier New', monospace;
    font-size: 14px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.mobile-chat-bar .mcb-input:focus {
    border-color: color-mix(in srgb, var(--t-accent) 60%, transparent);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--t-accent) 25%, transparent);
}

.mobile-chat-bar .mcb-input::placeholder {
    color: var(--t-text-dim);
    opacity: 0.5;
}

.mobile-chat-bar .mcb-send {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border: 1px solid color-mix(in srgb, var(--t-accent) 50%, transparent);
    border-radius: 4px;
    background: color-mix(in srgb, var(--t-accent) 15%, transparent);
    color: var(--t-accent);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-appearance: none;
    appearance: none;
    padding: 0;
    line-height: 1;
}

.mobile-chat-bar .mcb-send:active {
    background: color-mix(in srgb, var(--t-accent) 30%, transparent);
}

/* Only show on touch devices with small screens */
@media (max-width: 768px) and (hover: none) and (pointer: coarse) {
    .mobile-chat-bar.visible {
        display: flex;
    }

    /* Add bottom padding to terminal-lines so content isn't hidden behind the bar */
    body.mobile-chat-active .terminal-lines {
        padding-bottom: 60px;
    }
}

/* Hide on non-touch / large screens regardless of .visible class */
@media (min-width: 769px), (hover: hover) and (pointer: fine) {
    .mobile-chat-bar {
        display: none !important;
    }
}
