/* =========================================================
   Kum Seng — a quiet engineering notebook.

   Grey grid paper, blue-black ink. Interface text is IBM Plex
   Sans; anything you read (notes, posts, the quote of the day)
   is Source Serif, which sits well beside KaTeX maths. Each
   section has one pastel, used for its tabs, table headers and
   markers — never as decoration on text.
   ========================================================= */

@font-face { font-family: "IBM Plex Sans"; src: url(../fonts/IBMPlexSans.woff2) format("woff2"); font-weight: 300 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Source Serif 4"; src: url(../fonts/SourceSerif4.woff2) format("woff2"); font-weight: 400 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Source Serif 4"; src: url(../fonts/SourceSerif4-Italic.woff2) format("woff2"); font-weight: 400 700; font-style: italic; font-display: swap; }
@font-face { font-family: "Edu QLD Hand"; src: url(../fonts/EduQLDHand.woff2) format("woff2"); font-weight: 400 700; font-style: normal; font-display: swap; }

:root {
  /* paper and ink */
  --paper: #EEEDE8;
  --sheet: #F8F8F5;
  --ink: #1F2430;
  --ink-2: #474D5B;
  --muted: #646875;
  --faint: #9A9DA6;
  --rule: #D9D8D1;
  --rule-2: #C6C5BD;
  --grid: rgba(43, 56, 98, 0.052);
  --link: #2D4C93;
  --ring: #3A5BB0;
  --danger: #A8321F;

  /* section pastels: tint, mid tone, and an ink that reads on the tint */
  --sky: #D8E8F5;    --sky-mid: #8DB9DF;    --sky-ink: #24557F;
  --mint: #D6EEDD;   --mint-mid: #86C69B;   --mint-ink: #25613F;
  --peach: #F7DECE;  --peach-mid: #EBA47E;  --peach-ink: #8C4524;
  --lav: #E5DEF5;    --lav-mid: #B3A0E2;    --lav-ink: #573F9C;
  --butter: #F5EABD; --butter-mid: #E1C866; --butter-ink: #6C5509;
  --rose: #F5DCE3;   --rose-mid: #E7A2B6;   --rose-ink: #973556;
  --sec: var(--sky); --sec-mid: var(--sky-mid); --sec-ink: var(--sky-ink);

  --sans: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --serif: "Source Serif 4", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --hand: "Edu QLD Hand", "Segoe Print", "Bradley Hand", cursive;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;

  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .36 0 0 0 0 .33 0 0 0 0 .28 .16 0 0 0 -.04'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");

  --header-h: 60px;
  --gutter: 32px;
  --radius: 8px;
  color-scheme: light;
}

body.nav-notes    { --sec: var(--sky);    --sec-mid: var(--sky-mid);    --sec-ink: var(--sky-ink); }
body.nav-projects { --sec: var(--mint);   --sec-mid: var(--mint-mid);   --sec-ink: var(--mint-ink); }
body.nav-goals    { --sec: var(--peach);  --sec-mid: var(--peach-mid);  --sec-ink: var(--peach-ink); }
body.nav-blog     { --sec: var(--lav);    --sec-mid: var(--lav-mid);    --sec-ink: var(--lav-ink); }
body.nav-home     { --sec: var(--butter); --sec-mid: var(--butter-mid); --sec-ink: var(--butter-ink); }

/* ---------- base ---------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex; flex-direction: column;
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px),
    var(--grain);
  background-size: 24px 24px, 24px 24px, 240px 240px;
  color: var(--ink);
  font: 400 1rem/1.55 var(--sans);
  font-kerning: normal;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
main { flex: 1; padding-bottom: 88px; }
a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--ink); }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 4px; }
img { max-width: 100%; height: auto; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; font-weight: 600; }
p { margin: 0 0 1em; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: color-mix(in srgb, var(--sec) 80%, var(--sec-mid)); color: var(--ink); }
.muted { color: var(--muted); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -9999px; top: 10px; background: var(--sheet); color: var(--ink); padding: 8px 14px; border-radius: 6px; z-index: 100; }
.skip:focus { left: 10px; }
.inline { display: inline; }
[hidden] { display: none !important; }

.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 var(--gutter); }
/* narrower pages keep the same left edge as every other page; only their content is narrower */
.wrap.narrow > * { max-width: 820px; }
.wrap.narrow-wide > * { max-width: 960px; }

/* ---------- header and footer ---------- */

.site-header {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.1) blur(10px); backdrop-filter: saturate(1.1) blur(10px);
  border-bottom: 1px solid var(--rule);
}
.header-inner { display: flex; align-items: center; gap: 28px; height: var(--header-h); }
.wordmark {
  font: 500 0.9375rem/1 var(--sans); letter-spacing: 0.24em; text-transform: uppercase;
  color: var(--ink); text-decoration: none; white-space: nowrap; margin-right: auto; padding: 8px 0;
}
.wordmark:hover { color: var(--ink); }
.main-nav { display: flex; align-items: center; gap: 2px; }
.main-nav a {
  position: relative; color: var(--ink-2); text-decoration: none; font-size: 0.9375rem;
  padding: 8px 12px; border-radius: 6px; white-space: nowrap;
}
.main-nav a:hover { color: var(--ink); }
.main-nav a[aria-current="page"] { color: var(--ink); font-weight: 600; }
.signout { display: flex; align-items: center; padding-left: 20px; border-left: 1px solid var(--rule); height: 22px; }
.signout button { background: none; border: 0; padding: 4px 0; font-size: 0.875rem; color: var(--muted); cursor: pointer; }
.signout button:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }

/* footer: the owner's name line, which is also the way in */
.page-foot { padding: 0 0 28px; font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-2); }
.page-foot a { color: inherit; text-decoration: none; }
.page-foot a:hover { color: var(--ink); }
.page-foot [aria-hidden] { color: var(--faint); margin: 0 0.35em; }

.flash { background: var(--butter); border-bottom: 1px solid color-mix(in srgb, var(--butter-ink) 22%, transparent); }
.flash p { margin: 0; padding: 11px 0; font-size: 0.9375rem; display: flex; align-items: center; gap: 10px; color: var(--ink); }
.flash p::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--butter-ink); flex: none; }

/* ---------- page furniture ---------- */

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; padding: 56px 0 26px; }
.page-head h1 { font: 600 2.25rem/1.1 var(--sans); letter-spacing: -0.022em; }
.page-head-tight { padding-top: 10px; }
.page-head .btn { margin-bottom: 2px; }
.lede { color: var(--ink-2); font-size: 1.125rem; line-height: 1.55; max-width: 60ch; margin: -6px 0 28px; }
.lede-quiet { font-size: 0.9375rem; color: var(--muted); margin: 0 0 18px; }

.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 0.875rem; padding-top: 32px; color: var(--muted); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--ink); text-decoration: underline; }
.crumbs a + a::before { content: "/"; margin-right: 8px; color: var(--faint); display: inline-block; text-decoration: none; }

.doc-title { font: 600 clamp(2rem, 1.55rem + 1.5vw, 2.75rem)/1.12 var(--serif); letter-spacing: -0.016em; font-optical-sizing: auto; text-wrap: balance; }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-head h2 { font: 600 1.25rem/1.3 var(--sans); letter-spacing: -0.01em; }
.section-link { font-size: 0.9375rem; }

