:root {
  --paper: #ffffff;
  --surface: #f3f5f8;
  --ink: #18212c;
  --ink-soft: #2c3846;
  --muted: #566273;
  --line: #d9dfe6;
  --amber: #f4b63f;
  --amber-soft: #fbe6b6;
  --amber-ink: #7a4b00;
  --slate: #3b4a5c;
  --sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --measure: 68ch;
  --wrap: 1160px;
  --radius: 6px;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 88px;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4 {
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.015em;
  margin: 0;
}

p {
  margin: 0 0 1em;
}

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-color: #d9940f;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}

a:hover {
  text-decoration-color: currentColor;
}

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

.wrap {
  max-width: var(--wrap);
  margin: 0 auto;
  padding-inline: 28px;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 12px;
  z-index: 20;
  padding: 8px 14px;
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius);
}

.skip:focus {
  left: 16px;
}

.rid {
  font-family: var(--mono);
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 64px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 22px;
  margin-left: auto;
  font-size: 0.95rem;
}

.site-nav > a:not(.gh-button) {
  color: var(--muted);
  text-decoration: none;
  padding: 6px 0;
  border-bottom: 2px solid transparent;
}

.site-nav > a:not(.gh-button):hover,
.site-nav > a[aria-current='page'] {
  color: var(--ink);
}

.site-nav > a[aria-current='page'] {
  border-bottom-color: var(--amber);
}

.lang-menu {
  position: relative;
  padding-left: 22px;
  border-left: 1px solid var(--line);
}

.lang-menu summary {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 0;
  color: var(--muted);
  font-weight: 500;
  cursor: pointer;
  list-style: none;
}

.lang-menu summary::-webkit-details-marker {
  display: none;
}

.lang-menu summary:hover,
.lang-menu[open] summary {
  color: var(--ink);
}

.lang-menu[open] summary svg {
  transform: rotate(180deg);
}

.lang-menu ul {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 168px;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(24, 33, 44, 0.08);
}

.lang-menu li a {
  display: block;
  padding: 7px 10px;
  color: var(--ink-soft);
  text-decoration: none;
  border-radius: 4px;
}

.lang-menu li a:hover {
  background: var(--surface);
  color: var(--ink);
}

.lang-menu li a[aria-current] {
  color: var(--ink);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--amber);
}

.menu-toggle {
  display: none;
  margin-left: auto;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 12px;
  cursor: pointer;
}

.gh-button {
  display: inline-flex;
  align-items: stretch;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  overflow: hidden;
}

.gh-main,
.gh-count {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
}

.gh-count {
  gap: 5px;
  border-left: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
}

.gh-button:hover .gh-main {
  background: var(--surface);
}

.button {
  display: inline-flex;
  align-items: center;
  padding: 11px 20px;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  font-weight: 500;
  text-decoration: none;
  color: var(--ink);
  background: var(--paper);
}

.button:hover {
  background: var(--surface);
}

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

.button-primary:hover {
  background: var(--ink-soft);
}

.hero {
  padding: 80px 0 72px;
}

.hero h1 {
  font-size: clamp(2.5rem, 6.2vw, 4.4rem);
  line-height: 1.04;
  letter-spacing: -0.03em;
  max-width: 15ch;
}

.lead {
  font-size: 1.22rem;
  line-height: 1.6;
  color: var(--ink-soft);
  max-width: 60ch;
  margin-top: 24px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 32px 0 0;
}

.day {
  margin: 64px 0 0;
}

.day-title {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 12px;
}

.day-bar,
.day-legend {
  display: grid;
  grid-template-columns: 5fr 1fr 2fr 3fr;
  gap: 4px;
}

.day-bar {
  height: 64px;
}

.seg {
  border-radius: 4px;
  transform-origin: left center;
  animation: grow 0.55s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.seg-focus {
  background: var(--amber);
}

.seg-lunch {
  background: repeating-linear-gradient(135deg, var(--surface) 0 6px, var(--line) 6px 7px);
  animation-delay: 0.45s;
}

.seg-window {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  padding: 8px 6px;
  background: var(--surface);
  animation-delay: 0.6s;
}

.seg-after {
  background: var(--amber-soft);
  animation-delay: 0.75s;
}

.slot {
  position: relative;
}

.slot::before {
  content: '';
  position: absolute;
  inset: 0 25% 0 0;
  border-radius: 3px;
  border: 1px dashed #a7b1bd;
}

.slot.booked::before {
  background: var(--slate);
  border: 0;
}

.day-legend {
  margin-top: 10px;
}

.leg {
  display: flex;
  flex-direction: column;
  padding-left: 10px;
  border-left: 1px solid var(--line);
  min-width: 0;
}

.leg-time {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--muted);
}

.leg-name {
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.3;
}

