/* iA Writer Quattro (OFL): duplexed, between a book sans and mono.
   Body is Regular. Titles are Bold only. Code is IBM Plex Mono. */

@font-face {
  font-family: "iA Writer Quattro";
  src: url("../fonts/ia-writer-quattro-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "iA Writer Quattro";
  src: url("../fonts/ia-writer-quattro-400-italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "iA Writer Quattro";
  src: url("../fonts/ia-writer-quattro-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("../fonts/ibm-plex-mono-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --font: "iA Writer Quattro", ui-sans-serif, system-ui, sans-serif;
  --font-ui: "iA Writer Quattro", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --measure: 38rem;
  --rail: 15rem;
  --gap: 3.5rem;
  --pad: 2.5rem 1.5rem 4.5rem;

  /* Vermilion: hinomaru red on near-white, black ink, gold meta */
  --paper: #fff8f4;
  --ink: #14110f;
  --muted: #6b5e58;
  --gold: #b8860b;
  --rule: #ead8d0;
  --accent: #d61f26;
  --accent-hover: #a8181e;
  --code-bg: #f3e6df;
  --focus: #d61f26;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #140807;
    --ink: #ffe8e2;
    --muted: #d4a35a;
    --gold: #e0b84a;
    --rule: #3a1c18;
    --accent: #ff4d42;
    --accent-hover: #ff7a70;
    --code-bg: #1e0c0a;
    --focus: #ff4d42;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #140807;
  --ink: #ffe8e2;
  --muted: #d4a35a;
  --gold: #e0b84a;
  --rule: #3a1c18;
  --accent: #ff4d42;
  --accent-hover: #ff7a70;
  --code-bg: #1e0c0a;
  --focus: #ff4d42;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --paper: #fff8f4;
  --ink: #14110f;
  --muted: #6b5e58;
  --gold: #b8860b;
  --rule: #ead8d0;
  --accent: #d61f26;
  --accent-hover: #a8181e;
  --code-bg: #f3e6df;
  --focus: #d61f26;
  color-scheme: light;
}

/* Sepia: warm parchment, brown ink — clearly tan, not grey */
:root[data-palette="sepia"] {
  --paper: #e4c9a0;
  --ink: #3b2414;
  --muted: #7a5533;
  --gold: #8a5a1a;
  --rule: #c9a875;
  --accent: #7a3e14;
  --accent-hover: #5a2c0e;
  --code-bg: #d7b586;
  --focus: #7a3e14;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root[data-palette="sepia"] {
    --paper: #1c140c;
    --ink: #f3e2c4;
    --muted: #c4a06a;
    --gold: #e0b86a;
    --rule: #3d2e1c;
    --accent: #e0b07a;
    --accent-hover: #f0c898;
    --code-bg: #271c12;
    --focus: #e0b07a;
    color-scheme: dark;
  }
}

:root[data-palette="sepia"][data-theme="dark"] {
  --paper: #1c140c;
  --ink: #f3e2c4;
  --muted: #c4a06a;
  --gold: #e0b86a;
  --rule: #3d2e1c;
  --accent: #e0b07a;
  --accent-hover: #f0c898;
  --code-bg: #271c12;
  --focus: #e0b07a;
  color-scheme: dark;
}

:root[data-palette="sepia"][data-theme="light"] {
  --paper: #e4c9a0;
  --ink: #3b2414;
  --muted: #7a5533;
  --gold: #8a5a1a;
  --rule: #c9a875;
  --accent: #7a3e14;
  --accent-hover: #5a2c0e;
  --code-bg: #d7b586;
  --focus: #7a3e14;
  color-scheme: light;
}

/* Shibui: cool dusty-blue paper, burgundy accent, ochre gold */
:root[data-palette="shibui"] {
  --paper: #d5e0ea;
  --ink: #1c1719;
  --muted: #4a6578;
  --gold: #8a7020;
  --rule: #b7c7d4;
  --accent: #7a1f2b;
  --accent-hover: #5c171f;
  --code-bg: #c4d2de;
  --focus: #7a1f2b;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root[data-palette="shibui"] {
    --paper: #0c1218;
    --ink: #d7e4ee;
    --muted: #7a9bb0;
    --gold: #e6b148;
    --rule: #243040;
    --accent: #e05660;
    --accent-hover: #f07a82;
    --code-bg: #141c26;
    --focus: #e05660;
    color-scheme: dark;
  }
}

:root[data-palette="shibui"][data-theme="dark"] {
  --paper: #0c1218;
  --ink: #d7e4ee;
  --muted: #7a9bb0;
  --gold: #e6b148;
  --rule: #243040;
  --accent: #e05660;
  --accent-hover: #f07a82;
  --code-bg: #141c26;
  --focus: #e05660;
  color-scheme: dark;
}

:root[data-palette="shibui"][data-theme="light"] {
  --paper: #d5e0ea;
  --ink: #1c1719;
  --muted: #4a6578;
  --gold: #8a7020;
  --rule: #b7c7d4;
  --accent: #7a1f2b;
  --accent-hover: #5c171f;
  --code-bg: #c4d2de;
  --focus: #7a1f2b;
  color-scheme: light;
}

/* Kabuki: green-wash paper, persimmon, forest */
:root[data-palette="kabuki"] {
  --paper: #dce8dc;
  --ink: #161a16;
  --muted: #2d6b45;
  --gold: #c45a20;
  --rule: #b5cbb5;
  --accent: #e85a20;
  --accent-hover: #c44818;
  --code-bg: #c9dbc9;
  --focus: #e85a20;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root[data-palette="kabuki"] {
    --paper: #0a1610;
    --ink: #e4f5e8;
    --muted: #6fbf8a;
    --gold: #ff8a4a;
    --rule: #1c3a28;
    --accent: #ff7a3a;
    --accent-hover: #ff9a68;
    --code-bg: #102018;
    --focus: #ff7a3a;
    color-scheme: dark;
  }
}

