:root {
  --bg: #f8fbf9;
  --surface: #ffffff;
  --surface-2: #f0f6f2;
  --surface-3: #e6f1ea;
  --text: #14221a;
  --muted: #59675e;
  --subtle: #738078;
  --border: #dbe5de;
  --border-strong: #bdcdc2;
  --accent: #147552;
  --accent-hover: #0d5d40;
  --accent-soft: #dcf2e6;
  --accent-ink: #0c5138;
  --gold: #8a6412;
  --gold-bg: #faf0cf;
  --silver: #59646b;
  --silver-bg: #e9eef0;
  --bronze: #895638;
  --bronze-bg: #f5e6dc;
  --danger: #a43b3b;
  --danger-soft: #fae8e8;
  --warning: #8a5a12;
  --warning-soft: #fff1d5;
  --shadow: 0 18px 50px rgba(28, 65, 43, 0.08);
  --radius: 14px;
  --radius-small: 9px;
  --header-height: 68px;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

html[data-theme="dark"] {
  --bg: #0d1310;
  --surface: #131b17;
  --surface-2: #17231c;
  --surface-3: #1d2e24;
  --text: #edf7f0;
  --muted: #afbeb4;
  --subtle: #8fa096;
  --border: #293b30;
  --border-strong: #41584a;
  --accent: #69d4a1;
  --accent-hover: #8be5bb;
  --accent-soft: #153b2b;
  --accent-ink: #9ae8c2;
  --gold: #f1cf77;
  --gold-bg: #463b1d;
  --silver: #d3dee3;
  --silver-bg: #303a3f;
  --bronze: #e6b18d;
  --bronze-bg: #493126;
  --danger: #ff9c9c;
  --danger-soft: #422323;
  --warning: #ffd287;
  --warning-soft: #45351c;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.3);
}

@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] {
    --bg: #0d1310;
    --surface: #131b17;
    --surface-2: #17231c;
    --surface-3: #1d2e24;
    --text: #edf7f0;
    --muted: #afbeb4;
    --subtle: #8fa096;
    --border: #293b30;
    --border-strong: #41584a;
    --accent: #69d4a1;
    --accent-hover: #8be5bb;
    --accent-soft: #153b2b;
    --accent-ink: #9ae8c2;
    --gold: #f1cf77;
    --gold-bg: #463b1d;
    --silver: #d3dee3;
    --silver-bg: #303a3f;
    --bronze: #e6b18d;
    --bronze-bg: #493126;
    --danger: #ff9c9c;
    --danger-soft: #422323;
    --warning: #ffd287;
    --warning-soft: #45351c;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.3);
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 24px);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
}

button,
input,
select,
textarea {
  color: inherit;
  font: inherit;
}

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

a {
  color: var(--accent);
  text-underline-offset: 3px;
}

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

button {
  cursor: pointer;
}

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

h1,
h2,
h3 {
  letter-spacing: -0.035em;
  line-height: 1.16;
}

h1 {
  max-width: none;
  margin-bottom: 24px;
  font-size: clamp(2.7rem, 5vw, 4.35rem);
  font-weight: 650;
}

.hero-line {
  display: block;
  white-space: nowrap;
}

h2 {
  margin-bottom: 14px;
  font-size: clamp(2rem, 4vw, 3.25rem);
  font-weight: 630;
}

h3 {
  margin-bottom: 8px;
  font-size: 1.15rem;
  font-weight: 620;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  transform: translateY(-180%);
  border-radius: var(--radius-small);
  background: var(--text);
  color: var(--bg);
  padding: 10px 14px;
}

.skip-link:focus {
  transform: translateY(0);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--header-height);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

.nav-shell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1320px;
  height: 100%;
  margin: 0 auto;
  padding: 0 28px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--text);
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}

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

.brand-mark {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 10px;
  background: var(--accent);
  color: var(--bg);
  font-family: var(--font-mono);
  font-weight: 700;
}

.primary-nav {
  display: flex;
  align-items: center;
  gap: 24px;
}

.primary-nav a,
.theme-button,
.menu-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 560;
  text-decoration: none;
  white-space: nowrap;
}

.primary-nav a:hover,
.theme-button:hover,
.menu-button:hover {
  color: var(--text);
}

.theme-button,
.menu-button {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 12px;
}

.menu-button {
  display: none;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(340px, 0.65fr);
  gap: clamp(48px, 8vw, 110px);
  align-items: center;
  max-width: 1320px;
  min-height: calc(100dvh - var(--header-height));
  margin: 0 auto;
  padding: 68px 28px 72px;
}

