/* zotero.cmdspace.work — CMDSPACE v4.3 docs layout (sidebar · article · on-this-page). */
:root {
	--font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Pretendard", "Helvetica Neue", sans-serif;
	--font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Pretendard", sans-serif;
	--font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;

	--cmds-green: #134538;
	--cmds-green-bright: #22896a;
	--cmds-pink: #E985A2;

	--bg: #fbfbfa;
	--bg-elev: #ffffff;
	--bg-soft: #f3f5f3;
	--bg-code: #f4f5f3;
	--fg: #0b0d0c;
	--fg-muted: #46504b;
	--fg-subtle: #7d8681;
	--border: #e4e7e4;
	--border-strong: #cfd3cf;
	--accent: var(--cmds-green);
	--accent-on: #ffffff;
	--accent-soft: #e8f1ec;
	--accent-text: var(--cmds-green);
	--warn: #9a4a07;
	--warn-soft: #fdf3e7;

	--header-h: 56px;
	--sidebar-w: 260px;
	--toc-w: 220px;
	--measure: 760px;
	color-scheme: light;
}
[data-theme="dark"] {
	--bg: #0b0f0d;
	--bg-elev: #121714;
	--bg-soft: #151b18;
	--bg-code: #141a17;
	--fg: #eef1ef;
	--fg-muted: #a6afaa;
	--fg-subtle: #6c7570;
	--border: #1f2723;
	--border-strong: #2c3530;
	--accent: var(--cmds-pink);
	--accent-on: #1b1b1b;
	--accent-soft: #2a1820;
	--accent-text: #f2a3bb;
	--warn: #f0b75e;
	--warn-soft: #2a2114;
	color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 16px); }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
	margin: 0; background: var(--bg); color: var(--fg);
	font-family: var(--font-sans); font-size: 16px; line-height: 1.7; letter-spacing: -0.006em;
	-webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
	word-break: keep-all; overflow-wrap: anywhere;
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
code, kbd { font-family: var(--font-mono); font-size: 0.86em; }
:not(pre) > code { background: var(--bg-code); border: 1px solid var(--border); border-radius: 5px; padding: 0.08em 0.38em; white-space: break-spaces; }
kbd { display: inline-block; min-width: 1.6em; text-align: center; padding: 0 0.4em; line-height: 1.55; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; background: var(--bg-elev); color: var(--fg-muted); font-size: 0.78em; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: var(--accent-on); padding: 6px 12px; border-radius: 6px; z-index: 100; }
.skip:focus { left: 8px; }

/* Scrollbars stay invisible until something scrolls (several scrollers share this layout). */
html, .sidebar, .toc, .tbl-wrap, .code pre, #paletteList { scrollbar-width: thin; scrollbar-color: transparent transparent; }
html.scrolling, html.scrolling .sidebar, html.scrolling .toc, html.scrolling .tbl-wrap, html.scrolling .code pre, html.scrolling #paletteList {
	scrollbar-color: color-mix(in srgb, var(--fg-subtle) 55%, transparent) transparent;
}

/* ── Header ─────────────────────────────── */
.site-header {
	position: sticky; top: 0; z-index: 40; height: var(--header-h);
	display: flex; align-items: center; gap: 10px; padding: 0 16px 0 20px;
	background: color-mix(in srgb, var(--bg) 86%, transparent);
	backdrop-filter: saturate(180%) blur(12px); -webkit-backdrop-filter: saturate(180%) blur(12px);
	border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 9px; color: var(--fg); font-weight: 650; font-size: 15px; letter-spacing: -0.01em; margin-right: 8px; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 28px; height: 28px; border-radius: 50%; display: block; }
.brand-ver { font-family: var(--font-mono); font-size: 11.5px; font-weight: 500; color: var(--fg-subtle); border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px; }
.search-btn {
	display: flex; align-items: center; gap: 8px; margin-left: 8px; width: 240px; height: 34px; padding: 0 8px 0 11px;
	background: var(--bg-soft); border: 1px solid var(--border); border-radius: 9px; color: var(--fg-subtle);
	font: inherit; font-size: 13.5px; cursor: pointer;
}
.search-btn:hover { border-color: var(--border-strong); color: var(--fg-muted); }
.search-btn kbd { margin-left: auto; }
.header-links { display: flex; gap: 18px; margin-left: auto; margin-right: 6px; font-size: 14px; }
.header-links a { color: var(--fg-muted); }
.header-links a:hover { color: var(--fg); text-decoration: none; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0; background: none; color: var(--fg-muted); border-radius: 8px; cursor: pointer; }
.icon-btn:hover { background: var(--bg-soft); color: var(--fg); text-decoration: none; }
.nav-toggle { display: none; margin-left: -8px; }
[data-theme="light"] .i-moon, [data-theme="dark"] .i-sun { display: none; }

