@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root{
  --bg:#0f172a;
  --surface:#111827;
  --surface-soft:#1f2937;
  --text:#f9fafb;
  --muted:#cbd5e1;
  --accent:#60a5fa;
  --accent-2:#38bdf8;
  --border:rgba(255, 255, 255, 0.12);
  --shadow:0 18px 38px rgba(2, 6, 23, 0.45);
}

body[data-theme="light"]{
  --bg:#f5f8ff;
  --surface:#ffffff;
  --surface-soft:#eef4ff;
  --text:#14213d;
  --muted:#4f607a;
  --accent:#2747b7;
  --accent-2:#3b82f6;
  --border:rgba(20, 33, 61, 0.12);
  --shadow:0 18px 38px rgba(20, 33, 61, 0.08);
}

*{margin:0;padding:0;box-sizing:border-box;}
body{
  font-family:Inter,system-ui,-apple-system,'Segoe UI',Roboto,'Helvetica Neue',Arial;
  background:linear-gradient(135deg,var(--surface-soft) 0%, var(--bg) 100%);
  color:var(--text);
  line-height:1.7;
  min-height:100vh;
}
a{color:inherit}

/* ----------{Theme toggle}---------- */
.theme-toggle{
  position:fixed;
  top:20px;
  right:20px;
  z-index:100;
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:10px 14px;
  border:1px solid var(--border);
  border-radius:999px;
  background:var(--surface);
  color:var(--text);
  box-shadow:var(--shadow);
  font-weight:700;
  cursor:pointer;
  transition:transform .2s ease, background .2s ease, color .2s ease;
  font-family:inherit;
}
.theme-toggle:hover{transform:translateY(-1px)}
.theme-toggle-icon{font-size:1rem}
.theme-toggle-label{font-size:.85rem}

/* ---------- Layout ---------- */
.layout{display:flex;align-items:flex-start;max-width:1400px;margin:0 auto;padding:60px 20px 40px;}
.sidebar{
  width:260px;
  flex:0 0 260px;
  position:sticky;
  top:20px;
  height:calc(100vh - 40px);
  overflow-y:auto;
  background:rgba(255,255,255,0.04);
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:20px;
  padding:22px 14px 30px;
  box-shadow:var(--shadow);
}
.main{flex:1;min-width:0;padding:0 0 0 24px;}

/* ---------- Sidebar ---------- */
.sidebar .brand{text-align:center;padding:0 8px 18px;border-bottom:1px solid var(--border);margin-bottom:14px;}
.sidebar .flag{font-size:1.5em;}
.sidebar .brand h1{font-size:1.1em;background:linear-gradient(90deg,var(--accent),var(--accent-2));-webkit-background-clip:text;background-clip:text;-webkit-text-fill-color:transparent;margin-top:6px;letter-spacing:.3px;}
.sidebar .brand p{font-size:.8em;color:var(--muted);margin-top:2px;font-style:italic;}
.sidebar .nav-title{
  padding:14px 16px 4px;
  font-size:.72em;
  letter-spacing:1.5px;
  text-transform:uppercase;
  color:var(--accent);
  font-weight:800;
}
.sidebar a{
  display:block;
  margin:2px 4px;
  padding:8px 14px;
  color:var(--text);
  text-decoration:none;
  border-radius:10px;
  font-size:.94em;
  font-weight:500;
}
.sidebar a:hover{background:var(--surface-soft);}
.sidebar a.active{
  background:linear-gradient(90deg,var(--accent),var(--accent-2));
  color:#fff;
  font-weight:700;
}

/* ---------- Sidebar dropdown ---------- */
.nav-drop{margin:2px 4px;border-radius:10px;}
.nav-drop summary{
  display:block;
  padding:8px 14px;
  border-radius:10px;
  font-size:.94em;
  font-weight:500;
  cursor:pointer;
  user-select:none;
  list-style:none;
  transition:background .15s ease;
}
.nav-drop summary::-webkit-details-marker{display:none;}
.nav-drop summary::before{content:"▸";color:var(--accent);margin-right:8px;font-size:.8em;display:inline-block;transition:transform .15s ease;}
.nav-drop[open] summary::before{transform:rotate(90deg);}
.nav-drop summary:hover{background:var(--surface-soft);}
.nav-drop-links{margin:2px 0 6px 22px;border-left:1px solid var(--border);padding-left:8px;}
.nav-drop-links a{display:block;padding:6px 10px;border-radius:8px;font-size:.88em;color:var(--muted);}
.nav-drop-links a:hover{background:var(--surface-soft);color:var(--text);}
.nav-drop-links a.active{color:var(--accent);font-weight:700;}

/* ---------- Content card ---------- */
.book{
  max-width:920px;
  margin:auto;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:24px;
  box-shadow:var(--shadow);
  padding:44px 52px;
}
.cover{
  text-align:center;
  padding:14px 0 26px;
  border-bottom:1px solid var(--border);
  margin-bottom:28px;
}
.cover h1{
  font-size:clamp(1.8rem,4vw,2.4rem);
  background:linear-gradient(90deg,var(--accent),var(--accent-2));
  -webkit-background-clip:text;background-clip:text;-webkit-text-fill-color:transparent;
  margin-bottom:10px;
  font-weight:800;
}
.cover .meta{font-size:.98em;color:var(--muted);margin:3px 0;}
.cover .meta strong{color:var(--text);}
.cover .flag{font-size:1.4em;}

