:root {
  --bg: #090d16;
  --surface: rgba(17, 24, 39, 0.86);
  --surface-2: rgba(20, 29, 47, 0.96);
  --surface-3: #0f1727;
  --line: rgba(111, 132, 171, 0.22);
  --text: #ebf2ff;
  --muted: #97a4c1;
  --accent: #64b3ff;
  --accent-2: #89c7ff;
  --assistant: linear-gradient(180deg, rgba(53, 74, 116, 0.55), rgba(25, 37, 63, 0.82));
  --user: linear-gradient(180deg, rgba(22, 55, 101, 0.9), rgba(14, 40, 82, 0.96));
  --ok: #4bd08d;
  --warn: #f3bf57;
  --danger: #ff8e8e;
  --busy: #8ec1ff;
  --shadow: 0 18px 45px rgba(3, 7, 18, 0.38);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top, rgba(62, 125, 210, 0.2), transparent 34%),
    linear-gradient(180deg, #07101d 0%, #09101a 100%);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  padding: 0;
}

body.drawer-open {
  overflow: hidden;
}

.shell {
  max-width: 980px;
  margin: 0 auto;
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
  padding: 18px 16px 14px;
  backdrop-filter: blur(22px);
  background: rgba(9, 13, 22, 0.78);
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-2);
  margin-bottom: 6px;
}

.subtitle {
  margin: 8px 0 0;
  max-width: 620px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
}

h2 {
  font-size: 18px;
  margin-bottom: 4px;
}

h3 {
  font-size: 15px;
}

button,
select,
input,
textarea {
  font: inherit;
}

