:root {
    --bg: #fff7ed;
    --card: #ffffff;
    --border: #e7c9a8;
    --text: #2b2118;
    --muted: #78716c;
    --accent: #ea580c;
    --accent-hover: #c2410c;
    --accent-soft: #fdf1e3;
    --accent-soft-hover: #fbe3c4;
    --subheading: #9a3412;
    --label: #44403c;
    --danger: #dc2626;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--card);
}

header h1 {
    margin: 0;
    font-size: 1.4rem;
    color: var(--accent);
}

main {
    max-width: min(860px, 92vw);
    margin: 0 auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

section {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

section h2 {
    margin: 0 0 1rem;
    font-size: 1.1rem;
    color: var(--subheading);
}

.hidden {
    display: none;
}

.muted {
    color: var(--muted);
}

/* Vehicle list */
.vehicle-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.vehicle-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: clamp(0.6rem, 1vw, 1rem) clamp(0.8rem, 1.4vw, 1.4rem);
    background: var(--accent-soft);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.vehicle-list li:hover {
    background: var(--accent-soft-hover);
}

.vehicle-list li.selected {
    border-color: var(--accent);
    background: var(--accent-soft-hover);
}

.vehicle-list .name {
    font-weight: 600;
    color: var(--text);
    font-size: clamp(1rem, 1.2vw, 1.2rem);
}

.vehicle-list .mac {
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    font-size: clamp(0.85rem, 1vw, 1rem);
    color: var(--muted);
}

.vehicle-list .status {
    font-size: clamp(0.75rem, 0.9vw, 0.9rem);
    color: var(--muted);
}

/* On narrow screens the MAC address is secondary info and squeezes the
   layout (status/battery), so hide it. */
@media (max-width: 480px) {
    .vehicle-list li {
        flex-wrap: wrap;
        gap: 0.25rem 0.75rem;
    }
    .vehicle-list .name {
        flex: 1 1 auto;
    }
    .vehicle-list .mac {
        display: none;
    }
}

/* Vehicle list battery indicator */
.vehicle-list .status-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.vehicle-battery {
    display: inline-flex;
    align-items: center;
    gap: 1px;
}

.vehicle-battery-bar {
    position: relative;
    width: 38px;
    height: 16px;
    border: 2px solid #000;
    border-radius: 3px;
    background: #000;
    overflow: hidden;
    flex-shrink: 0;
}

.vehicle-battery-fill {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    background: #22c55e;
    transition: width 0.3s ease;
    overflow: hidden;
}

.vehicle-battery-value {
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    font-size: 0.6rem;
    line-height: 1;
    font-weight: 700;
    color: #000;
    white-space: nowrap;
}

/* The little terminal nub on the right, like a real battery. */
.vehicle-battery-cap {
    flex-shrink: 0;
    width: 3px;
    height: 8px;
    background: #000;
    border-radius: 0 2px 2px 0;
}

/* Control body: two columns.
   Left  = gauges + map (stacked vertically).
   Right = joystick, or the AI chat in AI mode.
   Matches the two buttons (toggle) above in horizontal alignment. */
.control-body {
    flex: 1;
    min-height: 0;
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

.control-left {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 0.75rem;
}

.control-gauges {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.75rem;
}

.control-left .map-wrap {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

.control-right {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Joystick: the physical pad is larger than the visible ring — the extra
   border-box padding area is still draggable (see the ::after hit zone).
   Scales with the viewport width so it looks right on phones and PCs. */
.joystick {
    width: clamp(220px, 20vw, 300px);
    height: clamp(220px, 20vw, 300px);
    border-radius: 50%;
    background: var(--accent-soft);
    border: 2px solid var(--border);
    position: relative;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.08);
}

/* Visible guide ring (smaller than the pad). Drawn as a centered child-
   sized circle so the pad area itself stays grabbable. */
.joystick::before {
    content: "";
    position: absolute;
    inset: 15%;
    border-radius: 50%;
    border: 2px solid var(--border);
    background:
        linear-gradient(var(--border), var(--border)) center/100% 1px no-repeat,
        linear-gradient(var(--border), var(--border)) center/1px 100% no-repeat;
    pointer-events: none;
}

.joystick-thumb {
    position: absolute;
    left: 50%;
    top: 50%;
    width: clamp(60px, 6vw, 92px);
    height: clamp(60px, 6vw, 92px);
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    transform: translate(-50%, -50%);
    pointer-events: none;
    transition: transform 0.08s ease-out;
}

/* Follow the finger 1:1 (no lag) while dragging. */
.joystick-active .joystick-thumb {
    transition: none;
}

button {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.15s;
}

button:hover {
    background: var(--accent-hover);
}

/* Control panel header */
.landscape-notice {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    margin-bottom: 1.25rem;
    background: var(--accent-soft);
    border: 1px solid var(--accent);
    border-radius: 8px;
    color: var(--accent);
    font-size: 0.95rem;
    text-align: center;
}

/* Hide once the device is actually in landscape. */
@media (orientation: landscape) {
    .landscape-notice {
        display: none;
    }
}

/* Vehicle-disconnect notice: overlays the control section IN PLACE (so no
   control gets pushed around) when the selected vehicle drops. The section
   (#control) is the positioning anchor. */
.disconnect-notice {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem;
    background: rgba(254, 226, 226, 0.94); /* translucent red wash */
    border: 1px solid var(--danger);
    border-radius: 10px;
    color: var(--danger);
    font-size: 1.05rem;
    text-align: center;
    backdrop-filter: blur(2px);
}

.disconnect-notice.hidden {
    display: none;
}

/* While driving: fill the viewport, no scrolling (mobile landscape). */
/* While driving: fill the viewport, no scrolling. 100vh fallback first,
   then svh (smallest viewport = always visible on phones with browser UI),
   then dvh for dynamic behavior where supported. */
body.driving {
    height: 100vh;
    height: 100svh;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    /* Kill browser gestures (double-tap zoom, pull-to-refresh) while driving. */
    touch-action: manipulation;
    overscroll-behavior: none;
}

/* The site header is unnecessary in controller mode — drop it to free
   vertical space (this also covers fullscreen, where there is no browser
   bar and the drive controls should own the whole screen). */
body.driving > header {
    display: none;
}

body.driving main {
    flex: 1;
    min-height: 0;
    /* Cap the width so the controls stay cohesive on big monitors instead
       of stretching apart with a huge void between map and joystick. */
    max-width: 1150px;
    width: 100%;
    margin: 0 auto;
    gap: 0;
    /* Generous padding so nothing is clipped on phones with rounded
       corners/notches, plus the device's safe-area insets (notch/home
       indicator areas) where the browser reports them. */
    padding:
        calc(env(safe-area-inset-top, 0px) + 1rem)
        calc(env(safe-area-inset-right, 0px) + 1rem)
        calc(env(safe-area-inset-bottom, 0px) + 1rem)
        calc(env(safe-area-inset-left, 0px) + 1rem);
}

body.driving section#control {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 0.75rem;
    margin: 0;
    overflow: hidden;
}

/* The control section is the anchor for the in-place disconnect overlay. */
section#control {
    position: relative;
}

body.driving .control-body {
    flex: 1;
    min-height: 0;
}

body.driving .map-wrap {
    flex: 1;
    min-height: 0;
    justify-content: center;
    align-items: center;
}

/* Compact gauges/joystick for short (landscape phone) viewports. */
@media (orientation: landscape) and (max-height: 520px) {
    .gauge-ring {
        width: 84px;
        height: 84px;
    }
    .gauge-value {
        font-size: 1.1rem;
    }
    .gauge-label {
        font-size: 0.7rem;
    }
    .joystick {
        width: 220px;
        height: 220px;
    }
    .joystick-thumb {
        width: 60px;
        height: 60px;
    }
    #ai-controller {
        width: 300px;
    }
}

/* In portrait: don't attempt the cramped column layout at all — show only
   the "rotate your device" notice, full screen. */
@media (orientation: portrait) {
    body.driving {
        height: 100vh;
        height: 100svh;
        height: 100dvh;
        overflow: hidden;
    }

    /* Hide everything except the notice while driving. */
    body.driving main > *:not(#control) {
        display: none;
    }
    body.driving .control-header,
    body.driving .control-body,
    body.driving .control-mode-toggle,
    body.driving #ai-controller {
        display: none;
    }

    /* The notice becomes the whole screen: a big, centered rotate prompt. */
    body.driving .landscape-notice {
        position: fixed;
        inset: 0;
        z-index: 10;
        margin: 0;
        border: none;
        border-radius: 0;
        background: var(--card);
        flex-direction: column;
        font-size: 1.2rem;
        gap: 1rem;
        display: flex; /* override the landscape rule; portrait shows it */
    }
    body.driving .landscape-notice::before {
        content: "🔄";
        font-size: 4rem;
        line-height: 1;
        /* Gently pulse to draw attention. */
        animation: rotate-hint 2s ease-in-out infinite;
    }

    @keyframes rotate-hint {
        0%, 100% { transform: rotate(0deg); }
        50% { transform: rotate(90deg); }
    }

    /* Only while NOT driving does the stacked-column fallback apply. */
    body:not(.driving) .control-body {
        flex-direction: column;
    }
    body:not(.driving) .control-right {
        flex-direction: row;
        justify-content: center;
    }
}

