:root {
  --bg-color: #0a0f1e;
  --bg-dark: #070b14;
  --sidebar-bg: #0a0f1e;
  --accent-mint: #00f5d4;
  --accent-purple: #7b2ff7;
  --glass: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.1);
  --text-main: #e0e0e0;
  --text-soft: rgba(224, 224, 224, 0.7);
  --danger: #ff6b7a;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Segoe UI", Roboto, sans-serif;
}

body {
  min-height: 100vh;
  background: var(--bg-color);
  color: var(--text-main);
  line-height: 1.6;
}

a {
  color: inherit;
}

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

button {
  cursor: pointer;
}

.bg-blobs {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: -1;
}

.blob {
  position: absolute;
  width: 520px;
  height: 520px;
  background: linear-gradient(45deg, var(--accent-mint), var(--accent-purple));
  filter: blur(110px);
  border-radius: 50%;
  opacity: 0.18;
  animation: move 16s infinite alternate ease-in-out;
}

.blob-2 {
  right: -120px;
  bottom: -120px;
  background: var(--accent-purple);
  animation-delay: -7s;
}

@keyframes move {
  from {
    transform: translate(-8%, -8%);
  }
  to {
    transform: translate(18%, 18%);
  }
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 5%;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 15, 30, 0.78);
  backdrop-filter: blur(14px);
}

.logo {
  text-decoration: none;
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: 0;
  white-space: nowrap;
}

.logo span,
.hero h1 span,
.reg-card h1 span {
  color: var(--accent-mint);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.nav-links a {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--text-main);
  text-decoration: none;
  font-size: 0.92rem;
  transition: 0.25s;
}

.nav-links a:hover,
.nav-links a.active {
  border-color: rgba(0, 245, 212, 0.35);
  background: rgba(0, 245, 212, 0.08);
  color: var(--accent-mint);
}

.home-layout {
  width: min(1120px, 90%);
  min-height: calc(100vh - 75px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 50px;
  align-items: center;
}

.hero h1,
.page-hero h1 {
  font-size: clamp(2.6rem, 7vw, 5.5rem);
  line-height: 1;
  margin-bottom: 18px;
}

.hero p,
.page-hero p {
  max-width: 760px;
  color: var(--text-soft);
  font-size: 1.08rem;
}

.kicker {
  color: var(--accent-mint);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0;
  margin-bottom: 12px;
}

.hero-actions {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 28px;
}

.primary-link,
.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 24px;
  border-radius: 14px;
  text-decoration: none;
  font-weight: 800;
}

.primary-link {
  background: var(--accent-mint);
  color: var(--bg-color);
}

.secondary-link {
  border: 1px solid var(--border);
  background: var(--glass);
}

.auth-card,
.reg-card {
  width: 100%;
  background: var(--glass);
  backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 34px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.34);
}

.auth-card h2,
.reg-card h1 {
  text-align: center;
  font-size: 1.9rem;
  margin-bottom: 8px;
}

.subtitle {
  text-align: center;
  color: var(--text-soft);
  margin-bottom: 26px;
}

.social-grid {
  display: grid;
  gap: 12px;
}

.social-btn,
.login-btn,
.reg-btn,
.new-chat-btn,
.send-btn {
  border: none;
  font-weight: 800;
  transition: 0.25s;
}

.social-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 46px;
  border-radius: 12px;
}

.social-icon {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 0.82rem;
  font-weight: 900;
}

.google-icon {
  background: #fff;
  color: #4285f4;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.telegram-icon {
  background: rgba(255, 255, 255, 0.18);
  color: white;
}

.image-icon {
  object-fit: contain;
}

.google {
  background: #fff;
  color: #101010;
}

.telegram {
  background: #229ed9;
  color: #fff;
}

.ghosty {
  background: #151923;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.social-btn:hover,
.login-btn:hover,
.reg-btn:hover {
  transform: translateY(-2px);
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px 0;
  color: rgba(224, 224, 224, 0.45);
  font-size: 0.85rem;
}

.divider::before,
.divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: rgba(255, 255, 255, 0.18);
}

input,
textarea,
select {
  width: 100%;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: #fff;
  outline: none;
}

input,
select {
  min-height: 44px;
  padding: 0 14px;
}

select option {
  color: #101010;
}

textarea {
  resize: none;
  min-height: 48px;
  padding: 12px;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent-mint);
  box-shadow: 0 0 0 3px rgba(0, 245, 212, 0.14);
}

.auth-form {
  display: grid;
  gap: 14px;
}

.login-btn,
.reg-btn {
  min-height: 48px;
  border-radius: 12px;
  color: white;
  background: linear-gradient(90deg, var(--accent-mint), var(--accent-purple));
}

.reg-link,
.login-link {
  text-align: center;
  color: var(--text-soft);
  margin-top: 22px;
}

.reg-link a,
.login-link a {
  color: var(--accent-mint);
  text-decoration: none;
  font-weight: 800;
}

.form-status,
.chat-status {
  min-height: 22px;
  color: var(--accent-mint);
  font-size: 0.9rem;
}

.hidden {
  display: none !important;
}