:root[data-palette="kabuki"][data-theme="dark"] {
  --paper: #0a1610;
  --ink: #e4f5e8;
  --muted: #6fbf8a;
  --gold: #ff8a4a;
  --rule: #1c3a28;
  --accent: #ff7a3a;
  --accent-hover: #ff9a68;
  --code-bg: #102018;
  --focus: #ff7a3a;
  color-scheme: dark;
}

:root[data-palette="kabuki"][data-theme="light"] {
  --paper: #dce8dc;
  --ink: #161a16;
  --muted: #2d6b45;
  --gold: #c45a20;
  --rule: #b5cbb5;
  --accent: #e85a20;
  --accent-hover: #c44818;
  --code-bg: #c9dbc9;
  --focus: #e85a20;
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-family: var(--font);
  font-size: 17px;
  font-weight: 400;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.7;
  background: var(--paper);
  color: var(--ink);
  hanging-punctuation: first last;
  overflow-x: clip;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
}

img,
svg,
video {
  max-width: 100%;
}

img {
  display: block;
  height: auto;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.skip {
  position: absolute;
  left: 0.75rem;
  top: 0.75rem;
  z-index: 20;
  padding: 0.3rem 0.6rem;
  background: var(--paper);
  transform: translateY(-150%);
}

.skip:focus {
  transform: none;
}

.shell {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, var(--measure));
  gap: var(--gap);
  align-items: start;
  max-width: calc(var(--rail) + var(--gap) + var(--measure));
  margin: 0 auto;
  padding: var(--pad);
  width: 100%;
  min-width: 0;
}

.shell--wide {
  --measure: min(76rem, 100%);
  max-width: 96rem;
}

.rail {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 1.6rem;
  padding: 2.5rem 0 2rem;
  font-family: var(--font-ui);
  font-size: 0.82rem;
  line-height: 1.45;
  max-height: 100dvh;
}

.rail--article {
  gap: 0.95rem;
  overflow: hidden;
}

.brand {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  min-width: 0;
}

.brand a {
  color: var(--accent);
}

.brand a:hover {
  opacity: 0.75;
}

.lede {
  margin: 0.45rem 0 0;
  color: var(--muted);
  text-transform: none;
  font-size: 0.82rem;
}

.rail--article .lede {
  display: none;
}

.nav-toggle {
  display: none;
  margin-top: 0.75rem;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--accent);
  text-transform: uppercase;
  cursor: pointer;
}

.nav-toggle[aria-expanded="true"] .nav-toggle__open,
.nav-toggle[aria-expanded="false"] .nav-toggle__close {
  display: none;
}

.toc {
  margin: 0;
}

