/* ===== Tokens ===== */
:root {
  --bg: #f6f8fc;
  --bg-alt: #eef2fa;
  --surface: #ffffff;
  --text: #1d2433;
  --muted: #5b6478;
  --border: #dde3ef;
  --primary: #3b5bdb;
  --primary-dark: #2c45b0;
  --center: #1f2a52;

  --innate: #e8590c;
  --innate-soft: #fff1e6;
  --adaptive: #1c7ed6;
  --adaptive-soft: #e7f2fd;
  --organs: #2b8a3e;
  --organs-soft: #e9f7ec;
  --apps: #7048e8;
  --apps-soft: #f1ecfe;

  --ok: #2b8a3e;
  --no: #e03131;

  --radius: 14px;
  --shadow: 0 6px 24px rgba(31, 42, 82, .08);
  --font: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.8;
}
h1, h2, h3 { line-height: 1.4; margin: 0 0 .5em; }
button { font-family: inherit; cursor: pointer; }
a { color: inherit; }

.container { width: min(1180px, 92%); margin-inline: auto; }
.container.narrow { width: min(760px, 92%); }

/* Branch color helpers */
.color-innate   { --c: var(--innate);   --c-soft: var(--innate-soft); }
.color-adaptive { --c: var(--adaptive); --c-soft: var(--adaptive-soft); }
.color-organs   { --c: var(--organs);   --c-soft: var(--organs-soft); }
.color-apps     { --c: var(--apps);     --c-soft: var(--apps-soft); }
.color-center   { --c: var(--center);   --c-soft: #e8ebf5; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; gap: .4em;
  padding: .7em 1.4em;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
  transition: transform .15s, background .15s, box-shadow .15s;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; }
.btn-small { padding: .45em 1.1em; font-size: .92rem; }

