:root {
  --bg: #F3F6F9;
  --surface: #FFFFFF;
  --surface-subtle: #E6ECF2;
  --surface-tint: #EBF2FC;
  --ink: #0F1C2E;
  --muted: #46586B;
  --line: #CFD9E3;
  --accent: #0052CC;
  --accent-hover: #003E9C;
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  --text-heading: 1.375rem;
  --text-body: 1rem;
  --text-sm: 0.875rem;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: 1.7;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color 180ms var(--ease-out), border-color 180ms var(--ease-out), background-color 180ms var(--ease-out);
}

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

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.skip {
  position: absolute;
  top: -120px;
  left: 16px;
  z-index: 100;
  padding: 10px 16px;
  background-color: var(--ink);
  color: var(--surface);
  font-size: var(--text-sm);
  border-radius: 6px;
}

.skip:focus {
  top: 12px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background-color: rgba(243, 246, 249, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.header-inner,
.page-shell,
.footer-inner {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding-left: 36px;
  padding-right: 36px;
}

.header-inner {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
  white-space: nowrap;
}

.brand:hover {
  color: var(--ink);
}

.brand-sub {
  font-size: var(--text-sm);
  font-weight: 400;
  letter-spacing: 0;
  color: var(--muted);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 28px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--muted);
}

.site-nav a {
  position: relative;
  padding: 8px 0;
  white-space: nowrap;
}

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

.site-nav a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background-color: var(--accent);
}

.page-shell {
  flex: 1;
  padding-top: 52px;
  padding-bottom: 72px;
}

/* Minimalist Breathing Homepage */
.home-shell {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-top: 48px;
  padding-bottom: 56px;
}

.home-canvas {
  width: 100%;
  min-height: min(520px, 64dvh);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 56px;
  padding: 28px 0 12px;
}

.home-identity h1 {
  margin: 0 0 14px;
  font-size: clamp(2.75rem, 5.2vw, 4.25rem);
  line-height: 1.08;
  letter-spacing: -0.035em;
  font-weight: 700;
  color: var(--ink);
}

.home-role {
  margin: 0 0 10px;
  font-size: var(--text-heading);
  line-height: 1.35;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.home-bio {
  margin: 0;
  max-width: 46ch;
  font-size: var(--text-body);
  color: var(--muted);
}

.home-arc {
  width: 100%;
  display: flex;
  justify-content: flex-end;
  padding-top: 12px;
}

.home-arc svg {
  width: min(560px, 100%);
  height: auto;
  display: block;
}

/* Page Headings */

.page-head {
  padding-bottom: 32px;
}

.page-head p {
  margin: 0;
  max-width: 60ch;
  font-size: var(--text-body);
  color: var(--muted);
}

.page-head h1 {
  margin: 0 0 12px;
  font-size: clamp(2rem, 3.6vw, 2.85rem);
  line-height: 1.12;
  letter-spacing: -0.03em;
  font-weight: 700;
}

/* Homepage Notes Editorial Section (Top Priority Block) */
.notes-home-section {
  padding-top: 40px;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(0, 1.85fr);
  gap: 48px;
  align-items: start;
}

.notes-intro p {
  margin: 12px 0 24px;
  color: var(--muted);
  max-width: 36ch;
}

/* Workbench Section */
.workbench-section {
  margin-top: 56px;
  padding-top: 44px;
  border-top: 1px solid var(--line);
}

.workbench-section.is-standalone {
  margin-top: 0;
  padding-top: 8px;
  border-top: none;
}

.section-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.section-bar h2,
.notes-intro h2,
.qr-sheet h2 {
  margin: 0;
  font-size: var(--text-heading);
  line-height: 1.35;
  letter-spacing: -0.02em;
  font-weight: 650;
}

.inline-link {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--accent);
  white-space: nowrap;
}

.inline-link:hover {
  color: var(--accent-hover);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.workbench-sheet {
  background-color: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

/* Connected Segmented Control (Presets & Note Categories) */
.preset-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 20px;
  padding: 16px 28px;
  background-color: var(--surface-subtle);
  border-bottom: 1px solid var(--line);
}

.preset-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--muted);
}

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  padding: 3px;
  background-color: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  gap: 2px;
}

.segmented label {
  position: relative;
  cursor: pointer;
  margin: 0;
}

