:root {
  color-scheme: light;
  --bg: #f5f8fb;
  --paper: #ffffff;
  --ink: #102131;
  --muted: #607286;
  --line: #d8e2ec;
  --blue: #176b9a;
  --blue-deep: #0b466b;
  --blue-soft: #dceef8;
  --cyan: #47b8d1;
  --amber: #864b00;
  --amber-soft: #fff0d4;
  --green: #287557;
  --on-action: #ffffff;
  --focus: #00658a;
  --shadow: 0 18px 50px rgb(24 62 91 / 10%);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #09131c;
  --paper: #101e29;
  --ink: #e7f0f6;
  --muted: #9cb0c0;
  --line: #263d4d;
  --blue: #5bb8e8;
  --blue-deep: #96d6f5;
  --blue-soft: #16384c;
  --cyan: #69d1e4;
  --amber: #f6bd68;
  --amber-soft: #3f2e18;
  --green: #73c5a5;
  --on-action: #07131c;
  --focus: #7bdcff;
  --shadow: 0 18px 60px rgb(0 0 0 / 35%);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.55;
}
a { color: var(--blue); text-underline-offset: .18em; }
button, input, textarea, select { font: inherit; }
button, .button { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 4rem;
  padding: 0 clamp(1rem, 4vw, 3rem);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(16px);
}
.brand {
  display: flex;
  align-items: center;
  gap: .65rem;
  color: var(--ink);
  font-weight: 760;
  text-decoration: none;
  letter-spacing: -.02em;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50% 45% 55% 42%;
  background: var(--blue);
  color: var(--on-action);
  font-family: var(--serif);
  font-size: 1.35rem;
  font-style: italic;
}
.header-actions { display: flex; align-items: center; gap: .85rem; }
.identity { color: var(--muted); font-size: .88rem; }
.theme-toggle, .icon-button, .link-button {
  border: 0;
  background: none;
  color: var(--muted);
}
.theme-toggle {
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--line);
  border-radius: 50%;
}
.link-button { text-decoration: underline; text-underline-offset: .2em; }

.landing {
  min-height: calc(100vh - 4rem);
  display: grid;
  place-items: center;
  padding: 2rem;
}
.landing-card {
  width: min(30rem, 100%);
  padding: clamp(2rem, 7vw, 3.5rem);
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--paper);
  box-shadow: var(--shadow);
  text-align: center;
}
.landing-mark {
  display: grid;
  width: 3rem;
  height: 3rem;
  place-items: center;
  margin: 0 auto 1.4rem;
  border-radius: 50% 45% 55% 42%;
  background: var(--blue);
  color: var(--on-action);
  font-family: var(--serif);
  font-size: 2rem;
  font-style: italic;
}
.landing h1 {
  margin: 0 0 .65rem;
  font-size: clamp(1.8rem, 7vw, 2.4rem);
  line-height: 1.1;
  letter-spacing: -.035em;
}
.landing p { margin: 0 auto; color: var(--muted); }
.button {
  display: inline-block;
  margin-top: 1.5rem;
  padding: .8rem 1.1rem;
  border-radius: .6rem;
  text-decoration: none;
  font-weight: 700;
}
.button.primary { background: var(--blue); color: var(--on-action); }
.notice {
  margin-top: 1.5rem !important;
  padding: .85rem 1rem;
  border-left: .25rem solid var(--amber);
  background: var(--amber-soft);
  color: var(--ink) !important;
}