.hero-copy {
  position: relative;
}

.hero-copy::before {
  position: absolute;
  top: -70px;
  left: -160px;
  width: 430px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 17%, transparent), transparent 68%);
  content: "";
  pointer-events: none;
}

.eyebrow {
  position: relative;
  margin-bottom: 18px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.hero-lede {
  position: relative;
  max-width: 40ch;
  margin-bottom: 30px;
  color: var(--muted);
  font-size: clamp(1.05rem, 1.6vw, 1.25rem);
  line-height: 1.6;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 0.94rem;
  font-weight: 630;
  line-height: 1;
  text-decoration: none;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
  white-space: nowrap;
}

.button:active,
.text-button:active,
.theme-button:active,
.menu-button:active {
  transform: translateY(1px);
}

.button-primary {
  background: var(--text);
  color: var(--bg);
}

.button-primary:hover {
  background: var(--accent);
  color: #ffffff;
}

.button-secondary {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--text);
}

.button-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.hero-data {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 93%, transparent);
  box-shadow: var(--shadow);
}

.hero-data-main {
  display: flex;
  min-height: 280px;
  flex-direction: column;
  justify-content: flex-end;
  padding: 32px;
  background:
    linear-gradient(145deg, transparent 15%, color-mix(in srgb, var(--accent) 8%, transparent)),
    var(--surface);
}

.hero-data-main strong {
  margin: 10px 0 5px;
  font-family: var(--font-mono);
  font-size: clamp(4rem, 9vw, 7rem);
  font-weight: 520;
  letter-spacing: -0.08em;
  line-height: 0.92;
}

.hero-data-main span:last-child,
.metric-label {
  color: var(--muted);
}

.metric-label {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  letter-spacing: 0.08em;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--border);
}

.metric-grid div {
  display: flex;
  min-height: 90px;
  flex-direction: column;
  justify-content: center;
  padding: 18px 24px;
}

.metric-grid div:nth-child(odd) {
  border-right: 1px solid var(--border);
}

.metric-grid div:nth-child(-n + 2) {
  border-bottom: 1px solid var(--border);
}

.metric-grid strong {
  font-family: var(--font-mono);
  font-size: 1.18rem;
}

.metric-grid span {
  color: var(--muted);
  font-size: 0.78rem;
}

.notice-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-block: 1px solid var(--border);
  background: var(--warning-soft);
  padding: 18px max(28px, calc((100vw - 1264px) / 2));
}

.notice-strip div {
  display: flex;
  align-items: baseline;
  gap: 18px;
}

.notice-strip strong {
  flex: none;
  color: var(--warning);
}

.notice-strip p {
  margin: 0;
  color: var(--muted);
}

.notice-strip a {
  flex: none;
  color: var(--text);
  font-weight: 620;
}

.section-shell {
  max-width: 1320px;
  margin: 0 auto;
  padding: 104px 28px;
}

.section-heading {
  max-width: 760px;
  margin-bottom: 44px;
}

.section-heading p {
  max-width: 58ch;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.overview-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 24px;
}

.year-chart-panel {
  min-height: 470px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 28px;
}

.panel-heading,
.subsection-heading,
.notes-toolbar,
.results-toolbar,
.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.panel-heading h3,
.subsection-heading h3,
.notes-toolbar h3 {
  margin: 0;
}

.panel-heading span,
.subsection-heading span,
.notes-toolbar span {
  color: var(--subtle);
  font-size: 0.82rem;
}

.year-chart {
  display: flex;
  min-height: 350px;
  align-items: end;
  justify-content: space-around;
  gap: 14px;
  padding: 48px 10px 0;
}

.year-bar-group {
  display: grid;
  width: min(88px, 17%);
  height: 300px;
  grid-template-rows: 24px 1fr 30px;
  gap: 8px;
  text-align: center;
}