.verify-form {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.telegram-widget-panel {
  display: grid;
  place-items: center;
  margin-top: 16px;
  min-height: 42px;
}

.page-hero {
  padding: 72px 5% 36px;
  text-align: center;
  background: radial-gradient(circle at center, rgba(123, 47, 247, 0.16) 0%, transparent 68%);
}

.page-hero p {
  margin: 0 auto;
}

.grid-container {
  padding: 40px 5%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
}

.model-card {
  min-height: 260px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px;
  transition: 0.3s;
}

.model-card:hover {
  transform: translateY(-6px);
  border-color: rgba(0, 245, 212, 0.55);
}

.model-card h2 {
  color: var(--accent-mint);
  margin: 8px 0 12px;
  font-size: 1.35rem;
}

.model-card p {
  color: var(--text-soft);
}

.muted-card {
  opacity: 0.68;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--accent-purple);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.badge.muted {
  background: rgba(255, 255, 255, 0.18);
}

.exp-box {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.exp-title {
  display: block;
  color: rgba(224, 224, 224, 0.55);
  font-weight: 800;
  margin-bottom: 6px;
}

code {
  color: var(--accent-mint);
  word-break: break-word;
}

.cta-box {
  padding: 42px 5% 80px;
  text-align: center;
}

footer {
  text-align: center;
  padding: 36px 5%;
  color: rgba(224, 224, 224, 0.5);
  font-size: 0.86rem;
}

.center-layout {
  min-height: calc(100vh - 75px);
  width: min(460px, calc(100% - 32px));
  margin: 0 auto;
  display: grid;
  place-items: center;
  padding: 32px 0;
}

.input-group {
  margin-bottom: 15px;
}

.input-group label {
  display: block;
  color: var(--text-soft);
  font-size: 0.85rem;
  margin: 0 0 6px 4px;
}

.terms {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 20px 0;
  color: var(--text-soft);
  font-size: 0.9rem;
}

.terms input {
  width: auto;
}

.chat-page {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  background: var(--bg-dark);
}

.sidebar {
  min-width: 0;
  min-height: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px;
}

.vertical {
  align-items: stretch;
  flex-direction: column;
  gap: 8px;
}

.vertical a {
  width: 100%;
}

.new-chat-btn {
  width: 100%;
  min-height: 44px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed var(--accent-mint);
  color: var(--accent-mint);
  border-radius: 12px;
}

.new-chat-btn:hover {
  background: rgba(0, 245, 212, 0.1);
}

.history-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-soft);
  font-size: 0.9rem;
  font-weight: 800;
}

.history-title button {
  border: none;
  background: transparent;
  color: var(--accent-mint);
  font-weight: 800;
}

.history-list {
  flex: 1;
  overflow-y: auto;
}

.account-panel {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: auto;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.045);
}

.account-avatar {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-mint), var(--accent-purple));
  color: white;
  font-weight: 900;
  text-transform: uppercase;
}

.account-details {
  min-width: 0;
}

.account-details strong,
.account-details span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-details strong {
  font-size: 0.95rem;
}

.account-details span {
  color: var(--text-soft);
  font-size: 0.8rem;
}

.history-item {
  width: 100%;
  min-height: 42px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  margin-bottom: 6px;
  background: transparent;
  color: var(--text-main);
  cursor: pointer;
  font-size: 0.9rem;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.7;
}

.history-item:hover,
.history-item.active {
  background: rgba(123, 47, 247, 0.12);
  border-color: rgba(123, 47, 247, 0.36);
  opacity: 1;
}

.main-chat {
  min-width: 0;
  min-height: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.chat-header {
  padding: 15px 30px;
  background: rgba(10, 15, 30, 0.6);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 18px;
  align-items: end;
}

.control-group label {
  display: block;
  color: rgba(224, 224, 224, 0.55);
  font-size: 0.75rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.prompt-group {
  flex: 1;
}

.messages-container {
  flex: 1;
  min-height: 0;
  padding: 34px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.empty-chat {
  margin: auto;
  max-width: 560px;
  text-align: center;
  color: var(--text-soft);
}

.message {
  max-width: min(820px, 84%);
  padding: 15px 18px;
  border-radius: 16px;
  white-space: pre-wrap;
}

.user-msg {
  align-self: flex-end;
  background: var(--accent-purple);
  color: white;
  border-bottom-right-radius: 4px;
}

.ai-msg {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.ai-msg.typing::after {
  content: "";
  display: inline-block;
  width: 0.55em;
  height: 1.05em;
  margin-left: 2px;
  border-right: 2px solid var(--accent-mint);
  transform: translateY(0.18em);
  animation: caret-blink 0.9s steps(1) infinite;
}

@keyframes caret-blink {
  50% {
    opacity: 0;
  }
}

.error-msg {
  border-color: rgba(255, 107, 122, 0.5);
  color: #ffd5da;
}

.input-area {
  padding: 22px 30px 16px;
  background: linear-gradient(to top, var(--bg-dark), rgba(7, 11, 20, 0.82));
}

.input-wrapper {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  align-items: end;
  gap: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 10px;
}

.input-wrapper textarea {
  flex: 1;
  border: none;
  background: transparent;
  box-shadow: none;
  min-height: 44px;
  max-height: 160px;
}

.send-btn {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--accent-mint);
}

.chat-status {
  max-width: 860px;
  margin: 8px auto 0;
}

::-webkit-scrollbar {
  width: 5px;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 10px;
}

@media (max-width: 920px) {
  .home-layout {
    grid-template-columns: 1fr;
    padding: 40px 0;
  }

  .chat-page {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .history-list {
    max-height: 190px;
  }

  .chat-header {
    flex-direction: column;
    align-items: stretch;
  }

  .main-chat {
    min-height: 0;
    height: auto;
  }
}

@media (max-width: 620px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav-links {
    width: 100%;
  }

  .nav-links a {
    flex: 1;
    justify-content: center;
  }

  .auth-card,
  .reg-card {
    padding: 24px;
  }

  .messages-container {
    padding: 22px 16px;
  }

  .message {
    max-width: 100%;
  }

  .input-area {
    padding: 16px;
  }
}