.dashboard { width: min(72rem, calc(100% - 2rem)); margin: 0 auto 5rem; }
.workspace-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(18rem, 25rem);
  gap: 2rem;
  align-items: end;
  padding: 3rem 0 2.25rem;
  border-bottom: 1px solid var(--line);
}
.workspace-head h1 { margin: 0; font-size: clamp(2rem, 5vw, 2.75rem); line-height: 1.08; letter-spacing: -.04em; }
.search-wrap { position: relative; }
.search-wrap label { display: block; margin-bottom: .45rem; font-size: .78rem; font-weight: 750; }
.search-wrap input {
  width: 100%;
  padding: .78rem .9rem;
  border: 1px solid var(--line);
  border-radius: .7rem;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 4px 18px rgb(23 107 154 / 5%);
}
.search-results {
  position: absolute;
  z-index: 10;
  top: 100%;
  width: 100%;
  margin-top: .35rem;
  border: 1px solid var(--line);
  border-radius: .7rem;
  background: var(--paper);
  box-shadow: var(--shadow);
  max-height: min(24rem, calc(100vh - 8rem));
  overflow-y: auto;
  overscroll-behavior: contain;
}
.search-results:empty { display: none; }
.search-result { display: block; padding: .8rem 1rem; border-bottom: 1px solid var(--line); text-decoration: none; }
.search-result:last-child { border-bottom: 0; }
.search-result strong { display: block; color: var(--ink); }
.search-result span { color: var(--muted); font-size: .82rem; }
.search-result[aria-selected="true"] { background: var(--blue-soft); }
.search-empty { padding: .8rem 1rem; color: var(--muted); }
.rfc-index { padding-top: 1.25rem; }
.rfc-grid { display: grid; grid-template-columns: 1fr; gap: .5rem; }
.rfc-card {
  position: relative;
  display: grid;
  grid-template-columns: 10rem minmax(0, 1fr);
  align-items: center;
  padding: .9rem 1rem;
  border: 1px solid var(--line);
  border-radius: .75rem;
  background: var(--paper);
  box-shadow: 0 5px 18px rgb(24 62 91 / 4%);
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.rfc-card:hover { border-color: color-mix(in srgb, var(--blue) 45%, var(--line)); box-shadow: 0 10px 26px rgb(24 62 91 / 8%); transform: translateY(-1px); }
.rfc-card-meta, .document-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .65rem;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 650;
}
.rfc-card h2 { margin: 0; font-family: var(--serif); font-size: 1.2rem; line-height: 1.2; }
.rfc-card h2 a { color: var(--ink); text-decoration: none; }
.rfc-card h2 a:focus-visible { outline: none; }
.rfc-card h2 a::after { position: absolute; inset: 0; content: ""; }
.rfc-card h2 a:focus-visible::after { outline: 3px solid var(--focus); outline-offset: 3px; }
.status { display: inline-flex; padding: .18rem .48rem; border-radius: 999px; }
.status.proposed { background: var(--amber-soft); color: var(--amber); }