.day figcaption {
  margin-top: 20px;
  max-width: 64ch;
  color: var(--muted);
}

@keyframes grow {
  from {
    transform: scaleX(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .seg {
    animation: none;
  }
}

.band {
  padding: 80px 0;
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.band-plain {
  background: var(--paper);
}

.band h2 {
  font-size: 1.85rem;
  margin-bottom: 12px;
}

.section-lead {
  color: var(--muted);
  max-width: 62ch;
  margin-bottom: 36px;
}

.core-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 40px;
}

.core-list a {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 18px;
  border-top: 3px solid var(--ink);
  text-decoration: none;
}

.core-list li:first-child a {
  border-top-color: var(--amber);
}

.core-list .rid {
  font-size: 1rem;
}

.core-name {
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.core-sum {
  color: var(--ink-soft);
}

.core-list a:hover .core-name {
  text-decoration: underline;
  text-decoration-color: #d9940f;
  text-underline-offset: 4px;
}

.rule-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
}

.rule-list a {
  display: grid;
  grid-template-columns: 4.5rem minmax(0, 1fr) 6.5rem;
  grid-template-areas: 'id name badge' 'id sum badge';
  column-gap: 16px;
  padding: 18px 12px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
}

.rule-list a:hover {
  background: var(--surface);
}

.rule-list .rid {
  grid-area: id;
  padding-top: 2px;
}

.rname {
  grid-area: name;
  font-weight: 600;
  font-size: 1.08rem;
}

.rsum {
  grid-area: sum;
  color: var(--muted);
  max-width: 72ch;
}

.rule-list .badge {
  grid-area: badge;
  justify-self: end;
  align-self: start;
  margin-top: 3px;
}

.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1;
  padding: 5px 8px;
  border-radius: 4px;
  border: 1px solid var(--ink);
  white-space: nowrap;
}

.badge-must {
  background: var(--ink);
  color: var(--paper);
}

.badge-should {
  color: var(--ink);
}

.badge-may {
  color: var(--muted);
  border: 1px dashed var(--muted);
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 72px;
}

.split p {
  color: var(--ink-soft);
  max-width: 56ch;
}

.text-link {
  font-weight: 500;
}

.inline-links {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
}

.code {
  position: relative;
  margin: 1.4em 0;
}

.code pre {
  margin: 0;
  padding: 18px 20px;
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 0.86rem;
  line-height: 1.6;
}

.band .code pre {
  background: var(--paper);
}

.citation pre {
  padding-right: 88px;
  white-space: pre-wrap;
}

.copy {
  position: absolute;
  top: 9px;
  right: 9px;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 3px 10px;
  cursor: pointer;
}

.copy:hover {
  border-color: var(--muted);
}

.page-head {
  padding-block: 64px 96px;
}

.page-head h1 {
  font-size: clamp(2.2rem, 4.5vw, 3rem);
  letter-spacing: -0.025em;
}

.page-head .lead {
  margin-bottom: 40px;
}

.tpl-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: var(--measure);
}

.tpl-list li {
  padding: 20px 0;
  border-top: 1px solid var(--line);
}

.tpl-list a {
  font-size: 1.15rem;
  font-weight: 600;
}

.tpl-list p {
  margin: 6px 0 0;
  color: var(--muted);
}

.doc-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 64px;
  padding-top: 48px;
  padding-bottom: 96px;
}

.side > * {
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  font-size: 0.9rem;
}

.side-title {
  font-weight: 600;
  margin-bottom: 10px;
}

.toc ol,
.side-rules {
  list-style: none;
  margin: 0;
  padding: 0;
}

.toc a,
.side-rules a {
  display: flex;
  gap: 10px;
  padding: 5px 0 5px 12px;
  border-left: 2px solid var(--line);
  color: var(--muted);
  text-decoration: none;
  line-height: 1.4;
}

.toc .toc-3 a {
  padding-left: 24px;
}

.toc a:hover,
.side-rules a:hover {
  color: var(--ink);
}

.side-rules .rid {
  flex: 0 0 2.4rem;
}

.side-rules a[aria-current='page'] {
  color: var(--ink);
  font-weight: 600;
  border-left-color: var(--amber);
}

.side-mobile {
  display: none;
}

.doc {
  max-width: var(--measure);
  min-width: 0;
}

.doc h1 {
  font-size: clamp(2rem, 4vw, 2.6rem);
  letter-spacing: -0.025em;
  margin-bottom: 0.6em;
}

.doc h2 {
  font-size: 1.45rem;
  margin: 2.2em 0 0.6em;
}

.doc h3 {
  font-size: 1.15rem;
  margin: 1.9em 0 0.5em;
}

.doc ul,
.doc ol {
  padding-left: 1.4em;
  margin: 0 0 1em;
}

