:root {
  --bg: #faf7f2;
  --card: #ffffff;
  --ink: #1f2430;
  --muted: #5d6472;
  --line: #e6e0d6;
  --accent: #2f6fdb;
  --accent-soft: #e8f0fd;
  --ok: #1f8a4c;
  --nomen: #2f6fdb;
  --verb: #d1453b;
  --adj: #1f8a4c;
  --other: #8a5cc2;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171c;
    --card: #1e2128;
    --ink: #eceef2;
    --muted: #a3a9b5;
    --line: #2e323b;
    --accent: #6f9cf0;
    --accent-soft: #1f2a40;
    --ok: #4cc27f;
    --nomen: #6f9cf0;
    --verb: #f07a70;
    --adj: #4cc27f;
    --other: #b48ce8;
  }
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color: var(--accent); }
.wrap { max-width: 860px; margin: 0 auto; padding: 0 16px 64px; }

header.top {
  padding: 28px 0 12px;
}
.crumb { font-size: 15px; color: var(--muted); text-decoration: none; }
.crumb:hover { color: var(--accent); }
h1 { font-size: 30px; line-height: 1.2; margin: 6px 0 6px; letter-spacing: -0.01em; }
.sub { color: var(--muted); margin: 0; }

/* Start page tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-top: 24px; }
.tile {
  display: block; text-decoration: none; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; min-height: 130px; transition: transform .12s ease, border-color .12s ease;
}
.tile:hover, .tile:focus-visible { border-color: var(--accent); transform: translateY(-2px); }
.tile .tag { font-size: 13px; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }
.tile h2 { font-size: 20px; margin: 6px 0 4px; }
.tile p { margin: 0; color: var(--muted); font-size: 15px; }
.tile.soon { opacity: .55; pointer-events: none; }
.tile.soon .tag { color: var(--muted); }

/* Section nav */
nav.toc {
  position: sticky; top: 0; z-index: 5;
  background: var(--bg); border-bottom: 1px solid var(--line);
  margin: 0 -16px; padding: 10px 16px;
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
}
nav.toc::-webkit-scrollbar { display: none; }
nav.toc a {
  flex: 0 0 auto; text-decoration: none; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 14px; font-size: 15px; white-space: nowrap;
}
nav.toc a:hover { border-color: var(--accent); color: var(--accent); }

section.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 20px; margin-top: 18px; scroll-margin-top: 70px;
}
section.card h2 { font-size: 23px; margin: 0 0 12px; }
section.card h3 { font-size: 17px; margin: 20px 0 8px; }
.num { color: var(--accent); margin-right: 6px; }

.tablewrap { overflow-x: auto; margin: 8px 0; }
table { border-collapse: collapse; width: 100%; font-size: 16px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 14px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: 0; }

.tip {
  background: var(--accent-soft); border-radius: 10px; padding: 12px 14px; margin-top: 12px;
}
.tip b { color: var(--accent); }

.wa { font-weight: 700; }
.wa.n { color: var(--nomen); } .wa.v { color: var(--verb); } .wa.a { color: var(--adj); } .wa.o { color: var(--other); }

ul, ol { padding-left: 22px; margin: 8px 0; }
li { margin: 4px 0; }

/* Self test */
.quiz { list-style: none; padding: 0; counter-reset: q; }
.quiz li {
  counter-increment: q; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; margin: 10px 0;
}
.quiz li::before { content: counter(q) ". "; font-weight: 700; color: var(--accent); }
.quiz button {
  margin-top: 8px; font: inherit; font-size: 15px; cursor: pointer;
  background: transparent; color: var(--accent); border: 1px solid var(--accent);
  border-radius: 999px; padding: 5px 14px;
}
.quiz .answer { display: none; margin-top: 8px; color: var(--ok); font-weight: 600; }
.quiz li.open .answer { display: block; }
.quiz li.open button { display: none; }

.totop { display: inline-block; margin-top: 28px; font-size: 15px; }
footer { color: var(--muted); font-size: 14px; margin-top: 32px; }

@media (max-width: 520px) {
  body { font-size: 16px; }
  h1 { font-size: 25px; }
  section.card { padding: 18px 14px; }
  th, td { padding: 8px 6px; font-size: 15px; }
}
@media print {
  nav.toc, .quiz button, .totop { display: none; }
  .quiz .answer { display: block; }
  section.card { break-inside: avoid; border-color: #ccc; }
}
