:root {
  color-scheme: dark;
  --bg: #0c1118;
  --panel: #121b25;
  --surface: #172330;
  --line: #293748;
  --txt: #e9eff5;
  --muted: #9daec1;
  --accent: #ffb354;
  --green: #71d6ad;
  --blue: #8dbbf3;
  --violet: #bdabf7;
  --radius: 18px;
  --shadow: 0 16px 48px #0003;
  font-family:
    Inter,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--txt);
  font-size: 15px;
  line-height: 1.65;
}
button,
input,
select {
  font: inherit;
}
button,
a,
input,
select,
summary {
  -webkit-tap-highlight-color: transparent;
}
button {
  cursor: pointer;
}
a {
  color: var(--blue);
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
button {
  color: inherit;
}
h1,
h2,
h3,
p {
  margin: 0;
}
h1,
h2,
h3 {
  line-height: 1.18;
  letter-spacing: -0.035em;
}
h1 {
  font-size: clamp(34px, 5vw, 60px);
  font-weight: 750;
}
h2 {
  font-size: clamp(25px, 3vw, 35px);
}
h3 {
  font-size: 19px;
}
p {
  color: var(--muted);
}
.shell {
  display: grid;
  grid-template-columns: 285px minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  border-right: 1px solid var(--line);
  padding: 26px 18px;
  background: #101720;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 7px;
}
.brand-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border: 1px solid #b87936;
  border-radius: 13px;
  background: #ffb35413;
  color: var(--accent);
  font-size: 23px;
  font-weight: 800;
  letter-spacing: -2px;
}
.brand strong {
  display: block;
  font-size: 16px;
  line-height: 1.2;
}
.brand small {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
}
.nav-label {
  font-size: 10px;
  letter-spacing: 0.15em;
  color: var(--muted);
  font-weight: 750;
  margin: 17px 9px 6px;
  text-transform: uppercase;
}
.navbtn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: none;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}
.navbtn:hover {
  background: #1c2734;
  color: var(--txt);
}
.navbtn.active {
  background: #ffb35413;
  border-color: #ffb35440;
  color: var(--accent);
}
.navnum {
  font-size: 11px;
  color: #788ba2;
  min-width: 21px;
  font-variant-numeric: tabular-nums;
}
.navbtn.active .navnum {
  color: var(--accent);
}
.navcount {
  margin-left: auto;
  font-size: 10px;
  color: #8fa3b8;
  white-space: nowrap;
}
.side-bottom {
  margin-top: auto;
  padding: 0 8px;
}
.progress-track {
  height: 7px;
  background: #283748;
  border-radius: 10px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0;
  background: var(--green);
  transition: width 0.25s;
}
.tiny {
  font-size: 12px;
  color: var(--muted);
}
.side-progress {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.main {
  min-width: 0;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #0c1118ed;
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px max(24px, calc((100% - 1120px) / 2));
  min-height: 70px;
}
.searchwrap {
  position: relative;
  flex: 1;
  min-width: 0;
}
.searchicon {
  position: absolute;
  left: 13px;
  top: 12px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
}
.search {
  width: 100%;
  padding: 10px 14px 10px 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--txt);
  outline: none;
}
.search::placeholder {
  color: #8293a8;
}
.btn {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 9px;
  padding: 9px 13px;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.25;
  white-space: nowrap;
}
.btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.btn.primary {
  background: var(--accent);
  color: #24170a;
  border-color: var(--accent);
}
.btn.primary:hover {
  background: #ffc780;
}
.mobile-menu {
  display: none;
}
.content {
  max-width: 1168px;
  margin: 0 auto;
  padding: 34px 28px 90px;
}
.eyebrow {
  font-size: 11px;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 750;
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 13px;
}
.eyebrow:before {
  content: "";
  width: 19px;
  height: 2px;
  background: var(--accent);
}
.hero {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: clamp(25px, 4vw, 48px);
  background:
    radial-gradient(ellipse at 98% 5%, #754a262e, transparent 65%),
    linear-gradient(140deg, #17222f, #101822 74%);
  box-shadow: var(--shadow);
}
.hero:after {
  content: "";
  position: absolute;
  right: -70px;
  top: -80px;
  width: 370px;
  height: 370px;
  border: 1px solid #e1a05a18;
  border-radius: 50%;
  box-shadow:
    0 0 0 36px #e1a05a08,
    0 0 0 72px #e1a05a06;
  pointer-events: none;
}
.hero > * {
  position: relative;
  z-index: 1;
}
.hero p {
  max-width: 700px;
  font-size: 16px;
  margin-top: 16px;
}
.hero h1 em {
  font-style: normal;
  color: var(--accent);
}
.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 24px;
}
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 20px 0 38px;
}
.stat {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  padding: 16px;
}
.stat strong {
  font-size: 29px;
  line-height: 1.15;
  display: block;
  letter-spacing: -0.06em;
  font-variant-numeric: tabular-nums;
}
.stat span {
  font-size: 12px;
  color: var(--muted);
}
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 14px;
  margin: 30px 0 17px;
}
.section-head p {
  font-size: 13px;
}
.chapter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
}
.chapter-card {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  background: var(--panel);
  transition:
    border-color 0.2s,
    transform 0.2s;
  min-height: 190px;
}
.chapter-card:hover {
  border-color: #9b7448;
  transform: translateY(-2px);
}
.chapter-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}
.chapter-index {
  color: var(--accent);
  font-size: 13px;
  font-weight: 750;
  letter-spacing: 0.08em;
}
.tag {
  font-size: 11px;
  color: var(--muted);
  background: #213041;
  padding: 3px 9px;
  border-radius: 20px;
  white-space: nowrap;
}
.chapter-card p {
  font-size: 13px;
  line-height: 1.5;
}
.chapter-card .card-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: auto;
}
.card-footer .progress-track {
  flex: 1;
  height: 4px;
}
.arrow {
  color: var(--accent);
  font-size: 18px;
}
.rule {
  margin: 24px 0;
  border-left: 3px solid var(--accent);
  background: #ffb3540d;
  padding: 16px 19px;
  border-radius: 0 12px 12px 0;
}
.rule .label {
  font-size: 10px;
  color: var(--accent);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 750;
  margin-bottom: 4px;
}
.rule strong {
  font-size: 17px;
  line-height: 1.45;
  display: block;
}
.chapter-header p {
  margin: 13px 0 0;
  max-width: 800px;
}
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 22px;
}
.linkbtn {
  border: 0;
  background: none;
  color: var(--blue);
  padding: 0;
  font-size: inherit;
}
.linkbtn:hover {
  text-decoration: underline;
}
.chapter-title-row {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
}
.chapter-title-row h1 {
  font-size: clamp(31px, 4vw, 46px);
}
.chapter-progress {
  min-width: 112px;
  text-align: right;
  font-size: 12px;
  color: var(--muted);
}
.chapter-progress strong {
  display: block;
  font-size: 26px;
  color: var(--green);
  font-variant-numeric: tabular-nums;
}
.tabs {
  display: flex;
  gap: 5px;
  overflow: auto;
  border-bottom: 1px solid var(--line);
  margin: 26px 0 20px;
  scrollbar-width: none;
}
.tab {
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  padding: 10px 12px;
  color: var(--muted);
  font-weight: 650;
  font-size: 13px;
  white-space: nowrap;
}
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.diagram {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 20px;
  margin: 0 0 13px;
  overflow: hidden;
}
.diagram h3 {
  margin-bottom: 17px;
  font-size: 16px;
  letter-spacing: -0.015em;
}
.lane {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin: 11px 0;
}
.lane-label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 650;
  line-height: 1.35;
}
.nodes {
  display: flex;
  align-items: stretch;
  gap: 6px;
  min-width: 0;
}
.node {
  border: 1px solid #476180;
  background: #18293b;
  flex: 1;
  min-width: 0;
  border-radius: 10px;
  padding: 11px 7px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  min-height: 72px;
}
.node:nth-of-type(4n + 1) {
  border-color: #476180;
  background: #18293b;
}
.node:nth-of-type(4n + 3) {
  border-color: #715d87;
  background: #28223a;
}
.node:last-child {
  border-color: #3b7160;
  background: #17312d;
}
.node b {
  font-size: 12px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.node small {
  display: block;
  margin-top: 4px;
  font-size: 10px;
  line-height: 1.3;
  color: #b2c3d4;
  overflow-wrap: anywhere;
}
.node-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  color: #8a9eb3;
  flex: 0 0 13px;
}
.diagram-note {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 12px;
}
.topic-tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin: 20px 0 12px;
  flex-wrap: wrap;
}
.topic-tools h2 {
  font-size: 25px;
}
.topic-tools .actions {
  margin: 0;
  gap: 6px;
}
.topic {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 14px;
  margin: 9px 0;
  overflow: hidden;
}
.topic[open] {
  border-color: #536579;
}
.topic summary {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 17px;
  cursor: pointer;
  list-style: none;
}
.topic summary::-webkit-details-marker {
  display: none;
}
.topic summary:after {
  content: "+";
  font-size: 23px;
  color: var(--accent);
  line-height: 1;
  margin-left: auto;
}
.topic[open] summary:after {
  content: "−";
}
.topic .topic-n {
  font-size: 11px;
  color: #8293a8;
  min-width: 19px;
}
.topic-text {
  min-width: 0;
  flex: 1;
}
.topic-text strong {
  display: block;
  font-size: 16px;
  line-height: 1.35;
}
.topic-text small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  margin-top: 4px;
}
.topic-reviewed {
  font-size: 11px;
  color: var(--green);
  font-weight: 650;
}
.topic-content {
  border-top: 1px solid var(--line);
  padding: 18px 20px 20px;
  display: grid;
  gap: 15px;
}
.topic-content p {
  color: #d4e0ed;
  line-height: 1.7;
  font-size: 14px;
}
.topic-content .label {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 750;
  margin-bottom: 3px;
}
.topic-content .example {
  border-left: 2px solid var(--blue);
  padding: 4px 12px;
}
.topic-content .trap {
  border-left: 2px solid #f0a56b;
  padding: 4px 12px;
}
.topic-content .trap .label {
  color: #f0a56b;
}
.topic-content .example .label {
  color: var(--blue);
}
.markbtn {
  justify-self: start;
  display: flex;
  gap: 8px;
  align-items: center;
}
.markbtn.done {
  border-color: #45836d;
  color: var(--green);
}
.compare {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  margin-bottom: 20px;
}
.compare table {
  border-collapse: collapse;
  width: 100%;
  text-align: left;
  background: var(--panel);
  font-size: 13px;
}
.compare th,
.compare td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  line-height: 1.45;
  min-width: 110px;
}
.compare th {
  background: #1d2a38;
  color: var(--muted);
  font-size: 12px;
}
.compare td:first-child {
  font-weight: 650;
  color: var(--txt);
}
.compare td {
  color: #bccbdd;
}
.compare tr:last-child td {
  border-bottom: none;
}
.quiz {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
.quiz h3 {
  font-size: 20px;
  line-height: 1.4;
  margin: 8px 0 17px;
}
.quiz .opt {
  display: block;
  text-align: left;
  width: 100%;
  padding: 12px 14px;
  margin: 8px 0;
  background: #192532;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 14px;
}
.quiz .opt:hover {
  border-color: var(--accent);
}
.quiz .opt.correct {
  border-color: var(--green);
  color: var(--green);
}
.quiz .opt.wrong {
  border-color: #ed8d8d;
  color: #f5a5a5;
}
.feedback {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 13px;
  font-size: 14px;
}
.feedback strong {
  display: block;
  margin-bottom: 4px;
}
.nextprev {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 30px;
}
.nextprev .btn {
  white-space: normal;
  text-align: left;
}
.result {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin: 9px 0;
  background: var(--panel);
  padding: 16px;
}
.result:hover {
  border-color: var(--accent);
}
.result small {
  color: var(--accent);
  font-size: 11px;
}
.result p {
  font-size: 13px;
  margin-top: 4px;
}
.pending-card {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 19px;
  border-radius: 14px;
  margin: 10px 0;
  display: flex;
  gap: 16px;
}
.pending-card h3 {
  margin-bottom: 6px;
  font-size: 18px;
}
.pending-card p {
  font-size: 14px;
}
.pending-num {
  color: var(--accent);
  font-size: 12px;
  font-weight: 750;
}
.notice {
  padding: 15px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  font-size: 13px;
  color: var(--muted);
  margin: 16px 0;
}
.footer {
  border-top: 1px solid var(--line);
  margin-top: 38px;
  padding-top: 15px;
  color: var(--muted);
  font-size: 12px;
}
.empty {
  padding: 40px 15px;
  text-align: center;
  color: var(--muted);
}
.mobile-nav {
  display: none;
}
#menuShade {
  display: none;
}
.mode-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.formula {
  font-family: ui-monospace, monospace;
  color: var(--accent);
}

