/* ══════════════════════════════════════════════
   НЕЙРО-ДРУГ · Global Styles
   ══════════════════════════════════════════════ */

:root {
  --c-mint:      #a8d8c4;
  --c-aqua:      #7bc8c8;
  --c-teal:      #4a9e9a;
  --c-deep:      #1e4a52;
  --c-night:     #0a1e24;
  --c-highlight: #c8f0e8;
  --c-cream:     #e8f5f2;
  --c-whisper:   rgba(232, 245, 242, 0.6);
  --font-display: 'Fraunces', serif;
  --font-body:    'Manrope', sans-serif;
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* Hebrew font stack */
html[lang="he"] {
  font-family: "SBL Hebrew", "Frank Ruehl CLM", "David CLM", 'Manrope', sans-serif;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%; overflow: hidden; overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none; -webkit-user-select: none;
  font-family: var(--font-body); color: var(--c-cream);
}
body {
  background: var(--c-night);
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}
button {
  font-family: inherit; border: none; outline: none;
  cursor: pointer; background: none; color: inherit;
}
button:focus-visible,
a:focus-visible { outline: 2px solid var(--c-mint); outline-offset: 2px; border-radius: 4px; }

/* ── Screen root ── */
#screen-root { position: relative; z-index: 10; height: 100%; }


/* ══════════════════════════════════════════════
   BACKGROUND LAYERS (shared, fixed)
   ══════════════════════════════════════════════ */

.bg-base {
  position: fixed; inset: 0; z-index: 0;
  background: linear-gradient(180deg, #1a3d44 0%, #2a5c5c 35%, #3d7878 65%, #0a1e24 100%);
}
.bg-aurora {
  position: fixed; inset: -20%; z-index: 1;
  filter: blur(80px); opacity: 0.55;
  animation: aurora-drift 24s ease-in-out infinite;
}
.bg-aurora::before, .bg-aurora::after { content: ''; position: absolute; border-radius: 50%; }
.bg-aurora::before {
  width: 60%; height: 60%; top: 10%; left: 5%;
  background: radial-gradient(circle, var(--c-mint) 0%, transparent 70%);
  animation: blob-1 28s ease-in-out infinite;
}
.bg-aurora::after {
  width: 50%; height: 50%; bottom: 15%; right: 8%;
  background: radial-gradient(circle, var(--c-aqua) 0%, transparent 70%);
  animation: blob-2 32s ease-in-out infinite;
}
.bg-aurora-2 { position: fixed; inset: -10%; z-index: 1; filter: blur(100px); opacity: 0.35; }
.bg-aurora-2::before {
  content: ''; position: absolute;
  width: 45%; height: 45%; top: 40%; left: 50%;
  background: radial-gradient(circle, var(--c-highlight) 0%, transparent 70%);
  border-radius: 50%;
  animation: blob-3 36s ease-in-out infinite;
}
.particles { position: fixed; inset: 0; z-index: 2; pointer-events: none; overflow: hidden; }
.particle {
  position: absolute; background: var(--c-cream); border-radius: 50%;
  box-shadow: 0 0 6px var(--c-cream);
  animation: float-up linear infinite;
}
.grain {
  position: fixed; inset: 0; z-index: 3;
  pointer-events: none; opacity: 0.08; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%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");
}

/* ── Background animations ── */
@keyframes aurora-drift {
  0%, 100% { transform: translate(0,0) scale(1); }
  33%  { transform: translate(5%,-3%) scale(1.05); }
  66%  { transform: translate(-3%,4%) scale(0.98); }
}
@keyframes blob-1 {
  0%, 100% { transform: translate(0,0) scale(1); opacity: 0.7; }
  50% { transform: translate(10%,15%) scale(1.2); opacity: 0.9; }
}
@keyframes blob-2 {
  0%, 100% { transform: translate(0,0) scale(1); opacity: 0.6; }
  50% { transform: translate(-8%,-12%) scale(1.15); opacity: 0.85; }
}
@keyframes blob-3 {
  0%, 100% { transform: translate(-50%,0) scale(1); opacity: 0.5; }
  50% { transform: translate(-40%,-20%) scale(1.3); opacity: 0.8; }
}
@keyframes float-up {
  0%   { transform: translateY(100vh) translateX(0); opacity: 0; }
  10%  { opacity: 0.8; }
  90%  { opacity: 0.4; }
  100% { transform: translateY(-10vh) translateX(var(--drift, 20px)); opacity: 0; }
}

/* ── Common animation keyframes ── */
@keyframes fd {
  0%   { opacity: 0; transform: translateY(-12px); }
  100% { opacity: 1; transform: translateY(0); }
}
@keyframes fu {
  0%   { opacity: 0; transform: translateY(12px); }
  100% { opacity: 1; transform: translateY(0); }
}
@keyframes scale-in {
  0%   { opacity: 0; transform: scale(0.8); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes dot-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes msg-in {
  0%   { opacity: 0; transform: translateY(12px); }
  100% { opacity: 1; transform: translateY(0); }
}


/* ══════════════════════════════════════════════
   PRE-JOIN SCREEN
   ══════════════════════════════════════════════ */

.screen-prejoin {
  height: 100%; display: flex; flex-direction: column; overflow: hidden;
}

.pj-header {
  padding: 40px 24px 16px;
  text-align: center; flex-shrink: 0;
  opacity: 0; animation: fd 0.8s 0.2s forwards;
}
.pj-title {
  font-family: var(--font-display);
  font-style: italic; font-weight: 400;
  font-size: 30px; letter-spacing: -0.02em; margin-bottom: 4px;
}
html[lang="he"] .pj-title { font-style: normal; }
.pj-subtitle {
  font-size: 12px; color: var(--c-whisper);
  font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase;
}

.pj-body {
  flex: 1; overflow-y: auto;
  padding: 8px 20px 140px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  opacity: 0; animation: fu 0.8s 0.4s forwards;
}

.pj-section { margin-bottom: 22px; }
.pj-section-label {
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--c-whisper); margin-bottom: 10px;
}

/* Segmented language control */
.seg-control {
  display: flex;
  background: rgba(232, 245, 242, 0.06);
  border: 1px solid rgba(232, 245, 242, 0.1);
  border-radius: 16px; padding: 4px; gap: 4px;
}
.seg-btn {
  flex: 1; min-height: 44px; padding: 10px 8px;
  border-radius: 12px; color: var(--c-whisper);
  font-size: 14px; font-weight: 500;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: all 0.2s ease; touch-action: manipulation;
}
.seg-btn:active, .seg-btn.is-pressed { transform: scale(0.97); }
.seg-btn[aria-pressed="true"] {
  background: rgba(168, 216, 196, 0.2);
  border: 1px solid rgba(168, 216, 196, 0.4);
  color: var(--c-cream);
}
.seg-btn:focus-visible { outline: 2px solid var(--c-mint); outline-offset: 2px; }

/* Voice grid 2×3 */
.voice-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.voice-card {
  position: relative;
  padding: 14px 12px 12px;
  background: rgba(232, 245, 242, 0.05);
  border: 1px solid rgba(232, 245, 242, 0.1);
  border-radius: 18px; cursor: pointer;
  transition: all 0.2s ease;
  min-height: 90px;
  display: flex; flex-direction: column; gap: 8px;
  text-align: start; width: 100%; touch-action: manipulation;
}
.voice-card:hover { background: rgba(168, 216, 196, 0.08); }
.voice-card:active, .voice-card.is-pressed { transform: scale(0.98); background: rgba(168, 216, 196, 0.12); }
.voice-card[aria-pressed="true"] {
  background: rgba(168, 216, 196, 0.18);
  border-color: rgba(168, 216, 196, 0.45);
  box-shadow: 0 0 0 1px rgba(168, 216, 196, 0.25);
}
.voice-card:focus-visible { outline: 2px solid var(--c-mint); outline-offset: 2px; }

.vc-top { display: flex; align-items: center; justify-content: space-between; }
.vc-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  font: 700 12px/1 var(--font-body); flex-shrink: 0;
}
.vc-avatar.g-m { background: linear-gradient(135deg, var(--c-aqua), var(--c-teal)); color: var(--c-cream); }
.vc-avatar.g-f { background: linear-gradient(135deg, var(--c-mint), var(--c-highlight)); color: var(--c-deep); }

.vc-play {
  width: 32px; height: 32px; min-width: 32px; border-radius: 50%;
  border: 1px solid rgba(168, 216, 196, 0.3);
  background: rgba(168, 216, 196, 0.08);
  color: var(--c-mint); display: grid; place-items: center;
  transition: all 0.2s ease; flex-shrink: 0;
}
.vc-play:hover { background: rgba(168, 216, 196, 0.2); }
.vc-play:active, .vc-play.is-pressed { transform: scale(0.88); }
.vc-play svg { width: 10px; height: 10px; fill: currentColor; }
html[dir="rtl"] .vc-play .icon-play { transform: scaleX(-1); }
.vc-play.is-playing { background: var(--c-mint); border-color: var(--c-mint); color: var(--c-deep); }
.vc-play.is-playing .icon-play { display: none; }
.vc-play:not(.is-playing) .icon-wave { display: none; }

.vc-name {
  font-family: var(--font-display); font-style: italic; font-weight: 400;
  font-size: 15px; color: var(--c-cream);
}
html[lang="he"] .vc-name { font-style: normal; }
.vc-desc { font-size: 11px; color: var(--c-whisper); line-height: 1.3; }

.vc-check {
  position: absolute; top: 8px; inset-inline-end: 8px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--c-mint); color: var(--c-deep);
  display: none; place-items: center;
}
.voice-card[aria-pressed="true"] .vc-check { display: grid; }
.vc-check svg { width: 10px; height: 10px; }

/* Wave bars (shared) */
.wave-bars { display: flex; align-items: center; gap: 2px; height: 12px; }
.wave-bars span {
  width: 2px; background: currentColor; border-radius: 1px;
  animation: wave 0.9s ease-in-out infinite;
}
.wave-bars span:nth-child(1) { height: 40%; }
.wave-bars span:nth-child(2) { height: 75%; animation-delay: 0.1s; }
.wave-bars span:nth-child(3) { height: 100%; animation-delay: 0.2s; }
.wave-bars span:nth-child(4) { height: 60%; animation-delay: 0.3s; }
@keyframes wave { 0%, 100% { transform: scaleY(0.4); } 50% { transform: scaleY(1); } }

/* Sticky CTA */
.pj-footer {
  position: fixed; bottom: 0; inset-inline: 0;
  padding: 16px 20px calc(16px + var(--safe-bottom));
  background: linear-gradient(180deg, transparent 0%, rgba(10,30,36,0.95) 35%);
  z-index: 20; pointer-events: none;
}
.pj-cta {
  width: 100%; min-height: 56px;
  background: linear-gradient(135deg, var(--c-teal), var(--c-deep));
  border: 1px solid rgba(94, 179, 176, 0.5);
  border-radius: 18px; color: var(--c-cream);
  font-size: 16px; font-weight: 600; letter-spacing: 0.01em;
  box-shadow: 0 8px 24px rgba(42, 92, 92, 0.5);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto; touch-action: manipulation;
  opacity: 0; animation: fu 0.8s 0.6s forwards;
}
.pj-cta:hover { filter: brightness(1.08); }
.pj-cta:active, .pj-cta.is-pressed { transform: scale(0.98); }
.pj-cta:focus-visible { outline: 2px solid var(--c-mint); outline-offset: 3px; }


/* ══════════════════════════════════════════════
   WARM ROOM SCREEN
   ══════════════════════════════════════════════ */

.screen-warmroom { height: 100%; display: flex; flex-direction: column; }

/* Connect state (before user taps "Начать") */
.screen-warmroom.screen-connect {
  justify-content: flex-start; align-items: stretch;
}
.connect-scroll {
  flex: 1; overflow-y: auto;
  padding-bottom: 120px;
  display: flex; flex-direction: column;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.connect-wrap {
  flex: 0 0 auto; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px; padding: 40px 24px 20px;
  opacity: 0; animation: fd 0.8s 0.2s forwards;
}
.connect-orb {
  position: relative; width: 120px; height: 120px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 8px;
}
.connect-title {
  font-family: var(--font-display); font-style: italic; font-weight: 400;
  font-size: 30px; letter-spacing: -0.02em; text-align: center;
}
html[lang="he"] .connect-title { font-style: normal; }
.connect-sub {
  font-size: 12px; color: var(--c-whisper);
  font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase;
  text-align: center;
}

/* Device selection */
.device-settings {
  padding: 8px 20px;
  display: flex; flex-direction: column; gap: 12px;
  opacity: 0; animation: fu 0.6s 0.5s forwards;
}
.device-row { display: flex; flex-direction: column; gap: 6px; }
.device-label {
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--c-whisper);
}
.device-select {
  width: 100%; padding: 12px 36px 12px 14px;
  background: rgba(232, 245, 242, 0.06);
  border: 1px solid rgba(232, 245, 242, 0.1);
  border-radius: 14px; color: var(--c-cream);
  font-size: 14px; font-weight: 500; font-family: var(--font-body);
  -webkit-appearance: none; appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='rgba(232%2C245%2C242%2C0.5)' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
  transition: border-color 0.2s;
}
.device-select:focus { outline: none; border-color: rgba(168, 216, 196, 0.4); }
.device-select option { background: #1a3d44; color: var(--c-cream); }

/* Header */
.header {
  padding: 16px 20px 0;
  display: flex; justify-content: space-between; align-items: center;
  flex-shrink: 0;
  opacity: 0; animation: fd 0.8s 0.2s forwards;
}
.pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  background: rgba(232, 245, 242, 0.08);
  border: 1px solid rgba(232, 245, 242, 0.12);
  backdrop-filter: blur(12px); border-radius: 100px;
  font-size: 12px; font-weight: 500;
}
.dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--c-mint); box-shadow: 0 0 8px var(--c-mint);
  animation: dot-pulse 2s ease-in-out infinite;
}
.header-right { display: flex; gap: 10px; align-items: center; }
.timer {
  font-family: var(--font-display); font-weight: 300; font-size: 14px;
  color: var(--c-whisper); font-variant-numeric: tabular-nums;
}
.history-btn {
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid rgba(232, 245, 242, 0.12);
  background: rgba(232, 245, 242, 0.08);
  backdrop-filter: blur(12px); color: var(--c-cream);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.2s ease; position: relative;
  touch-action: manipulation;
}
.history-btn:active, .history-btn.is-pressed { transform: scale(0.92); }
.history-btn svg { width: 16px; height: 16px; }
.history-btn:focus-visible { outline: 2px solid var(--c-mint); outline-offset: 2px; }
.history-btn .badge {
  position: absolute; top: -2px; inset-inline-end: -2px;
  min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--c-mint); color: var(--c-night);
  border-radius: 100px; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

