:root {
  color-scheme: light;
  --black: #080808;
  --black-soft: #111111;
  --white: #ffffff;
  --surface: #f5f5f5;
  --surface-2: #ededed;
  --gray: #858585;
  --gray-dark: #404040;
  --red: #e21b2d;
  --red-light: #ff5968;
  --red-dark: #8e0714;
  --line: rgba(0, 0, 0, .09);
  --shadow: 0 24px 70px rgba(0, 0, 0, .12);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --surface: #0b0b0b;
    --surface-2: #171717;
    --gray: #8b8b8b;
    --gray-dark: #b8b8b8;
    --line: rgba(255, 255, 255, .09);
    --shadow: 0 24px 70px rgba(0, 0, 0, .5);
  }
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

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

body {
  min-height: 100dvh;
  overflow-x: hidden;
  background:
    radial-gradient(
      circle at 50% -20%,
      rgba(226, 27, 45, .13),
      transparent 42%
    ),
    var(--surface);
  color: var(--black);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

@media (prefers-color-scheme: dark) {
  body {
    color: var(--white);
    background:
      radial-gradient(
        circle at 50% -20%,
        rgba(226, 27, 45, .18),
        transparent 42%
      ),
      var(--black);
  }
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
}

.splash {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-content: center;
  justify-items: center;
  background: var(--black);
  color: var(--white);
  transition:
    opacity .5s ease,
    visibility .5s ease;
}

body.ready .splash {
  opacity: 0;
  visibility: hidden;
}

.splash-mark,
.brand-symbol {
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 24px;
  background:
    radial-gradient(
      circle,
      var(--red-light),
      var(--red-dark)
    );
  box-shadow:
    0 0 60px rgba(226, 27, 45, .35);
  font-size: 28px;
  font-weight: 900;
}

.splash-name,
.brand h1 {
  margin-top: 18px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -.04em;
}

.splash-name span,
.brand h1 span,
.model-brand strong span,
.side-head strong span,
.welcome h1 span {
  color: var(--red);
}

.splash-line {
  width: 46px;
  height: 2px;
  margin-top: 16px;
  background: var(--red);
  animation: pulseLine 1.3s ease-in-out infinite;
}

@keyframes pulseLine {
  50% {
    width: 80px;
    opacity: .35;
  }
}

.auth-shell {
  width: min(100%, 520px);
  min-height: 100dvh;
  margin: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding:
    max(24px, env(safe-area-inset-top))
    22px
    max(24px, env(safe-area-inset-bottom));
}

.auth-shell.compact {
  justify-content: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 26px;
}

.brand h1 {
  margin: 0;
  font-size: 30px;
}

.brand p {
  margin: 4px 0 0;
  color: var(--gray);
}

.auth-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(255,255,255,.68);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
}

@media (prefers-color-scheme: dark) {
  .auth-card {
    background: rgba(20,20,20,.75);
  }
}

.language-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 20px;
}

.language {
  min-height: 42px;
  border-radius: 13px;
  color: var(--gray-dark);
  background: var(--surface-2);
}

.language.active {
  color: var(--white);
  background: var(--black);
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.field label {
  color: var(--gray-dark);
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field textarea {
  width: 100%;
  padding: 14px 15px;
  border: 1px solid var(--line);
  border-radius: 15px;
  outline: none;
  color: inherit;
  background: var(--surface);
}

.field input:focus,
.field textarea:focus {
  border-color: var(--red);
  box-shadow:
    0 0 0 4px rgba(226,27,45,.1);
}

.field textarea {
  resize: vertical;
}

.primary-button {
  width: 100%;
  min-height: 50px;
  border-radius: 15px;
  color: var(--white);
  background: var(--red);
  font-weight: 800;
  cursor: pointer;
  transition:
    transform .15s ease,
    background .15s ease;
}

.primary-button:active {
  transform: scale(.98);
}

.primary-button:disabled {
  opacity: .55;
}

.error-text,
.success-text {
  min-height: 20px;
  margin-top: 12px;
  color: var(--red);
  font-size: 13px;
}

.success-text {
  color: #238a51;
}

.app-shell {
  width: 100%;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  background:
    radial-gradient(
      circle at 50% 15%,
      rgba(226,27,45,.08),
      transparent 35%
    ),
    var(--surface);
}

.topbar {
  position: relative;
  z-index: 20;
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding:
    max(8px, env(safe-area-inset-top))
    14px
    8px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.58);
  backdrop-filter: blur(22px);
}

@media (prefers-color-scheme: dark) {
  .topbar {
    background: rgba(8,8,8,.68);
  }
}

.icon-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 42px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: inherit;
  background: var(--surface-2);
  cursor: pointer;
}

.model-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.model-brand strong {
  display: block;
  font-size: 15px;
}

.model-brand small {
  display: block;
  margin-top: 2px;
  color: var(--gray);
  font-size: 10px;
}

