:root {
  color-scheme: light;
  --paper: oklch(96% 0.018 84);
  --paper-deep: oklch(91% 0.03 83);
  --ink: oklch(25% 0.035 165);
  --ink-soft: oklch(43% 0.038 164);
  --green: oklch(42% 0.075 160);
  --green-deep: oklch(31% 0.06 159);
  --green-pale: oklch(91% 0.035 158);
  --red: oklch(53% 0.14 34);
  --gold: oklch(69% 0.115 78);
  --line: color-mix(in oklch, var(--ink) 18%, var(--paper));
  --line-strong: color-mix(in oklch, var(--ink) 34%, var(--paper));
  --serif: "Songti SC", "Noto Serif CJK SC", "STSong", serif;
  --sans: "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background-color: var(--paper);
  background-image:
    repeating-linear-gradient(0deg, transparent 0 31px, color-mix(in oklch, var(--green) 6%, transparent) 31px 32px),
    linear-gradient(90deg, color-mix(in oklch, var(--gold) 8%, transparent), transparent 14%, transparent 86%, color-mix(in oklch, var(--green) 5%, transparent));
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
}

button,
input,
textarea {
  font: inherit;
}

button,
a,
input,
textarea {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid color-mix(in oklch, var(--gold) 68%, transparent);
  outline-offset: 2px;
}

.masthead {
  background: var(--green-deep);
  color: var(--paper);
}

.masthead__rule {
  height: 7px;
  background: var(--red);
}

.masthead__inner,
main,
footer {
  width: min(1500px, calc(100% - clamp(28px, 6vw, 96px)));
  margin-inline: auto;
}

.masthead__inner {
  padding-block: clamp(34px, 7vw, 82px) clamp(38px, 6vw, 70px);
}

.masthead__eyebrow,
.section-kicker {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.masthead__eyebrow {
  color: color-mix(in oklch, var(--paper) 70%, var(--green));
}

.masthead__title-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-top: 18px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-family: var(--serif);
  font-size: clamp(3rem, 8vw, 7.5rem);
  font-weight: 800;
  letter-spacing: -0.075em;
  line-height: 0.88;
}

.masthead__title-row p {
  margin-bottom: 0;
  color: color-mix(in oklch, var(--paper) 79%, var(--green));
  font-size: clamp(0.95rem, 2vw, 1.12rem);
  letter-spacing: 0.08em;
}

.workshop-mark {
  display: grid;
  width: 84px;
  height: 84px;
  flex: 0 0 84px;
  place-items: center;
  border: 2px solid color-mix(in oklch, var(--red) 75%, var(--paper));
  color: color-mix(in oklch, var(--red) 65%, var(--paper));
  font-family: var(--serif);
  rotate: -5deg;
}

.workshop-mark span,
.workshop-mark strong {
  display: block;
  line-height: 1;
}

.workshop-mark span {
  align-self: end;
  font-size: 0.72rem;
  letter-spacing: 0.2em;
}

.workshop-mark strong {
  align-self: start;
  font-size: 1.75rem;
}

main {
  padding-block: clamp(30px, 5vw, 64px) 72px;
}

.ledger-summary {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) 1.8fr;
  align-items: end;
  gap: clamp(24px, 5vw, 72px);
  padding-bottom: 30px;
  border-bottom: 1px solid var(--line-strong);
}

.section-kicker {
  color: var(--red);
}

.ledger-summary__intro p {
  max-width: 36ch;
  margin: 8px 0 0;
  color: var(--ink-soft);
}

.ledger-stamps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 0;
  border-top: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
}

.ledger-stamps div {
  padding: 15px clamp(10px, 2vw, 22px) 14px;
  border-right: 1px solid var(--line);
}

.ledger-stamps div:last-child {
  border-right: 0;
}

.ledger-stamps dt {
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.08em;
}

.ledger-stamps dd {
  margin: 4px 0 0;
  font-family: var(--serif);
  font-size: clamp(1.4rem, 3vw, 2.2rem);
  font-weight: 800;
  line-height: 1.1;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 260px) 1fr auto;
  gap: 18px;
  align-items: end;
  padding-block: 26px;
}

.toolbar__search label {
  display: block;
  margin-bottom: 6px;
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.08em;
}

.toolbar__search input {
  width: 100%;
  height: 42px;
  border: 0;
  border-bottom: 2px solid var(--ink);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
}

.toolbar__search input::placeholder,
.note-input::placeholder {
  color: color-mix(in oklch, var(--ink-soft) 58%, var(--paper));
}

