:root {
  color-scheme: light;
  --bg: #f3f1ec;
  --surface: #ffffff;
  --surface-2: #ece7dd;
  --ink: #20242a;
  --muted: #68717a;
  --line: #d5d1c9;
  --accent: #0f6e74;
  --accent-dark: #0a4c50;
  --warning: #b7791f;
  --danger: #a63d40;
  --ok: #2e7d4f;
  --cyan: #0c7ec8;
  --yellow: #d7a916;
  --brown: #8b4633;
  --magenta: #c02784;
  --black: #242424;
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

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

.app-shell {
  min-height: 100vh;
}

.topbar {
  align-items: center;
  background: #f8f7f3;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 24px;
  justify-content: space-between;
  padding: 22px clamp(18px, 4vw, 42px);
}

.eyebrow {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  margin: 0 0 3px;
  text-transform: uppercase;
}

h1,
h2 {
  letter-spacing: 0;
  margin: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.05;
}

h2 {
  font-size: 20px;
}

.status-pill,
#confidenceTag {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  padding: 9px 14px;
  white-space: nowrap;
}

.status-pill.ok,
#confidenceTag.ok {
  background: #e8f3ed;
  border-color: #b7d9c6;
  color: var(--ok);
}

.status-pill.warn,
#confidenceTag.warn {
  background: #fff4df;
  border-color: #e8c383;
  color: var(--warning);
}

.status-pill.danger,
#confidenceTag.danger {
  background: #f8e5e6;
  border-color: #dea8aa;
  color: var(--danger);
}

.workspace {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(340px, 520px) minmax(0, 1fr);
  padding: 20px clamp(14px, 3vw, 34px) 34px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.input-panel {
  align-self: start;
  display: grid;
  gap: 18px;
}

.results-panel {
  display: grid;
  gap: 18px;
}

.section-title {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.field-grid,
.bars-grid,
.noise-grid,
.choice-grid {
  display: grid;
  gap: 12px;
}

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

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

label {
  display: grid;
  gap: 7px;
}

label span,
legend {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  background: #fbfaf7;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  min-width: 0;
  padding: 10px 11px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 110, 116, 0.14);
  outline: none;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 0;
  padding: 14px;
}

legend {
  padding: 0 6px;
}

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

.choice-grid label,
.bar-toggle {
  align-items: center;
  background: #fbfaf7;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: flex;
  gap: 8px;
  min-height: 42px;
  padding: 9px 10px;
}

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

.swatch {
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 999px;
  flex: 0 0 16px;
  height: 16px;
  width: 16px;
}

.noise-control {
  display: grid;
  gap: 7px;
}

.noise-label {
  align-items: center;
  display: flex;
  gap: 7px;
  justify-content: space-between;
}

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

.actions,
.inline-actions {
  display: flex;
  gap: 10px;
}

button {
  background: var(--accent);
  border: 0;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  font-weight: 800;
  padding: 11px 14px;
}

button:hover {
  background: var(--accent-dark);
}

button.secondary {
  background: #33424f;
}

button.ghost-button {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 8px 10px;
}

button.ghost-button:hover {
  background: var(--surface-2);
}

button.danger {
  color: var(--danger);
}

.learning-box,
.summary-box {
  background: #fbfaf7;
  border: 1px solid var(--line);
  border-radius: 8px;
  line-height: 1.45;
  margin-top: 14px;
  padding: 14px;
}

#learningTag {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.recommendations {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.rec-item,
.history-item {
  border-left: 4px solid var(--accent);
  background: #fbfaf7;
  border-radius: 6px;
  padding: 12px;
}

.rec-item.warn {
  border-left-color: var(--warning);
}

.rec-item.danger {
  border-left-color: var(--danger);
}

.rec-item h3,
.history-item h3 {
  font-size: 16px;
  margin: 0 0 5px;
}

.rec-item p,
.history-item p,
.rule-list p {
  line-height: 1.45;
  margin: 0;
}

.rule-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.history-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.history-meta {
  color: var(--muted);
  font-size: 13px;
  margin-top: 7px;
}

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

@media (max-width: 620px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .field-grid.three,
  .field-grid.two,
  .choice-grid,
  .bars-grid,
  .noise-grid {
    grid-template-columns: 1fr;
  }

  .actions {
    flex-direction: column;
  }
}
