:root {
  --bg: #020617;
  --panel: rgba(6, 18, 36, 0.72);
  --panel-strong: rgba(8, 24, 47, 0.9);
  --text: #f8fafc;
  --muted: #a9b6c8;
  --blue: #0ea5e9;
  --tiffany: #2dd4bf;
  --yellow: #f8c843;
  --line: rgba(255, 255, 255, 0.13);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.46);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  color: var(--text);
  font-family: "Inter", Arial, sans-serif;
  background:
    linear-gradient(rgba(2, 6, 23, 0.58), rgba(2, 6, 23, 0.7)),
    url("/bac.png"),
    radial-gradient(circle at 20% 28%, rgba(14, 165, 233, 0.24), transparent 36%),
    radial-gradient(circle at 82% 74%, rgba(45, 212, 191, 0.2), transparent 38%),
    linear-gradient(140deg, #020617, #03101f 48%, #020617);
  background-position: center;
  background-size: cover;
  background-attachment: fixed;
  overflow: hidden;
}

button,
textarea,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.login-screen {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 22px;
}

.login-card {
  position: relative;
  overflow: hidden;
  width: min(430px, 100%);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px) saturate(145%);
  animation: fadeUp 0.35s ease both;
}

.login-card::before {
  content: "";
  position: absolute;
  inset: -80% -40%;
  background: linear-gradient(120deg, transparent, rgba(255, 255, 255, 0.16), transparent);
  transform: rotate(25deg);
  animation: glassShine 6s linear infinite;
  pointer-events: none;
}

.login-logo {
  position: relative;
  display: block;
  width: 92px;
  height: 92px;
  object-fit: contain;
  margin: 0 auto 18px;
  filter: drop-shadow(0 0 18px rgba(45, 212, 191, 0.5));
  animation: logoGlow 4s ease-in-out infinite;
}

.login-card h1,
.login-card .eyebrow,
.login-card .login-subtitle,
.login-card label,
.login-card input,
.login-card button,
.login-error {
  position: relative;
}

.login-card h1,
.login-subtitle {
  text-align: center;
}

.login-subtitle {
  margin: 10px 0 24px;
  color: var(--muted);
  line-height: 1.5;
}

.login-card label {
  display: block;
  margin: 14px 0 8px;
  color: #dcecff;
  font-size: 0.9rem;
  font-weight: 800;
}

.login-card input {
  width: 100%;
  min-height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  outline: none;
  padding: 13px 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.login-card input:focus {
  border-color: rgba(45, 212, 191, 0.7);
  box-shadow: 0 0 0 4px rgba(45, 212, 191, 0.12);
}

.login-card button {
  width: 100%;
  min-height: 50px;
  margin-top: 18px;
  border: 0;
  border-radius: 8px;
  color: #03101f;
  font-weight: 900;
  background: linear-gradient(135deg, var(--yellow), var(--tiffany));
  box-shadow: 0 0 24px rgba(248, 200, 67, 0.18);
  transition: transform 0.18s ease, filter 0.18s ease;
}

.login-card button:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.login-error {
  margin: 12px 0 0;
  color: #ffd2d2;
  font-size: 0.9rem;
}

.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(0, 900px);
  gap: 22px;
  width: min(1240px, calc(100vw - 36px));
  height: min(900px, calc(100vh - 36px));
  margin: 18px auto;
}

.sidebar,
.chat-panel {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px) saturate(145%);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 24px;
  border-radius: 8px;
  overflow: hidden;
}

.brand {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 14px;
  align-items: center;
}