.toolbar__filters,
.toolbar__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.toolbar__actions {
  justify-content: flex-end;
}

.filter-button,
.button {
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: color-mix(in oklch, var(--paper) 88%, transparent);
  color: var(--ink);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 700;
  transition: background-color 150ms ease, color 150ms ease, transform 150ms ease;
}

.filter-button {
  padding-inline: 12px;
}

.button {
  padding-inline: 13px;
}

.filter-button:hover,
.button:hover {
  transform: translateY(-1px);
}

.filter-button[aria-pressed="true"] {
  border-color: var(--green-deep);
  background: var(--green-deep);
  color: var(--paper);
}

.button--ink {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
}

.button--quiet {
  border-color: transparent;
  background: transparent;
  color: var(--ink-soft);
}

.ledger-shell {
  background: color-mix(in oklch, var(--paper) 90%, var(--green-pale));
  border: 1px solid var(--line-strong);
  box-shadow: 8px 10px 0 color-mix(in oklch, var(--green) 13%, transparent);
}

.ledger-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 24px 20px;
  border-bottom: 1px solid var(--line-strong);
}

.ledger-heading h2,
.method-note h2,
.sources h2 {
  margin: 3px 0 0;
  font-family: var(--serif);
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 1;
}

.ledger-heading > p {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0;
  color: var(--ink-soft);
  font-size: 0.8rem;
}

.save-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
}

.table-wrap {
  overflow-x: auto;
}

.ledger-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.ledger-table th,
.ledger-table td {
  padding: 14px 12px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.ledger-table th:last-child,
.ledger-table td:last-child {
  border-right: 0;
}

.ledger-table tr:last-child td {
  border-bottom: 0;
}

.ledger-table th {
  position: sticky;
  z-index: 2;
  top: 0;
  background: var(--green-deep);
  color: var(--paper);
  font-size: 0.73rem;
  font-weight: 750;
  letter-spacing: 0.06em;
}

.ledger-table th:nth-child(1) { width: 9%; }
.ledger-table th:nth-child(2) { width: 14%; }
.ledger-table th:nth-child(3) { width: 8%; }
.ledger-table th:nth-child(4) { width: 7%; }
.ledger-table th:nth-child(5) { width: 9%; }
.ledger-table th:nth-child(6) { width: 15%; }
.ledger-table th:nth-child(7) { width: 12%; }
.ledger-table th:nth-child(8) { width: 26%; }

.ledger-row:hover td {
  background: color-mix(in oklch, var(--green-pale) 52%, var(--paper));
}

.category-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 750;
}

.category-label::before {
  width: 8px;
  height: 8px;
  border: 1px solid currentColor;
  content: "";
  rotate: 45deg;
}

.material-name {
  font-family: var(--serif);
  font-size: 1rem;
  font-weight: 800;
}

