/* Layout: one narrow reading column; index is a ruled list of idea rows, detail is a single article. */
:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --fg: #17202a;
  --muted: #5a6774;
  --line: #d9e0e6;
  --accent: #1d5c88;
  --accent-soft: #e2edf5;
  --mark: #f6e3a1;
  --display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --body: "Source Serif 4", Georgia, "Times New Roman", serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11161c; --surface: #19212a; --fg: #e4e9ee; --muted: #94a1ad;
    --line: #2a343f; --accent: #7fb6de; --accent-soft: #1c2c3a; --mark: #5b4a17;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #11161c; --surface: #19212a; --fg: #e4e9ee; --muted: #94a1ad;
  --line: #2a343f; --accent: #7fb6de; --accent-soft: #1c2c3a; --mark: #5b4a17;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 17px/1.6 var(--body);
}
.wrap {
  max-width: 44rem;
  margin: 0 auto;
  padding-block: 3rem 4rem;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}
a { color: var(--accent); text-underline-offset: 3px; }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
h1, h2, h3 { font-family: var(--display); text-wrap: balance; line-height: 1.15; margin: 0; }
h1 { font-size: clamp(2rem, 6vw, 2.8rem); font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 1.05rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
p { margin: 0; }
.label {
  font: 500 0.75rem/1.4 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

/* Header */
.masthead { display: flex; flex-direction: column; gap: 0.75rem; border-bottom: 2px solid var(--fg); padding-bottom: 1.25rem; }
.masthead .lede { color: var(--muted); max-width: 36rem; }
.masthead .meta { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; font-variant-numeric: tabular-nums; }

/* Index rows */
.ideas { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.ideas li { border-bottom: 1px solid var(--line); }
.ideas a.row {
  display: grid;
  grid-template-columns: 3.25rem 1fr;
  gap: 0 1rem;
  padding: 1.25rem 0;
  text-decoration: none;
  color: inherit;
}
.ideas a.row:hover .title, .ideas a.row:focus-visible .title { color: var(--accent); }
.ideas .num { font: 500 0.85rem/1.9 var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.ideas .text { min-width: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.ideas .title { font: 600 1.3rem/1.25 var(--display); transition: color 120ms; }
.ideas .one { color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.3rem; }
.tag {
  font: 500 0.72rem/1 var(--mono);
  padding: 0.3rem 0.5rem;
  border-radius: 3px;
  background: var(--accent-soft);
  color: var(--accent);
}

/* Detail */
.back { font: 500 0.85rem/1 var(--mono); text-decoration: none; }
.article { display: flex; flex-direction: column; gap: 2.25rem; }
.article header { display: flex; flex-direction: column; gap: 0.9rem; }
.article .one { font-size: 1.2rem; color: var(--muted); }
.section { display: flex; flex-direction: column; gap: 0.9rem; }
.prose { display: flex; flex-direction: column; gap: 1rem; }
.say { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.75rem; }
.say li {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.9rem 1rem;
}
.say li::before { content: "\201C"; font: 700 1.4rem/0 var(--display); color: var(--accent); margin-right: 0.15rem; vertical-align: -0.35rem; }
.asks { margin: 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: 0.4rem; }
.fits { display: grid; grid-template-columns: max-content 1fr; gap: 0.5rem 1rem; margin: 0; }
.fits dt { font: 600 0.95rem/1.6 var(--display); }
.fits dd { margin: 0; min-width: 0; }
.source {
  border-top: 1px solid var(--line);
  padding-top: 1rem;
  display: flex; flex-direction: column; gap: 0.3rem;
}
mark { background: var(--mark); color: inherit; padding: 0 0.15em; }
footer.foot { color: var(--muted); font-size: 0.9rem; border-top: 1px solid var(--line); padding-top: 1rem; }

@media (max-width: 480px) {
  body { font-size: 16px; }
  .ideas a.row { grid-template-columns: 2.25rem 1fr; }
  .fits { grid-template-columns: 1fr; gap: 0.15rem; }
  .fits dd { margin-bottom: 0.6rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Tables inside detail sections */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
table.grid { border-collapse: collapse; width: 100%; font-size: 0.92rem; line-height: 1.45; }
table.grid th, table.grid td { text-align: left; vertical-align: top; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--line); }
table.grid th { font: 500 0.72rem/1.3 var(--mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid td:first-child { font: 600 0.95rem/1.4 var(--display); white-space: nowrap; }
.note { color: var(--muted); font-size: 0.95rem; }
@media (max-width: 480px) { table.grid { min-width: 34rem; } }

/* Link to the original article */
.src { font-size: 0.92rem; color: var(--muted); display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.2rem 0.5rem; }
.src .label { font-size: 0.68rem; }
.ideas li .src { padding: 0 0 1.25rem calc(3.25rem + 1rem); margin-top: -0.6rem; }
@media (max-width: 480px) { .ideas li .src { padding-left: calc(2.25rem + 1rem); } }

/* Pattern guide: collapsible pattern cards */
.pattern { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.pattern + .pattern { margin-top: 0.75rem; }
.pattern summary {
  list-style: none; cursor: pointer; display: grid; grid-template-columns: 2.25rem 1fr; gap: 0.15rem 0.75rem;
  padding: 0.9rem 1rem;
}
.pattern summary::-webkit-details-marker { display: none; }
.pattern summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.pattern .pnum { font: 500 0.85rem/1.9 var(--mono); color: var(--muted); grid-row: span 2; }
.pattern .pname { font: 600 1.2rem/1.3 var(--display); }
.pattern .pname::after { content: " +"; color: var(--accent); }
.pattern[open] .pname::after { content: " \2212"; }
.pattern .psig { color: var(--muted); font-size: 0.95rem; }
.pattern summary:hover .pname { color: var(--accent); }
.pbody { padding: 0 1rem 1.25rem; display: flex; flex-direction: column; gap: 0.9rem; border-top: 1px solid var(--line); padding-top: 1rem; }
.pbody h3 { font-size: 1rem; margin-top: 0.6rem; }
.pbody .picture { font-size: 1.05rem; }
.pbody .note .label, .trade .label { margin-right: 0.35rem; }
.terms { display: grid; grid-template-columns: minmax(8rem, 13rem) 1fr; gap: 0.55rem 1rem; margin: 0; font-size: 0.95rem; }
.terms dt { font: 600 0.92rem/1.5 var(--display); }
.terms dd { margin: 0; min-width: 0; }
.trades { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 0.75rem; counter-reset: t; }
.trade { border-left: 3px solid var(--accent); padding: 0.1rem 0 0.1rem 0.9rem; display: flex; flex-direction: column; gap: 0.4rem; font-size: 0.97rem; }
.trade h4 { margin: 0; font: 600 1rem/1.3 var(--display); }
.trade .default { background: var(--accent-soft); border-radius: 4px; padding: 0.45rem 0.6rem; }
.reads { margin: 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.95rem; }
.dl a { font: 500 0.82rem/1.4 var(--mono); }
@media (max-width: 480px) {
  .terms { grid-template-columns: 1fr; gap: 0.1rem; }
  .terms dd { margin-bottom: 0.5rem; }
  .pattern summary { grid-template-columns: 1.75rem 1fr; }
}

/* Contents page */
.toc { display: flex; flex-direction: column; gap: 2.5rem; }
.toc ol { margin: 0; }
.toc-1 { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 1.5rem; }
.toc-1 > li { display: flex; flex-direction: column; gap: 0.35rem; padding-bottom: 1.5rem; border-bottom: 1px solid var(--line); min-width: 0; }
.toc-1 > li:last-child { border-bottom: 0; padding-bottom: 0; }
.toc-title { font: 600 1.3rem/1.25 var(--display); text-decoration: none; color: var(--fg); }
.toc-title:hover, .toc-title:focus-visible { color: var(--accent); }
.toc-one { color: var(--muted); }
.toc-2 { padding-left: 1.3rem; display: flex; flex-direction: column; gap: 0.3rem; margin-top: 0.4rem !important; font-size: 0.97rem; }
.toc-2 > li::marker { color: var(--muted); font: 500 0.8rem var(--mono); }
.toc-3 { padding-left: 1.2rem; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.15rem 1rem; margin: 0.3rem 0 0.4rem !important; font-size: 0.92rem; }
.toc-3 > li::marker { color: var(--muted); font: 500 0.75rem var(--mono); }
@media (max-width: 480px) { .toc-3 { grid-template-columns: 1fr; } }

/* Step-by-step plan */
.plan { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1rem; counter-reset: step; }
.step { counter-increment: step; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: 0.6rem; min-width: 0; }
.step .check { display: flex; align-items: baseline; gap: 0.6rem; cursor: pointer; }
.step .check input { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); flex: none; transform: translateY(0.15rem); }
.step-title { font: 600 1.15rem/1.3 var(--display); }
.step-title::before { content: counter(step) ". "; color: var(--muted); font-family: var(--mono); font-weight: 500; font-size: 0.9rem; }
.step.done { opacity: 0.6; }
.step.done .step-title { text-decoration: line-through; text-decoration-color: var(--muted); }
.step.morning { border-style: dashed; }
