:root {
  color-scheme: dark;
  --bg: #11110f;
  --panel: #181816;
  --panel-raised: #20201d;
  --panel-soft: #292925;
  --line: #32322d;
  --line-bright: #45453f;
  --text: #f1efe7;
  --muted: #99978d;
  --faint: #6f6d65;
  --accent: #d9ff72;
  --accent-ink: #161811;
  --danger: #ff8f82;
  --warn: #f5c96a;
  --sidebar-width: 320px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; overflow: hidden; background: var(--bg); color: var(--text); }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }

.login-view {
  min-height: 100%; display: grid; place-items: center; padding: 28px;
  background:
    radial-gradient(circle at 15% 15%, rgba(217, 255, 114, .1), transparent 24rem),
    radial-gradient(circle at 80% 90%, rgba(255, 255, 255, .055), transparent 30rem), var(--bg);
}
.login-card { width: min(100%, 500px); padding: 46px; border: 1px solid var(--line); border-radius: 24px; background: rgba(25, 25, 22, .88); box-shadow: 0 28px 90px rgba(0, 0, 0, .36); backdrop-filter: blur(24px); }
.brand-mark, .mini-mark { display: block; object-fit: cover; }
.brand-mark { width: 58px; height: 58px; margin-bottom: 28px; }
.mini-mark { width: 30px; height: 30px; flex: 0 0 auto; }
.eyebrow { margin: 0 0 8px; color: var(--accent); font: 650 11px/1.2 ui-monospace, "SFMono-Regular", monospace; letter-spacing: .14em; }
.login-card h1 { margin: 0; font-size: clamp(34px, 8vw, 48px); letter-spacing: -.045em; }
.login-copy { margin: 14px 0 32px; color: var(--muted); line-height: 1.65; }
label { display: grid; gap: 8px; color: var(--muted); font-size: 13px; }
input, textarea, select { width: 100%; border: 1px solid var(--line-bright); border-radius: 12px; outline: 0; background: #121210; color: var(--text); }
input, select { min-height: 46px; padding: 0 13px; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(217, 255, 114, .1); }
.token-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.primary, .secondary { min-height: 44px; padding: 0 18px; border-radius: 11px; cursor: pointer; }
.primary { border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.primary:hover { filter: brightness(1.05); }
.secondary { border: 1px solid var(--line-bright); background: transparent; }
.form-error { min-height: 18px; margin: 9px 0 0; color: var(--danger); font-size: 12px; }
.secure-note { margin: 28px 0 0; color: var(--faint); font-size: 11px; }
.secure-note span { color: var(--accent); margin-right: 6px; }

.app-shell { display: grid; grid-template-columns: var(--sidebar-width) 1fr; height: 100dvh; }
.sidebar { display: flex; min-width: 0; flex-direction: column; border-right: 1px solid var(--line); background: var(--panel); }
.sidebar-header { display: flex; align-items: center; justify-content: space-between; padding: max(18px, env(safe-area-inset-top)) 18px 14px; }
.wordmark { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; letter-spacing: -.02em; }
.icon-button { display: grid; width: 36px; height: 36px; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: transparent; cursor: pointer; font-size: 20px; }
.icon-button:hover { border-color: var(--line-bright); background: var(--panel-soft); }
.search-box { display: flex; align-items: center; gap: 8px; margin: 4px 14px 16px; padding: 0 11px; border: 1px solid var(--line); border-radius: 10px; background: #141412; color: var(--faint); }
.search-box input { min-height: 38px; padding: 0; border: 0; box-shadow: none; background: transparent; font-size: 13px; }
.nav-scroll { min-height: 0; flex: 1; overflow-y: auto; padding: 0 9px 20px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 7px; color: var(--faint); font: 650 10px/1 ui-monospace, "SFMono-Regular", monospace; letter-spacing: .12em; text-transform: uppercase; }
.section-actions { display: flex; align-items: center; gap: 8px; }
.section-add { display: grid; width: 22px; height: 22px; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; }
.section-add:hover { border-color: var(--accent); color: var(--accent); }
.text-button { padding: 3px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 11px; }
.text-button:hover { color: var(--text); }
.project-list { display: grid; gap: 10px; }
.project-group { min-width: 0; }
.project-button, .thread-button { width: 100%; border: 0; text-align: left; cursor: pointer; }
.project-button { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 9px; background: transparent; color: #d9d7cf; font-size: 13px; font-weight: 620; }
.project-button:hover { background: #22221f; color: var(--text); }
.project-folder { position: relative; width: 17px; height: 12px; border: 1.5px solid currentColor; border-radius: 2px; color: var(--muted); }
.project-folder::before { position: absolute; top: -4px; left: 1px; width: 7px; height: 4px; border: 1.5px solid currentColor; border-bottom: 0; border-radius: 2px 2px 0 0; content: ""; }
.project-count { color: var(--faint); font: 10px/1 ui-monospace, monospace; }
.project-threads { display: grid; gap: 1px; margin: 1px 0 0 20px; }
.thread-button { position: relative; display: grid; min-width: 0; grid-template-columns: minmax(0, 1fr) 18px; align-items: center; gap: 8px; padding: 9px 8px 9px 14px; border-radius: 9px; background: transparent; }
.thread-button:hover { background: #22221f; }
.thread-button.active { background: var(--panel-soft); }
.thread-button.active::before { position: absolute; top: 12px; bottom: 12px; left: 3px; width: 2px; border-radius: 2px; background: var(--accent); content: ""; }
.thread-copy { min-width: 0; }
.thread-name { display: block; overflow: hidden; color: #d9d7cf; font-size: 13px; font-weight: 530; text-overflow: ellipsis; white-space: nowrap; }
.thread-meta { display: flex; gap: 8px; margin-top: 5px; color: var(--faint); font: 10px/1.2 ui-monospace, monospace; }
.thread-spinner { width: 14px; height: 14px; border: 2px solid var(--line-bright); border-top-color: var(--text); border-right-color: var(--text); border-radius: 50%; animation: thread-spin .75s linear infinite; }
.project-empty { padding: 18px 11px; color: var(--faint); font-size: 12px; line-height: 1.5; }
@keyframes thread-spin { to { transform: rotate(360deg); } }
.sidebar-footer { display: flex; align-items: center; gap: 8px; padding: 13px 18px max(13px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.connection-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 0 3px rgba(245, 201, 106, .08); }
.connection-dot.online { background: var(--accent); box-shadow: 0 0 0 3px rgba(217, 255, 114, .08); }
.connection-dot.offline { background: var(--danger); }
.footer-action { margin-left: auto; }

.workspace {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  height: 100%;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  background: var(--bg);
}
.topbar { display: flex; min-width: 0; align-items: center; gap: 12px; padding: max(16px, env(safe-area-inset-top)) 24px 14px; border-bottom: 1px solid var(--line); background: rgba(17, 17, 15, .9); backdrop-filter: blur(16px); }
.thread-identity { min-width: 0; flex: 1; }
.thread-identity h1 { overflow: hidden; margin: 0; font-size: 15px; font-weight: 650; letter-spacing: -.015em; text-overflow: ellipsis; white-space: nowrap; }
.thread-identity p { overflow: hidden; margin: 4px 0 0; color: var(--faint); font: 10px/1.2 ui-monospace, monospace; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.status-pill { padding: 5px 8px; border: 1px solid rgba(217, 255, 114, .25); border-radius: 999px; background: rgba(217, 255, 114, .07); color: var(--accent); font: 10px/1 ui-monospace, monospace; }
.stop-button { width: 32px; height: 32px; border: 1px solid rgba(255, 143, 130, .3); border-radius: 9px; background: rgba(255, 143, 130, .08); color: var(--danger); cursor: pointer; }
.conversation { min-height: 0; overflow-y: auto; }
.transcript { width: min(100%, 880px); margin: 0 auto; padding: 40px 32px 120px; }
.message { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; margin-bottom: 26px; }
.message-avatar { display: grid; width: 28px; height: 28px; place-items: center; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); font: 700 11px/1 ui-monospace, monospace; }
.message.agent .message-avatar { border-color: rgba(217, 255, 114, .35); color: var(--accent); }
.message-copy { min-width: 0; padding-top: 4px; color: #e8e6df; font-size: 14px; line-height: 1.72; white-space: pre-wrap; overflow-wrap: anywhere; }
.message.user .message-copy { color: var(--muted); }
.tool-card { margin: 10px 0 18px 40px; overflow: hidden; border: 1px solid var(--line); border-radius: 11px; background: #151513; }
.tool-card summary { display: flex; align-items: center; gap: 9px; padding: 10px 12px; color: var(--muted); cursor: pointer; font: 11px/1.45 ui-monospace, monospace; list-style: none; }
.tool-card summary::-webkit-details-marker { display: none; }
.tool-card summary::before { color: var(--accent); content: "›"; font-size: 16px; }
.tool-card[open] summary::before { transform: rotate(90deg); }
.tool-status { margin-left: auto; color: var(--faint); }
.tool-card pre { max-height: 340px; margin: 0; overflow: auto; padding: 12px; border-top: 1px solid var(--line); color: #aaa89f; font: 11px/1.55 ui-monospace, "SFMono-Regular", monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.reasoning-card { margin: 0 0 18px 40px; color: var(--faint); font-size: 12px; }
.reasoning-card summary { cursor: pointer; }
.plan-card { margin: 10px 0 22px 40px; overflow: hidden; border: 1px solid var(--line-bright); border-radius: 14px; background: linear-gradient(180deg, rgba(41, 41, 37, .8), rgba(22, 22, 20, .95)); }
.plan-card header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.plan-card header strong { font-size: 12px; }
.plan-card header span { color: var(--faint); font: 10px/1.3 ui-monospace, monospace; }
.plan-card.complete header span { color: var(--accent); }
.plan-explanation { margin: 0; padding: 11px 14px 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.plan-steps { display: grid; gap: 10px; margin: 0; padding: 13px 14px 15px; list-style: none; }
.plan-step { display: grid; grid-template-columns: 18px minmax(0, 1fr); align-items: start; gap: 9px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.plan-step-marker { display: grid; width: 16px; height: 16px; place-items: center; margin-top: 1px; border: 1.5px solid var(--faint); border-radius: 50%; color: var(--accent-ink); font: 800 10px/1 sans-serif; }
.plan-step.inProgress { color: var(--text); }
.plan-step.inProgress .plan-step-marker { border: 3px solid rgba(217, 255, 114, .3); box-shadow: inset 0 0 0 2px var(--accent); }
.plan-step.completed { color: var(--faint); }
.plan-step.completed .plan-step-marker { border-color: var(--accent); background: var(--accent); }
.turn-divider { margin: 34px 0; border: 0; border-top: 1px solid var(--line); }
.empty-state { display: grid; align-content: center; justify-items: center; min-height: 0; padding: 34px; text-align: center; }
.empty-orbit { display: grid; width: 84px; height: 84px; place-items: center; margin-bottom: 22px; border: 1px solid var(--line-bright); border-radius: 50%; box-shadow: inset 0 0 0 12px #151513, 0 0 80px rgba(217, 255, 114, .06); }
.empty-orbit img { display: block; width: 52px; height: 52px; object-fit: cover; }
.empty-state h2 { margin: 0; font-size: 24px; letter-spacing: -.04em; }
.empty-state p { max-width: 430px; margin: 12px 0 24px; color: var(--muted); line-height: 1.6; }
.composer { position: relative; width: min(calc(100% - 40px), 840px); margin: 0 auto max(18px, env(safe-area-inset-bottom)); padding: 12px; border: 1px solid var(--line-bright); border-radius: 16px; background: rgba(31, 31, 28, .95); box-shadow: 0 14px 50px rgba(0, 0, 0, .34); backdrop-filter: blur(20px); }
.plan-progress { position: absolute; top: -42px; left: 50%; display: flex; min-height: 32px; align-items: center; gap: 7px; padding: 0 12px; border: 1px solid var(--line-bright); border-radius: 999px; background: rgba(31, 31, 28, .96); color: var(--muted); box-shadow: 0 8px 28px #0006; transform: translateX(-50%); cursor: pointer; font-size: 11px; white-space: nowrap; }
.plan-progress:hover { border-color: var(--accent); color: var(--text); }
.plan-progress-dot { width: 9px; height: 9px; border: 2px solid var(--accent); border-radius: 50%; box-shadow: 0 0 0 3px rgba(217, 255, 114, .08); }
.plan-progress.complete { color: var(--accent); }
.plan-progress.complete .plan-progress-dot { background: var(--accent); }
.composer textarea { max-height: 200px; min-height: 30px; resize: none; padding: 4px; border: 0; background: transparent; box-shadow: none; line-height: 1.5; }
.composer-footer { display: flex; align-items: center; justify-content: space-between; padding: 7px 0 0 4px; color: var(--faint); font-size: 10px; }
.composer-tools { display: flex; min-width: 0; align-items: center; gap: 9px; }
.attach-button { display: grid; width: 28px; height: 28px; flex: 0 0 auto; place-items: center; padding: 0; border: 1px solid var(--line-bright); border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; font-size: 18px; }
.attach-button:hover { border-color: var(--accent); color: var(--accent); }
.attach-button:disabled { cursor: wait; opacity: .5; }
.permission-picker { position: relative; flex: 0 0 auto; }
.permission-toggle { display: flex; min-height: 28px; align-items: center; gap: 5px; padding: 0 8px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; font-size: 11px; }
.permission-toggle:hover, .permission-toggle[aria-expanded="true"] { border-color: var(--line-bright); background: var(--panel-soft); color: var(--text); }
.permission-toggle:disabled { cursor: default; opacity: .5; }
.permission-toggle[data-mode="full"] { color: var(--warn); }
.permission-toggle[data-mode="full"] .permission-shield { color: var(--warn); }
.permission-shield { color: var(--accent); font-size: 15px; line-height: 1; }
.permission-chevron { margin-left: 1px; color: var(--faint); }
.permission-menu { position: absolute; bottom: calc(100% + 10px); left: -38px; z-index: 8; width: min(370px, calc(100vw - 32px)); max-height: min(570px, 62dvh); overflow-y: auto; padding: 8px; border: 1px solid var(--line-bright); border-radius: 14px; background: #232320; box-shadow: 0 22px 70px rgba(0, 0, 0, .62); color: var(--text); }
.reasoning-menu { right: 0; left: auto; width: min(300px, calc(100vw - 32px)); }
.reasoning-toggle > span:first-child { color: var(--accent); font-size: 12px; }
.permission-menu-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 8px 9px 10px; }
.permission-menu-heading strong { font-size: 13px; }
.permission-menu-heading span { color: var(--faint); font-size: 10px; }
.permission-options { display: grid; gap: 3px; }
.permission-group-label { margin: 8px 9px 3px; color: var(--faint); font: 650 9px/1.4 ui-monospace, "SFMono-Regular", monospace; letter-spacing: .1em; text-transform: uppercase; }
.permission-option { display: grid; width: 100%; grid-template-columns: 24px minmax(0, 1fr) 18px; align-items: center; gap: 8px; padding: 9px; border: 1px solid transparent; border-radius: 10px; background: transparent; text-align: left; cursor: pointer; }
.permission-option:hover { background: var(--panel-soft); }
.permission-option.active { border-color: rgba(217, 255, 114, .22); background: rgba(217, 255, 114, .06); }
.permission-option.danger { color: var(--warn); }
.permission-option:disabled { cursor: not-allowed; opacity: .42; }
.permission-option-icon { color: var(--muted); font-size: 16px; text-align: center; }
.permission-option.danger .permission-option-icon { color: var(--warn); }
.permission-option-copy { min-width: 0; }
.permission-option-copy strong, .permission-option-copy small { display: block; }
.permission-option-copy strong { overflow: hidden; color: inherit; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.permission-option-copy small { margin-top: 2px; color: var(--faint); font-size: 10px; line-height: 1.35; }
.permission-option-check { color: var(--accent); font-size: 14px; text-align: center; }
.permission-empty, .permission-error { margin: 5px 9px 8px; font-size: 10px; line-height: 1.45; }
.permission-empty { color: var(--faint); }
.permission-error { color: var(--danger); }
.attachment-list { display: flex; gap: 8px; overflow-x: auto; padding: 0 0 10px; }
.attachment { position: relative; width: 74px; height: 74px; flex: 0 0 auto; overflow: hidden; border: 1px solid var(--line-bright); border-radius: 10px; background: #121210; }
.attachment img { width: 100%; height: 100%; object-fit: cover; }
.attachment button { position: absolute; top: 4px; right: 4px; display: grid; width: 21px; height: 21px; place-items: center; padding: 0; border: 0; border-radius: 50%; background: rgba(0, 0, 0, .78); color: white; cursor: pointer; font-size: 14px; }
.send-button { width: 32px; height: 32px; border: 0; border-radius: 9px; background: var(--accent); color: var(--accent-ink); cursor: pointer; font-size: 18px; font-weight: 800; }
.send-button:disabled { background: var(--panel-soft); color: var(--faint); cursor: default; }

.modal { width: min(calc(100% - 30px), 560px); padding: 0; border: 1px solid var(--line-bright); border-radius: 18px; background: var(--panel-raised); color: var(--text); box-shadow: 0 28px 90px #0009; }
.modal::backdrop { background: rgba(0, 0, 0, .68); backdrop-filter: blur(5px); }
.modal form { display: grid; gap: 18px; padding: 24px; }
.modal-heading { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.modal-heading h2 { margin: 0; font-size: 21px; letter-spacing: -.03em; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 2px; }
.field-note { margin: -7px 0 -4px; color: var(--faint); font-size: 11px; line-height: 1.5; }
.request-body { display: grid; gap: 14px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.request-body pre { max-height: 260px; margin: 0; overflow: auto; padding: 13px; border: 1px solid var(--line); border-radius: 10px; background: #121210; color: var(--text); font: 11px/1.55 ui-monospace, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.request-question { display: grid; gap: 9px; padding: 12px; border: 1px solid var(--line); border-radius: 11px; }
.request-question strong { color: var(--text); }
.request-option { display: grid; grid-template-columns: auto 1fr; gap: 9px; align-items: start; cursor: pointer; }
.request-option input { width: auto; min-height: 0; margin-top: 3px; }
.request-option small { display: block; margin-top: 2px; color: var(--faint); }
.request-actions { flex-wrap: wrap; }
.danger-button { min-height: 40px; padding: 0 14px; border: 1px solid rgba(255, 143, 130, .3); border-radius: 10px; background: rgba(255, 143, 130, .08); color: var(--danger); cursor: pointer; }
.warning-button { min-height: 40px; padding: 0 14px; border: 1px solid rgba(245, 201, 106, .38); border-radius: 10px; background: rgba(245, 201, 106, .12); color: var(--warn); cursor: pointer; font-weight: 700; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 20; max-width: min(400px, calc(100% - 40px)); padding: 12px 14px; border: 1px solid var(--line-bright); border-radius: 11px; background: var(--panel-raised); color: var(--text); box-shadow: 0 16px 50px #0008; font-size: 12px; }
.sidebar-scrim, .mobile-only { display: none; }

@media (max-width: 760px) {
  .login-card { padding: 30px 24px; }
  .token-row { grid-template-columns: 1fr; }
  .app-shell { display: block; }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 10; width: min(88vw, var(--sidebar-width)); transform: translateX(-102%); box-shadow: 30px 0 80px #0008; transition: transform .2s ease; }
  .app-shell.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-scrim { position: fixed; inset: 0; z-index: 9; display: block; visibility: hidden; background: rgba(0, 0, 0, .56); opacity: 0; transition: opacity .2s, visibility .2s; }
  .app-shell.sidebar-open .sidebar-scrim { visibility: visible; opacity: 1; }
  .workspace { height: 100dvh; }
  .mobile-only { display: grid; flex: 0 0 auto; }
  .topbar { padding-right: 14px; padding-left: 14px; }
  .transcript { padding: 28px 17px 112px; }
  .message { grid-template-columns: 24px minmax(0, 1fr); gap: 9px; }
  .message-avatar { width: 24px; height: 24px; }
  .message-copy { font-size: 13px; line-height: 1.68; }
  .tool-card, .reasoning-card, .plan-card { margin-left: 33px; }
  .composer { width: calc(100% - 20px); margin-bottom: max(10px, env(safe-area-inset-bottom)); }
  .composer-tools > #composer-hint { display: none; }
  .permission-menu { max-height: 58dvh; }
  .status-pill { display: none; }
  .field-grid { grid-template-columns: 1fr; }
  .modal { max-height: calc(100dvh - 24px); overflow: auto; }
  .modal form { padding: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
  .thread-spinner { border-color: var(--accent); animation: none; }
}
