:root {
  color-scheme: dark;
  font-family: Inter, "Noto Sans", system-ui, sans-serif;
  --bg: #061311;
  --panel: rgba(6, 22, 20, 0.9);
  --panel-soft: rgba(9, 36, 31, 0.72);
  --mint: #6ff3d8;
  --mint-dim: rgba(111, 243, 216, 0.2);
  --gold: #f1c66d;
  --coral: #ff8d7d;
  --text: #e9fff9;
  --muted: #9bbdb5;
  --line: rgba(126, 235, 210, 0.16);
  --voice-level: 0;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
}

body {
  min-height: 100dvh;
  overflow: hidden;
  color: var(--text);
  background:
    linear-gradient(rgba(111, 243, 216, 0.026) 1px, transparent 1px),
    linear-gradient(90deg, rgba(111, 243, 216, 0.026) 1px, transparent 1px),
    radial-gradient(circle at 50% 0%, #113b33 0%, var(--bg) 46%, #030a09 100%);
  background-size:
    34px 34px,
    34px 34px,
    auto;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--mint);
  outline-offset: 3px;
}

.ambient {
  position: fixed;
  z-index: 0;
  width: 42vw;
  height: 42vw;
  min-width: 280px;
  min-height: 280px;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.16;
  pointer-events: none;
}

.ambient-a {
  top: -18vw;
  left: 8vw;
  background: #34d7bb;
}

.ambient-b {
  right: 4vw;
  bottom: -22vw;
  background: #b58b38;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(100%, 820px);
  height: 100dvh;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  border-inline: 1px solid var(--line);
  background: linear-gradient(
    180deg,
    rgba(3, 14, 12, 0.52),
    rgba(2, 10, 9, 0.74)
  );
  box-shadow: 0 0 90px rgba(0, 0, 0, 0.48);
}

.app-header {
  min-height: 76px;
  padding: max(12px, env(safe-area-inset-top)) 20px 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(4, 17, 15, 0.84);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  direction: ltr;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(111, 243, 216, 0.32);
  border-radius: 12px;
  color: var(--mint);
  background:
    linear-gradient(145deg, rgba(111, 243, 216, 0.15), transparent),
    #071b18;
  font: 700 18px/1 Inter, system-ui, sans-serif;
  box-shadow: inset 0 0 20px rgba(111, 243, 216, 0.06);
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--gold);
  font: 700 10px/1.2 Inter, "Noto Sans Arabic", sans-serif;
  letter-spacing: 1.4px;
}

h1 {
  margin: 0;
  color: #f2fffc;
  font: 700 22px/1.15 Inter, system-ui, sans-serif;
  letter-spacing: 0.06em;
}

.icon-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: #b9e2d9;
  background: rgba(111, 243, 216, 0.05);
  font: 18px/1 system-ui, sans-serif;
}

.icon-button:hover {
  color: var(--mint);
  border-color: rgba(111, 243, 216, 0.5);
}

.status-bar {
  min-height: 42px;
  padding: 8px 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border-bottom: 1px solid var(--line);
  background: rgba(4, 20, 17, 0.9);
  color: #bfe2da;
  transition: 180ms ease;
}

.status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: #678d84;
  box-shadow: 0 0 0 4px rgba(103, 141, 132, 0.1);
}

#statusText {
  margin: 0;
  color: inherit;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.6;
  text-align: center;
}

body[data-status="connecting"] .status-bar,
body[data-status="processing"] .status-bar {
  color: #ffe4a6;
  background: rgba(43, 34, 16, 0.92);
}

body[data-status="connecting"] .status-dot,
body[data-status="processing"] .status-dot {
  background: var(--gold);
  box-shadow:
    0 0 0 4px rgba(241, 198, 109, 0.13),
    0 0 14px rgba(241, 198, 109, 0.55);
  animation: pulse-dot 1.1s infinite ease-in-out;
}

body[data-status="connected"] .status-bar,
body[data-status="user-speaking"] .status-bar,
body[data-status="ai-speaking"] .status-bar {
  color: #d6fff7;
  background: rgba(6, 40, 34, 0.92);
}

body[data-status="connected"] .status-dot,
body[data-status="user-speaking"] .status-dot,
body[data-status="ai-speaking"] .status-dot {
  background: var(--mint);
  box-shadow:
    0 0 0 4px rgba(111, 243, 216, 0.12),
    0 0 14px rgba(111, 243, 216, 0.55);
}