/* Orb area */
.presence {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 0 20px; position: relative; min-height: 0;
}
.orb-box {
  position: relative;
  width: min(220px, 55vw); aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  opacity: 0; animation: scale-in 1.4s 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.halo { position: absolute; inset: 0; border-radius: 50%; pointer-events: none; }
.h1 {
  background: radial-gradient(circle, rgba(168,216,196,0.35) 0%, transparent 70%);
  animation: breathe 10s ease-in-out infinite; transform: scale(1.3);
}
.h2 {
  background: radial-gradient(circle, rgba(123,200,200,0.22) 0%, transparent 65%);
  animation: breathe 10s ease-in-out reverse infinite; transform: scale(1.5);
}
.h3 { border: 1px solid rgba(232,245,242,0.10); animation: ring 6s ease-in-out infinite; }
.h4 { border: 1px solid rgba(232,245,242,0.06); animation: ring 6s ease-in-out 1.5s infinite; }
@keyframes breathe {
  0%, 100% { opacity: 0.35; transform: scale(1.3); }
  50%       { opacity: 0.65; transform: scale(1.42); }
}
@keyframes ring {
  0%   { transform: scale(1.0); opacity: 0.5; }
  100% { transform: scale(1.7); opacity: 0; }
}
.orb {
  position: relative; width: 70%; height: 70%; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--c-mint) 0%, var(--c-aqua) 40%, var(--c-teal) 85%, var(--c-deep) 100%);
  box-shadow:
    inset 0 0 60px rgba(255,255,255,0.2),
    inset -20px -20px 50px rgba(30,74,82,0.5),
    0 20px 60px rgba(0,0,0,0.4),
    0 0 80px rgba(168,216,196,0.4);
  animation: orb-breathe 7s ease-in-out infinite; overflow: hidden;
}
.orb::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(circle at 70% 70%, transparent 40%, rgba(30,74,82,0.4) 100%);
  mix-blend-mode: multiply; animation: swirl 12s ease-in-out infinite;
}
.orb::after {
  content: ''; position: absolute;
  top: 20%; left: 25%; width: 30%; height: 25%;
  background: radial-gradient(ellipse, rgba(255,255,255,0.6) 0%, transparent 70%);
  filter: blur(4px); animation: hi-shift 9s ease-in-out infinite;
}
@keyframes orb-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.025); } }
@keyframes swirl { 0%, 100% { transform: rotate(0) scale(1); } 50% { transform: rotate(180deg) scale(1.08); } }
@keyframes hi-shift { 0%, 100% { opacity: 0.5; transform: translate(0,0); } 50% { opacity: 0.8; transform: translate(-8%,4%); } }
/* CSS fallback when Web Audio analyser isn't available */
.orb.speaking { animation: orb-speak-fallback 1.4s ease-in-out infinite; }
.orb-box.speaking .h1 { animation: breathe-speak 1.4s ease-in-out infinite; }
@keyframes orb-speak-fallback { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@keyframes breathe-speak {
  0%, 100% { opacity: 0.45; transform: scale(1.3); }
  50%       { opacity: 0.80; transform: scale(1.48); }
}

.state-label {
  margin-top: 20px; text-align: center;
  font-size: 13px; color: var(--c-whisper);
  letter-spacing: 0.02em; transition: opacity 0.4s ease;
  min-height: 18px;
  opacity: 0; animation: fu 0.8s 0.8s forwards;
}
[aria-live] { speak: always; }

/* Message stream */
.message-stream {
  position: relative; width: 100%; max-width: 480px;
  margin: 20px auto 0; height: 180px; overflow: hidden;
  mask-image: linear-gradient(180deg, transparent 0%, black 20%, black 85%, transparent 100%);
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, black 20%, black 85%, transparent 100%);
}
.messages-inner {
  position: absolute; bottom: 0; left: 0; right: 0;
  display: flex; flex-direction: column; gap: 10px;
  padding: 20px 8px;
}
.msg {
  max-width: 85%; padding: 10px 14px;
  border-radius: 18px; font-size: 14px; line-height: 1.45;
  opacity: 0; animation: msg-in 0.6s cubic-bezier(0.16,1,0.3,1) forwards;
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.msg.assistant {
  align-self: flex-start;
  background: rgba(168,216,196,0.15);
  border: 1px solid rgba(168,216,196,0.25);
  border-bottom-left-radius: 6px;
  font-family: var(--font-display); font-style: italic; font-weight: 400;
}
html[dir="rtl"] .msg.assistant {
  align-self: flex-end;
  border-bottom-left-radius: 18px; border-bottom-right-radius: 6px;
}
.msg.user {
  align-self: flex-end;
  background: rgba(232,245,242,0.14);
  border: 1px solid rgba(232,245,242,0.1);
  border-bottom-right-radius: 6px;
}
html[dir="rtl"] .msg.user {
  align-self: flex-start;
  border-bottom-right-radius: 18px; border-bottom-left-radius: 6px;
}
.msg.typing {
  display: inline-flex; gap: 4px; padding: 14px 16px;
  align-self: flex-start;
  background: rgba(168,216,196,0.15); border: 1px solid rgba(168,216,196,0.25);
  border-radius: 18px; border-bottom-left-radius: 6px; opacity: 1;
}
html[dir="rtl"] .msg.typing { align-self: flex-end; border-bottom-left-radius: 18px; border-bottom-right-radius: 6px; }
.msg.typing span {
  width: 6px; height: 6px; background: var(--c-cream); border-radius: 50%;
  opacity: 0.4; animation: typing-dot 1.2s ease-in-out infinite;
}
.msg.typing span:nth-child(2) { animation-delay: 0.2s; }
.msg.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-dot {
  0%, 100% { opacity: 0.3; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-3px); }
}