/* ── Layout ─────────────────────────────── */
.layout { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w); max-width: 1440px; margin: 0 auto; }
.sidebar, .toc { position: sticky; top: var(--header-h); height: calc(100vh - var(--header-h)); overflow-y: auto; }
.sidebar { padding: 26px 18px 40px 22px; border-right: 1px solid var(--border); }
.side-group + .side-group { margin-top: 22px; }
.side-label { margin: 0 0 6px 10px; font-size: 12px; font-weight: 650; letter-spacing: 0.04em; color: var(--fg-subtle); }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar li a { display: block; padding: 5px 10px; border-radius: 7px; color: var(--fg-muted); font-size: 14.5px; line-height: 1.45; }
.sidebar li a:hover { background: var(--bg-soft); color: var(--fg); text-decoration: none; }
.sidebar li a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.side-foot { margin: 28px 10px 0; font-size: 12px; color: var(--fg-subtle); }
.side-foot a { color: var(--fg-subtle); }

.content { min-width: 0; padding: 40px 56px 0; }
.doc { max-width: var(--measure); margin: 0 auto; }
.toc { padding: 34px 20px 40px 8px; font-size: 13px; }
.toc-label { margin: 0 0 8px; font-size: 12px; font-weight: 650; letter-spacing: 0.04em; color: var(--fg-subtle); }
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border); }
.toc li a { display: block; padding: 3px 0 3px 12px; margin-left: -1px; border-left: 2px solid transparent; color: var(--fg-subtle); line-height: 1.45; }
.toc li.lv3 a { padding-left: 24px; }
.toc li a:hover { color: var(--fg); text-decoration: none; }
.toc li a.active { color: var(--accent-text); border-left-color: var(--accent); }

/* ── Article ─────────────────────────────── */
.eyebrow { margin: 0 0 6px; font-size: 13px; font-weight: 600; color: var(--accent-text); letter-spacing: 0.02em; }
.doc h1 { font-family: var(--font-display); font-size: clamp(30px, 4vw, 40px); line-height: 1.2; letter-spacing: -0.025em; margin: 0 0 14px; font-weight: 700; text-wrap: balance; }
.lead { font-size: 18px; line-height: 1.65; color: var(--fg-muted); margin: 0 0 34px; text-wrap: pretty; }
.doc h2 { font-family: var(--font-display); font-size: 25px; line-height: 1.3; letter-spacing: -0.018em; margin: 56px 0 14px; padding-top: 22px; border-top: 1px solid var(--border); font-weight: 700; }
.doc h3 { font-size: 19px; line-height: 1.4; letter-spacing: -0.012em; margin: 34px 0 10px; font-weight: 650; }
.doc h4 { font-size: 16px; margin: 26px 0 8px; font-weight: 650; }
.doc h2, .doc h3, .doc h4 { position: relative; text-wrap: balance; }
.anchor { position: absolute; left: -1.1em; width: 1em; color: var(--fg-subtle); opacity: 0; font-weight: 400; }
.doc :is(h2, h3, h4):hover .anchor { opacity: 1; text-decoration: none; }
.doc p, .doc li { text-wrap: pretty; }
.doc p { margin: 0 0 16px; }
.doc ul, .doc ol { padding-left: 1.35em; margin: 0 0 18px; }
.doc li { margin: 4px 0; }
.doc li > ul, .doc li > ol { margin: 4px 0 6px; }
.doc strong { font-weight: 650; }
.doc hr { border: 0; border-top: 1px solid var(--border); margin: 40px 0; }
.doc img { max-width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--border); }
.doc blockquote { margin: 0 0 18px; padding: 2px 18px; border-left: 3px solid var(--border-strong); color: var(--fg-muted); }

