:root {
  --bg: #0f1419;
  --panel: #1a2332;
  --line: #2a3544;
  --text: #eef3f8;
  --muted: #8b9aab;
  --in: #243044;
  --out: #2f6fed;
  --accent: #3d8bfd;
  --ok: #3dd68c;
  --danger: #ff6b7a;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  max-width: 100%;
  -webkit-text-size-adjust: 100%;
}
.hidden { display: none !important; }

.screen {
  height: 100%;
  height: 100dvh;
  max-width: 100%;
  overflow-x: hidden;
}

.boot-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top, 0px) 16px env(safe-area-inset-bottom, 0px);
  background: var(--bg);
}
.boot-logo {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--muted);
  text-align: center;
  width: 100%;
}

/* LOGIN */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px))
    max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  width: 100%;
}
.login-card {
  width: 100%;
  max-width: min(380px, 100%);
  background: var(--panel);
  border-radius: 16px;
  padding: 20px;
}
.login-logo {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: center;
}
.login-sub {
  text-align: center;
  color: var(--muted);
}
.login-hint, .status { color: var(--muted); }
.login-hint { margin: 8px 0; font-size: 0.9rem; line-height: 1.35; }
.flashcall-number {
  display: block;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  margin: 12px 0;
  color: var(--accent);
  text-decoration: none;
  word-break: break-all;
  line-height: 1.3;
  -webkit-tap-highlight-color: transparent;
}
.flashcall-number:active { opacity: 0.75; }
.status { min-height: 1.2em; margin-top: 10px; }
.status.error { color: var(--danger); }
.status.ok { color: var(--ok); }

.field {
  width: 100%;
  max-width: 100%;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: #121a24;
  color: var(--text);
  /* ≥16px — иначе iOS зумит страницу и она «уезжает» вширь */
  font-size: 16px;
}

.btn {
  border: 0;
  border-radius: 12px;
  padding: 13px 16px;
  font-weight: 600;
  cursor: pointer;
  font-size: 1rem;
}
.btn.primary {
  width: 100%;
  margin-top: 12px;
  background: var(--accent);
  color: #fff;
}
.btn.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}
.btn.small { padding: 8px 12px; font-size: 0.85rem; }
.btn.send {
  background: var(--accent);
  color: #fff;
  white-space: nowrap;
}

/* CHAT */
.chat-screen {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  background: var(--bg);
}

.topbar {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 14px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.topbar-main { min-width: 0; }
.title { font-weight: 700; }
.subtitle { font-size: 0.8rem; color: var(--muted); }
.subtitle.online { color: var(--ok); }

.devices-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #141c28;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.devices-list {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  flex: 1 1 auto;
  min-width: 0;
}
.device-chip {
  border: 1px solid var(--line);
  background: #1e2a3a;
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.85rem;
  white-space: nowrap;
  cursor: pointer;
}
.device-chip.active {
  border-color: #22c55e;
  background: rgba(34, 197, 94, 0.18);
  color: #4ade80;
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.35);
}
.device-prompt .field.hidden,
.device-prompt input.hidden {
  display: none;
}
.device-chip.empty {
  color: var(--muted);
  border-style: dashed;
  cursor: default;
}
.device-action {
  border: 1px solid var(--line);
  background: #1e2a3a;
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.82rem;
  white-space: nowrap;
  cursor: pointer;
  flex: 0 0 auto;
}
.device-action.muted {
  color: var(--muted);
}
.device-action:disabled,
.btn:disabled,
.device-chip:disabled {
  opacity: 0.45;
  pointer-events: none;
}

.busy-bar {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 12px 10px;
  background: #121a24;
  border-bottom: 1px solid var(--line);
}
.busy-text {
  font-size: 0.82rem;
  color: var(--muted);
}
.busy-track {
  height: 3px;
  border-radius: 2px;
  background: var(--line);
  overflow: hidden;
}
.busy-indeterminate {
  height: 100%;
  width: 40%;
  border-radius: 2px;
  background: var(--accent);
  animation: busy-slide 1.1s ease-in-out infinite;
}
@keyframes busy-slide {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}

.device-prompt {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  background: #121a24;
  border-bottom: 1px solid var(--line);
}
.device-prompt input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: #0f1419;
  color: var(--text);
  font-size: 16px;
}

.feed {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.bubble {
  max-width: 85%;
  padding: 10px 12px;
  border-radius: 14px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}
.bubble.in {
  align-self: flex-start;
  background: var(--in);
  border-bottom-left-radius: 4px;
}
.bubble.out {
  align-self: flex-end;
  background: var(--out);
  border-bottom-right-radius: 4px;
}
.bubble.sys {
  align-self: center;
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  max-width: 95%;
}
.bubble img { max-width: 100%; border-radius: 8px; margin-top: 6px; display: block; }
.bubble a { color: #9fd0ff; }

.bottom {
  flex: 0 0 auto;
  background: var(--panel);
  border-top: 1px solid var(--line);
  padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
}

.toolbar {
  display: none;
}

.choice-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.choice-bar.hidden {
  display: none;
}
.choice-bar button {
  border: 0;
  background: #334155;
  color: #fff;
  border-radius: 16px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.9rem;
}

.composer {
  display: flex;
  gap: 8px;
}
.composer input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: #121a24;
  color: var(--text);
  font-size: 16px;
}