body[data-status="user-speaking"] .status-dot,
body[data-status="ai-speaking"] .status-dot {
  animation: pulse-dot 0.8s infinite ease-in-out;
}

body[data-status="error"] .status-bar {
  color: #ffd5d0;
  background: rgba(48, 20, 18, 0.95);
}

body[data-status="error"] .status-dot {
  background: var(--coral);
}

.conversation {
  position: relative;
  min-height: 0;
  overflow: hidden;
  isolation: isolate;
}

.conversation::before,
.conversation::after {
  content: "";
  position: fixed;
  top: 19%;
  bottom: 19%;
  width: 1px;
  pointer-events: none;
  background: linear-gradient(
    transparent,
    rgba(111, 243, 216, 0.16),
    rgba(241, 198, 109, 0.22),
    transparent
  );
}

.conversation::before {
  left: max(10px, calc(50% - 410px));
}

.conversation::after {
  right: max(10px, calc(50% - 410px));
}

.orb-wrap {
  position: absolute;
  inset: 0;
  z-index: -1;
  display: grid;
  place-items: center;
  opacity: 0.7;
  pointer-events: none;
  transition:
    opacity 180ms ease,
    filter 180ms ease;
}

body[data-status="user-speaking"] .orb-wrap,
body[data-status="ai-speaking"] .orb-wrap {
  opacity: 0.94;
  filter: drop-shadow(0 0 30px rgba(111, 243, 216, 0.12));
}

#orbCanvas {
  width: min(74vw, 430px);
  aspect-ratio: 1;
  transform: scale(calc(1 + var(--voice-level) * 0.08));
  transition: transform 70ms linear;
}

.orb-halo {
  position: absolute;
  width: min(66vw, 380px);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid rgba(111, 243, 216, 0.15);
  animation: orbit 22s linear infinite;
}

.orb-halo::before,
.orb-halo::after {
  content: "";
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 12px var(--gold);
}

.orb-halo::before {
  top: 11%;
  left: 20%;
}

.orb-halo::after {
  right: 16%;
  bottom: 18%;
}

.orb-halo-b {
  width: min(78vw, 450px);
  border-style: dashed;
  border-color: rgba(241, 198, 109, 0.13);
  animation-direction: reverse;
  animation-duration: 31s;
}

.chat {
  position: absolute;
  z-index: 2;
  inset: 0;
  padding: 22px 18px 108px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  scrollbar-color: rgba(111, 243, 216, 0.3) transparent;
}

.bubble {
  width: fit-content;
  max-width: min(82%, 580px);
  padding: 11px 14px;
  border-radius: 13px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  unicode-bidi: plaintext;
  line-height: 1.85;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
  animation: bubble-in 180ms ease-out;
}

.bubble::before {
  display: block;
  margin-bottom: 4px;
  color: var(--gold);
  font-size: 11px;
  line-height: 1.2;
  opacity: 0.9;
}