h1{
  color:var(--text);
  font-size:1.55em;
  margin:38px 0 14px;
  padding-bottom:8px;
  border-bottom:1px solid var(--border);
}
h1 .num{color:var(--accent);font-weight:800;margin-right:8px;}
h2{color:var(--accent);font-size:1.2em;margin:26px 0 12px;}
h3{color:var(--text);font-size:1.02em;margin:18px 0 8px;}

p{margin:12px 0;}
ul,ol{margin:12px 0 12px 26px;}
li{margin-bottom:7px;}
strong{color:var(--text);}

hr{border:none;margin:32px 0;text-align:center;color:var(--muted);}
hr::after{content:"❖ ❖ ❖";color:var(--accent);font-size:.9em;}

table{
  width:100%;
  border-collapse:collapse;
  margin:16px 0 20px;
  font-size:.96em;
  border:1px solid var(--border);
  border-radius:12px;
  overflow:hidden;
  background:var(--surface);
}
th{
  background:var(--surface-soft);
  color:var(--accent);
  padding:11px 14px;
  text-align:left;
  font-weight:700;
  letter-spacing:.4px;
  border-bottom:1px solid var(--border);
}
td{padding:9px 14px;border-bottom:1px solid var(--border);}
thead tr th:last-child,tbody tr td:last-child{border-right:none;}
tbody tr:last-child td{border-bottom:none;}
tr:hover td{background:var(--surface-soft);}
caption{font-weight:700;color:var(--accent);padding:4px 0 8px;text-align:left;}

.example{
  margin:12px 22px;
  padding:10px 16px;
  border-left:4px solid var(--accent);
  background:var(--surface-soft);
  border-radius:10px;
  font-style:italic;
  color:var(--text);
}
.example strong{font-style:normal;color:var(--accent);}
.inline-table{display:inline-block;vertical-align:top;}
.inline-tables{display:flex;gap:22px;flex-wrap:wrap;margin:8px 0;}
.pre-body{
  margin:10px 22px;
  padding:10px 16px;
  background:var(--surface-soft);
  border:1px dashed var(--border);
  border-radius:10px;
  font-family:'SF Mono',ui-monospace,Menlo,Consolas,monospace;
  font-size:.9em;
}
.pre-body strong{color:var(--text);}

/* ---------- Cards on home ---------- */
.cards{display:grid;grid-template-columns:repeat(auto-fill,minmax(240px,1fr));gap:16px;margin:24px 0;}
.card{
  display:block;
  background:var(--surface);
  border:1px solid var(--border);
  border-left:4px solid var(--accent);
  border-radius:14px;
  padding:16px 18px;
  text-decoration:none;
  color:var(--text);
  transition:transform .12s ease,box-shadow .12s ease,background .12s ease;
}
.card:hover{transform:translateY(-3px);box-shadow:var(--shadow);background:var(--surface-soft);}
.card .c-num{color:var(--accent);font-weight:800;font-size:.8em;letter-spacing:1px;}
.card strong{display:block;font-size:1.05em;margin:4px 0 2px;}
.card span{font-size:.88em;color:var(--muted);}

/* ---------- Pager / breadcrumb ---------- */
.pager{display:flex;justify-content:space-between;gap:14px;margin-top:38px;padding-top:18px;border-top:1px solid var(--border);}
.pager a{
  text-decoration:none;
  background:var(--surface-soft);
  border:1px solid var(--border);
  color:var(--text);
  padding:10px 16px;
  border-radius:999px;
  font-weight:700;
  font-size:.9em;
}
.pager a:hover{background:linear-gradient(90deg,var(--accent),var(--accent-2));color:#fff;}
.pager .next{margin-left:auto;}
.crumb{font-size:.85em;color:var(--muted);margin-bottom:16px;}
.crumb a{color:var(--accent);text-decoration:none;font-weight:600;}
.crumb a:hover{text-decoration:underline;}

/* ---------- Responsive ---------- */
@media (max-width:860px){
  .layout{flex-direction:column;padding:72px 10px 24px;}
  .sidebar{
    position:static;
    width:100%;
    height:auto;
    display:flex;
    flex-wrap:wrap;
    align-items:center;
    padding:12px 12px;
    border-radius:14px;
  }
  .sidebar .brand{border-bottom:none;padding:0 12px 0 0;margin:0;text-align:left;}
  .sidebar .brand h1{font-size:1em;margin-top:0;}
  .sidebar .brand p{display:none;}
  .sidebar .flag{display:none;}
  .sidebar a{display:inline-block;padding:6px 10px;margin:3px 4px 3px 0;font-size:.85em;}
  .main{padding:0;}
  .book{padding:28px 22px;}
  .example{margin:12px 6px;}
  .pre-body{margin:10px 6px;}
}