:root {
  color-scheme: dark;
  font-family: "Segoe UI", Inter, Arial, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  --bg: #070b09;
  --surface: #0b110e;
  --surface-2: #0f1712;
  --surface-3: #121e17;
  --line: #1d3024;
  --line-lit: #31573d;
  --green: #53ff91;
  --green-soft: #a0ffc0;
  --ink: #e4f1e8;
  --muted: #8ca192;
  --dim: #52675a;
  --mono: "Cascadia Code", Consolas, "Courier New", monospace;
  --display: "Segoe UI", Inter, Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; height: 100vh; overflow: hidden; color: var(--ink); background: var(--bg); }
button, input { font: inherit; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; }

.topbar {
  height: 76px; display: grid; grid-template-columns: 1fr 1fr 1fr; align-items: center;
  padding: 0 35px; background: #090e0b; border-bottom: 1px solid #1b2c21; position: relative; z-index: 10;
}
.brand { width: max-content; display: flex; align-items: center; gap: 9px; color: #edfff2; text-decoration: none; font: 700 18px var(--display); letter-spacing: -.055em; }
.brand-mark { width: 23px; height: 26px; flex: none; overflow: visible; fill: none; stroke: var(--green); stroke-width: 1.45; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 4px #53ff9140); }
.brand-name { white-space: nowrap; }
.brand-version { align-self: center; margin: 2px 0 0 1px; padding: 3px 5px; border: 1px solid #31573d; color: #77c889; background: #0d1710; font: 7px var(--mono); letter-spacing: .1em; }
.top-title { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.top-kicker, .card-kind, .detail-kicker, .section-label { font: 9px var(--mono); letter-spacing: .12em; color: #75907d; }
.top-kicker { color: var(--green); }
.top-role { color: #c1d5c6; font: 500 12px var(--mono); letter-spacing: .035em; }
.search-wrap { justify-self: end; width: min(330px, 100%); height: 40px; display: flex; align-items: center; gap: 10px; padding: 0 11px; position: relative; border: 1px solid #26392b; border-radius: 3px; background: #0c130f; }
.search-wrap:focus-within { border-color: #4da36a; box-shadow: 0 0 0 2px #53ff9112; }
.search-icon { color: var(--green); font: 20px/1 var(--mono); }
.search-wrap input { min-width: 0; flex: 1; border: 0; outline: 0; color: var(--ink); background: transparent; font: 11px var(--mono); }
.search-wrap input::placeholder { color: #607265; }
.search-wrap kbd { padding: 3px 5px; border: 1px solid #26392b; border-radius: 2px; color: #779180; background: #0b120d; font: 9px var(--mono); }
.search-results { position: absolute; top: 46px; left: 0; right: 0; z-index: 20; max-height: 410px; overflow: auto; padding: 5px; border: 1px solid #2a4932; border-radius: 4px; background: #0b120e; box-shadow: 0 18px 50px #000b; }
.hidden { display: none !important; }
.search-result { width: 100%; display: flex; align-items: center; justify-content: space-between; padding: 10px 9px; border: 0; border-radius: 2px; text-align: left; color: var(--ink); background: transparent; cursor: pointer; }
.search-result:hover { background: #12251a; }
.search-result b { display: block; color: #dfffea; font: 600 12px var(--mono); }
.search-result small { display: block; max-width: 250px; overflow: hidden; margin-top: 4px; color: #819586; font-size: 10px; white-space: nowrap; text-overflow: ellipsis; }
.search-result i { color: var(--green); font-style: normal; }
.search-empty { padding: 14px 10px; color: var(--muted); font: 11px var(--mono); }

.app-shell { height: calc(100vh - 76px); display: flex; flex-direction: column; padding: 0 32px 23px; }
.map-topline { height: 58px; min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.breadcrumbs { min-width: 0; display: flex; align-items: center; gap: 9px; overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
.breadcrumbs::-webkit-scrollbar { display: none; }
.crumb { flex: none; padding: 3px 0; border: 0; color: #71887a; background: none; font: 10px var(--mono); cursor: pointer; }
.crumb:hover, .crumb.current { color: var(--green); }
.crumb.current { font-weight: 500; }
.crumb-sep { flex: none; color: #3d5946; font: 11px var(--mono); }
.map-instructions { display: flex; align-items: center; gap: 8px; color: #718579; font: 10px var(--mono); white-space: nowrap; }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 9px #53ff91a8; }
.workspace { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 346px; overflow: hidden; border: 1px solid #1c3023; border-radius: 4px; background: var(--surface); box-shadow: 0 18px 80px #0005; }
.map-stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; touch-action: none; overscroll-behavior: contain; background-color: #080e0a; background-image: radial-gradient(#31553a55 .75px, transparent .9px); background-size: 21px 21px; }
.map-stage::before { content: "01001011  00110101  10100110  01011001  11001010  00101101  10010110  01100011"; position: absolute; z-index: 0; top: 16%; right: 13%; width: 250px; color: #59d783; opacity: .055; font: 10px/2.7 var(--mono); letter-spacing: .2em; word-break: break-all; pointer-events: none; }
.map-stage::after { content: "NODE / 0x04   ·   LINK / ACTIVE   ·   ROUTE / OPEN"; position: absolute; right: 18px; bottom: 15px; color: #41604a; font: 8px var(--mono); letter-spacing: .12em; pointer-events: none; }
.map-stage.is-dragging { cursor: grabbing; }
.map-stage svg { position: relative; z-index: 1; width: 100%; height: 100%; display: block; overflow: visible; user-select: none; }
.edge { fill: none; stroke: #36543c; stroke-width: 1.35; vector-effect: non-scaling-stroke; }
.edge-related { stroke: #68c67e; stroke-width: 1.2; stroke-dasharray: 3 6; opacity: .72; }
.node-card { position: relative; width: 232px; height: 108px; overflow: hidden; border: 1px solid #263b2c; border-radius: 3px; color: var(--ink); background: #0c140f; box-shadow: 0 7px 24px #0005; transition: border-color .16s, box-shadow .16s, transform .16s; }
.node-card:hover { transform: translateY(-2px); border-color: #5c9c68; box-shadow: 0 0 0 1px #53ff9121, 0 12px 30px #0009; }
.node-card.is-selected { border-color: var(--green); box-shadow: inset 0 0 0 1px #53ff9129, 0 0 23px #53ff9118; }
.node-card.quiz-complete { border-color: #69ef91; box-shadow: inset 0 0 0 1px #53ff9138, 0 0 9px #53ff9170, 0 0 27px #53ff9140; }
.node-card.quiz-complete.is-selected { box-shadow: inset 0 0 0 1px #a0ffb2, 0 0 12px #53ff91aa, 0 0 34px #53ff9160; }
.node-card.root { border-color: #57e77f; color: #f0fff3; background: linear-gradient(135deg, #10351e, #0b2113 70%); }
.node-card.root::after { content: "ROOT"; position: absolute; right: 10px; bottom: 8px; color: #7bf79b; font: 8px var(--mono); letter-spacing: .12em; }
.node-card.root.is-selected { box-shadow: inset 0 0 0 1px #53ff9144, 0 0 30px #53ff9124; }
.node-card.domain { border-color: #31573c; background: #0d1a11; }
.card-main { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 12px 37px 10px 13px; border: 0; color: inherit; text-align: left; background: transparent; cursor: pointer; }
.card-kind { max-width: 100%; overflow: hidden; color: #75917b; font-size: 8px; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }
.card-kind i { display: inline-block; width: 3px; height: 3px; margin: 0 4px; border-radius: 50%; vertical-align: middle; background: #4d7656; }
.root .card-kind { color: #74d98b; }
.domain .card-kind { color: #84c091; }
.card-name { color: #e5f5e9; font: 600 13px/1.25 var(--mono); letter-spacing: -.035em; }
.root .card-name { color: #f2fff5; font-size: 14px; }
.card-summary { display: -webkit-box; overflow: hidden; color: #84978a; font-size: 10px; line-height: 1.4; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.quiz-badge { position: absolute; right: 8px; bottom: 7px; color: #8dffa8; font: 7px var(--mono); letter-spacing: .07em; text-shadow: 0 0 8px #53ff91a8; }
.root .card-summary { color: #a4c6ad; }
.root .quiz-badge { right: auto; left: 13px; bottom: 7px; }

.map-controls { position: absolute; z-index: 3; top: 16px; right: 16px; display: flex; flex-direction: column; padding: 4px; border: 1px solid #29412f; border-radius: 3px; background: #0a120d; box-shadow: 0 8px 24px #0007; }
.map-controls button { width: 30px; height: 30px; border: 0; border-radius: 2px; color: #99b79f; background: transparent; font: 17px var(--mono); cursor: pointer; }
.map-controls button:hover { color: var(--green); background: #12251a; }
.map-controls span { height: 1px; margin: 2px 5px; background: #1f3525; }
.map-legend { position: absolute; z-index: 2; top: 16px; left: 16px; display: flex; align-items: center; gap: 13px; padding: 8px 10px; border: 1px solid #263b2b; border-radius: 2px; color: #829787; background: #09110cdd; font: 9px var(--mono); backdrop-filter: blur(5px); }
.map-legend span { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 6px; height: 6px; border-radius: 50%; background: #6e9275; }
.root-dot { background: var(--green); box-shadow: 0 0 7px #53ff91; }
.domain-dot { background: #64b978; }
.pan-hint { position: absolute; bottom: 15px; left: 16px; z-index: 2; color: #536b58; font: 8px var(--mono); letter-spacing: .1em; pointer-events: none; }
.mobile-sheet-handle { display: none; }

.detail-panel { min-width: 0; display: flex; flex-direction: column; overflow: auto; padding: 25px 23px 22px; border-left: 1px solid #203426; background: #0a100c; }
.detail-heading { display: flex; align-items: center; justify-content: space-between; }
.detail-kicker { font-size: 8px; }
.close-detail { display: none; width: 29px; height: 29px; border: 1px solid #2a4030; border-radius: 2px; color: #a6c0ab; background: #111b14; font-size: 19px; line-height: 1; cursor: pointer; }
.detail-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 9px; margin-top: 18px; }
.detail-title-row h1 { max-width: 220px; margin: 0; color: #edfff0; font: 600 22px/1.2 var(--display); letter-spacing: -.045em; }
.level-chip { flex: none; padding: 5px 7px; border: 1px solid #294631; border-radius: 2px; color: #90d69c; background: #102016; font: 8px var(--mono); }
.detail-summary { margin: 10px 0 20px; color: #93a699; font-size: 12px; line-height: 1.6; }
.detail-section { margin-top: 17px; }
.section-label { color: #6f9778; font-size: 8px; }
.next-hint { margin: 7px 0 2px; color: #718978; font: 9px var(--mono); line-height: 1.5; }
.detail-copy, .example-box p { margin: 9px 0 0; color: #b6c9ba; font-size: 11px; line-height: 1.75; }
.example-box { margin-top: 19px; padding: 14px; border: 1px solid #263b2b; border-left: 2px solid #4dcc71; border-radius: 2px; background: #0e1711; }
.example-box p { margin-top: 8px; color: #a5baa9; font-size: 10px; }
.quiz-panel { margin-top: 20px; padding: 14px; border: 1px solid #294531; border-radius: 3px; background: linear-gradient(145deg,#0d1911,#0a120d); }
.quiz-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.quiz-intro { margin: 6px 0 0; color: #849989; font-size: 10px; }
.quiz-round { flex: none; padding: 4px 6px; border: 1px solid #28432e; color: #78b984; font: 8px var(--mono); }
.quiz-question { min-width: 0; margin: 14px 0 0; padding: 0; border: 0; }
.quiz-question legend { width: 100%; display: flex; align-items: flex-start; gap: 8px; color: #d4e5d8; font-size: 10px; line-height: 1.5; }
.quiz-question legend b { flex: none; color: var(--green); font: 9px var(--mono); }
.quiz-options { display: grid; gap: 5px; margin-top: 8px; }
.quiz-option { display: flex; align-items: flex-start; gap: 8px; padding: 8px; border: 1px solid #1d3023; color: #a9bcad; background: #09110c; font-size: 9px; line-height: 1.45; cursor: pointer; }
.quiz-option:hover { border-color: #416b49; background: #0e1a12; }
.quiz-option input { flex: none; width: 12px; height: 12px; margin: 1px 0 0; accent-color: var(--green); }
.quiz-option.option-correct { border-color: #3b8a50; color: #c9f8d2; background: #102316; }
.quiz-option.option-wrong { border-color: #98594d; color: #f1c2b7; background: #24130f; }
.quiz-question:disabled .quiz-option { cursor: default; }
.quiz-feedback { margin: 7px 0 0; padding: 8px; border-left: 2px solid; font-size: 9px; line-height: 1.55; }
.quiz-feedback.good { border-color: #55d879; color: #aee9bb; background: #102016; }
.quiz-feedback.bad { border-color: #d27a65; color: #e8b3a6; background: #1d1310; }
.quiz-error { margin: 10px 0 0; color: #ffb9a6; font-size: 10px; }
.quiz-result { margin: 12px 0 0; color: #e6c389; font: 10px/1.5 var(--mono); }
.quiz-result.success { color: #83e99a; }
.quiz-submit { width: 100%; margin-top: 13px; padding: 10px; border: 1px solid #4da763; border-radius: 2px; color: #08110b; background: #62e782; font: 600 10px var(--mono); cursor: pointer; }
.quiz-submit:hover { background: #8cff9f; box-shadow: 0 0 18px #53ff912b; }
.quiz-retry { border-color: #40704a; color: #c8efd0; background: #112319; }
.locked-next { padding: 10px 11px; border: 1px dashed #304735; background: #0b130d; }
.locked-next .next-hint { margin-bottom: 0; }
.child-list { display: grid; gap: 2px; margin-top: 8px; }
.child-link { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 9px; padding: 9px 1px; border: 0; border-bottom: 1px solid #19271d; color: #b4c9b8; text-align: left; background: transparent; font-size: 10px; cursor: pointer; }
.child-link:hover { color: var(--green); }
.child-link i { color: #73ad7e; font: normal 13px var(--mono); }
.relation-list { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.relation-chip { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border: 1px solid #263a2b; border-radius: 2px; color: #b8d5bf; background: #0c150f; font-size: 9px; cursor: pointer; }
.relation-chip:hover { border-color: #5a9b67; background: #102018; }
.relation-chip span { color: #70917a; font: 7px var(--mono); text-transform: uppercase; }
.relation-chip b { color: var(--green); font-weight: 400; }
.detail-bottom { margin-top: auto; padding-top: 22px; }
.parent-link { display: block; margin-bottom: 13px; padding: 0; border: 0; color: #7e9e84; background: none; font: 9px var(--mono); cursor: pointer; }
.parent-link:hover { color: var(--green); }
.end-note { padding: 10px 0; color: #74897a; font: 9px var(--mono); }

@media (max-width: 950px) {
  .topbar { grid-template-columns: .8fr 1fr 1.2fr; padding: 0 20px; }
  .app-shell { padding: 0 18px 17px; }
  .workspace { grid-template-columns: minmax(0, 1fr) 305px; }
  .detail-panel { padding: 21px 18px; }
  .map-instructions { font-size: 9px; }
}
@media (max-width: 760px) {
  body { height: 100dvh; }
  .topbar { height: auto; min-height: 65px; grid-template-columns: 1fr auto; gap: 10px; padding: 10px 14px; }
  .brand { font-size: 16px; }
  .top-title { align-items: flex-end; gap: 4px; }
  .top-kicker { font-size: 7px; }
  .top-role { font-size: 10px; }
  .search-wrap { grid-column: 1 / -1; grid-row: 2; width: 100%; height: 37px; }
  .search-results { top: 43px; }
  .app-shell { height: calc(100dvh - 115px); padding: 0 10px 10px; }
  .map-topline { height: 46px; min-height: 46px; align-items: center; }
  .crumb { font-size: 8px; }
  .map-instructions { display: none; }
  .workspace { position: relative; display: block; border-radius: 3px; }
  .map-stage { position: absolute; inset: 0; }
  .map-legend { top: 10px; left: 10px; gap: 8px; padding: 7px 8px; font-size: 7px; }
  .legend-dot { width: 5px; height: 5px; }
  .map-controls { top: 10px; right: 10px; }
  .map-controls button { width: 27px; height: 27px; }
  .map-stage::after { display: none; }
  .pan-hint { bottom: 12px; left: 11px; font-size: 7px; }
  .detail-panel { position: absolute; z-index: 4; right: 0; bottom: 0; left: 0; max-height: min(57%, 430px); padding: 17px 17px 16px; overflow: auto; border: 1px solid #29432f; border-bottom: 0; border-radius: 4px 4px 0 0; background: #0a110c; box-shadow: 0 -10px 40px #0008; transform: translateY(calc(100% - 43px)); transition: transform .28s ease; }
  .detail-panel:not(.mobile-open) > :not(.mobile-sheet-handle) { visibility: hidden; }
  .detail-panel.mobile-open { transform: translateY(0); }
  .detail-panel.mobile-open .close-detail { display: block; }
  .mobile-sheet-handle { position: absolute; top: 0; left: 0; width: 100%; height: 42px; display: flex; align-items: center; justify-content: center; gap: 8px; border: 0; color: #9ab8a0; background: transparent; font: 9px var(--mono); cursor: pointer; }
  .mobile-sheet-handle::before { content: ""; width: 30px; height: 3px; border-radius: 4px; background: #507258; }
  .detail-panel .detail-heading { padding-top: 4px; }
  .detail-title-row { margin-top: 12px; }
  .detail-title-row h1 { font-size: 19px; }
  .detail-summary { margin: 7px 0 12px; font-size: 10px; }
  .detail-section { margin-top: 12px; }
  .detail-copy { font-size: 10px; line-height: 1.55; }
  .example-box { margin-top: 13px; padding: 11px; }
  .example-box p { font-size: 9px; line-height: 1.5; }
  .detail-bottom { padding-top: 12px; }
}
@media (max-width: 390px) {
  .app-shell { padding-right: 7px; padding-left: 7px; }
  .map-topline { padding: 0 2px; }
  .map-legend { gap: 6px; }
  .map-legend span { gap: 4px; }
  .detail-panel { padding-right: 14px; padding-left: 14px; }
  .node-card { width: 220px; }
  .card-main { padding-left: 11px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
