:root {
  color-scheme: dark;
  --bg: #07090d;
  --surface: #10151d;
  --surface-raised: #171e28;
  --border: rgba(255, 255, 255, 0.09);
  --text: #f5f7fa;
  --muted: #a1abba;
  --blue: #8bc5ff;
  --green: #60e3ab;
  --amber: #ffd283;
  --red: #ff929a;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { color: var(--text); background: var(--bg); font-size: 14px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; }
button, input, textarea, select, a { -webkit-tap-highlight-color: transparent; }
button, a, select { cursor: pointer; }
button { color: inherit; }
button:disabled, select:disabled { cursor: default; opacity: 0.45; }
button, a { transition: background 160ms ease, border-color 160ms ease, color 160ms ease; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.skip-link { position: fixed; z-index: 60; top: 10px; left: -9999px; padding: 10px 14px; color: #07110c; background: var(--green); border-radius: 8px; }
.skip-link:focus { left: 12px; }
.muted-text { color: var(--muted); }
.text-button, .icon-button { border: 1px solid transparent; background: transparent; border-radius: 9px; }
.text-button { min-height: 44px; padding: 7px 13px; color: var(--muted); }
.text-button:hover { color: var(--text); background: var(--surface-raised); }
.icon-button { width: 44px; height: 44px; display: grid; place-items: center; flex: 0 0 auto; color: var(--muted); }
.icon-button:hover:not(:disabled) { color: var(--text); background: var(--surface-raised); }
.primary-button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 44px; padding: 10px 19px; border: 1px solid #73b5f7; border-radius: 10px; background: #92ccff; color: #071b2b; font-weight: 650; text-decoration: none; }
.primary-button:hover:not(:disabled) { background: #b2dcff; }
.logo-box { display: grid; place-items: center; width: 58px; height: 42px; background: white; border-radius: 6px; flex: 0 0 auto; }
.logo-box img { width: 48px; height: 34px; object-fit: contain; }
.login-screen { height: 100%; height: 100dvh; display: grid; place-items: center; padding: 24px; background: radial-gradient(ellipse at 50% 20%, #102137, transparent 65%), var(--bg); overflow-y: auto; }
.login-card { width: 100%; max-width: 420px; padding: 38px 30px 28px; text-align: center; background: #10151ddd; border: 1px solid var(--border); border-radius: 22px; }
.login-logo { width: 90px; height: 64px; margin: 0 auto 25px; }
.login-logo img { width: 76px; height: 53px; }
.eyebrow { font-size: 11px; font-weight: 650; letter-spacing: 0.22em; color: var(--blue); }
.login-card h1 { margin: 7px 0 12px; font-size: 30px; font-weight: 650; }
.login-intro { margin: 0 0 27px; color: #bcc8d6; line-height: 1.9; }
.login-button { width: 100%; }
#login-status { margin: 15px 0 0; overflow-wrap: anywhere; }
.login-footer { margin: 30px 0 0; color: var(--muted); font-size: 12px; }
.workbench { height: 100%; height: 100dvh; display: flex; flex-direction: column; background: radial-gradient(ellipse at 80% -20%, #102038, transparent 65%), var(--bg); }
.topbar { min-height: 76px; flex: 0 0 76px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 23px; border-bottom: 1px solid var(--border); }
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; }
.brand strong { display: block; letter-spacing: 0.12em; font-size: 12px; }
.brand small { display: block; color: var(--muted); font-size: 11px; }
.topbar-actions { display: flex; align-items: center; gap: 14px; min-width: 0; }
.connection-status { font-size: 12px; color: var(--amber); display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.connection-status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.connection-status[data-state='connected'] { color: var(--green); }
.user-name { color: var(--muted); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workspace { min-height: 0; flex: 1; display: grid; grid-template-columns: 282px minmax(0, 1fr); }
.session-panel { min-width: 0; min-height: 0; display: flex; flex-direction: column; padding: 21px 14px 12px; border-right: 1px solid var(--border); background: #0e131acc; }
.panel-heading { display: flex; align-items: center; gap: 10px; padding: 0 7px; }
.panel-heading h1 { margin: 0; font-size: 16px; font-weight: 650; }
.count-badge { min-width: 24px; padding: 0 7px; border: 1px solid var(--border); border-radius: 7px; color: var(--muted); font-size: 12px; text-align: center; }
.panel-intro { margin: 5px 7px 17px; font-size: 12px; color: var(--muted); }
.session-search { margin-bottom: 17px; }
.session-search input { width: 100%; height: 42px; padding: 8px 12px; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 9px; }
input::placeholder, textarea::placeholder { color: #9ba6b5; opacity: 1; }
.device-list { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.device-group { margin-bottom: 19px; }
.device-heading { padding: 0 7px; margin: 0 0 7px; display: flex; align-items: center; justify-content: space-between; gap: 5px; }
.device-heading strong { font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-state { flex: 0 0 auto; font-size: 11px; color: var(--muted); }
.device-state[data-online='true'] { color: var(--green); }
.device-error { margin: 4px 7px 9px; color: var(--amber); font-size: 11px; overflow-wrap: anywhere; }
.session-button { width: 100%; display: block; margin: 4px 0; padding: 12px; text-align: left; border: 1px solid transparent; border-radius: 10px; background: transparent; }
.session-button:hover { background: #ffffff07; border-color: var(--border); }
.session-button[aria-current='true'] { background: #19355080; border-color: #5c9ad650; }
.session-project { display: flex; gap: 9px; justify-content: space-between; align-items: center; }
.session-project strong { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-status { font-size: 10px; white-space: nowrap; color: var(--muted); }
.session-status[data-status='developing'] { color: var(--blue); }
.session-status[data-status='confirmation'] { color: var(--amber); }
.session-status[data-status='error'] { color: var(--red); }
.session-title { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.devices-empty { padding: 20px 8px; color: var(--muted); font-size: 13px; }
.devices-empty strong { color: var(--text); font-weight: 550; }
.sidebar-note { padding: 10px 7px 0; margin: 0; color: var(--muted); font-size: 11px; border-top: 1px solid var(--border); }
.conversation { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.conversation-heading { flex: 0 0 auto; display: flex; align-items: center; gap: 12px; padding: 17px 26px; min-height: 85px; border-bottom: 1px solid var(--border); }
.conversation-title { min-width: 0; flex: 1; }
.conversation-title h2 { margin: 0; font-weight: 600; font-size: 17px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.conversation-title p { margin: 2px 0 0; font-size: 12px; color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.status-badge { white-space: nowrap; padding: 3px 9px; font-size: 11px; color: var(--muted); background: var(--surface-raised); border: 1px solid var(--border); border-radius: 8px; }
.status-badge[data-status='developing'] { color: var(--blue); }
.status-badge[data-status='confirmation'] { color: var(--amber); }
.status-badge[data-status='error'] { color: var(--red); }
.session-notice { margin: 12px 26px 0; padding: 9px 13px; border: 1px solid #ffd28340; background: #ffd28308; border-radius: 8px; font-size: 12px; color: var(--amber); overflow-wrap: anywhere; }
.conversation-scroll { min-height: 0; flex: 1; overflow-y: auto; padding: 24px 26px; scrollbar-width: thin; }
.messages, .requests { width: 100%; max-width: 900px; margin: 0 auto; }
.conversation-empty { max-width: 370px; margin: 6vh auto; text-align: center; color: var(--muted); }
.empty-symbol { display: grid; width: 58px; height: 58px; margin: 0 auto 18px; place-items: center; background: #173046; color: var(--blue); border-radius: 16px; }
.empty-symbol svg { width: 30px; height: 30px; }
.conversation-empty h3 { margin: 0 0 8px; color: var(--text); font-weight: 550; font-size: 19px; }
.conversation-empty p { margin: 0; font-size: 13px; line-height: 1.9; }
.message { margin-bottom: 24px; }
.message-label { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 12px; font-weight: 650; color: var(--blue); }
.message-label::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.message-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.8; }
.message[data-role='user'] { margin-left: 12%; padding: 15px 19px; background: #1b2939; border: 1px solid #5b7fa025; border-radius: 13px 13px 4px 13px; }
.message[data-role='user'] .message-label { color: #ccd6e2; }
.message[data-role='assistant'] { padding-right: 4%; }
.message[data-role='activity'] { margin-bottom: 13px; padding: 7px 11px; border-left: 2px solid #ffffff25; color: var(--muted); }
.message[data-role='activity'] .message-label { display: none; }
.message[data-role='activity'] .message-text { font-size: 12px; line-height: 1.6; }
.request-card { padding: 20px; margin: 0 0 17px; background: #201b12; border: 1px solid #c8994f50; border-radius: 12px; }
.request-card h3 { margin: 0 0 7px; font-weight: 600; font-size: 15px; color: var(--amber); }
.request-card p { margin: 5px 0 15px; color: #d6c9b5; overflow-wrap: anywhere; }
.request-command { margin: 10px 0 16px; max-height: 160px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; padding: 12px; border: 1px solid #ffd28325; border-radius: 8px; background: #090c11; color: #d7dfe9; font-family: ui-monospace, 'SFMono-Regular', monospace; font-size: 12px; }
.request-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.request-decline { min-height: 44px; padding: 9px 17px; background: transparent; border: 1px solid #ffffff30; border-radius: 9px; }
.request-decline:hover:not(:disabled) { background: #ffffff09; }
.question-group { min-width: 0; margin: 18px 0; padding: 0; border: 0; }
.question-group legend { margin-bottom: 10px; font-weight: 550; overflow-wrap: anywhere; }
.question-option { display: flex; align-items: flex-start; gap: 9px; min-height: 44px; padding: 9px 11px; border: 1px solid #ffffff1c; border-radius: 8px; margin-bottom: 7px; cursor: pointer; }
.question-option input { margin-top: 5px; accent-color: #8bc5ff; }
.question-option strong { display: block; font-weight: 550; }
.question-option small { display: block; color: #c4bba9; font-size: 12px; }
.question-freeform { display: block; width: 100%; margin-top: 8px; min-height: 70px; max-height: 140px; resize: vertical; padding: 10px; color: var(--text); background: #0c1119; border: 1px solid #ffffff26; border-radius: 8px; }
.permission-list { padding-left: 20px; color: #d6c9b5; font-size: 13px; overflow-wrap: anywhere; }
.secret-note { padding: 9px 12px; border-radius: 7px; background: #ffd28310; color: var(--amber); }
.composer { flex: 0 0 auto; padding: 14px 26px max(15px, env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: #0e1319e0; }
.composer textarea { display: block; width: 100%; max-height: 220px; min-height: 79px; resize: vertical; padding: 12px 14px; border: 1px solid #ffffff24; border-radius: 12px; color: var(--text); background: #151d27; font-size: 14px; line-height: 1.7; }
.composer textarea:disabled { background: #111720; }
.composer-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 9px; }
.composer-options { display: flex; align-items: center; gap: 9px; min-width: 0; }
.composer select { min-height: 44px; max-width: 170px; padding: 8px 10px; color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.stop-button { display: flex; align-items: center; justify-content: center; gap: 5px; min-height: 44px; padding: 8px 12px; background: transparent; border: 1px solid var(--border); border-radius: 8px; color: var(--muted); }
.stop-button:hover:not(:disabled) { color: var(--red); border-color: #ff929a70; }
.stop-button svg { width: 16px; height: 16px; }
.send-button { flex: 0 0 auto; }
.send-button svg { width: 18px; height: 18px; }
.composer-help { margin: 8px 0 0; min-height: 19px; font-size: 11px; color: var(--muted); }
.sessions-toggle { display: none; }
.sidebar-backdrop { position: fixed; z-index: 20; inset: 64px 0 0; border: 0; background: #0009; }
.toast { position: fixed; z-index: 50; bottom: max(22px, env(safe-area-inset-bottom)); left: 50%; transform: translate(-50%, 9px); width: max-content; max-width: min(500px, calc(100% - 32px)); padding: 11px 17px; border: 1px solid #ffffff26; border-radius: 10px; background: #222e3f; color: #eef4fc; opacity: 0; pointer-events: none; transition: opacity 170ms ease, transform 170ms ease; font-size: 13px; box-shadow: 0 6px 30px #0005; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 1440px) {
  .workspace { grid-template-columns: 305px minmax(0, 1fr); }
  .conversation-heading, .composer { padding-left: 42px; padding-right: 42px; }
  .conversation-scroll { padding-left: 42px; padding-right: 42px; }
}

@media (max-width: 900px) {
  .workspace { grid-template-columns: 242px minmax(0, 1fr); }
  .topbar { padding: 0 17px; }
  .topbar-actions { gap: 8px; }
  .conversation-heading { padding: 15px 17px; gap: 8px; }
  .conversation-scroll { padding: 20px 17px; }
  .composer { padding-left: 17px; padding-right: 17px; }
  .session-notice { margin-left: 17px; margin-right: 17px; }
  .user-name { max-width: 100px; }
}

@media (max-width: 640px) {
  body { font-size: 16px; }
  .topbar { flex-basis: 64px; min-height: 64px; padding: 0 12px; }
  .brand { gap: 9px; }
  .brand .logo-box { width: 47px; height: 35px; }
  .brand .logo-box img { width: 40px; height: 29px; }
  .brand strong { font-size: 10px; letter-spacing: 0.09em; }
  .brand small { font-size: 10px; }
  .user-name { display: none; }
  .topbar-actions { gap: 3px; }
  .topbar-actions .text-button { padding: 7px 9px; font-size: 12px; }
  .connection-status { font-size: 11px; gap: 5px; }
  .workspace { display: block; position: relative; }
  .conversation { width: 100%; height: 100%; }
  .session-panel { position: fixed; z-index: 30; top: 64px; left: 0; bottom: 0; width: min(300px, calc(100vw - 42px)); background: #0e131a; transform: translateX(-101%); visibility: hidden; transition: transform 180ms ease, visibility 180ms; }
  .workbench[data-sidebar-open='true'] .session-panel { transform: translateX(0); visibility: visible; }
  .sessions-toggle { display: grid; }
  .conversation-heading { padding: 10px 12px 10px 7px; min-height: 72px; gap: 5px; }
  .conversation-title h2 { font-size: 15px; }
  .conversation-title p { font-size: 11px; }
  .status-badge { padding: 2px 6px; font-size: 10px; }
  .conversation-scroll { padding: 19px 16px; }
  .session-notice { margin: 9px 12px 0; }
  .message[data-role='user'] { margin-left: 5%; padding: 12px 14px; }
  .message-text { font-size: 15px; }
  .request-card { padding: 15px; }
  .request-card p, .question-group, .question-freeform { font-size: 14px; }
  .composer { padding: 11px 12px max(11px, env(safe-area-inset-bottom)); }
  .composer textarea { min-height: 76px; max-height: 160px; font-size: 16px; padding: 10px 12px; }
  .composer select { max-width: 132px; font-size: 12px; }
  .composer-options { gap: 6px; }
  .stop-button { padding: 8px; font-size: 12px; }
  .send-button { padding: 10px 13px; font-size: 14px; }
  .composer-help { font-size: 10px; }
  .conversation-empty { margin-top: 5vh; }
  .login-card { padding: 28px 24px 23px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}
