:root {
  --ink: #07080c;
  --ink-2: #0c0e15;
  --glass: rgba(255, 255, 255, 0.045);
  --glass-brd: rgba(255, 255, 255, 0.09);
  --txt: #eef1f7;
  --muted: #8d97ac;

  --cool: #2dd4bf;   /* русский — холодная бирюза */
  --cool-2: #38bdf8;
  --warm: #fbbf24;   /* собеседник — тёплый янтарь */
  --warm-2: #fb7185;
  --live: #34d399;
  --err: #fb7185;

  --r: 24px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--ink);
  color: var(--txt);
  font-family: "Manrope", -apple-system, BlinkMacSystemFont, sans-serif;
  overflow-x: hidden;
  position: relative;
  min-height: 100dvh;
}

/* ---------- атмосфера ---------- */
.aurora { position: fixed; inset: 0; z-index: -2; overflow: hidden; filter: blur(70px); opacity: 0.85; }
.blob { position: absolute; width: 70vmax; height: 70vmax; border-radius: 50%; mix-blend-mode: screen; }
.blob--teal  { background: radial-gradient(circle at 30% 30%, #14b8a6, transparent 60%); top: -25vmax; left: -20vmax; animation: drift1 22s ease-in-out infinite; }
.blob--amber { background: radial-gradient(circle at 50% 50%, #f59e0b, transparent 60%); bottom: -30vmax; right: -25vmax; animation: drift2 26s ease-in-out infinite; }
.blob--violet{ background: radial-gradient(circle at 50% 50%, #6366f1, transparent 62%); top: 30%; left: 20%; opacity: 0.5; animation: drift3 30s ease-in-out infinite; }
@keyframes drift1 { 0%,100%{transform:translate(0,0) scale(1)} 50%{transform:translate(8vmax,6vmax) scale(1.15)} }
@keyframes drift2 { 0%,100%{transform:translate(0,0) scale(1.05)} 50%{transform:translate(-7vmax,-5vmax) scale(0.9)} }
@keyframes drift3 { 0%,100%{transform:translate(0,0)} 50%{transform:translate(-6vmax,8vmax)} }

.grain {
  position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- каркас ---------- */
.shell {
  max-width: 480px; margin: 0 auto; min-height: 100dvh;
  display: flex; flex-direction: column;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 18px calc(var(--safe-b) + 16px);
  animation: rise 0.6s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------- топбар ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; }
.wordmark {
  font-family: "Bricolage Grotesque", sans-serif; font-weight: 800; font-size: 21px;
  letter-spacing: -0.02em; display: flex; align-items: center; gap: 9px;
}
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); transition: background .3s, box-shadow .3s; }
.dot.is-live { background: var(--live); box-shadow: 0 0 0 4px rgba(52,211,153,.18); }
.dot.is-err  { background: var(--err); box-shadow: 0 0 0 4px rgba(251,113,133,.18); }
.dot.is-wait { background: var(--warm); box-shadow: 0 0 0 4px rgba(251,191,36,.18); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .35; } }

.ghost-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--glass); border: 1px solid var(--glass-brd); color: var(--txt);
  font-family: inherit; font-size: 13px; font-weight: 600;
  padding: 9px 13px; border-radius: 999px; cursor: pointer;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  transition: transform .12s, background .2s;
}
.ghost-btn:active { transform: scale(.94); background: rgba(255,255,255,.09); }

/* ---------- пара языков ---------- */
.pair {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  margin: 22px 0 14px; font-family: "Bricolage Grotesque", sans-serif;
}
.pair__me, .pair__them {
  font-weight: 700; font-size: 30px; letter-spacing: -0.02em;
  background-clip: text; -webkit-background-clip: text; color: transparent;
}
.pair__me   { background-image: linear-gradient(120deg, var(--cool), var(--cool-2)); }
.pair__them { background-image: linear-gradient(120deg, var(--warm), var(--warm-2)); }
.pair__swap { color: var(--muted); font-size: 20px; }

/* ---------- чипсы языков ---------- */
.langs {
  display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
}
.langs::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; scroll-snap-align: start;
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  background: var(--glass); border: 1px solid var(--glass-brd); color: var(--muted);
  font-family: inherit; font-size: 14px; font-weight: 600;
  padding: 10px 15px; border-radius: 999px; cursor: pointer;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  transition: transform .12s, color .2s, border-color .2s, background .2s;
}
.chip span { font-size: 17px; }
.chip:active { transform: scale(.95); }
.chip.is-active {
  color: #07120f;
  background: linear-gradient(120deg, var(--warm), var(--warm-2));
  border-color: transparent;
  box-shadow: 0 8px 26px rgba(251,191,36,.28);
}

/* ---------- сегмент режима ---------- */
.seg {
  position: relative; display: grid; grid-template-columns: 1fr 1fr;
  margin: 18px auto 0; width: 220px; padding: 5px;
  background: var(--glass); border: 1px solid var(--glass-brd); border-radius: 999px;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.seg__pill {
  position: absolute; top: 5px; left: 5px; width: calc(50% - 5px); height: calc(100% - 10px);
  border-radius: 999px; background: linear-gradient(120deg, var(--cool), var(--cool-2));
  box-shadow: 0 6px 20px rgba(45,212,191,.3);
  transition: transform .32s cubic-bezier(.2,.9,.2,1);
}
.seg.auto .seg__pill { transform: translateX(100%); }
.seg__opt {
  position: relative; z-index: 1; background: none; border: 0; cursor: pointer;
  font-family: inherit; font-size: 14px; font-weight: 700; color: var(--muted);
  padding: 9px 0; transition: color .25s;
}
.seg__opt.is-active { color: #04140f; }

/* ---------- сцена с орбом ---------- */
.stage {
  flex: 0 0 auto; display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 26px 0 6px; gap: 14px;
}
.orb {
  position: relative; width: 184px; height: 184px; border: 0; background: none;
  cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none; display: grid; place-items: center;
}
.orb__core {
  width: 158px; height: 158px; border-radius: 50%; display: grid; place-items: center;
  color: #04140f;
  background:
    radial-gradient(circle at 35% 28%, rgba(255,255,255,.55), transparent 45%),
    linear-gradient(150deg, var(--cool) 0%, var(--cool-2) 55%, #6366f1 120%);
  box-shadow:
    inset 0 2px 8px rgba(255,255,255,.4),
    inset 0 -10px 24px rgba(0,0,0,.28),
    0 22px 60px rgba(45,212,191,.4);
  transition: transform .18s cubic-bezier(.2,.9,.2,1), box-shadow .25s, background .3s;
}
.orb__ring {
  position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--cool);
  opacity: 0; pointer-events: none;
}
/* нажат — пульсация */
.orb.is-talking .orb__core { transform: scale(.92); }
.orb.is-talking .orb__ring  { animation: pulse 1.4s ease-out infinite; }
.orb.is-talking .orb__ring--2 { animation: pulse 1.4s ease-out .7s infinite; }
@keyframes pulse { 0% { opacity: .55; transform: scale(.86); } 100% { opacity: 0; transform: scale(1.35); } }

/* говорит ассистент — тёплое свечение */
.orb.is-speaking .orb__core {
  background:
    radial-gradient(circle at 35% 28%, rgba(255,255,255,.55), transparent 45%),
    linear-gradient(150deg, var(--warm) 0%, var(--warm-2) 90%);
  box-shadow: inset 0 2px 8px rgba(255,255,255,.4), inset 0 -10px 24px rgba(0,0,0,.28), 0 22px 60px rgba(251,191,36,.45);
  animation: breathe 1.6s ease-in-out infinite;
}
@keyframes breathe { 50% { transform: scale(1.05); } }
.orb:active .orb__core { transform: scale(.92); }
.orb.is-busy { opacity: .55; pointer-events: none; }

.orb__hint { font-size: 13.5px; font-weight: 600; color: var(--muted); letter-spacing: .01em; }

/* ---------- статус ---------- */
.status {
  text-align: center; font-size: 12.5px; font-weight: 600; color: var(--muted);
  min-height: 18px; margin: 4px 0 2px; transition: color .25s;
}
.status.is-err { color: var(--err); }
.status.is-live { color: var(--live); }

/* ---------- диалог ---------- */
.transcript {
  flex: 1 1 auto; overflow-y: auto; margin-top: 12px; padding: 4px 2px 8px;
  display: flex; flex-direction: column; gap: 10px;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 18px);
  mask-image: linear-gradient(to bottom, transparent 0, #000 18px);
}
.transcript::-webkit-scrollbar { display: none; }
.empty { margin: auto 0; text-align: center; color: var(--muted); font-size: 14px; line-height: 1.6; opacity: .8; }

.bubble {
  max-width: 84%; padding: 12px 15px; border-radius: 20px; font-size: 16px; line-height: 1.42;
  border: 1px solid var(--glass-brd); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  animation: pop .26s cubic-bezier(.2,.9,.2,1) both; word-wrap: break-word;
}
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.bubble .tag { display: block; font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 4px; opacity: .8; }
.bubble.ru {
  align-self: flex-end; border-bottom-right-radius: 7px;
  background: linear-gradient(160deg, rgba(45,212,191,.18), rgba(56,189,248,.1));
  border-color: rgba(45,212,191,.35);
}
.bubble.ru .tag { color: var(--cool); }
.bubble.them {
  align-self: flex-start; border-bottom-left-radius: 7px;
  background: linear-gradient(160deg, rgba(251,191,36,.16), rgba(251,113,133,.1));
  border-color: rgba(251,191,36,.32);
}
.bubble.them .tag { color: var(--warm); }
.bubble.partial { opacity: .6; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