/* Tables scroll inside their own card; the page never scrolls sideways. */
.tbl-wrap { margin: 0 0 22px; overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-elev); }
table { border-collapse: collapse; width: 100%; font-size: 14.5px; line-height: 1.55; }
th, td { text-align: left; vertical-align: top; padding: 9px 14px; border-bottom: 1px solid var(--border); }
th { background: var(--bg-soft); font-weight: 650; font-size: 13.5px; color: var(--fg-muted); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td:first-child { min-width: 9.5em; }
.tbl-wide table { min-width: 680px; }
/* Three- and four-column tables keep readable columns and scroll inside their card on phones. */
.tbl-wrap table:has(th:nth-child(3)) { min-width: 560px; }
.tbl-wrap table:has(th:nth-child(4)) { min-width: 680px; }
tr[hidden] { display: none; }

/* Code */
.code { position: relative; margin: 0 0 20px; }
.code pre { margin: 0; padding: 14px 16px; overflow-x: auto; background: var(--bg-code); border: 1px solid var(--border); border-radius: 10px; font-size: 13.5px; line-height: 1.6; }
.code pre code { font-size: inherit; }
.copy { position: absolute; top: 8px; right: 8px; padding: 3px 9px; font: inherit; font-size: 12px; color: var(--fg-muted); background: var(--bg-elev); border: 1px solid var(--border); border-radius: 6px; cursor: pointer; opacity: 0.45; transition: opacity .15s; }
.code:hover .copy, .copy:focus-visible { opacity: 0.85; }
.copy:hover { opacity: 1; }
.copy.done { color: var(--accent-text); opacity: 1; }

/* Callouts: a tinted panel with a small label, no side stripe. */
.callout { margin: 0 0 20px; padding: 14px 18px 4px; border-radius: 10px; background: var(--bg-soft); border: 1px solid var(--border); }
.callout-title { margin: 0 0 6px !important; font-size: 13px; font-weight: 700; letter-spacing: 0.02em; color: var(--fg-muted); }
.callout p { margin-bottom: 10px; }
.callout-insight, .callout-tip { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 22%, transparent); }
.callout-insight .callout-title, .callout-tip .callout-title { color: var(--accent-text); }
.callout-warning { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.callout-warning .callout-title { color: var(--warn); }

/* Diagrams (Pele) */
.diagram { margin: 8px 0 26px; }
.diagram pre.mermaid { white-space: pre; overflow-x: auto; font-size: 12px; color: var(--fg-subtle); background: var(--bg-soft); border-radius: 10px; padding: 14px; }
.diagram figcaption { margin-top: 8px; font-size: 14px; color: var(--fg-muted); font-style: italic; text-align: center; text-wrap: balance; }
.cmds-pele {
	--cp-bg: var(--bg); --cp-fg: var(--fg); --cp-accent: var(--accent);
	--cp-font: "Pretendard", "SF Pro Text", -apple-system, system-ui, sans-serif;
}
.diagram .cmds-pele { display: flex; justify-content: center; }
.diagram svg { max-width: 100%; height: auto; }

/* Cards (home and step lists) */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin: 0 0 26px; }
.card { display: block; padding: 18px 18px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-elev); color: var(--fg); transition: border-color .15s, transform .15s; }
.card:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-1px); }
.card b { display: block; font-size: 16px; margin-bottom: 4px; }
.card span { display: block; font-size: 14px; color: var(--fg-muted); line-height: 1.55; }
.card .k { font-family: var(--font-mono); font-size: 12px; color: var(--accent-text); margin-bottom: 8px; }

/* Home hero */
.hero { padding: 26px 0 8px; }
.hero h1 { font-family: var(--font-display); font-size: clamp(36px, 6vw, 60px); line-height: 1.1; letter-spacing: -0.035em; margin: 0 0 18px; font-weight: 750; text-wrap: balance; }
.hero h1 .accent-word { color: var(--accent-text); }
.hero .lead { font-size: 19px; max-width: 640px; }
.cta { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 22px; }
.btn { display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 18px; border-radius: 10px; font-weight: 600; font-size: 15px; border: 1px solid var(--border-strong); color: var(--fg); background: var(--bg-elev); }
.btn:hover { text-decoration: none; border-color: var(--fg-subtle); }
.btn.primary { background: var(--accent); color: var(--accent-on); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.doc .facts { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0 0 8px; padding: 0; list-style: none; font-size: 13.5px; color: var(--fg-subtle); }
.doc .facts li { margin: 0; }

/* Home: no on-this-page column, a wider measure */
.home .layout { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
.home .toc { display: none; }
.home .doc, .home .site-footer { max-width: 880px; }

/* Pager and footer */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 64px 0 0; }
.pager a { display: block; padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; color: var(--fg); font-weight: 600; font-size: 15px; }
.pager a:hover { border-color: var(--accent); text-decoration: none; }
.pager span { display: block; font-size: 12.5px; font-weight: 500; color: var(--fg-subtle); margin-bottom: 2px; }
.pager-next { text-align: right; }
.site-footer { max-width: var(--measure); margin: 48px auto 0; padding: 22px 0 48px; border-top: 1px solid var(--border); font-size: 13.5px; color: var(--fg-subtle); }
.site-footer p { margin: 0 0 6px; }
.site-footer a { color: var(--fg-muted); }
.site-footer .fine { font-size: 12.5px; }

/* Table filter on the reference pages */
.filter { display: flex; align-items: center; gap: 10px; margin: 0 0 22px; padding: 0 12px; height: 42px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--bg-elev); color: var(--fg-subtle); }
.filter input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--fg); font: inherit; font-size: 15px; }
.filter-count { font-size: 12.5px; white-space: nowrap; }