.year-bar-value,
.year-bar-label {
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.year-bar-track {
  display: flex;
  align-items: flex-end;
  border-radius: var(--radius-small);
  background: var(--surface-2);
  padding: 5px;
}

.year-bar {
  width: 100%;
  min-height: 4px;
  border-radius: 6px;
  background: var(--accent);
  transform-origin: bottom;
  animation: grow-bar 700ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.year-bar-group.is-sample .year-bar {
  background: repeating-linear-gradient(45deg, var(--accent), var(--accent) 6px, var(--surface-3) 6px, var(--surface-3) 12px);
}

.insight-stack {
  display: grid;
  gap: 12px;
}

.insight-stack article {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 18px;
  align-items: start;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 24px;
}

.insight-number {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.84rem;
}

.insight-stack p,
.method-grid p {
  margin-bottom: 0;
  color: var(--muted);
}

.works-section {
  max-width: none;
  border-block: 1px solid var(--border);
  background: var(--surface-2);
  padding-inline: max(28px, calc((100vw - 1264px) / 2));
}

.filters {
  display: grid;
  grid-template-columns: minmax(240px, 2fr) repeat(5, minmax(135px, 1fr)) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 24px;
}

.field {
  display: grid;
  gap: 7px;
}

.field label,
.spec-checker label,
.spec-checker legend {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 590;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-small);
  outline: none;
  background: var(--surface);
}

input,
select {
  min-height: 44px;
  padding: 9px 11px;
}

textarea {
  min-height: 140px;
  resize: vertical;
  padding: 12px;
}

input::placeholder,
textarea::placeholder {
  color: var(--subtle);
  opacity: 1;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 34%, transparent);
  outline-offset: 2px;
  border-color: var(--accent);
}

.reset-button {
  min-width: 108px;
}

.results-toolbar {
  margin-bottom: 14px;
}

.results-toolbar p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.mobile-table-hint {
  display: none;
  margin: -4px 0 12px;
  color: var(--subtle);
  font-size: 0.78rem;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--accent);
  padding: 4px 0;
  font-size: 0.88rem;
  font-weight: 620;
  text-decoration: underline;
  text-underline-offset: 3px;
}

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

.danger-text {
  color: var(--danger);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

table {
  width: 100%;
  min-width: 930px;
  border-collapse: collapse;
}

th,
td {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  background: color-mix(in srgb, var(--surface-2) 70%, var(--surface));
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
  white-space: nowrap;
}

td {
  font-size: 0.9rem;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: color-mix(in srgb, var(--accent-soft) 40%, transparent);
}

.work-title-button {
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
  font-weight: 650;
  text-align: left;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
  text-underline-offset: 4px;
}

.work-title-button:hover {
  color: var(--accent);
}

.work-code,
.source-badge,
.coverage-label {
  display: block;
  margin-top: 4px;
  color: var(--subtle);
  font-family: var(--font-mono);
  font-size: 0.7rem;
}

.award-badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.75rem;
  font-weight: 660;
  white-space: nowrap;
}

.award-gold {
  background: var(--gold-bg);
  color: var(--gold);
}

.award-silver {
  background: var(--silver-bg);
  color: var(--silver);
}

.award-bronze {
  background: var(--bronze-bg);
  color: var(--bronze);
}

.school-list {
  max-width: 36ch;
  color: var(--muted);
  font-size: 0.82rem;
}

.source-link {
  white-space: nowrap;
}

.loading-row td {
  height: 240px;
  color: var(--muted);
  text-align: center;
  vertical-align: middle;
}

.empty-state {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 44px 22px;
  text-align: center;
}

.empty-state h3 {
  margin-bottom: 5px;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
}

#works-empty {
  margin-top: 16px;
  background: var(--surface);
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
  margin-top: 24px;
}

.page-button {
  min-width: 40px;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
}

.page-button[aria-current="page"] {
  border-color: var(--text);
  background: var(--text);
  color: var(--bg);
}

.page-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.limits-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.6fr);
  gap: 34px;
  align-items: start;
}

.subsection-heading {
  margin-bottom: 18px;
}

.rules-list {
  display: grid;
  gap: 10px;
}

.rule-item {
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
}

.rule-item summary {
  display: grid;
  grid-template-columns: minmax(160px, 0.42fr) 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 18px 20px;
  cursor: pointer;
  list-style: none;
}

.rule-item summary::-webkit-details-marker {
  display: none;
}

.rule-item summary::after {
  color: var(--accent);
  content: "+";
  font-family: var(--font-mono);
  font-size: 1.2rem;
}

.rule-item[open] summary::after {
  content: "−";
}

.rule-item summary strong {
  letter-spacing: -0.02em;
}

.rule-item summary span {
  color: var(--muted);
  font-size: 0.9rem;
}

.rule-check {
  margin: 0 20px 18px;
  border-radius: var(--radius-small);
  background: var(--accent-soft);
  color: var(--accent-ink);
  padding: 13px 15px;
  font-size: 0.88rem;
}

.spec-checker {
  position: sticky;
  top: calc(var(--header-height) + 24px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 26px;
}

.spec-checker > p {
  color: var(--muted);
  font-size: 0.88rem;
}

.spec-checker form {
  display: grid;
  gap: 15px;
}

.spec-checker fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}

