:root {
  --bg: #f7f4eb;
  --panel: #ffffff;
  --ink: #102028;
  --muted: #4c5a61;
  --line: #d5ddd7;
  --teal: #0f766e;
  --amber: #d97706;
  --red: #c2410c;
  --green: #15803d;
  --accent: #205295;
  --radius: 18px;
  --shadow: 0 18px 40px rgba(16, 32, 40, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 15% -10%, #feeecf 0%, transparent 40%),
    radial-gradient(circle at 95% 10%, #d7eef0 0%, transparent 30%), var(--bg);
  line-height: 1.45;
}

.bg-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(16, 32, 40, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16, 32, 40, 0.03) 1px, transparent 1px);
  background-size: 34px 34px;
  z-index: -1;
}

.site-header,
.layout,
.site-footer {
  width: min(1080px, 92vw);
  margin: 0 auto;
}

.site-header {
  padding: 3.2rem 0 1.8rem;
}

.lang-switch {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-bottom: 0.85rem;
}

.lang-btn {
  font: inherit;
  border-radius: 999px;
  border: 1px solid var(--line);
  cursor: pointer;
  background: #fff;
  color: var(--ink);
  padding: 0.4rem 0.85rem;
}

.lang-btn.is-active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(120deg, #1f4d8b 0%, #197278 100%);
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--teal);
  font-weight: 700;
  font-size: 0.78rem;
}

h1,
h2,
h3 {
  font-family: "Fraunces", Georgia, serif;
  line-height: 1.12;
  margin: 0;
}

h1 {
  margin-top: 0.5rem;
  font-size: clamp(1.9rem, 3.3vw, 3rem);
  max-width: 16ch;
}

.lead {
  margin-top: 0.95rem;
  max-width: 68ch;
  color: var(--muted);
}

.layout {
  display: grid;
  gap: 1.1rem;
  padding-bottom: 3rem;
}

.panel {
  background: color-mix(in srgb, var(--panel) 94%, #f0e7d6 6%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(1rem, 2vw, 1.5rem);
}

.panel-head {
  margin-bottom: 0.55rem;
}

.step {
  margin: 0;
  font-weight: 700;
  font-size: 0.78rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h2 {
  margin-top: 0.25rem;
  font-size: clamp(1.3rem, 2.25vw, 1.85rem);
}

.theory {
  margin: 0.45rem 0 1rem;
  color: var(--muted);
  max-width: 75ch;
}

.traffic-wrap {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1rem;
  align-items: center;
}

.traffic-light {
  background: #182229;
  border-radius: 999px;
  padding: 0.6rem;
  display: grid;
  gap: 0.6rem;
  width: 74px;
  border: 2px solid #091016;
}

.light {
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  opacity: 0.25;
  cursor: pointer;
  transition: opacity 0.18s ease, transform 0.18s ease, box-shadow 0.2s ease;
}

.light:focus-visible,
.lang-btn:focus-visible,
.chip:focus-visible,
.decision:focus-visible,
.dilemma-option:focus-visible,
.face-btn:focus-visible,
.optativa-mode:focus-visible,
.primary:focus-visible,
.secondary:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 60%, white 40%);
  outline-offset: 2px;
}

.light-green {
  background: var(--green);
}

.light-amber {
  background: var(--amber);
}

.light-red {
  background: var(--red);
}

.light.is-active {
  opacity: 1;
  transform: scale(1.03);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.2), 0 0 18px rgba(255, 255, 255, 0.3);
}

.action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.chip,
.decision,
.dilemma-option,
.face-btn,
.primary,
.secondary {
  font: inherit;
  border-radius: 999px;
  border: 1px solid var(--line);
  cursor: pointer;
  background: #fff;
  color: var(--ink);
}

.chip,
.decision,
.face-btn {
  padding: 0.48rem 0.9rem;
}

.chip.is-active,
.decision.is-active,
.dilemma-option.is-active,
.face-btn.is-active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(120deg, #1f4d8b 0%, #197278 100%);
}

.choice-row,
.dilemma-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-bottom: 0.9rem;
}

.decision {
  min-width: 140px;
}

.controls-grid {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
}

.control {
  display: grid;
  gap: 0.45rem;
  padding: 0.8rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fbfbf8;
}

.control span {
  font-weight: 600;
}

output {
  font-weight: 700;
  color: var(--accent);
}

input[type="range"] {
  width: 100%;
}

select {
  font: inherit;
  padding: 0.5rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.dilemma-option {
  text-align: left;
  padding: 0.9rem 1rem;
  border-radius: 14px;
  flex: 1 1 220px;
}

.feedback {
  margin-top: 0.9rem;
  border-left: 6px solid var(--accent);
  border-radius: 12px;
  background: #f3f7ff;
  padding: 0.9rem 1rem;
}

.feedback h3 {
  font-size: 1.1rem;
  margin: 0 0 0.2rem;
}

.feedback p {
  margin: 0.3rem 0;
}

.feedback small {
  display: block;
  margin-top: 0.35rem;
  color: #344850;
}

.feedback.state-green {
  border-left-color: var(--green);
  background: #edf8f0;
}

.feedback.state-amber {
  border-left-color: var(--amber);
  background: #fff6e9;
}

.feedback.state-red {
  border-left-color: var(--red);
  background: #fdeee8;
}

.tri-grid {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: repeat(auto-fit, minmax(235px, 1fr));
  justify-items: center;
}

.tri-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.95rem;
  background: #fff;
  display: grid;
  gap: 0.85rem;
  perspective: 1100px;
  box-shadow: 0 10px 24px rgba(17, 31, 39, 0.08);
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
  width: min(100%, 380px);
}

