:root {
  --ink:       #0c1015;
  --panel:     #11161e;
  --panel2:    #161d27;
  --card:      #141b24;
  --line:      #222b37;
  --line2:     #2c3744;
  --text:      #e8edf3;
  --muted:     #8d97a6;
  --faint:     #6a7383;
  --amber:     #f5a524;
  --amber-dim: #caa15a;
  --steel:     #5a9be0;
  --steel-dim: #6f8fb5;
  --green:     #46c46a;
  --red:       #f06a5d;
  --radius:    10px;
  --side:      var(--amber); /* dynamic accent */
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ---------- LAYOUT ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 300px;
  flex: 0 0 300px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 40;
}

.brand {
  padding: 22px 22px 16px;
  border-bottom: 1px solid var(--line);
}

.brand .cs {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: .28em;
  color: var(--amber);
  text-transform: uppercase;
  font-weight: 700;
}

.brand h2 {
  font-family: "Oswald", sans-serif;
  font-weight: 600;
  font-size: 22px;
  margin: 6px 0 0;
  letter-spacing: .02em;
  text-transform: uppercase;
}

.brand .roster { font-size: 11.5px; color: var(--faint); margin-top: 4px; }

.search { padding: 14px 16px 6px; }

.search input {
  width: 100%;
  background: var(--panel2);
  border: 1px solid var(--line2);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 13px;
  font-family: inherit;
}

.search input::placeholder { color: var(--faint); }
.search input:focus { outline: 2px solid var(--side); outline-offset: 1px; border-color: transparent; }

.nav { flex: 1; overflow-y: auto; padding: 8px 10px 28px; }
.nav::-webkit-scrollbar { width: 8px; }
.nav::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 8px; }

.navgroup { margin-bottom: 6px; }

.grouphead {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  font-family: "Oswald", sans-serif;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 10px 10px 8px;
}

.grouphead .chev { color: var(--faint); transition: transform .18s ease; font-size: 11px; }
.navgroup.collapsed .chev { transform: rotate(0deg); }
.navgroup:not(.collapsed) .chev { transform: rotate(90deg); }
.grouplinks { display: block; overflow: hidden; }
.navgroup.collapsed .grouplinks { display: none; }

.navlink {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px 7px 12px;
  font-size: 13px;
  color: var(--muted);
  border-radius: 7px;
  margin: 1px 0;
  border-left: 2px solid transparent;
}

.navlink .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--line2);
  flex: 0 0 6px;
  transition: background .15s;
}

.navlink.terro .dot { background: var(--amber-dim); }
.navlink.ct    .dot { background: var(--steel-dim); }
.navlink:hover       { color: var(--text); background: var(--panel2); }
.navlink.active      { color: var(--text); background: var(--panel2); font-weight: 600; }

.navlink.active.terro { border-left-color: var(--amber); }
.navlink.active.terro .dot { background: var(--amber); }
.navlink.active.ct    { border-left-color: var(--steel); }
.navlink.active.ct    .dot { background: var(--steel); }
.navlink.active.gen   { border-left-color: var(--muted); }
.navlink.active.gen   .dot { background: var(--muted); }
.navlink.hidden { display: none; }

/* ---------- MAIN ---------- */
.main { flex: 1; min-width: 0; }

.topbar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
}

.burger {
  background: var(--panel2);
  border: 1px solid var(--line2);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 11px;
  cursor: pointer;
  font-size: 16px;
}

.topbar .ttl {
  font-family: "Oswald", sans-serif;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 600;
}

.content { max-width: 880px; margin: 0 auto; padding: 46px 40px 120px; }

.doc { margin-bottom: 30px; }

.dochead {
  margin: 64px 0 26px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.doc:first-child .dochead { margin-top: 8px; }

.dochead .eyebrow {
  font-family: "JetBrains Mono", monospace;
  font-size: 10.5px;
  letter-spacing: .3em;
  text-transform: uppercase;
  color: var(--amber);
  font-weight: 700;
}

.dochead h1 {
  font-family: "Oswald", sans-serif;
  font-weight: 700;
  font-size: 46px;
  margin: 8px 0 4px;
  letter-spacing: .005em;
  text-transform: uppercase;
  line-height: 1.02;
}

.dochead .dsub { color: var(--muted); font-size: 15px; margin: 0; }

.sec { scroll-margin-top: 64px; padding: 26px 0 8px; border-top: 1px solid var(--line); }
.sec:first-of-type { border-top: none; }

.sechead { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }

.sechead h2 {
  font-family: "Oswald", sans-serif;
  font-weight: 600;
  font-size: 24px;
  margin: 0;
  letter-spacing: .01em;
  text-transform: uppercase;
  position: relative;
  padding-left: 16px;
}

.sechead h2::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 5px;
  height: 26px;
  border-radius: 3px;
  background: var(--side);
}

.sec.terro { --side: var(--amber); }
.sec.ct    { --side: var(--steel); }
.sec.gen   { --side: var(--muted); }

.side-pill {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 20px;
  color: var(--ink);
  background: var(--side);
}

.sec.gen .side-pill { color: var(--text); background: var(--panel2); border: 1px solid var(--line2); }

h3 {
  font-family: "Oswald", sans-serif;
  font-weight: 500;
  font-size: 17px;
  letter-spacing: .02em;
  text-transform: uppercase;
  margin: 24px 0 8px;
  color: var(--text);
}

h3 .accent, .accent { color: var(--side); }

h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--steel-dim);
  margin: 18px 0 6px;
  letter-spacing: .02em;
}

.sec.terro h4 { color: var(--amber-dim); }
.sec.gen   h4 { color: var(--faint); }

