:root {
  color-scheme: dark;
  --bg: #101110;
  --panel: #171917;
  --panel-2: #1d201d;
  --panel-3: #242824;
  --line: #30352f;
  --line-soft: #252a25;
  --text: #f1f4ef;
  --muted: #9ba59b;
  --dim: #69736a;
  --green: #8ee3a8;
  --green-strong: #54c979;
  --green-wash: rgba(116, 217, 145, .13);
  --amber: #e9bd69;
  --red: #ef8d8d;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); }
body { min-height: 100vh; background: radial-gradient(900px 500px at 50% -180px, #273329 0, var(--bg) 65%); }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .52; cursor: wait; }
button, input, textarea { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.shell { width: 100%; min-height: 100vh; }
.auth-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(470px, 100%); padding: 34px; border: 1px solid var(--line); border-radius: 20px; background: rgba(23,25,23,.96); box-shadow: 0 24px 80px rgba(0,0,0,.34); }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; background: var(--green); color: #102018; font-weight: 900; font-size: 24px; box-shadow: 0 0 0 7px rgba(142,227,168,.1); }
.brand-mark.small { width: 28px; height: 28px; border-radius: 9px; font-size: 16px; box-shadow: none; }
.auth-heading { margin: 28px 0 20px; }
.eyebrow { color: var(--green); font-size: 10px; font-weight: 800; letter-spacing: .18em; }
.auth-heading h1 { margin: 8px 0 10px; font-size: clamp(23px, 5vw, 30px); letter-spacing: -.035em; }
.auth-heading p { margin: 0; color: var(--muted); line-height: 1.6; }
.auth-form { display: flex; gap: 9px; }
input, textarea { width: 100%; border: 1px solid var(--line); border-radius: 11px; background: #111311; color: var(--text); outline: none; }
input { padding: 12px 13px; }
input:focus, textarea:focus { border-color: var(--green-strong); box-shadow: 0 0 0 3px rgba(84,201,121,.13); }
.auth-form button, .send-button { border: 0; border-radius: 11px; background: var(--green); color: #122219; font-weight: 800; white-space: nowrap; padding: 11px 17px; }
.error, .inline-error { color: var(--red); font-size: 13px; white-space: pre-wrap; }
.error { min-height: 18px; margin-top: 12px; }

.app-panel { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { height: 58px; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; border-bottom: 1px solid var(--line-soft); background: rgba(16,17,16,.9); }
.topbar-brand, .topbar-actions, .thread-heading, .thread-title-row, .heading-actions, .composer-footer, .composer-actions, .session-title-row, .message-head, .state-card, .detail-id-heading { display: flex; align-items: center; }
.topbar-brand { gap: 10px; min-width: 0; }
.topbar-brand strong { display: block; font-size: 13px; letter-spacing: .01em; }
.topbar-brand span { display: flex; align-items: center; gap: 6px; margin-top: 2px; color: var(--muted); font-size: 11px; }
.connection-dot, .session-dot, .event-marker { display: inline-block; flex: 0 0 auto; border-radius: 50%; }
.connection-dot { width: 7px; height: 7px; background: var(--green-strong); }
.connection-dot.working { box-shadow: 0 0 0 4px rgba(84,201,121,.14); animation: pulse 1.5s infinite; }
.topbar-actions { gap: 7px; }
.icon-button, .subtle-button, .text-button { border: 1px solid var(--line); background: transparent; color: var(--muted); }
.icon-button { width: 33px; height: 33px; display: grid; place-items: center; padding: 7px; border-radius: 9px; }
.icon-button:hover, .subtle-button:hover { color: var(--text); background: var(--panel-2); }
.icon-button svg, .subtle-button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.subtle-button { display: inline-flex; align-items: center; gap: 7px; border-radius: 9px; padding: 8px 11px; font-size: 12px; }
.mobile-only { display: none; }

.workbench { flex: 1; min-height: 0; display: grid; grid-template-columns: 275px minmax(0, 1fr) 260px; }
.sidebar { min-width: 0; background: rgba(20,22,20,.86); }
.sessions-sidebar { border-right: 1px solid var(--line-soft); padding: 17px 13px 13px; display: flex; flex-direction: column; min-height: calc(100vh - 58px); }
.details-sidebar { border-left: 1px solid var(--line-soft); padding: 17px 16px 13px; display: flex; flex-direction: column; min-height: calc(100vh - 58px); }
.sidebar-heading { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.sidebar-heading h2 { margin: 4px 0 2px; font-size: 16px; letter-spacing: -.02em; }
.sidebar-heading small { color: var(--muted); font-size: 11px; }
.heading-actions { gap: 5px; }
.search-box { height: 35px; display: flex; align-items: center; gap: 7px; padding: 0 9px; border: 1px solid var(--line); border-radius: 9px; background: #111311; color: var(--dim); }
.search-box svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.search-box input { min-width: 0; height: 100%; padding: 0; border: 0; background: transparent; box-shadow: none; font-size: 12px; }
.search-box kbd { padding: 1px 4px; border: 1px solid var(--line); border-radius: 4px; color: var(--dim); font-size: 10px; }
.session-filters { display: flex; gap: 3px; padding: 11px 0 9px; }
.filter-button { flex: 1; padding: 6px 4px; border: 1px solid transparent; border-radius: 7px; background: transparent; color: var(--muted); font-size: 11px; }
.filter-button span { color: var(--dim); }
.filter-button.active { border-color: var(--line); background: var(--panel-3); color: var(--text); }
.filter-button.active span { color: var(--green); }
.sessions-list { min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; padding-right: 2px; }
.session-item { width: 100%; padding: 10px 9px; border: 1px solid transparent; border-radius: 9px; background: transparent; color: var(--text); text-align: left; }
.session-item:hover { background: var(--panel-2); }
.session-item.selected { border-color: rgba(142,227,168,.42); background: var(--green-wash); }
.session-title-row { min-width: 0; gap: 7px; }
.session-title-row strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 650; }
.session-item small { display: block; margin: 5px 0 0 15px; color: var(--muted); font-size: 10px; }
.session-sub { display: block; margin: 4px 0 0 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dim); font: 9px ui-monospace, SFMono-Regular, Consolas, monospace; }
.session-dot { width: 7px; height: 7px; background: var(--dim); }
.session-dot.working { background: var(--green-strong); }
.session-dot.completed { background: #86a8e7; }
.session-dot.aborted { background: var(--red); }
.session-dot.archived { background: #8d7ca2; }
.session-dot.pulse { animation: pulse 1.5s infinite; }
.sessions-empty, .details-empty { margin: 24px 4px; color: var(--muted); font-size: 12px; line-height: 1.55; text-align: center; }

.chat-column { min-width: 0; min-height: calc(100vh - 58px); display: grid; grid-template-rows: auto minmax(0, 1fr) auto; background: rgba(16,17,16,.55); }
.thread-header { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 15px 24px; border-bottom: 1px solid var(--line-soft); }
.thread-heading { min-width: 0; gap: 10px; }
.thread-title-wrap { min-width: 0; }
.thread-title-row { gap: 9px; min-width: 0; }
.thread-title-row h1 { min-width: 0; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 17px; letter-spacing: -.025em; }
.thread-subtitle { margin: 5px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 11px; }
.thread-header p { margin: 5px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 11px; }
.status-badge { display: inline-flex; align-items: center; padding: 3px 7px; border-radius: 99px; background: var(--panel-3); color: var(--muted); font-size: 10px; white-space: nowrap; }
.status-badge.working { background: rgba(84,201,121,.17); color: var(--green); }
.status-badge.completed { background: rgba(134,168,231,.15); color: #a9c0f2; }
.status-badge.aborted { background: rgba(239,141,141,.15); color: var(--red); }
.status-badge.archived { background: rgba(141,124,162,.16); color: #baa7d0; }
.messages { min-height: 0; overflow-y: auto; padding: 26px clamp(18px, 5vw, 76px) 20px; scroll-behavior: smooth; }
.empty-state { min-height: 100%; display: grid; place-content: center; justify-items: center; gap: 7px; color: var(--muted); text-align: center; }
.empty-glyph { width: 47px; height: 47px; display: grid; place-items: center; margin-bottom: 7px; border: 1px solid var(--line); border-radius: 15px; background: var(--panel); color: var(--green); }
.empty-glyph svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.empty-state h2 { margin: 0; color: var(--text); font-size: 17px; }
.empty-state p { max-width: 360px; margin: 0 0 10px; font-size: 12px; line-height: 1.55; }
.message { max-width: min(780px, 92%); margin: 0 auto 21px; }
.message.user { margin-left: auto; }
.message-head { gap: 8px; margin-bottom: 7px; color: var(--muted); font-size: 11px; }
.message.user .message-head { justify-content: flex-end; }
.message-head time { color: var(--dim); font-size: 10px; }
.message-body { padding: 13px 15px; border: 1px solid var(--line); border-radius: 13px; background: var(--panel); color: var(--text); line-height: 1.62; white-space: pre-wrap; overflow-wrap: anywhere; }
.message.user .message-body { border-color: rgba(142,227,168,.3); background: var(--green-wash); }
.timeline-event { max-width: min(780px, 92%); margin: 0 auto 12px; border: 1px solid var(--line-soft); border-radius: 10px; background: rgba(23,25,23,.72); color: var(--muted); }
.timeline-event summary { display: flex; align-items: center; gap: 8px; padding: 9px 11px; cursor: pointer; list-style: none; font-size: 11px; }
.timeline-event summary::-webkit-details-marker { display: none; }
.timeline-event summary time { margin-left: auto; color: var(--dim); font-size: 10px; }
.event-marker { width: 6px; height: 6px; background: var(--green-strong); }
.timeline-event.command .event-marker { background: var(--amber); }
.timeline-event.file_change .event-marker { background: #88abe8; }
.timeline-event pre { max-height: 260px; overflow: auto; margin: 0; padding: 0 12px 11px 25px; color: #b6c1b7; font: 10px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.history-notice { margin: 10px 24px 0; padding: 7px 10px; border: 1px solid rgba(233,189,105,.26); border-radius: 8px; background: rgba(233,189,105,.08); color: var(--amber); font-size: 11px; }
.composer { margin: 0 clamp(14px, 4vw, 60px) 18px; padding: 10px 12px 9px; border: 1px solid var(--line); border-radius: 13px; background: rgba(29,32,29,.95); box-shadow: 0 14px 36px rgba(0,0,0,.22); }
.composer textarea { display: block; min-height: 31px; max-height: 180px; resize: none; padding: 4px 3px 8px; border: 0; background: transparent; line-height: 1.45; }
.composer textarea:focus { box-shadow: none; }
.composer-footer { justify-content: space-between; gap: 10px; color: var(--dim); font-size: 10px; }
.composer-actions { gap: 9px; }
.keyboard-hint { color: var(--dim); }
.send-button { display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px; font-size: 11px; }
.send-button svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.inline-error { max-width: 780px; margin: 0 auto 12px; padding: 10px 12px; border: 1px solid rgba(239,141,141,.3); border-radius: 9px; background: rgba(239,141,141,.1); }

.details-heading { margin-bottom: 23px; }
.details-content { min-width: 0; }
.detail-section { padding: 0 0 19px; margin-bottom: 18px; border-bottom: 1px solid var(--line-soft); }
.detail-section h3 { margin: 0 0 11px; color: var(--dim); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.state-card { gap: 10px; }
.large-status-dot { width: 10px; height: 10px; flex: 0 0 auto; border-radius: 50%; background: var(--dim); }
.large-status-dot.working { background: var(--green-strong); box-shadow: 0 0 0 5px rgba(84,201,121,.14); animation: pulse 1.5s infinite; }
.large-status-dot.completed { background: #86a8e7; }
.large-status-dot.aborted { background: var(--red); }
.large-status-dot.archived { background: #8d7ca2; }
.state-card small, .state-card strong, .state-card span { display: block; }
.state-card small { color: var(--dim); font-size: 10px; }
.state-card strong { margin: 2px 0; font-size: 13px; }
.state-card span { color: var(--muted); font-size: 10px; }
.detail-list { display: grid; gap: 9px; margin: 0; }
.detail-list div { display: flex; justify-content: space-between; gap: 10px; }
.detail-list dt { color: var(--muted); font-size: 11px; }
.detail-list dd { max-width: 145px; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-size: 11px; text-align: right; }
.path-value, .thread-id-value { display: block; color: var(--muted); font: 10px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; overflow-wrap: anywhere; }
.property-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.property-chip { padding: 4px 7px; border: 1px solid var(--line); border-radius: 99px; color: var(--dim); font-size: 10px; }
.property-chip.active { border-color: rgba(142,227,168,.3); color: var(--green); background: var(--green-wash); }
.detail-id-heading { justify-content: space-between; }
.text-button { padding: 3px 7px; border-radius: 6px; font-size: 10px; }
.details-footer { margin-top: auto; padding-top: 12px; overflow: hidden; color: var(--dim); font: 9px/1.4 ui-monospace, SFMono-Regular, Consolas, monospace; text-overflow: ellipsis; white-space: nowrap; }
.toast { position: fixed; z-index: 20; right: 18px; bottom: 18px; max-width: min(360px, calc(100vw - 36px)); padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; background: #252a25; color: var(--text); font-size: 11px; opacity: 0; transform: translateY(8px); pointer-events: none; transition: .2s ease; }
.toast:not(:empty) { opacity: 1; transform: translateY(0); }
.toast.error { border-color: rgba(239,141,141,.35); background: #382222; color: var(--red); }
.drawer-scrim { display: none; }

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .42; } }

@media (max-width: 980px) {
  .workbench { grid-template-columns: 245px minmax(0, 1fr); }
  .details-sidebar { display: none; }
  .mobile-only { display: inline-grid; }
  .topbar .mobile-only { display: inline-grid; }
}

@media (max-width: 700px) {
  body { background: var(--bg); }
  .topbar { height: 54px; padding: 0 11px; }
  .topbar-brand strong { font-size: 12px; }
  .topbar-actions { gap: 4px; }
  .topbar .subtle-button { padding: 7px 8px; }
  .topbar .subtle-button span { display: none; }
  .workbench { position: relative; display: block; }
  .chat-column { min-height: calc(100vh - 54px); }
  .sessions-sidebar, .details-sidebar { position: fixed; z-index: 12; top: 54px; bottom: 0; width: min(320px, 88vw); min-height: 0; display: flex; border: 0; box-shadow: 18px 0 45px rgba(0,0,0,.4); transition: transform .2s ease; }
  .sessions-sidebar { left: 0; transform: translateX(-105%); }
  .details-sidebar { right: 0; transform: translateX(105%); }
  .app-panel[data-drawer="sessions"] .sessions-sidebar { transform: translateX(0); }
  .app-panel[data-drawer="details"] .details-sidebar { transform: translateX(0); }
  .drawer-scrim { position: fixed; z-index: 11; inset: 54px 0 0; display: block; background: rgba(0,0,0,.52); opacity: 0; pointer-events: none; transition: opacity .2s ease; }
  .drawer-scrim.visible { opacity: 1; pointer-events: auto; }
  .thread-header { min-height: 68px; padding: 11px 12px; }
  .thread-title-row h1 { font-size: 15px; }
  .thread-header p { font-size: 10px; }
  .messages { padding: 18px 12px 12px; }
  .message, .timeline-event { max-width: 100%; }
  .composer { margin: 0 8px max(8px, env(safe-area-inset-bottom)); }
  .keyboard-hint { display: none; }
  .auth-card { padding: 25px 20px; }
  .auth-form { flex-direction: column; }
  .auth-form button { width: 100%; }
}