.tri-card:hover {
  border-color: color-mix(in srgb, var(--accent) 28%, var(--line) 72%);
  box-shadow: 0 16px 32px rgba(17, 31, 39, 0.11);
}

.tri-head {
  display: grid;
  gap: 0.28rem;
}

.tri-kicker {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--teal);
}

.tri-card h3 {
  margin: 0;
  font-size: 1.06rem;
}

.tri-shell {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem;
  background: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
  transform-style: preserve-3d;
  min-height: 124px;
}

.side-label {
  margin: 0;
  font-size: 0.83rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent);
  font-weight: 700;
}

.side-text {
  margin: 0.25rem 0 0;
  color: #21343c;
}

.tri-card.flip-right .tri-shell {
  animation: card-flip-right 0.44s cubic-bezier(0.2, 0.82, 0.2, 1);
}

.tri-card.flip-left .tri-shell {
  animation: card-flip-left 0.44s cubic-bezier(0.2, 0.82, 0.2, 1);
}

@keyframes card-flip-right {
  0% {
    transform: rotateY(0deg);
  }
  45% {
    transform: rotateY(78deg);
    filter: brightness(0.95);
  }
  100% {
    transform: rotateY(0deg);
  }
}

@keyframes card-flip-left {
  0% {
    transform: rotateY(0deg);
  }
  45% {
    transform: rotateY(-78deg);
    filter: brightness(0.95);
  }
  100% {
    transform: rotateY(0deg);
  }
}

.face-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: center;
}

.tri-card .face-btn {
  min-width: 82px;
  text-align: center;
}

.optativa-lab {
  display: grid;
  gap: 0.9rem;
  margin-bottom: 1rem;
}

.optativa-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.mini-label {
  margin: 0;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 700;
  color: var(--teal);
}

.optativa-mode {
  font: inherit;
  border-radius: 999px;
  border: 1px solid var(--line);
  cursor: pointer;
  background: #fff;
  color: var(--ink);
  padding: 0.5rem 0.9rem;
}

.optativa-mode.is-active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(120deg, #1f4d8b 0%, #197278 100%);
}

.optativa-factors {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 0.75rem;
  display: grid;
  gap: 0.45rem;
}

.optativa-factors legend {
  padding: 0 0.35rem;
  font-weight: 700;
  color: #1e3944;
}

.factor-item {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 0.55rem;
  row-gap: 0.15rem;
  align-items: start;
}

.factor-item input {
  margin-top: 0.2rem;
}

.factor-item span {
  font-weight: 600;
}

.factor-item small {
  grid-column: 2 / -1;
  color: #44606a;
}

.optativa-tree {
  display: grid;
  gap: 0.7rem;
  margin-bottom: 0.9rem;
}

.tree-root {
  border: 1px dashed color-mix(in srgb, var(--accent) 52%, var(--line) 48%);
  border-radius: 12px;
  background: #f8fbff;
  padding: 0.75rem;
}

.tree-branches {
  display: grid;
  gap: 0.7rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.branch-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 0.75rem;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.branch-card h3 {
  margin: 0.1rem 0 0.35rem;
  font-size: 1rem;
}

.branch-card p {
  margin: 0.25rem 0;
}

.branch-type {
  margin: 0;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 700;
  color: var(--accent);
}

.branch-positive.is-active {
  border-color: color-mix(in srgb, var(--green) 60%, var(--line) 40%);
  box-shadow: 0 10px 20px rgba(21, 128, 61, 0.14);
  transform: translateY(-2px);
}

.branch-negative.is-active {
  border-color: color-mix(in srgb, var(--red) 60%, var(--line) 40%);
  box-shadow: 0 10px 20px rgba(194, 65, 12, 0.15);
  transform: translateY(-2px);
}

.branch-card.is-muted {
  opacity: 0.58;
}

.checklist {
  display: grid;
  gap: 0.55rem;
  margin-bottom: 0.95rem;
}

.checklist label {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.6rem 0.75rem;
  background: #fff;
}

.final-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.primary,
.secondary {
  padding: 0.58rem 1rem;
}

.primary {
  background: linear-gradient(120deg, #184f90 0%, #15756e 100%);
  color: #fff;
  border: none;
}

.secondary {
  background: #fff;
}

.site-footer {
  padding: 0.6rem 0 2.2rem;
  color: var(--muted);
}

.site-footer p {
  margin: 0.3rem 0;
}

.site-footer a {
  color: var(--accent);
  font-weight: 600;
  text-decoration-thickness: 2px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.reveal {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.56s ease, transform 0.56s ease;
}

.reveal.in-view {
  opacity: 1;
  transform: translateY(0);
}

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

  .traffic-wrap {
    grid-template-columns: 1fr;
  }

  .traffic-light {
    grid-auto-flow: column;
    width: max-content;
    padding: 0.5rem;
    border-radius: 999px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  .reveal {
    opacity: 1;
    transform: none;
  }
}