@media (max-width: 950px) {
  .shell {
    grid-template-columns: 235px minmax(0, 1fr);
  }
  .sidebar {
    padding: 20px 12px;
  }
  .content {
    padding: 26px 21px 70px;
  }
  .topbar {
    padding: 12px 21px;
  }
  .lane {
    grid-template-columns: 75px minmax(0, 1fr);
  }
  .node {
    padding: 8px 5px;
  }
  .node b {
    font-size: 11px;
  }
  .node small {
    font-size: 10px;
  }
  .stats {
    gap: 8px;
  }
  .stat {
    padding: 13px;
  }
  .stat strong {
    font-size: 24px;
  }
}

@media (max-width: 720px) {
  .shell {
    display: block;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(320px, 86vw);
    z-index: 31;
    transform: translateX(-105%);
    transition: transform 0.22s;
    height: 100dvh;
    padding: 20px 15px;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  #menuShade.open {
    display: block;
    position: fixed;
    inset: 0;
    background: #0009;
    z-index: 30;
  }
  .mobile-menu {
    display: block;
    padding: 10px;
    line-height: 1;
    font-size: 19px;
  }
  .topbar {
    padding: 10px 12px;
    min-height: 61px;
    gap: 8px;
  }
  .topbar .btn:not(.mobile-menu) {
    padding: 10px;
    font-size: 12px;
  }
  .search {
    font-size: 14px;
  }
  .content {
    padding: 20px 14px 65px;
  }
  .hero {
    padding: 24px 20px;
    border-radius: 18px;
  }
  .hero p {
    font-size: 14px;
  }
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 13px 0 26px;
  }
  .chapter-grid {
    grid-template-columns: 1fr;
  }
  .chapter-card {
    min-height: 0;
    padding: 16px;
  }
  .section-head {
    align-items: start;
    flex-direction: column;
    gap: 4px;
  }
  .chapter-title-row {
    align-items: flex-start;
  }
  .chapter-progress {
    min-width: 65px;
  }
  .chapter-progress strong {
    font-size: 20px;
  }
  .chapter-header p {
    font-size: 14px;
  }
  .rule {
    padding: 12px 14px;
  }
  .rule strong {
    font-size: 15px;
  }
  .diagram {
    padding: 15px;
  }
  .lane {
    display: block;
    margin: 15px 0;
  }
  .lane-label {
    display: block;
    margin-bottom: 7px;
  }
  .nodes {
    flex-direction: column;
    gap: 3px;
  }
  .node {
    min-height: 54px;
    padding: 9px;
  }
  .node b {
    font-size: 13px;
  }
  .node small {
    font-size: 11px;
  }
  .node-arrow {
    flex: 0 0 17px;
    transform: rotate(90deg);
  }
  .topic summary {
    padding: 14px 11px;
    gap: 8px;
  }
  .topic-text strong {
    font-size: 15px;
  }
  .topic-content {
    padding: 14px;
  }
  .topic-reviewed {
    font-size: 10px;
  }
  .tab {
    padding: 9px 10px;
  }
  .nextprev {
    font-size: 12px;
  }
  .pending-card {
    padding: 15px;
  }
  .quiz {
    padding: 16px;
  }
}

@media print {
  .sidebar,
  .topbar,
  .tabs,
  .btn,
  .nextprev,
  .quiz {
    display: none !important;
  }
  .shell {
    display: block;
  }
  .content {
    max-width: none;
    padding: 0;
  }
  body {
    background: white;
    color: black;
  }
  .topic,
  .diagram,
  .compare,
  .hero {
    break-inside: avoid;
    border-color: #aaa;
    background: white;
  }
  .topic-content p,
  .topic-text small,
  p,
  .diagram-note {
    color: #333;
  }
  .topic-content {
    display: block;
  }
  .node {
    background: #eee !important;
    color: #111;
    border-color: #999 !important;
  }
  .node small {
    color: #444;
  }
  .rule strong {
    color: #111;
  }
}
