:root {
  color-scheme: light;
  --bg: #f4efe7;
  --surface: #fffaf4;
  --surface-strong: #ffffff;
  --text: #1e1d1a;
  --muted: #6d665d;
  --accent: #0d6e6e;
  --accent-strong: #084949;
  --border: #d7ccbf;
  --shadow: 0 18px 40px rgba(43, 35, 24, 0.08);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(13, 110, 110, 0.12), transparent 28%),
    linear-gradient(180deg, #fbf7f1 0%, var(--bg) 100%);
}

.page {
  width: min(1180px, calc(100% - 32px));
  margin: 32px auto 48px;
}

.hero,
.card {
  background: rgba(255, 250, 244, 0.92);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 28px;
  margin-bottom: 24px;
}

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

h1,
h2,
h3 {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.3rem);
  line-height: 1.05;
  max-width: 760px;
}

.subcopy {
  max-width: 760px;
  color: var(--muted);
  line-height: 1.6;
}

.hero-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 220px;
}

.auth-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(13, 110, 110, 0.08);
  border: 1px solid rgba(13, 110, 110, 0.16);
}

#auth-username {
  font-weight: 700;
  color: var(--accent-strong);
}

.card {
  padding: 24px;
  margin-bottom: 24px;
}

.chat-form {
  display: grid;
  gap: 14px;
}

.input-label {
  font-weight: 700;
}

textarea,
input,
button,
.link-button {
  font: inherit;
}

textarea,
input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  color: var(--text);
}

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

button,
.link-button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  text-decoration: none;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease, background 120ms ease;
}

button:hover,
.link-button:hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.7;
  transform: none;
}

#submit-button {
  background: var(--accent);
  color: #ffffff;
}

#submit-button:hover {
  background: var(--accent-strong);
}

.secondary-button,
.link-button {
  background: transparent;
  color: var(--accent-strong);
  border-color: var(--border);
}

.form-actions,
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.status-text,
.result-meta {
  color: var(--muted);
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(480px, 100%);
  padding: 32px;
  background: rgba(255, 250, 244, 0.95);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 24px;
}

.messages {
  display: flex;
  flex-direction: column-reverse;
  gap: 12px;
  min-height: 220px;
}

.message {
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.message.user {
  border-left: 5px solid var(--accent);
}

.message.assistant {
  border-left: 5px solid #b47b28;
}

.message p {
  margin: 8px 0 0;
  line-height: 1.55;
  white-space: pre-wrap;
}

.message-meta {
  display: block;
  margin-top: 10px;
  color: var(--muted);
}

.debug-block + .debug-block {
  margin-top: 20px;
}

pre {
  margin: 10px 0 0;
  padding: 14px;
  border-radius: 12px;
  background: #1d2528;
  color: #f4f7f8;
  overflow: auto;
  white-space: pre-wrap;
}

.table-wrapper {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-strong);
}

.presentation-wrapper {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-strong);
  padding: 20px;
}

.presentation-wrapper h3 {
  margin-bottom: 10px;
  font-size: 1.05rem;
}

.presentation-narrative {
  margin: 0 0 16px;
  color: var(--text);
  line-height: 1.6;
}

.presentation-note {
  color: var(--muted);
}

.bullet-list {
  margin: 0;
  padding-left: 22px;
  display: grid;
  gap: 10px;
}

.chart-shell {
  width: 100%;
  overflow: auto;
}

.chart-svg {
  width: 100%;
  min-width: 640px;
  height: auto;
}

.chart-svg-pie {
  min-width: 300px;
  max-width: 320px;
}

.chart-axis,
.line-path {
  fill: none;
  stroke: #6d665d;
  stroke-width: 2;
}

.line-path {
  stroke: var(--accent);
  stroke-width: 3;
}

.line-point {
  fill: #ffffff;
  stroke: var(--accent);
  stroke-width: 3;
}

.bar-fill {
  fill: var(--accent);
}

.pie-slice {
  stroke: rgba(255, 255, 255, 0.9);
  stroke-width: 2;
}

.chart-axis-label,
.chart-value-label {
  fill: var(--text);
  font-size: 13px;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

.chart-value-label {
  font-weight: 700;
}

.pie-layout {
  display: flex;
  gap: 24px;
  align-items: center;
  flex-wrap: wrap;
}

.chart-legend {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
  min-width: 240px;
}

.chart-legend li {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 10px;
  align-items: center;
}

.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
}

.empty-state {
  padding: 22px;
  color: var(--muted);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  background: #f0e8dd;
  position: sticky;
  top: 0;
}

@media (max-width: 900px) {
  .hero,
  .grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .hero-actions {
    min-width: unset;
  }

  .chart-svg {
    min-width: 560px;
  }
}