/* Controls board */
.controls {
  padding: 20px 16px calc(24px + var(--safe-bottom));
  display: flex; justify-content: center; align-items: center; gap: 14px;
  flex-shrink: 0;
  opacity: 0; animation: fu 0.8s 1s forwards;
}
.controls--single { gap: 0; }
.ctrl {
  position: relative;
  width: 56px; height: 56px; border-radius: 50%;
  border: 1px solid rgba(232,245,242,0.15);
  background: rgba(232,245,242,0.06);
  backdrop-filter: blur(20px); color: var(--c-cream);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16,1,0.3,1);
  touch-action: manipulation; flex-shrink: 0;
}
.ctrl:hover { background: rgba(232,245,242,0.1); }
.ctrl:active, .ctrl.is-pressed { transform: scale(0.92); background: rgba(232,245,242,0.14); }
.ctrl.active { background: rgba(123,200,200,0.3); border-color: rgba(123,200,200,0.5); }
.ctrl.danger {
  width: 68px; height: 68px;
  background: linear-gradient(135deg, #5eb3b0, #2a5c5c);
  border-color: rgba(94,179,176,0.5);
  box-shadow: 0 8px 24px rgba(42,92,92,0.5);
}
.ctrl svg { width: 22px; height: 22px; }
.ctrl.danger svg { width: 26px; height: 26px; }
.ctrl:focus-visible { outline: 2px solid var(--c-mint); outline-offset: 3px; }

.ctrl-chip {
  position: absolute; bottom: -4px; inset-inline-end: -4px;
  min-width: 22px; height: 18px; padding: 0 6px;
  background: var(--c-mint); color: var(--c-night);
  border-radius: 100px; font-size: 10px; font-weight: 700;
  letter-spacing: 0.04em;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--c-night); pointer-events: none;
}