.bubble.user {
  align-self: flex-start;
  border: 1px solid rgba(111, 243, 216, 0.38);
  color: #f2fffb;
  background: linear-gradient(135deg, #176c59, #135143);
}

.bubble.user::before {
  content: "Сіз";
}

.bubble.assistant {
  align-self: flex-end;
  border: 1px solid var(--line);
  color: #e3f7f2;
  background: rgba(7, 26, 24, 0.96);
}

.bubble.assistant::before {
  content: "bota";
}

.bubble.partial {
  opacity: 0.7;
}

.welcome {
  position: absolute;
  z-index: 3;
  left: 24px;
  right: 24px;
  bottom: 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  pointer-events: none;
}

.welcome p {
  max-width: 440px;
  margin: 0;
  padding: 9px 16px;
  border: 1px solid rgba(111, 243, 216, 0.16);
  border-radius: 10px;
  color: #a9ccc3;
  background: rgba(3, 18, 15, 0.72);
  font-size: 15px;
  line-height: 1.8;
  text-align: center;
  backdrop-filter: blur(8px);
}

.welcome-line {
  width: 46px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.welcome[hidden] {
  display: none;
}

.control-zone {
  padding: 12px 20px max(15px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(3, 15, 13, 0.94);
  backdrop-filter: blur(18px);
}

.control-row {
  display: grid;
  grid-template-columns: 48px minmax(160px, 260px) 48px;
  justify-content: center;
  align-items: center;
  gap: 14px;
  direction: ltr;
}

.main-control {
  position: relative;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid rgba(111, 243, 216, 0.72);
  border-radius: 16px;
  color: #e0fff9;
  background:
    linear-gradient(180deg, rgba(111, 243, 216, 0.19), rgba(111, 243, 216, 0.08)),
    #0a241e;
  box-shadow:
    inset 0 -2px rgba(111, 243, 216, 0.2),
    0 12px 35px rgba(0, 0, 0, 0.24);
  font-size: 17px;
  font-weight: 750;
  direction: ltr;
}

.main-control.active {
  border-color: rgba(255, 141, 125, 0.68);
  background: rgba(255, 141, 125, 0.12);
}

.main-control:disabled {
  cursor: wait;
  opacity: 0.55;
}

.live-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 10px currentColor;
}

body[data-status="user-speaking"] .live-dot,
body[data-status="ai-speaking"] .live-dot {
  animation: pulse-dot 0.8s infinite ease-in-out;
}

.round-control {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: #a9d2c9;
  background: rgba(111, 243, 216, 0.055);
}

.round-control:disabled {
  cursor: default;
  opacity: 0.3;
}

.round-control.selected {
  color: var(--coral);
  border-color: rgba(255, 141, 125, 0.45);
  background: rgba(255, 141, 125, 0.1);
}

.mic-icon {
  position: relative;
  width: 11px;
  height: 17px;
  border: 2px solid currentColor;
  border-radius: 8px;
}

.mic-icon::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -8px;
  width: 17px;
  height: 10px;
  border: 2px solid currentColor;
  border-top: 0;
  border-radius: 0 0 10px 10px;
  transform: translateX(-50%);
}

.mic-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -13px;
  width: 2px;
  height: 5px;
  background: currentColor;
  transform: translateX(-50%);
}

.stop-icon {
  width: 13px;
  height: 13px;
  border-radius: 3px;
  background: currentColor;
}

.control-hint {
  margin: 9px 0 0;
  color: #759b92;
  font-size: 10px;
  text-align: center;
}

.settings-dialog {
  width: min(92vw, 440px);
  padding: 0;
  border: 1px solid rgba(111, 243, 216, 0.24);
  border-radius: 18px;
  color: var(--text);
  background: #071916;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.62);
}

.settings-dialog::backdrop {
  background: rgba(0, 7, 6, 0.75);
  backdrop-filter: blur(7px);
}

.settings-dialog form {
  padding: 20px;
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.dialog-head h2 {
  margin: 0;
  font-size: 21px;
}

.field {
  display: grid;
  gap: 7px;
  margin: 0 0 14px;
  color: #b7d7cf;
  font-size: 12px;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: #effffb;
  background: #0c2621;
  padding: 11px 12px;
  font-size: 14px;
}

.field textarea {
  resize: vertical;
  line-height: 1.7;
}

.apply-button {
  width: 100%;
  height: 48px;
  border: 1px solid rgba(111, 243, 216, 0.7);
  border-radius: 12px;
  color: #dcfff8;
  background: rgba(111, 243, 216, 0.12);
  font-weight: 750;
}

.toast {
  position: fixed;
  z-index: 80;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  max-width: min(86vw, 520px);
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: #e8fff9;
  background: rgba(10, 38, 33, 0.96);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: 180ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@keyframes pulse-dot {
  50% {
    opacity: 0.45;
    transform: scale(1.45);
  }
}

@keyframes orbit {
  to {
    transform: rotate(360deg);
  }
}

@keyframes bubble-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

@media (max-width: 560px) {
  .app-header {
    min-height: 68px;
    padding-inline: 14px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  h1 {
    font-size: 19px;
  }

  .chat {
    padding-inline: 12px;
  }

  .bubble {
    max-width: 90%;
  }

  .control-zone {
    padding-inline: 12px;
  }

  .control-row {
    grid-template-columns: 44px minmax(120px, 1fr) 44px;
    gap: 9px;
  }

  .round-control {
    width: 44px;
    height: 46px;
  }

  .main-control {
    height: 54px;
  }
}

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