/* Темы из дизайна: dawn — светлая, dusk — тёмная (по colorScheme Telegram). */
:root {
  --bg: linear-gradient(168deg,#fdf6f0 0%,#fbece2 40%,#f6ddd2 74%,#efd2cb 100%);
  --ink: #473a33; --ink-soft: rgba(71,58,51,.56);
  --orb-core: #ffe7cd; --orb-edge: #f0b495;
  --accent: #cf8a6c; --accent-ink: #fffaf6;
  --card: rgba(255,255,255,.5); --card-border: rgba(255,255,255,.7); --chip: rgba(255,255,255,.42);
}
:root.dark {
  --bg: linear-gradient(165deg,#1d1830 0%,#272039 46%,#332544 78%,#3b2b41 100%);
  --ink: #efe8e0; --ink-soft: rgba(239,232,224,.56);
  --orb-core: #f3d4bb; --orb-edge: #a684d6;
  --accent: #dba884; --accent-ink: #241327;
  --card: rgba(255,255,255,.06); --card-border: rgba(255,255,255,.12); --chip: rgba(255,255,255,.07);
}

* { box-sizing: border-box; margin: 0; }
::-webkit-scrollbar { display: none; }
html, body { height: 100%; }
body {
  height: var(--tg-viewport-stable-height, 100dvh);
  display: flex; flex-direction: column; overflow: hidden; position: relative;
  background: var(--bg); background-color: #fbece2; color: var(--ink);
  font-family: 'Golos Text', system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
:root.dark body { background-color: #272039; }
button { font-family: inherit; color: inherit; cursor: pointer; }
button:active { transform: scale(.98); }
button:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.glass {
  background: var(--card); border: 1px solid var(--card-border);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}

/* ambient light */
.ambient { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.orb-wrap {
  position: absolute; left: 50%; top: 44%; width: 360px; height: 360px;
  transform: translate(-50%,-50%) scale(1); transition: transform 1.8s cubic-bezier(.4,.6,.3,1);
}
.orb-drift { width: 100%; height: 100%; animation: drift 18s ease-in-out infinite; }
.orb {
  width: 100%; height: 100%; border-radius: 50%;
  background: radial-gradient(circle at 50% 46%, var(--orb-core), var(--orb-edge) 46%, transparent 70%);
  filter: blur(48px); opacity: .62; transition: opacity 1.8s; animation: breathe 9s ease-in-out infinite;
}
body.is-thinking .orb-wrap { transform: translate(-50%,-50%) scale(1.3); }
body.is-thinking .orb { opacity: .85; }
.mote {
  position: absolute; border-radius: 50%; background: var(--orb-core);
  filter: blur(2px); opacity: .5; animation: floaty 10s ease-in-out infinite;
}
.mote.edge { background: var(--orb-edge); opacity: .4; }
/* Позиции — здесь, а не в style="": CSP без 'unsafe-inline' блокирует инлайн-стили. */
.mote:nth-of-type(1) { left: 18%; top: 24%; width: 7px; height: 7px; animation-duration: 9s; }
.mote:nth-of-type(2) { left: 78%; top: 30%; width: 5px; height: 5px; animation-duration: 11s; animation-delay: 1.4s; }
.mote:nth-of-type(3) { left: 30%; top: 64%; width: 6px; height: 6px; animation-duration: 12s; animation-delay: .6s; }
.mote:nth-of-type(4) { left: 70%; top: 70%; width: 8px; height: 8px; animation-duration: 10s; animation-delay: 2.2s; }
.mote:nth-of-type(5) { left: 50%; top: 82%; width: 5px; height: 5px; animation-duration: 13s; animation-delay: 1.1s; }

/* header */
header {
  position: relative; z-index: 3; flex-shrink: 0;
  display: flex; justify-content: center; align-items: center; padding: 16px 22px 8px;
}
.brand { display: flex; align-items: center; gap: 8px; font-family: 'Cormorant', serif; font-weight: 600; font-style: italic; font-size: 21px; letter-spacing: .02em; }
.dot { width: 11px; height: 11px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, var(--orb-core), var(--orb-edge)); box-shadow: 0 0 12px 2px var(--orb-edge); }

/* screens */
main { position: relative; z-index: 1; flex: 1; overflow: hidden; }
.screen {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  padding: 0 26px calc(26px + env(safe-area-inset-bottom)); overflow-y: auto;
  opacity: 0; transform: translateY(16px); pointer-events: none; visibility: hidden;
  transition: opacity .55s ease, transform .6s cubic-bezier(.2,.7,.2,1), visibility 0s .6s;
}
.screen.active { opacity: 1; transform: none; pointer-events: auto; visibility: visible; transition-delay: 0s; }

.kicker { font-size: 11.5px; letter-spacing: .22em; text-transform: uppercase; color: var(--ink-soft); }
h1, h2, .thinking-label { font-family: 'Cormorant', serif; font-style: italic; }
h1 { font-weight: 600; font-size: 46px; line-height: 1.04; letter-spacing: .01em; margin-top: 20px; }
h2 { font-weight: 600; font-size: 34px; padding-top: 28px; }
.sub { font-size: 16.5px; line-height: 1.55; color: var(--ink-soft); margin-top: 16px; max-width: 300px; }
.sub.small { font-size: 15px; line-height: 1.5; margin-top: 10px; }

#home { justify-content: space-between; padding-top: 36px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.btn {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  height: 60px; padding: 0 26px; border-radius: 26px; font-size: 16px; font-weight: 500;
  transition: opacity .3s;
}
.btn.primary { height: 62px; border: none; background: var(--accent); color: var(--accent-ink); font-size: 16.5px; font-weight: 600; box-shadow: 0 16px 38px -16px var(--accent); }
.btn.center { justify-content: center; margin-top: auto; flex-shrink: 0; }
.btn:disabled { opacity: .4; pointer-events: none; }
.chev { font-size: 22px; opacity: .85; }
.chev.dim { opacity: .6; }

.field { position: relative; margin-top: 20px; flex-shrink: 0; }
textarea {
  display: block; width: 100%; height: 150px; resize: none; padding: 20px 20px 56px;
  border-radius: 26px; color: var(--ink); font: 16.5px/1.5 'Golos Text', sans-serif; outline: none;
}
textarea::placeholder { color: var(--ink-soft); opacity: .85; }
.mic {
  position: absolute; right: 12px; bottom: 12px; width: 42px; height: 42px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--chip); border: 1px solid var(--card-border); color: var(--ink);
}
.mic[hidden] { display: none; }
.mic .i-stop, .mic.rec .i-mic { display: none; }
.mic.rec .i-stop { display: block; }
.mic.rec { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); animation: micpulse 1.6s ease-out infinite; }
.mic:disabled { opacity: .45; pointer-events: none; }
.voice-status { min-height: 18px; margin-top: 8px; font-size: 12.5px; color: var(--ink-soft); }
.label { font-size: 12.5px; letter-spacing: .04em; color: var(--ink-soft); margin: 6px 0 10px; }
.moods { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.moods button { padding: 9px 15px; border-radius: 999px; background: var(--chip); border: 1px solid var(--card-border); font-size: 14px; }
.moods button:active { transform: scale(.95); }

#thinking { justify-content: center; align-items: center; text-align: center; }
.pulse { position: relative; width: 150px; height: 150px; display: flex; align-items: center; justify-content: center; }
.pulse i { position: absolute; inset: 0; border-radius: 50%; border: 1px solid var(--accent); animation: ringpulse 2.6s ease-out infinite; }
.pulse i + i { animation-delay: 1.3s; }
.pulse b { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 34px 8px var(--accent); }
.thinking-label { font-size: 23px; color: var(--ink-soft); margin-top: 30px; }

#answer > .kicker { padding-top: 26px; letter-spacing: .24em; flex-shrink: 0; }
.answer-wrap { flex: 1; display: flex; align-items: center; padding: 20px 0; }
.card { width: 100%; border-radius: 28px; padding: 30px 28px; -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); box-shadow: 0 24px 60px -28px rgba(0,0,0,.4); }
.answer-text { font-family: 'Cormorant', serif; font-weight: 500; font-size: 27px; line-height: 1.4; }
.answer-text span { display: inline-block; margin-right: .26em; animation: wordRise .55s cubic-bezier(.2,.7,.2,1) both; }
.card-foot { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 20px; }
.votes { display: flex; gap: 8px; }
.votes[hidden] { display: none; }
.votes button { min-width: 44px; height: 36px; padding: 0 12px; border-radius: 999px; background: var(--chip); border: 1px solid var(--card-border); font-size: 15px; transition: background .25s, border-color .25s; }
.votes button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.votes span:empty { display: none; }
.row { display: flex; gap: 12px; flex-shrink: 0; }
.btn.small { flex: 1; height: 54px; border-radius: 18px; font-size: 15.5px; justify-content: center; padding: 0; }
.btn.small.primary { box-shadow: 0 12px 30px -14px var(--accent); }

/* Мягкая подсветка при наведении. Только на устройствах с курсором — на тач-экранах hover «залипает». */
@media (hover: hover) {
  button { transition: box-shadow .35s ease, filter .35s ease, background .25s, border-color .25s, opacity .3s, transform .15s; }
  button:hover { box-shadow: 0 0 26px 2px color-mix(in srgb, var(--orb-edge) 60%, transparent); border-color: var(--orb-core); }
  .btn.primary:hover { box-shadow: 0 16px 38px -16px var(--accent), 0 0 34px 4px color-mix(in srgb, var(--accent) 50%, transparent); filter: brightness(1.06); }
  .votes button.on:hover { border-color: var(--accent); }
}

@keyframes breathe { 0%,100% { transform: scale(1); opacity: .9; } 50% { transform: scale(1.1); opacity: 1; } }
@keyframes drift { 0%,100% { transform: translate(0,0); } 33% { transform: translate(18px,-14px); } 66% { transform: translate(-16px,12px); } }
@keyframes floaty { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-22px); } }
@keyframes wordRise { from { opacity: 0; transform: translateY(12px); filter: blur(8px); } to { opacity: 1; transform: none; filter: blur(0); } }
@keyframes micpulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); } 100% { box-shadow: 0 0 0 16px transparent; } }
@keyframes ringpulse { 0% { transform: scale(.7); opacity: .55; } 70% { opacity: 0; } 100% { transform: scale(1.9); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