.segmented input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: block;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--muted);
  transition: background-color 160ms var(--ease-out), color 160ms var(--ease-out);
  user-select: none;
}

.segmented input[type="radio"]:checked + span {
  background-color: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(15, 28, 46, 0.08);
}

.segmented input[type="radio"]:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Calculator Form */
.calc-form {
  padding: 28px;
  border-bottom: 1px solid var(--line);
}

.input-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink);
}

.field input,
.search-field input,
.output-box textarea {
  width: 100%;
  font-family: inherit;
  font-size: var(--text-body);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background-color: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  transition: border-color 160ms var(--ease-out), background-color 160ms var(--ease-out);
}

.field input:hover,
.search-field input:hover {
  border-color: #9FB0C2;
}

.field input:focus,
.search-field input:focus,
.output-box textarea:focus {
  background-color: var(--surface);
  border-color: var(--accent);
}

.form-actions {
  margin-top: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.confirm-check {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: var(--text-sm);
  color: var(--muted);
  cursor: pointer;
}

.confirm-check input[type="checkbox"] {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 22px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background-color: var(--accent);
  color: var(--surface);
  font-family: inherit;
  font-size: var(--text-body);
  font-weight: 600;
  cursor: pointer;
  transition: background-color 160ms var(--ease-out), border-color 160ms var(--ease-out), transform 160ms var(--ease-out);
}

.primary-btn:hover {
  background-color: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--surface);
}

.primary-btn:active {
  transform: translateY(1px);
}

/* Status & Weight Proportion Meter */
.meter-zone {
  padding: 22px 28px;
  border-bottom: 1px solid var(--line);
  background-color: var(--surface);
}

.status-line {
  margin: 0;
  font-size: var(--text-body);
  font-weight: 600;
  color: var(--ink);
}

.status-line.is-muted {
  font-weight: 400;
  color: var(--muted);
}

.status-line.is-error {
  color: #B42318;
}

.weight-meter {
  margin-top: 14px;
}

.meter-track {
  height: 10px;
  width: 100%;
  background-color: var(--surface-subtle);
  border-radius: 999px;
  overflow: hidden;
  display: flex;
}

.meter-gross {
  height: 100%;
  background-color: var(--ink);
  transition: width 220ms var(--ease-out);
}

.meter-bubble {
  height: 100%;
  background-color: var(--accent);
  transition: width 220ms var(--ease-out);
}

.meter-legend {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  font-size: var(--text-sm);
  color: var(--muted);
}

.legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.legend-dot.gross {
  background-color: var(--ink);
}

.legend-dot.bubble {
  background-color: var(--accent);
}

/* Results Table */
.table-zone {
  overflow-x: auto;
}

.results-table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
}

.results-table th,
.results-table td {
  padding: 14px 28px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}

.results-table th {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--muted);
  background-color: var(--surface-subtle);
}

.results-table td {
  font-size: var(--text-body);
  color: var(--ink);
}

.results-table th.num,
.results-table td.num {
  text-align: right;
}

.results-table tbody tr:hover {
  background-color: var(--surface-tint);
}

.results-table td.strong-val {
  font-weight: 650;
  color: var(--accent);
}

.empty-row td {
  color: var(--muted);
  text-align: center;
  padding: 28px;
}

/* Copyable Output Box */
.output-zone {
  padding: 22px 28px 28px;
  background-color: var(--surface);
}

.output-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.output-head label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink);
}

.text-action {
  padding: 4px 10px;
  border: none;
  background: transparent;
  color: var(--accent);
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  border-radius: 6px;
  transition: background-color 160ms var(--ease-out), color 160ms var(--ease-out);
}

.text-action:hover:not(:disabled) {
  background-color: var(--surface-tint);
  color: var(--accent-hover);
}

.text-action:disabled {
  color: var(--muted);
  opacity: 0.5;
  cursor: default;
}

.output-box textarea {
  resize: vertical;
  min-height: 156px;
  line-height: 1.6;
}

.formula-note {
  margin: 12px 0 0;
  font-size: var(--text-sm);
  color: var(--muted);
  max-width: 72ch;
}

/* Notes Archive Page Controls & Entries */
.notes-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 20px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.search-field {
  flex: 1 1 240px;
  max-width: 320px;
}