.control-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    min-height: 40px;
}

.control-header h2 {
    margin: 0;
    flex: 1;
    font-size: clamp(1.05rem, 1.4vw, 1.5rem);
}

button.back {
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid var(--border);
    font-size: 0.9rem;
    padding: 0.4rem 0.8rem;
}

button.back:hover {
    background: var(--accent-soft-hover);
}

/* Small square icon button in the control header (fullscreen toggle). */
.icon-btn {
    width: 38px;
    height: 38px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    line-height: 1;
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid var(--border);
    border-radius: 6px;
    flex-shrink: 0;
}

.icon-btn:hover {
    background: var(--accent-soft-hover);
}

/* Fullscreen icon: show the matching SVG for the current state. */
.icon-btn .icon-fullscreen-exit {
    display: none;
}

.icon-btn.fullscreen-active .icon-fullscreen {
    display: none;
}

.icon-btn.fullscreen-active .icon-fullscreen-exit {
    display: block;
}

/* Rename-in-header: swap the title for an edit input. */
.drive-title {
    flex: 1;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Ensure the .hidden class wins over .landscape-notice's display:flex. */
.landscape-notice.hidden {
    display: none;
}

.name-edit {
    flex: 1;
    min-width: 0;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--accent);
    border-radius: 6px;
    font-size: 1em;
    font-weight: 600;
    background: var(--card);
    color: var(--text);
}

