:root {
  --bg0: #070908;
  --bg1: #121612;
  --ink: #e8f0e6;
  --muted: #8a9a86;
  --lime: #c8f531;
  --lime-dim: #7a9a20;
  --coral: #ff5c4d;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg0);
  color: var(--ink);
  font-family: Manrope, system-ui, sans-serif;
  overflow: hidden;
}

body {
  background:
    radial-gradient(120% 80% at 50% -10%, #1c2a14 0%, transparent 55%),
    radial-gradient(90% 60% at 100% 100%, #1a100c 0%, transparent 45%),
    linear-gradient(180deg, var(--bg1), var(--bg0));
}

#app {
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  padding: calc(20px + var(--safe-t)) 22px calc(28px + var(--safe-b));
}

/* —— Главная: только бренд —— */
#app[data-screen="home"] {
  display: grid;
  place-items: center;
}

#app[data-screen="home"] .room {
  display: none;
}

.brand-home {
  border: 0;
  padding: 0;
  background: none;
  color: inherit;
  cursor: pointer;
  font-family: Unbounded, sans-serif;
  font-weight: 700;
  font-size: clamp(2.6rem, 12vw, 3.8rem);
  letter-spacing: -0.04em;
  line-height: 0.92;
  text-align: center;
  animation: brandIn 0.7s ease both;
}

.brand-home span {
  color: var(--lime);
}

.brand-home:active {
  transform: scale(0.98);
}

@keyframes brandIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* —— Комната диалога —— */
#app[data-screen="room"] {
  display: block;
}

#app[data-screen="room"] .brand-home {
  display: none;
}

.room {
  min-height: calc(100dvh - var(--safe-t) - var(--safe-b) - 48px);
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 18px;
  animation: roomIn 0.35s ease both;
}

@keyframes roomIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.brand-mini {
  margin: 0;
  font-family: Unbounded, sans-serif;
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.brand-mini::after {
  content: "";
  display: inline-block;
  width: 0.45em;
  height: 0.45em;
  margin-left: 0.45em;
  border-radius: 50%;
  background: var(--lime);
  vertical-align: 0.1em;
}

.persona {
  display: inline-block;
  margin: 8px 0 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  cursor: pointer;
  font-family: Unbounded, sans-serif;
  font-weight: 500;
  font-size: clamp(1.35rem, 5.5vw, 1.75rem);
  letter-spacing: -0.02em;
  line-height: 1.1;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--lime) 55%, transparent);
  text-underline-offset: 0.22em;
  transition: color 0.15s ease, text-decoration-color 0.15s ease, transform 0.12s ease;
}

.persona:active {
  transform: scale(0.98);
}

.persona::after {
  content: " ⇄";
  opacity: 0.45;
  font-size: 0.85em;
  text-decoration: none;
}

.tag {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  max-width: 26ch;
}

#app[data-persona="sis"] {
  --lime: #ff7a6e;
  --lime-dim: #c45a50;
}

body:has(#app[data-persona="sis"][data-screen="room"]) {
  background:
    radial-gradient(120% 80% at 50% -10%, #2a1414 0%, transparent 55%),
    radial-gradient(90% 60% at 100% 100%, #1a100c 0%, transparent 45%),
    linear-gradient(180deg, #161212, #070908);
}

#app[data-persona="sis"] .ptt {
  background: radial-gradient(circle at 35% 30%, #ffb4ab, #ff7a6e 45%, #b23028 100%);
  color: #fff;
  box-shadow:
    0 0 0 10px rgba(255, 122, 110, 0.1),
    0 18px 40px rgba(0, 0, 0, 0.45);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.status i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--lime-dim);
}

#app[data-state="listening"] .status i {
  background: var(--coral);
  box-shadow: 0 0 12px var(--coral);
  animation: pulse 1s infinite;
}

#app[data-state="thinking"] .status i {
  background: var(--lime);
  animation: pulse 1.4s infinite;
}

#app[data-state="speaking"] .status i {
  background: var(--lime);
}

#app[data-state="error"] .status {
  color: var(--coral);
}

#app[data-state="error"] .status i {
  background: var(--coral);
}