.doc li {
  margin: 0.3em 0;
}

.doc li > ul,
.doc li > ol {
  margin: 0.3em 0;
}

.doc a {
  overflow-wrap: anywhere;
}

.doc blockquote {
  margin: 1.5em 0;
  padding: 2px 0 2px 18px;
  border-left: 3px solid var(--amber);
  color: var(--ink-soft);
}

.doc blockquote p:last-child {
  margin-bottom: 0;
}

.doc code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--surface);
  border-radius: 3px;
  padding: 1px 5px;
}

.doc pre code {
  background: none;
  padding: 0;
  font-size: inherit;
}

.table-wrap {
  overflow-x: auto;
  margin: 1.4em 0;
}

.doc table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.95rem;
}

.doc th,
.doc td {
  text-align: left;
  vertical-align: top;
  padding: 9px 14px 9px 0;
  border-bottom: 1px solid var(--line);
}

.doc th {
  font-weight: 600;
  border-bottom-color: var(--ink);
}

.doc thead tr:has(th:empty:only-child),
.doc thead:has(th:empty + th:empty) {
  display: none;
}

.rule-head {
  padding-bottom: 28px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.rule-head h1 {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0 16px;
}

.rule-head h1 .rid {
  color: var(--amber-ink);
}

.statement {
  font-size: 1.3rem;
  line-height: 1.5;
  margin: 4px 0 28px;
  padding-left: 18px;
  border-left: 3px solid var(--amber);
}

.rule-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 40px;
  margin: 0;
}

.rule-meta dt {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 2px;
}

.rule-meta dd {
  margin: 0;
  font-weight: 500;
}

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 64px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.pager a {
  text-decoration: none;
  font-weight: 600;
}

.pager a span {
  display: block;
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--muted);
}

.pager a:hover {
  text-decoration: underline;
  text-decoration-color: #d9940f;
}

.pager-next {
  text-align: right;
}

.site-footer {
  border-top: 1px solid var(--line);
  padding: 32px 0 48px;
  font-size: 0.9rem;
  color: var(--muted);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 16px 32px;
}

.footer-inner p {
  margin: 0;
}

.footer-inner ul {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  list-style: none;
  margin: 0;
  padding: 0;
}

@media (max-width: 1020px) {
  .doc-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    padding-top: 32px;
  }

  .side {
    display: none;
  }

  .side-mobile {
    display: block;
    margin-bottom: 32px;
    padding: 12px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-size: 0.95rem;
  }

  .side-mobile summary {
    font-weight: 600;
    cursor: pointer;
  }

  .side-mobile > nav,
  .side-mobile > .toc {
    margin-top: 12px;
  }

  .side-mobile .side-title {
    display: none;
  }

  .core-list,
  .split {
    grid-template-columns: 1fr;
    gap: 40px;
  }
}

@media (max-width: 900px) {
  .menu-toggle {
    display: inline-block;
  }

  .site-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 12px 28px 20px;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
  }

  .site-header[data-open] .site-nav {
    display: flex;
  }

  .lang-menu {
    padding-left: 0;
    border-left: 0;
  }

  .lang-menu ul {
    position: static;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    min-width: 0;
    margin: 6px 0 0 -10px;
    padding: 0;
    border: 0;
    box-shadow: none;
  }

  .site-nav .gh-button {
    margin-top: 8px;
  }
}

@media (max-width: 640px) {
  .wrap {
    padding-inline: 20px;
  }

  .hero {
    padding: 48px 0 56px;
  }

  .day-bar {
    height: 48px;
  }

  .day-legend {
    grid-template-columns: 1fr 1fr;
    gap: 12px 16px;
    margin-top: 16px;
  }

  .leg {
    border-left: 0;
    padding-left: 22px;
    position: relative;
  }

  .leg::before {
    content: '';
    position: absolute;
    left: 0;
    top: 4px;
    width: 14px;
    height: 14px;
    border-radius: 3px;
  }

  .leg-focus::before {
    background: var(--amber);
  }

  .leg-lunch::before {
    background: repeating-linear-gradient(135deg, var(--surface) 0 3px, var(--line) 3px 4px);
    outline: 1px solid var(--line);
  }

  .leg-window::before {
    background: var(--slate);
  }

  .leg-after::before {
    background: var(--amber-soft);
  }

  .band {
    padding: 56px 0;
  }

  .rule-list a {
    grid-template-columns: 3rem minmax(0, 1fr);
    grid-template-areas: 'id name' 'id sum' 'id badge';
    row-gap: 4px;
    padding: 16px 4px;
  }

  .rule-list .badge {
    justify-self: start;
    margin-top: 6px;
  }

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

  .pager-next {
    text-align: left;
  }

  .page-head {
    padding-block: 40px 64px;
  }
}
