@font-face {
  font-family: 'Fira Sans Condensed';
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/fira-sans-condensed-v11-cyrillic_latin-500.woff2') format('woff2');
}

@font-face {
  font-family: 'Fira Sans Condensed';
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/fira-sans-condensed-v11-cyrillic_latin-700.woff2') format('woff2');
}

@font-face {
  font-family: 'Fira Sans Condensed';
  font-weight: 800;
  font-display: swap;
  src: url('/fonts/fira-sans-condensed-v11-cyrillic_latin-800.woff2') format('woff2');
}

@font-face {
  font-family: 'IBM Plex Mono';
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/ibm-plex-mono-v20-cyrillic_latin-500.woff2') format('woff2');
}

:root {
  color-scheme: dark;
  --bg: #0f0f0d;
  --panel: #171714;
  --line: #2a2925;
  --line-strong: #46443e;
  --fg: #f3f0e8;
  --muted: #8f8b81;
  --yellow: #ffc20e;
  --yellow-press: #e0a800;
  --ink: #11100d;
  --red: #d7261e;
  --red-press: #b31d16;
  --red-text: #ff5446;
  --sans: 'Fira Sans Condensed', 'Roboto Condensed', 'Arial Narrow', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --pad: 20px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-weight: 500;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

svg {
  display: block;
}

button {
  border-radius: 0;
  font: inherit;
  cursor: pointer;
}

input {
  user-select: text;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 3px solid var(--fg);
  outline-offset: 3px;
}

/* ---------- Views: loading → auth | app ---------- */

body[data-view='loading'] .auth,
body[data-view='loading'] .topbar,
body[data-view='loading'] .stage,
body[data-view='auth'] .topbar,
body[data-view='auth'] .stage,
body[data-view='app'] .auth {
  display: none;
}

/* ---------- Brand ---------- */

.brand {
  display: flex;
  align-items: baseline;
  gap: 14px;
  min-width: 0;
}

.wordmark {
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  white-space: nowrap;
}

.wordmark-ai {
  color: var(--yellow);
}

.tag {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

/* ---------- Top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 12px var(--pad);
  border-bottom: 1px solid var(--line);
}

.profile-button {
  flex: none;
  max-width: 45%;
  min-height: 44px;
  padding: 0 14px;
  border: 2px solid var(--line-strong);
  background: transparent;
  color: var(--fg);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.profile-button:active {
  background: var(--panel);
}

.profile-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Stage: display on top, one big switch below ---------- */

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 560px;
  min-height: 0;
  margin: 0 auto;
}

.display {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  padding: 16px var(--pad) var(--pad);
}

/* ---------- Avatar: the companion's "video call" tile ---------- */

.avatar {
  position: relative;
  flex: 1;
  min-height: 150px;
  overflow: hidden;
  background: var(--avatar-bg, #2b5a8a);
}

.avatar-art,
.avatar-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.avatar-art .avatar-svg {
  height: calc(100% - 60px);
}

.av-tilt,
.av-head,
.av-brows,
.av-gaze,
.av-eyes,
.av-mouth-open {
  transform-box: fill-box;
  transform-origin: center;
}

.av-tilt {
  transform-origin: 50% 100%;
  transition: transform 400ms var(--ease-out);
}

.av-brows,
.av-gaze {
  transition: transform 220ms var(--ease-out);
}

.av-eyes {
  transition: transform 70ms ease;
}

.av-mouth-open {
  transform: scale(0.7, 0);
}

.avatar.blink .av-eyes {
  transform: scaleY(0.1);
}

body[data-state='listening'] .avatar .av-tilt {
  transform: rotate(-3deg);
}

body[data-state='listening'] .avatar .av-brows {
  transform: translateY(-3px);
}

body[data-state='thinking'] .avatar .av-gaze {
  transform: translate(-4px, -3px);
}

body[data-state='thinking'] .avatar .av-brows {
  transform: translateY(-2px);
}

/* Looping clips (public/avatars/video): the listening one covers the drawing once it plays,
   the speaking one fades in over it. */
.avatar-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 40%;
  opacity: 0;
  pointer-events: none;
  transition: opacity 280ms ease;
}

.avatar[data-video='idle'] .avatar-video[data-kind='idle'],
.avatar[data-video='talk'] .avatar-video {
  opacity: 1;
}

.line {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--ink);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}