/* section tabs: the active tab is a divider tab in the section's colour */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--rule-2); margin-bottom: 28px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  position: relative; top: 1px; display: inline-flex; align-items: baseline; gap: 7px; white-space: nowrap;
  color: var(--ink-2); text-decoration: none; padding: 10px 16px 11px; font-size: 0.9375rem;
  border: 1px solid transparent; border-bottom: 0; border-radius: 9px 9px 0 0;
}
.tabs a:hover { color: var(--ink); }
.tabs a:focus-visible { outline-offset: -3px; border-radius: 9px 9px 0 0; }
.tabs a[aria-current="page"] {
  background: var(--sec); color: var(--ink); font-weight: 600;
  border-color: color-mix(in srgb, var(--sec-ink) 22%, var(--sec));
}
.tabs .count { font-size: 0.8125rem; font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
.tabs a[aria-current="page"] .count { color: var(--sec-ink); }

.empty {
  text-align: center; padding: 52px 20px; color: var(--ink-2);
  border: 1px dashed var(--rule-2); border-radius: 12px; background: color-mix(in srgb, var(--sheet) 55%, transparent);
}
.empty p { margin-bottom: 14px; }
.empty p:last-child { margin-bottom: 0; }
.empty-left { text-align: left; padding: 22px 24px; }

/* status: a coloured dot and plain words */
.status { display: inline-flex; align-items: center; gap: 7px; font-size: 0.875rem; line-height: 1.2; color: var(--ink-2); white-space: nowrap; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--dot, var(--faint)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--dot, var(--faint)) 22%, transparent); }
.status-in-progress, .status-ongoing { --dot: #4C89C6; }
.status-completed, .status-done { --dot: #3F9A62; }
.status-paused { --dot: #D0A12E; }
.status-planned, .status-idea { --dot: #8B76D0; }

.tags { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.tag { display: inline-block; font-size: 0.75rem; line-height: 1; font-weight: 500; padding: 4px 7px 5px; border-radius: 4px; background: var(--sky); color: var(--sky-ink); white-space: nowrap; }

/* ---------- buttons and forms ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 16px;
  font: 600 0.875rem/1 var(--sans); letter-spacing: 0.005em; white-space: nowrap; text-decoration: none; cursor: pointer;
  color: #F8F8F5; background: var(--ink); border: 1px solid var(--ink); border-radius: var(--radius);
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn:hover { background: #363C4B; border-color: #363C4B; color: #F8F8F5; }
.btn-quiet { background: transparent; color: var(--ink); border-color: var(--rule-2); }
.btn-quiet:hover { background: var(--sheet); color: var(--ink); border-color: var(--ink-2); }
.btn-danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 38%, transparent); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 8%, transparent); color: var(--danger); border-color: var(--danger); }
.btn-block { width: 100%; height: 44px; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; font-size: 0.875rem; line-height: 1.4; color: var(--link); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link-btn:hover { color: var(--ink); }
.mini-btn {
  display: inline-grid; place-items: center; width: 28px; height: 28px; padding: 0; list-style: none; cursor: pointer;
  border-radius: 6px; border: 1px solid var(--rule); background: var(--sheet); color: var(--ink-2); font-size: 0.875rem; line-height: 1; text-decoration: none;
}
.mini-btn::-webkit-details-marker { display: none; }
.mini-btn:hover { border-color: var(--rule-2); color: var(--ink); background: #fff; }
.mini-btn.is-placeholder { visibility: hidden; }
.admin-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }

.panel { background: var(--sheet); border: 1px solid var(--rule); border-radius: 12px; padding: 24px; margin-bottom: 28px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 16px; }
.form-grid .span-2, .form-grid .form-actions, .form-grid fieldset { grid-column: 1 / -1; }
.stack { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > span { font-size: 0.8125rem; color: var(--ink-2); font-weight: 600; }
.field em { font-style: normal; font-weight: 400; color: var(--muted); }
input[type="text"], input[type="search"], input[type="url"], input[type="number"], input[type="date"], input[type="password"], select, textarea {
  width: 100%; font: 400 0.9375rem/1.4 var(--sans); color: var(--ink); background: #FCFCFA;
  border: 1px solid var(--rule-2); border-radius: var(--radius); padding: 9px 12px; min-height: 40px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
select { appearance: none; padding-right: 34px; cursor: pointer;
  background: #FCFCFA url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%23646875' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E") no-repeat right 12px center; }
textarea { resize: vertical; line-height: 1.55; }
input:hover, select:hover, textarea:hover { border-color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ring); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 18%, transparent); }
input[type="file"] { font-size: 0.875rem; color: var(--ink-2); padding: 6px 0; }
input[type="file"]::file-selector-button { font: 600 0.8125rem var(--sans); color: var(--ink); background: var(--sheet); border: 1px solid var(--rule-2); border-radius: 7px; padding: 8px 12px; margin-right: 12px; cursor: pointer; }
.check, .radio { display: flex; gap: 10px; align-items: flex-start; font-size: 0.9375rem; color: var(--ink-2); cursor: pointer; }
.check input, .radio input { margin-top: 3px; accent-color: var(--ink); width: 16px; height: 16px; flex: none; }
fieldset.choice { border: 0; padding: 0; margin: 0; display: grid; gap: 10px; }
fieldset.choice legend { font-size: 0.8125rem; font-weight: 600; color: var(--ink-2); margin-bottom: 8px; padding: 0; }
.radio { border: 1px solid var(--rule-2); border-radius: 10px; padding: 12px 14px; background: #FCFCFA; }
.radio:has(input:checked) { border-color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--ink-2); }
.radio strong { display: block; color: var(--ink); font-weight: 600; margin-bottom: 1px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.form-error { color: var(--danger); background: color-mix(in srgb, var(--danger) 7%, var(--sheet)); border: 1px solid color-mix(in srgb, var(--danger) 22%, transparent); border-radius: var(--radius); padding: 10px 12px; font-size: 0.9375rem; }
.danger-zone { margin-top: 12px; padding-top: 24px; border-top: 1px solid var(--rule); }

/* ---------- notes: module table ---------- */

.db-tools { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.db-tools .search { flex: 0 1 340px; position: relative; }
.db-tools input[type="search"] {
  padding-left: 36px; background: #FCFCFA url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23646875' stroke-width='1.6' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='m11 11 3.5 3.5'/%3E%3C/svg%3E") no-repeat 12px center;
}
.seg { display: inline-flex; gap: 2px; padding: 3px; background: color-mix(in srgb, var(--sheet) 70%, transparent); border: 1px solid var(--rule-2); border-radius: 10px; }
.chip { font: 500 0.875rem/1 var(--sans); padding: 8px 12px; border-radius: 7px; border: 0; background: transparent; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.chip:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 5%, transparent); }
.chip:focus-visible { outline-offset: 0; }
.chip[aria-pressed="true"] { background: var(--sec); color: var(--sec-ink); font-weight: 600; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--sec-ink) 20%, transparent); }

.db-table-wrap { background: var(--sheet); border: 1px solid var(--rule); border-radius: 12px; overflow: hidden; }
.db-table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
.db-table th {
  text-align: left; font-weight: 500; font-size: 0.8125rem; color: var(--sec-ink); background: var(--sec);
  border-bottom: 1px solid color-mix(in srgb, var(--sec-ink) 16%, var(--sec)); padding: 0; white-space: nowrap;
}
.db-table th button {
  font: inherit; color: inherit; background: none; border: 0; padding: 11px 16px; width: 100%; text-align: inherit;
  cursor: pointer; display: flex; gap: 6px; align-items: center;
}
.entries-table th { padding: 11px 16px; }
.db-table th button::after {
  content: ""; width: 7px; height: 7px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg); opacity: 0; transition: opacity 0.15s ease, transform 0.15s ease;
}
.db-table th button:hover::after { opacity: 0.35; }
.db-table th[aria-sort="ascending"] button::after { opacity: 1; transform: translateY(2px) rotate(225deg); }
.db-table th[aria-sort="descending"] button::after { opacity: 1; }
.db-table th button:hover { color: var(--ink); }
.db-table th button:focus-visible { outline-offset: -3px; }
.db-table td { padding: 15px 16px; border-top: 1px solid var(--rule); vertical-align: middle; }
.db-table tbody tr:first-child td { border-top: 0; }
.db-table tbody tr[data-href] { cursor: pointer; transition: background-color 0.12s ease; }
.db-table tbody tr[data-href]:hover { background: color-mix(in srgb, var(--sec) 45%, transparent); }
.db-table .col-code { width: 1%; white-space: nowrap; font-weight: 600; letter-spacing: 0.01em; color: var(--ink); }
.db-table .col-title a { color: var(--ink); text-decoration: none; font-weight: 500; }
.db-table .col-title a:hover { text-decoration: underline; text-decoration-color: var(--sec-mid); text-decoration-thickness: 2px; }
.db-table .col-title .tags { margin-left: 10px; vertical-align: 1px; }
.db-table .col-year, .db-table .col-sem { width: 1%; white-space: nowrap; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.db-table .col-year .cell-label { display: none; }
.db-table .col-status { width: 1%; white-space: nowrap; }
.db-table .col-date { width: 1%; white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }
.db-table .col-num { text-align: right; font-variant-numeric: tabular-nums; }
.db-table th.col-num { text-align: right; }
.db-table .col-actions { width: 1%; text-align: right; white-space: nowrap; }
.db-table .none { color: var(--faint); }
.db-empty { color: var(--muted); padding: 16px 2px; }

/* ---------- notes: textbook shelf ---------- */

.gallery { list-style: none; margin: 0; padding: 4px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 44px 32px; }
.book { display: grid; gap: 3px; align-content: start; }
.book-link { display: grid; gap: 14px; text-decoration: none; color: var(--ink); margin-bottom: 1px; }
.cover {
  display: block; width: 100%; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 2px 6px 6px 2px;
  box-shadow: 0 1px 1px rgba(31, 36, 48, 0.08), 0 8px 16px -8px rgba(31, 36, 48, 0.28), 0 22px 34px -22px rgba(31, 36, 48, 0.4);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.book-link:hover .cover { transform: translateY(-4px); box-shadow: 0 1px 1px rgba(31, 36, 48, 0.08), 0 12px 22px -10px rgba(31, 36, 48, 0.3), 0 30px 40px -24px rgba(31, 36, 48, 0.42); }
.cover-gen {
  position: relative; overflow: hidden; container-type: inline-size;
  display: flex; flex-direction: column; justify-content: space-between; gap: 10px;
  padding: 19% 11% 12% 17%; background-color: var(--c-bg); color: var(--c-fg);
  background-image: var(--grain); background-size: 200px 200px;
}
.cover-gen::before { /* spine and hinge */
  content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 8%;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.13), rgba(0, 0, 0, 0.05) 62%, rgba(255, 255, 255, 0.32) 76%, rgba(0, 0, 0, 0.07) 88%, transparent);
}
.cover-gen::after { content: ""; position: absolute; left: 17%; right: 11%; top: 11.5%; height: 2px; background: currentColor; opacity: 0.7; }
.cover-title { font: 600 clamp(0.78rem, 9.8cqi, 1.35rem)/1.16 var(--serif); letter-spacing: -0.01em; overflow-wrap: break-word; hyphens: auto; display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.cover-author { font: 500 clamp(0.62rem, 6.4cqi, 0.8rem)/1.35 var(--sans); opacity: 0.82; }
.book-title { font-weight: 600; line-height: 1.3; font-size: 0.975rem; }
.book-link:hover .book-title { text-decoration: underline; text-decoration-color: var(--sec-mid); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.book-author { color: var(--ink-2); font-size: 0.875rem; line-height: 1.4; }
.book-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin-top: 6px; color: var(--muted); font-size: 0.8125rem; }
.book-meta .status { font-size: 0.8125rem; }

/* ---------- notes: programming and language lists ---------- */

.nb-list { list-style: none; margin: -8px 0 0; padding: 0; isolation: isolate; }
.nb-row { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 40px; align-items: start; padding: 20px 0; border-bottom: 1px solid var(--rule); }
.nb-row::before { content: ""; position: absolute; inset: 4px -14px; border-radius: 10px; background: color-mix(in srgb, var(--sec) 50%, transparent); opacity: 0; transition: opacity 0.12s ease; z-index: -1; }
.nb-row:hover::before { opacity: 1; }
.nb-row-title { font: 600 1.1875rem/1.3 var(--sans); letter-spacing: -0.01em; color: var(--ink); text-decoration: none; }
.nb-row-title::after { content: ""; position: absolute; inset: 0; }
.nb-row-title:focus-visible { outline: none; }
.nb-row-title:focus-visible::after { outline: 2px solid var(--ring); outline-offset: -2px; border-radius: 6px; }
.nb-row-summary { color: var(--ink-2); margin: 5px 0 0; max-width: 62ch; }
.nb-row-meta { display: grid; justify-items: end; gap: 2px; margin: 3px 0 0; font-size: 0.8125rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- notebook overview ---------- */

.notebook .crumbs { padding-top: 32px; }
.nb-head { display: grid; gap: 32px; padding: 14px 0 34px; }
.nb-head.has-cover { grid-template-columns: 176px minmax(0, 1fr); align-items: start; }
.nb-head-main { min-width: 0; }
.nb-head .doc-title { max-width: 22ch; }
.nb-cover { width: 176px; }

/* properties as an engineering-drawing title block */
.titleblock {
  --tb: color-mix(in srgb, var(--ink) 26%, transparent);
  display: flex; flex-wrap: wrap; margin: 24px 0 0; max-width: 760px;
  border-top: 1px solid var(--tb); border-left: 1px solid var(--tb);
  background: color-mix(in srgb, var(--sheet) 55%, transparent);
}
.tb-cell { flex: 1 1 auto; min-width: 104px; padding: 8px 16px 11px; border-right: 1px solid var(--tb); border-bottom: 1px solid var(--tb); }
.tb-tags { flex-grow: 4; }
.titleblock dt { font-size: 0.75rem; color: var(--muted); margin-bottom: 4px; }
.titleblock dd { margin: 0; font-weight: 500; font-size: 0.975rem; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 24px; }
.tb-code dd { font-weight: 600; letter-spacing: 0.01em; }

.nb-summary { max-width: 720px; margin-bottom: 40px; }
.nb-contents { max-width: 760px; }

.outline, .outline-sub { list-style: none; margin: 0; padding: 0; }
.outline { border-top: 1px solid var(--rule-2); }
.outline > li { border-bottom: 1px solid var(--rule); }
.outline summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px; }
.outline summary::-webkit-details-marker { display: none; }
.twisty { width: 22px; height: 22px; flex: none; display: grid; place-items: center; border-radius: 5px; color: var(--muted); }
.twisty::before { content: ""; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform 0.15s ease; }
details[open] > summary > .twisty::before { transform: rotate(45deg) translate(-1px, -1px); }
summary:hover > .twisty { color: var(--ink); background: color-mix(in srgb, var(--ink) 6%, transparent); }
.outline-row { display: flex; align-items: center; }
.outline > li > details > summary { padding: 12px 0; }
.outline > li > .outline-row { padding: 12px 0 12px 28px; }
.outline-link { flex: 1; min-width: 0; color: var(--ink); text-decoration: none; }
.outline > li > details > summary .outline-link, .outline > li > .outline-row .outline-link { font-weight: 600; }
.outline-link:hover { text-decoration: underline; text-decoration-color: var(--sec-mid); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.outline-sub { margin: -4px 0 12px 10px; padding-left: 18px; border-left: 1px solid var(--rule-2); }
.outline-sub > li > .outline-row, .outline-sub > li > details > summary { padding: 6px 0 6px 2px; }
.outline-sub .outline-row { padding-left: 2px; }
.outline-sub summary { margin-left: -24px; }
.outline-sub .outline-link { color: var(--ink-2); }
.outline-sub .outline-link:hover { color: var(--ink); }
.outline-tools { display: inline-flex; gap: 4px; margin-left: 12px; opacity: 0; transition: opacity 0.15s ease; }
.outline li:hover > * > .outline-tools, .outline li:focus-within > * > .outline-tools { opacity: 1; }
@media (hover: none) { .outline-tools { opacity: 1; } }

/* ---------- note page ---------- */

body:has(.note-layout) main { display: flex; flex-direction: column; }
.note-layout { flex: 1; display: grid; grid-template-columns: 264px minmax(0, 1fr); align-items: start; }
/* Plain panel behind the sidebar (no grid lines), running from the window's left edge down to the footer. */
.note-side {
  align-self: stretch; position: relative; background: var(--paper);
  border-right: 1px solid var(--rule); box-shadow: -100vw 0 0 100vw var(--paper); clip-path: inset(0 0 0 -100vw);
  margin-bottom: -88px; padding-bottom: 88px;
}
.side-toggle { position: sticky; top: var(--header-h); max-height: calc(100vh - var(--header-h)); overflow: auto; padding: 30px 20px 32px 0; scrollbar-width: thin; scrollbar-color: var(--rule-2) transparent; }
.side-toggle > summary { list-style: none; }
.side-toggle > summary::-webkit-details-marker { display: none; }
.side-title { display: grid; gap: 2px; padding: 0 0 14px 8px; margin-bottom: 10px; border-bottom: 1px solid var(--rule); }
.side-title a { font-weight: 600; color: var(--ink); text-decoration: none; letter-spacing: 0.01em; justify-self: start; }
.side-title a:hover { text-decoration: underline; }
.side-sub { font-size: 0.8125rem; color: var(--muted); line-height: 1.4; }
.tree, .tree-sub { list-style: none; margin: 0; padding: 0; }
.tree { font-size: 0.90625rem; }
.tree summary { list-style: none; display: flex; align-items: flex-start; cursor: pointer; }
.tree summary::-webkit-details-marker { display: none; }
.tree summary > .twisty { margin: 4px 0 0 2px; width: 22px; height: 22px; }
.tree summary > a { flex: 1; min-width: 0; }
.tree a { display: block; padding: 6px 9px; border-radius: 6px; color: var(--ink-2); text-decoration: none; line-height: 1.38; }
.tree a.leaf { margin-left: 24px; }
.tree a:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); color: var(--ink); }
.tree a[aria-current="page"] { background: var(--sky); color: var(--sky-ink); font-weight: 600; }
.tree-sub { margin-left: 13px; padding-left: 10px; border-left: 1px solid var(--rule); }
.tree-sub a.leaf { margin-left: 0; }
.tree-sub summary > .twisty { margin-left: -6px; }
.side-files { margin: 14px 0 0; padding: 14px 0 0 9px; border-top: 1px solid var(--rule); font-size: 0.875rem; }
.side-files a { color: var(--ink-2); text-decoration: none; }
.side-files a:hover { color: var(--ink); text-decoration: underline; }
.side-files .count { color: var(--muted); margin-left: 4px; font-variant-numeric: tabular-nums; }

.note { min-width: 0; padding: 0 0 0 64px; max-width: 784px; }
.note .crumbs { padding-top: 30px; }
.note-head { padding: 14px 0 24px; margin-bottom: 32px; border-bottom: 1px solid var(--rule); }
.note-meta { color: var(--muted); font-size: 0.875rem; margin: 12px 0 0; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.subpages { margin-top: 48px; padding: 18px 22px; background: color-mix(in srgb, var(--sheet) 70%, transparent); border: 1px solid var(--rule); border-radius: 12px; }
.subpages h2 { font: 600 0.875rem var(--sans); color: var(--muted); margin-bottom: 8px; }
.subpages ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; }
.subpages a { color: var(--ink); text-decoration: none; font-weight: 500; }
.subpages a:hover { text-decoration: underline; text-decoration-color: var(--sec-mid); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 56px; }
.pager a {
  display: grid; gap: 3px; align-content: start; padding: 15px 18px 16px; text-decoration: none; color: var(--ink);
  border: 1px solid var(--rule); border-radius: 12px; background: color-mix(in srgb, var(--sheet) 70%, transparent);
  font-weight: 600; line-height: 1.35; transition: border-color 0.15s ease, background-color 0.15s ease;
}
.pager a:hover { border-color: var(--sec-mid); background: color-mix(in srgb, var(--sec) 45%, var(--sheet)); color: var(--ink); }
.pager span { font-size: 0.8125rem; font-weight: 400; color: var(--muted); }
.pager-next { text-align: right; grid-column: 2; }

/* ---------- prose: rendered Markdown ---------- */

.prose { font-family: var(--serif); font-size: 1.125rem; line-height: 1.66; color: var(--ink); overflow-wrap: break-word; font-optical-sizing: auto; }
.prose > :first-child { margin-top: 0; }
.prose h1, .prose h2 { font: 600 1.625rem/1.25 var(--serif); letter-spacing: -0.012em; margin: 2em 0 0.55em; }
.prose h1 { font-size: 1.875rem; }
.prose h3 { font: 600 1.3125rem/1.3 var(--serif); margin: 1.8em 0 0.45em; }
.prose h4 { font: 600 1rem/1.4 var(--sans); margin: 1.7em 0 0.4em; color: var(--ink-2); }
.prose :is(h1, h2, h3, h4) { scroll-margin-top: calc(var(--header-h) + 20px); }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose pre, .prose .table-scroll, .prose .math-block, .prose .callout { margin: 0 0 1.05em; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li { margin: 0.3em 0; padding-left: 0.15em; }
.prose li > ul, .prose li > ol { margin: 0.3em 0; }
.prose li::marker { color: var(--muted); }
.prose strong { font-weight: 650; color: var(--ink); }
.prose a { color: var(--link); text-decoration-color: color-mix(in srgb, var(--link) 40%, transparent); }
.prose a:hover { color: var(--ink); text-decoration-color: currentColor; }
.prose hr { border: 0; border-top: 1px solid var(--rule-2); margin: 2.4em 0; }
.prose blockquote { border-left: 2px solid var(--rule-2); padding: 1px 0 1px 20px; color: var(--ink-2); font-style: italic; }
.prose code { font-family: var(--mono); font-size: 0.82em; background: color-mix(in srgb, var(--ink) 6%, transparent); border-radius: 4px; padding: 0.12em 0.36em; }
.prose pre { background: #F4F4F0; border: 1px solid var(--rule); border-radius: 10px; padding: 14px 18px; overflow-x: auto; line-height: 1.55; }
.prose pre code { background: none; padding: 0; font-size: 0.8125rem; }
.prose img { border-radius: 8px; border: 1px solid var(--rule); display: block; margin: 0 auto; }
.prose .table-scroll { overflow-x: auto; border: 1px solid var(--rule); border-radius: 10px; background: var(--sheet); }
.prose table { border-collapse: collapse; width: 100%; font: 400 0.9375rem/1.5 var(--sans); }
.prose th, .prose td { padding: 9px 14px; border-top: 1px solid var(--rule); text-align: left; vertical-align: top; }
.prose tr:first-child th, .prose tr:first-child td { border-top: 0; }
.prose th { background: color-mix(in srgb, var(--ink) 4%, var(--sheet)); font-weight: 600; font-size: 0.8125rem; color: var(--ink-2); border-bottom: 1px solid var(--rule); }
.prose .math-block { overflow-x: auto; overflow-y: hidden; padding: 6px 0; }
.prose .katex { font-size: 1.04em; }
.prose .katex-display { margin: 0.5em 0; }
.prose .wikilink { text-decoration-style: dotted; text-decoration-thickness: 1.5px; }
.prose .wikilink-missing { color: var(--muted); border-bottom: 1px dashed var(--rule-2); }
.prose .math-error { color: var(--danger); font-family: var(--mono); font-size: 0.85em; }
.prose-post { font-size: 1.1875rem; line-height: 1.7; }

/* Obsidian callouts: a tinted note with a small coloured label */
.callout {
  --c: var(--sky-ink); --c-bg: var(--sky);
  background: color-mix(in srgb, var(--c-bg) 62%, var(--sheet)); border: 1px solid color-mix(in srgb, var(--c) 16%, transparent);
  border-radius: 10px; padding: 13px 18px 3px;
}
.callout > :last-child { margin-bottom: 12px; }
.callout-title { display: flex; align-items: center; gap: 8px; font: 600 0.8125rem/1.3 var(--sans) !important; letter-spacing: 0.01em; color: var(--c); margin: 0 0 6px !important; }
.callout-title::before { content: ""; width: 7px; height: 7px; border-radius: 2px; background: var(--c); flex: none; }
.callout .katex-display { margin: 0.25em 0 0.5em; }
.callout-tip, .callout-success, .callout-example { --c: var(--mint-ink); --c-bg: var(--mint); }
.callout-warning, .callout-caution, .callout-important { --c: var(--butter-ink); --c-bg: var(--butter); }
.callout-question { --c: var(--peach-ink); --c-bg: var(--peach); }
.callout-danger { --c: var(--rose-ink); --c-bg: var(--rose); }
.callout-formula, .callout-definition { --c: var(--lav-ink); --c-bg: var(--lav); }
.callout-quote, .callout-summary, .callout-abstract { --c: var(--ink-2); --c-bg: #E7E6E1; }

/* ---------- files ---------- */

.upload-form { grid-template-columns: 2fr 1fr; align-items: end; }
.file-group { margin-bottom: 34px; }
.file-group h2 { font: 600 0.9375rem var(--sans); color: var(--ink-2); margin: 0 0 10px; }
.file-list { list-style: none; margin: 0; padding: 0; background: var(--sheet); border: 1px solid var(--rule); border-radius: 12px; }
.file-row { display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-top: 1px solid var(--rule); position: relative; }
.file-row:first-child { border-top: 0; }
.file-ext { font: 600 0.6875rem/1 var(--sans); letter-spacing: 0.04em; color: var(--ink-2); background: #E7E6E1; border-radius: 4px; padding: 5px 0; width: 44px; text-align: center; flex: none; }
.file-ext-pdf { background: var(--peach); color: var(--peach-ink); }
.file-ext-docx, .file-ext-txt, .file-ext-md { background: var(--sky); color: var(--sky-ink); }
.file-ext-xlsx, .file-ext-csv { background: var(--mint); color: var(--mint-ink); }
.file-ext-pptx { background: var(--butter); color: var(--butter-ink); }
.file-ext-png, .file-ext-jpg, .file-ext-jpeg, .file-ext-gif, .file-ext-webp { background: var(--lav); color: var(--lav-ink); }
.file-name { flex: 1; min-width: 0; color: var(--ink); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.file-name:hover { text-decoration: underline; }
.file-size, .file-vis { color: var(--muted); font-size: 0.8125rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.file-vis.is-private { color: var(--peach-ink); }

details.row-admin, details.file-admin { position: relative; }
.popover {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: 288px; display: grid; gap: 14px;
  background: var(--sheet); border: 1px solid var(--rule-2); border-radius: 12px; padding: 18px;
  box-shadow: 0 1px 2px rgba(31, 36, 48, 0.06), 0 16px 36px -14px rgba(31, 36, 48, 0.32);
}
.popover-wide { width: min(560px, calc(100vw - 48px)); }

/* ---------- projects ---------- */

.page-head { position: relative; }
.add-panel > summary { list-style: none; display: inline-flex; }
.add-panel > summary::-webkit-details-marker { display: none; }
.add-panel[open] > summary { background: var(--sheet); color: var(--ink); border-color: var(--ink-2); }
.add-panel > .panel {
  position: absolute; right: 0; top: calc(100% - 10px); z-index: 20; width: min(560px, 100%); margin: 0;
  box-shadow: 0 1px 2px rgba(31, 36, 48, 0.06), 0 18px 40px -16px rgba(31, 36, 48, 0.34); border-color: var(--rule-2);
}
.projects { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule-2); }
.project { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 4px 24px; align-items: baseline; padding: 24px 0; border-bottom: 1px solid var(--rule); }
.project-year { font-size: 0.9375rem; font-weight: 500; color: var(--mint-ink); font-variant-numeric: tabular-nums; }
.project-name { font: 600 1.25rem/1.3 var(--sans); letter-spacing: -0.012em; display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 16px; }
.project-name a { color: var(--ink); text-decoration: none; }
.project-name a:hover { text-decoration: underline; text-decoration-color: var(--mint-mid); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.project-name .ext { display: inline-block; margin-left: 6px; font-size: 0.8em; font-weight: 400; color: var(--muted); transition: transform 0.15s ease; }
.project-name a:hover .ext { transform: translate(1px, -1px); color: var(--ink); }
.project-name .status { font-size: 0.8125rem; font-weight: 400; letter-spacing: 0; }
.project-summary { color: var(--ink-2); margin: 6px 0 0; max-width: 60ch; }
.project .row-admin { align-self: center; }

/* ---------- goals ---------- */

.goals { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); gap: 28px; }
.goal-c0 { --g: var(--mint); --gm: var(--mint-mid); --gi: var(--mint-ink); }
.goal-c1 { --g: var(--lav); --gm: var(--lav-mid); --gi: var(--lav-ink); }
.goal-c2 { --g: var(--peach); --gm: var(--peach-mid); --gi: var(--peach-ink); }
.goal-c3 { --g: var(--sky); --gm: var(--sky-mid); --gi: var(--sky-ink); }
.goal {
  position: relative; display: grid; gap: 18px; align-content: start;
  background: var(--sheet); border: 1px solid var(--rule); border-radius: 14px; padding: 24px 26px 24px;
}
.goal::before { content: ""; position: absolute; left: 26px; top: -1px; width: 40px; height: 4px; border-radius: 0 0 3px 3px; background: var(--gm); }
.goal-detail { margin-bottom: 44px; }
.goal-page .entries-table th { background: var(--g); color: var(--gi); border-bottom-color: color-mix(in srgb, var(--gi) 16%, var(--g)); }
.goal-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.goal-head h2 { font: 600 1.25rem/1.25 var(--sans); letter-spacing: -0.01em; }
.goal-head h2 a { color: var(--ink); text-decoration: none; }
.goal-head h2 a:hover { text-decoration: underline; text-decoration-color: var(--gm); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.goal-updated { color: var(--muted); font-size: 0.8125rem; margin: 0; white-space: nowrap; }
.goal-figures { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px 28px; }
.goal-big { margin: 0; line-height: 1; display: flex; align-items: baseline; gap: 6px; }
.goal-big .num { font: 300 3.25rem/0.95 var(--sans); letter-spacing: -0.035em; color: var(--ink); }
.goal-big .unit { font-size: 1.125rem; font-weight: 500; color: var(--ink-2); }
.goal-big .of { font-size: 0.9375rem; color: var(--muted); margin-left: 2px; }
.goal-stats { display: flex; gap: 26px; margin: 0; }
.goal-stats div { display: grid; gap: 3px; }
.goal-stats dt { color: var(--muted); font-size: 0.75rem; }
.goal-stats dd { margin: 0; font-weight: 600; font-size: 0.975rem; white-space: nowrap; }
.goal-stats dd span { font-weight: 400; color: var(--ink-2); }
.progress { height: 6px; border-radius: 99px; overflow: hidden; background: color-mix(in srgb, var(--g) 85%, var(--rule)); }
.progress span { display: block; height: 100%; border-radius: 99px; background: var(--gi); }
.progress-label { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 0.8125rem; margin: -8px 0 0; }
.goal-empty { color: var(--muted); padding: 30px 0; text-align: center; border: 1px dashed var(--rule-2); border-radius: 10px; margin: 0; }
.chart-wrap { margin: 2px 0 0; }
.chart-compact { display: none; }
.chart-wrap figcaption { color: var(--muted); font-size: 0.75rem; margin-top: 6px; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--rule); stroke-width: 1; stroke-dasharray: 2 3; }
.chart .baseline { stroke: var(--rule-2); stroke-width: 1; }
.chart .axis { fill: var(--muted); font: 400 11px var(--sans); }
.chart .bar { fill: var(--gm); }
.chart .bar:has(+ .hit.is-active) { fill: var(--gi); }
.chart .line { fill: none; stroke: var(--gi); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot, .chart .hover-dot { fill: var(--gi); stroke: var(--sheet); stroke-width: 2.5; }
.chart .hover-dot { opacity: 0; pointer-events: none; }
.chart .hover-dot.is-on { opacity: 1; }
.chart .target { stroke: var(--ink-2); stroke-width: 1.25; stroke-dasharray: 5 4; opacity: 0.6; }
.chart .target-label { fill: var(--ink-2); font-weight: 600; }
.chart .hit { fill: transparent; }
.chart .hit.is-active { fill: var(--g); fill-opacity: 0.55; }
.tooltip { position: fixed; z-index: 50; pointer-events: none; background: var(--ink); color: #F8F8F5; font-size: 0.8125rem; padding: 6px 10px; border-radius: 7px; max-width: 260px; line-height: 1.35; box-shadow: 0 8px 20px -10px rgba(31, 36, 48, 0.5); }
.log-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding-top: 18px; border-top: 1px dashed var(--rule-2); }
.log-form .field { flex: 1 1 110px; min-width: 0; }
.log-form .field-date { flex: 0 0 160px; }
.log-form .field-grow { flex: 2 1 170px; }
.log-form input { min-height: 38px; padding: 7px 10px; }
.log-form .field > span { font-size: 0.75rem; }
.entries h2 { font: 600 1.25rem var(--sans); letter-spacing: -0.01em; margin-bottom: 14px; }
.entries-table .col-date { color: var(--ink-2); }
.entries-table .col-num { width: 1%; white-space: nowrap; padding-left: 28px; padding-right: 28px; font-weight: 500; color: var(--ink); }
.entries-table .col-note { color: var(--ink-2); }
.archived { margin-top: 36px; color: var(--muted); font-size: 0.9375rem; }

/* ---------- blog ---------- */

.posts { list-style: none; margin: 0; padding: 0; isolation: isolate; }
.post-item { position: relative; display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 24px; padding: 24px 0 26px; border-bottom: 1px solid var(--rule); }
.post-item::before { content: ""; position: absolute; inset: 6px -14px; border-radius: 10px; background: color-mix(in srgb, var(--sec) 45%, transparent); opacity: 0; transition: opacity 0.12s ease; z-index: -1; }
.post-item:first-child::before { top: -6px; }
.post-item:hover::before { opacity: 1; }
.post-title a::after { content: ""; position: absolute; inset: 0; }
.post-title a:focus-visible { outline: none; }
.post-title a:focus-visible::after { outline: 2px solid var(--ring); outline-offset: -2px; border-radius: 8px; }
.post-item:first-child { padding-top: 6px; }
.post-date { color: var(--muted); font-size: 0.875rem; font-variant-numeric: tabular-nums; padding-top: 7px; white-space: nowrap; }
.post-title { font: 600 1.5rem/1.25 var(--serif); letter-spacing: -0.012em; font-optical-sizing: auto; }
.post-title a { color: var(--ink); text-decoration: none; }
.post-title a:hover { text-decoration: underline; text-decoration-color: var(--lav-mid); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.post-title .status { font: 400 0.8125rem var(--sans); vertical-align: 3px; margin-left: 10px; }
.post-excerpt { font-family: var(--serif); font-size: 1.0625rem; line-height: 1.55; color: var(--ink-2); margin: 8px 0 0; max-width: 62ch; }
.post > * { max-width: 760px; }
.post-head { padding: 14px 0 28px; margin-bottom: 36px; border-bottom: 1px solid var(--rule); }
.post-head .doc-title { font-size: clamp(2.1rem, 1.6rem + 2vw, 3rem); }

.quotes { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule-2); }
.quote-item { padding: 24px 0 25px; border-bottom: 1px solid var(--rule); }
.quote-item blockquote { margin: 0; }
.quote-item blockquote p { font: 400 1.1875rem/1.5 var(--sans); letter-spacing: -0.005em; margin: 0; color: var(--ink); max-width: 64ch; }
.quote-by { color: var(--ink-2); font-size: 0.9375rem; margin: 9px 0 0; display: flex; gap: 8px 14px; flex-wrap: wrap; align-items: center; }
.quote-by cite { font-style: normal; color: var(--muted); }
.today-mark { font-size: 0.8125rem; color: var(--muted); }
.row-actions { display: flex; align-items: baseline; gap: 18px; margin-top: 10px; }
.row-actions .link-btn { color: var(--muted); text-decoration-color: color-mix(in srgb, var(--muted) 45%, transparent); }
.row-actions .link-btn:hover { color: var(--ink); text-decoration-color: currentColor; }
.add-quote { margin-bottom: 30px; }

/* ---------- editor ---------- */

.editor-page { padding-bottom: 40px; }
.editor-form { display: grid; gap: 18px; margin-top: 18px; }
.title-input {
  font: 600 clamp(1.9rem, 1.5rem + 1.4vw, 2.5rem)/1.15 var(--serif) !important; letter-spacing: -0.014em; min-height: 0 !important;
  border: 0 !important; border-bottom: 1px solid var(--rule) !important; border-radius: 0 !important; background: transparent !important;
  padding: 2px 0 12px !important; box-shadow: none !important;
}
.title-input:focus { border-bottom-color: var(--ring) !important; }
.editor-meta { display: flex; flex-wrap: wrap; gap: 14px 16px; align-items: flex-end; }
.editor-meta .field { flex: 1 1 220px; max-width: 360px; }
.editor-meta .check { padding-bottom: 10px; }
.editor { background: var(--sheet); border: 1px solid var(--rule-2); border-radius: 12px; overflow: clip; }
.editor-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 6px 8px; border-bottom: 1px solid var(--rule); background: #F1F1EC; position: sticky; top: var(--header-h); z-index: 4; }
.tool-group { display: inline-flex; gap: 1px; padding-right: 6px; margin-right: 2px; border-right: 1px solid var(--rule); }
.tool-group:nth-last-of-type(1) { border-right: 0; }
.editor-toolbar button, .toolbar-upload {
  font: 500 0.8125rem/1 var(--sans); color: var(--ink-2); background: none; border: 0; border-radius: 6px; padding: 8px 10px; cursor: pointer;
}
.editor-toolbar button:hover, .toolbar-upload:hover { background: var(--sheet); color: var(--ink); box-shadow: inset 0 0 0 1px var(--rule); }
.toolbar-spacer { flex: 1; }
.view-toggle[aria-pressed="true"] { background: var(--sheet) !important; color: var(--ink) !important; box-shadow: inset 0 0 0 1px var(--rule-2); }
.editor-panes { display: grid; grid-template-columns: 1fr 1fr; min-height: 440px; }
.editor-input {
  border: 0 !important; border-radius: 0 !important; box-shadow: none !important; resize: none; padding: 22px !important;
  font: 400 0.875rem/1.7 var(--mono) !important; background: var(--sheet) !important; min-height: 440px; border-right: 1px solid var(--rule) !important;
}
.editor-preview { padding: 22px 26px; overflow: auto; background: var(--paper); font-size: 1.0625rem; }
.editor-help { font-size: 0.75rem; color: var(--muted); padding: 9px 14px; margin: 0; border-top: 1px solid var(--rule); background: #F1F1EC; }
.editor-help code { font-family: var(--mono); font-size: 0.75rem; color: var(--ink-2); }
.editor .editor-error { margin: 8px; }
.sticky-actions { position: sticky; bottom: 0; z-index: 5; padding: 12px 0; background: color-mix(in srgb, var(--paper) 90%, transparent); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); border-top: 1px solid var(--rule); }
@media (max-width: 1000px) {
  .editor-panes { grid-template-columns: 1fr; }
  .editor-preview { display: none; }
  .editor.show-preview .editor-preview { display: block; }
  .editor.show-preview .editor-input { display: none; }
  .editor-input { border-right: 0 !important; }
}
@media (min-width: 1001px) { .view-toggle { display: none; } }

/* ---------- sign in and errors ---------- */

.login { display: grid; place-items: start center; padding-top: 72px; }
.login-box { width: 100%; max-width: 380px; }
.login h1 { font: 600 1.75rem/1.2 var(--sans); letter-spacing: -0.015em; margin-bottom: 8px; }
.login-note { color: var(--ink-2); font-size: 0.9375rem; margin-bottom: 26px; }
.login .stack { gap: 16px; }
.login .btn-block { margin-top: 6px; }
.error-page { padding-top: 96px; }
.error-page h1 { font: 600 2rem/1.2 var(--sans); letter-spacing: -0.02em; margin-bottom: 12px; }
.error-page p { color: var(--ink-2); font-size: 1.0625rem; }
.error-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 24px; }

/* =========================================================
   Home: the quote of the day and the section wheel
   ========================================================= */

/* header: just the name, centred; the wheel is the navigation here */
body.nav-home { --header-h: 54px; }
body.nav-home .header-inner { justify-content: center; position: relative; }
body.nav-home .wordmark { margin-right: 0; padding-left: 0.24em; }
body.nav-home .main-nav { display: none; }
body.nav-home .signout { position: absolute; right: var(--gutter); top: 50%; translate: 0 -50%; border-left: 0; }
body.nav-home .site-header { background: color-mix(in srgb, var(--paper) 80%, transparent); }
body.nav-home main { padding-bottom: 0; }

/* pastel washes: faint at rest, a little stronger while the pointer moves or a finger touches */
body.nav-home::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(55vw 60vh at 0% 100%, color-mix(in srgb, var(--rose) 95%, transparent), transparent 70%),
    radial-gradient(45vw 55vh at 18% 75%, color-mix(in srgb, var(--lav) 80%, transparent), transparent 70%),
    radial-gradient(60vw 80vh at 100% 20%, color-mix(in srgb, var(--sky) 95%, transparent), transparent 70%),
    radial-gradient(40vw 40vh at 0% 0%, color-mix(in srgb, var(--butter) 70%, transparent), transparent 70%);
  opacity: 0.42; transition: opacity 1.4s ease;
}
body.nav-home::after {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(500px 500px at var(--mx, 50%) var(--my, 50%), color-mix(in srgb, var(--lav) 78%, var(--lav-ink)), transparent 70%);
  opacity: 0; transition: opacity 1.4s ease;
}
body.nav-home.is-awake::before { opacity: 0.72; transition-duration: 0.6s; }
body.nav-home.is-awake::after { opacity: 0.62; transition-duration: 0.5s; }

.home {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 46vw);
  min-height: calc(100vh - 55px); min-height: calc(100svh - 55px); overflow: hidden;
  /* bottom padding = header height, so the quote and the wheel's centre sit at the middle of the screen */
  padding: 0 0 55px max(var(--gutter), calc((100vw - 1240px) / 2));
}
.home-quote { align-self: center; padding: 48px 0; max-width: 640px; }
.home-date { font: 400 clamp(0.95rem, 0.88rem + 0.3vw, 1.2rem)/1.3 var(--serif); color: var(--ink-2); margin: 0 0 22px; letter-spacing: 0.01em; }
.home-date span { color: var(--faint); margin: 0 0.25em; }
.home-q { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 0 22px; }
.home-q-mark { width: clamp(26px, 2.4vw, 34px); fill: var(--ink); margin-top: 0.35em; grid-row: 1 / span 2; }
.home-q-text { margin: 0; }
.home-q-text p { font: 400 clamp(1.55rem, 1.05rem + 1.6vw, 2.4rem)/1.17 var(--serif); letter-spacing: -0.012em; color: var(--ink); margin: 0; text-wrap: balance; font-optical-sizing: auto; }
.home-q-text.is-long p { font-size: clamp(1.25rem, 0.95rem + 1vw, 1.8rem); line-height: 1.28; }
.home-q-by { grid-column: 2; margin-top: 14px; font: 400 clamp(1.05rem, 0.9rem + 0.6vw, 1.4rem)/1.35 var(--serif); color: var(--ink-2); }
.home-q-by cite { font-style: italic; color: var(--muted); font-size: 0.78em; }
.home-admin { margin: 26px 0 0 calc(clamp(26px, 2.4vw, 34px) + 22px); font-size: 0.875rem; }

.home-foot { position: absolute; left: max(var(--gutter), calc((100vw - 1240px) / 2)); bottom: 26px; display: flex; flex-wrap: wrap; gap: 6px 28px; align-items: baseline; font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-2); }
.home-foot a { color: inherit; text-decoration: none; }
.home-foot a:hover { color: var(--ink); }
.home-foot [aria-hidden] { color: var(--faint); margin: 0 0.35em; }

/* the wheel */
.wheel { position: relative; align-self: stretch; min-height: 420px; touch-action: none; user-select: none; -webkit-user-select: none; }
.wheel-items { list-style: none; margin: 0; padding: 0; position: absolute; inset: 0; }
.wheel-item {
  position: absolute; left: 0; top: 0; white-space: nowrap; text-decoration: none; transform-origin: center;
  font-family: var(--hand); font-weight: 400; font-size: clamp(1.5rem, 1rem + 1.6vw, 2.4rem); line-height: 1.3; padding: 0 0.2em;
  color: color-mix(in srgb, var(--ink-2) calc(25% + var(--focus, 0) * 60%), var(--muted));
  will-change: transform, opacity; opacity: 0;
}
.wheel-item:hover { color: var(--ink); }
.wheel-item.is-active { color: var(--ink-2); font-weight: 500; text-shadow: 0 6px 18px color-mix(in srgb, var(--ink) 10%, transparent); }
.wheel-item:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 12px; }
/* before the script places them (or without JavaScript): a plain list */
.wheel:not(.is-ready) .wheel-items { position: static; display: grid; gap: 8px; justify-items: end; padding: 80px 48px 0 0; }
.wheel:not(.is-ready) .wheel-item { position: static; opacity: 1; font-size: 2rem; }

/* ---------- responsive ---------- */

@media (max-width: 980px) {
  .note-layout { grid-template-columns: minmax(0, 1fr); align-content: start; }
  .note-side { align-self: start; box-shadow: none; clip-path: none; margin: 24px 0 0; padding: 0; border: 1px solid var(--rule); border-radius: 12px; background: var(--sheet); }
  .side-toggle { position: static; max-height: none; overflow: visible; padding: 0; }
  .side-toggle > summary { cursor: pointer; padding: 13px 16px; margin: 0; border: 0; display: flex; align-items: center; gap: 4px 10px; flex-wrap: wrap; }
  .side-toggle > summary::after { content: "Pages"; margin-left: auto; font-size: 0.8125rem; color: var(--muted); padding-right: 18px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='7' fill='none' stroke='%23646875' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.5l4 4 4-4'/%3E%3C/svg%3E") no-repeat right center; }
  .side-toggle[open] > summary { border-bottom: 1px solid var(--rule); }
  .side-toggle[open] > summary::after { content: "Hide"; }
  .side-title .side-sub { flex-basis: 100%; order: 3; }
  .side-toggle > .tree { padding: 8px 10px 10px 6px; }
  .side-files { padding: 12px 16px 14px; margin: 0; }
  .note { padding: 0; }
  .note .crumbs { padding-top: 22px; }
}

@media (max-width: 720px) {
  :root { --gutter: 18px; --header-h: 50px; }
  body { font-size: 0.9375rem; }
  .header-inner { flex-wrap: wrap; height: auto; gap: 0; padding-top: 4px; }
  .wordmark { font-size: 0.875rem; padding: 13px 0 11px; }
  .signout { border-left: 0; padding-left: 0; height: auto; }
  .main-nav { order: 3; flex-basis: 100%; justify-content: space-between; margin: 0 -10px; padding-bottom: 2px; }
  .main-nav a { padding: 10px 10px 12px; font-size: 0.9375rem; }
  .site-header { position: static; }
  .side-toggle { top: 0; }
  .editor-toolbar { top: 0; }
  .page-head { padding-top: 34px; padding-bottom: 20px; }
  .page-head h1 { font-size: 1.875rem; }
  /* section tabs become a two-column set of buttons, so none hide off-screen */
  .tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; border-bottom: 0; margin-bottom: 22px; overflow: visible; }
  .tabs a { top: 0; justify-content: space-between; padding: 10px 12px; font-size: 0.875rem; border: 1px solid var(--rule-2); border-radius: 9px; background: color-mix(in srgb, var(--sheet) 60%, transparent); }
  .tabs a[aria-current="page"] { border-color: color-mix(in srgb, var(--sec-ink) 28%, var(--sec)); }
  .tabs a:focus-visible { border-radius: 9px; }
  .form-grid, .upload-form { grid-template-columns: 1fr; }
  .panel { padding: 18px; }

  .db-tools { align-items: stretch; }
  .db-tools .search { flex: 1 1 100%; }
  .seg { width: 100%; justify-content: space-between; }
  .seg .chip { flex: 1; padding: 9px 4px; }

  /* module table becomes a list of rows */
  .db-table thead { display: none; }
  .db-table, .db-table tbody, .db-table tr, .db-table td { display: block; width: 100%; }
  .db-table tr[data-href] { display: grid; grid-template-columns: auto auto minmax(0, 1fr); align-items: center; gap: 5px 14px; padding: 14px 16px 13px; border-top: 1px solid var(--rule); }
  .db-table tbody tr:first-child { border-top: 0; }
  .db-table tr[data-href] td { border: 0; padding: 0; width: auto; }
  .db-table td.col-code { grid-area: 1 / 1; }
  .db-table td.col-status { grid-area: 1 / 2 / 2 / 4; justify-self: end; }
  .db-table td.col-title { grid-area: 2 / 1 / 3 / 4; font-size: 1rem; }
  .db-table td.col-title .tags { display: flex; margin: 7px 0 1px; }
  .db-table td.col-year, .db-table td.col-sem, .db-table td.col-date { grid-row: 3; font-size: 0.8125rem; color: var(--muted); }
  .db-table td.col-year { grid-column: 1; }
  .db-table td.col-sem { grid-column: 2; }
  .db-table td.col-date { grid-column: 3; justify-self: end; }
  .db-table .col-year .cell-label { display: inline; }
  .db-table td .none { display: none; }
  .entries-table thead { display: table-header-group; }
  .entries-table { display: table; }
  .entries-table tbody { display: table-row-group; }
  .entries-table tr { display: table-row; }
  .entries-table td { display: table-cell; width: auto; padding: 11px 12px; border-top: 1px solid var(--rule); }
  .entries-table th { padding: 9px 12px; }

  .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px 18px; }
  .nb-row { grid-template-columns: 1fr; margin: 0 calc(-1 * var(--gutter)); padding: 16px var(--gutter); }
  .nb-row-meta { justify-items: start; grid-auto-flow: column; justify-content: start; gap: 14px; margin-top: 2px; }

  .nb-head.has-cover { grid-template-columns: 112px minmax(0, 1fr); gap: 20px; }
  .nb-cover { width: 112px; }
  .titleblock { display: grid; grid-template-columns: 1fr 1fr; }
  .tb-cell { min-width: 0; padding: 8px 12px 10px; }
  .tb-tags, .tb-author { grid-column: 1 / -1; }
  .nb-head.has-cover .titleblock { grid-column: 1 / -1; }

  .project { grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 20px 0; }
  .project-year { grid-column: 1; grid-row: 1; font-size: 0.8125rem; }
  .project-year:empty { display: none; }
  .project-body { grid-column: 1; }
  .project .row-admin { grid-column: 2; grid-row: 1 / span 2; }
  .project-name { font-size: 1.125rem; }

  .goal { padding: 20px 18px; }
  .goal::before { left: 18px; }
  .goal-big .num { font-size: 2.75rem; }
  .goal-stats { gap: 18px; }
  .goals .chart .axis, .chart-compact .chart .axis { font-size: 14px; }
  .chart-full { display: none; }
  .chart-compact { display: block; }
  .log-form .field-date { flex: 1 1 140px; }

  .post-item { grid-template-columns: 1fr; gap: 4px; padding: 20px 0; }
  .post-date { padding-top: 0; }
  .post-title { font-size: 1.3125rem; }
  .prose { font-size: 1.0625rem; }
  .prose-post { font-size: 1.125rem; }

  .pager { grid-template-columns: 1fr; }
  .pager-next { grid-column: 1; }
  .file-row { flex-wrap: wrap; gap: 6px 12px; }
  .file-name { flex-basis: calc(100% - 60px); }
  .file-size { margin-left: 56px; }

  /* home */
  body.nav-home .header-inner { flex-wrap: nowrap; padding-top: 0; height: 50px; }
  body.nav-home .wordmark { padding: 0 0 0 0.24em; }
  body.nav-home .site-header { position: sticky; }
  body.nav-home .home { grid-template-columns: 1fr; grid-template-rows: auto minmax(360px, 1fr) auto; padding: 0 var(--gutter); min-height: calc(100vh - 51px); min-height: calc(100svh - 51px); }
  .home-quote { padding: 32px 0 8px; }
  .wheel { margin: 0 calc(-1 * var(--gutter)); min-height: 380px; }
  .home-foot { position: static; grid-column: 1; padding: 8px 0 22px; flex-direction: column; gap: 6px; font-size: 0.6875rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

@media print {
  .site-header, .page-foot, .admin-bar, .note-side, .pager, .flash { display: none; }
  body { background: #fff; }
  .note { padding: 0; max-width: none; }
  .note-layout { display: block; }
}
