:root{
  --bg: #0b1020;
  --panel: rgba(255,255,255,.06);
  --panel2: rgba(255,255,255,.085);
  --stroke: rgba(255,255,255,.12);
  --text: rgba(255,255,255,.88);
  --muted: rgba(255,255,255,.62);
  --muted2: rgba(255,255,255,.48);
  --brand: #7c3aed;
  --brand2: #22c55e;
  --accent: #06b6d4;
  --danger: #ef4444;
  --shadow: 0 20px 60px rgba(0,0,0,.35);
  --radius: 16px;
  --radius2: 22px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

:root[data-theme="light"]{
  --bg: #f6f7fb;
  --panel: rgba(15, 23, 42, .05);
  --panel2: rgba(15, 23, 42, .075);
  --stroke: rgba(15, 23, 42, .14);
  --text: rgba(15, 23, 42, .90);
  --muted: rgba(15, 23, 42, .64);
  --muted2: rgba(15, 23, 42, .52);
  --shadow: 0 18px 50px rgba(2, 6, 23, .18);
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
  background:
    radial-gradient(1200px 800px at 20% 0%, rgba(124,58,237,.32), transparent 60%),
    radial-gradient(900px 700px at 90% 10%, rgba(6,182,212,.24), transparent 55%),
    radial-gradient(900px 700px at 60% 100%, rgba(34,197,94,.18), transparent 60%),
    var(--bg);
  color: var(--text);
  overflow:hidden;
}

a{color:inherit}
code{font-family:var(--mono); font-size:.95em}

.skip-link{
  position:absolute; left:-999px; top:12px;
  padding:10px 12px; background:var(--panel2);
  border:1px solid var(--stroke); border-radius:12px;
}
.skip-link:focus{left:12px; z-index:10}

.app{
  height:100vh;
  display:grid;
  grid-template-columns: 360px 1fr;
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "topbar topbar"
    "sidebar main";
}

.topbar{
  grid-area: topbar;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:14px 18px;
  border-bottom:1px solid var(--stroke);
  background: linear-gradient(180deg, rgba(0,0,0,.18), rgba(0,0,0,0));
  backdrop-filter: blur(10px);
}

.brand{display:flex; gap:12px; align-items:center}
.brand__mark{
  width:44px; height:44px;
  border-radius:14px;
  display:grid; place-items:center;
  background: linear-gradient(135deg, rgba(124,58,237,.9), rgba(6,182,212,.75));
  box-shadow: var(--shadow);
}
.brand__title{font-weight:700; letter-spacing:-.02em}
.brand__subtitle{color:var(--muted); font-size:12px; margin-top:2px}

.segmented{
  display:flex;
  gap:10px;
  padding:6px;
  border-radius:999px;
  border:1px solid var(--stroke);
  background: rgba(255,255,255,.04);
}
.segmented__btn{
  border:0;
  padding:10px 14px;
  border-radius:999px;
  background:transparent;
  color:var(--muted);
  font-weight:600;
  cursor:pointer;
  display:flex;
  gap:10px;
  align-items:center;
}
.segmented__btn[aria-selected="true"]{
  background: rgba(255,255,255,.09);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
}

.icon-btn{
  width:42px; height:42px;
  border-radius:14px;
  border:1px solid var(--stroke);
  background: rgba(255,255,255,.04);
  color: var(--text);
  cursor:pointer;
}
.icon-btn:hover{background: rgba(255,255,255,.07)}

.sidebar{
  grid-area: sidebar;
  height: calc(100vh - 68px);
  overflow:auto;
  padding:16px;
  border-right:1px solid var(--stroke);
  background: rgba(0,0,0,.12);
  backdrop-filter: blur(10px);
}

.sidebar__section{margin-bottom:16px}
.sidebar__title{display:flex; align-items:center; justify-content:space-between; gap:12px; margin:10px 2px}
.sidebar__actions{display:flex; gap:8px; flex-wrap:wrap; justify-content:flex-end}

.search{
  position:relative;
  display:flex;
  align-items:center;
  border:1px solid var(--stroke);
  background: rgba(255,255,255,.04);
  border-radius: 18px;
  padding:10px 12px;
}
.search input{
  flex:1;
  background:transparent;
  border:0;
  outline:none;
  color:var(--text);
  font-size:14px;
}
.search input::placeholder{color:var(--muted2)}
.search__btn{
  width:34px; height:34px;
  border-radius:12px;
  border:0;
  background: rgba(255,255,255,.06);
  color:var(--text);
  cursor:pointer;
}
.search__btn:hover{background: rgba(255,255,255,.1)}
.searchmeta{color:var(--muted); font-size:12px; padding:8px 4px 0}

.chip{
  border:1px solid var(--stroke);
  background: rgba(255,255,255,.04);
  color: var(--muted);
  padding:7px 10px;
  border-radius:999px;
  cursor:pointer;
  font-weight:600;
  font-size:12px;
}
.chip:hover{background: rgba(255,255,255,.07); color:var(--text)}

.toc{display:flex; flex-direction:column; gap:8px}
.toc a{
  text-decoration:none;
  padding:10px 12px;
  border:1px solid transparent;
  border-radius:14px;
  color: var(--muted);
  background: transparent;
  display:flex;
  align-items:center;
  gap:10px;
}
.toc a:hover{background: rgba(255,255,255,.05); color:var(--text)}
.toc a.is-active{border-color: rgba(124,58,237,.35); background: rgba(124,58,237,.14); color: var(--text)}
.toc .toc__meta{margin-left:auto; font-size:12px; color:var(--muted2)}

.note{
  border:1px solid var(--stroke);
  background: rgba(255,255,255,.04);
  border-radius: var(--radius);
  padding:12px;
}
.note__title{font-weight:700; display:flex; align-items:center; gap:10px}
.note__body{color:var(--muted); font-size:12px; line-height:1.45; margin-top:8px}

.main{
  grid-area: main;
  height: calc(100vh - 68px);
  overflow:auto;
}

.content{max-width: 1100px; margin:0 auto; padding: 18px 18px 36px}

.hero{
  display:grid;
  grid-template-columns: 1.25fr .95fr;
  gap:16px;
  align-items:stretch;
  padding: 14px 0 10px;
}
.hero__copy h1{margin:0 0 10px; font-size: 28px; letter-spacing:-.03em}
.hero__copy p{margin:0 0 12px; color:var(--muted); line-height:1.6}
.hero__actions{display:flex; gap:10px; flex-wrap:wrap; margin: 10px 0 10px}
.hero__meta{display:flex; gap:10px; flex-wrap:wrap; margin-top:10px}

.pill{
  display:inline-flex; align-items:center; gap:10px;
  border:1px solid var(--stroke);
  background: rgba(255,255,255,.04);
  padding:8px 10px;
  border-radius:999px;
  color: var(--muted);
  font-size:12px;
  font-weight:600;
}

.btn{
  border:1px solid rgba(124,58,237,.38);
  background: linear-gradient(135deg, rgba(124,58,237,.9), rgba(6,182,212,.55));
  color: white;
  padding:10px 12px;
  border-radius: 14px;
  cursor:pointer;
  font-weight:700;
  display:inline-flex; align-items:center; gap:10px;
  box-shadow: var(--shadow);
}
.btn:hover{filter:brightness(1.05)}
.btn--ghost{
  background: rgba(255,255,255,.04);
  border-color: var(--stroke);
  color: var(--text);
  box-shadow:none;
}
.btn--ghost:hover{background: rgba(255,255,255,.07)}

.hero__panel{
  border:1px solid var(--stroke);
  background: rgba(255,255,255,.04);
  border-radius: var(--radius2);
  padding:14px;
}

.cardgrid{display:grid; grid-template-columns: 1fr 1fr; gap:10px}
.card{
  text-align:left;
  border:1px solid var(--stroke);
  background: rgba(255,255,255,.04);
  border-radius: 16px;
  padding:12px;
  cursor:pointer;
  color: var(--text);
}
.card:hover{background: rgba(255,255,255,.07)}
.card__icon{color: rgba(255,255,255,.82)}
.card__title{font-weight:800; margin-top:8px; letter-spacing:-.02em}
.card__desc{color:var(--muted); font-size:12px; margin-top:6px; line-height:1.4}

.panel{margin-top: 10px}

.section{
  border:1px solid var(--stroke);
  background: rgba(255,255,255,.035);
  border-radius: var(--radius2);
  padding: 14px;
  margin: 12px 0;
}
.section__header{display:flex; align-items:flex-start; justify-content:space-between; gap:12px}
.section__title{margin:0; font-size:18px; letter-spacing:-.02em}
.section__subtitle{margin:6px 0 0; color:var(--muted); font-size:13px; line-height:1.5}

.kbd{
  font-family: var(--mono);
  font-size: 12px;
  border:1px solid var(--stroke);
  background: rgba(255,255,255,.04);
  padding:4px 8px;
  border-radius:10px;
  color: var(--muted);
}

details.module{
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,.04);
  border-radius: var(--radius);
  margin-top:12px;
  overflow:hidden;
}

