/* report.kawaiii.me — shared design for the index and Markdown reports.
   Tokens mirror the HIP report so every page reads as one family.
   Layout: index is one 52rem column; a report is a 15.5rem contents rail + 45rem reading column,
   and below 1024px the rail becomes a drawer behind a slim top bar. */
:root {
  --bg: #fcfcfb; --raised: #f3f2ee; --ink: #0b0b0b; --ink-2: #52514e; --muted: #6b6a66; --line: #e4e3dc; --line-strong: #c3c2b7;
  --accent: #1c5cab; --accent-wash: #eaf1fb; --hover: rgba(11,11,11,.045); --scrim: rgba(11,11,11,.32);
  --shadow: 0 8px 28px rgba(11,11,11,.12), 0 1px 3px rgba(11,11,11,.08);
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", sans-serif;
  --font-mono: "SF Mono", ui-monospace, Menlo, Consolas, "Liberation Mono", monospace;
  --gutter-l: max(16px, env(safe-area-inset-left, 0px)); --gutter-r: max(16px, env(safe-area-inset-right, 0px));
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #1a1a19; --raised: #242422; --ink: #f0efec; --ink-2: #c3c2b7; --muted: #a3a197; --line: #2f2f2c; --line-strong: #45443f;
  --accent: #7ab0ee; --accent-wash: #1d2735; --hover: rgba(255,255,255,.05); --scrim: rgba(0,0,0,.5);
  --shadow: 0 8px 28px rgba(0,0,0,.45), 0 1px 3px rgba(0,0,0,.4); color-scheme: dark; } }
:root[data-theme="dark"] {
  --bg: #1a1a19; --raised: #242422; --ink: #f0efec; --ink-2: #c3c2b7; --muted: #a3a197; --line: #2f2f2c; --line-strong: #45443f;
  --accent: #7ab0ee; --accent-wash: #1d2735; --hover: rgba(255,255,255,.05); --scrim: rgba(0,0,0,.5);
  --shadow: 0 8px 28px rgba(0,0,0,.45), 0 1px 3px rgba(0,0,0,.4); color-scheme: dark; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; animation: none !important; } }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-sans); font-size: 16px; line-height: 1.75;
  -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
b, strong { font-weight: 650; }
::selection { background: var(--accent-wash); }

/* shared controls */
.pill { font: inherit; font-size: .82rem; display: inline-flex; align-items: center; gap: .4rem; padding: .3rem .7rem; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--bg); color: var(--ink-2); cursor: pointer; white-space: nowrap; line-height: 1.4; }
.pill:hover { color: var(--ink); border-color: var(--ink-2); text-decoration: none; }
.pill svg { width: 14px; height: 14px; flex: none; }
.icon-btn { padding: .3rem; width: 2rem; height: 2rem; justify-content: center; }
.progress { position: fixed; top: env(safe-area-inset-top, 0px); left: 0; right: 0; height: 2px; z-index: 60; pointer-events: none; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); }