/* Glossary hover */
.gloss { border-bottom: 1px dotted var(--fg-subtle); cursor: help; }
#glossTip { position: fixed; z-index: 70; max-width: 300px; padding: 9px 12px; border-radius: 9px; background: var(--fg); color: var(--bg); font-size: 13px; line-height: 1.55; box-shadow: 0 6px 24px rgba(0,0,0,.18); pointer-events: none; }
#glossTip b { display: block; margin-bottom: 2px; }

/* Search palette */
.palette { position: fixed; inset: 0; z-index: 80; display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; background: color-mix(in srgb, #000 38%, transparent); }
.palette[hidden] { display: none; }
.palette-box { width: min(620px, 100%); background: var(--bg-elev); border: 1px solid var(--border-strong); border-radius: 14px; box-shadow: 0 24px 60px rgba(0,0,0,.25); overflow: hidden; }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 0 14px; height: 52px; border-bottom: 1px solid var(--border); color: var(--fg-subtle); }
.palette-input input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--fg); font: inherit; font-size: 16px; }
.palette-input input::-webkit-search-cancel-button { display: none; }
#paletteList { list-style: none; margin: 0; padding: 6px; max-height: min(56vh, 460px); overflow-y: auto; }
#paletteList li a { display: block; padding: 9px 12px; border-radius: 9px; color: var(--fg); }
#paletteList li a:hover, #paletteList li[aria-selected="true"] a { background: var(--accent-soft); text-decoration: none; }
#paletteList .p-title { font-weight: 600; font-size: 14.5px; }
#paletteList .p-page { font-size: 12px; color: var(--fg-subtle); margin-left: 6px; }
#paletteList .p-text { display: block; font-size: 13px; color: var(--fg-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#paletteList mark { background: none; color: var(--accent-text); font-weight: 650; }
#paletteList .empty { padding: 16px 12px; color: var(--fg-subtle); font-size: 14px; }
.palette-hint { margin: 0; padding: 8px 14px; border-top: 1px solid var(--border); font-size: 12px; color: var(--fg-subtle); display: flex; gap: 6px; align-items: center; }

.notfound { padding: 40px 0; }

/* ── Responsive ─────────────────────────── */
@media (max-width: 1180px) {
	.layout { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
	.toc { display: none; }
	.content { padding: 36px 40px 0; }
}
@media (max-width: 880px) {
	.layout { grid-template-columns: minmax(0, 1fr); }
	.nav-toggle { display: inline-grid; }
	.sidebar { position: fixed; z-index: 45; top: var(--header-h); left: 0; width: min(300px, 86vw); background: var(--bg); transform: translateX(-102%); transition: transform .2s ease; box-shadow: 0 10px 40px rgba(0,0,0,.18); }
	html.nav-open .sidebar { transform: none; }
	.content { padding: 28px 16px 0; }
	.search-btn { width: auto; margin-left: auto; }
	.search-btn span, .search-btn kbd, .header-links, .brand-ver { display: none; }
	.anchor { display: none; }
	.lead { font-size: 17px; }
	.pager { grid-template-columns: 1fr; }
}
@media (max-width: 420px) {
	.site-header { padding: 0 8px 0 14px; gap: 4px; }
	.brand-name { font-size: 14px; }
}
@media print {
	.site-header, .sidebar, .toc, .pager, .palette, .copy { display: none !important; }
	.layout { display: block; }
}