p      { margin: 8px 0 12px; color: #d4dbe4; }
.note  { color: var(--muted); font-style: italic; font-size: 13.5px; }
.todo  { color: var(--faint); font-style: italic; }
em     { color: var(--muted); font-style: italic; }
strong { color: #fff; font-weight: 600; }
sup    { font-size: .7em; }

ul { list-style: none; margin: 10px 0 14px; padding: 0; }

li {
  position: relative;
  padding-left: 20px;
  margin-bottom: 7px;
  color: #d4dbe4;
}

li::before {
  content: "";
  position: absolute;
  left: 3px;
  top: .62em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--side);
  opacity: .85;
}

ul ul { margin: 6px 0; }
ul ul li::before { background: transparent; border: 1.4px solid var(--faint); top: .55em; }

/* ---------- CALLOUTS ---------- */
.callout {
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 14px 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-left-width: 4px;
}

.callout .clabel {
  display: block;
  font-family: "JetBrains Mono", monospace;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.callout p:last-child,
.callout ul:last-child { margin-bottom: 0; }
.callout p:first-of-type { margin-top: 0; }

.callout.warn { border-left-color: var(--red);   background: rgba(240, 106,  93, .07); }
.callout.info { border-left-color: var(--steel);  background: rgba( 90, 155, 224, .07); }
.callout.tip  { border-left-color: var(--amber);  background: rgba(245, 165,  36, .07); }
.callout.key  { border-left-color: var(--green);  background: rgba( 70, 196, 106, .07); }

.callout.warn .clabel { color: var(--red);   }
.callout.info .clabel { color: var(--steel); }
.callout.tip  .clabel { color: var(--amber); }
.callout.key  .clabel { color: var(--green); }

/* ---------- ROLES ---------- */
.roles {
  margin: 12px 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.role {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}

.role:last-child { border-bottom: none; }

.role .zone {
  font-family: "Oswald", sans-serif;
  text-transform: uppercase;
  font-size: 13.5px;
  letter-spacing: .03em;
  color: var(--steel-dim);
}

.sec.terro .role .zone { color: var(--amber-dim); }

.role .who {
  font-family: "JetBrains Mono", monospace;
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
}

/* ---------- GLOSSARY ---------- */
.glossary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 22px;
  margin: 14px 0;
}

.term { padding-left: 12px; border-left: 3px solid var(--amber); }

.term .tname {
  font-family: "Oswald", sans-serif;
  text-transform: uppercase;
  font-weight: 600;
  font-size: 14px;
  color: #fff;
  display: block;
  letter-spacing: .02em;
}

.term .tdef { font-size: 13px; color: var(--muted); }

/* ---------- STUFF GRID ---------- */
.stuffgrid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 18px;
  margin: 14px 0;
}

.stuffgrid .s {
  position: relative;
  padding: 7px 12px 7px 26px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  color: #d4dbe4;
}

.stuffgrid .s::before {
  content: "›";
  position: absolute;
  left: 11px;
  top: 7px;
  color: var(--amber);
  font-weight: 700;
}

.scrim { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 35; }

/* ---------- CHANGELOG ---------- */
.clog-list { list-style: none; margin: 0; padding: 0; }
.clog-list > li { margin-bottom: 0; padding-left: 0; }
.clog-list > li::before { display: none; }

.clog-entry {
  padding: 20px 0 10px;
  border-top: 1px solid var(--line);
}
.clog-entry:first-child { border-top: none; padding-top: 4px; }

.clog-date {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: 10px;
  display: block;
}

.clog-items { list-style: none; margin: 0; padding: 0; }
.clog-items > li {
  position: relative;
  padding-left: 18px;
  margin-bottom: 6px;
  font-size: 13.5px;
  color: #d4dbe4;
}
.clog-items > li::before {
  content: "›";
  position: absolute;
  left: 3px;
  top: 0;
  color: var(--amber);
  font-weight: 700;
  opacity: 1;
  background: none;
  width: auto;
  height: auto;
  border-radius: 0;
}

/* ---------- TAB BAR ---------- */
.tabbar {
  display: flex;
  background: var(--panel);
  border-bottom: 2px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.tab {
  flex: 1;
  padding: 13px 14px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  color: var(--muted);
  font-family: "Oswald", sans-serif;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
}

.tab:hover  { color: var(--text); background: var(--panel2); }
.tab.active { color: var(--text); border-bottom-color: var(--amber); }

/* ---------- SUB-TAB BAR ---------- */
.subtabbar {
  display: none;
  background: var(--panel2);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 47px;
  z-index: 19;
  padding: 0 20px;
  gap: 4px;
}

.subtabbar.visible { display: flex; }

.subtab {
  padding: 9px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  color: var(--faint);
  font-family: "Oswald", sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
}

.subtab:hover  { color: var(--muted); }
.subtab.active { color: var(--amber); border-bottom-color: var(--amber); }

/* ---------- VIDEO GRID ---------- */
.video-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin: 14px 0;
}

.video-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.video-card video {
  width: 100%;
  display: block;
  background: #000;
  max-height: 190px;
  object-fit: contain;
}

.video-card .vlabel {
  padding: 8px 12px 10px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.4;
}

.video-card .vlabel strong {
  display: block;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 1px;
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: 0 0 40px rgba(0, 0, 0, .5);
  }
  body.navopen .sidebar { transform: translateX(0); }
  body.navopen .scrim   { display: block; }
  .topbar    { display: flex; }
  .tabbar    { top: 56px; }
  .subtabbar { top: 104px; }
  .content   { padding: 30px 22px 100px; }
  .dochead h1 { font-size: 36px; }
  .glossary, .stuffgrid, .video-grid { grid-template-columns: 1fr; }
  .sec { scroll-margin-top: 160px; }
}

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