:root {
  color-scheme: light;
  --background: #eef1fb;
  --panel: #ffffff;
  --panel-border: #e2e5f5;
  --text: #1a1c33;
  --muted: #6b7089;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-soft: #eef0ff;
  --bot-bubble: #f3f2ff;
  --user-bubble: #1a1c33;
  --accent: #06b6d4;
  --shadow: 0 30px 80px rgba(30, 27, 75, 0.14);
  --radius: 16px;
  --font-display: "Plus Jakarta Sans", Inter, ui-sans-serif, system-ui, sans-serif;
  --font-body: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(circle at 12% 8%, rgba(79, 70, 229, 0.16), transparent 38rem),
    radial-gradient(circle at 88% 92%, rgba(6, 182, 212, 0.14), transparent 40rem),
    linear-gradient(160deg, #f7f8ff 0%, var(--background) 100%);
}

.chat-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.chat-panel {
  width: min(980px, 100%);
  height: min(780px, calc(100vh - 56px));
  min-height: 560px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 30px;
  border-bottom: 1px solid var(--panel-border);
  background: var(--panel);
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  border-radius: 14px;
  font-size: 1.4rem;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 10px 24px rgba(79, 70, 229, 0.35);
}

.eyebrow,
.message-name {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

h1 {
  margin: 2px 0 0;
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3.4vw, 2.1rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.back-button {
  min-height: 42px;
  padding: 0 18px;
  flex: 0 0 auto;
  color: var(--text);
  background: var(--primary-soft);
  font-size: 0.9rem;
}

.back-button:hover {
  background: #e0e2fb;
}

.start-screen {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 26px;
  overflow-y: auto;
  background: linear-gradient(180deg, rgba(238, 240, 255, 0.5), transparent 200px);
}

.mode-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px 22px;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(30, 27, 75, 0.05);
  transition: box-shadow 160ms ease, transform 160ms ease;
}

.mode-card:hover {
  box-shadow: 0 14px 32px rgba(30, 27, 75, 0.09);
  transform: translateY(-1px);
}

.mode-card-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  text-align: left;
}

.mode-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: 12px;
  font-size: 1.15rem;
  background: var(--primary-soft);
}

.mode-card-head h2 {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.mode-card-head p {
  margin: 0;
  font-size: 0.86rem;
  color: var(--muted);
  font-weight: 500;
  line-height: 1.4;
}

.mode-card-divider {
  height: 1px;
  margin: 2px 0;
  background: var(--panel-border);
}

.start-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.chat-window {
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  padding: 28px 30px;
  background: linear-gradient(180deg, rgba(238, 240, 255, 0.35), transparent 160px);
}

.message {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  max-width: 78%;
}

.user-message {
  align-self: flex-end;
}

.bot-message {
  align-self: flex-start;
}

.auth-gate {
  width: min(520px, 100%);
  padding: 40px;
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: var(--shadow);
  text-align: center;
  font-family: var(--font-body);
}

.auth-gate h1 {
  margin-top: 0;
}

.login-link {
  display: inline-block;
  margin-top: 12px;
  padding: 12px 18px;
  border-radius: 10px;
  color: #fff;
  background: var(--primary);
  font-weight: 700;
  text-decoration: none;
}

.avatar {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex: 0 0 36px;
  border-radius: 50%;
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  font-weight: 700;
  font-size: 0.9rem;
}

.user-message .avatar {
  background: #0f172a;
}

.message-content {
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid #e4e2fb;
  background: var(--bot-bubble);
}

.user-message .message-content {
  color: #ffffff;
  border-color: var(--user-bubble);
  background: var(--user-bubble);
}

.message-content p {
  margin: 6px 0 0;
  line-height: 1.55;
  white-space: pre-wrap;
}

.message-content .message-name {
  margin: 0;
}

.user-message .message-name {
  color: rgba(255, 255, 255, 0.65);
}

.composer {
  padding: 18px 30px 24px;
  border-top: 1px solid var(--panel-border);
  background: var(--panel);
}

.composer label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.composer-box {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
}

textarea {
  width: 100%;
  min-height: 54px;
  max-height: 160px;
  resize: none;
  padding: 14px 16px;
  border: 1px solid #d7d9ee;
  border-radius: 12px;
  color: var(--text);
  background: #f8f8fd;
  font: inherit;
  line-height: 1.4;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

textarea:focus {
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.12);
}

button {
  min-height: 46px;
  padding: 0 22px;
  border: 0;
  border-radius: 10px;
  color: #ffffff;
  background: var(--primary);
  font: inherit;
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

button:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(79, 70, 229, 0.22);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  cursor: not-allowed;
  color: rgba(255, 255, 255, 0.85);
  background: #a3a6c2;
  opacity: 1;
  box-shadow: none;
  transform: none;
}

button:disabled:hover {
  background: #a3a6c2;
  transform: none;
}

@media (max-width: 680px) {
  .chat-shell {
    padding: 12px;
  }

  .chat-panel {
    height: calc(100vh - 24px);
    min-height: 0;
    border-radius: 16px;
  }

  .chat-header,
  .chat-window,
  .composer,
  .start-screen {
    padding-left: 18px;
    padding-right: 18px;
  }

  .chat-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
  }

  .message {
    max-width: 100%;
  }

  .composer-box {
    grid-template-columns: 1fr;
  }

  .start-buttons {
    flex-direction: column;
  }

  .start-buttons button {
    width: 100%;
  }
}