.brand-logo {
  width: 74px;
  height: 74px;
  object-fit: contain;
  filter: drop-shadow(0 0 18px rgba(45, 212, 191, 0.5));
  animation: logoGlow 4s ease-in-out infinite;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--yellow);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-family: "Orbitron", "Inter", sans-serif;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.55rem, 4vw, 2.35rem);
  background: linear-gradient(90deg, var(--blue), var(--tiffany), var(--yellow));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.status-panel {
  position: relative;
  overflow: hidden;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.status-panel::before {
  content: "";
  position: absolute;
  inset: -80% -40%;
  background: linear-gradient(120deg, transparent, rgba(255, 255, 255, 0.17), transparent);
  transform: rotate(25deg);
  animation: glassShine 6s linear infinite;
}

.status-panel p {
  position: relative;
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.status-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}

.pulse {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--tiffany);
  box-shadow: 0 0 18px var(--tiffany);
  animation: pulse 1.5s ease-in-out infinite;
}

.capabilities {
  display: grid;
  gap: 10px;
}

.capabilities span {
  display: block;
  padding: 13px 14px;
  border: 1px solid rgba(14, 165, 233, 0.25);
  border-radius: 8px;
  color: #dcecff;
  background: rgba(14, 165, 233, 0.09);
}

.conversation-area {
  min-height: 0;
  display: grid;
  gap: 10px;
}

.conversation-title {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.conversation-list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
}

