:root {
  --bg: #f4f1ea;
  --panel: #fffdfa;
  --panel-muted: #f7f1e6;
  --line: #ddd1bb;
  --text: #1d1a16;
  --muted: #6d6458;
  --accent: #7d4e24;
  --accent-soft: #efe1cf;
  --nav: #201f1b;
  --nav-text: #f4efe7;
  --ok: #24613e;
  --warn: #8b5d12;
  --err: #9e2f2f;
  --shadow: 0 18px 45px rgba(49, 37, 20, 0.08);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  background:
    radial-gradient(circle at top left, rgba(199, 161, 108, 0.18), transparent 24%),
    linear-gradient(180deg, #f6f1e8 0%, #efe7da 100%);
}

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

a:hover {
  text-decoration: underline;
}

code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

pre {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.85rem 0.95rem;
  background: #fff;
  color: var(--text);
}

textarea {
  resize: vertical;
  min-height: 120px;
}

label {
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.button {
  border: 0;
  border-radius: 999px;
  padding: 0.85rem 1.25rem;
  cursor: pointer;
  background: var(--accent);
  color: #fff8ef;
  font-weight: 700;
}

.button--secondary {
  background: #2f5146;
}

.button--ghost {
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  grid-template-rows: 68px minmax(0, 1fr);
  grid-template-areas:
    "topbar topbar"
    "sidebar workspace";
}

.topbar {
  grid-area: topbar;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 1.25rem;
  background: rgba(30, 24, 18, 0.96);
  color: var(--nav-text);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.topbar__brand,
.topbar__meta {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #c99656, #8a5629);
  display: grid;
  place-items: center;
  color: white;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.brand-eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.62);
}

.brand-title {
  font-size: 1rem;
  font-weight: 700;
}

.user-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.12rem;
}

.user-chip__name {
  font-size: 0.92rem;
  font-weight: 700;
}

.user-chip__role {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.65);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sidebar {
  grid-area: sidebar;
  background: var(--nav);
  color: var(--nav-text);
  padding: 1.2rem 1rem;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-group + .sidebar-group {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-group__label {
  margin-bottom: 0.6rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.48);
}

.sidebar-nav {
  display: grid;
  gap: 0.45rem;
}

.sidebar-link {
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  color: rgba(255, 255, 255, 0.82);
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.sidebar-link:hover,
.sidebar-link.is-active {
  text-decoration: none;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  transform: translateX(2px);
}

.workspace {
  grid-area: workspace;
  padding: 1.5rem;
  overflow: auto;
}

.workspace-header {
  margin-bottom: 1.25rem;
}

.workspace-header h1 {
  margin: 0 0 0.35rem;
  font-size: clamp(1.8rem, 2.4vw, 2.4rem);
}

.workspace-header p {
  margin: 0;
  max-width: 760px;
  color: var(--muted);
}

.panel,
.message-card {
  background: var(--panel);
  border: 1px solid rgba(128, 102, 71, 0.14);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel {
  padding: 1.2rem 1.2rem 1.3rem;
}

.panel + .panel {
  margin-top: 1rem;
}

.panel__header {
  margin-bottom: 1rem;
}

.panel__header h2,
.message-card h2 {
  margin: 0 0 0.35rem;
  font-size: 1.18rem;
}

.panel__header p,
.message-card p {
  margin: 0;
  color: var(--muted);
}

.panel-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel-grid--ask {
  align-items: start;
}

.stack-form {
  display: grid;
  gap: 0.8rem;
}

.inline-form,
.inline-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.inline-form input,
.inline-form select {
  min-width: 220px;
}

.message-stack {
  display: grid;
  gap: 0.9rem;
  margin-bottom: 1rem;
}

.message-card {
  padding: 1rem 1.1rem;
}

.message-card--ok {
  border-left: 5px solid var(--ok);
}

.message-card--warn {
  border-left: 5px solid var(--warn);
}

.message-card--err {
  border-left: 5px solid var(--err);
}

.message-card--info {
  border-left: 5px solid #456a84;
}

.compact {
  margin-top: 1rem;
}

.callout {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  border-radius: 14px;
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
}

.callout--ok {
  background: rgba(36, 97, 62, 0.1);
  color: var(--ok);
}

.callout--warn {
  background: rgba(139, 93, 18, 0.12);
  color: var(--warn);
}

.rich-answer,
.chat-bubble__body {
  line-height: 1.65;
}

.source-list ul,
.chat-bubble__sources ul,
.validation-block ul {
  margin: 0.6rem 0 0;
  padding-left: 1.2rem;
}

.list-stack {
  display: grid;
  gap: 0.7rem;
  margin-top: 1rem;
}

.list-card {
  display: grid;
  gap: 0.25rem;
  padding: 0.9rem 1rem;
  border-radius: 14px;
  background: var(--panel-muted);
  border: 1px solid rgba(128, 102, 71, 0.1);
}

.list-card.is-active {
  border-color: rgba(125, 78, 36, 0.38);
  background: #f4e8d8;
}

.list-card span {
  color: var(--muted);
  font-size: 0.9rem;
}

.chat-thread {
  display: grid;
  gap: 0.95rem;
  margin-top: 1rem;
}

.chat-bubble {
  border-radius: 16px;
  padding: 1rem;
  border: 1px solid rgba(128, 102, 71, 0.14);
}

.chat-bubble--user {
  background: #f7efe4;
}

.chat-bubble--assistant {
  background: #fffdf9;
}

.chat-bubble__label {
  margin-bottom: 0.5rem;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.chat-bubble__sources {
  margin-top: 0.9rem;
  padding-top: 0.8rem;
  border-top: 1px solid rgba(128, 102, 71, 0.12);
}

.field-grid,
.output-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.output-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 1rem;
}

.output-panel,
.validation-block,
.empty-state {
  border-radius: 16px;
  background: var(--panel-muted);
  padding: 1rem;
}

.validation-block--err {
  border: 1px solid rgba(158, 47, 47, 0.22);
}

.validation-block--warn {
  border: 1px solid rgba(139, 93, 18, 0.22);
}

.score-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  font-size: 0.9rem;
  font-weight: 700;
}

.score-approve {
  background: rgba(36, 97, 62, 0.12);
  color: var(--ok);
}

.score-revise-minor {
  background: rgba(139, 93, 18, 0.14);
  color: var(--warn);
}

.score-revise-major {
  background: rgba(158, 47, 47, 0.12);
  color: var(--err);
}

.info-list {
  display: grid;
  gap: 0.8rem;
}

.compact-gap {
  margin: 1rem 0;
}

.info-row {
  display: grid;
  gap: 0.2rem;
}

.info-row strong {
  font-size: 0.88rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.subtle-note {
  margin-top: 1rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.login-shell {
  width: min(100%, 460px);
}

.login-panel {
  background: rgba(255, 250, 244, 0.92);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(128, 102, 71, 0.15);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 2rem;
}

.login-panel__eyebrow {
  margin-bottom: 0.85rem;
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.login-panel h1 {
  margin: 0 0 0.6rem;
  font-size: 2rem;
}

.login-panel p {
  margin: 0 0 1.15rem;
  color: var(--muted);
}

@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 68px auto 1fr;
    grid-template-areas:
      "topbar"
      "sidebar"
      "workspace";
  }

  .sidebar {
    padding-bottom: 0.9rem;
  }

  .panel-grid,
  .field-grid,
  .output-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 0 0.9rem;
  }

  .topbar__meta {
    gap: 0.5rem;
  }

  .user-chip {
    display: none;
  }

  .workspace {
    padding: 1rem;
  }

  .panel,
  .message-card {
    padding: 1rem;
  }
}