.mini-orb {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(
      circle at 35% 30%,
      var(--red-light),
      var(--red-dark)
    );
  box-shadow:
    0 0 20px rgba(226,27,45,.28);
}

.mini-orb span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 0 12px white;
  animation: heartbeat 1.4s infinite;
}

@keyframes heartbeat {
  0%,
  100% {
    transform: scale(1);
  }

  15% {
    transform: scale(1.25);
  }

  30% {
    transform: scale(1);
  }
}

.chat-area {
  position: relative;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.welcome {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px 100px;
  text-align: center;
  transition:
    opacity .35s ease,
    transform .35s ease;
}

.welcome.hidden {
  display: none;
}

.hero-orb {
  position: relative;
  width: 150px;
  height: 150px;
  margin-bottom: 30px;
  display: grid;
  place-items: center;
}

.orb-core {
  width: 86px;
  height: 86px;
  border-radius: 50%;
  background:
    radial-gradient(
      circle at 35% 25%,
      #ff6976,
      var(--red) 50%,
      var(--red-dark)
    );
  box-shadow:
    0 0 35px rgba(226,27,45,.4),
    inset 0 -12px 25px rgba(0,0,0,.2);
  animation: orbPulse 2.6s ease-in-out infinite;
}

.orb-ring {
  position: absolute;
  inset: 20px;
  border: 1px solid rgba(226,27,45,.25);
  border-radius: 50%;
}

.ring-one {
  animation: ringPulse 2.4s infinite;
}

.ring-two {
  inset: 4px;
  animation: ringPulse 2.4s .7s infinite;
}

@keyframes orbPulse {
  50% {
    transform: scale(1.05);
  }
}

@keyframes ringPulse {
  0% {
    transform: scale(.75);
    opacity: .8;
  }

  100% {
    transform: scale(1.15);
    opacity: 0;
  }
}

.welcome h1 {
  margin: 0;
  font-size: clamp(30px, 9vw, 52px);
  letter-spacing: -.06em;
}

.welcome p {
  max-width: 310px;
  margin: 12px auto 0;
  color: var(--gray);
  line-height: 1.7;
}

.messages {
  width: min(100%, 720px);
  margin: auto;
  padding: 18px 16px 110px;
}

.message {
  display: flex;
  gap: 10px;
  margin: 0 0 22px;
  animation: messageIn .28s ease both;
}

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.message.user {
  flex-direction: row-reverse;
}

.message-avatar {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  flex: 0 0 30px;
  border-radius: 10px;
  color: var(--white);
  background: var(--red);
  font-size: 12px;
  font-weight: 900;
}

.message.user .message-avatar {
  color: var(--black);
  background: var(--surface-2);
}

.message-body {
  max-width: 82%;
}

.message-body strong {
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
  color: var(--gray);
}

.message-text {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--surface-2);
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message.assistant .message-text {
  border-top-left-radius: 5px;
}

.message.user .message-text {
  border-top-right-radius: 5px;
  color: var(--white);
  background: var(--black);
}

.composer {
  position: relative;
  z-index: 15;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding:
    10px
    20px
    max(18px, env(safe-area-inset-bottom));
  background:
    linear-gradient(
      to top,
      var(--surface) 62%,
      transparent
    );
  pointer-events: none;
}

.typing-indicator {
  position: absolute;
  bottom: 126px;
  display: flex;
  align-items: center;
  gap: 5px;
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity .2s ease,
    transform .2s ease;
}

.typing-indicator.show {
  opacity: 1;
  transform: translateY(0);
}

.typing-indicator span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--red);
  animation: typing .9s infinite;
}

.typing-indicator span:nth-child(2) {
  animation-delay: .15s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: .3s;
}

.typing-indicator label {
  margin-inline-start: 5px;
  color: var(--gray);
  font-size: 11px;
}

@keyframes typing {
  50% {
    transform: translateY(-4px);
    opacity: .4;
  }
}

