:root {
  color-scheme: light;
  --background: #f4f7fb;
  --panel: #ffffff;
  --panel-border: #dbe3ee;
  --text: #172033;
  --muted: #68758a;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bot-bubble: #eef4ff;
  --user-bubble: #172033;
  --shadow: 0 24px 70px rgba(23, 32, 51, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.14), transparent 34rem),
    linear-gradient(135deg, #f8fafc 0%, var(--background) 100%);
}

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

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

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

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

h1 {
  margin: 6px 0 0;
  font-size: clamp(1.7rem, 4vw, 2.5rem);
  line-height: 1;
  letter-spacing: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  padding: 9px 12px;
  border: 1px solid #b9e8cb;
  border-radius: 999px;
  color: #166534;
  background: #ecfdf3;
  font-size: 0.9rem;
  font-weight: 700;
}

.status-pill span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.16);
}

.chat-window {
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  padding: 28px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.74), rgba(255, 255, 255, 0.74)),
    repeating-linear-gradient(0deg, transparent 0, transparent 31px, rgba(219, 227, 238, 0.52) 32px);
}

.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: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
  text-align: center;
}

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

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

.avatar {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: 0 0 38px;
  border-radius: 50%;
  color: #ffffff;
  background: var(--primary);
  font-weight: 800;
}

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

.message-content {
  padding: 14px 16px;
  border-radius: 8px;
  border: 1px solid #d6e4fb;
  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.5;
}

.message-content a {
  color: var(--primary);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

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

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

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

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

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

textarea {
  width: 100%;
  min-height: 58px;
  max-height: 160px;
  resize: none;
  padding: 14px 16px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  color: var(--text);
  background: #f8fafc;
  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(37, 99, 235, 0.12);
}

button {
  min-height: 58px;
  padding: 0 24px;
  border: 0;
  border-radius: 8px;
  color: #ffffff;
  background: var(--primary);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease;
}

button:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

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

button:disabled {
  cursor: not-allowed;
  color: rgba(255, 255, 255, 0.85);
  background: #94a3b8;
  opacity: 1;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
  transform: none;
}

button:disabled:hover {
  background: #94a3b8;
  transform: none;
}

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

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

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

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

  .message {
    max-width: 100%;
  }

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

  button {
    width: 100%;
  }
}
