:root {
  color-scheme: dark;
  font: 15px/1.55 system-ui, -apple-system, sans-serif;
  color: #dedfe5;
  background: #111318;
  --muted: #939aa9;
  --line: #2a2e38;
  --accent: #c7dfad;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; }
button, input, select, textarea {
  font: inherit;
  color: inherit;
  background: #222630;
  border: 1px solid #414754;
  border-radius: 8px;
  padding: 9px 12px;
}
button { cursor: pointer; }
button:hover:not(:disabled) { border-color: #73826b; }
button:disabled { opacity: .5; cursor: not-allowed; }
.primary { background: var(--accent); color: #21311a; border-color: var(--accent); font-weight: 650; }
h1 { font-size: 27px; letter-spacing: -.6px; margin: 0; }
h2 { font-size: 22px; margin: 0 0 12px; }
p { margin: 8px 0; }
.eyebrow { color: var(--accent); letter-spacing: 2px; font-size: 10px; margin: 0 0 7px; }
.muted, .hint, .privacy { color: var(--muted); }
.hint, .privacy { font-size: 12px; }
.error { color: #f4c58b; }

.login-card {
  max-width: 560px;
  margin: 10vh auto;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #171a20;
}
.login-card form { display: flex; align-items: end; gap: 10px; margin-top: 22px; }
.login-card label { flex: 1; }
.login-card input { width: 100%; }
label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 12px; }

#workspace { height: 100vh; display: flex; }
aside {
  width: 270px;
  flex-shrink: 0;
  background: #181b21;
  border-right: 1px solid var(--line);
  padding: 26px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.brand { display: flex; gap: 12px; align-items: center; font-weight: 650; font-size: 20px; }
.mark { border: 1px solid #56694d; color: var(--accent); border-radius: 12px; padding: 5px 10px; }
.brand small { display: block; font-size: 9px; letter-spacing: 2px; color: var(--muted); font-weight: 500; }
.new-actions { display: grid; grid-template-columns: 1fr; gap: 7px; }
.availability { margin: -10px 0 0; color: #f4c58b; font-size: 11px; }
.agent-search input { width: 100%; }
.archived-toggle { flex-direction: row; align-items: center; }
.archived-toggle input { width: auto; }
nav { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; min-height: 60px; }
nav button { text-align: left; background: transparent; border-color: transparent; padding: 10px; }
nav button.selected { background: #292f29; border-color: #49553f; }
nav small { display: block; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.agent-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.nav-badge { color: #f4c58b; font-size: 9px; text-transform: uppercase; letter-spacing: .5px; }
aside footer { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 11px; }
aside footer button { padding: 5px 8px; white-space: nowrap; }

main { flex: 1; min-width: 0; overflow-y: auto; padding: 0 clamp(20px, 5vw, 90px) 30px; position: relative; }
#session-overview {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #111318;
  padding: 18px 0 12px;
  border-bottom: 1px solid var(--line);
}
#session-overview header { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
#meta { color: var(--muted); font-size: 12px; white-space: pre-line; overflow-wrap: anywhere; margin: 7px 0 0; }
.session-status { display: flex; align-items: center; gap: 8px; }
.badge { border-radius: 20px; background: #2b3529; color: var(--accent); padding: 6px 12px; font-size: 12px; }
.badge.warn { color: #f4c58b; background: #382f23; }
#error { min-height: 24px; font-size: 12px; }
#welcome { text-align: center; margin: 100px auto; max-width: 600px; color: var(--muted); }
#welcome h2 { color: #dedfe5; }
.welcome-icon { font-size: 46px; color: var(--accent); margin-bottom: 18px; }
#activity { padding: 10px 0 24px; max-width: 1100px; margin: auto; }
.entry { padding: 12px 16px; margin: 10px 0; border-radius: 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
.entry.user { background: #242b23; margin-left: 10%; border: 1px solid #394336; }
.entry.answer { background: #191d24; border-left: 2px solid var(--accent); }
.entry.thought { color: var(--muted); font-size: 13px; border-left: 2px solid #4b5363; }
.entry.system { font-size: 12px; color: var(--muted); padding: 4px 0; }
.entry.tool { background: #1b2028; border: 1px solid var(--line); font-size: 13px; }
.entry label { display: block; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px; }
pre { white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.5 ui-monospace, monospace; }
summary { cursor: pointer; }

#usage-panel[popover] {
  display: none;
  position: fixed;
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100dvh - 100px);
  overflow-y: auto;
  margin: 0;
  padding: 16px;
  border: 1px solid #394047;
  border-radius: 12px;
  background: #191d24;
  color: inherit;
  box-shadow: 0 12px 36px #0008;
}
#usage-panel:popover-open { display: grid; grid-template-columns: 1fr; gap: 4px; }
#usage-panel h3 { font-size: 13px; margin: 0; }
#usage-panel p { margin: 2px 0; overflow-wrap: anywhere; font-size: 12px; color: var(--muted); }
#usage-panel progress { width: 100%; height: 10px; accent-color: var(--accent); }

dialog {
  width: min(620px, calc(100vw - 28px));
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 24px;
  color: inherit;
  background: #181b21;
  border: 1px solid #464d5a;
  border-radius: 14px;
  box-shadow: 0 22px 70px #000b;
}
dialog::backdrop { background: #08090cbb; backdrop-filter: blur(2px); }
dialog form { display: flex; flex-direction: column; gap: 14px; }
.dialog-title { display: flex; align-items: center; justify-content: space-between; }
.dialog-title h2 { margin: 0; }
.dialog-title button { padding: 5px 9px; }
dialog input, dialog select, dialog textarea { width: 100%; }
dialog select[size] { min-height: 180px; }
fieldset { border: 1px solid var(--line); border-radius: 9px; padding: 12px; }
legend { color: var(--muted); font-size: 12px; padding: 0 5px; }
.command-status p { color: var(--muted); font-size: 12px; }
.command-status button { margin-top: 5px; }

@media (max-width: 760px) {
  #workspace { height: auto; min-height: 100vh; display: block; }
  aside { width: 100%; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  nav { max-height: 240px; }
  aside footer { margin-top: 0; }
  main { min-height: 60vh; }
  #session-overview header { align-items: flex-start; flex-direction: column; }
  .login-card { margin: 5vh 14px; }
  .login-card form { align-items: stretch; flex-direction: column; }
}
