:root {
  color-scheme: light;
  --bg: #f4f1ec;
  --panel: #ffffff;
  --ink: #171a1c;
  --muted: #66706a;
  --line: #d9d4cc;
  --accent: #2f6f4f;
  --accent-strong: #245940;
  --warning: #9a4d22;
  --shadow: 0 16px 50px rgba(28, 34, 31, 0.12);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

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

.shell {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 14px max(28px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

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

h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1;
  letter-spacing: 0;
}

.status {
  min-width: 88px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  background: rgba(255, 255, 255, 0.58);
}

.status.ok {
  color: var(--accent-strong);
  border-color: rgba(47, 111, 79, 0.28);
}

.status.bad {
  color: var(--warning);
}

.form {
  display: grid;
  gap: 12px;
}

.section {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(217, 212, 204, 0.9);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.section.compact {
  padding: 10px;
}

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

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

.result-only {
  display: none;
}

body[data-mode="result"] .result-only {
  display: grid;
}

body[data-mode="result"] .plan-only {
  display: none;
}

.field {
  display: grid;
  gap: 6px;
}

.field span,
.section-title span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  color: var(--ink);
  background: #fbfaf7;
  outline: none;
}

textarea {
  resize: vertical;
  line-height: 1.35;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 111, 79, 0.14);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

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

.segmented label {
  min-width: 0;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: grid;
  min-height: 46px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fbfaf7;
  font-weight: 750;
}

.segmented input:checked + span {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

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

.icon-button {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
  font-size: 24px;
  font-weight: 600;
  line-height: 1;
}

.icon-button.ghost {
  align-self: end;
  border: 1px solid var(--line);
  color: var(--muted);
  background: #fbfaf7;
}

.takes {
  display: grid;
  gap: 10px;
}

.take-row {
  display: grid;
  grid-template-columns: 1fr 1fr 38px;
  gap: 8px;
  align-items: end;
}

.trade-card {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid rgba(47, 111, 79, 0.18);
  border-radius: 8px;
  color: var(--muted);
  background: #f7f7f2;
  font-size: 13px;
  line-height: 1.35;
}

.trade-card strong {
  color: var(--ink);
}

.actions {
  display: grid;
  gap: 10px;
  padding: 4px 0 0;
}

.primary {
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
}

.primary:disabled {
  opacity: 0.62;
}

.message {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

.message.error {
  color: var(--warning);
}

.message.success {
  color: var(--accent-strong);
}

@media (max-width: 560px) {
  .grid,
  .grid.two {
    grid-template-columns: 1fr;
  }

  .take-row {
    grid-template-columns: 1fr 1fr 38px;
  }

  .outcome-switch {
    grid-template-columns: 1fr;
  }
}