details.module[open]{background: rgba(255,255,255,.055)}

.module summary{
  list-style:none;
  cursor:pointer;
  padding:12px 12px;
  display:flex;
  gap:10px;
  align-items:flex-start;
}
.module summary::-webkit-details-marker{display:none}

.module__chev{margin-left:auto; color:var(--muted)}
details.module[open] .module__chev{transform: rotate(180deg)}

.module__title{font-weight:800; letter-spacing:-.02em}
.module__meta{color: var(--muted2); font-size:12px; margin-top:4px}

.module__body{padding: 0 12px 12px}
.module__body p{margin: 10px 0; color: var(--text); line-height: 1.7}
.module__body ul{margin: 8px 0 12px 18px; color: var(--text); line-height: 1.7}
.module__body li{margin: 6px 0}
.module__body .muted{color:var(--muted)}

.badge{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:6px 10px;
  border-radius:999px;
  border:1px solid rgba(6,182,212,.35);
  background: rgba(6,182,212,.10);
  color: var(--text);
  font-size:12px;
  font-weight:700;
}
.badge--brand{
  border-color: rgba(124,58,237,.38);
  background: rgba(124,58,237,.14);
}

.hr{height:1px; background: var(--stroke); margin: 10px 0 12px}

.highlight{background: rgba(250,204,21,.22); border-radius:6px; padding:0 2px}

