:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --panel: #fffdf8;
  --ink: #1c1915;
  --muted: #5c564c;
  --line: #e4dccf;
  --accent: #1f4d3a;
  --accent-ink: #f7f4ee;
  --bad: #8a2e24;
  --ok: #1f4d3a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 16px/1.45 "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

header, main {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
}

header { padding: 28px 0 8px; }

h1 { margin: 0 0 6px; font-size: 1.6rem; }
h2 { margin: 0 0 12px; font-size: 1.05rem; }
h3 { margin: 8px 0; font-size: 0.95rem; }

header p, .hint { color: var(--muted); margin: 0 0 12px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin: 14px 0;
}

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 10px;
}

.row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  align-self: end;
  margin-bottom: 10px;
}

input, select, textarea, button {
  font: inherit;
  color: var(--ink);
}

input, select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-weight: 400;
}

textarea { resize: vertical; }

button {
  background: var(--accent);
  color: var(--accent-ink);
  border: 0;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
}

button:disabled { opacity: 0.6; cursor: wait; }

#clearBtn { background: #efe8dc; color: var(--ink); }

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.status { font-size: 0.9rem; color: var(--muted); }
.status.ok { color: var(--ok); }
.status.bad { color: var(--bad); }

.messages {
  min-height: 80px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.bubble {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 10px;
  white-space: pre-wrap;
}

.bubble.user {
  align-self: flex-end;
  background: #e7f0ea;
}

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

.thinking {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.85rem;
}

.out {
  margin: 8px 0 0;
  padding: 12px;
  background: #1c1915;
  color: #f4f1ea;
  border-radius: 8px;
  overflow: auto;
  max-height: 420px;
  font-size: 0.82rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 8px;
}

.stat {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
}

.stat span {
  display: block;
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.1;
}

.stat small { color: var(--muted); }

.checks { align-items: end; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-top: 8px;
}

th, td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
}

.budget {
  margin: 8px 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--line);
}

.budget.ok { background: #e5f2ea; }
.budget.bad { background: #f8e6e3; }

#variantLog button {
  padding: 4px 8px;
  margin-right: 4px;
}