/* ───────── index ───────── */
.index { max-width: 52rem; margin: 0 auto; padding: calc(2.5rem + env(safe-area-inset-top, 0px)) var(--gutter-r) calc(4rem + env(safe-area-inset-bottom, 0px)) var(--gutter-l); }
.masthead { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.eyebrow { margin: 0; font-size: .75rem; letter-spacing: .16em; color: var(--muted); font-weight: 600; }
.masthead h1 { margin: .45rem 0 .35rem; font-size: clamp(1.9rem, 1.4rem + 2vw, 2.6rem); line-height: 1.2; letter-spacing: -.01em; font-weight: 700; }
.masthead .sub { margin: 0; color: var(--ink-2); font-size: .95rem; font-variant-numeric: tabular-nums; }
.filter { margin: 2rem 0 .5rem; position: relative; }
.filter input { width: 100%; box-sizing: border-box; font: inherit; font-size: 1rem; color: var(--ink); background: var(--raised);
  border: 1px solid transparent; border-radius: 10px; padding: .65rem .9rem .65rem 2.4rem; -webkit-appearance: none; appearance: none; }
.filter input::placeholder { color: var(--muted); }
.filter input:focus { outline: none; border-color: var(--line-strong); background: var(--bg); }
.filter svg { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.reports { list-style: none; margin: 0; padding: 0; }
.report { position: relative; display: grid; grid-template-columns: 6.5rem minmax(0, 1fr); column-gap: 1.75rem; padding: 1.5rem 0; border-bottom: 1px solid var(--line); }
.report:last-child { border-bottom: 0; }
.report time { color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; padding-top: .2rem; }
.report h2 { margin: 0 0 .4rem; font-size: 1.18rem; line-height: 1.45; font-weight: 650; text-wrap: balance; }
.report h2 a { color: var(--ink); }
.report h2 a::after { content: ""; position: absolute; inset: 0; border-radius: 12px; }   /* whole row is the link */
.report:hover h2 a { color: var(--accent); text-decoration: none; }
.report p { margin: 0; color: var(--ink-2); font-size: .94rem; line-height: 1.75; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; text-wrap: pretty; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .9rem; margin-top: .65rem; font-size: .8rem; color: var(--muted); }
.meta .tag { border: 1px solid var(--line-strong); border-radius: 5px; padding: 0 .4rem; font-size: .72rem; letter-spacing: .04em; line-height: 1.6; }
.meta .mdate { display: none; }
.meta a { position: relative; z-index: 1; color: var(--ink-2); }   /* sits above the row link */
.meta a:hover { color: var(--accent); }
.empty { color: var(--muted); padding: 2rem 0; text-align: center; }
.site-foot { margin-top: 3rem; padding-top: 1.25rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .8rem; display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
@media (max-width: 640px) {
  .index { padding-top: calc(1.75rem + env(safe-area-inset-top, 0px)); }
  .report { grid-template-columns: minmax(0, 1fr); padding: 1.25rem 0; }
  .report time { display: none; }
  .meta .mdate { display: inline; font-variant-numeric: tabular-nums; }
  .report p { -webkit-line-clamp: 3; }
}

/* ───────── report page ───────── */
.shell { display: grid; grid-template-columns: 15.5rem minmax(0, 1fr); column-gap: 4rem; max-width: 76rem; margin: 0 auto; padding-left: var(--gutter-l); padding-right: var(--gutter-r); }
.rail { position: sticky; top: 0; align-self: start; height: 100vh; height: 100dvh; box-sizing: border-box; overflow-y: auto;
  padding-block: 2.25rem 1.25rem; display: flex; flex-direction: column; gap: 1rem; scrollbar-width: thin; overscroll-behavior: contain; }
.rail-head { display: flex; flex-direction: column; gap: .35rem; padding: 0 .5rem 1rem; border-bottom: 1px solid var(--line); }
.rail-head .home { font-size: .8rem; color: var(--muted); display: inline-flex; align-items: center; gap: .3rem; }
.rail-head .home:hover { color: var(--accent); text-decoration: none; }
.rail-head .home svg { width: 12px; height: 12px; }
.rail-head .rt { color: var(--ink); font-weight: 650; font-size: .95rem; line-height: 1.45; }
.toc { font-size: .84rem; line-height: 1.45; }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc a { display: grid; grid-template-columns: 1.9em minmax(0, 1fr); gap: .2em; padding: .32rem .5rem; border-radius: 6px; color: var(--ink-2); }
.toc a.nonum { grid-template-columns: minmax(0, 1fr); }
.toc a:hover { background: var(--hover); color: var(--ink); text-decoration: none; }
.toc .n { color: var(--muted); font-variant-numeric: tabular-nums; }
.toc a.active { color: var(--accent); background: var(--accent-wash); font-weight: 600; }
.toc a.active .n { color: var(--accent); }
.toc li ol { margin: .15rem 0 .5rem 1.2rem; border-left: 1px solid var(--line); }
.toc li ol a { display: block; padding: .24rem .6rem; font-size: .79rem; border-radius: 0 6px 6px 0; margin-left: -1px; border-left: 1px solid transparent; }
.toc li ol a.active { border-left-color: var(--accent); background: none; }
.js .toc > ol > li:not(.open) > ol { display: none; }
.rail-foot { margin-top: auto; padding: 1rem .5rem 0; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.rail-foot a { font-size: .8rem; color: var(--muted); }
.topbar { display: none; }
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 40; }

.doc { min-width: 0; max-width: 45rem; padding-block: 3.25rem 5rem; font-size: 1.0625rem; line-height: 1.85; }
.doc [id] { scroll-margin-top: 1.5rem; }
.doc-head { margin-bottom: 2.25rem; }
.doc-head .kicker { margin: 0; font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; display: flex; flex-wrap: wrap; gap: .2rem .9rem; }
.doc h1 { font-size: clamp(1.7rem, 1.25rem + 1.9vw, 2.35rem); line-height: 1.32; letter-spacing: -.01em; margin: .55rem 0 0; font-weight: 700; text-wrap: balance; }
.doc .lede { font-size: 1.02rem; color: var(--ink-2); margin: 1.1rem 0 0; }
.doc h2 { font-size: 1.45rem; line-height: 1.4; margin: 4rem 0 1.1rem; padding-top: 1.5rem; border-top: 1px solid var(--line); font-weight: 650; text-wrap: balance; }
.doc h3 { font-size: 1.14rem; line-height: 1.5; margin: 2.4rem 0 .65rem; font-weight: 650; text-wrap: balance; }
.doc h4 { font-size: 1rem; margin: 1.8rem 0 .5rem; font-weight: 650; }
.doc-body > h2:first-child { margin-top: 1rem; }
.secno { color: var(--muted); font-weight: 600; margin-right: .45em; font-variant-numeric: tabular-nums; }
.doc h2 .secno { color: var(--accent); }
.anchor { margin-left: .4em; color: var(--muted); opacity: 0; font-weight: 400; }
.anchor:hover { text-decoration: none; color: var(--accent); }
h2:hover .anchor, h3:hover .anchor, .anchor:focus-visible { opacity: 1; }
.doc p { margin: 0 0 1em; text-wrap: pretty; }
.doc ul, .doc ol { margin: 0 0 1.1em; padding-left: 1.45em; }
.doc li { margin: .32em 0; }
.doc li > p { margin: 0 0 .4em; }
.doc li::marker { color: var(--muted); }
.doc hr { border: 0; border-top: 1px solid var(--line); margin: 2.5rem 0; }
.doc code { font-family: var(--font-mono); font-size: .84em; background: var(--raised); border-radius: 4px; padding: .08em .34em; overflow-wrap: anywhere; }
.doc blockquote { margin: 1.4rem 0; padding: .85rem 1.1rem; background: var(--accent-wash); border-radius: 10px; color: var(--ink); font-size: .97rem; }
.doc blockquote > :last-child { margin-bottom: 0; }
.doc img { max-width: 100%; height: auto; }

.tscroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 1.6rem 0 1.4rem; position: relative; }
.doc table { width: 100%; border-collapse: collapse; font-size: .875rem; line-height: 1.55; font-variant-numeric: tabular-nums;
  border-top: 1.5px solid var(--ink-2); border-bottom: 1.5px solid var(--ink-2); }
.doc th, .doc td { padding: .5rem .65rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.doc thead th { font-weight: 650; color: var(--ink-2); border-bottom: 1px solid var(--line-strong); vertical-align: bottom; }
.doc th.num, .doc td.num { text-align: right; white-space: nowrap; }
.doc tbody tr:last-child td { border-bottom: 0; }
.doc tbody tr:hover td { background: var(--hover); }
.doc td code, .doc th code { overflow-wrap: normal; }
.doc td.nw { white-space: nowrap; }
.tscroll.wide table { min-width: 40rem; }
.tscroll.scrollable { mask-image: linear-gradient(to right, #000 calc(100% - 2rem), transparent); -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 2rem), transparent); }
.tscroll.scrollable.at-end { mask-image: none; -webkit-mask-image: none; }

.codeblock { position: relative; margin: .5rem 0 1.2rem; }
.doc pre { margin: 0; font-family: var(--font-mono); font-size: .8rem; line-height: 1.7; background: var(--raised); border-radius: 10px;
  padding: 1rem 1.1rem; overflow-x: auto; white-space: pre; tab-size: 4; }
.doc pre code { background: none; padding: 0; font-size: inherit; overflow-wrap: normal; }
.copy { position: absolute; top: .55rem; right: .55rem; font: inherit; font-size: .75rem; line-height: 1.4; padding: .2rem .65rem; border-radius: 6px;
  border: 1px solid var(--line-strong); background: var(--bg); color: var(--ink-2); cursor: pointer; opacity: 0; transition: opacity .15s; }
.codeblock:hover .copy, .copy:focus-visible { opacity: 1; }
@media (hover: none) { .copy { opacity: 1; } }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 4rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.pager a { display: block; padding: .85rem 1rem; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); font-size: .92rem; line-height: 1.5; }
.pager a:hover { border-color: var(--line-strong); background: var(--hover); text-decoration: none; }
.pager span { display: block; font-size: .75rem; color: var(--muted); margin-bottom: .15rem; }
.pager .next { text-align: right; grid-column: 2; }

.totop { position: fixed; z-index: 20; right: calc(var(--gutter-r) + .25rem); bottom: calc(1.1rem + env(safe-area-inset-bottom, 0px));
  width: 2.5rem; height: 2.5rem; border-radius: 50%; display: grid; place-items: center; background: var(--bg); color: var(--ink-2);
  border: 1px solid var(--line-strong); box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .2s ease; }
.totop.show { opacity: 1; pointer-events: auto; }
.totop:hover { color: var(--accent); text-decoration: none; }
.totop svg { width: 16px; height: 16px; }

@media (max-width: 1023px) {
  .shell { display: block; }
  .topbar { display: flex; align-items: center; gap: .6rem; position: sticky; top: env(safe-area-inset-top, 0px); z-index: 30; height: 3rem;
    padding-left: var(--gutter-l); padding-right: var(--gutter-r); background: color-mix(in srgb, var(--bg) 88%, transparent);
    -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px); border-bottom: 1px solid var(--line); }
  body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 31; background: var(--bg); }
  .tb-title { flex: 1; min-width: 0; color: var(--ink); font-weight: 650; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .tb-title:hover { text-decoration: none; }
  .rail { position: fixed; top: 0; bottom: 0; left: 0; z-index: 50; width: min(20rem, 86vw); height: auto; align-self: stretch; background: var(--bg);
    border-right: 1px solid var(--line); box-shadow: var(--shadow);
    padding: calc(1.25rem + env(safe-area-inset-top, 0px)) 1rem calc(1rem + env(safe-area-inset-bottom, 0px)) max(1rem, env(safe-area-inset-left, 0px));
    transform: translateX(-105%); visibility: hidden; transition: transform .22s ease, visibility 0s linear .22s; }
  body.toc-open .rail { transform: none; visibility: visible; transition: transform .22s ease, visibility 0s; }
  body.toc-open { overflow: hidden; }
  .doc { margin: 0 auto; padding-top: 1.75rem; }
  .doc [id] { scroll-margin-top: 4.25rem; }
}
@media (max-width: 640px) {
  .doc { font-size: 1.03rem; line-height: 1.82; padding-bottom: calc(4rem + env(safe-area-inset-bottom, 0px)); }
  .doc h2 { font-size: 1.3rem; margin-top: 3.2rem; }
  .doc th, .doc td { padding: .45rem .5rem; }
  .doc td code { overflow-wrap: anywhere; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { grid-column: 1; }
}
@media (min-width: 1600px) { .doc { font-size: 1.1rem; } .shell { max-width: 80rem; } }
@media print {
  .rail, .topbar, .progress, .totop, .pager, .copy, .scrim { display: none !important; }
  .shell { display: block; } .doc { max-width: none; padding: 0; } .tscroll { overflow: visible; mask-image: none; -webkit-mask-image: none; }
}