.reader {
  display: grid;
  grid-template-columns: minmax(12rem, 15rem) minmax(0, 52rem);
  gap: clamp(1.5rem, 4vw, 4rem);
  width: min(74rem, calc(100% - 2rem));
  margin: 0 auto;
  padding: 3rem 0 8rem;
}
.toc-panel {
  position: sticky;
  top: 6rem;
  align-self: start;
  max-height: calc(100vh - 8rem);
  overflow: auto;
}
.back-link { font-size: .82rem; font-weight: 700; text-decoration: none; }
.toc-details { margin-top: 2rem; }
.toc-details summary { color: var(--muted); cursor: pointer; font-size: .72rem; font-weight: 800; letter-spacing: .05em; list-style: none; text-transform: uppercase; }
.toc-details summary::-webkit-details-marker { display: none; }
.toc-details summary::after { margin-left: .4rem; content: "−"; }
.toc-details:not([open]) summary::after { content: "+"; }
.toc-panel ol { margin: 0; padding: 0; list-style: none; }
.toc-panel li { margin: .2rem 0; }
.toc-panel a { display: block; padding: .24rem 0; color: var(--muted); font-size: .78rem; line-height: 1.35; text-decoration: none; }
.toc-level-3 { padding-left: .8rem; }
.rfc-document { min-width: 0; }
.rfc-document > .rfc-block:has(> :is(p, h1, h2, h3, h4, ul, ol, blockquote)) { max-width: 46rem; }
.document-toolbar {
  padding: 0 0 1rem;
  border-bottom: 1px solid var(--line);
}
.document-toolbar > a, .export-menu > summary {
  min-height: 2rem;
  padding: .38rem .22rem;
  cursor: pointer;
  text-decoration: none;
}
.document-toolbar > a:first-of-type { margin-left: auto; }
.pinned-revision { color: var(--blue-deep); font-weight: 750; }
.export-menu { position: relative; }
.export-menu > summary { list-style: none; }
.export-menu > summary::-webkit-details-marker { display: none; }
.export-menu > summary::after { margin-left: .28rem; content: "▾"; }
.export-menu[open] > summary::after { content: "▴"; }
.export-links {
  position: absolute;
  z-index: 12;
  top: calc(100% + .25rem);
  left: 0;
  display: grid;
  min-width: 11rem;
  padding: .35rem;
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: var(--paper);
  box-shadow: var(--shadow);
}
.export-links a { padding: .48rem .55rem; border-radius: .3rem; text-decoration: none; }
.export-links a:hover, .export-links a:focus-visible { background: var(--blue-soft); }
.document-toolbar + .rfc-block { margin-top: 2.25rem; }
.document-toolbar + .rfc-block h1 { margin-top: 0; }
.rfc-block {
  position: relative;
  scroll-margin-top: 6rem;
  border-radius: .35rem;
  outline: none;
  transition: background .15s, box-shadow .15s;
}
.rfc-block:hover, .rfc-block:focus { background: color-mix(in srgb, var(--blue-soft) 48%, transparent); box-shadow: 0 0 0 .4rem color-mix(in srgb, var(--blue-soft) 48%, transparent); }
.rfc-block.has-comments::after {
  position: absolute;
  top: .3rem;
  right: -1.4rem;
  width: .55rem;
  height: .55rem;
  border-radius: 50%;
  background: var(--cyan);
  content: "";
}
.rfc-document h1, .rfc-document h2, .rfc-document h3, .rfc-document h4 {
  font-family: var(--serif);
  line-height: 1.12;
  letter-spacing: -.025em;
}
.rfc-document h1 { margin: 0 0 1.2rem; font-size: clamp(2.3rem, 6vw, 4.2rem); }
.rfc-document h2 { margin: 3.6rem 0 1rem; padding-top: .3rem; border-top: 1px solid var(--line); font-size: 2rem; }
.rfc-document h3 { margin-top: 2.4rem; font-size: 1.35rem; }
.rfc-document p, .rfc-document li { font-family: var(--serif); font-size: 1.05rem; }
.rfc-document table { display: block; width: 100%; overflow-x: auto; border-collapse: collapse; font-size: .88rem; }
.rfc-document th, .rfc-document td { padding: .55rem .65rem; border: 1px solid var(--line); vertical-align: top; }
.rfc-document th { background: var(--blue-soft); text-align: left; }
.rfc-document pre {
  overflow: auto;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: .6rem;
  background: #0b1822;
  color: #d9e9f3;
  font-size: .82rem;
  line-height: 1.5;
}
.rfc-document code { font-family: var(--mono); font-size: .88em; }
.rfc-document :not(pre) > code { padding: .08rem .28rem; border-radius: .25rem; background: var(--blue-soft); color: var(--blue-deep); }
.hljs-keyword, .hljs-meta { color: #77caee; }
.hljs-string, .hljs-literal { color: #a8d7a7; }
.hljs-number, .hljs-type { color: #f4bd78; }
.hljs-comment { color: #78909f; font-style: italic; }
.hljs-title { color: #e4a6d8; }

.review-panel {
  position: fixed;
  z-index: 30;
  top: 0;
  right: 0;
  width: min(31rem, 100%);
  height: 100vh;
  padding: 1.35rem;
  overflow: auto;
  border-left: 1px solid var(--line);
  background: var(--paper);
  box-shadow: -16px 0 48px rgb(0 0 0 / 12%);
  transform: translateX(105%);
  transition: transform .2s ease;
}
.review-panel[hidden] { display: none; }
.review-backdrop {
  position: fixed;
  z-index: 25;
  inset: 0;
  background: rgb(4 13 20 / 48%);
  backdrop-filter: blur(2px);
}
.review-backdrop[hidden] { display: none; }
.review-panel.open { transform: none; }
.review-panel-head { display: flex; align-items: start; justify-content: space-between; }
.review-panel-head h2 { margin: 0; font-size: 1.35rem; letter-spacing: -.02em; }
.icon-button { font-size: 1.8rem; }
.review-tabs { display: flex; gap: .25rem; margin: 1.2rem 0; border-bottom: 1px solid var(--line); }
.review-tabs button {
  padding: .55rem .8rem;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
}
.review-tabs button.active { border-color: var(--blue); color: var(--ink); }
.review-fab {
  position: fixed;
  z-index: 18;
  right: 1.5rem;
  bottom: 1.5rem;
  padding: .75rem 1rem;
  border: 0;
  border-radius: 999px;
  background: var(--blue);
  color: var(--on-action);
  box-shadow: var(--shadow);
  font-weight: 750;
}
.review-fab span { display: inline-grid; min-width: 1.4rem; height: 1.4rem; place-items: center; margin-left: .35rem; border-radius: 50%; background: rgb(255 255 255 / 18%); }
.anchor-chip { margin-bottom: .9rem; padding: .65rem .7rem; border: 1px solid color-mix(in srgb, var(--blue) 20%, var(--line)); border-radius: .45rem; background: color-mix(in srgb, var(--blue-soft) 55%, transparent); color: var(--blue-deep); font-size: .78rem; }
.review-form label { display: block; color: var(--muted); font-size: .78rem; font-weight: 700; }
.review-form textarea, .review-form input, .review-form select {
  width: 100%;
  margin: .25rem 0 .75rem;
  padding: .65rem;
  border: 1px solid var(--line);
  border-radius: .4rem;
  background: var(--bg);
  color: var(--ink);
}
.review-form textarea { min-height: 7rem; resize: vertical; }
.review-form button, .comment-actions button {
  padding: .48rem .7rem;
  border: 1px solid var(--line);
  border-radius: .35rem;
  background: var(--paper);
  color: var(--ink);
}
.review-form button[type="submit"] { border-color: var(--blue); background: var(--blue); color: var(--on-action); }
.comment, .proposal {
  margin: .9rem 0;
  padding: .9rem;
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: var(--bg);
}
.comment.outdated, .proposal.outdated { border-color: var(--amber); }
.comment.reply { margin-left: 1.2rem; }
.comment-meta, .proposal-meta { color: var(--muted); font-size: .72rem; font-weight: 650; }
.comment-body { margin: .55rem 0; white-space: pre-wrap; }
.anchor-excerpt { margin: .45rem 0; padding-left: .6rem; border-left: 2px solid var(--cyan); color: var(--muted); font-size: .78rem; }
.proposal-diff {
  max-height: 16rem;
  overflow: auto;
  padding: .65rem;
  border: 1px solid var(--line);
  border-radius: .35rem;
  background: var(--paper);
  color: var(--muted);
  font-family: var(--mono);
  font-size: .72rem;
  white-space: pre;
}
.comment-actions { display: flex; flex-wrap: wrap; gap: .35rem; }
.empty-state { margin: 1rem 0; color: var(--muted); font-size: .88rem; }

@media (max-width: 900px) {
  .workspace-head { grid-template-columns: 1fr; }
  .reader { grid-template-columns: 1fr; }
  .toc-panel { position: static; max-height: none; padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
  .toc-details { margin-top: 1rem; }
  .toc-panel ol { max-height: 13rem; overflow: auto; }
}
@media (max-width: 580px) {
  .rfc-card { grid-template-columns: 1fr; gap: .45rem; }
  .dashboard, .reader { width: min(100% - 1.2rem, 78rem); }
  .identity { display: none; }
  .site-header { padding-inline: .8rem; }
  .brand { gap: .5rem; font-size: .92rem; }
  .brand-mark { width: 1.75rem; height: 1.75rem; font-size: 1.15rem; }
  .workspace-head { padding-top: 2rem; }
  .rfc-document h1 { font-size: 2.35rem; }
  .document-toolbar { align-items: flex-start; }
  .document-toolbar > a:first-of-type { margin-left: 0; }
  .review-fab {
    position: static;
    grid-row: 2;
    justify-self: end;
    margin-bottom: .25rem;
    border-radius: .6rem;
    box-shadow: none;
  }
  .rfc-document { grid-row: 3; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