.conversation-item {
  width: 100%;
  min-height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: #dcecff;
  background: rgba(255, 255, 255, 0.055);
  padding: 9px 10px;
  text-align: left;
  font-size: 0.86rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-item:hover,
.conversation-item.is-active {
  border-color: rgba(45, 212, 191, 0.55);
  background: rgba(45, 212, 191, 0.11);
}

.clear-button {
  margin-top: auto;
  min-height: 46px;
  border: 1px solid rgba(248, 200, 67, 0.42);
  border-radius: 8px;
  color: var(--yellow);
  background: rgba(248, 200, 67, 0.08);
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.clear-button:hover {
  transform: translateY(-1px);
  border-color: rgba(248, 200, 67, 0.78);
  background: rgba(248, 200, 67, 0.14);
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  border-radius: 8px;
  overflow: hidden;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  min-height: 92px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(2, 6, 23, 0.34);
}

.chat-header h2 {
  font-size: clamp(1.45rem, 3vw, 2rem);
}

.model-badge {
  padding: 9px 12px;
  border: 1px solid rgba(45, 212, 191, 0.36);
  border-radius: 999px;
  color: var(--tiffany);
  background: rgba(45, 212, 191, 0.1);
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
}

.messages {
  min-height: 0;
  padding: 24px;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.message {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin: 0 0 18px;
  animation: fadeUp 0.28s ease both;
}

.user-message {
  justify-content: flex-end;
}

.assistant-message {
  position: relative;
}

.avatar {
  display: grid;
  place-items: center;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  color: #02111f;
  font-weight: 900;
  background: linear-gradient(135deg, var(--blue), var(--tiffany));
  box-shadow: 0 0 20px rgba(14, 165, 233, 0.35);
}

.assistant-avatar {
  overflow: hidden;
  background: rgba(255, 255, 255, 0.92);
}

.assistant-avatar img {
  width: 82%;
  height: 82%;
  object-fit: contain;
  filter: drop-shadow(0 0 6px rgba(14, 165, 233, 0.35));
}

.user-message .avatar {
  order: 2;
  color: #111827;
  background: linear-gradient(135deg, var(--yellow), #fff0a3);
}

.bubble {
  max-width: min(680px, 78%);
  padding: 15px 16px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 8px;
  color: #ecf7ff;
  line-height: 1.6;
  white-space: pre-wrap;
  background: rgba(7, 20, 42, 0.78);
}

.user-message .bubble {
  color: #07111d;
  border-color: rgba(248, 200, 67, 0.5);
  background: linear-gradient(135deg, #f8c843, #ffe98a);
}

.audio-button {
  align-self: flex-end;
  min-width: 58px;
  min-height: 30px;
  border: 1px solid rgba(45, 212, 191, 0.38);
  border-radius: 8px;
  color: var(--tiffany);
  background: rgba(45, 212, 191, 0.1);
  font-size: 0.72rem;
  font-weight: 900;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.audio-button:hover {
  transform: translateY(-1px);
  border-color: rgba(45, 212, 191, 0.75);
  background: rgba(45, 212, 191, 0.16);
}

.audio-button.is-speaking {
  color: #03101f;
  border-color: rgba(248, 200, 67, 0.85);
  background: linear-gradient(135deg, var(--yellow), var(--tiffany));
  animation: audioPulse 1s ease-in-out infinite;
}

.thinking {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 24px 12px;
  color: var(--muted);
  font-size: 0.92rem;
}

.thinking-logo {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 0 18px rgba(45, 212, 191, 0.42);
  animation: thinkingPulse 1.15s ease-in-out infinite;
}

.thinking-logo img {
  width: 82%;
  height: 82%;
  object-fit: contain;
}

.dot-loader {
  display: inline-flex;
  gap: 4px;
}

.dot-loader i {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--tiffany);
  animation: dots 1s ease-in-out infinite;
}

.dot-loader i:nth-child(2) {
  animation-delay: 0.15s;
}

.dot-loader i:nth-child(3) {
  animation-delay: 0.3s;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 18px;
  border-top: 1px solid var(--line);
  background: rgba(2, 6, 23, 0.5);
}

.composer textarea {
  width: 100%;
  max-height: 150px;
  min-height: 50px;
  resize: none;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  outline: none;
  padding: 14px 15px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.composer textarea:focus {
  border-color: rgba(45, 212, 191, 0.7);
  box-shadow: 0 0 0 4px rgba(45, 212, 191, 0.12);
}

.composer button {
  min-width: 112px;
  min-height: 50px;
  border: 0;
  border-radius: 8px;
  color: #03101f;
  font-weight: 900;
  background: linear-gradient(135deg, var(--yellow), var(--tiffany));
  box-shadow: 0 0 24px rgba(248, 200, 67, 0.18);
  transition: transform 0.18s ease, filter 0.18s ease;
}

.composer button:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.composer button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  transform: none;
}

@keyframes logoGlow {
  0%,
  100% {
    filter: drop-shadow(0 0 14px rgba(14, 165, 233, 0.45));
  }
  50% {
    filter: drop-shadow(0 0 24px rgba(45, 212, 191, 0.65));
  }
}

@keyframes glassShine {
  0% {
    transform: translateX(-55%) rotate(25deg);
    opacity: 0;
  }
  50% {
    opacity: 0.55;
  }
  100% {
    transform: translateX(55%) rotate(25deg);
    opacity: 0;
  }
}

@keyframes pulse {
  50% {
    transform: scale(1.2);
    opacity: 0.72;
  }
}

@keyframes fadeUp {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes dots {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

@keyframes thinkingPulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 0 14px rgba(14, 165, 233, 0.34);
  }
  50% {
    transform: scale(1.1);
    box-shadow: 0 0 26px rgba(45, 212, 191, 0.68);
  }
}

@keyframes audioPulse {
  50% {
    transform: translateY(-1px) scale(1.04);
    box-shadow: 0 0 18px rgba(248, 200, 67, 0.32);
  }
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    width: min(100vw - 24px, 720px);
    height: calc(100vh - 24px);
    margin: 12px auto;
  }

  .sidebar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 14px;
  }

  .status-panel,
  .capabilities,
  .conversation-area {
    display: none;
  }

  .chat-panel {
    min-height: 0;
  }

  .messages {
    padding: 18px;
  }

  .bubble {
    max-width: 84%;
  }

  .clear-button {
    width: 118px;
    margin-top: 0;
  }
}

@media (max-width: 560px) {
  .brand {
    grid-template-columns: 58px 1fr;
  }

  .brand-logo {
    width: 58px;
    height: 58px;
  }

  .chat-header {
    min-height: 78px;
    padding: 16px;
  }

  .model-badge {
    display: none;
  }

  .composer {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .composer button {
    width: 100%;
  }

  .bubble {
    max-width: calc(100vw - 104px);
    font-size: 0.95rem;
  }

  .assistant-message {
    flex-wrap: wrap;
  }

  .audio-button {
    margin-left: 48px;
  }
}
