:root {
  --bg: #0d121a;
  --panel: #131a25;
  --panel-2: #19222f;
  --border: #253244;
  --text: #e1e8f2;
  --text-2: #adbbcd;
  --muted: #8a99ad;
  --sage: #8cbaa4;
  --sky: #86a9d6;
  --sage-soft: rgba(140, 186, 164, .12);
  --sky-soft: rgba(134, 169, 214, .12);
  --danger: #e0938f;
  --radius: 18px;
  --spring: cubic-bezier(.34, 1.4, .64, 1);
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  background: var(--bg);
  background-image:
    radial-gradient(900px 560px at 50% -120px, rgba(140, 186, 164, .16), transparent 70%),
    radial-gradient(700px 480px at 110% 100%, rgba(134, 169, 214, .08), transparent 70%);
  background-attachment: fixed;
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: .88em; }

/* шапка */
.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
  background: rgba(13, 18, 26, .78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(37, 50, 68, .6);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { border-radius: 10px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { font-size: 1.05em; letter-spacing: .01em; }
.brand-text small { color: var(--sage); font-size: .78em; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.account {
  max-width: 40vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-2);
  font-size: .9em;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--panel);
  cursor: pointer;
  transition: transform .2s var(--spring), border-color .2s, background .2s;
}
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:hover { border-color: var(--sage); }
.icon-btn:active { transform: scale(.92); }
.icon-btn:disabled { opacity: .45; cursor: default; }
#speak .wave { opacity: .25; transition: opacity .2s; }
#speak[aria-pressed="true"] { color: var(--sage); border-color: rgba(140, 186, 164, .5); }
#speak[aria-pressed="true"] .wave { opacity: 1; }
.send { background: var(--sage); border-color: var(--sage); color: #0d121a; }
.send:hover { border-color: #b2d6c5; }
.mic.is-recording { background: var(--danger); border-color: var(--danger); color: #0d121a; animation: pulse 1.4s ease-in-out infinite; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  cursor: pointer;
  transition: transform .2s var(--spring), border-color .2s;
}
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--sage); border-color: var(--sage); color: #0d121a; font-weight: 600; }
.btn-small { min-height: 34px; padding: 5px 13px; font-size: .9em; }

/* главная область */
main {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 20px 16px 8px;
}
.hero, .welcome { text-align: center; padding: 6vh 8px 20px; }
.hero h1, .welcome h1 { margin: 18px 0 8px; font-size: clamp(1.5em, 5vw, 2em); line-height: 1.2; letter-spacing: -.01em; }
.hero p { max-width: 460px; margin: 0 auto 18px; color: var(--text-2); }
.orb {
  width: 84px;
  height: 84px;
  margin: 0 auto;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, .55), transparent 32%),
    radial-gradient(circle at 50% 55%, var(--sage), #3f6f5c 70%);
  box-shadow: 0 0 40px rgba(140, 186, 164, .35), 0 0 90px rgba(134, 169, 214, .18);
  animation: breathe 5s ease-in-out infinite;
}
.links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 14px 0 6px; }
.link-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: .85em;
  color: var(--text-2);
}
.link-chip.on { border-color: rgba(140, 186, 164, .45); color: var(--sage); background: var(--sage-soft); }
.link-chip.off { border-style: dashed; }
.examples { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 18px; }
.example {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text-2);
  cursor: pointer;
  transition: border-color .2s, color .2s, transform .2s var(--spring);
}
.example:hover { border-color: var(--sage); color: var(--text); }
.example:active { transform: scale(.96); }

/* переписка */
.log { display: flex; flex-direction: column; gap: 10px; padding-bottom: 10px; }
.msg {
  max-width: min(600px, 88%);
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  animation: rise .28s var(--ease);
}
.msg.user { align-self: flex-end; background: var(--sky-soft); border-color: rgba(134, 169, 214, .4); border-bottom-right-radius: 6px; }
.msg.assistant { align-self: flex-start; border-bottom-left-radius: 6px; }
.msg .voice-tag { color: var(--muted); margin-right: 4px; }
.msg.typing { display: flex; gap: 5px; padding: 14px 16px; }
.msg.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: dot 1.2s infinite; }
.msg.typing i:nth-child(2) { animation-delay: .15s; }
.msg.typing i:nth-child(3) { animation-delay: .3s; }
.action {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px dashed rgba(140, 186, 164, .5);
  border-radius: 12px;
  background: var(--sage-soft);
  white-space: normal;
}
.action-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

/* ввод */
.composer {
  position: sticky;
  bottom: 0;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 8px 16px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, rgba(13, 18, 26, 0));
}
.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 26px;
  background: var(--panel);
  transition: border-color .2s;
}
.composer-row:focus-within { border-color: rgba(140, 186, 164, .55); }
.composer textarea {
  flex: 1;
  min-height: 42px;
  max-height: 180px;
  padding: 9px 6px;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
}
.composer textarea::placeholder { color: var(--muted); }
.composer-meta { display: flex; justify-content: space-between; gap: 8px; min-height: 20px; padding: 4px 14px 0; font-size: .8em; }
.rec { color: var(--danger); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(110px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel-2);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
  animation: rise .25s var(--ease);
  z-index: 10;
}

@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes breathe { 50% { transform: scale(1.06); box-shadow: 0 0 56px rgba(140, 186, 164, .45), 0 0 110px rgba(134, 169, 214, .22); } }
@keyframes dot { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(224, 147, 143, .18); } }
.toast[hidden], [hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
