/* Visual language borrowed from solsoletti.com: night sky, sun and moon accents, mono eyebrows. */
:root {
  --bg: #07080c;
  --bg-raised: #0b0d14;
  --surface: #10131b;
  --surface-2: #161a24;
  --line: rgba(170, 180, 210, 0.14);
  --line-strong: rgba(255, 181, 71, 0.38);
  --text: #f4f2ee;
  --muted: #a7adbb;
  --faint: #737a8a;

  --sol: #ffb547;
  --sol-2: #ff7a3d;
  --luna: #b9a8ff;
  --legios: #5ae5f1;
  --verde: #5cffb1;
  --accent-ink: #170d02;
  --glow-a: rgba(255, 181, 71, 0.10);
  --glow-b: rgba(185, 168, 255, 0.06);
  --grid-a: rgba(255, 181, 71, 0.035);
  --grid-b: rgba(90, 229, 241, 0.03);
  --header: rgba(7, 8, 12, 0.72);

  --f-display: "Bricolage Grotesque", system-ui, sans-serif;
  --f-body: "DM Sans", system-ui, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --r: 14px;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f7f5f0;
    --bg-raised: #f1ede4;
    --surface: #ffffff;
    --surface-2: #f1ede4;
    --line: rgba(60, 50, 30, 0.13);
    --line-strong: rgba(214, 120, 20, 0.45);
    --text: #1b1a17;
    --muted: #5d5a52;
    --faint: #85817a;
    --sol: #c96a00;
    --sol-2: #e0561c;
    --luna: #6c55d9;
    --legios: #0f8f9a;
    --verde: #1f9d63;
    --accent-ink: #1b0f02;
    --glow-a: rgba(255, 170, 60, 0.16);
    --glow-b: rgba(140, 120, 255, 0.08);
    --grid-a: rgba(200, 120, 20, 0.05);
    --grid-b: rgba(20, 140, 150, 0.04);
    --header: rgba(247, 245, 240, 0.8);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(900px 520px at 50% -120px, var(--glow-a), transparent 70%),
    radial-gradient(700px 600px at 100% 40%, var(--glow-b), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--f-body);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
/* The fixed grid, fading downwards: the "map sheet" of the portfolio. */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    linear-gradient(var(--grid-a) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-b) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: linear-gradient(to bottom, #000 0%, transparent 85%);
}
a { color: inherit; }
button { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
::selection { background: var(--sol); color: var(--accent-ink); }
.mono { font-family: var(--f-mono); }
code {
  font-family: var(--f-mono);
  font-size: .86em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: .08em .38em;
  border-radius: 6px;
}

/* ---------- reading progress ---------- */
.readbar {
  position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 60;
  background: linear-gradient(90deg, var(--sol), var(--luna));
  transform-origin: left; transform: scaleX(0);
}

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 22px;
  height: 62px; padding: 0 max(16px, calc((100% - 1080px) / 2));
  background: var(--header);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 7px; text-decoration: none; }
.brand-mark { width: 30px; height: 30px; flex: none; filter: drop-shadow(0 0 8px color-mix(in srgb, var(--sol) 35%, transparent)); transition: transform .3s ease; }
.brand:hover .brand-mark { transform: rotate(-6deg) scale(1.05); }
.brand-name { font-family: var(--f-display); font-weight: 800; font-size: 22px; letter-spacing: -0.035em; line-height: 1; }
.dot-i { position: relative; display: inline-block; }
.dot-i::after {
  content: ""; position: absolute; left: 50%; top: .02em; width: .2em; height: .2em; border-radius: 50%;
  transform: translateX(-50%); background: var(--sol);
}
.dot-i.moon::after { background: var(--luna); }
.top-nav { display: flex; gap: 4px; font-family: var(--f-mono); font-size: 13.5px; }
.top-nav a { text-decoration: none; color: var(--muted); padding: 6px 10px; border-radius: 8px; transition: color .2s, background .2s; }
.top-nav a:hover { color: var(--sol); }
.top-nav a.active { color: var(--text); background: var(--surface-2); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.progress { font-family: var(--f-mono); font-size: 12px; color: var(--faint); white-space: nowrap; }
.lang {
  display: inline-flex; align-items: center; height: 34px; padding: 3px; gap: 2px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  font-family: var(--f-mono); font-size: 12px;
}
.lang span { padding: 4px 8px; border-radius: 7px; color: var(--faint); transition: color .2s, background .2s; }
.lang span.on { background: var(--sol); color: var(--accent-ink); font-weight: 600; }
.lang:hover span:not(.on) { color: var(--sol); }

/* ---------- layout ---------- */
.app { max-width: 1080px; margin: 0 auto; padding: 40px 16px 72px; }
.loading, .empty { color: var(--muted); text-align: center; padding: 56px 0; font-family: var(--f-mono); font-size: 14px; }
h1, h2, h3 { font-family: var(--f-display); font-weight: 700; letter-spacing: -0.02em; line-height: 1.08; }
h1 { font-size: clamp(34px, 6vw, 60px); margin: 0 0 10px; letter-spacing: -0.035em; }
h2 { font-size: clamp(24px, 3vw, 30px); margin: 56px 0 18px; }
h2::before { content: "// "; font-family: var(--f-mono); font-size: .55em; font-weight: 500; color: var(--faint); vertical-align: .25em; letter-spacing: 0; }
.muted { color: var(--muted); }
.kicker {
  font-family: var(--f-mono); font-size: 12.5px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--sol); margin: 0 0 14px;
}
.kicker a { text-decoration: none; }
.kicker a:hover { color: var(--text); }

/* ---------- today hero ---------- */
.hero {
  display: grid; grid-template-columns: 1fr; gap: 28px; align-items: center;
  position: relative; overflow: hidden;
  background: linear-gradient(180deg, var(--surface), var(--bg-raised));
  border: 1px solid color-mix(in srgb, var(--sol) 22%, var(--line)); border-radius: 20px;
  padding: 24px;
}
.hero::before {
  content: ""; position: absolute; inset: auto -20% -60% auto; width: 70%; aspect-ratio: 1; pointer-events: none;
  background: radial-gradient(circle, color-mix(in srgb, var(--sol) 14%, transparent), transparent 65%);
}
@media (min-width: 820px) { .hero { grid-template-columns: 1.15fr 1fr; padding: 40px; gap: 40px; } }
.hero-copy { position: relative; min-width: 0; }
.hero-title { font-size: clamp(32px, 5vw, 52px); margin: 0 0 10px; letter-spacing: -0.035em; overflow-wrap: anywhere; }
.hero-title a {
  text-decoration: none;
  background: linear-gradient(100deg, var(--text) 30%, var(--sol) 75%, var(--sol-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero .tagline { font-size: clamp(18px, 2.2vw, 21px); color: var(--text); margin: 0 0 16px; max-width: 40ch; }
.hero .meta { margin-bottom: 18px; }
.hero .lead { color: var(--muted); font-size: 16px; margin: 0 0 24px; max-width: 58ch; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.hero-note { display: flex; align-items: center; gap: 8px; margin: 22px 0 0; font-size: 12px; color: var(--faint); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--verde); animation: pulse 2.2s infinite; flex: none; }
.hero-img {
  position: relative; border-radius: var(--r); overflow: hidden;
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, .7), 0 0 0 1px var(--line);
  transform: rotate(1.2deg); transition: transform .4s ease;
}
.hero:hover .hero-img { transform: rotate(0deg) scale(1.01); }
.hero-img img { width: 100%; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--f-mono); font-size: 13.5px; font-weight: 600;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 10px; padding: 11px 18px; cursor: pointer; text-decoration: none;
  transition: transform .2s, box-shadow .2s, border-color .2s, background .2s;
}
.btn:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.btn.primary {
  background: linear-gradient(135deg, var(--sol), var(--sol-2)); color: var(--accent-ink); border-color: transparent;
  box-shadow: 0 8px 30px -10px color-mix(in srgb, var(--sol-2) 70%, transparent);
}
.btn.primary:hover { box-shadow: 0 12px 38px -8px color-mix(in srgb, var(--sol-2) 85%, transparent); }
.btn.done { background: color-mix(in srgb, var(--verde) 12%, var(--surface)); border-color: color-mix(in srgb, var(--verde) 55%, transparent); color: var(--text); }
.more-link { margin: 22px 0 0; }

/* ---------- filters ---------- */
.filters { display: flex; flex-direction: column; gap: 14px; margin: 18px 0 28px; }
.search {
  width: 100%; border: 1px solid var(--line); background: var(--surface); color: inherit;
  border-radius: 12px; padding: 13px 16px; font: inherit; outline: none; transition: border-color .2s, box-shadow .2s;
}
.search:focus { border-color: var(--line-strong); box-shadow: 0 0 0 4px color-mix(in srgb, var(--sol) 12%, transparent); }
.search::placeholder { color: var(--faint); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chips .muted { font-family: var(--f-mono); font-size: 12px !important; }
.chip {
  font-family: var(--f-mono); font-size: 12.5px; color: var(--muted);
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 5px 12px; cursor: pointer; transition: color .2s, border-color .2s, background .2s;
}
.chip:hover { color: var(--sol); border-color: var(--line-strong); }
.chip[aria-pressed="true"] { background: var(--sol); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.chip.ghost { border-style: dashed; }
.chip.lvlchip[aria-pressed="true"] { background: var(--surface-2); color: var(--text); border-color: var(--muted); }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); cursor: pointer; }
.toggle input { accent-color: var(--sol); }

/* ---------- cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.card {
  display: flex; flex-direction: column; gap: 10px;
  background: linear-gradient(180deg, var(--surface), var(--bg-raised));
  border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px; text-decoration: none; position: relative;
  transition: transform .25s, border-color .25s, box-shadow .25s;
}
.card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--sol) 35%, transparent); box-shadow: 0 18px 40px -24px rgba(0, 0, 0, .6); }
.card-img { border-radius: 10px; overflow: hidden; aspect-ratio: 5 / 3; box-shadow: 0 0 0 1px var(--line); }
.card-img img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s ease; }
.card:hover .card-img img { transform: scale(1.03); }
.card h3 { margin: 4px 0 0; font-size: 20px; }
.card p { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.5; }
.meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--faint); }
.card.learned::after {
  content: "✓"; position: absolute; top: 24px; right: 24px;
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: var(--verde); color: #04140c; font-size: 13px; font-weight: 700;
  box-shadow: 0 4px 14px -4px color-mix(in srgb, var(--verde) 80%, transparent);
}
.tag, .lvl {
  display: inline-block; font-family: var(--f-mono); font-size: 10.5px; font-weight: 500; letter-spacing: .1em; text-transform: uppercase;
  padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.lvl { border-color: currentColor; }
.lvl-1 { color: var(--verde); }
.lvl-2 { color: var(--sol); }
.lvl-3 { color: var(--luna); }

/* ---------- subject overview ---------- */
.subjects { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.subject {
  display: flex; flex-direction: column; gap: 6px; text-decoration: none;
  background: linear-gradient(180deg, var(--surface), var(--bg-raised));
  border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px;
  transition: transform .25s, border-color .25s;
}
.subject:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.subject strong { font-family: var(--f-display); font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.subject .muted { font-family: var(--f-mono); font-size: 11.5px; color: var(--faint); }
.bar { display: block; height: 4px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: 6px; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--sol), var(--luna)); border-radius: 999px; transition: width .4s ease; }

/* ---------- entry page ---------- */
.entry { max-width: 720px; margin: 0 auto; }
.entry .tagline { font-size: clamp(19px, 2.4vw, 22px); color: var(--muted); margin: 0 0 8px; }
.entry-img { border-radius: var(--r); overflow: hidden; margin: 26px 0 30px; box-shadow: 0 30px 60px -34px rgba(0, 0, 0, .7), 0 0 0 1px var(--line); }
.entry-img img { width: 100%; }
.entry p { margin: 0 0 18px; }
.entry:not(.page) .prose p:first-child::first-letter {
  font-family: var(--f-display); font-weight: 800; float: left; font-size: 3.3em; line-height: .9;
  margin: .06em .1em 0 0; color: var(--sol);
}
.prose strong { color: var(--text); font-weight: 700; }
.box {
  position: relative; margin: 28px 0; padding: 18px 20px 18px 22px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--luna) 9%, var(--surface)), var(--surface));
  border: 1px solid color-mix(in srgb, var(--luna) 28%, var(--line)); border-radius: 12px;
}
.box .kicker { color: var(--luna); margin-bottom: 6px; }
.box p { margin: 0; }
.points { list-style: none; padding: 0; margin: 0 0 18px; display: grid; gap: 10px; }
.points li {
  position: relative; padding: 12px 16px 12px 42px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
}
.points li::before {
  content: "→"; position: absolute; left: 16px; top: 12px; font-family: var(--f-mono); color: var(--sol);
}
.links { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.links a {
  display: flex; justify-content: space-between; gap: 12px; align-items: center; text-decoration: none;
  padding: 12px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  transition: border-color .2s, color .2s;
}
.links a:hover { border-color: var(--line-strong); color: var(--sol); }
.links a::after { content: "↗"; font-family: var(--f-mono); color: var(--faint); }
.entry-foot {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--line);
}
.pager { display: flex; gap: 8px; }