@keyframes pulse {
  50% {
    opacity: 0.35;
    transform: scale(0.85);
  }
}

.feed {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 4px 2px 12px;
  mask-image: linear-gradient(180deg, transparent, #000 12px, #000 92%, transparent);
}

.line {
  max-width: 92%;
}

.line .who {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}

.line.me {
  align-self: flex-end;
  text-align: right;
}

.line.me .who {
  color: var(--lime-dim);
}

.line.bot .who {
  color: var(--lime);
}

.line p {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.35;
  font-weight: 600;
}

.dock {
  display: grid;
  justify-items: center;
  gap: 12px;
}

.hint {
  font-size: 0.85rem;
  color: var(--muted);
  min-height: 1.2em;
  transition: color 0.2s;
}

#app[data-state="listening"] .hint {
  color: var(--coral);
}

#app[data-state="thinking"] .hint,
#app[data-state="speaking"] .hint {
  color: var(--lime);
}

.ptt {
  --size: min(42vw, 168px);
  width: var(--size);
  height: var(--size);
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #e8ff7a, var(--lime) 45%, #8bb000 100%);
  color: #10140c;
  font-family: Unbounded, sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  box-shadow:
    0 0 0 10px rgba(200, 245, 49, 0.08),
    0 18px 40px rgba(0, 0, 0, 0.45);
  touch-action: none;
  user-select: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s;
}

.ptt:active,
#app[data-state="listening"] .ptt {
  transform: scale(0.94);
  filter: saturate(1.15);
  box-shadow:
    0 0 0 16px rgba(255, 92, 77, 0.12),
    0 10px 28px rgba(0, 0, 0, 0.5);
  background: radial-gradient(circle at 35% 30%, #ffb4ab, var(--coral) 55%, #b23028 100%);
  color: #fff;
}

#app[data-state="thinking"] .ptt,
#app[data-state="speaking"] .ptt {
  opacity: 0.55;
  pointer-events: none;
}

.reset,
.home-link {
  border: 0;
  background: none;
  color: var(--muted);
  font: 600 0.8rem Manrope, sans-serif;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 8px;
}

#login {
  display: none;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}

#app[data-screen="login"] {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

#app[data-screen="login"] #login {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#app[data-screen="login"] .brand-home,
#app[data-screen="login"] .room {
  display: none;
}

.login-title {
  margin: 0;
  font-family: Unbounded, sans-serif;
  font-weight: 700;
  font-size: clamp(2rem, 9vw, 2.8rem);
  letter-spacing: -0.04em;
  line-height: 0.95;
  text-align: center;
}

.login-title span {
  color: var(--lime);
}

.login-lead,
.install-note {
  margin: 0;
  color: var(--muted);
  text-align: center;
  font-size: 0.92rem;
  line-height: 1.35;
}

.code-input {
  width: 100%;
  border: 0;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  font: 700 2rem/1 Manrope, system-ui, sans-serif;
  letter-spacing: 0.22em;
  text-align: center;
  padding: 16px 8px;
}

.login-primary,
.login-secondary {
  display: block;
  width: 100%;
  text-align: center;
  text-decoration: none;
  border-radius: 999px;
  padding: 14px 18px;
  font: 700 0.95rem Manrope, system-ui, sans-serif;
}

.login-primary {
  border: 0;
  background: var(--lime);
  color: #10140c;
}

.login-secondary {
  border: 1px solid rgba(232, 240, 230, 0.16);
  color: var(--ink);
  background: transparent;
}

.login-error,
.error-banner {
  margin: 0;
  color: var(--coral);
  text-align: center;
  font-weight: 600;
}

.rec-timer {
  margin-left: 6px;
  font-variant-numeric: tabular-nums;
  color: var(--coral);
}

.install-panel {
  display: grid;
  gap: 8px;
  margin: 4px 0 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
}

.install-code {
  margin: 0;
  font: 700 2rem/1 Manrope, system-ui, sans-serif;
  letter-spacing: 0.28em;
  text-align: center;
  color: var(--lime);
}

.install-safari {
  color: var(--lime);
  text-align: center;
  font-size: 0.85rem;
}
