:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #101014;
  color: #f4f4f5;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(88, 166, 255, 0.13), transparent 32rem),
    #101014;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 310px 1fr;
}

.app-shell[hidden] {
  display: none;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
}

.login-screen[hidden] {
  display: none;
}

.login-card {
  width: min(420px, 100%);
  padding: 28px;
  display: grid;
  gap: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 26px;
  background: rgba(24, 24, 27, 0.92);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.32);
}

.login-card h1,
.login-card p {
  margin: 0;
}

.login-card p {
  color: #a1a1aa;
}

.login-card label {
  display: grid;
  gap: 8px;
  color: #d4d4d8;
}

.login-card input,
.settings-card select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  outline: 0;
  background: rgba(0, 0, 0, 0.22);
  color: #f4f4f5;
}

.login-error {
  min-height: 22px;
  color: #fca5a5;
}

button,
textarea,
input {
  font: inherit;
}

button {
  border: 0;
}

.corner-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-button {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  background: rgba(24, 24, 27, 0.9);
  color: #f4f4f5;
  cursor: pointer;
  font-weight: 800;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(14px);
}

.icon-button:hover {
  background: rgba(16, 163, 127, 0.92);
}

.logout-button {
  width: auto;
  min-width: 64px;
  padding: 0 14px;
}

.logout-button:hover {
  background: rgba(239, 68, 68, 0.92);
}

.sidebar {
  min-height: 100vh;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(18, 18, 22, 0.88);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.94);
  overflow: hidden;
}

.logo img {
  width: 70%;
  height: 70%;
  object-fit: contain;
}

.brand h1,
.panel h2,
.empty-state h2 {
  margin: 0;
}

.brand p,
.panel p,
.empty-state p,
.message-meta {
  color: #a1a1aa;
}

.brand p {
  margin: 4px 0 0;
  font-size: 14px;
}

.sidebar-hint {
  margin: 0;
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  color: #a1a1aa;
  line-height: 1.8;
}

.new-chat,
.composer button {
  border: 0;
  border-radius: 14px;
  background: #10a37f;
  color: white;
  cursor: pointer;
  font-weight: 700;
  transition:
    transform 0.18s ease,
    background 0.18s ease;
}

.new-chat {
  padding: 13px 16px;
  text-align: left;
}

.new-chat:hover,
.composer button:hover {
  background: #0f8f70;
  transform: translateY(-1px);
}

.panel {
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
}

.panel h2 {
  margin-bottom: 14px;
  font-size: 15px;
}

.panel label {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  color: #d4d4d8;
  font-size: 14px;
}

.panel input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.22);
  color: #f4f4f5;
}

.api-panel code {
  display: block;
  padding: 10px 12px;
  direction: ltr;
  text-align: left;
  border-radius: 12px;
  background: #09090b;
  color: #86efac;
}

.chat-shell {
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.chat-header {
  padding: 18px 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: #d4d4d8;
}

.status-dot {
  width: 10px;
  height: 10px;
  display: inline-block;
  margin-inline-end: 8px;
  border-radius: 50%;
  background: #f59e0b;
}

.status-dot.ok {
  background: #22c55e;
}

.status-dot.error {
  background: #ef4444;
}

.messages {
  overflow-y: auto;
  padding: 34px min(8vw, 90px);
}

.empty-state {
  max-width: 640px;
  margin: 12vh auto 0;
  text-align: center;
  color: #f4f4f5;
}

.empty-icon {
  width: 62px;
  height: 62px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  border-radius: 22px;
  background: rgba(16, 163, 127, 0.16);
}

.empty-icon img {
  width: 58%;
  height: 58%;
  object-fit: contain;
}

.message {
  max-width: 900px;
  margin: 0 auto 18px;
  display: grid;
  gap: 8px;
}

.message-meta {
  font-size: 13px;
}

.bubble {
  width: fit-content;
  max-width: 88%;
  padding: 14px 16px;
  border-radius: 18px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
}

.message.user {
  justify-items: end;
}

.message.user .bubble {
  background: #10a37f;
  color: #ffffff;
  border-bottom-left-radius: 6px;
}

.message.assistant .bubble {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-bottom-right-radius: 6px;
}

.typing {
  display: inline-flex;
  gap: 5px;
}

.typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #a1a1aa;
  animation: pulse 1s infinite ease-in-out;
}

.typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing span:nth-child(3) {
  animation-delay: 0.3s;
}

.composer {
  width: min(980px, calc(100% - 42px));
  margin: 0 auto 22px;
  padding: 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 22px;
  background: rgba(24, 24, 27, 0.96);
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.28);
}

.composer textarea {
  max-height: 180px;
  min-height: 46px;
  resize: none;
  padding: 12px 14px;
  border: 0;
  outline: 0;
  background: transparent;
  color: #f4f4f5;
  line-height: 1.6;
}

.composer button {
  align-self: end;
  padding: 12px 22px;
}

.composer button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(10px);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(760px, 100%);
  max-height: min(760px, calc(100vh - 44px));
  overflow-y: auto;
  padding: 22px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  background: #18181b;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.42);
}

.wide-modal {
  width: min(980px, 100%);
}

.modal-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.modal-header h2,
.settings-card h3 {
  margin: 0;
}

.modal-header p,
.settings-card p {
  margin: 6px 0 0;
  color: #a1a1aa;
  line-height: 1.8;
}

.modal-close {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: #f4f4f5;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

.modal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.settings-card,
.api-playground {
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
}

.settings-card label,
.api-playground label {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  color: #d4d4d8;
}

.checkbox-label {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.checkbox-label input {
  width: auto;
}

.settings-card input,
.api-playground input,
.api-playground textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  outline: 0;
  background: rgba(0, 0, 0, 0.22);
  color: #f4f4f5;
}

.api-playground textarea {
  resize: vertical;
  line-height: 1.7;
}

.endpoint-code,
.code-block {
  display: block;
  width: 100%;
  overflow-x: auto;
  direction: ltr;
  text-align: left;
  white-space: pre;
  padding: 12px;
  border-radius: 12px;
  background: #09090b;
  color: #86efac;
}

.code-block {
  min-height: 150px;
  margin: 12px 0 0;
  color: #d4d4d8;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.primary-button,
.secondary-button {
  padding: 11px 16px;
  border-radius: 13px;
  color: #ffffff;
  cursor: pointer;
  font-weight: 700;
}

.primary-button {
  background: #10a37f;
}

.secondary-button {
  background: rgba(255, 255, 255, 0.1);
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

@keyframes pulse {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-4px);
  }
}

@media (max-width: 820px) {
  body {
    display: block;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    padding: 18px;
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .chat-shell {
    height: auto;
    min-height: 72vh;
  }

  .messages {
    padding: 26px 18px;
  }

  .composer {
    width: calc(100% - 24px);
  }

  .corner-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .chat-header {
    padding: 18px;
    flex-wrap: wrap;
  }

  .modal-grid {
    grid-template-columns: 1fr;
  }
}