/* ---------- justified prose, term links ---------- */
.entry .prose p, .entry .box p, .entry .points li { text-align: justify; hyphens: auto; -webkit-hyphens: auto; }
a.term { text-decoration: none; color: inherit; border-bottom: 1.5px dotted color-mix(in srgb, var(--sol) 70%, transparent); transition: color .2s, background .2s; }
a.term:hover { color: var(--sol); border-bottom-style: solid; }

/* ---------- footer ---------- */
.foot { border-top: 1px solid var(--line); padding: 28px 16px 40px; font-family: var(--f-mono); font-size: 12.5px; color: var(--faint); }
.foot { text-align: center; }
.foot p { margin: 10px 0 0; }
.foot-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; }
.foot a { color: var(--muted); text-decoration: none; }
.foot a:hover { color: var(--sol); }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--verde) 60%, transparent); }
  70%, 100% { box-shadow: 0 0 0 8px transparent; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .hero-img { transform: none; }
}
@media (max-width: 640px) {
  body { font-size: 16px; }
  .top { gap: 10px; }
  .brand-name, .progress { display: none; }
  .top-nav a { padding: 6px 7px; font-size: 12.5px; }
  .app { padding-top: 24px; }
  .hero-img { transform: none; order: -1; }
  h2 { margin-top: 44px; }
}

