:root {
  color-scheme: dark;
  --bg: #07101f;
  --surface: rgba(13, 27, 48, 0.86);
  --surface-strong: #10233d;
  --surface-soft: rgba(255, 255, 255, 0.055);
  --line: rgba(255, 255, 255, 0.105);
  --text: #f5f8fc;
  --muted: #9eafc4;
  --cyan: #69e1d5;
  --cyan-strong: #22c9bd;
  --blue: #6ca9ff;
  --danger: #ff766c;
  --warning: #f6c561;
  --success: #72dfaa;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.34);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 8%, rgba(33, 181, 184, 0.14), transparent 34rem),
    radial-gradient(circle at 92% 88%, rgba(54, 104, 210, 0.15), transparent 38rem),
    linear-gradient(155deg, #07101f 0%, #091628 52%, #07101f 100%);
}

button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }

.ambient {
  position: fixed;
  z-index: -1;
  width: 24rem;
  height: 24rem;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.18;
  pointer-events: none;
}
.ambient-one { top: -12rem; right: -7rem; background: var(--cyan); }
.ambient-two { bottom: -14rem; left: -10rem; background: #466ee9; }

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 74px;
  padding: max(12px, env(safe-area-inset-top)) clamp(18px, 4vw, 48px) 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(6, 15, 29, 0.78);
  backdrop-filter: blur(22px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}
.brand > span:last-child { display: grid; }
.brand strong { font-size: 1.08rem; letter-spacing: 0.015em; }
.brand small { margin-top: 1px; color: var(--muted); font-size: 0.72rem; }
.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(105, 225, 213, 0.45);
  border-radius: 13px;
  background: linear-gradient(145deg, rgba(105, 225, 213, 0.22), rgba(108, 169, 255, 0.13));
  box-shadow: inset 0 0 18px rgba(105, 225, 213, 0.08);
}
.brand-mark span {
  width: 15px;
  height: 15px;
  border: 2px solid var(--cyan);
  border-radius: 50% 50% 48% 18%;
  transform: rotate(45deg);
  box-shadow: 0 0 14px rgba(105, 225, 213, 0.65);
}

.connection-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
  font-size: 0.75rem;
  white-space: nowrap;
}
.connection-badge > span:first-child {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warning);
  box-shadow: 0 0 10px currentColor;
}
.connection-badge.is-online > span:first-child { background: var(--success); }
.connection-badge.is-offline > span:first-child { background: var(--danger); }

.shell { width: min(1220px, 100%); margin: 0 auto; padding: clamp(20px, 4vw, 46px); }

.setup-layout {
  display: grid;
  min-height: calc(100vh - 150px);
  align-items: center;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: clamp(28px, 6vw, 86px);
}

.hero-card h1, .welcome-block h1 {
  max-width: 700px;
  margin: 8px 0 18px;
  font-size: clamp(2.65rem, 7vw, 5.8rem);
  font-weight: 620;
  line-height: 0.98;
  letter-spacing: -0.052em;
}
.hero-copy {
  max-width: 650px;
  margin: 0;
  color: #bdcada;
  font-size: clamp(1rem, 2vw, 1.22rem);
  line-height: 1.65;
}
.eyebrow { margin: 0; color: var(--cyan); font-size: 0.7rem; font-weight: 750; letter-spacing: 0.18em; }