.footer{
  margin-top: 18px;
  padding-top: 14px;
  border-top:1px solid var(--stroke);
  display:flex;
  align-items:center;
  justify-content:space-between;
  color:var(--muted);
  font-size:12px;
}
.footer__link{color:var(--muted); text-decoration:none}
.footer__link:hover{color:var(--text)}

.dialog{
  width:min(720px, calc(100% - 28px));
  border:1px solid var(--stroke);
  border-radius: 18px;
  background: rgba(16, 18, 35, .92);
  color: var(--text);
  box-shadow: var(--shadow);
}
:root[data-theme="light"] .dialog{background: rgba(255,255,255,.96)}

.dialog::backdrop{background: rgba(0,0,0,.5)}
.dialog__header{display:flex; align-items:center; justify-content:space-between; padding: 14px 14px 0}
.dialog__body{padding: 10px 16px 16px; color: var(--muted); line-height:1.6}

.list{margin: 8px 0 0 18px}
.list li{margin:8px 0}

.sr-only{
  position:absolute; width:1px; height:1px; padding:0; margin:-1px;
  overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0;
}

.is-hidden{display:none !important}

@media (max-width: 980px){
  body{overflow:auto}
  .app{
    grid-template-columns: 1fr;
    grid-template-areas:
      "topbar"
      "main";
  }
  .sidebar{display:none}
  .main{height:auto; overflow:visible}
  .hero{grid-template-columns: 1fr;}
  .cardgrid{grid-template-columns: 1fr 1fr}
}

@media (max-width: 520px){
  .cardgrid{grid-template-columns: 1fr}
  .segmented{flex-direction:column; border-radius: 18px}
  .segmented__btn{justify-content:center}
}

@media print{
  body{background:white; color:black; overflow:visible}
  .topbar,.sidebar,.hero__panel,.hero__actions,.footer__right,#btnBackToTop{display:none !important}
  .app{display:block}
  .main{height:auto; overflow:visible}
  .section, details.module{break-inside: avoid}
  details.module{border:1px solid #ddd; background:white}
  .section{border:1px solid #ddd; background:white}
  .module__body p,.module__body ul{color:black}
}