/* Battery bar (top-right, matches the selection-menu style: black body,
   green fill with the percent inside, and a terminal cap on the right). */
.battery {
    display: inline-flex;
    align-items: center;
    gap: 1px;
    flex-shrink: 0;
}

.battery-bar {
    position: relative;
    width: 52px;
    height: 20px;
    border: 2px solid #000;
    border-radius: 3px;
    background: #000;
    overflow: hidden;
}

.battery-fill {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 0%;
    background: #22c55e;
    transition: width 0.3s ease;
    overflow: hidden;
}

.battery-value {
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    font-size: 0.7rem;
    line-height: 1;
    font-weight: 700;
    color: #000;
    white-space: nowrap;
}

.battery-cap {
    flex-shrink: 0;
    width: 3px;
    height: 10px;
    background: #000;
    border-radius: 0 2px 2px 0;
}

/* Motor load gauges (conic-gradient ring + needle), compact top-left. */
.gauge {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
}

/* The ring: a 180-degree arc sweeping from the left, over the top, to the
   right (like a car gauge). White 0-70%, green 70-90%, red 90-100%. */
.gauge-ring {
    position: relative;
    width: clamp(96px, 8vw, 130px);
    height: clamp(96px, 8vw, 130px);
    border-radius: 50%;
}

/* The colored arc is a pseudo-element so the mask only applies to the ring,
   not to the needle/hub children. */