.orb-wrap { display: flex; align-items: center; min-height: 190px; padding: 24px 0 12px; }
.orb {
  position: relative;
  display: grid;
  width: 112px;
  height: 112px;
  place-items: center;
  border: 1px solid rgba(105, 225, 213, 0.26);
  border-radius: 50%;
  background: radial-gradient(circle at 36% 29%, #b9fff6 0, #55d8d2 15%, #137b94 48%, #172e5d 74%, #081124 100%);
  box-shadow: 0 0 0 20px rgba(105, 225, 213, 0.035), 0 0 70px rgba(49, 198, 196, 0.28);
}
.orb span { position: absolute; width: 2px; border-radius: 99px; background: rgba(255, 255, 255, 0.75); }
.orb span:nth-child(1) { height: 24px; transform: translateX(-10px); }
.orb span:nth-child(2) { height: 42px; }
.orb span:nth-child(3) { height: 18px; transform: translateX(10px); }

.boundary-note {
  display: flex;
  max-width: 660px;
  gap: 16px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}
.boundary-note strong { flex: 0 0 auto; color: var(--text); }

.setup-card {
  display: grid;
  gap: 21px;
  padding: clamp(24px, 5vw, 40px);
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 28px;
  background: linear-gradient(155deg, rgba(19, 40, 69, 0.92), rgba(10, 23, 42, 0.94));
  box-shadow: var(--shadow);
}
.setup-card h2, .panel-heading h2 { margin: 7px 0 8px; font-size: clamp(1.65rem, 4vw, 2.25rem); letter-spacing: -0.03em; }
.setup-card p { margin: 0; color: var(--muted); font-size: 0.9rem; line-height: 1.55; }
label { display: grid; gap: 8px; color: #c9d4e1; font-size: 0.8rem; font-weight: 640; }
input, textarea {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 14px;
  outline: 0;
  color: var(--text);
  background: rgba(2, 10, 20, 0.54);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
input { min-height: 49px; padding: 0 14px; }
textarea { padding: 14px; line-height: 1.5; resize: vertical; }
input:focus, textarea:focus { border-color: rgba(105, 225, 213, 0.7); box-shadow: 0 0 0 3px rgba(105, 225, 213, 0.1); background: rgba(2, 10, 20, 0.72); }
.secret-field { position: relative; }
.secret-field input { padding-right: 64px; }
.text-button { position: absolute; top: 0; right: 2px; height: 49px; border: 0; color: var(--cyan); background: transparent; font-size: 0.76rem; font-weight: 700; cursor: pointer; }

.primary-button, .send-button {
  display: inline-flex;
  min-height: 49px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 14px;
  color: #041717;
  background: linear-gradient(135deg, #83eee3, #48cfc4);
  box-shadow: 0 10px 30px rgba(59, 208, 198, 0.17);
  font-weight: 760;
  cursor: pointer;
}
.primary-button:hover, .send-button:hover { filter: brightness(1.06); }
.primary-button:disabled, .send-button:disabled, .icon-button:disabled { opacity: 0.55; cursor: wait; }
.primary-button.compact { min-height: 45px; padding: 0 20px; }
.primary-button.fit { width: fit-content; padding: 0 21px; }
.privacy-line { padding-top: 3px; border-top: 1px solid var(--line); font-size: 0.72rem !important; }
.form-error { min-height: 18px; color: #ff968e !important; }

.assistant-layout {
  display: grid;
  min-height: calc(100vh - 165px);
  grid-template-columns: 255px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(8, 19, 35, 0.67);
  box-shadow: var(--shadow);
}
.sidebar { display: flex; flex-direction: column; padding: 27px 20px; border-right: 1px solid var(--line); background: rgba(8, 20, 37, 0.72); }
.welcome-block { padding: 5px 6px 24px; }
.welcome-block h1 { margin: 9px 0 12px; font-size: 2.05rem; line-height: 1.04; }
.welcome-block p:last-child { margin: 0; color: var(--muted); font-size: 0.82rem; line-height: 1.55; }
.side-nav { display: grid; gap: 7px; }
.nav-button {
  display: flex;
  min-height: 47px;
  align-items: center;
  gap: 12px;
  padding: 0 13px;
  border: 1px solid transparent;
  border-radius: 13px;
  color: var(--muted);
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.nav-button span { width: 22px; color: var(--cyan); font-size: 1rem; text-align: center; }
.nav-button.is-active { border-color: rgba(105, 225, 213, 0.16); color: var(--text); background: rgba(105, 225, 213, 0.08); }
.sidebar-footer { display: grid; gap: 10px; margin-top: auto; padding: 24px 6px 2px; color: #71859e; font-size: 0.68rem; }
.quiet-button { width: fit-content; padding: 0; border: 0; color: var(--muted); background: transparent; font-size: 0.75rem; text-decoration: underline; cursor: pointer; }

.workspace { min-width: 0; }
.tool-panel { display: none; min-height: 100%; padding: clamp(22px, 4vw, 42px); }
.tool-panel.is-active { display: flex; flex-direction: column; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin-bottom: 0; }
.speak-toggle { display: flex; align-items: center; gap: 8px; padding-top: 8px; color: var(--muted); white-space: nowrap; }
.speak-toggle input { width: 16px; min-height: 16px; accent-color: var(--cyan-strong); }

.messages { display: flex; min-height: 330px; max-height: calc(100vh - 430px); flex: 1; flex-direction: column; gap: 14px; overflow-y: auto; padding: 24px 2px; scroll-behavior: smooth; }
.message { display: flex; max-width: min(78%, 680px); flex-direction: column; gap: 6px; }
.message.user { align-self: flex-end; }
.message.assistant { align-self: flex-start; }
.message-meta { padding: 0 4px; color: #71859e; font-size: 0.66rem; }
.message.user .message-meta { text-align: right; }
.message-bubble { padding: 13px 15px; border: 1px solid var(--line); border-radius: 17px; line-height: 1.55; white-space: pre-wrap; }
.message.assistant .message-bubble { border-top-left-radius: 5px; background: rgba(255, 255, 255, 0.055); }
.message.user .message-bubble { border-color: rgba(105, 225, 213, 0.22); border-top-right-radius: 5px; background: rgba(69, 193, 188, 0.13); }
.action-note { margin-top: 8px; padding: 10px 12px; border-left: 2px solid var(--cyan); border-radius: 8px; color: #c7d8e6; background: rgba(105, 225, 213, 0.065); font-size: 0.78rem; }

.quick-prompts { display: flex; gap: 8px; overflow-x: auto; padding: 0 0 13px; scrollbar-width: none; }
.quick-prompts::-webkit-scrollbar { display: none; }
.quick-prompts button { flex: 0 0 auto; padding: 8px 11px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: transparent; font-size: 0.72rem; cursor: pointer; }
.quick-prompts button:hover { border-color: rgba(105, 225, 213, 0.4); color: var(--text); }

.composer { display: flex; align-items: flex-end; gap: 10px; padding: 10px; border: 1px solid rgba(255, 255, 255, 0.15); border-radius: 19px; background: rgba(2, 9, 18, 0.63); }
.composer textarea { min-height: 46px; max-height: 160px; flex: 1; padding: 12px 10px; border: 0; background: transparent; resize: none; }
.composer textarea:focus { box-shadow: none; }
.composer-actions { display: flex; align-items: center; gap: 7px; }
.icon-button { display: grid; width: 40px; height: 40px; place-items: center; border: 1px solid var(--line); border-radius: 12px; color: var(--cyan); background: rgba(255, 255, 255, 0.04); cursor: pointer; }
.icon-button.is-recording { border-color: rgba(255, 118, 108, 0.7); color: var(--danger); background: rgba(255, 118, 108, 0.1); animation: pulse 1.2s infinite; }
.send-button { min-height: 40px; padding: 0 14px; border-radius: 12px; }
.helper-line { min-height: 18px; margin: 8px 3px 0; color: var(--muted); font-size: 0.72rem; }

.inline-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 24px 0; }
.stack-form { display: grid; gap: 14px; padding: 24px 0; }
.result-list { display: grid; gap: 11px; }
.empty-state { min-height: 170px; place-items: center; padding: 28px; border: 1px dashed var(--line); border-radius: 18px; color: var(--muted); text-align: center; }
.result-card { display: grid; gap: 7px; padding: 16px 17px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-soft); }
.result-card h3 { margin: 0; font-size: 0.98rem; line-height: 1.4; }
.result-card p { margin: 0; color: var(--muted); font-size: 0.8rem; line-height: 1.5; }
.result-card a { width: fit-content; color: var(--cyan); font-size: 0.76rem; text-decoration: none; }
.result-meta { display: flex; flex-wrap: wrap; gap: 8px 12px; color: #7f93aa; font-size: 0.68rem; }
.severity-extreme, .severity-severe { border-color: rgba(255, 118, 108, 0.35); }
.severity-moderate { border-color: rgba(246, 197, 97, 0.3); }

.safety-callout { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin: 24px 0 17px; padding: 17px; border: 1px solid rgba(255, 118, 108, 0.28); border-radius: 17px; background: rgba(255, 118, 108, 0.075); }
.safety-callout div { display: grid; gap: 4px; }
.safety-callout span { color: #c6a8a8; font-size: 0.77rem; line-height: 1.45; }
.safety-callout a { flex: 0 0 auto; padding: 9px 13px; border-radius: 11px; color: #250503; background: #ff928a; font-size: 0.78rem; font-weight: 800; text-decoration: none; }
#safetyResults { margin-top: 18px; }

.assessment { display: grid; gap: 15px; margin-top: 8px; padding: 19px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface-soft); }
.risk-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.risk-pill { padding: 7px 10px; border-radius: 999px; font-size: 0.72rem; font-weight: 800; text-transform: uppercase; }
.risk-low { color: #082016; background: var(--success); }
.risk-medium { color: #2c1a00; background: var(--warning); }
.risk-high { color: #2c0704; background: var(--danger); }
.risk-unknown { color: #0b1727; background: #a8b7c8; }
.assessment h3, .assessment p { margin: 0; }
.assessment p, .assessment li { color: var(--muted); font-size: 0.82rem; line-height: 1.55; }
.assessment ul { margin: 0; padding-left: 19px; }

.toast { position: fixed; z-index: 50; right: 22px; bottom: max(22px, env(safe-area-inset-bottom)); max-width: min(360px, calc(100vw - 44px)); padding: 13px 16px; border: 1px solid var(--line); border-radius: 14px; background: #152944; box-shadow: var(--shadow); color: var(--text); font-size: 0.8rem; }
.toast.is-error { border-color: rgba(255, 118, 108, 0.5); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(255, 118, 108, 0.08); } }

@media (max-width: 860px) {
  .shell { padding: 18px; }
  .setup-layout { grid-template-columns: 1fr; padding-bottom: 40px; }
  .hero-card { padding-top: 22px; }
  .orb-wrap { min-height: 150px; }
  .assistant-layout { display: block; min-height: calc(100vh - 115px); border-radius: 22px; }
  .sidebar { padding: 17px 15px 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .welcome-block { display: none; }
  .side-nav { display: flex; gap: 5px; overflow-x: auto; }
  .nav-button { flex: 0 0 auto; min-height: 42px; padding: 0 10px; font-size: 0.75rem; }
  .nav-button span { width: auto; }
  .sidebar-footer { display: none; }
  .tool-panel { min-height: calc(100vh - 190px); padding: 21px 17px calc(22px + env(safe-area-inset-bottom)); }
  .messages { max-height: none; min-height: 300px; }
}

@media (max-width: 560px) {
  .topbar { min-height: 66px; padding-left: 15px; padding-right: 15px; }
  .brand small { display: none; }
  .connection-badge { padding: 7px 9px; }
  .shell { padding: 12px; }
  .setup-layout { min-height: auto; gap: 24px; }
  .hero-card h1 { font-size: 3.05rem; }
  .hero-copy { font-size: 0.94rem; }
  .boundary-note { display: grid; }
  .setup-card { padding: 22px 18px; border-radius: 22px; }
  .assistant-layout { border-radius: 19px; }
  .panel-heading { align-items: center; padding-bottom: 18px; }
  .panel-heading h2 { font-size: 1.55rem; }
  .speak-toggle span { display: none; }
  .message { max-width: 88%; }
  .composer { display: grid; grid-template-columns: 1fr auto; }
  .composer textarea { grid-column: 1 / -1; }
  .composer-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .send-button { margin-left: auto; }
  .inline-form { grid-template-columns: 1fr; }
  .safety-callout { align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
