:root {
  --bg: #f6f1e8;
  --bg-strong: #ece3d5;
  --card: rgba(255, 250, 244, 0.82);
  --line: rgba(54, 40, 23, 0.12);
  --text: #24180d;
  --muted: #6f5e4d;
  --accent: #0f6b5c;
  --accent-soft: #d7f0e8;
  --warning: #b04b2f;
  --shadow: 0 24px 80px rgba(45, 31, 19, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(209, 228, 216, 0.7), transparent 28%),
    radial-gradient(circle at top right, rgba(238, 211, 190, 0.65), transparent 24%),
    linear-gradient(180deg, #f9f4ee 0%, #f2eadf 100%);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea {
  font: inherit;
}

.page-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.hero-card,
.sidebar-card,
.chat-card,
.panel-card {
  background: var(--card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.hero-card {
  display: grid;
  gap: 24px;
  grid-template-columns: 1.6fr 0.9fr;
  padding: 32px;
  animation: fade-up 0.5s ease;
}

.hero-card.compact {
  grid-template-columns: 1.55fr 0.8fr;
}

.hero-copy h1 {
  margin: 6px 0 12px;
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
  font-size: clamp(2.3rem, 4vw, 4rem);
  line-height: 0.96;
  letter-spacing: -0.04em;
}

.hero-copy p,
.sidebar-note,
.helper-text,
.document-card p,
.message-bubble p {
  color: var(--muted);
  line-height: 1.6;
}

.message-bubble p {
  white-space: pre-wrap;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.hero-meta,
.stats-grid {
  display: grid;
  gap: 12px;
}

.stats-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.meta-tile,
.stat-card,
.citation-card,
.document-card,
.prompt-card {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.48);
}

.meta-tile,
.stat-card {
  padding: 16px;
}

.meta-tile small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.5;
}

.meta-tile span,
.stat-card span,
.message-head small,
.document-head span {
  color: var(--muted);
  font-size: 0.9rem;
}

.meta-tile strong,
.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 1.2rem;
  line-height: 1.25;
}

.workspace-grid,
.admin-grid {
  display: grid;
  gap: 24px;
  margin-top: 24px;
}

.app-credit {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 24px;
  padding: 14px 18px 0;
  color: var(--muted);
  font-size: 0.92rem;
  letter-spacing: 0.01em;
}

.app-credit a {
  color: #4897b1;
  font-weight: 700;
  transition: opacity 0.2s ease;
}

.app-credit a:hover {
  opacity: 0.78;
}

.workspace-grid {
  grid-template-columns: 0.88fr 1.32fr;
}

.admin-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.admin-workspace {
  grid-template-columns: minmax(0, 1.18fr) minmax(300px, 0.82fr);
  align-items: start;
}

.sidebar-card,
.chat-card,
.panel-card {
  padding: 24px;
}

.admin-main-stack,
.admin-side-stack,
.prompt-grid,
.document-grid,
.citation-list,
.form-stack,
.debug-list,
.tag-row,
.field-grid,
.field-group,
.info-grid {
  display: grid;
  gap: 12px;
}

.admin-main-stack,
.admin-side-stack {
  gap: 24px;
}

.chat-side-stack {
  display: grid;
  gap: 24px;
}

.field-grid.two-col,
.info-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.info-grid.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.prompt-card {
  padding: 16px;
  text-align: left;
  width: 100%;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.prompt-card strong,
.prompt-card small {
  display: block;
}

.prompt-card strong {
  margin-bottom: 6px;
}

.prompt-card small {
  color: var(--muted);
  line-height: 1.55;
}

.prompt-card:hover,
.primary-button:hover,
.ghost-button:hover,
.secondary-button:hover {
  transform: translateY(-1px);
}

.chat-card {
  display: grid;
  gap: 18px;
  min-height: 720px;
}

.chat-panel-head + .helper-text {
  margin-top: -4px;
}

.chat-scroll {
  display: grid;
  gap: 14px;
  align-content: start;
}

.message-bubble {
  max-width: 100%;
  padding: 18px;
  border-radius: 24px;
  border: 1px solid var(--line);
  animation: fade-up 0.35s ease;
}

.message-bubble.user {
  background: linear-gradient(135deg, #f0dfca, #f8efe3);
}

.message-bubble.assistant {
  background: linear-gradient(135deg, #f8fbfa, #edf7f3);
}

.message-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-weight: 600;
}

.message-notice {
  display: grid;
  gap: 4px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed rgba(54, 40, 23, 0.14);
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.message-notice-label {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.message-copy {
  color: var(--text);
  line-height: 1.72;
}

.composer {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.composer-input,
.form-stack input,
.form-stack textarea,
.field-group input,
.field-group textarea,
.admin-textarea {
  width: 100%;
  border: 1px solid rgba(54, 40, 23, 0.16);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--text);
  padding: 16px 18px;
  resize: vertical;
}

.composer-row,
.section-head,
.document-head,
.document-meta-row,
.panel-intro,
.action-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.helper-stack,
.composer-actions {
  display: grid;
  gap: 8px;
}

.composer-actions {
  grid-auto-flow: column;
  align-items: center;
}

.composer-actions-wrap {
  align-items: flex-end;
}

.panel-intro {
  align-items: flex-start;
}

.panel-intro h2 {
  margin: 6px 0 0;
}

.field-label {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.primary-button,
.ghost-button,
.secondary-button,
.danger-button {
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.primary-button {
  background: linear-gradient(135deg, #0f6b5c, #0d5347);
  color: #f9f7f2;
  padding: 14px 22px;
  font-weight: 600;
}

.ghost-button {
  background: transparent;
  color: var(--accent);
  padding: 0;
  justify-self: start;
}

.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 18px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
  color: var(--text);
  font-weight: 600;
}

.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  background: rgba(176, 75, 47, 0.12);
  border: 1px solid rgba(176, 75, 47, 0.16);
  color: var(--warning);
  font-weight: 700;
}

.link-button {
  text-decoration: none;
}

.primary-button:disabled,
.secondary-button:disabled,
.danger-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 0.84rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill.ready {
  background: var(--accent-soft);
  border-color: rgba(15, 107, 92, 0.16);
  color: var(--accent);
}

.status-pill.warning {
  background: rgba(251, 231, 224, 0.92);
  border-color: rgba(176, 75, 47, 0.16);
  color: var(--warning);
}

.status-pill.idle {
  background: rgba(255, 255, 255, 0.76);
  color: var(--muted);
}

.error-text {
  color: var(--warning);
  margin: 8px 0 0;
}

.admin-stats-grid {
  margin-top: 8px;
}

.document-list {
  margin-top: 24px;
}

.document-grid {
  grid-template-columns: 1fr;
  margin-top: 18px;
}

.document-group,
.monitor-grid {
  display: grid;
  gap: 16px;
}

.document-group-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.document-group-head h3 {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
}

.document-group-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.document-card,
.citation-card,
.debug-card,
.admin-user-card {
  padding: 16px;
}

.document-card {
  display: grid;
  gap: 14px;
}

.admin-user-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.54);
}

.debug-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.54);
}

.log-tail-card p {
  margin: 0;
  font-family: "SFMono-Regular", "Menlo", monospace;
  font-size: 0.8rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.document-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.document-head h3,
.panel-card h2,
.sidebar-card h2,
.section-head h2 {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
}

.tag-row {
  grid-template-columns: repeat(auto-fit, minmax(88px, max-content));
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.84rem;
}

.accent-panel {
  background:
    radial-gradient(circle at top right, rgba(15, 107, 92, 0.18), transparent 36%),
    linear-gradient(180deg, rgba(252, 249, 244, 0.96), rgba(242, 236, 228, 0.92));
}

.feature-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.7;
}

.feature-list li + li {
  margin-top: 8px;
}

.empty-state {
  margin-top: 18px;
  padding: 18px;
  border: 1px dashed rgba(54, 40, 23, 0.2);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.42);
  color: var(--muted);
}

.empty-state[hidden] {
  display: none;
}

.empty-state.compact {
  margin-top: 0;
  padding: 14px;
  border-radius: 20px;
}

.document-source-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(15, 107, 92, 0.08);
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: capitalize;
}

.document-timestamp {
  color: var(--muted);
  font-size: 0.84rem;
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 960px) {
  .hero-card,
  .hero-card.compact,
  .workspace-grid,
  .admin-grid,
  .document-grid,
  .document-group-grid,
  .admin-workspace {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .field-grid.two-col,
  .info-grid,
  .info-grid.compact {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 640px) {
  .page-shell {
    width: min(100% - 20px, 100%);
    padding: 16px 0 36px;
  }

  .hero-card,
  .sidebar-card,
  .chat-card,
  .panel-card {
    border-radius: 22px;
    padding: 18px;
  }

  .composer-row,
  .section-head,
  .document-head,
  .document-meta-row,
  .panel-intro,
  .action-row {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .primary-button,
  .secondary-button {
    width: 100%;
  }

  .composer-actions {
    width: 100%;
    grid-auto-flow: row;
  }

  .danger-button {
    width: 100%;
  }

  .app-credit {
    justify-content: flex-start;
    padding-left: 6px;
  }
}