button {
  appearance: none;
  border: 0;
  cursor: pointer;
  padding: 12px 16px;
  border-radius: 14px;
  background: linear-gradient(180deg, #6ec0ff, #439dff);
  color: #06101d;
  font-weight: 700;
  box-shadow: 0 10px 25px rgba(67, 157, 255, 0.35);
}

button.secondary {
  background: rgba(19, 30, 48, 0.92);
  color: var(--text);
  border: 1px solid rgba(120, 146, 190, 0.22);
  box-shadow: none;
}

button:disabled {
  opacity: 0.65;
  cursor: wait;
}

.nav-button {
  min-width: 116px;
}

.icon-button {
  width: 44px;
  height: 44px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.content {
  padding: 16px;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.section-head,
.card-head,
.drawer-header,
.verbose-meta {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.section-head {
  margin-bottom: 12px;
}

.section-head.compact {
  margin-bottom: 10px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

.status-chip,
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  white-space: nowrap;
  border: 1px solid transparent;
}

.status-chip {
  background: rgba(151, 164, 193, 0.13);
  color: var(--muted);
}

.status-chip.ok,
.status-chip.idle {
  background: rgba(75, 208, 141, 0.18);
  color: var(--ok);
  border-color: rgba(75, 208, 141, 0.18);
}

.status-chip.warn,
.status-chip.thinking {
  background: rgba(243, 191, 87, 0.16);
  color: var(--warn);
  border-color: rgba(243, 191, 87, 0.18);
}

.status-chip.working,
.status-chip.busy,
.status-chip.typing {
  background: rgba(100, 179, 255, 0.16);
  color: var(--busy);
  border-color: rgba(100, 179, 255, 0.2);
}

.status-text {
  display: inline-flex;
  align-items: center;
}

.thinking-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.thinking-dots span {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.28;
  animation: think-bounce 1.15s infinite ease-in-out;
}

.thinking-dots span:nth-child(2) {
  animation-delay: 0.14s;
}

.thinking-dots span:nth-child(3) {
  animation-delay: 0.28s;
}

@keyframes think-bounce {
  0%,
  80%,
  100% {
    transform: translateY(0) scale(0.82);
    opacity: 0.28;
  }
  40% {
    transform: translateY(-2px) scale(1);
    opacity: 1;
  }
}

.info-banner,
.activity-banner,
.card,
.chat-list,
.verbose-list,
textarea,
input,
select,
.status-dock {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.info-banner,
.activity-banner {
  border-radius: 14px;
  padding: 12px 14px;
  line-height: 1.45;
}

.info-banner.warning {
  border-color: rgba(243, 191, 87, 0.35);
}

.activity-banner.thinking {
  border-color: rgba(243, 191, 87, 0.28);
}

.activity-banner.working,
.activity-banner.typing {
  border-color: rgba(100, 179, 255, 0.28);
}

.status-banner-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.chat-list,
.verbose-list {
  overflow: auto;
  border-radius: 22px;
  padding: 14px;
  scroll-behavior: smooth;
}

.chat-list {
  min-height: 56vh;
  max-height: calc(100vh - 360px);
  display: flex;
  flex-direction: column;
}

.verbose-list {
  min-height: 72vh;
  max-height: calc(100vh - 170px);
}

.msg {
  max-width: 88%;
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 18px;
  border: 1px solid rgba(125, 145, 184, 0.14);
}

.msg.assistant {
  background: var(--assistant);
  margin-right: auto;
}

.msg.user {
  background: var(--user);
  margin-left: auto;
}

.msg.optimistic {
  opacity: 0.82;
  border-style: dashed;
}

.meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.body,
.msg-content {
  line-height: 1.52;
  word-break: break-word;
}

.body-stream {
  min-height: 20px;
}

.body p:first-child,
.verbose-body p:first-child {
  margin-top: 0;
}

.body p:last-child,
.verbose-body p:last-child {
  margin-bottom: 0;
}

.body pre,
.body code,
.verbose-code {
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
}

.body pre,
.verbose-code {
  overflow: auto;
  margin: 12px 0 0;
  padding: 12px;
  border-radius: 14px;
  background: rgba(8, 13, 24, 0.95);
  border: 1px solid rgba(137, 164, 205, 0.16);
  white-space: pre-wrap;
}

.body code:not(pre code) {
  padding: 2px 6px;
  border-radius: 8px;
  background: rgba(10, 17, 31, 0.7);
}

.stream-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 10px;
}

.stream-indicator span {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: rgba(137, 199, 255, 0.85);
  animation: pulse 1.1s infinite ease-in-out;
}

.stream-indicator span:nth-child(2) {
  animation-delay: 0.12s;
}

.stream-indicator span:nth-child(3) {
  animation-delay: 0.24s;
}

@keyframes pulse {
  0%,
  80%,
  100% {
    transform: scale(0.7);
    opacity: 0.45;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

.chat-form {
  margin-top: 12px;
}

textarea,
input,
select {
  width: 100%;
  color: var(--text);
  border-radius: 16px;
  padding: 14px;
  outline: none;
}

textarea {
  resize: none;
  min-height: 54px;
}

input::placeholder,
textarea::placeholder {
  color: rgba(151, 164, 193, 0.78);
}

.composer-row {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
}

.status-dock {
  margin-top: 12px;
  border-radius: 20px;
  padding: 14px;
}

.composer-hint {
  color: var(--muted);
  font-size: 12px;
}

.status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.status-dock .activity-banner,
.status-dock .info-banner {
  margin-top: 12px;
}

.status-cards,
.provider-cards {
  margin-bottom: 12px;
}

.status-card {
  min-height: 140px;
}

.status-metric {
  font-size: 30px;
  font-weight: 800;
  margin-top: 10px;
}

.status-progress {
  width: 100%;
  height: 10px;
  margin-top: 12px;
  border-radius: 999px;
  background: rgba(125, 145, 184, 0.14);
  overflow: hidden;
}

.status-progress-provider {
  margin-top: 14px;
}

.status-progress-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  transition: width 220ms ease;
  background: linear-gradient(90deg, rgba(75, 208, 141, 0.95), rgba(100, 179, 255, 0.9));
}

.status-progress-fill.warn {
  background: linear-gradient(90deg, rgba(243, 191, 87, 0.95), rgba(255, 142, 142, 0.9));
}

.status-subtext {
  margin-top: 8px;
  line-height: 1.45;
}

.status-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.status-summary-item {
  border: 1px solid rgba(125, 145, 184, 0.12);
  border-radius: 14px;
  padding: 12px;
  background: rgba(12, 18, 31, 0.56);
}

.status-summary-label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.status-summary-item strong {
  display: block;
  line-height: 1.4;
  word-break: break-word;
}

.status-list {
  list-style: none;
  padding: 0;
  margin: 14px 0 0;
}

.status-row-item,
.status-list .empty {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(125, 145, 184, 0.12);
}

.status-row-item:last-child {
  border-bottom: 0;
}

.status-row-item span:last-child {
  text-align: right;
  color: var(--muted);
}

.status-raw {
  margin-top: 14px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(8, 13, 24, 0.95);
  border: 1px solid rgba(137, 164, 205, 0.16);
  white-space: pre-wrap;
  color: var(--text);
  overflow: auto;
}

.cards {
  display: grid;
  gap: 12px;
}

.split-cards {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 12px;
}

.card {
  border-radius: 22px;
  padding: 14px;
}

.transport-controls {
  margin-bottom: 12px;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.transport-controls input,
.transport-controls select {
  margin-bottom: 12px;
}

.pill.realtime {
  background: rgba(75, 208, 141, 0.18);
  color: var(--ok);
}

.pill.forecast {
  background: rgba(243, 191, 87, 0.16);
  color: var(--warn);
}

.pill.status-pill.ok {
  background: rgba(75, 208, 141, 0.18);
  color: var(--ok);
}

.pill.status-pill.warn {
  background: rgba(243, 191, 87, 0.16);
  color: var(--warn);
}

.eta-list,
#arrivals-list {
  list-style: none;
  padding: 0;
  margin: 14px 0 0;
}

.eta-row,
#arrivals-list li,
.empty {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(125, 145, 184, 0.12);
}

#arrivals-list li,
.empty {
  justify-content: flex-start;
}

.eta-row:last-child,
#arrivals-list li:last-child {
  border-bottom: 0;
}

.route {
  font-weight: 700;
}

.eta {
  color: var(--muted);
}

.verbose-item {
  border: 1px solid rgba(125, 145, 184, 0.14);
  border-radius: 16px;
  padding: 12px 14px;
  margin-bottom: 12px;
  background: rgba(14, 21, 36, 0.86);
}

.verbose-item.ok {
  border-color: rgba(75, 208, 141, 0.25);
}

.verbose-item.accent {
  border-color: rgba(100, 179, 255, 0.25);
}

.verbose-item.danger {
  border-color: rgba(255, 142, 142, 0.28);
}

.verbose-meta {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}

.verbose-body {
  line-height: 1.5;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 16, 0.62);
  backdrop-filter: blur(8px);
  z-index: 39;
}

.side-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(320px, 88vw);
  height: 100vh;
  background: rgba(8, 14, 24, 0.96);
  border-left: 1px solid rgba(137, 164, 205, 0.14);
  box-shadow: -28px 0 55px rgba(0, 0, 0, 0.35);
  transform: translateX(108%);
  transition: transform 0.22s ease;
  z-index: 40;
  padding: 18px 16px 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.side-drawer.open {
  transform: translateX(0);
}

.drawer-header {
  margin-bottom: 16px;
}

.drawer-nav {
  display: grid;
  gap: 10px;
}

.drawer-nav-button {
  width: 100%;
  text-align: left;
  background: rgba(19, 30, 48, 0.92);
  color: var(--text);
  border: 1px solid rgba(120, 146, 190, 0.22);
  box-shadow: none;
}

.drawer-nav-button.active {
  background: linear-gradient(180deg, #6ec0ff, #439dff);
  color: #06101d;
  border-color: transparent;
  box-shadow: 0 10px 25px rgba(67, 157, 255, 0.35);
}

@media (max-width: 860px) {
  .topbar,
  .section-head,
  .card-head,
  .drawer-header,
  .status-banner-row,
  .status-row-item {
    flex-direction: column;
    align-items: stretch;
  }

  .chat-list {
    min-height: 52vh;
    max-height: calc(100vh - 390px);
  }

  .status-summary-grid {
    grid-template-columns: 1fr;
  }

  .verbose-list {
    min-height: 65vh;
    max-height: calc(100vh - 190px);
  }

  .split-cards {
    grid-template-columns: 1fr;
  }

  .msg {
    max-width: 100%;
  }

  .nav-button,
  .composer-row button,
  button.secondary {
    width: 100%;
  }

  .side-drawer {
    width: 100vw;
    padding-bottom: 28px;
  }
}