.research-badge {
  display: inline-block;
  margin-top: 5px;
  padding: 1px 5px;
  background: color-mix(in oklch, var(--gold) 24%, var(--paper));
  color: color-mix(in oklch, var(--red) 76%, var(--ink));
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.level-mark {
  display: inline-flex;
  flex-direction: column;
  line-height: 1.15;
  white-space: nowrap;
}

.level-mark span {
  color: var(--ink-soft);
  font-size: 0.65rem;
  font-weight: 750;
  letter-spacing: 0.08em;
}

.level-mark strong {
  margin-top: 3px;
  color: var(--red);
  font-family: var(--serif);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

.amount {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.stack-editor {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.stack-input {
  width: 64px;
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 750;
}

.stack-editor span,
.packing-secondary {
  color: var(--ink-soft);
  font-size: 0.74rem;
}

.packing-primary {
  display: block;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.packing-secondary {
  display: block;
  margin-top: 3px;
}

.note-input {
  display: block;
  width: 100%;
  min-height: 42px;
  max-height: 150px;
  resize: vertical;
  border: 0;
  border-bottom: 1px dashed var(--line-strong);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  line-height: 1.45;
}

.note-input:focus {
  border-bottom-style: solid;
  border-bottom-color: var(--red);
  background: color-mix(in oklch, var(--paper) 80%, transparent);
}

.empty-state {
  padding: 72px 24px;
  text-align: center;
}

.empty-state strong,
.empty-state span {
  display: block;
}

.empty-state strong {
  font-family: var(--serif);
  font-size: 1.4rem;
}

.empty-state span {
  margin-top: 6px;
  color: var(--ink-soft);
}

.method-note,
.sources {
  display: grid;
  grid-template-columns: minmax(180px, 0.52fr) 1.7fr;
  gap: clamp(26px, 6vw, 92px);
  margin-top: clamp(54px, 8vw, 96px);
  padding-top: 24px;
  border-top: 1px solid var(--line-strong);
}

.method-note__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line-strong);
}

.method-note__grid p {
  margin: 0;
  padding: 16px 14px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.method-note__grid p:nth-child(3n) {
  border-right: 0;
}

.method-note__grid strong,
.method-note__grid span {
  display: block;
}

.method-note__grid strong {
  font-family: var(--serif);
  font-size: 1rem;
}

.method-note__grid span {
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 0.78rem;
}

.method-note__fineprint {
  grid-column: 2;
  margin: 16px 0 0;
  color: var(--ink-soft);
  font-size: 0.78rem;
}

.sources {
  margin-top: 54px;
}

.sources__links {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--line-strong);
}

.sources__links a {
  padding: 18px 14px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-family: var(--serif);
  font-weight: 800;
  text-decoration: none;
}

.sources__links a:last-child {
  border-right: 0;
}

.sources__links a::after {
  float: right;
  color: var(--red);
  content: "↗";
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding-block: 24px 38px;
  border-top: 1px solid var(--line-strong);
  color: var(--ink-soft);
  font-size: 0.76rem;
}

footer p {
  margin-bottom: 0;
}

.toast {
  position: fixed;
  z-index: 10;
  right: 22px;
  bottom: 22px;
  max-width: min(340px, calc(100vw - 44px));
  padding: 11px 14px;
  border-left: 4px solid var(--red);
  background: var(--ink);
  color: var(--paper);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1120px) {
  .toolbar {
    grid-template-columns: 240px 1fr;
  }

  .toolbar__actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .ledger-table {
    min-width: 1080px;
  }
}

@media (max-width: 760px) {
  body {
    background-image: repeating-linear-gradient(0deg, transparent 0 31px, color-mix(in oklch, var(--green) 6%, transparent) 31px 32px);
  }

  .masthead__inner,
  main,
  footer {
    width: min(100% - 28px, 1500px);
  }

  .masthead__inner {
    padding-block: 34px 38px;
  }

  h1 {
    font-size: clamp(3.2rem, 18vw, 5.6rem);
  }

  .workshop-mark {
    width: 66px;
    height: 66px;
    flex-basis: 66px;
  }

  .workshop-mark strong {
    font-size: 1.35rem;
  }

  .ledger-summary,
  .method-note,
  .sources {
    grid-template-columns: 1fr;
  }

  .ledger-stamps {
    grid-column: 1;
  }

  .ledger-stamps div {
    padding-inline: 8px;
  }

  .toolbar {
    grid-template-columns: 1fr;
  }

  .toolbar__actions {
    grid-column: auto;
  }

  .ledger-shell {
    box-shadow: 5px 6px 0 color-mix(in oklch, var(--green) 13%, transparent);
  }

  .ledger-heading {
    display: block;
    padding: 20px 16px;
  }

  .ledger-heading > p {
    margin-top: 14px;
  }

  .table-wrap {
    overflow: visible;
  }

  .ledger-table,
  .ledger-table tbody,
  .ledger-table tr,
  .ledger-table td {
    display: block;
    width: 100%;
  }

  .ledger-table {
    min-width: 0;
  }

  .ledger-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .ledger-table tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-bottom: 1px solid var(--line-strong);
  }

  .ledger-table tr:last-child {
    border-bottom: 0;
  }

  .ledger-table td {
    min-height: 60px;
    padding: 12px 14px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
  }

  .ledger-table td:nth-child(even) {
    border-right: 0;
  }

  .ledger-table td::before {
    display: block;
    margin-bottom: 4px;
    color: var(--ink-soft);
    content: attr(data-label);
    font-size: 0.66rem;
    font-weight: 750;
    letter-spacing: 0.08em;
  }

  .ledger-table td:nth-child(7),
  .ledger-table td:nth-child(8) {
    grid-column: 1 / -1;
    border-right: 0;
  }

  .ledger-table td:nth-child(8) {
    border-bottom: 0;
  }

  .note-input {
    min-height: 48px;
  }

  .method-note__grid,
  .sources__links {
    grid-template-columns: 1fr;
  }

  .method-note__grid p,
  .method-note__grid p:nth-child(3n),
  .sources__links a {
    border-right: 0;
  }

  .method-note__fineprint {
    grid-column: 1;
  }

  footer {
    display: block;
  }

  footer span {
    display: block;
    margin-top: 8px;
  }
}

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