/* ===== Header ===== */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.nav { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { font-weight: 800; font-size: 1.15rem; text-decoration: none; display: flex; align-items: center; gap: .4em; }
.nav-links { display: flex; gap: 1.4rem; }
.nav-links a { text-decoration: none; color: var(--muted); font-weight: 600; font-size: .95rem; }
.nav-links a:hover { color: var(--primary); }
.nav-toggle { display: none; background: none; border: 0; font-size: 1.6rem; }

/* ===== Hero ===== */
.hero {
  background: radial-gradient(circle at 15% 20%, #dfe7ff 0, transparent 45%),
              radial-gradient(circle at 85% 80%, #ffe8d6 0, transparent 40%),
              var(--bg);
  padding: 4.5rem 0 4rem;
}
.hero-inner { display: grid; grid-template-columns: 1.3fr 1fr; gap: 3rem; align-items: center; }
.eyebrow {
  display: inline-block; background: var(--surface); border: 1px solid var(--border);
  padding: .2em .9em; border-radius: 999px; color: var(--primary); font-weight: 700; font-size: .85rem;
}
.hero h1 { font-size: clamp(1.8rem, 3.6vw, 2.8rem); font-weight: 800; margin-top: .6em; }
.hl { color: var(--primary); }
.hero p { color: var(--muted); font-size: 1.1rem; }
.hero-actions { display: flex; gap: .8rem; flex-wrap: wrap; margin-top: 1.6rem; }

.hero { position: relative; overflow: hidden; }
.hero-inner { position: relative; z-index: 1; }
.hero-svg { width: 100%; max-width: 420px; display: block; margin-inline: auto; overflow: visible; direction: ltr; }
.hero-ring { fill: none; stroke: #b6c2de; stroke-width: 3; stroke-dasharray: 6 8; animation: dash 3s linear infinite; }
.hero-ring-2 { stroke: #dbe2f3; stroke-dasharray: 2 10; animation-direction: reverse; }
.hero-core { filter: drop-shadow(0 10px 24px rgba(59, 91, 219, .25)); }
.hb circle { fill: #fff; stroke-width: 4; filter: drop-shadow(0 6px 12px rgba(0,0,0,.12)); }
.hb text {
  font-family: var(--font); font-weight: 800; font-size: 15px; text-anchor: middle;
  paint-order: stroke; stroke: #fff; stroke-width: 5px; stroke-linejoin: round;
}
.hb { transform-box: fill-box; transform-origin: center; animation: bob 4s ease-in-out infinite; }
.hb2 { animation-delay: -1s; } .hb3 { animation-delay: -2s; } .hb4 { animation-delay: -3s; }
.float { transform-box: fill-box; transform-origin: center; animation: drift 6s ease-in-out infinite; }
.f2 { animation-duration: 7s; animation-delay: -2s; }
.f3 { animation-duration: 5s; animation-delay: -1s; }
@keyframes dash { to { stroke-dashoffset: -28; } }
@keyframes bob { 50% { transform: translateY(-6px); } }
@keyframes drift { 33% { transform: translate(6px, -8px) rotate(12deg); } 66% { transform: translate(-5px, 5px) rotate(-8deg); } }

.hero-deco .ico { position: absolute; opacity: .13; animation: drift 9s ease-in-out infinite; }
.hero-deco .d1 { width: 90px; height: 90px; top: 8%; inset-inline-start: 3%; }
.hero-deco .d2 { width: 70px; height: 70px; bottom: 10%; inset-inline-start: 42%; animation-delay: -3s; }
.hero-deco .d3 { width: 60px; height: 60px; top: 12%; inset-inline-start: 48%; animation-delay: -5s; }
.hero-deco .d4 { width: 110px; height: 110px; bottom: -20px; inset-inline-end: 2%; animation-delay: -2s; }
.hero-deco .d5 { width: 50px; height: 50px; top: 55%; inset-inline-start: 8%; animation-delay: -6s; }

.hero-stats { list-style: none; padding: 0; margin: 1.2rem 0 0; display: flex; flex-wrap: wrap; gap: .6rem; }
.hero-stats li {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: .35rem .9rem; font-size: .9rem; font-weight: 600; color: var(--muted);
}
.hero-stats b { color: var(--primary); font-size: 1.15rem; margin-inline-end: .2rem; }
.hero-stats li:nth-child(1) b { color: var(--innate); }
.hero-stats li:nth-child(2) b { color: var(--adaptive); }
.hero-stats li:nth-child(3) b { color: var(--organs); }
.hero-stats li:nth-child(4) b { color: var(--apps); }

/* ===== Sections ===== */
.section { padding: 4rem 0; }
.section-alt { background: var(--bg-alt); }
.section-title { font-size: clamp(1.4rem, 2.6vw, 2rem); font-weight: 800; text-align: center; }
.section-lead { text-align: center; color: var(--muted); margin: -.2rem auto 2rem; max-width: 680px; }

.cards-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.4rem; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.6rem; box-shadow: var(--shadow);
}
.card-icon { font-size: 2rem; }
.card h3 { font-size: 1.15rem; margin-top: .4rem; }
.card p { margin: .4rem 0; font-size: .96rem; }
.problem { color: var(--muted); }
.solution { color: var(--text); background: #eef6ee; border-radius: 8px; padding: .4rem .7rem; }

/* ===== Mind map ===== */
.map-toolbar { display: flex; gap: .6rem; flex-wrap: wrap; justify-content: center; margin-bottom: 1rem; }
.map-toolbar input {
  flex: 1 1 280px; max-width: 420px;
  font: inherit; padding: .5em 1.1em; border-radius: 999px; border: 1.5px solid var(--border);
  background: var(--surface);
}
.map-toolbar input:focus { outline: 2px solid var(--primary); outline-offset: 1px; }

.legend { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 1.2rem; padding: 0; margin: 0 0 1.6rem; }
.legend li { display: flex; align-items: center; gap: .4em; font-weight: 600; font-size: .92rem; color: var(--muted); }
.swatch { width: 14px; height: 14px; border-radius: 4px; background: var(--c); display: inline-block; }

.map-layout { display: grid; grid-template-columns: 1fr 300px; gap: 1.4rem; align-items: start; }

.mindmap {
  position: relative;
  display: grid;
  grid-template-columns: 1fr minmax(150px, 190px) 1fr;
  grid-template-areas:
    "b1 c b2"
    "b3 c b4";
  gap: 2.2rem 3.2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.8rem;
  box-shadow: var(--shadow);
}
.mindmap-lines { position: absolute; inset: 0; pointer-events: none; z-index: 0; overflow: visible; }
.mindmap-lines .line { fill: none; stroke: var(--c); stroke-width: 3; stroke-linecap: round; opacity: .55; }

.mm-center-wrap { grid-area: c; display: flex; align-items: center; justify-content: center; z-index: 1; }
.mm-branch { z-index: 1; align-self: start; }

.mm-node {
  display: inline-flex; align-items: center; gap: .45em;
  border: 2px solid var(--c, var(--center));
  background: var(--surface);
  color: var(--text);
  border-radius: 12px;
  padding: .4em .85em;
  font-size: .95rem; font-weight: 600;
  text-align: start;
  transition: transform .15s, box-shadow .15s, background .15s, opacity .2s;
}
.mm-node:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(0,0,0,.1); }
.mm-node.active { box-shadow: 0 0 0 4px color-mix(in srgb, var(--c, var(--center)) 30%, transparent); }
.mm-node.match { background: #fff3bf; border-color: #f08c00; }
.mm-node.dim { opacity: .3; }
.mm-icon { font-size: 1.1em; }

.mm-center {
  --c: var(--center);
  flex-direction: column; justify-content: center;
  width: 150px; height: 150px; border-radius: 50%;
  background: var(--center); color: #fff;
  font-size: 1.1rem; font-weight: 800; text-align: center;
  box-shadow: 0 10px 30px rgba(31, 42, 82, .35);
}
.mm-center .mm-icon { font-size: 2rem; }
.mm-center.match { color: var(--text); }

.mm-branch-head { display: flex; align-items: center; gap: .4rem; }
.mm-branch-node { background: var(--c); color: #fff; font-weight: 800; font-size: 1.02rem; }
.mm-toggle {
  width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid var(--c); background: var(--c-soft); color: var(--c);
  font-weight: 800; font-size: 1.1rem; line-height: 1;
}

.mm-children {
  list-style: none; margin: .5rem 0 0; padding: 0;
  padding-inline-start: 1.3rem;
  border-inline-start: 3px solid var(--c-soft);
  margin-inline-start: .9rem;
}
.mm-children li { position: relative; padding: .28rem 0; }
.mm-children li::before {
  content: ''; position: absolute; inset-inline-start: -1.3rem; top: 50%;
  width: 1.1rem; border-top: 3px solid var(--c-soft);
}
.mm-leaf { background: var(--c-soft); border-color: transparent; border-inline-start: 4px solid var(--c); font-size: .9rem; }
.mm-branch.collapsed .mm-children { display: none; }

/* Info panel */
.info-panel {
  position: sticky; top: 84px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.4rem; box-shadow: var(--shadow); min-height: 220px;
}
.info-empty { text-align: center; color: var(--muted); padding-top: 2rem; }
.info-empty-icon { font-size: 2.2rem; }
.info-head { display: flex; gap: .8rem; align-items: center; border-bottom: 3px solid var(--c); padding-bottom: .7rem; margin-bottom: .8rem; }
.info-head h3 { margin: 0; color: var(--c); font-size: 1.25rem; }
.info-icon { font-size: 2rem; background: var(--c-soft); width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; }
.info-tag { font-size: .78rem; font-weight: 700; color: var(--muted); }
.info-desc { margin: 0 0 1rem; }
.info-rel-title { font-weight: 700; font-size: .9rem; margin: 0 0 .4rem; color: var(--muted); }
.info-rel { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
  border: 1px solid var(--border); background: var(--bg); border-radius: 999px;
  padding: .2em .8em; font-size: .85rem; font-weight: 600;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }

/* ===== Flow ===== */
.flow-track {
  list-style: none; padding: 0; margin: 0 0 1.6rem;
  display: grid; grid-template-columns: repeat(8, 1fr);
  position: relative;
}
.flow-track::before {
  content: ''; position: absolute; top: 22px; inset-inline: 6%;
  height: 4px; background: var(--border); border-radius: 2px;
}
.flow-track li { position: relative; display: flex; justify-content: center; }
.flow-dot { background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: .4rem; padding: 0 .2rem; }
.flow-num {
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface); border: 3px solid var(--border);
  font-weight: 800; color: var(--muted); position: relative; z-index: 1;
  transition: all .25s;
}
.flow-label { font-size: .82rem; font-weight: 600; color: var(--muted); text-align: center; line-height: 1.4; }
.flow-track li.done .flow-num { background: var(--adaptive-soft); border-color: var(--adaptive); color: var(--adaptive); }
.flow-track li.current .flow-num { background: var(--primary); border-color: var(--primary); color: #fff; transform: scale(1.15); box-shadow: 0 0 0 6px rgba(59, 91, 219, .18); }
.flow-track li.current .flow-label { color: var(--text); font-weight: 800; }

.flow-card {
  display: flex; gap: 1.4rem; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.8rem; box-shadow: var(--shadow);
  max-width: 820px; margin: 0 auto 1.4rem;
}
.flow-card.enter { animation: slideIn .35s ease; }
@keyframes slideIn { from { opacity: 0; transform: translateX(-16px); } }
.flow-card-icon { font-size: 3rem; background: var(--bg-alt); border-radius: 50%; width: 88px; height: 88px; display: grid; place-items: center; flex-shrink: 0; }
.flow-card h3 { font-size: 1.4rem; margin-bottom: .3rem; }
.flow-card p { margin: 0; }
.flow-line { font-size: .85rem; font-weight: 700; color: var(--primary); }
.flow-next-hint { margin-top: .8rem !important; color: var(--muted); font-size: .92rem; }
.flow-controls { display: flex; justify-content: center; gap: .6rem; flex-wrap: wrap; }

/* ===== Compare ===== */
.table-wrap { overflow-x: auto; border-radius: var(--radius); box-shadow: var(--shadow); }
.compare-table { width: 100%; border-collapse: collapse; background: var(--surface); min-width: 600px; }
.compare-table th, .compare-table td { padding: 1rem 1.2rem; text-align: start; border-bottom: 1px solid var(--border); }
.compare-table th { background: var(--center); color: #fff; }
.compare-table .th-innate { background: var(--innate); }
.compare-table .th-adaptive { background: var(--adaptive); }
.compare-table td:first-child { font-weight: 700; background: var(--bg); width: 22%; }
.compare-table tr:last-child td { border-bottom: 0; }

/* ===== Sort activity ===== */
.sort-pool {
  display: flex; flex-wrap: wrap; gap: .6rem; justify-content: center;
  min-height: 70px; padding: 1rem; margin-bottom: 1.4rem;
  border: 2px dashed var(--border); border-radius: var(--radius); background: var(--surface);
}
.sort-card {
  border: 1.5px solid var(--border); background: var(--bg); border-radius: 10px;
  padding: .45em 1em; font-weight: 600; font-size: .95rem; cursor: grab;
  transition: transform .15s, box-shadow .15s;
}
.sort-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.08); }
.sort-card.selected { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59, 91, 219, .25); }
.sort-card.dragging { opacity: .4; }
.sort-card.right { border-color: var(--ok); background: #ebfbee; }
.sort-card.wrong { border-color: var(--no); background: #fff5f5; }
.sort-bins { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.sort-bin {
  border-radius: var(--radius); padding: 1rem; min-height: 190px;
  border: 2px solid var(--c); background: var(--c-soft); cursor: pointer;
  transition: box-shadow .15s;
}
.bin-innate { --c: var(--innate); --c-soft: var(--innate-soft); }
.bin-adaptive { --c: var(--adaptive); --c-soft: var(--adaptive-soft); }
.sort-bin.over { box-shadow: 0 0 0 5px color-mix(in srgb, var(--c) 25%, transparent); }
.sort-bin h3 { color: var(--c); text-align: center; }
.bin-drop { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; }
.sort-actions { display: flex; align-items: center; justify-content: center; gap: .8rem; flex-wrap: wrap; margin-top: 1.4rem; }
.sort-result { font-weight: 700; }

/* ===== Quiz ===== */
.quiz {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 2rem; box-shadow: var(--shadow);
}
.quiz-progress { height: 8px; background: var(--bg-alt); border-radius: 4px; overflow: hidden; }
.quiz-progress span { display: block; height: 100%; background: var(--primary); transition: width .3s; }
.quiz-count { color: var(--muted); font-size: .9rem; margin: .6rem 0 .2rem; }
.quiz-q { font-size: 1.25rem; }
.quiz-options { display: grid; gap: .6rem; }
.quiz-opt {
  text-align: start; font-size: 1rem; padding: .8em 1.1em;
  border: 1.5px solid var(--border); border-radius: 10px; background: var(--bg);
  transition: border-color .15s, background .15s;
}
.quiz-opt:hover:not(:disabled) { border-color: var(--primary); background: #f0f3ff; }
.quiz-opt:disabled { cursor: default; color: var(--text); }
.quiz-opt.right { border-color: var(--ok); background: #ebfbee; font-weight: 700; }
.quiz-opt.wrong { border-color: var(--no); background: #fff5f5; }
.quiz-feedback:empty { display: none; }
.quiz-feedback { margin-top: 1rem; padding: 1rem 1.2rem; border-radius: 10px; }
.quiz-feedback.ok { background: #ebfbee; color: #1b5e29; }
.quiz-feedback.no { background: #fff5f5; color: #9b1c1c; }
.quiz-feedback p { margin: .3rem 0 .8rem; color: var(--text); }
.quiz-done { text-align: center; }
.score-ring {
  --pct: 0;
  width: 140px; height: 140px; border-radius: 50%; margin: 0 auto 1rem;
  background: conic-gradient(var(--primary) calc(var(--pct) * 1%), var(--bg-alt) 0);
  display: grid; place-items: center;
}
.score-ring span {
  width: 108px; height: 108px; border-radius: 50%; background: var(--surface);
  display: grid; place-items: center; font-size: 1.8rem; font-weight: 800;
}

/* ===== Tips ===== */
.tips { counter-reset: tip; list-style: none; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.tips li {
  counter-increment: tip; position: relative;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.2rem; padding-inline-start: 4rem;
}
.tips li::before {
  content: counter(tip); position: absolute; inset-inline-start: 1rem; top: 50%; transform: translateY(-50%);
  width: 2.2rem; height: 2.2rem; border-radius: 50%; display: grid; place-items: center;
  background: var(--primary); color: #fff; font-weight: 800;
}

/* ===== Footer ===== */
.site-footer { background: var(--center); color: #c5cde3; text-align: center; padding: 1.6rem 0; font-size: .92rem; }
.site-footer p { margin: 0; }

/* =====================================================================
   Graphics layer: icons, section badges, castle, cell cards, chart
   ===================================================================== */
.ico { width: 1em; height: 1em; display: inline-block; vertical-align: middle; flex-shrink: 0; overflow: visible; }
.brand-icon { width: 30px; height: 30px; }

/* Section heads */
.section-head { text-align: center; margin-bottom: 2rem; }
.section-head .section-lead { margin-bottom: 0; }
.section-badge {
  display: inline-grid; place-items: center;
  width: 72px; height: 72px; border-radius: 22px; margin-bottom: .6rem;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: 0 8px 22px rgba(31, 42, 82, .10);
  transform: rotate(-6deg);
}
.section-badge .ico { width: 46px; height: 46px; transform: rotate(6deg); }
.section { position: relative; }
.section-alt {
  background-color: var(--bg-alt);
  background-image: radial-gradient(rgba(59, 91, 219, .10) 1.2px, transparent 1.4px);
  background-size: 22px 22px;
}
.section { overflow-x: clip; }

/* "Why" cards */
.card { position: relative; overflow: hidden; transition: transform .2s, box-shadow .2s; }
.card::after {
  content: ''; position: absolute; inset-inline-end: -40px; top: -40px;
  width: 130px; height: 130px; border-radius: 50%; background: var(--card-tint); opacity: .5;
}
.card:hover { transform: translateY(-4px); box-shadow: 0 14px 34px rgba(31, 42, 82, .12); }
.card-amber  { --card-tint: #fff3bf; --card-c: #f59f00; }
.card-blue   { --card-tint: #d0ebff; --card-c: #1c7ed6; }
.card-violet { --card-tint: #e5dbff; --card-c: #7048e8; }
.card { border-top: 5px solid var(--card-c); }
.card-icon {
  position: relative; z-index: 1;
  width: 74px; height: 74px; border-radius: 20px; display: grid; place-items: center;
  background: var(--card-tint);
}
.card-icon .ico { width: 50px; height: 50px; }
.card h3, .card p { position: relative; z-index: 1; }
.pill { display: inline-block; font-size: .75rem; font-weight: 800; padding: .05em .7em; border-radius: 999px; margin-inline-end: .3em; }
.pill-no { background: #ffe3e3; color: #c92a2a; }
.pill-ok { background: #d3f9d8; color: #2b8a3e; }
.solution { background: #f4fbf5; }

/* Legend + mind map icons */
.legend .legend-ico { width: 26px; height: 26px; }
.legend li { background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: .2rem .8rem .2rem .9rem; color: var(--c); }
.mm-node .mm-icon { width: 30px; height: 30px; }
.mm-leaf .mm-icon { width: 28px; height: 28px; }
.mm-bubble { background: #fff; border-radius: 50%; width: 38px; height: 38px; display: grid; place-items: center; flex-shrink: 0; }
.mm-bubble .mm-icon { width: 30px; height: 30px; }
.mm-center .mm-icon { width: 62px; height: 62px; }
.mm-center {
  background: radial-gradient(circle at 35% 30%, #34447a, var(--center) 70%);
  border: 6px solid #fff; outline: 3px solid var(--center);
}
.info-icon .ico { width: 42px; height: 42px; }
.info-icon { width: 64px; height: 64px; }
.info-empty-icon { width: 64px; height: 64px; opacity: .8; }
.chip { display: inline-flex; align-items: center; gap: .35em; }
.chip .ico { width: 22px; height: 22px; }

/* Flow: icons in the track, colour per line of defence */
.tone-start  { --t: #2f9e44; --t-soft: #ebfbee; }
.tone-first  { --t: #e8590c; --t-soft: #fff4e6; }
.tone-second { --t: #e03131; --t-soft: #fff5f5; }
.tone-link   { --t: #d6336c; --t-soft: #fff0f6; }
.tone-third  { --t: #1c7ed6; --t-soft: #e7f5ff; }
.tone-result { --t: #7048e8; --t-soft: #f3f0ff; }
.flow-track::before { top: 30px; background: linear-gradient(to left, #2f9e44, #e8590c, #e03131, #d6336c, #1c7ed6, #7048e8); opacity: .35; }
.flow-num { width: 62px; height: 62px; border-color: var(--t); background: var(--surface); position: relative; }
.flow-num .ico { width: 38px; height: 38px; }
.flow-badge {
  position: absolute; top: -6px; inset-inline-end: -6px;
  width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  background: var(--t); color: #fff; font-size: .75rem; font-weight: 800; border: 2px solid #fff;
}
.flow-track li .flow-num { opacity: .55; }
.flow-track li.done .flow-num { background: var(--t-soft); border-color: var(--t); opacity: 1; }
.flow-track li.current .flow-num { background: var(--t-soft); border-color: var(--t); opacity: 1; transform: scale(1.18); box-shadow: 0 0 0 6px color-mix(in srgb, var(--t) 20%, transparent); }
.flow-track li.current .flow-label { color: var(--t); }
.flow-legend { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: .4rem 1.1rem; padding: 0; margin: -.4rem 0 1.4rem; }
.flow-legend li { display: flex; align-items: center; gap: .4em; font-size: .82rem; font-weight: 700; color: var(--t); }
.flow-legend .swatch { background: var(--t); border-radius: 50%; }
.flow-card { border-inline-start: 6px solid var(--t); }
.flow-card-icon { background: var(--t-soft); border: 3px solid color-mix(in srgb, var(--t) 35%, transparent); width: 104px; height: 104px; }
.flow-card-icon .ico { width: 70px; height: 70px; }
.flow-card .flow-line { color: var(--t); }

/* Compare table + response chart */
.compare-table th .ico { width: 28px; height: 28px; background: #fff; border-radius: 50%; padding: 3px; margin-inline-end: .3em; }
.speed-chart {
  margin-top: 2rem; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.4rem; box-shadow: var(--shadow); text-align: center;
}
.speed-chart h3 { font-size: 1.15rem; }
.speed-svg { width: 100%; max-width: 720px; direction: ltr; overflow: visible; }
.speed-svg .axis { stroke: #adb5bd; stroke-width: 2; }
.speed-svg .axis-label { font-family: var(--font); font-size: 13px; fill: var(--muted); text-anchor: middle; font-weight: 600; }
.speed-svg .curve { fill: none; stroke-width: 5; stroke-linecap: round; }
.speed-svg .curve-1 { stroke: #ff922b; }
.speed-svg .curve-2 { stroke: #1c7ed6; }
.speed-svg .marker { stroke: #ced4da; stroke-width: 2; stroke-dasharray: 4 5; }
.speed-svg .curve-label { font-family: var(--font); font-size: 14px; font-weight: 800; text-anchor: middle; paint-order: stroke; stroke: #fff; stroke-width: 5px; }
.speed-svg .c1 { fill: #e8590c; }
.speed-svg .c2 { fill: #1c7ed6; }
.speed-svg .mem-label { font-family: var(--font); font-size: 12px; font-weight: 700; fill: #7048e8; text-anchor: middle; }

/* Sort cards with icons */
.sort-card { display: inline-flex; align-items: center; gap: .45em; }
.sort-card .ico { width: 28px; height: 28px; }
.sort-bin h3 { display: flex; align-items: center; justify-content: center; gap: .4em; }
.sort-bin h3 .ico { width: 34px; height: 34px; }

/* Quiz result */
.score-ring span { display: grid; place-items: center; align-content: center; gap: 0; line-height: 1.1; }
.score-ico { width: 44px; height: 44px; }
.score-ring b { font-size: 1.3rem; }

/* Tips with icons */
.tips li { display: flex; align-items: center; gap: 1rem; padding-inline-start: 1.2rem; }
.tips li > .ico { width: 46px; height: 46px; padding: 6px; background: var(--bg-alt); border-radius: 14px; box-sizing: content-box; }
.tips li::before {
  width: 1.5rem; height: 1.5rem; font-size: .8rem; top: .6rem; transform: none;
  inset-inline-start: auto; inset-inline-end: .7rem; background: var(--border); color: var(--muted);
}

/* Castle analogy */
.castle-layout { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 2rem; align-items: center; }
.castle-svg { width: 100%; max-width: 520px; margin-inline: auto; display: block; direction: ltr; overflow: visible; cursor: pointer; }
.castle-svg .ring { transition: opacity .25s; }
.castle-svg .band { stroke-width: 3; transition: stroke-width .25s, filter .25s; }
.ring-l1 .band { fill: #fff4e6; stroke: #e8590c; }
.ring-l1 .bricks { fill: none; stroke: #ffa94d; stroke-width: 10; stroke-dasharray: 16 9; }
.ring-l2 .band { fill: #fff5f5; stroke: #fa5252; }
.ring-l3 .band { fill: #e7f5ff; stroke: #1c7ed6; }
.ring-label { direction: rtl; unicode-bidi: embed; font-family: var(--font); font-weight: 800; font-size: 17px; text-anchor: middle; paint-order: stroke; stroke: #fff; stroke-width: 5px; }
.ring-l1 .ring-label { fill: #d9480f; }
.ring-l2 .ring-label { fill: #e03131; }
.ring-l3 .ring-label { fill: #1864ab; }
.castle-svg .core circle { fill: #fff; stroke: var(--center); stroke-width: 3; filter: drop-shadow(0 4px 10px rgba(31,42,82,.2)); }
.castle-svg .core text { font-family: var(--font); font-weight: 800; font-size: 14px; text-anchor: middle; fill: var(--center); }
.castle-svg .attack path { stroke: #fa5252; stroke-width: 3; stroke-dasharray: 6 6; fill: none; opacity: .6; animation: dash 1.6s linear infinite; }
.castle-svg.focused .ring:not(.active) use, .castle-svg.focused .ring:not(.active) text { opacity: .35; }
.castle-svg .ring.active .band { stroke-width: 7; filter: drop-shadow(0 0 10px rgba(0,0,0,.15)); }
.castle-svg use, .castle-svg text { transition: opacity .25s; }

.castle-cards { display: grid; gap: .9rem; }
.castle-card {
  display: flex; gap: 1rem; align-items: flex-start; text-align: start;
  background: var(--surface); border: 2px solid var(--border); border-inline-start: 6px solid var(--t);
  border-radius: var(--radius); padding: 1rem 1.1rem; color: var(--text);
  transition: transform .2s, box-shadow .2s, border-color .2s, background .2s;
}
.castle-card.active { border-color: var(--t); background: var(--t-soft); transform: translateX(-6px); box-shadow: var(--shadow); }
.castle-card-icon { width: 64px; height: 64px; border-radius: 18px; background: var(--t-soft); display: grid; place-items: center; flex-shrink: 0; }
.castle-card-icon .ico { width: 46px; height: 46px; }
.castle-card-body { display: grid; gap: .15rem; }
.castle-card b { color: var(--t); font-size: 1.08rem; }
.castle-card small { color: var(--muted); font-weight: 600; font-size: .85rem; }
.castle-card-desc { font-size: .93rem; }

/* Cell gallery (flip cards) */
.filter-tabs { display: flex; justify-content: center; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.6rem; }
.tab {
  border: 2px solid var(--border); background: var(--surface); border-radius: 999px;
  padding: .4em 1.2em; font-weight: 700; color: var(--muted);
}
.tab.active { background: var(--center); border-color: var(--center); color: #fff; }
.tab-innate.active { background: var(--innate); border-color: var(--innate); }
.tab-adaptive.active { background: var(--adaptive); border-color: var(--adaptive); }

.cells-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1.1rem; }
.cell-card { border: 0; padding: 0; background: none; perspective: 900px; height: 270px; color: var(--text); text-align: center; }
.cell-card.hidden { display: none; }
.cell-card.type-innate { --c: var(--innate); --c-soft: var(--innate-soft); }
.cell-card.type-adaptive { --c: var(--adaptive); --c-soft: var(--adaptive-soft); }
.cell-inner { position: relative; display: block; width: 100%; height: 100%; transition: transform .6s; transform-style: preserve-3d; }
.cell-card.flipped .cell-inner { transform: rotateY(180deg); }
.cell-front, .cell-back {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border-radius: 18px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 1rem; gap: .25rem; box-shadow: var(--shadow);
}
.cell-front { background: linear-gradient(180deg, var(--c-soft) 0 52%, var(--surface) 52%); border: 2px solid color-mix(in srgb, var(--c) 30%, transparent); }
.cell-portrait {
  width: 108px; height: 108px; border-radius: 50%; background: #fff; display: grid; place-items: center;
  border: 4px solid var(--c); box-shadow: 0 8px 18px rgba(0,0,0,.1); margin-bottom: .3rem;
  transition: transform .3s;
}
.cell-card:hover .cell-portrait { transform: rotate(-8deg) scale(1.05); }
.cell-portrait .ico { width: 76px; height: 76px; }
.cell-nick { font-size: .78rem; font-weight: 800; color: #fff; background: var(--c); padding: .05em .8em; border-radius: 999px; }
.cell-name { font-size: 1.02rem; line-height: 1.4; }
.cell-type { font-size: .78rem; color: var(--c); font-weight: 700; }
.cell-hint { font-size: .74rem; color: var(--muted); margin-top: .2rem; }
.cell-back { background: var(--c); color: #fff; transform: rotateY(180deg); font-size: .92rem; line-height: 1.7; }
.cell-back b { font-size: 1rem; }
.cell-back-ico { width: 46px; height: 46px; background: #fff; border-radius: 50%; padding: 5px; box-sizing: content-box; }

/* Footer */
.footer-icons { display: flex; justify-content: center; gap: .8rem; margin-bottom: .6rem; }
.footer-icons .ico { width: 34px; height: 34px; background: rgba(255,255,255,.95); border-radius: 50%; padding: 4px; box-sizing: content-box; }

/* ===== Responsive ===== */
@media (max-width: 1100px) {
  .nav-toggle { display: block; }
  .nav-links {
    display: none; position: absolute; top: 64px; inset-inline: 0;
    flex-direction: column; gap: 0; background: var(--surface); border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: .8rem 4%; border-top: 1px solid var(--border); }
}
@media (max-width: 900px) {
  .castle-layout { grid-template-columns: 1fr; }
  .castle-svg { max-width: 420px; }
  .castle-card.active { transform: none; }
}
@media (max-width: 1060px) {
  .map-layout { grid-template-columns: 1fr; }
  .info-panel { position: static; }
}

@media (max-width: 900px) {
  .nav-toggle { display: block; }
  .nav-links {
    display: none; position: absolute; top: 64px; inset-inline: 0;
    flex-direction: column; gap: 0; background: var(--surface); border-bottom: 1px solid var(--border);
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: .8rem 4%; border-top: 1px solid var(--border); }

  .hero-inner { grid-template-columns: 1fr; text-align: center; }
  .hero-actions { justify-content: center; }
  .hero-visual { order: -1; }
  .hero-svg { max-width: 240px; }
  .cards-3 { grid-template-columns: 1fr; }
  .tips { grid-template-columns: 1fr; }

  .flow-track { grid-template-columns: repeat(4, 1fr); row-gap: 1rem; }
  .flow-track::before { display: none; }
}

@media (max-width: 720px) {
  .mindmap {
    grid-template-columns: 1fr;
    grid-template-areas: "c" "b1" "b2" "b3" "b4";
    gap: 1.6rem;
    padding: 1.2rem;
  }
  .mindmap-lines { display: none; }
  .mm-center { width: 120px; height: 120px; font-size: 1rem; }
  .sort-bins { grid-template-columns: 1fr; }
  .flow-card { flex-direction: column; align-items: center; text-align: center; }
  .flow-label { display: none; }
}

/* Info panel extras (only visible as a phone bottom sheet) */
.info-close, .sheet-grip, .sheet-backdrop { display: none; }

@media (max-width: 720px) {
  body { font-size: 15.5px; }
  .section { padding: 2.8rem 0; }
  .hero { padding: 2.2rem 0 2.6rem; }
  .hero p { font-size: 1rem; }
  .hero-actions .btn { flex: 1 1 140px; justify-content: center; }
  .section-lead { margin-bottom: 1.4rem; }

  /* Toolbar: search on its own row, buttons share the next one */
  .map-toolbar input { flex-basis: 100%; max-width: none; }
  .map-toolbar .btn { flex: 1; justify-content: center; }
  .legend { gap: .5rem 1rem; }

  /* Comfortable tap targets */
  .mm-node { min-height: 44px; }
  .mm-toggle { width: 40px; height: 40px; flex-shrink: 0; }
  .mm-branch-node { flex: 1; }
  .mm-children li { padding: .3rem 0; }
  .chip { padding: .45em 1em; }
  .btn-small { padding: .6em 1.1em; }

  /* Bottom sheet for the explanation panel */
  .info-panel {
    position: fixed; top: auto; bottom: 0; inset-inline: 0; z-index: 70;
    min-height: 0; max-height: 70vh; overflow-y: auto; overscroll-behavior: contain;
    border-radius: 20px 20px 0 0; border-bottom: 0;
    padding: 1.6rem 1.2rem calc(1.4rem + env(safe-area-inset-bottom));
    box-shadow: 0 -10px 40px rgba(31, 42, 82, .25);
    transform: translateY(105%); visibility: hidden;
    transition: transform .3s ease, visibility .3s;
  }
  .info-panel.open { transform: none; visibility: visible; }
  .info-panel .info-empty { display: none; }
  .info-close {
    display: grid; place-items: center;
    position: absolute; top: .7rem; inset-inline-end: .7rem;
    width: 40px; height: 40px; border-radius: 50%;
    border: 0; background: var(--bg-alt); font-size: 1.1rem; color: var(--muted);
  }
  .sheet-grip { display: block; width: 44px; height: 5px; border-radius: 3px; background: var(--border); margin: -.8rem auto .9rem; }
  .info-head { padding-inline-end: 2.6rem; }
  .sheet-backdrop {
    display: block; position: fixed; inset: 0; z-index: 65;
    background: rgba(20, 26, 45, .45);
    opacity: 0; pointer-events: none; transition: opacity .3s;
  }
  .sheet-backdrop.show { opacity: 1; pointer-events: auto; }

  /* Flow */
  .flow-card { padding: 1.3rem; }
  .flow-card-icon { width: 72px; height: 72px; font-size: 2.4rem; }
  .flow-card h3 { font-size: 1.2rem; }
  .flow-controls .btn { flex: 1; justify-content: center; }
  .flow-controls #flow-play { order: -1; flex-basis: 100%; }

  /* Comparison table becomes one card per row */
  .table-wrap { box-shadow: none; overflow: visible; }
  .compare-table { min-width: 0; background: none; }
  .compare-table thead { display: none; }
  .compare-table, .compare-table tbody, .compare-table tr, .compare-table td { display: block; width: 100%; }
  .compare-table tr {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    margin-bottom: .9rem; overflow: hidden; box-shadow: var(--shadow);
  }
  .compare-table td { border-bottom: 1px solid var(--border); padding: .7rem 1rem; }
  .compare-table td:first-child { width: 100%; background: var(--center); color: #fff; }
  .compare-table td:not(:first-child)::before {
    content: attr(data-label); display: block; font-size: .8rem; font-weight: 800;
  }
  .compare-table td:nth-child(2)::before { color: var(--innate); }
  .compare-table td:nth-child(3)::before { color: var(--adaptive); }
  .compare-table tr:last-child td { border-bottom: 1px solid var(--border); }
  .compare-table td:last-child { border-bottom: 0 !important; }

  /* Sort + quiz */
  .sort-pool { padding: .8rem; }
  .sort-card { padding: .55em 1em; }
  .sort-bin { min-height: 140px; }
  .sort-actions .btn { flex: 1; justify-content: center; }
  .sort-result { flex-basis: 100%; text-align: center; }
  .quiz { padding: 1.3rem; }
  .quiz-q { font-size: 1.1rem; }
  .tips li { padding-inline-start: 1rem; padding-inline-end: 2.4rem; }
  .tips li > .ico { width: 36px; height: 36px; }

  /* Graphics on phones */
  .section-badge { width: 60px; height: 60px; border-radius: 18px; }
  .section-badge .ico { width: 38px; height: 38px; }
  .hero-stats { justify-content: center; }
  .hero-deco .d3, .hero-deco .d2, .hero-deco .d4 { display: none; }
  .mm-center .mm-icon { width: 42px; height: 42px; }
  .ring-label { font-size: 22px; }
  .castle-svg .core text { font-size: 18px; }
  .flow-num { width: 52px; height: 52px; }
  .flow-num .ico { width: 32px; height: 32px; }
  .flow-card-icon { width: 84px; height: 84px; }
  .flow-card-icon .ico { width: 56px; height: 56px; }
  .flow-legend { margin-top: 0; }
  .castle-card { padding: .8rem; gap: .8rem; }
  .castle-card-icon { width: 52px; height: 52px; }
  .castle-card-icon .ico { width: 38px; height: 38px; }
  .cells-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
  .cell-card { height: 250px; }
  .cell-portrait { width: 86px; height: 86px; border-width: 3px; }
  .cell-portrait .ico { width: 60px; height: 60px; }
  .cell-name { font-size: .92rem; }
  .cell-back { font-size: .8rem; line-height: 1.6; padding: .7rem; justify-content: flex-start; overflow-y: auto; }
  .cell-back-ico { width: 34px; height: 34px; }
  .speed-chart { padding: 1rem .6rem; }
  .speed-svg .curve-label { font-size: 26px; stroke-width: 7px; }
  .speed-svg .axis-label, .speed-svg .mem-label { font-size: 22px; }
  .speed-svg .curve { stroke-width: 7; }
}

@media (max-width: 380px) {
  .container { width: 94%; }
  .brand { font-size: 1rem; }
  .flow-num { width: 44px; height: 44px; }
  .flow-num .ico { width: 26px; height: 26px; }
  .flow-badge { width: 18px; height: 18px; font-size: .65rem; }
  .cell-card { height: 236px; }
  .mm-node { font-size: .88rem; }
}

/* Touch screens: no sticky hover lift */
@media (hover: none) {
  .btn:hover, .mm-node:hover, .sort-card:hover { transform: none; box-shadow: none; }
  .mm-node.active { box-shadow: 0 0 0 4px color-mix(in srgb, var(--c, var(--center)) 30%, transparent); }
}

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