/* ══════════════════════════════════════════════
   BOTTOM SHEETS (shared)
   ══════════════════════════════════════════════ */

.sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(10,30,36,0); z-index: 100; pointer-events: none;
  transition: background 0.35s ease, backdrop-filter 0.35s ease;
  backdrop-filter: blur(0px); -webkit-backdrop-filter: blur(0px);
}
.sheet-backdrop.open {
  background: rgba(10,30,36,0.55); pointer-events: auto;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0;
  max-height: 88vh;
  background: linear-gradient(180deg, #123035 0%, #0a1e24 100%);
  border-radius: 28px 28px 0 0; z-index: 101;
  transform: translateY(100%);
  transition: transform 0.45s cubic-bezier(0.32,0.72,0.27,1);
  display: flex; flex-direction: column;
  box-shadow: 0 -20px 60px rgba(0,0,0,0.5);
  padding-bottom: var(--safe-bottom);
}
.sheet.open { transform: translateY(0); }
.sheet-handle {
  width: 36px; height: 4px;
  background: rgba(232,245,242,0.2);
  border-radius: 100px; margin: 10px auto 0; flex-shrink: 0;
}
.sheet-header {
  padding: 16px 24px 14px;
  display: flex; justify-content: space-between; align-items: baseline;
  border-bottom: 1px solid rgba(232,245,242,0.08); flex-shrink: 0;
}
.sheet-title {
  font-family: var(--font-display); font-style: italic; font-weight: 400;
  font-size: 22px; letter-spacing: -0.01em;
}
html[lang="he"] .sheet-title { font-style: normal; }
.sheet-meta {
  font-size: 11px; color: var(--c-whisper);
  font-weight: 500; letter-spacing: 0.05em;
  text-transform: uppercase; font-variant-numeric: tabular-nums;
}
.sheet-body {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch; padding: 20px 20px 32px;
}

/* History list */
.history-list { display: flex; flex-direction: column; gap: 14px; }
.h-msg { display: flex; flex-direction: column; gap: 4px; max-width: 86%; }
.h-msg.assistant { align-self: flex-start; }
.h-msg.user { align-self: flex-end; align-items: flex-end; }
html[dir="rtl"] .h-msg.assistant { align-self: flex-end; align-items: flex-end; }
html[dir="rtl"] .h-msg.user { align-self: flex-start; align-items: flex-start; }
.h-msg-bubble { padding: 10px 14px; border-radius: 18px; font-size: 15px; line-height: 1.5; }
.h-msg.assistant .h-msg-bubble {
  background: rgba(168,216,196,0.12); border: 1px solid rgba(168,216,196,0.2);
  border-bottom-left-radius: 6px;
  font-family: var(--font-display); font-style: italic; font-weight: 400;
}
html[dir="rtl"] .h-msg.assistant .h-msg-bubble { border-bottom-left-radius: 18px; border-bottom-right-radius: 6px; }
.h-msg.user .h-msg-bubble { background: rgba(232,245,242,0.12); border-bottom-right-radius: 6px; }
html[dir="rtl"] .h-msg.user .h-msg-bubble { border-bottom-right-radius: 18px; border-bottom-left-radius: 6px; }
.h-msg-meta {
  font-size: 10px; color: rgba(232,245,242,0.35);
  padding: 0 6px; letter-spacing: 0.03em; font-variant-numeric: tabular-nums;
}
.sheet-empty {
  text-align: center; padding: 48px 20px; color: var(--c-whisper);
  font-family: var(--font-display); font-style: italic; font-size: 16px;
}
.sheet-divider {
  text-align: center; margin: 8px 0;
  font-size: 10px; color: rgba(232,245,242,0.3);
  letter-spacing: 0.15em; text-transform: uppercase; font-weight: 600;
}

/* Option list (lang / voice sheets) */
.opt-list { display: flex; flex-direction: column; gap: 8px; padding: 4px 0; }
.opt {
  position: relative; display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; min-height: 60px;
  background: rgba(232,245,242,0.05); border: 1px solid rgba(232,245,242,0.1);
  border-radius: 18px; color: var(--c-cream);
  cursor: pointer; transition: all 0.2s ease;
  text-align: start; width: 100%; touch-action: manipulation;
}
.opt:hover { background: rgba(168,216,196,0.08); border-color: rgba(168,216,196,0.2); }
.opt:active, .opt.is-pressed { transform: scale(0.99); background: rgba(168,216,196,0.12); }
.opt[aria-pressed="true"] {
  background: rgba(168,216,196,0.18); border-color: rgba(168,216,196,0.45);
  box-shadow: 0 0 0 1px rgba(168,216,196,0.25);
}
.opt:focus-visible { outline: 2px solid var(--c-mint); outline-offset: 2px; }
.opt-flag {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; font-size: 22px;
  background: rgba(232,245,242,0.08); flex-shrink: 0;
}
.opt-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  font: 700 13px/1 var(--font-body); flex-shrink: 0; letter-spacing: 0.02em;
}
.opt-avatar.g-m { background: linear-gradient(135deg, var(--c-aqua), var(--c-teal)); color: var(--c-cream); }
.opt-avatar.g-f { background: linear-gradient(135deg, var(--c-mint), var(--c-highlight)); color: var(--c-deep); }
.opt-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.opt-name {
  font-family: var(--font-display); font-style: italic; font-weight: 400;
  font-size: 17px; line-height: 1.2; color: var(--c-cream); letter-spacing: -0.005em;
}
html[lang="he"] .opt-name { font-style: normal; }
.opt-desc { font-size: 12.5px; line-height: 1.35; color: var(--c-whisper); }
.opt-play {
  width: 40px; height: 40px; min-width: 40px; border-radius: 50%;
  border: 1px solid rgba(168,216,196,0.3); background: rgba(168,216,196,0.1);
  color: var(--c-mint); display: grid; place-items: center;
  cursor: pointer; flex-shrink: 0; transition: all 0.2s ease;
}
.opt-play:hover { background: rgba(168,216,196,0.2); border-color: rgba(168,216,196,0.5); }
.opt-play:active, .opt-play.is-pressed { transform: scale(0.9); }
.opt-play svg { width: 12px; height: 12px; fill: currentColor; }
html[dir="rtl"] .opt-play .icon-play { transform: scaleX(-1); }
.opt-play.is-playing { background: var(--c-mint); border-color: var(--c-mint); color: var(--c-deep); }
.opt-play.is-playing .icon-play { display: none; }
.opt-play:not(.is-playing) .icon-wave { display: none; }
.opt-check {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--c-mint); color: var(--c-deep);
  display: none; place-items: center; flex-shrink: 0;
}
.opt[aria-pressed="true"] .opt-check { display: grid; }
.opt-check svg { width: 12px; height: 12px; }