.avatar-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 8px 8px 14px;
  background: var(--ink);
}

.persona-id {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.persona-name {
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
}

.persona-role {
  overflow: hidden;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.persona-change {
  flex: none;
  min-height: 44px;
  padding: 0 14px;
  border: 2px solid var(--line-strong);
  background: transparent;
  color: var(--fg);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.persona-change:active {
  background: var(--panel);
}

body:not([data-state='idle']):not([data-state='error']) .persona-change {
  visibility: hidden;
}

/* ---------- Card over the avatar: found parkings, fuel, route ---------- */

.card {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  border: 2px solid var(--yellow);
  background: var(--bg);
  user-select: text;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 8px 12px 14px;
  border-bottom: 1px solid var(--line);
}

.card-heading {
  min-width: 0;
}

.card-title {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
}

.card-sub {
  margin: 6px 0 0;
  overflow: hidden;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-close {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 2px solid var(--line-strong);
  background: transparent;
  color: var(--fg);
}

.card-close svg {
  width: 18px;
  height: 18px;
}

.card-close:active {
  background: var(--panel);
}

.card-map {
  flex: none;
  height: 42%;
  min-height: 130px;
  border-bottom: 1px solid var(--line);
  background: #1d232a;
  user-select: none;
}

.card[data-type='route'] .card-map {
  flex: 1;
  height: auto;
}

.card[data-type='route'] .card-list {
  flex: none;
}

.card[data-type='route'] .card-item-details {
  font-size: 13px;
}

.translator-line {
  overflow-wrap: anywhere;
}

/* What the companion said — the other person reads it from the phone. */
.translator-said {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
}

.translator-said:first-child {
  border-left: 4px solid var(--yellow);
}

.translator-heard {
  font-size: 15px;
  line-height: 1.3;
  color: var(--muted);
}

.translator-empty {
  font-size: 15px;
  color: var(--muted);
}

/* The card needs the room more than the hint under the status. */
body:has(.card:not([hidden])) .hint {
  display: none;
}

/* TomTom's night map is bluish; muted to sit with the warm black UI. */
.card-map .leaflet-tile-pane {
  filter: saturate(0.45) brightness(0.95);
}

.card-map .leaflet-control-attribution {
  background: rgba(17, 16, 13, 0.75);
  color: var(--muted);
  font: 10px var(--mono);
}

.card-map .leaflet-control-attribution a {
  color: var(--muted);
}

/* Leaflet's own CSS loads later, hence the doubled class. */
.leaflet-marker-icon.map-pin {
  display: grid;
  place-items: center;
  border: 2px solid var(--ink);
  background: var(--yellow);
  color: var(--ink);
  font: 800 14px/1 var(--sans);
}

.leaflet-marker-icon.map-pin-end {
  background: var(--red);
}

.card-num {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  margin-right: 8px;
  padding: 0 4px;
  background: var(--yellow);
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
  vertical-align: 2px;
}

.card-list {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
}

.card-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.card-item-name {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.1;
}

.card-item-meta {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--yellow);
  font-variant-numeric: tabular-nums;
}

.card-item-details {
  font-size: 15px;
  line-height: 1.3;
  color: var(--muted);
}

.card-item-meta:empty,
.card-item-details:empty {
  display: none;
}

.card-nav {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.card-nav-link {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 12px;
  border: 2px solid var(--line-strong);
  color: var(--fg);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  text-decoration: none;
}

.card-nav-link:first-child {
  border-color: var(--yellow);
}

.card-nav-link:active {
  background: var(--panel);
}

.readout {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.led {
  flex: none;
  width: 10px;
  height: 10px;
  background: var(--line-strong);
}

body[data-state='connecting'] .led {
  background: var(--yellow);
  animation: blink 0.8s steps(1) infinite;
}

body[data-state='listening'] .led,
body[data-state='thinking'] .led,
body[data-state='speaking'] .led {
  background: var(--yellow);
}

body[data-state='error'] .led {
  background: var(--red);
}

.status {
  margin: 0;
  font-size: clamp(34px, 10vw, 56px);
  font-weight: 800;
  line-height: 0.95;
  letter-spacing: 0;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

body[data-state='speaking'] .status {
  color: var(--yellow);
}

body[data-state='error'] .status {
  color: var(--red-text);
  font-size: clamp(28px, 8vw, 40px);
}

.hint {
  margin: 0;
  min-height: 2.6em;
  max-width: 30em;
  font-size: 17px;
  line-height: 1.3;
  color: var(--muted);
}

/* Bar graph of the live voice; JS scales each bar with the spectrum. */
.meter {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 32px;
}

.bar {
  flex: 1;
  height: 100%;
  background: var(--line-strong);
  transform-origin: 50% 100%;
  transform: scaleY(0.06);
}

body[data-state='listening'] .bar {
  background: var(--fg);
}

body[data-state='connecting'] .bar,
body[data-state='thinking'] .bar,
body[data-state='speaking'] .bar {
  background: var(--yellow);
}

.talk {
  position: relative;
  flex: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  height: clamp(140px, 25vh, 260px);
  padding: var(--pad);
  border: 0;
  overflow: hidden;
  background: var(--yellow);
  color: var(--ink);
  text-align: left;
  touch-action: manipulation;
}

.talk:active {
  background: var(--yellow-press);
}

.talk:focus-visible {
  outline-offset: -6px;
  outline-color: var(--ink);
}

.icon {
  width: 44px;
  height: 44px;
}

.icon-stop {
  display: none;
}

.talk-label {
  font-size: clamp(40px, 13vw, 68px);
  font-weight: 800;
  line-height: 0.9;
  text-transform: uppercase;
}

/* Hazard stripes slide along the top edge while connecting. */
.talk::before {
  content: '';
  position: absolute;
  top: 0;
  left: -56px;
  right: 0;
  height: 14px;
  background: repeating-linear-gradient(-45deg, var(--yellow) 0 14px, var(--ink) 14px 28px);
  opacity: 0;
}

body[data-state='connecting'] .talk {
  background: var(--panel);
  color: var(--yellow);
}

body[data-state='connecting'] .talk::before {
  opacity: 1;
  animation: hazard 0.6s linear infinite;
}

body[data-state='listening'] .talk,
body[data-state='thinking'] .talk,
body[data-state='speaking'] .talk {
  background: var(--red);
  color: var(--fg);
}

body[data-state='listening'] .talk:active,
body[data-state='thinking'] .talk:active,
body[data-state='speaking'] .talk:active {
  background: var(--red-press);
}

body[data-state='listening'] .icon-mic,
body[data-state='thinking'] .icon-mic,
body[data-state='speaking'] .icon-mic {
  display: none;
}

body[data-state='listening'] .icon-stop,
body[data-state='thinking'] .icon-stop,
body[data-state='speaking'] .icon-stop {
  display: block;
}

/* ---------- Auth ---------- */

.auth {
  flex: 1;
  overflow-y: auto;
  padding: 0 var(--pad);
}

.auth-inner {
  display: flex;
  flex-direction: column;
  justify-content: safe center;
  width: 100%;
  max-width: 440px;
  min-height: 100%;
  margin: 0 auto;
  padding: 28px 0;
}

.auth-title {
  margin: 48px 0 0;
  font-size: clamp(56px, 18vw, 80px);
  font-weight: 800;
  line-height: 0.9;
  text-transform: uppercase;
}

.auth-subtitle {
  margin: 12px 0 32px;
  font-size: 19px;
  line-height: 1.35;
  color: var(--muted);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-label {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.field input {
  width: 100%;
  height: 58px;
  padding: 0 16px;
  border: 2px solid var(--line-strong);
  border-radius: 0;
  background: var(--panel);
  color: var(--fg);
  font: inherit;
  font-size: 20px;
  outline: none;
}

.field input::placeholder {
  color: #5d5a53;
}

.field input:focus {
  border-color: var(--yellow);
}

.field-password {
  position: relative;
  display: block;
}

.field-password input {
  padding-right: 120px;
}

.field-toggle {
  position: absolute;
  top: 2px;
  right: 2px;
  bottom: 2px;
  padding: 0 16px;
  border: 0;
  border-left: 2px solid var(--line-strong);
  background: transparent;
  color: var(--fg);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.field-toggle:focus-visible {
  outline-offset: -4px;
}

.auth-error {
  min-height: 1.3em;
  margin: -4px 0 0;
  font-size: 17px;
  line-height: 1.3;
  color: var(--red-text);
}

.auth-submit {
  height: 64px;
  border: 0;
  background: var(--yellow);
  color: var(--ink);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.auth-submit:active {
  background: var(--yellow-press);
}

.auth-submit:disabled {
  opacity: 0.6;
  cursor: progress;
}

.auth-switch {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  margin: 24px 0 0;
  font-size: 17px;
  color: var(--muted);
}

.auth-switch button {
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--fg);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: var(--yellow);
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
}

/* ---------- Get the app ---------- */

.get-app {
  margin-top: 36px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.get-app-label {
  margin: 0 0 10px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.get-app-button {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 68px;
  padding: 10px 18px;
  border: 2px solid var(--yellow);
  color: var(--fg);
  text-decoration: none;
}

.get-app-button:active {
  background: var(--panel);
}

.get-app-icon {
  flex: none;
  width: 28px;
  height: 28px;
  color: var(--yellow);
}

.get-app-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.get-app-title {
  font-size: 21px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.get-app-meta {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.get-app-note {
  margin: 10px 0 0;
  font-size: 16px;
  line-height: 1.35;
  color: var(--muted);
}

.topbar-get-app {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  min-height: 44px;
  margin-left: auto;
  padding: 0 12px;
  border: 2px solid var(--yellow);
  color: var(--yellow);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
}

.topbar-get-app svg {
  width: 18px;
  height: 18px;
}

.topbar-get-app:active {
  background: var(--panel);
}

@media (max-width: 480px) {
  .topbar:has(.topbar-get-app:not([hidden])) .tag {
    display: none;
  }
}

@media (max-width: 400px) {
  .topbar-get-app span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
}

.get-app-lead {
  margin: 20px 0 0;
  font-size: 18px;
  line-height: 1.4;
}

.get-app-qr {
  display: block;
  width: 240px;
  height: 240px;
  margin: 20px auto 0;
  background: #fff;
}

.get-app-steps {
  margin: 20px 0 0;
  padding-left: 22px;
  font-size: 16px;
  line-height: 1.45;
  color: var(--muted);
}

.get-app-steps b {
  color: var(--fg);
  font-weight: 700;
}

.get-app-direct {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  padding: 0 16px;
  border: 2px solid var(--line-strong);
  color: var(--fg);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  text-decoration: none;
}

.get-app-direct:active {
  background: var(--panel);
}

/* ---------- Profile & memory dialog ---------- */

.memory {
  width: min(94vw, 480px);
  max-height: 86vh;
  padding: 24px;
  border: 2px solid var(--line-strong);
  background: var(--bg);
  color: var(--fg);
  user-select: text;
}

.memory::backdrop {
  background: rgba(0, 0, 0, 0.8);
}

.memory h2 {
  margin: 0;
  font-size: 34px;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
}

.memory-sub {
  margin: 8px 0 0;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
}

.memory h3 {
  margin: 24px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 20px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.memory h4 {
  margin: 18px 0 6px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--yellow);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.memory ul {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 18px;
  line-height: 1.45;
}

.memory li {
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}

.memory-content {
  margin-top: 8px;
  font-size: 18px;
  line-height: 1.45;
}

.memory-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 28px;
}

.memory-actions button,
.logout {
  min-height: 56px;
  padding: 0 16px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.memory-actions .primary {
  border: 0;
  background: var(--yellow);
  color: var(--ink);
}

.memory-actions .primary:active {
  background: var(--yellow-press);
}

.memory-actions .danger {
  border: 2px solid var(--red-text);
  background: transparent;
  color: var(--red-text);
}

.logout {
  width: 100%;
  margin-top: 8px;
  border: 2px solid var(--line-strong);
  background: transparent;
  color: var(--muted);
}

.memory-actions .danger:active,
.logout:active {
  background: var(--panel);
}

/* ---------- Profile: balance, invites, account ---------- */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.profile {
  display: flex;
  flex-direction: column;
  padding-bottom: 20px;
}

.profile:not([open]) {
  display: none;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 20px 0 0;
  border: 2px solid var(--line-strong);
}

.tabs button {
  min-height: 48px;
  padding: 0 4px;
  border: 0;
  border-left: 2px solid var(--line-strong);
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.tabs button:first-child {
  border-left: 0;
}

.tabs button[aria-selected='true'] {
  background: var(--yellow);
  color: var(--ink);
}

.tab-panel {
  padding-top: 4px;
}

.balance {
  display: flex;
  flex-direction: column;
  margin-top: 20px;
}

.balance-label {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.balance-amount {
  font-size: 56px;
  font-weight: 800;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.balance-amount.is-empty {
  color: var(--red-text);
}

.topup-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.topup-options button,
.topup-custom button,
.invite-link button {
  min-height: 56px;
  border: 2px solid var(--yellow);
  background: transparent;
  color: var(--fg);
  font-size: 20px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  transition: transform 160ms var(--ease-out);
}

.topup-options button:active,
.topup-custom button:active,
.invite-link button:active {
  background: var(--yellow);
  color: var(--ink);
  transform: scale(0.97);
}

.topup-custom,
.invite-link {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 8px;
}

.topup-custom input,
.invite-link input {
  min-width: 0;
  height: 56px;
  padding: 0 14px;
  border: 2px solid var(--line-strong);
  border-radius: 0;
  background: var(--panel);
  color: var(--fg);
  font: inherit;
  font-size: 18px;
  outline: none;
}

.topup-custom input:focus {
  border-color: var(--yellow);
}

.topup-custom button,
.invite-link button {
  padding: 0 16px;
  font-size: 15px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.invite-link input {
  font-family: var(--mono);
  font-size: 14px;
}

.topup button:disabled {
  opacity: 0.5;
  cursor: progress;
}

.topup-note {
  margin: 8px 0 0;
  font-size: 14px;
  color: var(--muted);
}

.form-error {
  min-height: 1.3em;
  margin: 6px 0 0;
  font-size: 16px;
  line-height: 1.3;
  color: var(--red-text);
}

.form-error.is-ok {
  color: var(--yellow);
}

.history li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  font-size: 16px;
}

.history-amount {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.history-amount.is-plus {
  color: var(--yellow);
}

.history-date {
  grid-column: 1 / -1;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

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

.invite-lead {
  margin: 20px 0 0;
  font-size: 19px;
  line-height: 1.4;
}

.invite-lead b {
  color: var(--yellow);
}

.invite-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 20px 0;
}

.invite-stats div {
  display: flex;
  flex-direction: column;
  padding: 12px 14px;
  border: 2px solid var(--line);
}

.invite-stats b {
  font-size: 32px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.invite-stats span {
  font-size: 14px;
  color: var(--muted);
}

.invite-link {
  margin-top: 8px;
}

.profile-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 20px;
}

.profile-form .field input {
  height: 52px;
  font-size: 18px;
}

.wide-primary,
.wide-secondary,
.wide-danger {
  width: 100%;
  min-height: 56px;
  margin-top: 8px;
  padding: 0 16px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.wide-primary {
  border: 0;
  background: var(--yellow);
  color: var(--ink);
}

.wide-primary:active {
  background: var(--yellow-press);
}

.wide-secondary {
  border: 2px solid var(--yellow);
  background: transparent;
  color: var(--fg);
}

.wide-danger {
  margin-top: 20px;
  border: 2px solid var(--red-text);
  background: transparent;
  color: var(--red-text);
}

.wide-secondary:active,
.wide-danger:active {
  background: var(--panel);
}

.profile-form button:disabled {
  opacity: 0.6;
  cursor: progress;
}

.account-exit {
  margin-top: 28px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.admin-link {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg);
  text-decoration: none;
}

.profile-close {
  margin-top: 24px;
}

.profile-balance {
  display: block;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--yellow);
  white-space: nowrap;
}

.profile-balance.is-empty {
  color: var(--red-text);
}

/* ---------- Companion picker ---------- */

.persona-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 20px 0 8px;
}

.persona-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 0 14px 0 0;
  border: 2px solid var(--line-strong);
  background: transparent;
  color: var(--fg);
  text-align: left;
}

.persona-item:active {
  background: var(--panel);
}

.persona-item[aria-pressed='true'] {
  border-color: var(--yellow);
}

.persona-thumb {
  position: relative;
  flex: none;
  width: 76px;
  height: 76px;
  overflow: hidden;
}

.persona-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  padding: 10px 0;
}

.persona-item-name {
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
}

.persona-item-role {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--yellow);
}

.persona-item-tag {
  font-size: 16px;
  line-height: 1.25;
  color: var(--muted);
}

.persona-check {
  flex: none;
  width: 14px;
  height: 14px;
  border: 2px solid var(--line-strong);
}

.persona-item[aria-pressed='true'] .persona-check {
  border-color: var(--yellow);
  background: var(--yellow);
}

.persona-list h3 {
  margin: 16px 0 4px;
  padding-top: 16px;
  color: var(--red-text);
}

.adult-gate {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border: 2px dashed var(--line-strong);
}

.adult-gate p {
  margin: 0;
  font-size: 17px;
  line-height: 1.35;
  color: var(--muted);
}

.adult-confirm {
  min-height: 52px;
  border: 2px solid var(--red-text);
  background: transparent;
  color: var(--red-text);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.adult-confirm:active {
  background: var(--panel);
}

/* ---------- Small phones ---------- */

@media (max-width: 360px) {
  .topbar .tag {
    display: none;
  }
}

/* ---------- Phone in a landscape dashboard holder ---------- */

@media (orientation: landscape) and (max-height: 560px) {
  :root {
    --pad: 16px;
  }

  .topbar,
  .stage {
    max-width: none;
  }

  .topbar {
    padding-block: 6px;
  }

  .stage {
    flex-direction: row;
  }

  .display {
    flex-direction: row;
    gap: 16px;
    padding: var(--pad);
  }

  .avatar {
    flex: none;
    height: 100%;
    min-height: 0;
    aspect-ratio: 1;
  }

  .persona-role {
    display: none;
  }

  .readout {
    flex: 1;
    justify-content: center;
    min-width: 0;
  }

  .status {
    font-size: clamp(28px, 5vw, 44px);
  }

  .hint {
    font-size: 15px;
  }

  .talk {
    width: 30%;
    height: auto;
  }

  .icon {
    width: 40px;
    height: 40px;
  }

  .talk-label {
    font-size: clamp(30px, 5vw, 48px);
  }
}

/* ---------- Motion ---------- */

@keyframes blink {
  50% {
    opacity: 0.2;
  }
}

@keyframes hazard {
  to {
    transform: translateX(39.6px);
  }
}

@media (prefers-reduced-motion: reduce) {
  body[data-state='connecting'] .led,
  body[data-state='connecting'] .talk::before {
    animation: none;
  }
  .av-tilt,
  .av-brows,
  .av-gaze {
    transition: none;
  }
  body[data-state] .avatar .av-tilt {
    transform: none;
  }
}
