:root {
  color-scheme: light;
  --ink: #222729;
  --muted: #6c7578;
  --soft: #f3f5f4;
  --line: #d9dedc;
  --paper: #ffffff;
  --sidebar: #252a2c;
  --sidebar-line: #424a4c;
  --sidebar-muted: #aab3b3;
  --accent: #cf6840;
  --accent-dark: #a94e2d;
  --danger: #b84e4e;
  --success: #4e9a70;
  --shadow: 0 16px 40px rgba(28, 34, 34, 0.1);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { background: var(--soft); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(207, 104, 64, 0.32); outline-offset: 2px; }

[hidden] { display: none !important; }
.login-view { min-height: 100svh; display: grid; place-items: center; padding: 24px; background: #ecefed; }
.login-panel { width: min(430px, 100%); padding: 34px; background: var(--paper); border: 1px solid var(--line); box-shadow: var(--shadow); }
.brand-lockup { display: flex; align-items: center; gap: 11px; }
.brand-mark { width: 35px; height: 35px; display: grid; place-items: center; background: var(--accent); color: #fff; font-weight: 800; letter-spacing: 0; }
.brand-lockup strong { display: block; font-size: 15px; letter-spacing: 0.01em; }
.brand-lockup span { display: block; margin-top: 2px; color: var(--sidebar-muted); font-size: 11px; }
.login-panel .brand-lockup span { color: var(--muted); }
.login-heading { margin: 64px 0 25px; }
.eyebrow { margin: 0 0 6px; color: var(--accent-dark); font-size: 11px; font-weight: 800; letter-spacing: 0.11em; text-transform: uppercase; }
.login-heading h1 { margin: 0; font-size: 28px; letter-spacing: 0; }
.login-heading p:last-child { margin: 10px 0 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
.login-form { display: grid; gap: 9px; }
.login-form label { margin-top: 8px; color: #505a5c; font-size: 12px; font-weight: 700; }
.login-form input { min-height: 44px; padding: 10px 12px; border: 1px solid #bfc7c5; background: #fff; color: var(--ink); }
.form-error { margin: 3px 0 0; color: var(--danger); font-size: 13px; line-height: 1.45; }

.app-shell { display: grid; grid-template-columns: 278px minmax(0, 1fr); min-height: 100svh; }
.sidebar { display: flex; flex-direction: column; min-height: 100svh; padding: 22px 18px 18px; background: var(--sidebar); color: #f5f7f6; }
.sidebar-topline { display: flex; align-items: flex-start; justify-content: space-between; }
.connection-status { display: flex; align-items: center; gap: 8px; margin: 25px 0 30px; color: #d5dcda; font-size: 12px; }
.status-dot { width: 8px; height: 8px; flex: 0 0 auto; display: inline-block; border-radius: 50%; background: #a2abad; }
.status-dot.online { background: #63ba87; }
.status-dot.busy { background: #e39b61; }
.status-dot.error { background: #df6d6d; }
.sidebar-section { margin-bottom: 26px; }
.sidebar label, .section-label { display: block; color: var(--sidebar-muted); font-size: 11px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.sidebar select { width: 100%; min-height: 42px; margin-top: 8px; padding: 8px 10px; border: 1px solid var(--sidebar-line); border-radius: 0; background: #303638; color: #f6f8f7; }
.sidebar select:disabled { opacity: 0.62; cursor: not-allowed; }
.section-label-row { display: flex; align-items: center; justify-content: space-between; }
.mode-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-top: 9px; }
.mode-button { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--sidebar-line); border-radius: 0; background: #303638; color: #dbe1df; font-size: 12px; }
.mode-button.active { border-color: #e2916e; background: #f8eee9; color: #713820; }
.mode-description { min-height: 34px; margin: 10px 0 0; color: var(--sidebar-muted); font-size: 12px; line-height: 1.45; }
.sidebar-spacer { flex: 1; min-height: 24px; }
.session-block { padding: 17px 0; border-top: 1px solid var(--sidebar-line); border-bottom: 1px solid var(--sidebar-line); }
.session-block code { display: block; max-width: 100%; margin-top: 8px; overflow: hidden; color: #eef3f0; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-actions { display: grid; gap: 8px; padding-top: 14px; }

.workspace { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-width: 0; min-height: 100svh; background: var(--soft); }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 79px; padding: 15px clamp(18px, 4vw, 54px); border-bottom: 1px solid var(--line); background: var(--paper); }
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 13px; }
.topbar h1 { margin: 0; font-size: 18px; line-height: 1.2; letter-spacing: 0; }
.run-state { display: inline-flex; align-items: center; gap: 7px; min-height: 29px; padding: 5px 9px; border: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.run-state.running { color: #9b5b31; background: #fff5ec; border-color: #efc8ae; }
.run-state.done { color: #3d805c; background: #f0f8f2; border-color: #bcddc6; }
.transcript { overflow-y: auto; padding: 34px clamp(18px, 7vw, 92px) 36px; }
.empty-state { width: min(640px, 100%); margin: 12vh auto 0; text-align: center; color: var(--muted); }
.empty-icon { width: 44px; height: 44px; display: grid; place-items: center; margin: 0 auto 17px; border: 1px solid #c9d1ce; color: var(--accent-dark); }
.empty-state h2 { margin: 0; color: var(--ink); font-size: 22px; font-weight: 700; }
.empty-state > p:not(.eyebrow) { max-width: 470px; margin: 11px auto 0; font-size: 14px; line-height: 1.6; }
.starter-prompts { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 25px; }
.starter-button { padding: 9px 12px; border: 1px solid #c7d0cd; border-radius: 0; background: #fff; color: #4a5557; font-size: 12px; }
.starter-button:hover { border-color: var(--accent); color: var(--accent-dark); }
.message { width: min(960px, 100%); margin: 0 auto 17px; }
.message-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.message-body { padding: 13px 15px; border-left: 3px solid #adb8b5; background: #fff; line-height: 1.65; overflow-wrap: anywhere; white-space: pre-wrap; }
.message.user .message-body { border-left-color: var(--accent); background: #fff8f4; }
.message.assistant .message-body { border-left-color: #82999f; }
.message.system .message-body, .message.tool .message-body { border-left-color: #8d9b9e; background: #f7faf9; color: #4f5b5d; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.message.result .message-body { border-left-color: var(--success); background: #f2faf4; }
.message.error .message-body { border-left-color: var(--danger); background: #fff4f4; color: #8d3838; }
.tool-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; color: #596466; font-family: ui-sans-serif, system-ui, sans-serif; font-size: 12px; font-weight: 700; }
.tool-json { max-height: 230px; overflow: auto; margin: 0; padding: 10px; background: #eef3f1; white-space: pre-wrap; word-break: break-word; }
.permission-card { border: 1px solid #e3c3b3; background: #fffaf7; }
.permission-card .permission-heading { display: flex; align-items: flex-start; gap: 10px; padding: 15px 15px 8px; }
.permission-card .permission-heading h3 { margin: 0; color: #713820; font-size: 14px; }
.permission-card .permission-heading p { margin: 5px 0 0; color: #795e53; font-size: 12px; line-height: 1.45; }
.permission-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 15px 15px; }
.permission-card.expired { opacity: 0.65; }
.composer { padding: 14px clamp(18px, 7vw, 92px) max(18px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--paper); }
.composer textarea { display: block; width: min(960px, 100%); min-height: 82px; max-height: 260px; margin: 0 auto; padding: 13px 14px; resize: vertical; border: 1px solid #b9c3c0; border-radius: 0; background: #fff; color: var(--ink); line-height: 1.55; }
.composer textarea::placeholder { color: #9aa3a3; }
.composer-footer { display: flex; align-items: center; width: min(960px, 100%); margin: 9px auto 0; }
.composer-footer > span { margin-right: auto; color: var(--muted); font-size: 11px; }

.button { min-height: 39px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 13px; border: 1px solid transparent; border-radius: 0; font-size: 12px; font-weight: 700; }
.button-primary { background: var(--accent); color: #fff; }
.button-primary:hover { background: var(--accent-dark); }
.button-secondary { border-color: #697476; background: transparent; color: #eef3f0; }
.button-quiet { border-color: transparent; background: transparent; color: var(--sidebar-muted); }
.button-danger { border-color: #dbacac; background: #fff; color: var(--danger); }
.button-wide { width: 100%; }
.icon-button { width: 34px; height: 34px; display: inline-grid; place-items: center; padding: 0; border: 1px solid var(--sidebar-line); border-radius: 0; background: transparent; color: #e9efed; }
.icon-button:hover { border-color: #d79070; color: #f0b094; }
.icon-button.tiny { width: 24px; height: 24px; border-color: transparent; color: var(--sidebar-muted); }
.icon-button.dark-icon { border-color: #c6cfcc; color: #4e5a5c; }
.icon-button.dark-icon:hover { border-color: var(--accent); color: var(--accent-dark); }
.danger-icon { border-color: #e2b1b1; color: var(--danger); }
.mobile-only { display: none; }
.sidebar-scrim { display: none; }
.toast-region { position: fixed; right: 16px; bottom: 16px; z-index: 20; display: grid; gap: 8px; width: min(330px, calc(100vw - 32px)); }
.toast { padding: 11px 13px; border: 1px solid #d0d8d5; background: #fff; box-shadow: var(--shadow); color: #4e595b; font-size: 12px; line-height: 1.45; }
.toast.error { border-color: #e2b0b0; color: #8d3838; }
.modal-dialog { width: min(820px, calc(100vw - 28px)); max-height: min(760px, calc(100svh - 28px)); padding: 0; border: 1px solid #c9d2cf; background: #fff; color: var(--ink); box-shadow: 0 24px 70px rgba(26, 34, 34, 0.24); }
.modal-dialog::backdrop { background: rgba(23, 29, 30, 0.5); }
.modal-shell { padding: 24px; }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 0; font-size: 21px; }
.modal-close { border-color: #c6cfcc; color: #4e5a5c; }
.modal-close:hover { border-color: var(--accent); color: var(--accent-dark); }
.provider-manager { display: grid; grid-template-columns: minmax(230px, 0.9fr) minmax(300px, 1.1fr); gap: 24px; padding-top: 20px; }
.provider-list-panel { min-width: 0; }
.modal-section-heading, .modal-form-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 28px; }
.provider-list { display: grid; gap: 8px; margin-top: 10px; max-height: 430px; overflow: auto; }
.provider-empty { margin: 0; padding: 16px; border: 1px dashed #c7d0cd; color: var(--muted); font-size: 12px; line-height: 1.55; }
.provider-item { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 11px; border: 1px solid #d1d9d6; background: #f8faf9; }
.provider-item.active { border-color: #df9a7b; background: #fff8f4; }
.provider-item-copy { min-width: 0; display: grid; gap: 4px; }
.provider-item-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.provider-item-copy span, .provider-item-copy small { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.provider-item-actions { display: flex; flex: 0 0 auto; gap: 5px; }
.modal-form { display: grid; gap: 8px; min-width: 0; }
.modal-form-heading { margin-bottom: 2px; }
.modal-form label { margin-top: 6px; color: #505a5c; font-size: 12px; font-weight: 700; }
.modal-form input, .modal-form textarea { width: 100%; padding: 10px 11px; border: 1px solid #bfc7c5; border-radius: 0; background: #fff; color: var(--ink); line-height: 1.45; }
.modal-form input { min-height: 42px; }
.modal-form textarea { resize: vertical; }
.modal-form .form-note { color: var(--muted); font-size: 11px; font-weight: 400; line-height: 1.4; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.button-quiet-light { border-color: #c6cfcc; background: #fff; color: #566264; }
.button-quiet-light:hover { border-color: #8d9a98; color: var(--ink); }
.compact-form { width: min(450px, 100%); }

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 12; width: min(310px, calc(100vw - 46px)); min-height: 100svh; transform: translateX(-105%); transition: transform 180ms ease; box-shadow: 18px 0 40px rgba(0, 0, 0, 0.2); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-scrim { position: fixed; inset: 0; z-index: 11; display: block; background: rgba(20, 24, 25, 0.45); }
  .mobile-only { display: inline-grid; }
  .workspace { min-height: 100svh; }
  .topbar { min-height: 70px; padding: 12px 14px; }
  .topbar h1 { font-size: 16px; }
  .topbar-right { gap: 7px; }
  .run-state { padding: 5px 7px; }
  .transcript { min-height: 48svh; padding: 22px 14px 26px; }
  .empty-state { margin-top: 8vh; }
  .empty-state h2 { font-size: 20px; }
  .starter-prompts { display: grid; }
  .starter-button { width: 100%; }
  .composer { padding: 11px 14px max(12px, env(safe-area-inset-bottom)); }
  .composer textarea { min-height: 76px; font-size: 16px; }
  .composer-footer { align-items: flex-end; gap: 10px; }
  .composer-footer > span { line-height: 1.4; }
  .composer-footer .button { min-width: 106px; }
  .message-body { padding: 12px; }
  .permission-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .permission-actions .button { width: 100%; }
  .modal-dialog { width: calc(100vw - 20px); max-height: calc(100svh - 20px); }
  .modal-shell { padding: 18px; }
  .provider-manager { grid-template-columns: 1fr; gap: 18px; }
  .provider-list { max-height: 190px; }
  .modal-actions { flex-wrap: wrap; }
  .modal-actions .button { flex: 1 1 130px; }
}
