:root {
  color-scheme: dark;
  --canvas: #0a1017;
  --side: #0d151e;
  --surface: #111c27;
  --surface-raised: #142330;
  --line: #233747;
  --text: #eef6f8;
  --muted: #a5b9c6;
  --accent: #72eef0;
  --accent-text: #062022;
  --warning: #f7cc8b;
  --danger: #ffaca6;
  --radius: 14px;
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--canvas); color: var(--text); }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
a { color: var(--accent); }
p, h1, h2, h3 { margin: 0; }
.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;
}
.boot { min-height: 100dvh; display: grid; place-items: center; color: var(--muted); }
.brand { display: flex; align-items: center; gap: 11px; font-size: 1.04rem; letter-spacing: .13em; white-space: nowrap; }
.brand strong span { color: var(--accent); }
.brand-mark {
  display: inline-grid;
  width: 32px;
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid #5cbcc1;
  border-radius: 50%;
  background: radial-gradient(circle, #459da2 0, #204b55 30%, #132a36 58%, #12202b 71%);
  box-shadow: 0 0 14px #73e5ea27, inset 0 0 7px #6fe8e35b;
  flex: 0 0 auto;
}
.brand-mark::before { content: ""; width: 16px; aspect-ratio: 1; border: 1px solid #a3f7f1; border-radius: 50%; }
.brand-mark::after { content: ""; position: absolute; width: 4px; aspect-ratio: 1; border-radius: 50%; background: #d3fffb; box-shadow: 0 0 8px #a3f7f1; }
.login-screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(ellipse at 50% 32%, #123441 0, var(--canvas) 62%);
}
.login-card {
  width: min(100%, 430px);
  border: 1px solid #294655;
  background: #101b25f2;
  border-radius: 21px;
  padding: clamp(24px, 6vw, 42px);
  box-shadow: 0 22px 70px #0005;
}
.login-card h1 { margin: 32px 0 20px; font-size: 1.8rem; line-height: 1.2; letter-spacing: -.04em; }
.login-form { display: grid; gap: 8px; }
.login-form label { color: var(--muted); font-size: .9rem; }
.login-form input {
  width: 100%; min-height: 46px; padding: 9px 12px; border: 1px solid #365263;
  border-radius: 9px; color: var(--text); background: var(--canvas);
}
.login-form .primary { margin-top: 10px; }
.button {
  display: inline-flex; min-height: 40px; align-items: center; justify-content: center; gap: 8px;
  padding: 7px 13px; border: 1px solid transparent; border-radius: 9px;
  font-size: .86rem; font-weight: 650; color: var(--text); background: transparent;
  text-decoration: none; white-space: nowrap;
}
.button:not(:disabled):active { transform: translateY(1px); }
.button.primary { color: var(--accent-text); background: var(--accent); border-color: var(--accent); }
.button.primary:not(:disabled):hover { background: #a0fbf8; }
.button.secondary { color: var(--accent); border-color: #2f606c; background: #122b35; }
.button.secondary:not(:disabled):hover { background: #1b3b47; }
.button.quiet { color: var(--muted); }
.button.quiet:not(:disabled):hover { background: #ffffff0a; color: var(--text); }
.button.danger { color: var(--danger); border-color: #68464b; }
.button.danger:not(:disabled):hover { background: #3e232c; }

.app {
  display: grid;
  min-height: 100dvh;
  grid-template-columns: 208px minmax(0, 1fr) 274px;
  grid-template-rows: 76px minmax(0, 1fr);
  grid-template-areas: "sidebar head head" "sidebar workspace voice";
}
.sidebar {
  grid-area: sidebar; display: flex; flex-direction: column; min-width: 0; gap: 34px;
  min-height: 100dvh; padding: 22px 14px 17px;
  background: var(--side); border-right: 1px solid var(--line);
}
.sidebar .brand { padding: 0 10px; }
.navigation { display: grid; gap: 5px; }
.nav-button {
  min-height: 44px; display: flex; align-items: center; gap: 10px; width: 100%;
  justify-content: flex-start; text-align: left; padding: 8px 11px;
  color: var(--muted); border: 1px solid transparent; border-radius: 9px;
  background: transparent; font-size: .87rem; font-weight: 600;
}
.nav-button:hover { color: var(--text); background: #ffffff06; }
.nav-button[aria-current="page"] { color: var(--accent); border-color: #27515d; background: #132d36; }
.counter {
  min-width: 21px; min-height: 21px; padding: 0 4px; margin-left: auto;
  border-radius: 999px; color: var(--accent-text); background: var(--accent); text-align: center;
  line-height: 21px; font-size: .72rem; font-variant-numeric: tabular-nums;
}
.logout { margin-top: auto; align-self: flex-start; }
.nav-icon, .clip-icon {
  position: relative; display: inline-block; width: 15px; height: 15px; flex: 0 0 auto; color: inherit;
}
.chat-icon { height: 12px; border: 1.5px solid currentColor; border-radius: 4px; }
.chat-icon::after { content: ""; position: absolute; left: 2px; bottom: -4px; width: 3px; height: 4px; border-left: 1.5px solid currentColor; transform: skewY(-37deg); }
.missions-icon { border: 1.5px solid currentColor; border-radius: 3px; }
.missions-icon::after { content: ""; position: absolute; top: 3px; left: 3px; width: 6px; height: 4px; border-block: 1px solid currentColor; }
.memory-icon { border: 1.5px solid currentColor; border-radius: 50% / 28%; }
.memory-icon::after { content: ""; position: absolute; top: 2px; left: 0; right: 0; height: 4px; border-bottom: 1px solid currentColor; border-radius: 50%; }
.voice-icon { border: 1.5px solid currentColor; width: 9px; height: 13px; border-radius: 5px; margin-inline: 3px; }
.voice-icon::after { content: ""; position: absolute; left: -4px; right: -4px; top: 3px; bottom: -4px; border: 1px solid currentColor; border-top: 0; border-radius: 0 0 9px 9px; }
.clip-icon { width: 10px; height: 15px; border: 1.5px solid currentColor; border-radius: 6px; transform: rotate(26deg); }
.clip-icon::after { content: ""; position: absolute; inset: 3px 2px -2px; border: 1px solid currentColor; border-radius: 3px; }

.page-header {
  grid-area: head; min-width: 0; padding: 0 clamp(18px, 3vw, 38px);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border-bottom: 1px solid var(--line); background: #0a1017;
}
.page-header h1 { font-size: 1.36rem; font-weight: 650; letter-spacing: -.035em; }
.connection-status { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: .79rem; white-space: nowrap; }
.connection-status::before { content: ""; width: 7px; aspect-ratio: 1; border-radius: 50%; background: #79e5c0; box-shadow: 0 0 10px #79e5c055; }
.connection-status[data-state="offline"]::before { background: var(--warning); box-shadow: none; }
.workspace { grid-area: workspace; min-width: 0; }
.page { min-width: 0; }
.chat-page { display: flex; flex-direction: column; min-height: calc(100dvh - 76px); height: 0; }
.chat-scroll {
  flex: 1 1 auto; min-height: 0; overflow: auto;
  padding: clamp(14px, 3vw, 34px) clamp(14px, 3vw, 36px);
  scrollbar-color: #355665 transparent;
}
.chat-scroll > .feedback { text-align: center; }
.welcome {
  min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding-block: 12px 26px;
}
.welcome h2 { margin: 16px 0 15px; font-size: clamp(1.75rem, 4vw, 2.65rem); line-height: 1.2; font-weight: 655; letter-spacing: -.055em; }
.hologram { width: clamp(116px, 17vw, 181px); aspect-ratio: 1; position: relative; display: grid; place-items: center; }
.hologram::before {
  content: ""; position: absolute; inset: -20%; border-radius: 50%;
  background: radial-gradient(circle, #2aeae534 0, #1f768225 43%, transparent 69%);
  pointer-events: none;
}
.ring { position: absolute; border-radius: 50%; border: 1px solid #6bd8de75; }
.ring-one { inset: 0; border-style: dashed; }
.ring-two { inset: 11%; box-shadow: 0 0 15px #4ac9d41e; border-left-color: #a9ffff; border-bottom-color: #96f7f3; }
.ring-three { inset: 21%; border-color: #5dacbb89; }
.orb {
  display: grid; place-items: center; width: 46%; aspect-ratio: 1; border-radius: 50%; z-index: 1;
  background: radial-gradient(circle at 40% 36%, #d0fffa 0%, #6de1e5 11%, #2c8c9a 28%, #154b60 62%, #132638 85%);
  border: 1px solid #9cfcf5; box-shadow: 0 0 22px #57ebeb5e, inset 0 0 18px #62e7e880;
}
.orb i { width: 60%; aspect-ratio: 1; border: 1px solid #b1fbf58c; border-radius: 50%; }
.suggestions { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; }
.suggestion { border-color: var(--line); background: #111c26; }
.messages { min-width: 0; display: grid; width: min(100%, 800px); margin: 0 auto; gap: 18px; }
.message { min-width: 0; display: grid; gap: 5px; justify-items: start; }
.message.user { margin-left: min(9%, 60px); justify-items: end; }
.message-author { color: var(--muted); font-size: .77rem; font-weight: 650; }
.message-body {
  max-width: min(100%, 72ch); overflow-wrap: anywhere; white-space: pre-wrap; padding: 12px 15px;
  border: 1px solid var(--line); border-radius: 4px 13px 13px; background: var(--surface);
}
.message.user .message-body { border-color: #315663; background: #15343f; border-radius: 13px 4px 13px 13px; }
.message-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.message-actions .button { min-height: 32px; padding: 4px 9px; font-size: .77rem; }
.composer-wrap { flex: 0 0 auto; width: min(100%, 872px); align-self: center; padding: 0 clamp(14px, 3vw, 36px) clamp(14px, 3vw, 28px); }
.composer-wrap > .feedback, .composer-wrap > .chat-metric { margin-bottom: 8px; }
.chat-metric { color: var(--muted); font-size: .77rem; }
.composer { display: grid; gap: 9px; padding: 11px; border: 1px solid #355162; border-radius: var(--radius); background: var(--surface); }
.composer:focus-within { border-color: #5691a0; }
.composer textarea {
  width: 100%; min-height: 59px; max-height: min(24dvh, 200px); border: none; padding: 4px 7px;
  resize: vertical; background: transparent; color: var(--text); outline: none;
}
.composer textarea::placeholder { color: var(--muted); opacity: .88; }
.composer-controls, .attachment-controls {
  display: flex; align-items: center; justify-content: space-between; gap: 6px; min-width: 0;
}
.composer-controls .primary { min-width: 91px; }
.attachment-controls .filename { display: block; min-width: 0; max-width: min(30vw, 300px); overflow: hidden; text-overflow: ellipsis; padding-inline: 5px; }
.chat-mission { display: flex; justify-content: space-between; align-items: center; gap: 7px; margin-bottom: 8px; padding: 8px 10px; border: 1px solid #315663; border-radius: 10px; background: #122731; }
.chat-mission p { font-size: .85rem; color: var(--text); overflow-wrap: anywhere; }
.voice-panel {
  grid-area: voice; min-width: 0; align-self: start; display: grid; gap: 13px;
  margin: clamp(14px, 3vw, 34px) clamp(14px, 2.4vw, 31px) 15px 0; padding: 14px;
  border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius);
}
.voice-panel-header { display: flex; align-items: center; gap: 11px; min-width: 0; }
.voice-panel-title { min-width: 0; }
.voice-panel h2 { font-size: .91rem; font-weight: 650; }
.voice-panel-title p { color: var(--muted); font-size: .79rem; overflow-wrap: anywhere; }
.voice-panel-actions { display: flex; gap: 5px; flex-wrap: wrap; }
.voice-panel-actions .button { min-height: 38px; }
.voice-indicator {
  flex: 0 0 auto; display: grid; place-items: center; width: 39px; aspect-ratio: 1; border: 1px solid #355360;
  border-radius: 50%; background: #152733;
}
.voice-indicator span { width: 11px; height: 16px; border-radius: 8px; border: 1.5px solid #9cb5c4; }
.voice-indicator[data-state="active"], .voice-indicator[data-state="speaking"] { border-color: #63dbe0; background: #193e46; box-shadow: 0 0 14px #6be8e224; }
.voice-indicator[data-state="active"] span, .voice-indicator[data-state="speaking"] span { border-color: var(--accent); }
.voice-metric, .voice-note { color: var(--muted); font-size: .77rem; }
.voice-note[data-error="true"] { color: var(--danger); }
.feedback { color: var(--muted); font-size: .88rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.feedback:empty { display: none; }
.error { color: var(--danger); }
.list-page { width: min(100%, 936px); margin: 0 auto; padding: clamp(14px, 3vw, 34px); }
.section-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.section-top p { color: var(--muted); font-size: .9rem; }
.list-page > .feedback { margin-bottom: 10px; }
.cards { display: grid; gap: 13px; }
.card { min-width: 0; display: grid; gap: 10px; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: clamp(13px, 2vw, 20px); overflow-wrap: anywhere; }
.card + .card.voice-help { margin-top: 14px; }
.card h2, .card h3 { font-size: 1.02rem; line-height: 1.25; }
.card p { font-size: .87rem; color: var(--muted); white-space: pre-wrap; }
.card p.error { color: var(--danger); }
.card-header { display: flex; gap: 8px; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; }
.status-pill { border: 1px solid #42576a; border-radius: 999px; padding: 2px 8px; color: var(--muted); font-size: .74rem; white-space: nowrap; }
.status-pill[data-state="awaiting_approval"] { color: var(--warning); border-color: #735d43; }
.status-pill[data-state="completed"] { color: #8fe7c0; border-color: #326355; }
.status-pill[data-state="failed"] { color: var(--danger); border-color: #734c53; }
.mission-fields { display: grid; gap: 5px; margin: 0; }
.mission-fields div { display: grid; grid-template-columns: minmax(75px, 24%) minmax(0, 1fr); gap: 5px; }
.mission-fields dt { color: var(--muted); font-size: .78rem; }
.mission-fields dd { min-width: 0; margin: 0; white-space: pre-wrap; font-size: .8rem; overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.receipt, .events { padding-top: 9px; border-top: 1px solid var(--line); }
.events summary { color: var(--muted); font-size: .82rem; cursor: pointer; }
.events li { margin: 5px 0; font-size: .77rem; }
.receipt .button { margin-top: 8px; }
.voice-settings .actions { margin-top: 5px; }
.voice-settings .sample-example { color: var(--text); font-style: italic; }
.voice-settings .sample-progress { color: var(--accent); }

@media (max-width: 1040px) {
  .app { grid-template-columns: 177px minmax(0, 1fr) 214px; }
  .voice-panel { margin-right: 14px; }
}
@media (max-width: 800px) {
  .app { grid-template-columns: 160px minmax(0, 1fr); grid-template-rows: 60px auto minmax(0, 1fr); grid-template-areas: "sidebar head" "sidebar voice" "sidebar workspace"; }
  .voice-panel { grid-template-columns: minmax(0, 1fr) auto; align-items: center; margin: 10px 14px 0; padding: 9px 11px; gap: 7px; }
  .voice-panel-actions { justify-content: end; }
  .voice-metric, .voice-note { grid-column: 1 / -1; }
  .voice-indicator { width: 32px; }
  .chat-page { min-height: calc(100dvh - 130px); min-height: max(410px, calc(100dvh - 130px)); }
}
@media (max-width: 570px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 49px auto minmax(0, 1fr); grid-template-areas: "sidebar" "head" "voice" "workspace"; }
  .sidebar { min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 8px; padding: max(8px, env(safe-area-inset-top)) 10px 4px; border-right: none; border-bottom: 1px solid var(--line); }
  .sidebar .brand { padding-left: 4px; grid-column: 1; grid-row: 1; }
  .sidebar .brand-mark { width: 28px; }
  .sidebar .logout { grid-column: 2; grid-row: 1; margin-top: 0; align-self: center; }
  .navigation { grid-column: 1 / -1; display: grid; grid-template-columns: 1.1fr 1.1fr 1fr .75fr; gap: 3px; }
  .nav-button { min-height: 40px; justify-content: center; gap: 4px; padding: 5px 4px; font-size: .76rem; }
  .nav-icon { display: none; }
  .counter { margin-left: 0; min-width: 16px; min-height: 16px; line-height: 16px; padding-inline: 3px; font-size: .66rem; }
  .page-header { padding-inline: 12px; }
  .page-header h1 { font-size: 1.12rem; }
  .connection-status { font-size: .73rem; }
  .voice-panel { margin: 8px 10px 0; }
  .voice-panel-actions .button { min-height: 37px; padding-inline: 7px; font-size: .72rem; }
  .chat-page { min-height: max(365px, calc(100dvh - 218px)); }
  .chat-scroll { padding: 11px 10px; }
  .composer-wrap { padding: 0 10px max(10px, env(safe-area-inset-bottom)); }
  .section-top { align-items: flex-start; }
  .chat-mission p { font-size: .78rem; }
  .chat-mission .button { font-size: .74rem; min-height: 35px; }
}
@media (max-width: 340px) {
  .voice-panel { grid-template-columns: minmax(0, 1fr); }
  .voice-panel-actions { justify-content: start; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}