.gauge-ring::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: conic-gradient(
        from 270deg,
        var(--accent-soft-hover) 0deg 126deg,   /* 0-70% white */
        #22c55e 126deg 162deg,                  /* 70-90% green */
        #ef4444 162deg 180deg,                  /* 90-100% red */
        transparent 180deg 360deg
    );
    /* Cut out the center to make a ring. */
    -webkit-mask: radial-gradient(circle, transparent 58%, #000 60%);
    mask: radial-gradient(circle, transparent 58%, #000 60%);
}

/* The needle: a tapered needle pivoting at the exact center of the ring,
   pointing upward toward the arc. */
.gauge-needle {
    position: absolute;
    left: 50%;
    bottom: 50%;
    width: 5px;
    height: 50%;
    margin-left: -2.5px; /* center the 5px-wide needle on the ring center */
    background: var(--text);
    transform-origin: 50% 100%; /* pivot at bottom-center (ring center) */
    transform: rotate(-90deg); /* start at 0% (left) */
    clip-path: polygon(50% 0%, 100% 100%, 0% 100%); /* tapered needle */
    transition: transform 0.3s ease;
    z-index: 1;
}

/* Center hub over the pivot point. */
.gauge-hub {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 12px;
    height: 12px;
    background: var(--text);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
    box-shadow: 0 0 0 3px var(--card);
}

/* The percent sits in the empty lower half of the ring, below the needle's
   sweep and the hub, so it is always readable. */
.gauge-value {
    position: absolute;
    left: 50%;
    top: 72%;
    transform: translate(-50%, -50%);
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    font-size: clamp(1.2rem, 1.6vw, 1.8rem);
    font-weight: 700;
    color: var(--text);
    z-index: 3;
    pointer-events: none;
}

.gauge-label {
    position: absolute;
    left: 50%;
    bottom: 5%;
    transform: translateX(-50%);
    font-size: clamp(0.7rem, 0.9vw, 0.9rem);
    font-weight: 600;
    color: var(--muted);
    white-space: nowrap;
}

/* Position map (center column). */
.map-wrap {
    position: relative;
    display: flex;
    justify-content: flex-start;
}

#map {
    display: block; /* no inline baseline gap inside the box */
    background: var(--accent-soft);
    border: 1px solid var(--border);
    border-radius: 10px;
}

/* Shrink-wrap box around the canvas: exactly the canvas' display size.
   Its only absolutely-positioned children anchor to the canvas edges. */
.map-canvas-box {
    position: relative;
    line-height: 0;
}

/* Reset button pinned to the canvas' bottom-right corner (just the arrow). */
.map-canvas-box button {
    position: absolute;
    right: 6px;
    bottom: 6px;
    width: 30px;
    height: 30px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    line-height: 1;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--accent);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(2px);
}

.map-canvas-box button:hover {
    background: #fff;
    color: var(--accent-hover);
}

/* ---- Control mode toggle (manual vs AI) ---- */
.control-mode-toggle {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.mode-btn {
    flex: 1;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: clamp(0.9rem, 1vw, 1.05rem);
    font-weight: 600;
    cursor: pointer;
}

.mode-btn:hover {
    background: var(--accent-soft-hover);
}

.mode-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* ---- AI driving panel (replaces the joystick in the right column) ---- */
#manual-controller {
    display: contents;
}

/* ID selector beats the generic .hidden rule, so force-hide manually. */
#manual-controller.hidden,
#ai-controller.hidden {
    display: none;
}

