:root {
  --bg: #efe8dd;
  --panel: rgba(255, 251, 245, 0.92);
  --ink: #221b15;
  --muted: #6f6559;
  --accent: #a34b19;
  --accent-soft: #ecd2bf;
  --line: #dac4af;
  --ok: #1f6b48;
  --ok-soft: #d7f0e2;
  --error: #8a2b2b;
  --error-soft: #f4d7d7;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 245, 232, 0.9), transparent 28%),
    linear-gradient(180deg, #f6efe6 0%, #eadbcc 100%);
}

.shell {
  display: grid;
  grid-template-columns: 380px 1fr;
  min-height: 100vh;
}

.sidebar {
  padding: 22px;
  border-right: 1px solid var(--line);
  background: rgba(255, 248, 239, 0.92);
  backdrop-filter: blur(14px);
  overflow: auto;
}

.main {
  padding: 24px;
}

h1,
h2 {
  margin: 0 0 12px;
}

.muted {
  color: var(--muted);
  line-height: 1.5;
}

.small {
  font-size: 13px;
}

.field,
.checkbox {
  display: block;
  margin: 18px 0;
}

.field span {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  color: var(--muted);
}

textarea,
input,
button {
  font: inherit;
}

textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fffdf9;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 12px 16px;
  background: var(--ink);
  color: white;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease;
}

button:hover {
  transform: translateY(-1px);
  opacity: 0.95;
}

button.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.button-grid,
.button-stack {
  display: grid;
  gap: 10px;
}

.button-grid {
  grid-template-columns: 1fr 1fr;
}

.button-stack {
  grid-template-columns: 1fr;
  margin-top: 14px;
}

.status-card,
.chat-card,
.notice {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: 0 18px 60px rgba(84, 50, 22, 0.08);
}

.status-card {
  margin-top: 18px;
  padding: 16px;
}

.auth-summary p {
  margin: 0 0 8px;
  line-height: 1.45;
}

pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
}

.evidence-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.evidence-list a {
  color: var(--accent);
  text-decoration: none;
}

.notice {
  margin-bottom: 16px;
  padding: 14px 16px;
}

.notice.success {
  background: var(--ok-soft);
  border-color: rgba(31, 107, 72, 0.25);
  color: var(--ok);
}

.notice.error {
  background: var(--error-soft);
  border-color: rgba(138, 43, 43, 0.25);
  color: var(--error);
}

.chat-card {
  height: calc(100vh - 48px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
}

.chat-header {
  padding: 20px 20px 0;
}

.messages {
  padding: 20px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message {
  max-width: 82%;
  padding: 14px 16px;
  border-radius: 18px;
  white-space: pre-wrap;
  line-height: 1.45;
}

.message.user {
  align-self: flex-end;
  background: var(--ink);
  color: white;
}

.message.assistant {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--line);
}

.message.system {
  align-self: center;
  background: var(--accent-soft);
}

.message.error {
  align-self: center;
  background: var(--error-soft);
  color: var(--error);
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 18px;
  border-top: 1px solid var(--line);
}

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .chat-card {
    height: auto;
    min-height: 70vh;
  }

  .button-grid {
    grid-template-columns: 1fr;
  }
}
