:root {
  --primary: #0a0a0a;
  --accent: #c41e3a;
  --bg: #0d0d0d;
  --surface: #161616;
  --surface-elevated: #1e1e1e;
  --text: #f2f2f2;
  --muted: #9a9a9a;
  --border: #2a2a2a;
  --radius: 4px;
  --touch: 44px;
  --font: "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.45;
}

.app[hidden] {
  display: none;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 0.75rem 0.75rem 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0 1rem;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  gap: 0.65rem;
  align-items: center;
}

.brand-logo {
  font-size: 1.5rem;
  line-height: 1;
  color: var(--accent);
}

.brand-name {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text);
}

.brand-tagline {
  margin: 0.2rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.btn-text {
  min-height: var(--touch);
  padding: 0.5rem 0.5rem;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  text-transform: uppercase;
}

.btn-text:hover {
  color: var(--accent);
}

.progress-wrap {
  margin: 0.75rem 0;
}

.progress-label {
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.progress-bar {
  height: 2px;
  background: var(--border);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.3s ease;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.transcript {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-height: 200px;
  max-height: 52vh;
}

.msg {
  max-width: 92%;
  padding: 0.65rem 0.85rem;
  font-size: 0.9375rem;
  line-height: 1.4;
}

.msg-assistant {
  align-self: flex-start;
  background: var(--surface);
  border-left: 2px solid var(--accent);
}

.msg-user {
  align-self: flex-end;
  background: var(--surface-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}

.msg-label {
  display: block;
  font-size: 0.625rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.typing-indicator {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.65rem;
  opacity: 0.92;
}

.typing-indicator .msg-label {
  width: 100%;
  margin-bottom: 0;
}

.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
}

.typing-dots i {
  display: block;
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: var(--accent);
  animation: typing-bounce 1.1s ease-in-out infinite;
}

.typing-dots i:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dots i:nth-child(3) {
  animation-delay: 0.3s;
}

.typing-caption {
  font-size: 0.8125rem;
  color: var(--muted);
}

@keyframes typing-bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.35;
  }
  30% {
    transform: translateY(-3px);
    opacity: 1;
  }
}

.prompt {
  font-size: 0.9375rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
}

.node-root {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.app.demo-mode .node-root {
  margin-top: 0.5rem;
}

.app.prod-mode .node-root.select-hidden {
  display: none;
}

.quick-replies {
  margin: 0.5rem 0;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chip {
  min-height: 36px;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  text-align: center;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.chip.selected {
  border-color: var(--accent);
  color: var(--accent);
}

.app.demo-mode .chip {
  flex: 1 1 calc(50% - 0.2rem);
  min-width: calc(50% - 0.2rem);
}

.btn-primary {
  min-height: var(--touch);
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  width: 100%;
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-secondary {
  min-height: var(--touch);
  padding: 0.75rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}

.field-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field-label {
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.field-input {
  min-height: var(--touch);
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  width: 100%;
  background: var(--surface);
  color: var(--text);
}

.field-input:focus {
  outline: none;
  border-color: var(--accent);
}

.field-hint {
  font-size: 0.75rem;
  color: var(--muted);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.card-title {
  font-weight: 700;
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0 0 0.5rem;
}

.card-facts {
  list-style: none;
  margin: 0;
  padding: 0;
}

.card-facts li {
  padding: 0.35rem 0;
  font-size: 0.9375rem;
  border-bottom: 1px solid var(--border);
}

.card-warning {
  font-size: 0.8125rem;
  color: var(--muted);
  margin: 0.75rem 0 0;
  padding: 0.5rem;
  background: var(--surface-elevated);
  border-radius: var(--radius);
}

.terminal-card,
.report-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-top: 0.5rem;
}

.report-panel h3 {
  margin: 0 0 0.5rem;
  font-size: 0.6875rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.report-facts {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
}

.report-narrative {
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.45;
  margin: 0.75rem 0;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.04);
  border-left: 3px solid var(--accent, #c41e3a);
}

.report-facts li {
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

.terminal-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  color: var(--accent);
}

.terminal-summary {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.9375rem;
}

.terminal-lead {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 1rem;
}

.scan-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.scan-spinner {
  width: 28px;
  height: 28px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.error {
  color: #ff6b6b;
  font-size: 0.875rem;
  margin: 0.5rem 0 0;
  padding: 0.65rem;
  background: rgba(196, 30, 58, 0.12);
  border-radius: var(--radius);
}

.chat-footer {
  position: sticky;
  bottom: 0;
  padding: 0.65rem 0 0.75rem;
  background: var(--bg);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chat-bar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.chat-input {
  flex: 1;
  min-height: var(--touch);
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9375rem;
  font-family: inherit;
}

.chat-input:focus {
  outline: none;
  border-color: var(--accent);
}

.btn-send {
  min-height: var(--touch);
  padding: 0 1rem;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.app.demo-mode .chat-bar {
  opacity: 0.85;
}

.app.prod-mode .chat-bar {
  flex: 1;
}

.route-badge {
  cursor: pointer;
  font-size: 0.625rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.2rem 0.5rem;
  align-self: center;
}

.route-badge:hover {
  color: var(--accent);
}

.loading {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  gap: 1rem;
  color: var(--muted);
  background: var(--bg);
}

.loading[hidden] {
  display: none;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 360px) {
  .app.demo-mode .chip {
    flex: 1 1 100%;
    min-width: 100%;
  }
}