.search-field input {
  background-color: var(--surface);
  padding: 8px 12px;
}

.notes-ledger {
  border-top: 1px solid var(--line);
}

.notes-toolbar + .notes-ledger {
  border-top: none;
}

.note-row {
  display: block;
  padding: 24px 0;
  border-bottom: 1px solid var(--line);
}

.note-row-meta {
  font-size: var(--text-sm);
  color: var(--muted);
  margin: 0 0 6px;
}

.note-row h3 {
  margin: 0 0 8px;
  font-size: var(--text-heading);
  font-weight: 650;
  line-height: 1.35;
  letter-spacing: -0.015em;
  color: var(--ink);
  transition: color 160ms var(--ease-out);
}

.note-row:hover h3 {
  color: var(--accent);
}

.note-row p {
  margin: 0;
  color: var(--muted);
  max-width: 64ch;
}

.ledger-empty {
  padding: 36px 28px;
  background-color: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.ledger-empty h3 {
  margin: 0 0 8px;
  font-size: var(--text-body);
  font-weight: 650;
  color: var(--ink);
}

.ledger-empty p {
  margin: 0;
  color: var(--muted);
  max-width: 58ch;
}

.ledger-tracks {
  margin: 20px 0 0;
  padding: 16px 0 0;
  list-style: none;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.ledger-tracks li strong {
  display: block;
  font-size: var(--text-body);
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 4px;
}

.ledger-tracks li span {
  display: block;
  font-size: var(--text-sm);
  color: var(--muted);
}

/* Single Note Reader View */
.note-reader {
  padding-top: 8px;
}

.reader-back {
  display: inline-block;
  margin-bottom: 20px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--accent);
}

.reader-meta {
  margin: 0 0 10px;
  font-size: var(--text-sm);
  color: var(--muted);
}

.note-reader h1 {
  margin: 0 0 20px;
  font-size: clamp(1.85rem, 3.4vw, 2.6rem);
  line-height: 1.18;
  letter-spacing: -0.025em;
}

.reader-body {
  padding-top: 24px;
  border-top: 1px solid var(--line);
  max-width: 65ch;
}

.reader-body p,
.reader-body ul,
.reader-body ol {
  margin: 0 0 18px;
  font-size: var(--text-body);
  color: var(--ink);
}

.reader-body h2 {
  margin: 32px 0 12px;
  font-size: var(--text-heading);
}

/* Contact / QR Pages */
.contact-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  margin-top: 8px;
}

.qr-sheet {
  background-color: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 32px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.qr-sheet p {
  margin: 8px 0 20px;
  color: var(--muted);
}

.qr-frame {
  width: 100%;
  max-width: 280px;
  height: 296px;
  padding: 16px;
  background-color: var(--bg);
  border-radius: 8px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-frame img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 4px;
}

.qr-sheet .inline-link {
  margin-top: auto;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--line);
  background-color: var(--bg);
}

.footer-inner {
  min-height: 76px;
  padding-top: 20px;
  padding-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 24px;
  font-size: var(--text-sm);
  color: var(--muted);
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 22px;
}

/* Responsive */
@media (max-width: 820px) {
  .home-canvas {
    min-height: 380px;
    gap: 44px;
  }

  .input-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .notes-home-section {
    grid-template-columns: 1fr;
    gap: 28px;
    padding-top: 32px;
  }

  .workbench-section {
    margin-top: 44px;
    padding-top: 36px;
  }

  .ledger-tracks,
  .contact-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .header-inner,
  .page-shell,
  .footer-inner {
    padding-left: 20px;
    padding-right: 20px;
  }

  .header-inner {
    min-height: 64px;
    gap: 12px;
  }

  .brand-sub {
    display: none;
  }

  .site-nav {
    gap: 18px;
  }

  .page-shell {
    padding-top: 32px;
    padding-bottom: 52px;
  }

  .preset-bar,
  .calc-form,
  .meter-zone,
  .output-zone {
    padding-left: 18px;
    padding-right: 18px;
  }

  .segmented {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .segmented span {
    text-align: center;
    padding: 8px 10px;
  }

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

  .results-table th,
  .results-table td {
    padding: 12px 16px;
  }

  .search-field {
    max-width: none;
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
