:root {
  --bg: #f3efe7;
  --panel: rgba(255, 252, 245, 0.92);
  --ink: #1e2430;
  --muted: #647084;
  --line: rgba(30, 36, 48, 0.12);
  --accent: #b3472f;
  --accent-dark: #7f2c1a;
  --accent-soft: rgba(179, 71, 47, 0.12);
  --success: #1a7f5a;
  --warning: #9b6a10;
  --danger: #a43125;
  --shadow: 0 16px 50px rgba(64, 41, 28, 0.12);
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(179, 71, 47, 0.15), transparent 28%),
    radial-gradient(circle at bottom right, rgba(37, 105, 146, 0.14), transparent 30%),
    var(--bg);
}

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

.sidebar {
  padding: 28px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(18px);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
}

h1 {
  margin: 0 0 10px;
  font-size: 32px;
  line-height: 1.05;
}

h2 {
  margin: 0 0 14px;
  font-size: 16px;
}

.muted,
.hint {
  color: var(--muted);
}

.panel {
  margin-top: 22px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.field,
.checkbox {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.checkbox {
  flex-direction: row;
  align-items: center;
}

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

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: white;
  color: var(--ink);
}

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

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

.chip,
.link-button,
button[type="submit"] {
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.chip:hover,
.link-button:hover,
button[type="submit"]:hover {
  transform: translateY(-1px);
  background: rgba(179, 71, 47, 0.18);
}

.link-button {
  width: 100%;
  margin-top: 10px;
}

.link-button.secondary {
  background: rgba(37, 105, 146, 0.1);
  color: #1f5c7b;
}

.main {
  padding: 28px;
}

.composer,
.status,
.message {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.composer {
  padding: 18px;
}

.composer-actions {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

button[type="submit"] {
  background: var(--accent);
  color: #fffaf5;
  min-width: 132px;
}

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

.status.hidden {
  display: none;
}

.status.info {
  color: #1f5c7b;
  background: rgba(37, 105, 146, 0.08);
}

.status.error {
  color: var(--danger);
  background: rgba(164, 49, 37, 0.08);
}

.chat {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-top: 18px;
}

.message {
  padding: 18px;
}

.message.user {
  border-color: rgba(37, 105, 146, 0.18);
}

.message.assistant {
  border-color: rgba(26, 127, 90, 0.18);
}

.message-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.badge {
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.message.user .badge {
  background: rgba(37, 105, 146, 0.12);
  color: #1f5c7b;
}

.message.assistant .badge {
  background: rgba(26, 127, 90, 0.12);
  color: var(--success);
}

.message-body p {
  margin: 0;
  line-height: 1.6;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.meta-card {
  border-radius: 16px;
  border: 1px solid var(--line);
  padding: 12px;
  background: rgba(255, 255, 255, 0.72);
}

.meta-card h3 {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.meta-card ul {
  margin: 0;
  padding-left: 18px;
}

.meta-card li + li {
  margin-top: 6px;
}

table {
  width: 100%;
  margin-top: 16px;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 16px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  background: rgba(255, 255, 255, 0.78);
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.debug-block {
  margin-top: 16px;
  padding: 14px;
  border-radius: 16px;
  background: #1f2430;
  color: #e8edf6;
  overflow-x: auto;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

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

  .main {
    padding: 20px;
  }

  .composer-actions {
    flex-direction: column;
    align-items: stretch;
  }
}