.toc ol {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.toc a {
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.toc a:hover,
.toc a[aria-current="page"] {
  color: var(--accent);
}

.rail--article .toc--site ol {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.2rem 0.75rem;
}

.rail--article .toc--site a {
  font-size: 0.68rem;
  letter-spacing: 0.04em;
}

.page-toc {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-top: 0.75rem;
  border-top: 1px solid var(--rule);
  overscroll-behavior: contain;
}

.page-toc__label {
  margin: 0 0 0.55rem;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.page-toc #TableOfContents ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.page-toc #TableOfContents ul ul {
  margin-top: 0.35rem;
  padding-left: 0.7rem;
  gap: 0.28rem;
}

.page-toc a {
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.78rem;
  line-height: 1.35;
  display: inline-block;
  max-width: 100%;
}

.page-toc a:hover,
.page-toc a[aria-current="location"] {
  color: var(--accent);
}

.page-toc a[aria-current="location"] {
  font-weight: 700;
}

.social {
  display: flex;
  gap: 0.85rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.rail--article .social {
  gap: 0.65rem;
}

.social a {
  display: grid;
  place-items: center;
  color: var(--ink);
}

.social a:hover {
  color: var(--accent);
}

.social svg {
  width: 1rem;
  height: 1rem;
  fill: currentColor;
}

.switches {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.rail--article .switches {
  gap: 0.45rem;
  padding-top: 0.15rem;
}

.ink-switch {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.85rem;
  margin: 0;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}

.ink-switch button {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.ink-switch button[aria-pressed="true"],
.ink-switch button:hover {
  color: var(--accent);
}

.ink-switch[aria-label="Palette"] {
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
}

.ink-switch .swatch {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--ink) 18%, transparent);
}

.ink-switch [data-palette-set="vermilion"] .swatch {
  background: #d61f26;
}

.ink-switch [data-palette-set="sepia"] .swatch {
  background: #e4c9a0;
}

.ink-switch [data-palette-set="shibui"] .swatch {
  background: #7a1f2b;
}

.ink-switch [data-palette-set="kabuki"] .swatch {
  background: #e85a20;
}

.stage {
  min-width: 0;
  max-width: 100%;
  padding-top: 2.5rem;
}

.colophon {
  margin-top: 3.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.75rem;
}

.colophon p {
  margin: 0;
}

.colophon a {
  color: inherit;
}

.colophon a:hover {
  color: var(--accent);
}

.post__head {
  margin: 0 0 1.75rem;
}

.post__title {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 1.85rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.03em;
  text-wrap: balance;
  color: var(--ink);
}

.meta {
  margin: 0.55rem 0 0;
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.draft {
  margin-left: 0.5rem;
  color: var(--accent);
  text-transform: uppercase;
}

.log {
  display: flex;
  flex-direction: column;
  gap: 1.6rem;
}

.log__item .meta {
  margin: 0 0 0.2rem;
}

.log__title {
  display: inline;
  font-family: var(--font-ui);
  font-size: 1.12rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.log__title:hover {
  color: var(--accent);
}

.log__desc {
  margin: 0.4rem 0 0;
  font-weight: 400;
  color: var(--muted);
  max-width: 36em;
}

.post__tags {
  margin: 2.25rem 0 0;
  font-family: var(--font-ui);
  font-size: 0.82rem;
  color: var(--muted);
}

.post__tags a {
  color: var(--accent);
}

.term-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.term-list a {
  color: var(--ink);
}

.term-list a:hover {
  color: var(--accent);
}

.term-list .meta {
  display: inline;
  margin-left: 0.6rem;
}

.pagination {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: 1.5rem 0 0;
  padding: 0;
  list-style: none;
  font-family: var(--font-ui);
  font-size: 0.82rem;
  text-transform: uppercase;
}

.pagination li {
  list-style: none;
}

.prose {
  font-size: 1.02rem;
  font-weight: 400;
  line-height: 1.75;
  overflow-wrap: break-word;
}

.prose > * {
  max-width: min(62ch, 100%);
}

.prose--wide > .calc-container {
  max-width: none;
}

.prose h2,
.prose h3,
.prose h4 {
  font-family: var(--font-ui);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
  text-wrap: balance;
  margin: 2.1em 0 0.6em;
  scroll-margin-top: 1.25rem;
}

.prose h2 {
  font-size: 1.2rem;
}

.prose h3 {
  font-size: 1.02rem;
}

.prose p,
.prose ul,
.prose ol {
  margin: 0 0 1.1em;
}

.prose li + li {
  margin-top: 0.35em;
}

.prose a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: color-mix(in oklab, var(--accent) 42%, transparent);
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
}

.prose a:hover {
  text-decoration-color: var(--accent);
}

.prose strong,
.prose b {
  font-weight: 700;
  font-style: normal;
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 2rem 0;
}

.prose blockquote {
  margin: 1.4em 0;
  padding: 0 0 0 1rem;
  border-left: 2px solid var(--accent);
  color: var(--muted);
  font-style: italic;
}

.prose img {
  margin: 1.25rem 0;
}

.prose figure {
  margin: 1.25rem 0;
  max-width: none;
}

.prose figcaption {
  margin-top: 0.4rem;
  font-family: var(--font-ui);
  font-size: 0.78rem;
  color: var(--muted);
}

.prose table {
  display: block;
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  font-size: 0.92rem;
}

.prose th,
.prose td {
  padding: 0.4rem 0.75rem 0.4rem 0;
  border-bottom: 1px solid var(--rule);
  text-align: left;
}

.prose pre {
  max-width: 100%;
  margin: 1.25rem 0;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.55;
  background: var(--code-bg);
}

.prose .highlight {
  max-width: 100%;
}

.prose code,
.prose kbd {
  font-family: var(--font-mono);
  font-size: 0.84em;
}

.prose :not(pre) > code {
  padding: 0.05em 0.28em;
  background: var(--code-bg);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.highlight {
  margin: 1.25rem 0;
  background: var(--code-bg);
  overflow-x: auto;
}

.highlight pre {
  margin: 0;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.55;
  background: transparent;
}

.highlight code {
  font-family: inherit;
}

.chroma .c,
.chroma .c1,
.chroma .cm,
.chroma .cs {
  color: var(--muted);
  font-style: italic;
}

.chroma .k,
.chroma .kd,
.chroma .kn,
.chroma .kp,
.chroma .kr,
.chroma .kt {
  color: var(--accent);
}

.chroma .s,
.chroma .s1,
.chroma .s2,
.chroma .sb,
.chroma .sc,
.chroma .sd,
.chroma .se,
.chroma .sh,
.chroma .si,
.chroma .sx {
  color: var(--ink);
}

.chroma .n,
.chroma .nx,
.chroma .nv,
.chroma .p,
.chroma .o {
  color: var(--ink);
}

/* Calculator: isolate from article prose so cards/tables/inputs keep their layout. */
.prose .calc-container,
.prose .calc-container * {
  max-width: none;
}

.calc-container {
  width: 100%;
  margin: 0 0 2rem;
  padding: 0;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 400;
  line-height: 1.4;
  color: var(--ink);
  container-type: inline-size;
}

.calc-container .tab-navigation {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  margin: 0 0 1.1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--rule);
}

.calc-container .tab-buttons {
  display: flex;
  flex-grow: 1;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.calc-container .tab-button,
.calc-container .add-tab-btn {
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.2;
  cursor: pointer;
}

.calc-container .tab-button {
  position: relative;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--muted);
}

.calc-container .tab-button:hover,
.calc-container .tab-button.active {
  border-color: var(--accent);
  color: var(--accent);
}

.calc-container .tab-button .tab-name {
  display: inline-block;
  max-width: 10rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calc-container .tab-button .tab-close,
.calc-container .tab-button .tab-edit {
  margin-left: 0.35rem;
  opacity: 0.6;
  cursor: pointer;
}

.calc-container .tab-button .tab-close:hover,
.calc-container .tab-button .tab-edit:hover {
  opacity: 1;
  color: var(--ink);
}

.calc-container .tab-name-input {
  width: 7rem;
  padding: 0.15rem 0.4rem;
  border: 1px solid var(--rule);
  background: var(--paper);
  color: inherit;
  font: inherit;
}

.calc-container .add-tab-btn {
  flex: 0 0 auto;
  width: 1.85rem;
  height: 1.85rem;
  padding: 0;
  border: 0;
  background: var(--accent);
  color: var(--paper);
}

.calc-container .add-tab-btn:hover {
  background: var(--accent-hover);
}

.calc-container .tab-content {
  width: 100%;
}

.calc-container .calc-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.15rem;
  width: 100%;
  align-items: start;
}

@container (min-width: 40rem) {
  .calc-container .calc-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.calc-container .card {
  min-width: 0;
  margin: 0;
  padding: 1.05rem 1.15rem 1.15rem;
  background: var(--code-bg);
  border: 1px solid var(--rule);
}

.prose .calc-container h1,
.prose .calc-container h2,
.prose .calc-container h3,
.calc-container h1,
.calc-container h2,
.calc-container h3 {
  font-family: var(--font-ui);
  font-weight: 700;
  font-style: normal;
  line-height: 1.3;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-wrap: pretty;
  color: inherit;
  max-width: none;
}

.prose .calc-container h1,
.calc-container h1 {
  margin: 0 0 0.85rem;
  font-size: 0.95rem;
}

.prose .calc-container .card h2,
.calc-container .card h2 {
  margin: 0 0 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--rule);
  font-size: 0.78rem;
}

.prose .calc-container .card h3,
.calc-container .card h3 {
  margin: 1rem 0 0.45rem;
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--muted);
}

.prose .calc-container table,
.calc-container table {
  display: table;
  width: 100%;
  max-width: none;
  margin: 0;
  border-collapse: collapse;
  table-layout: auto;
  font-size: 0.84rem;
  font-variant-numeric: tabular-nums;
}

.prose .calc-container th,
.prose .calc-container td,
.calc-container th,
.calc-container td {
  padding: 0.4rem 0.55rem 0.4rem 0;
  border: 0;
  background: transparent;
  text-align: left;
  vertical-align: middle;
}

.prose .calc-container th,
.calc-container th {
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.68rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.calc-container tr:nth-child(even) {
  background: color-mix(in oklab, var(--ink) 5%, transparent);
}

.calc-container td:last-child {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}

.calc-container input {
  max-width: 100%;
  min-height: 2.15rem;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--rule);
  border-radius: 0;
  background: var(--paper);
  color: inherit;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.2;
}

.calc-container input[type="number"] {
  width: 5.5rem;
  font-variant-numeric: tabular-nums;
}

.calc-container input[type="text"] {
  width: 100%;
  min-width: 8rem;
}

.calc-container input:focus {
  border-color: var(--accent);
  outline: none;
}

.calc-container .total-row {
  font-weight: 700;
  font-style: italic;
}

.calc-container .total-row td {
  border-top: 1px solid var(--rule);
  padding-top: 0.5rem;
}

.prose .calc-container .note,
.calc-container .note {
  margin: 1rem 0 0;
  font-size: 0.82rem;
  font-style: italic;
  color: var(--muted);
  max-width: none;
}

.giscus,
.giscus-frame {
  max-width: none;
  margin-top: 2.5rem;
}

@media (max-width: 52rem) {
  html {
    font-size: 16px;
  }

  .shell,
  .shell--wide {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    max-width: none;
    padding: 0 1.1rem 3rem;
  }

  .stage,
  .post,
  .prose {
    min-width: 0;
    max-width: 100%;
  }

  .rail,
  .rail--article {
    position: static;
    max-height: none;
    overflow: visible;
    padding: 1.1rem 0 0.85rem;
    gap: 0.75rem;
    border-bottom: 1px solid var(--rule);
  }

  .rail__brand {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: baseline;
    column-gap: 1rem;
    row-gap: 0.15rem;
    width: 100%;
  }

  .lede {
    grid-column: 1 / -1;
    width: auto;
    margin-top: 0.15rem;
  }

  .rail--article .lede {
    display: none;
  }

  .nav-toggle {
    display: inline-block;
    grid-column: 2;
    grid-row: 1;
    margin-top: 0;
    z-index: 1;
  }

  .brand {
    font-size: 0.7rem;
    letter-spacing: 0.03em;
  }

  .toc--site,
  .social,
  .switches {
    display: none;
  }

  html[data-nav-open="true"] .toc--site,
  html[data-nav-open="true"] .social {
    display: flex;
  }

  html[data-nav-open="true"] .switches {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
  }

  html[data-nav-open="true"] .toc--site ol {
    padding: 0.4rem 0 0.2rem;
  }

  .page-toc {
    flex: none;
    overflow-y: auto;
    max-height: 7.5rem;
    padding-top: 0.55rem;
    border-top: 1px solid var(--rule);
  }

  .page-toc a {
    font-size: 0.72rem;
  }

  .page-toc #TableOfContents ul {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.3rem 0.85rem;
  }

  .page-toc #TableOfContents ul ul {
    display: contents;
  }

  .stage {
    padding-top: 1.5rem;
  }

  .post__title {
    font-size: 1.55rem;
  }

  .calc-container input[type="number"] {
    width: 5.5rem;
  }

  .calc-container input[type="text"] {
    min-width: 0;
  }
}

@media (prefers-reduced-motion: no-preference) {
  @view-transition {
    navigation: auto;
  }
}

@media print {
  .rail,
  .switches,
  .nav-toggle,
  .giscus,
  .skip {
    display: none !important;
  }

  .shell,
  .shell--wide {
    display: block;
    padding: 0;
  }

  a {
    color: inherit;
  }
}
