:root {
  color-scheme: light;
  --ink: #201f20;
  --muted: #5b5b5b;
  --line: #e0e0df;
  --soft: #f7f6f6;
  --blue: #2548c5;
  --focus: #2e5bff;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  color: var(--ink);
  background: #fff;
  font-family: "Host Grotesk", system-ui, -apple-system, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
  line-height: 1.6;
}

a { color: var(--blue); text-underline-offset: .19em; }
a:hover { text-decoration-thickness: 2px; }
button, input { font: inherit; }
button, summary { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
::selection { background: #dce5ff; color: var(--ink); }

.skip-link {
  position: absolute;
  z-index: 1;
  inset: 8px auto auto 12px;
  padding: 8px 12px;
  background: #fff;
  transform: translateY(-140%);
}

.skip-link:focus { transform: none; }
.site-width { width: min(1200px, calc(100% - 48px)); margin-inline: auto; }
.site-header { border-bottom: 1px solid var(--line); }

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

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 20px;
  font-weight: 700;
  text-decoration: none;
}

.brand-mark { flex: none; color: var(--focus); }
.header-nav { display: flex; align-items: center; gap: 24px; font-size: 14px; }
.header-nav a { display: inline-flex; align-items: center; gap: .3em; min-height: 44px; color: inherit; text-decoration: none; }
.header-nav a:hover, .header-nav a[aria-current] { color: var(--blue); text-decoration: underline; }
.header-nav .external-link { color: var(--blue); }

.intro { padding: 34px 0 22px; border-bottom: 1px solid var(--line); }
.intro h1 { margin: 0; font-size: clamp(27px, 4vw, 36px); line-height: 1.2; letter-spacing: -.035em; }
.intro > p { margin: 10px 0 22px; color: var(--muted); }
.search-panel { display: grid; grid-template-columns: max-content minmax(0, 560px); gap: 4px 14px; align-items: center; }
.search-panel label { font-size: 14px; font-weight: 650; }

.search-field {
  display: flex;
  align-items: center;
  border: 1px solid #88898d;
  border-radius: 6px;
  background: #fff;
}

.search-field:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.search-field input { min-width: 0; width: 100%; min-height: 42px; padding: 8px 12px; border: 0; border-radius: inherit; color: var(--ink); background: transparent; }
.search-field input:focus-visible { outline: none; }
.search-field input::placeholder { color: var(--muted); opacity: 1; }
.clear-button { flex: none; padding: 5px 10px; margin-right: 5px; border: 0; border-radius: 4px; color: var(--blue); background: var(--soft); font-size: 13px; }
.clear-button:hover { text-decoration: underline; }
.search-status { grid-column: 2; margin: 0; color: var(--muted); font-size: 13px; }

.doc-layout { display: grid; gap: 30px; align-items: start; padding: 26px 0 48px; }
.doc-layout:has(.doc-sidebar:not([hidden])) { grid-template-columns: 210px minmax(0, 1fr); }
.doc-sidebar { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; padding: 2px 17px 0 2px; border-right: 1px solid var(--line); }
.toc > summary { font-weight: 650; margin-bottom: 8px; }
.resource-nav :is(ol, ul) { padding: 0; margin: 0; list-style: none; }
.resource-nav > ol > li + li { margin-top: 14px; }
.resource-nav > ol > li > a { font-weight: 650; }
.resource-nav ul { margin: 2px 0 0 8px; }
.resource-nav a { display: block; padding: 5px 8px; border-radius: 4px; color: var(--muted); font-size: 14px; text-decoration: none; }
.resource-nav a:hover { color: var(--blue); text-decoration: underline; }
.resource-nav a[aria-current] { color: var(--blue); background: #edf1ff; font-weight: 650; }

.markdown-body { min-width: 0; overflow-wrap: anywhere; }
.markdown-body :is(h2, h3, h4) { line-height: 1.35; scroll-margin-top: 18px; }
.markdown-body h2 { margin: 28px 0 8px; font-size: clamp(19px, 2vw, 24px); }
.markdown-body > .doc-section:first-of-type > h2, .markdown-body > h2:first-child { margin-top: 0; }
.markdown-body h3 { margin: 24px 0 8px; font-size: clamp(18px, 2vw, 23px); }
.markdown-body h4 { margin: 17px 0 6px; font-size: 16px; }
.markdown-body p { margin: 6px 0 12px; }
.markdown-body > .doc-section + .doc-section { margin-top: 40px; }
.markdown-body hr { margin: 22px 0; border: 0; border-top: 1px solid var(--line); }
.markdown-body blockquote { margin: 7px 0 10px; color: var(--muted); font-size: 14px; }
.markdown-body blockquote p { margin: 0; }
.timeline { margin: 7px 0 0; color: var(--muted); }
.timeline h4 { display: inline; font-size: 14px; font-weight: 500; }
.timeline summary:hover, .paper-name summary:hover { text-decoration: underline; }

.table-scroll { max-width: 100%; margin: 10px 0 20px; overflow-x: auto; }
.markdown-body table { width: 100%; border-spacing: 0; font-size: 14px; }
.markdown-body table:not(.paper-table) { min-width: 280px; }
.markdown-body table.wide-table { min-width: 820px; }
.markdown-body :is(th, td) { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.markdown-body th { background: var(--soft); text-align: left; font-weight: 650; white-space: nowrap; }
.markdown-body th button { display: inline-flex; align-items: center; gap: .4em; padding: 0; border: 0; color: inherit; background: transparent; font-weight: inherit; }
.markdown-body th button:hover { color: var(--blue); }
.markdown-body th button span::after { content: "↕"; color: var(--muted); }
.markdown-body th[aria-sort="ascending"] button span::after { content: "↑"; color: var(--blue); }
.markdown-body th[aria-sort="descending"] button span::after { content: "↓"; color: var(--blue); }
.markdown-body td { max-width: 38rem; }
.markdown-body tbody tr:hover { background: #fafafa; }
.paper-table { table-layout: fixed; }
.paper-table th:nth-child(2) { width: 84px; }
.paper-table :is(th:nth-child(3), th:nth-child(4)) { width: 20%; }
.paper-table :is(th, td) { text-align: left !important; }
.paper-name strong { font-size: 15px; }
.paper-name strong:empty { display: none; }
.paper-title { color: var(--muted); }
.paper-year { white-space: nowrap; font-variant-numeric: tabular-nums; }
.paper-links { color: var(--muted); font-size: 13px; }
.paper-original { display: block; width: fit-content; font-size: 14px; }
.paper-name details { margin-top: 3px; font-size: 13px; }
.paper-name summary { width: fit-content; color: var(--blue); }
.paper-name dl { margin: 6px 0 1px; padding-left: 10px; border-left: 2px solid var(--line); }
.paper-name dt { margin-top: 4px; color: var(--ink); font-weight: 650; }
.paper-name dd { margin: 0; color: var(--muted); }
.empty-state { padding: 12px 0; color: var(--muted); }

.site-footer { display: flex; justify-content: space-between; gap: 12px; padding: 16px 0 28px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }

@media (max-width: 780px) {
  .site-width { width: calc(100% - 32px); }
  .header-inner { flex-wrap: wrap; gap: 0 12px; padding: 10px 0 0; }
  .header-nav { flex-basis: 100%; gap: clamp(8px, 4vw, 22px); flex-wrap: wrap; font-size: 13px; }
  .intro { padding-top: 22px; }
  .search-panel { grid-template-columns: minmax(0, 1fr); }
  .search-status { grid-column: 1; }
  .doc-layout:has(.doc-sidebar:not([hidden])) { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .doc-sidebar { position: static; max-height: none; overflow: visible; padding: 0 0 6px; border: 0; border-bottom: 1px solid var(--line); }
  .toc > summary { padding: 8px 0; margin: 0; }
  .doc-section > h2 + p { font-size: 14px; }
}

@media (max-width: 600px) {
  .paper-table :is(thead, tbody) { display: block; }
  .paper-table thead tr { display: flex; flex-wrap: wrap; background: var(--soft); }
  .paper-table thead th:nth-child(n) { width: auto; padding: 5px 7px; border: 0; }
  .paper-table th button { min-height: 30px; font-size: 12px; }
  .paper-table tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; padding: 10px 8px; border-bottom: 1px solid var(--line); }
  .paper-table td { display: block; max-width: none; padding: 0; border: 0; }
  .paper-name { grid-column: 1 / -1; }
  .paper-year { font-size: 13px; color: var(--muted); }
  .paper-venue { grid-row: 3; color: var(--muted); font-size: 13px; }
  .paper-links { grid-column: 2; grid-row: 2 / 4; max-width: 8rem !important; text-align: right !important; }
  .paper-original { margin-left: auto; }
}
