/* kuraokami docs — layout and palette modeled on react.dev (light default, dark toggle). */
:root {
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --bg-softer: #ebecf0;
  --text: #23272f;
  --text-2: #404756;
  --muted: #5e687e;
  --border: #e5e7eb;
  --accent: #087ea4;
  --accent-soft: #e6f7ff;
  --link: #087ea4;
  --code-bg: #f6f7f9;
  --code-text: #23272f;
  --note: #087ea4;     --note-bg: #e6f7ff;
  --pitfall: #c1554d;  --pitfall-bg: #fdeceb;
  --deep: #575fb7;     --deep-bg: #f3f2fd;
  --learn: #087ea4;    --learn-bg: #e6f7ff;
  --tip: #45a1aa;      --tip-bg: #ecfbfb;
  --tok-c: #8a8f98; --tok-s: #2e7d32; --tok-n: #b35900; --tok-k: #7c3aed; --tok-p: #087ea4;
  --shadow: 0 8px 30px rgba(0,0,0,.12);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #23272f;
  --bg-soft: #16181d;
  --bg-softer: #343a46;
  --text: #f6f7f9;
  --text-2: #d0d3dc;
  --muted: #99a1b3;
  --border: #343a46;
  --accent: #58c4dc;
  --accent-soft: #1d3f4b;
  --link: #58c4dc;
  --code-bg: #16181d;
  --code-text: #f6f7f9;
  --note: #58c4dc;     --note-bg: #19303a;
  --pitfall: #ff8f86;  --pitfall-bg: #3a2322;
  --deep: #a6adf6;     --deep-bg: #2b2d45;
  --learn: #58c4dc;    --learn-bg: #19303a;
  --tip: #7cd3dc;      --tip-bg: #1b3437;
  --tok-c: #8b93a5; --tok-s: #a8e1a0; --tok-n: #ffb86b; --tok-k: #c4a7ff; --tok-p: #79d2f0;
  --shadow: 0 8px 30px rgba(0,0,0,.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 76px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Optimistic Display", -apple-system, "Segoe UI", "Noto Sans JP", "Noto Sans CJK JP", "Hiragino Sans", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
kbd {
  font-family: ui-monospace, "JetBrains Mono", monospace;
  font-size: .8em;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 0 .4em;
  background: var(--bg-soft);
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  height: 64px; padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 1.15rem; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.version { font-size: .7rem; font-weight: 600; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 0 8px; }
.search-btn {
  flex: 1; max-width: 420px; display: flex; align-items: center; gap: 10px;
  height: 40px; padding: 0 14px; border-radius: 999px; border: none;
  background: var(--bg-soft); color: var(--muted); font: inherit; font-size: .95rem; cursor: pointer;
}
.search-btn:hover { background: var(--bg-softer); }
.search-btn kbd { margin-left: auto; }
.search-icon { font-size: 1.2rem; }
.top-links { display: flex; gap: 4px; margin-left: auto; }
.top-links a { color: var(--text-2); padding: 6px 12px; border-radius: 999px; font-weight: 500; font-size: .95rem; }
.top-links a:hover { background: var(--bg-soft); text-decoration: none; }
.icon-btn { border: none; background: none; color: var(--text); font-size: 1.25rem; width: 40px; height: 40px; border-radius: 999px; cursor: pointer; }
.icon-btn:hover { background: var(--bg-soft); }
.menu-btn { display: none; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 290px minmax(0, 1fr) 240px; }
.sidebar {
  position: sticky; top: 64px; height: calc(100vh - 64px); overflow-y: auto;
  padding: 20px 12px 40px 20px; border-right: 1px solid var(--border);
}
.nav-section { margin-bottom: 18px; }
.nav-title { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 6px 12px; }
.nav-link { display: block; padding: 6px 12px; border-radius: 0 999px 999px 0; color: var(--text-2); font-size: .95rem; line-height: 1.45; border-left: 3px solid transparent; }
.nav-link:hover { background: var(--bg-soft); text-decoration: none; }
.nav-link.active { color: var(--accent); background: var(--accent-soft); border-left-color: var(--accent); font-weight: 700; }
.content { min-width: 0; padding: 36px 56px 80px; }
.toc { position: sticky; top: 64px; height: calc(100vh - 64px); overflow-y: auto; padding: 36px 20px; }
.toc-title { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 8px; }
.toc-link { display: block; color: var(--muted); font-size: .85rem; padding: 4px 10px; border-left: 2px solid var(--border); line-height: 1.4; }
.toc-link.lvl3 { padding-left: 22px; }
.toc-link:hover { color: var(--text); text-decoration: none; }
.toc-link.active { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }

/* ---------- article ---------- */
article { max-width: 780px; margin: 0 auto; }
.crumb { color: var(--accent); font-weight: 700; font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
article h1 { font-size: 2.6rem; line-height: 1.2; margin: 0 0 20px; letter-spacing: -.01em; }
article h2 { font-size: 1.85rem; line-height: 1.3; margin: 56px 0 16px; padding-top: 8px; }
article h3 { font-size: 1.3rem; margin: 36px 0 12px; }
article h4 { font-size: 1.05rem; margin: 28px 0 8px; }
article h2 + p, article h1 + p { margin-top: 0; }
article p, article li { color: var(--text-2); }
article strong { color: var(--text); }
article img { max-width: 100%; border-radius: 12px; border: 1px solid var(--border); }
article hr { border: none; border-top: 1px solid var(--border); margin: 48px 0; }
.anchor { margin-left: 8px; opacity: 0; color: var(--muted); font-weight: 400; }
h2:hover .anchor, h3:hover .anchor { opacity: 1; }
article ul, article ol { padding-left: 1.5em; }
article li { margin: 4px 0; }
article blockquote { margin: 20px 0; padding: 4px 20px; border-left: 4px solid var(--border); color: var(--muted); }
:not(pre) > code {
  font-family: "JetBrains Mono", ui-monospace, "Cascadia Code", monospace;
  font-size: .88em; background: var(--code-bg); border: 1px solid var(--border);
  border-radius: 6px; padding: .1em .35em; color: var(--code-text); word-break: break-word;
}

/* code blocks */
.code { position: relative; margin: 20px 0; border-radius: 14px; background: var(--code-bg); border: 1px solid var(--border); overflow: hidden; }
.code-title { font-family: ui-monospace, monospace; font-size: .8rem; color: var(--muted); padding: 8px 16px; border-bottom: 1px solid var(--border); }
.code pre { margin: 0; padding: 16px 18px; overflow-x: auto; font-family: "JetBrains Mono", ui-monospace, "Cascadia Code", monospace; font-size: .86rem; line-height: 1.6; color: var(--code-text); }
.copy { position: absolute; right: 8px; top: 8px; font: inherit; font-size: .72rem; border: 1px solid var(--border); background: var(--bg); color: var(--muted); border-radius: 8px; padding: 2px 8px; cursor: pointer; opacity: 0; transition: opacity .15s; }
.code:hover .copy { opacity: 1; }
.code-title + .copy { top: 44px; }
.tok-c { color: var(--tok-c); font-style: italic; }
.tok-s { color: var(--tok-s); }
.tok-n { color: var(--tok-n); }
.tok-k { color: var(--tok-k); font-weight: 600; }
.tok-p { color: var(--tok-p); }

/* tables */
.table-wrap { overflow-x: auto; margin: 20px 0; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-weight: 700; color: var(--text); background: var(--bg-soft); }
td { color: var(--text-2); }

/* callouts (react.dev style) */
.callout { margin: 24px 0; border-radius: 16px; padding: 16px 22px; }
.callout-label { font-weight: 700; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.callout-body > :first-child { margin-top: 0; }
.callout-body > :last-child { margin-bottom: 0; }
.callout.note { background: var(--note-bg); } .callout.note .callout-label { color: var(--note); }
.callout.pitfall { background: var(--pitfall-bg); } .callout.pitfall .callout-label { color: var(--pitfall); }
.callout.tip { background: var(--tip-bg); } .callout.tip .callout-label { color: var(--tip); }
.callout.note .callout-label::before { content: "ⓘ"; }
.callout.pitfall .callout-label::before { content: "⚠"; }
.callout.tip .callout-label::before { content: "💡"; }
.callout.learn { background: var(--learn-bg); border: 1px solid color-mix(in srgb, var(--learn) 25%, transparent); }
.callout.learn .callout-label { color: var(--learn); font-size: 1.05rem; }
.callout.learn ul { margin: 6px 0 0; }
details.deepdive { background: var(--deep-bg); }
details.deepdive summary { cursor: pointer; list-style: none; display: flex; flex-direction: column; gap: 2px; }
details.deepdive summary::-webkit-details-marker { display: none; }
details.deepdive .callout-label { color: var(--deep); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; margin: 0; }
details.deepdive .callout-label::before { content: "▸"; transition: transform .15s; }
details.deepdive[open] .callout-label::before { transform: rotate(90deg); }
details.deepdive .callout-title { font-weight: 700; font-size: 1.1rem; color: var(--text); }
details.deepdive .callout-body { margin-top: 12px; }

/* pager & footer */
.pager { max-width: 780px; margin: 56px auto 0; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.pager a { display: flex; flex-direction: column; padding: 14px 18px; border: 1px solid var(--border); border-radius: 14px; color: var(--text); font-weight: 600; }
.pager a:hover { border-color: var(--accent); text-decoration: none; }
.pager a span { font-size: .8rem; color: var(--muted); font-weight: 500; }
.pager .next { text-align: right; grid-column: 2; }
.foot { max-width: 780px; margin: 40px auto 0; padding-top: 20px; border-top: 1px solid var(--border); color: var(--muted); font-size: .85rem; }

/* home hero */
.home h1 { display: none; }
.hero { text-align: center; padding: 40px 0 24px; }
.hero img.hero-logo { border: none; width: 120px; height: 120px; }
.hero .hero-title { font-size: 3.4rem; font-weight: 800; letter-spacing: -.02em; margin: 12px 0 8px; color: var(--text); line-height: 1.15; }
.hero .hero-sub { font-size: 1.35rem; color: var(--muted); max-width: 640px; margin: 0 auto 28px; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.btn { display: inline-block; padding: 12px 26px; border-radius: 999px; font-weight: 700; font-size: 1rem; }
.btn.primary { background: var(--accent); color: #fff; }
:root[data-theme="dark"] .btn.primary { color: #16181d; }
.btn.secondary { border: 1px solid var(--border); color: var(--text); }
.btn:hover { text-decoration: none; filter: brightness(1.05); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin: 28px 0; }
.card { border: 1px solid var(--border); border-radius: 16px; padding: 18px 20px; background: var(--bg); }
.card .card-title { font-weight: 700; color: var(--text); margin-bottom: 4px; }
.card p { margin: 0; font-size: .93rem; }
a.card { display: block; color: inherit; }
a.card:hover { border-color: var(--accent); text-decoration: none; }

/* search */
.search-overlay { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.35); display: flex; justify-content: center; align-items: flex-start; padding-top: 10vh; }
.search-overlay[hidden] { display: none; }
.search-dialog { width: min(680px, 94vw); background: var(--bg); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; border: 1px solid var(--border); }
#search-input { width: 100%; border: none; outline: none; padding: 18px 20px; font: inherit; font-size: 1.1rem; background: var(--bg); color: var(--text); border-bottom: 1px solid var(--border); }
#search-results { list-style: none; margin: 0; padding: 8px; max-height: 56vh; overflow-y: auto; }
#search-results li { padding: 10px 12px; border-radius: 10px; cursor: pointer; }
#search-results li.sel { background: var(--accent-soft); }
#search-results li.empty { color: var(--muted); cursor: default; }
.r-page { font-size: .75rem; color: var(--muted); }
.r-head { font-weight: 700; color: var(--text); }
.r-snip { font-size: .85rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-hint { font-size: .78rem; color: var(--muted); padding: 8px 16px; border-top: 1px solid var(--border); display: flex; gap: 6px; align-items: center; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .layout { grid-template-columns: 270px minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .menu-btn { display: block; }
  .top-links, .search-label, .search-btn kbd { display: none; }
  .search-btn { flex: 0 0 auto; width: 40px; padding: 0; justify-content: center; margin-left: auto; }
  .sidebar { position: fixed; left: 0; top: 64px; z-index: 15; width: 300px; background: var(--bg); transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  body.nav-open .sidebar { transform: none; }
  .content { padding: 24px 16px 60px; }
  article h1 { font-size: 2rem; }
  .hero .hero-title { font-size: 2.4rem; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { grid-column: 1; }
}
