:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --danger: #dc2626;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #eef4ff, var(--bg));
  color: var(--text);
}

.page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.card, .chat-shell {
  width: min(920px, 100%);
  background: rgba(255, 255, 255, .94);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, .10);
}

.home-card { max-width: 560px; padding: 36px; }
.brand {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  margin-bottom: 20px;
}

h1 { margin: 0 0 10px; font-size: clamp(28px, 5vw, 42px); }
.muted { color: var(--muted); margin: 0 0 28px; line-height: 1.55; }
code { background: #f3f4f6; border: 1px solid var(--border); padding: 2px 6px; border-radius: 8px; }

.form { display: grid; gap: 18px; }
label { display: grid; gap: 8px; font-weight: 650; }
small { color: var(--muted); font-weight: 400; }
input, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 13px 14px;
  font: inherit;
  outline: none;
  background: #fff;
}
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(37, 99, 235, .12); }
button, .button-link {
  border: 0;
  border-radius: 14px;
  padding: 13px 18px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 750;
  text-decoration: none;
  display: inline-flex;
  justify-content: center;
}
button:hover, .button-link:hover { background: var(--accent-dark); }
.result, .status { min-height: 22px; color: var(--muted); margin: 0; }
.slug-row { display: flex; align-items: center; gap: 0; }
.slug-row span {
  padding: 13px 0 13px 14px;
  border: 1px solid var(--border);
  border-right: 0;
  border-radius: 14px 0 0 14px;
  color: var(--muted);
  background: #f9fafb;
  white-space: nowrap;
}
.slug-row input { border-radius: 0 14px 14px 0; }

.chat-shell {
  height: min(760px, calc(100vh - 48px));
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  overflow: hidden;
}
.chat-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 24px;
  border-bottom: 1px solid var(--border);
}
.chat-header h1 { font-size: 28px; margin-bottom: 4px; }
.chat-header p { margin: 0; color: var(--muted); }
.eyebrow { color: var(--accent); font-weight: 800; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; }
.messages {
  overflow: auto;
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.message {
  padding: 14px 16px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 18px;
  max-width: 760px;
}
.message-meta {
  display: flex;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 6px;
}
.message-meta span { color: var(--muted); font-size: 13px; }
.message p { margin: 0; white-space: pre-wrap; line-height: 1.45; }
.message p a { color: var(--accent); font-weight: 650; text-decoration: underline; text-underline-offset: 2px; word-break: break-word; }
.message-form {
  border-top: 1px solid var(--border);
  padding: 18px 24px;
  display: grid;
  grid-template-columns: 180px 1fr auto;
  gap: 12px;
  align-items: start;
}
.message-form textarea { min-height: 48px; max-height: 140px; resize: vertical; }
.status { padding: 0 24px 18px; }
.error { color: var(--danger); }

@media (max-width: 720px) {
  .page { padding: 12px; align-items: stretch; }
  .home-card { padding: 24px; }
  .chat-shell { height: calc(100vh - 24px); border-radius: 18px; }
  .chat-header { flex-direction: column; padding: 18px; }
  .messages { padding: 16px; }
  .message-form { grid-template-columns: 1fr; padding: 16px; }
  .slug-row { display: grid; }
  .slug-row span { border-right: 1px solid var(--border); border-radius: 14px 14px 0 0; }
  .slug-row input { border-radius: 0 0 14px 14px; }
}