.dimension-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 7px;
}

.dimension-grid label,
.spec-checker > form > label:not(.check-row) {
  display: grid;
  gap: 7px;
}

.check-row {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 10px;
  align-items: start;
  color: var(--text) !important;
  line-height: 1.45;
}

.check-row input {
  width: 18px;
  min-height: auto;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--accent);
}

.checker-result {
  margin-top: 18px;
  border-radius: var(--radius-small);
  padding: 16px;
}

.checker-result.pass {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.checker-result.fail {
  background: var(--danger-soft);
  color: var(--danger);
}

.checker-result strong,
.checker-result span {
  display: block;
}

.checker-result ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.guidance-section,
.prototype-section {
  margin-top: 72px;
}

.guidance-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.guidance-card {
  border-top: 1px solid var(--border-strong);
  padding: 20px 0 12px;
}

.guidance-card span {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.7rem;
}

.guidance-card p {
  margin: 0;
  color: var(--muted);
}

.prototype-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.prototype-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 26px;
}

.prototype-card:nth-child(2),
.prototype-card:nth-child(3) {
  background: var(--surface-2);
}

.prototype-card .prototype-level {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.76rem;
}

.prototype-card dl {
  display: grid;
  gap: 13px;
  margin: 18px 0 0;
}

.prototype-card dt {
  color: var(--subtle);
  font-size: 0.74rem;
}

.prototype-card dd {
  margin: 2px 0 0;
  color: var(--muted);
}

.discussion-section {
  max-width: none;
  border-block: 1px solid var(--border);
  background: var(--surface-2);
  padding-inline: max(28px, calc((100vw - 1264px) / 2));
}

.discussion-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.65fr) minmax(0, 1.35fr);
  gap: 24px;
  align-items: start;
}

.note-form,
.notes-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 24px;
}

.note-form {
  display: grid;
  gap: 18px;
}

.note-form .button {
  justify-self: start;
}

.notes-toolbar {
  align-items: start;
  margin-bottom: 18px;
}

.notes-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.notes-list {
  display: grid;
  gap: 10px;
}

.note-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--bg);
  padding: 16px;
}

.note-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

.note-topic {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.73rem;
}

.note-card time {
  color: var(--subtle);
  font-size: 0.75rem;
}

.note-card p {
  margin: 0;
  white-space: pre-wrap;
}

.note-card button {
  border: 0;
  background: transparent;
  color: var(--danger);
  padding: 2px;
  font-size: 0.78rem;
}

.notes-empty {
  padding-block: 60px;
}

.method-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 1fr;
  gap: 20px;
  margin-bottom: 48px;
}

.method-grid article {
  border-top: 1px solid var(--border-strong);
  padding-top: 20px;
}

.sources-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 28px;
}

.source-item {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
}