#ai-controller {
    width: clamp(280px, 24vw, 380px);
    max-width: 100%;
    height: clamp(240px, 20vw, 300px); /* match the joystick so switching doesn't re-layout */
    max-height: 300px;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    text-align: left;
    overflow: hidden;
}

.ai-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.1rem;
}

.ai-header h3 {
    margin: 0;
    font-size: clamp(1.05rem, 1.3vw, 1.3rem);
    color: var(--subheading);
}

.ai-header-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.ai-badge {
    font-size: clamp(0.75rem, 0.9vw, 0.9rem);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.25rem 0.7rem;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
}

.ai-badge[data-state="running"] {
    background: #dcfce7;
    color: #15803d;
}

.ai-badge[data-state="error"] {
    background: #fee2e2;
    color: var(--danger);
}

/* The prompt input with the send/stop button as a separate element on its
   right — outside the field, so tapping it never opens the keyboard. */
.ai-input-wrap {
    display: flex;
    align-items: stretch;
    gap: 0.4rem;
    width: 100%;
}

.ai-prompt {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0.6rem 0.8rem; /* no reserved button space anymore */
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: clamp(0.95rem, 1.1vw, 1.15rem);
    background: var(--card);
    color: var(--text);
}

.ai-prompt:focus {
    outline: none;
    border-color: var(--accent);
}

/* Standalone send/stop button to the right of the input. */
.ai-send {
    flex: 0 0 auto;
    width: 2.6rem;
    align-self: stretch;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    padding: 0;
}

.ai-send svg {
    width: 1.2rem;
    height: 1.2rem;
}

.ai-send:hover {
    background: var(--accent-hover);
}

/* While running, the button becomes a red stop square (icon swaps too). */
.ai-send .icon-stop {
    display: none;
}

.ai-send.stop {
    background: var(--danger);
}

.ai-send.stop .icon-send {
    display: none;
}

.ai-send.stop .icon-stop {
    display: block;
}

.ai-send.stop:hover {
    background: #b91c1c;
}

.ai-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-danger:disabled,
.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-train {
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid var(--accent);
    padding: 0.3rem 0.7rem;
    font-size: clamp(0.75rem, 0.9vw, 0.9rem);
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
}

.btn-train:hover {
    background: var(--accent-soft-hover);
}

.btn-train:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ai-status {
    margin-top: 0.3rem;
    font-size: clamp(0.8rem, 0.95vw, 0.95rem);
    flex: 0 0 auto;
    max-height: 4.8em;
    overflow-y: auto;
    word-break: break-word;
}

.ai-logs {
    margin-top: 0.3rem;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: clamp(0.75rem, 0.9vw, 0.9rem);
    color: var(--label);
    background: var(--accent-soft);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem;
}

.ai-logs div {
    padding: 0.08rem 0;
    border-bottom: 1px dashed var(--border);
}

.ai-logs div:last-child {
    border-bottom: none;
}

/* Mobile keyboard: while the AI prompt input is focused, the on-screen
   keyboard covers the lower half of the screen. The driving view cannot
   scroll, so re-anchor the AI panel to the TOP of the screen while typing:
   the input lands in the visible area and the log collapses to a sliver.
   (The keyboard overlays thanks to interactive-widget=resizes-visual.) */
body.keyboard-open #ai-controller {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 0.5rem);
    left: 0.5rem;
    right: 0.5rem;
    width: auto;
    max-width: none;
    height: auto;
    max-height: 40vh;
    z-index: 20;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    background: var(--card);
    border-radius: 10px;
    padding: 0.5rem;
}

body.keyboard-open #ai-controller .ai-logs {
    display: none; /* keyboard eats most of the screen; hide the log box */
}

/* Live progress mode (while the AI runs): tool-call lines only, newest at
   the bottom, auto-scrolled. Replaced by the final result when done. */
.ai-logs.live {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.ai-logs.live div {
    border-bottom: none;
}