.talk-button {
  position: relative;
  width: 88px;
  height: 88px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  color: var(--white);
  background: transparent;
  pointer-events: auto;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.talk-halo {
  position: absolute;
  inset: -8px;
  border: 1px solid rgba(226,27,45,.28);
  border-radius: 50%;
  transition:
    transform .2s ease,
    border-color .2s ease;
}

.talk-core {
  position: relative;
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(
      circle at 35% 25%,
      var(--red-light),
      var(--red) 48%,
      var(--red-dark)
    );
  box-shadow:
    0 12px 40px rgba(226,27,45,.3),
    inset 0 -12px 20px rgba(0,0,0,.18);
  transition:
    transform .16s ease,
    filter .16s ease;
}

.talk-button:active .talk-core,
.talk-button.recording .talk-core {
  transform: scale(.91);
}

.talk-button.recording .talk-halo {
  transform: scale(1.17);
  border-color: rgba(226,27,45,.65);
  animation: recordingPulse .9s infinite;
}

@keyframes recordingPulse {
  50% {
    opacity: .3;
  }
}

.talk-button.processing .talk-core {
  animation: processingPulse .75s infinite;
}

@keyframes processingPulse {
  0%,
  100% {
    transform: scale(1);
    filter: brightness(1);
  }

  50% {
    transform: scale(1.12);
    filter: brightness(1.35);
  }
}

.talk-button.processing .talk-halo {
  animation: processingRing .9s infinite;
}

@keyframes processingRing {
  50% {
    transform: scale(1.2);
    opacity: .15;
  }
}

.mic-icon {
  width: 12px;
  height: 18px;
  display: block;
  border-radius: 8px;
  color: transparent;
  border: 2px solid white;
  box-shadow:
    inset 0 0 0 2px transparent;
}

.mic-icon::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 12px;
  margin-top: 14px;
  margin-left: -7px;
  border-bottom: 2px solid white;
  border-radius: 0 0 15px 15px;
}

.composer-hint {
  margin-top: 12px;
  color: var(--gray);
  font-size: 11px;
  pointer-events: none;
}

.side-panel {
  position: fixed;
  z-index: 50;
  top: 0;
  bottom: 0;
  left: 0;
  width: min(330px, 88vw);
  padding:
    max(18px, env(safe-area-inset-top))
    18px
    max(18px, env(safe-area-inset-bottom));
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--line);
  transform: translateX(-105%);
  transition: transform .28s ease;
}

[dir="rtl"] .side-panel {
  left: auto;
  right: 0;
  transform: translateX(105%);
  border-right: 0;
  border-left: 1px solid var(--line);
}

.side-panel.open {
  transform: translateX(0);
}

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.side-head strong {
  font-size: 19px;
}

.profile-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 19px;
  background: var(--surface-2);
}

.profile-avatar {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: white;
  background: var(--red);
  font-weight: 900;
}

.profile-card strong,
.profile-card span {
  display: block;
}

.profile-card span {
  margin-top: 3px;
  color: var(--gray);
  font-size: 11px;
}

.usage-card {
  margin-top: 12px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 19px;
}

.usage-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.usage-title span {
  color: var(--gray);
  font-size: 11px;
}

.usage-title strong {
  font-size: 13px;
}

.usage-track {
  height: 5px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 10px;
  background: var(--surface-2);
}

.usage-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--red);
  transition: width .5s ease;
}

.menu-item {
  width: 100%;
  min-height: 48px;
  margin-top: 8px;
  padding: 0 14px;
  border-radius: 15px;
  text-align: start;
  color: inherit;
  background: transparent;
  cursor: pointer;
}

.menu-item:active,
.menu-item:hover {
  background: var(--surface-2);
}

.menu-item.danger {
  color: var(--red);
}

.overlay {
  position: fixed;
  z-index: 40;
  inset: 0;
  background: rgba(0,0,0,.42);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity .2s ease,
    visibility .2s ease;
}

.overlay.show {
  opacity: 1;
  visibility: visible;
}

.modal {
  position: fixed;
  z-index: 80;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
  background: rgba(0,0,0,.5);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity .22s ease,
    visibility .22s ease;
}

.modal.open {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  position: relative;
  width: min(100%, 520px);
  max-height: 88dvh;
  overflow-y: auto;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 27px;
  color: inherit;
  background: var(--surface);
  box-shadow: var(--shadow);
  transform: translateY(25px);
  transition: transform .25s ease;
}

.modal.open .modal-card {
  transform: translateY(0);
}

.modal-card h2 {
  margin: 0 0 22px;
  font-size: 21px;
}

.modal-close {
  position: absolute;
  top: 15px;
  right: 15px;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  color: inherit;
  background: var(--surface-2);
  cursor: pointer;
}

[dir="rtl"] .modal-close {
  right: auto;
  left: 15px;
}

.memory-list {
  display: grid;
  gap: 8px;
}

.memory-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--gray-dark);
  font-size: 13px;
  line-height: 1.7;
}

.language-choice {
  width: 100%;
  min-height: 52px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 15px;
  color: inherit;
  background: var(--surface-2);
}

.muted {
  color: var(--gray);
}

@media (min-width: 700px) {
  body {
    display: grid;
    place-items: center;
    padding: 20px;
  }

  .app-shell {
    width: min(100%, 520px);
    height: min(920px, calc(100dvh - 40px));
    min-height: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 30px;
    box-shadow: var(--shadow);
  }

  .side-panel {
    top: 20px;
    bottom: 20px;
    border-radius: 0 25px 25px 0;
  }

  [dir="rtl"] .side-panel {
    border-radius: 25px 0 0 25px;
  }

  .overlay {
    border-radius: 30px;
  }
}