.source-number {
  color: var(--subtle);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.source-item a {
  font-weight: 600;
}

.source-item span:last-child {
  display: block;
  color: var(--subtle);
  font-size: 0.78rem;
}

.record-dialog {
  width: min(680px, calc(100% - 28px));
  max-height: min(780px, calc(100dvh - 28px));
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  padding: 0;
}

.record-dialog::backdrop {
  background: rgba(5, 15, 9, 0.58);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.dialog-header {
  position: sticky;
  top: 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  padding: 22px 24px;
}

.dialog-header h2 {
  margin: 4px 0 0;
  font-size: 1.65rem;
}

.dialog-header span {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.dialog-header button {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  padding: 7px 11px;
}

.dialog-body {
  padding: 24px;
}

.record-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.record-grid div {
  border-radius: var(--radius-small);
  background: var(--surface-2);
  padding: 14px;
}

.record-grid dt {
  color: var(--subtle);
  font-size: 0.75rem;
}

.record-grid dd {
  margin: 3px 0 0;
  font-weight: 580;
}

.dialog-source-note {
  border-left: 3px solid var(--accent);
  color: var(--muted);
  padding-left: 14px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 60;
  max-width: min(380px, calc(100vw - 44px));
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow);
  padding: 11px 18px;
  font-size: 0.88rem;
}

footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  max-width: 1320px;
  margin: 0 auto;
  border-top: 1px solid var(--border);
  padding: 38px 28px 48px;
}

footer p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

@keyframes grow-bar {
  from {
    transform: scaleY(0.05);
    opacity: 0.4;
  }
  to {
    transform: scaleY(1);
    opacity: 1;
  }
}

@media (max-width: 1160px) {
  .filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .field-search {
    grid-column: span 2;
  }

  .reset-button {
    justify-self: start;
  }
}

@media (max-width: 920px) {
  .primary-nav {
    gap: 14px;
  }

  .primary-nav a:nth-child(3),
  .primary-nav a:nth-child(4) {
    display: none;
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 44px;
    min-height: auto;
    padding-block: 76px;
  }

  h1 {
    max-width: 14ch;
  }

  .hero-data {
    max-width: 640px;
  }

  .overview-layout,
  .limits-layout,
  .discussion-layout {
    grid-template-columns: 1fr;
  }

  .spec-checker {
    position: static;
  }

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

  .method-grid article:first-child {
    grid-column: span 2;
  }
}

@media (max-width: 720px) {
  :root {
    --header-height: 62px;
  }

  .nav-shell {
    padding-inline: 18px;
  }

  .brand span:last-child {
    font-size: 0.92rem;
  }

  .menu-button {
    display: inline-block;
  }

  .primary-nav {
    position: absolute;
    top: calc(100% + 1px);
    right: 14px;
    left: 14px;
    display: none;
    align-items: stretch;
    flex-direction: column;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    padding: 10px;
  }

  .primary-nav.is-open {
    display: flex;
  }

  .primary-nav a,
  .primary-nav a:nth-child(3),
  .primary-nav a:nth-child(4),
  .theme-button {
    display: block;
    width: 100%;
    border: 0;
    border-radius: var(--radius-small);
    padding: 11px 12px;
    text-align: left;
  }

  .primary-nav a:hover,
  .theme-button:hover {
    background: var(--surface-2);
  }

  .hero {
    padding: 58px 18px;
  }

  h1 {
    font-size: clamp(2.65rem, 13vw, 4.2rem);
  }

  .hero-line {
    white-space: normal;
  }

  .hero-data-main {
    min-height: 230px;
    padding: 24px;
  }

  .hero-data-main strong {
    font-size: 4.4rem;
  }

  .metric-grid div {
    padding: 16px 18px;
  }

  .notice-strip {
    display: block;
    padding: 20px 18px;
  }

  .notice-strip div {
    display: block;
  }

  .notice-strip p {
    margin: 6px 0 10px;
  }

  .section-shell,
  .works-section,
  .discussion-section {
    padding: 72px 18px;
  }

  .section-heading {
    margin-bottom: 34px;
  }

  .year-chart-panel {
    min-height: 400px;
    padding: 22px 16px;
  }

  .year-chart {
    min-height: 300px;
    gap: 8px;
    padding-inline: 0;
  }

  .year-bar-group {
    height: 260px;
  }

  .insight-stack article {
    grid-template-columns: 42px 1fr;
    padding: 20px;
  }

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

  .field-search {
    grid-column: span 2;
  }

  .results-toolbar,
  .subsection-heading,
  .notes-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .mobile-table-hint {
    display: block;
  }

  .rule-item summary {
    grid-template-columns: 1fr auto;
    gap: 8px 14px;
  }

  .rule-item summary span {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .rule-item summary::after {
    grid-column: 2;
    grid-row: 1;
  }

  .guidance-grid,
  .prototype-grid,
  .sources-list,
  .method-grid {
    grid-template-columns: 1fr;
  }

  .method-grid article:first-child {
    grid-column: auto;
  }

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

  footer {
    align-items: flex-start;
    flex-direction: column;
    padding-inline: 18px;
  }
}

@media (max-width: 470px) {
  .brand span:last-child {
    display: none;
  }

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

  .metric-grid div:nth-child(odd) {
    border-right: 0;
  }

  .metric-grid div:not(:last-child) {
    border-bottom: 1px solid var(--border);
  }

  .metric-grid div {
    min-height: 76px;
  }

  .filters,
  .dimension-grid {
    grid-template-columns: 1fr;
  }

  .field-search {
    grid-column: auto;
  }

  .hero-actions .button {
    width: 100%;
  }

  .note-form,
  .notes-panel,
  .spec-checker {
    padding: 20px;
  }
}

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

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  .site-header,
  .hero-actions,
  .filters,
  .results-toolbar .text-button,
  .pagination,
  .discussion-section,
  .theme-button,
  .menu-button,
  .toast,
  .record-dialog {
    display: none !important;
  }

  body {
    background: #ffffff;
    color: #111111;
  }

  .hero,
  .section-shell,
  .works-section {
    display: block;
    max-width: none;
    min-height: auto;
    padding: 24px 0;
  }

  .table-wrap {
    overflow: visible;
  }

  table {
    min-width: 0;
  }
}