/* Toast */
.toast {
  position: fixed; bottom: calc(100px + var(--safe-bottom)); left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 10px 18px;
  background: rgba(10,30,36,0.9); border: 1px solid rgba(168,216,196,0.3);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-radius: 100px; color: var(--c-cream);
  font-size: 13px; font-weight: 500;
  opacity: 0; z-index: 200; pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.16,1,0.3,1);
  max-width: 86vw; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }


/* ══════════════════════════════════════════════
   ENDED SCREEN
   ══════════════════════════════════════════════ */

.screen-ended {
  height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 24px; text-align: center;
}
.ended-icon {
  width: 80px; height: 80px; border-radius: 50%;
  background: rgba(168,216,196,0.12); border: 1px solid rgba(168,216,196,0.25);
  display: grid; place-items: center; margin-bottom: 24px;
  opacity: 0; animation: scale-in 0.8s 0.2s cubic-bezier(0.16,1,0.3,1) forwards;
}
.ended-icon svg { width: 32px; height: 32px; color: var(--c-mint); }
.ended-title {
  font-family: var(--font-display); font-style: italic; font-weight: 400;
  font-size: 28px; letter-spacing: -0.02em; margin-bottom: 8px;
  opacity: 0; animation: fu 0.8s 0.4s forwards;
}
html[lang="he"] .ended-title { font-style: normal; }
.ended-duration {
  font-size: 15px; color: var(--c-whisper); margin-bottom: 48px; line-height: 1.5;
  opacity: 0; animation: fu 0.8s 0.5s forwards;
}
.ended-cta {
  width: 100%; max-width: 320px; min-height: 56px;
  background: linear-gradient(135deg, var(--c-teal), var(--c-deep));
  border: 1px solid rgba(94,179,176,0.5); border-radius: 18px;
  color: var(--c-cream); font-size: 16px; font-weight: 600; letter-spacing: 0.01em;
  box-shadow: 0 8px 24px rgba(42,92,92,0.5);
  transition: all 0.25s cubic-bezier(0.16,1,0.3,1);
  margin-bottom: 20px; touch-action: manipulation;
  opacity: 0; animation: fu 0.8s 0.6s forwards;
}
.ended-cta:active, .ended-cta.is-pressed { transform: scale(0.98); }
.ended-cta:focus-visible { outline: 2px solid var(--c-mint); outline-offset: 3px; }
.ended-disclaimer {
  font-size: 12px; color: rgba(232,245,242,0.3);
  max-width: 280px; line-height: 1.5;
  opacity: 0; animation: fu 0.8s 0.7s forwards;
}


/* ══════════════════════════════════════════════
   REDUCED MOTION
   ══════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
