:root {
  color-scheme: dark;
  --night: #081728;
  --panel: #102943;
  --panel-deep: #0c2239;
  --line: rgba(216, 237, 255, .14);
  --paper: #f5fbff;
  --muted: #9db5ca;
  --mint: #49e0b1;
  --mint-dark: #113f3c;
  --amber: #ffc45b;
  --coral: #ff7d78;
  --blue: #70cfff;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", sans-serif;
  background: var(--night);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  min-height: 100svh;
  color: var(--paper);
  background:
    radial-gradient(circle at 86% -4%, rgba(73, 224, 177, .16), transparent 25rem),
    radial-gradient(circle at -10% 42%, rgba(112, 207, 255, .10), transparent 22rem),
    var(--night);
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.app-shell {
  width: min(100%, 590px);
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 18px) 17px calc(env(safe-area-inset-bottom) + 112px);
}

.topbar, .section-heading, .gate-signal {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}
.topbar { margin-bottom: 22px; }
.eyebrow {
  margin: 0 0 6px;
  color: var(--mint);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .14em;
  text-transform: uppercase;
}
h1, h2 {
  margin: 0;
  font-family: "Arial Rounded MT Bold", "SF Pro Rounded", "PingFang SC", sans-serif;
  letter-spacing: -.04em;
}
h1 { font-size: clamp(30px, 8.7vw, 44px); line-height: 1.05; }
h1 span { color: var(--mint); }
h2 { font-size: 21px; }

.connection {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 7px;
  margin-top: 3px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(8, 23, 40, .76);
  font-size: 11px;
  font-weight: 800;
}
.connection i, .live-mark i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(255, 196, 91, .12);
}
.connection[data-state="online"] i, .live-mark i { background: var(--mint); box-shadow: 0 0 0 4px rgba(73, 224, 177, .12); }
.connection[data-state="offline"] i { background: var(--coral); box-shadow: none; }

.safety-gate, .composer, .message-history {
  border: 1px solid var(--line);
  border-radius: 29px;
  background: linear-gradient(145deg, rgba(18, 48, 76, .98), rgba(12, 34, 57, .98));
  box-shadow: 0 22px 54px rgba(0, 7, 17, .28);
}
.safety-gate { padding: 0; }
.safety-gate > summary { list-style: none; padding: 14px 15px; cursor: pointer; }
.safety-gate > summary::-webkit-details-marker { display: none; }
.gate-signal { justify-content: flex-start; }
.gate-icon {
  display: grid;
  place-items: center;
  flex: 0 0 43px;
  width: 43px;
  height: 43px;
  border: 1px solid rgba(255, 125, 120, .32);
  border-radius: 15px;
  background: rgba(255, 125, 120, .10);
}
.gate-icon i {
  width: 11px;
  height: 11px;
  border: 3px solid var(--coral);
  border-radius: 50%;
  box-shadow: 0 0 0 7px rgba(255, 125, 120, .09);
}
.gate-signal[data-safe="true"] .gate-icon { border-color: rgba(73, 224, 177, .34); background: rgba(73, 224, 177, .10); }
.gate-signal[data-safe="true"] .gate-icon i { border-color: var(--mint); box-shadow: 0 0 0 7px rgba(73, 224, 177, .09); }
.gate-kicker { margin: 0 0 3px; color: var(--muted); font-size: 11px; font-weight: 800; }
.gate-signal > div { min-width: 0; flex: 1; }
.gate-signal h2 { font-size: 16px; }
.gate-signal p:last-child { overflow: hidden; margin: 3px 0 0; color: var(--muted); font-size: 10px; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }
.gate-chevron { align-self: center; color: var(--muted); font-size: 20px; transition: transform .18s; }
.safety-gate[open] .gate-chevron { transform: rotate(180deg); }
.safety-controls { padding: 0 15px 14px; border-top: 1px solid rgba(216,237,255,.08); }