/* ---------- dictionary ---------- */
.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; }
.skip { position: absolute; left: 12px; top: -48px; z-index: 70; padding: 8px 14px; border-radius: 8px; background: var(--sol); color: var(--accent-ink); font-family: var(--f-mono); font-size: 13px; text-decoration: none; }
.skip:focus { top: 12px; }
:focus-visible { outline: 2px solid var(--sol); outline-offset: 2px; }
.dict-hero { padding: 28px 0 8px; max-width: 820px; }
.dict-hero h1 { font-size: clamp(38px, 7vw, 76px); line-height: .98; margin-bottom: 18px; }
.dict-lead { color: var(--muted); font-size: clamp(17px, 2vw, 19px); max-width: 64ch; margin: 0 0 24px; }
.searchbar { display: flex; gap: 10px; max-width: 640px; }
.searchbar .search { flex: 1; min-width: 0; font-size: 17px; padding: 14px 18px; }
.popular { margin: 16px 0 0; font-size: 15px; }
.popular a { color: var(--text); text-decoration: none; border-bottom: 1px dotted var(--faint); }
.popular a:hover { color: var(--sol); }
.letters { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 18px; }
.letters a {
  min-width: 34px; height: 34px; display: grid; place-items: center; padding: 0 8px;
  font-family: var(--f-mono); font-size: 13px; text-decoration: none; color: var(--muted);
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface); transition: color .2s, border-color .2s;
}
.letters a:hover { color: var(--sol); border-color: var(--line-strong); }
.letters a.off { opacity: .3; pointer-events: none; }
.letter { scroll-margin-top: 80px; }
.letter h2 { margin: 34px 0 10px; }
.letter h2::before { content: none; }
.az { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.az li { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); transition: border-color .2s; }
.az li:hover { border-color: var(--line-strong); }
.az li a { flex: 1; min-width: 0; text-decoration: none; display: flex; flex-wrap: wrap; gap: 2px 12px; align-items: baseline; }
.az-title { font-family: var(--f-display); font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.az-tag { color: var(--muted); font-size: 14.5px; }
.az li.learned .az-title::after { content: " ✓"; color: var(--verde); }
.chips-label { font-family: var(--f-mono); font-size: 12px; }
.crumbs { font-family: var(--f-mono); font-size: 12.5px; color: var(--faint); margin: 0 0 14px; }
.crumbs a { color: var(--sol); text-decoration: none; }
.crumbs a:hover { color: var(--text); }
.entry-meta { margin-bottom: 10px; }
a.tag { text-decoration: none; }
a.tag:hover { color: var(--sol); border-color: var(--line-strong); }
figure.entry-img { margin: 26px 0 30px; }
aside.box h2.kicker { font-size: 12.5px; margin: 0 0 6px; }
aside.box h2.kicker::before { content: none; }
.related { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.related a { display: inline-block; text-decoration: none; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: 14.5px; transition: color .2s, border-color .2s; }
.related a:hover { color: var(--sol); border-color: var(--line-strong); }
.entry.more { margin-top: 48px; }
.page .prose p { color: var(--text); }
.page .prose a { color: var(--sol); }
.page + .page { margin-top: 48px; padding-top: 32px; border-top: 1px solid var(--line); }
.pager .btn { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 640px) {
  .searchbar { flex-direction: column; }
  .az li { align-items: flex-start; }
  .pager { width: 100%; flex-direction: column; }
  .pager .btn { max-width: none; }
}
pre { margin: 0 0 18px; padding: 14px 16px; overflow-x: auto; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-raised); }
pre code { background: none; border: 0; padding: 0; font-size: 13px; line-height: 1.55; white-space: pre; }
.page section { scroll-margin-top: 80px; }