.vehicle-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin-top: 13px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: rgba(5, 18, 32, .48);
}
.vehicle-switch button {
  min-height: 43px;
  border: 0;
  border-radius: 12px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 800;
}
.vehicle-switch button span { display: inline-grid; width: 18px; margin-right: 2px; color: var(--paper); }
.vehicle-switch button.is-active { color: var(--night); background: var(--mint); box-shadow: 0 6px 18px rgba(73, 224, 177, .18); }
.vehicle-switch button[data-mode="moving"].is-active { color: var(--paper); background: #a34b50; box-shadow: none; }
.demo-note { margin: 11px 2px 0; color: #7f9aaf; font-size: 10px; line-height: 1.5; }

.composer, .message-history { margin-top: 14px; padding: 21px; }
.section-heading { align-items: center; }
.section-heading a {
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
  text-decoration: none;
}
.private-badge { padding: 6px 8px; border: 1px solid rgba(73,224,177,.18); border-radius: 999px; color: var(--mint); background: rgba(73,224,177,.07); font-size: 9px; font-weight: 800; }
.quick-messages { display: flex; gap: 7px; margin: 17px -2px 15px; overflow-x: auto; padding: 2px; scrollbar-width: none; }
.quick-messages::-webkit-scrollbar { display: none; }
.quick-messages button {
  flex: 0 0 auto;
  padding: 10px 12px;
  border: 1px solid rgba(112, 207, 255, .22);
  border-radius: 999px;
  color: #d9efff;
  background: rgba(112, 207, 255, .07);
  font-size: 12px;
  font-weight: 720;
}
form > label { display: block; margin: 0 0 7px 2px; color: var(--muted); font-size: 11px; font-weight: 800; }
.message-field { position: relative; }
textarea {
  width: 100%;
  min-height: 102px;
  resize: none;
  padding: 15px 15px 28px;
  border: 1px solid rgba(216, 237, 255, .18);
  border-radius: 17px;
  outline: none;
  color: var(--paper);
  background: rgba(4, 17, 30, .48);
  font-size: 16px;
  line-height: 1.55;
}
textarea:focus, input:focus { border-color: var(--mint); box-shadow: 0 0 0 3px rgba(73, 224, 177, .10); }
.message-field > span { position: absolute; right: 13px; bottom: 10px; color: #6f8ca4; font-size: 10px; }
.message-field > span.is-near-limit { color: var(--amber); }
.send-button, dialog button[type="submit"] {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 51px;
  margin-top: 10px;
  border: 0;
  border-radius: 16px;
  color: #05221e;
  background: var(--mint);
  box-shadow: 0 10px 25px rgba(73, 224, 177, .17);
  font-weight: 850;
}
.send-button span { font-size: 21px; }
.send-button:disabled { opacity: .55; box-shadow: none; }
.privacy-note { margin: 11px 2px 0; color: #829db3; font-size: 10px; line-height: 1.5; }

.live-mark { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; font-weight: 800; }
.empty-state { padding: 34px 18px 20px; text-align: center; color: var(--muted); }
.empty-state > span { display: block; color: var(--mint); font-size: 34px; }
.empty-state strong { display: block; margin-top: 5px; color: var(--paper); }
.empty-state p { max-width: 310px; margin: 7px auto 0; font-size: 11px; line-height: 1.55; }
.message-list { display: grid; gap: 12px; margin-top: 18px; }
.message-card {
  position: relative;
  overflow: hidden;
  padding: 16px 15px 14px 21px;
  border: 1px solid rgba(216, 237, 255, .13);
  border-radius: 18px;
  background: rgba(5, 19, 33, .48);
}
.message-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--amber);
}
.message-card[data-tone="success"]::before { background: var(--mint); }
.message-card[data-tone="danger"]::before { background: var(--coral); }
.message-meta { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 10px; }
.message-meta strong { color: var(--amber); font-size: 11px; }
.message-card[data-tone="success"] .message-meta strong { color: var(--mint); }
.message-card[data-tone="danger"] .message-meta strong { color: var(--coral); }
.message-text { margin: 11px 0 0; color: var(--paper); font-size: 16px; font-weight: 720; line-height: 1.55; }
.status-track { display: flex; align-items: center; gap: 6px; margin-top: 13px; }
.status-track i { flex: 1; height: 3px; border-radius: 99px; background: rgba(216, 237, 255, .10); }
.status-track i.is-done { background: var(--mint); }
.reply-bubble { margin: 13px 0 0 18px; padding: 11px 13px; border-radius: 15px 15px 4px 15px; color: #dffbf2; background: var(--mint-dark); font-size: 13px; line-height: 1.5; }
.reply-bubble span { display: block; margin-bottom: 3px; color: var(--mint); font-size: 9px; font-weight: 850; letter-spacing: .08em; }
.message-actions { display: flex; justify-content: flex-end; margin-top: 10px; }
.withdraw-button { padding: 7px 9px; border: 1px solid rgba(255, 125, 120, .25); border-radius: 10px; color: #ffaaa6; background: transparent; font-size: 10px; font-weight: 800; }

dialog {
  width: min(calc(100% - 34px), 420px);
  padding: 0;
  border: 1px solid rgba(216, 237, 255, .18);
  border-radius: 26px;
  color: var(--paper);
  background: #102943;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .58);
}
dialog::backdrop { background: rgba(2, 10, 18, .78); backdrop-filter: blur(6px); }
dialog form { padding: 25px; }
dialog form > p:not(.eyebrow) { margin: 8px 0 20px; color: var(--muted); font-size: 12px; line-height: 1.55; }
dialog label { display: block; margin: 13px 0 6px; color: var(--muted); font-size: 11px; font-weight: 800; }
dialog input {
  width: 100%;
  height: 48px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  outline: none;
  color: var(--paper);
  background: rgba(4, 17, 30, .52);
}
.pair-error { display: block; min-height: 18px; padding-top: 7px; color: var(--coral); font-size: 11px; }

.toast {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 91px);
  max-width: calc(100% - 40px);
  padding: 11px 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--paper);
  background: rgba(4, 17, 30, .94);
  box-shadow: 0 12px 35px rgba(0,0,0,.38);
  font-size: 12px;
  font-weight: 750;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.app-nav {
  position: fixed;
  z-index: 9;
  right: max(13px, calc((100vw - 590px) / 2 + 13px));
  bottom: calc(env(safe-area-inset-bottom) + 11px);
  left: max(13px, calc((100vw - 590px) / 2 + 13px));
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 7px;
  border: 1px solid rgba(216,237,255,.18);
  border-radius: 23px;
  background: rgba(8,24,41,.91);
  box-shadow: 0 18px 55px rgba(0,0,0,.5);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.app-nav a { min-height: 52px; display: grid; place-items: center; align-content: center; gap: 3px; border-radius: 17px; color: #7893aa; font-size: 9px; font-weight: 800; text-decoration: none; }
.app-nav a.is-active { color: var(--night); background: var(--mint); box-shadow: 0 8px 20px rgba(73,224,177,.16); }
.app-nav svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

button:focus-visible, a:focus-visible, textarea:focus-visible, input:focus-visible { outline: 3px solid rgba(112, 207, 255, .45); outline-offset: 2px; }
@media (max-width: 380px) {
  h1 { font-size: 29px; }
  .connection span { display: none; }
  .vehicle-switch button { font-size: 11px; }
  .composer, .message-history { padding: 17px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
