/* InspectAssets User Manual — design system
   Light/dark via [data-theme] on <html>, defaulting to the OS preference. */

:root {
  --brand: #2f5fdb;
  --brand-strong: #1f43a8;
  --brand-soft: #eaf0fe;

  --ink: #101423;
  --ink-2: #363c4f;
  --ink-3: #656d84;

  --bg: #ffffff;
  --bg-2: #f7f8fb;
  --bg-3: #eef1f7;
  --line: #e2e6ef;
  --line-2: #d3d9e6;

  --ok: #0f7b52;
  --ok-bg: #e7f6ef;
  --warn: #8a5b00;
  --warn-bg: #fdf3e0;
  --danger: #b3261e;
  --danger-bg: #fdecec;

  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(16, 20, 35, .06), 0 1px 3px rgba(16, 20, 35, .04);
  --shadow-lg: 0 18px 48px rgba(16, 20, 35, .16);

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --topbar-h: 58px;
  --sidebar-w: 268px;
  --aside-w: 210px;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --brand: #7ea2ff; --brand-strong: #a8c0ff; --brand-soft: #1b2440;
    --ink: #eef1f8; --ink-2: #c2c9da; --ink-3: #8d97ae;
    --bg: #0e1119; --bg-2: #141924; --bg-3: #1b2130;
    --line: #262d3d; --line-2: #333c50;
    --ok: #5bd2a0; --ok-bg: #10291f; --warn: #e0b263; --warn-bg: #2a2013;
    --danger: #ff8f87; --danger-bg: #2e1717;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
    --shadow-lg: 0 18px 48px rgba(0,0,0,.6);
  }
}

:root[data-theme="dark"] {
  --brand: #7ea2ff; --brand-strong: #a8c0ff; --brand-soft: #1b2440;
  --ink: #eef1f8; --ink-2: #c2c9da; --ink-3: #8d97ae;
  --bg: #0e1119; --bg-2: #141924; --bg-3: #1b2130;
  --line: #262d3d; --line-2: #333c50;
  --ok: #5bd2a0; --ok-bg: #10291f; --warn: #e0b263; --warn-bg: #2a2013;
  --danger: #ff8f87; --danger-bg: #2e1717;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow-lg: 0 18px 48px rgba(0,0,0,.6);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--topbar-h) + 20px); }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--sans); font-size: 15.5px; line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 300;
  background: var(--brand); color: #fff; padding: 10px 18px; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

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

/* ---------- Auth gate ---------- */
.gate-overlay {
  position: fixed; inset: 0; z-index: 200; background: var(--bg);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.gate-card {
  text-align: center; max-width: 380px; padding: 40px 36px;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
}
.gate-status { color: var(--ink-3); margin: 18px 0 0; font-size: 14px; }
.spinner {
  width: 32px; height: 32px; margin: 0 auto; border-radius: 50%;
  border: 3px solid var(--line-2); border-top-color: var(--brand);
  animation: spin .75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.gate-overlay-error .spinner { display: none; }
.gate-overlay-error .gate-status { display: none; }
.gate-error[hidden] { display: none; }
.gate-error-message { color: var(--danger); font-size: 14px; margin: 0 0 18px; }

.gate-loading .protected { visibility: hidden; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 60; height: var(--topbar-h);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  height: 100%; max-width: 1440px; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; gap: 14px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-size: 12px; font-weight: 800; letter-spacing: .02em;
}
.brand-text { font-weight: 650; font-size: 14.5px; display: flex; flex-direction: column; line-height: 1.15; }
.brand-text em { font-style: normal; font-weight: 450; font-size: 11.5px; color: var(--ink-3); }

.search-trigger {
  margin-left: auto; display: flex; align-items: center; gap: 8px;
  min-width: 200px; padding: 7px 10px; font: inherit; font-size: 13px;
  color: var(--ink-3); background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 8px; cursor: pointer;
}
.search-trigger:hover { border-color: var(--line-2); color: var(--ink-2); }
.search-trigger svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.search-trigger span { flex: 1; text-align: left; }
.search-trigger kbd, .search-footer kbd {
  font-family: var(--sans); font-size: 11px; padding: 2px 5px; border-radius: 4px;
  background: var(--bg-3); border: 1px solid var(--line); color: var(--ink-3);
}

.topbar-actions { display: flex; align-items: center; gap: 8px; }
.user-menu { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; margin-right: 4px; }
.user-chip { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.user-role { font-size: 11px; color: var(--ink-3); text-transform: capitalize; }

.btn {
  font: inherit; font-size: 13px; font-weight: 600; padding: 7px 13px;
  border-radius: 8px; border: 1px solid transparent; cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center; white-space: nowrap;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-strong); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink-2); }
.btn-ghost:hover { background: var(--bg-2); }

.icon-btn {
  width: 32px; height: 32px; display: grid; place-items: center; cursor: pointer;
  background: transparent; border: 1px solid var(--line); border-radius: 8px; color: var(--ink-2);
}
.icon-btn:hover { background: var(--bg-2); }
.icon-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] .icon-sun { display: none; }
  :root[data-theme="auto"] .icon-moon { display: block; }
}

.nav-toggle { display: none; flex-direction: column; gap: 4px; background: none; border: 0; cursor: pointer; padding: 6px; }
.nav-toggle span { width: 18px; height: 2px; background: var(--ink-2); border-radius: 2px; }

/* ---------- Layout ---------- */
.layout { max-width: 1440px; margin: 0 auto; display: grid; grid-template-columns: var(--sidebar-w) 1fr; }

.sidebar {
  position: sticky; top: var(--topbar-h); align-self: start;
  height: calc(100vh - var(--topbar-h)); overflow-y: auto;
  padding: 22px 14px 40px; border-right: 1px solid var(--line);
}
.sidebar-filter { padding: 0 8px 14px; margin-bottom: 10px; border-bottom: 1px solid var(--line); }
.sidebar-filter[hidden] { display: none; }
.switch { display: flex; align-items: center; gap: 9px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  width: 32px; height: 18px; border-radius: 999px; background: var(--line-2);
  position: relative; transition: background .16s; flex: none;
}
.switch-thumb {
  position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; transition: transform .16s; box-shadow: var(--shadow-sm);
}
.switch input:checked + .switch-track { background: var(--brand); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(14px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--brand); outline-offset: 2px; }
.switch-label { font-size: 12.5px; color: var(--ink-3); }

.nav-group { margin-bottom: 20px; }
.nav-group-title {
  margin: 0 0 6px 10px; font-size: 10.5px; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--ink-3);
}
.nav-group ul { list-style: none; margin: 0; padding: 0; }
.nav-group a {
  display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 7px;
  color: var(--ink-2); text-decoration: none; font-size: 13.5px;
}
.nav-group a:hover { background: var(--bg-2); color: var(--ink); }
.nav-group a.active { background: var(--brand-soft); color: var(--brand-strong); font-weight: 620; }
.nav-label { flex: 1; }
.nav-lock { font-size: 9px; opacity: .5; }
.nav-lock[hidden] { display: none; }
body.filter-accessible-only .nav-locked { display: none; }

/* ---------- Content ---------- */
.content { min-width: 0; padding: 40px 40px 72px; }
.content-inner { display: grid; grid-template-columns: minmax(0, 1fr) var(--aside-w); gap: 44px; max-width: 1060px; }
.content-body { min-width: 0; max-width: 760px; }

.content h1 { font-size: 32px; line-height: 1.2; letter-spacing: -.02em; margin: 0 0 8px; }
.lede { font-size: 16.5px; color: var(--ink-3); margin: 0 0 28px; line-height: 1.55; }
.content h2 {
  font-size: 20px; letter-spacing: -.01em; margin: 42px 0 12px;
  padding-top: 22px; border-top: 1px solid var(--line);
}
.content h2:first-of-type { border-top: 0; padding-top: 0; margin-top: 30px; }
.content h3 { font-size: 15.5px; margin: 26px 0 8px; }
.content p { margin: 0 0 14px; color: var(--ink-2); }
.content ul, .content ol { margin: 0 0 16px; padding-left: 22px; color: var(--ink-2); }
.content li { margin-bottom: 7px; }
.content li::marker { color: var(--ink-3); }
.content strong { color: var(--ink); font-weight: 640; }
.content code {
  font-family: var(--mono); font-size: .875em; padding: 1.5px 5px; border-radius: 5px;
  background: var(--bg-3); color: var(--ink); border: 1px solid var(--line);
}
kbd {
  font-family: var(--sans); font-size: 11.5px; padding: 2px 6px; border-radius: 5px;
  background: var(--bg-3); border: 1px solid var(--line-2); color: var(--ink-2);
  box-shadow: 0 1px 0 var(--line-2);
}

/* Callouts */
.callout {
  margin: 20px 0; padding: 14px 16px; border-radius: var(--radius);
  background: var(--bg-2); border: 1px solid var(--line); border-left: 3px solid var(--brand);
}
.callout.warn { border-left-color: var(--warn); background: var(--warn-bg); }
.callout.danger { border-left-color: var(--danger); background: var(--danger-bg); }
.callout-title {
  margin: 0 0 5px; font-size: 11px; font-weight: 750; letter-spacing: .06em;
  text-transform: uppercase; color: var(--ink-3);
}
.callout.warn .callout-title { color: var(--warn); }
.callout.danger .callout-title { color: var(--danger); }
.callout p:last-child { margin-bottom: 0; }

/* Access banner (permission-aware) */
.access-banner {
  display: flex; gap: 12px; align-items: flex-start; margin: 0 0 26px;
  padding: 13px 16px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--bg-2);
}
.access-banner[hidden] { display: none; }
.access-icon {
  flex: none; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center;
  font-size: 11px; font-weight: 800; color: #fff; margin-top: 2px;
}
.access-yes { border-color: color-mix(in srgb, var(--ok) 35%, var(--line)); background: var(--ok-bg); }
.access-yes .access-icon { background: var(--ok); }
.access-no { border-color: color-mix(in srgb, var(--warn) 35%, var(--line)); background: var(--warn-bg); }
.access-no .access-icon { background: var(--warn); }
.access-headline { margin: 0; font-size: 13.5px; font-weight: 650; color: var(--ink); }
.access-detail { margin: 2px 0 0; font-size: 12.5px; color: var(--ink-2); line-height: 1.5; }

/* Steps */
.steps { counter-reset: step; list-style: none; padding-left: 0; }
.steps > li { counter-increment: step; position: relative; padding-left: 36px; margin-bottom: 14px; }
.steps > li::before {
  content: counter(step); position: absolute; left: 0; top: 1px;
  width: 23px; height: 23px; border-radius: 50%; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand-strong); font-size: 11.5px; font-weight: 750;
}

/* Tables */
table { width: 100%; border-collapse: collapse; margin: 18px 0 24px; font-size: 14px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 11px; font-weight: 720; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); }
td { color: var(--ink-2); }
tbody tr:hover { background: var(--bg-2); }

/* Badges */
.badge {
  display: inline-block; font-size: 11px; font-weight: 650; padding: 2.5px 9px; border-radius: 999px;
  background: var(--bg-3); border: 1px solid var(--line); color: var(--ink-3);
}
.badge.admin { background: var(--danger-bg); border-color: color-mix(in srgb, var(--danger) 30%, var(--line)); color: var(--danger); }
.badge.status { font-family: var(--mono); font-size: 10.5px; }

/* Card grid */
.card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 20px 0; }
.card {
  display: block; padding: 15px 16px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg); text-decoration: none; color: var(--ink); box-shadow: var(--shadow-sm);
}
.card:hover { border-color: var(--brand); transform: translateY(-1px); }
.card h3 { margin: 0 0 3px; font-size: 14.5px; color: var(--brand); }
.card p { margin: 0; font-size: 12.5px; color: var(--ink-3); }

/* Page meta + prev/next */
.page-meta {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--line);
  font-size: 12px; color: var(--ink-3);
}
.page-meta .dot { opacity: .5; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--brand); cursor: pointer; text-decoration: underline; }

.prev-next { display: flex; justify-content: space-between; gap: 16px; margin-top: 26px; }
.prev-next-link {
  display: flex; flex-direction: column; gap: 2px; text-decoration: none;
  padding: 11px 14px; border: 1px solid var(--line); border-radius: var(--radius); min-width: 0;
}
.prev-next-link:hover { border-color: var(--brand); background: var(--bg-2); }
.prev-next-link span { font-size: 11.5px; color: var(--ink-3); }
.prev-next-link strong { font-size: 13.5px; color: var(--brand); font-weight: 620; }
.prev-next-link.next { text-align: right; align-items: flex-end; }

/* On-page TOC */
.content-aside { min-width: 0; }
.toc { position: sticky; top: calc(var(--topbar-h) + 34px); }
.toc-title {
  margin: 0 0 8px; font-size: 10.5px; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--ink-3);
}
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.toc a {
  display: block; padding: 4.5px 0 4.5px 13px; margin-left: -1px;
  border-left: 2px solid transparent; color: var(--ink-3);
  font-size: 12.5px; line-height: 1.4; text-decoration: none;
}
.toc a:hover { color: var(--ink); }
.toc a.active { color: var(--brand); border-left-color: var(--brand); font-weight: 600; }

/* Footer */
.site-footer {
  border-top: 1px solid var(--line); padding: 22px 24px; text-align: center;
  font-size: 12px; color: var(--ink-3);
}

/* ---------- Search modal ---------- */
.search-modal { position: fixed; inset: 0; z-index: 150; }
.search-modal[hidden] { display: none; }
.search-backdrop { position: absolute; inset: 0; background: rgba(10, 13, 22, .45); backdrop-filter: blur(2px); }
.search-panel {
  position: relative; max-width: 620px; margin: 10vh auto 0;
  background: var(--bg); border: 1px solid var(--line-2); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); overflow: hidden;
}
.search-input-row { display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.search-input-row svg { width: 17px; height: 17px; fill: none; stroke: var(--ink-3); stroke-width: 1.8; stroke-linecap: round; flex: none; }
.search-input-row input {
  flex: 1; border: 0; outline: 0; background: transparent;
  font: inherit; font-size: 15.5px; color: var(--ink);
}
.search-input-row input::placeholder { color: var(--ink-3); }
.search-esc {
  font: inherit; font-size: 11px; padding: 3px 7px; border-radius: 5px; cursor: pointer;
  background: var(--bg-3); border: 1px solid var(--line); color: var(--ink-3);
}
.search-results { max-height: 52vh; overflow-y: auto; padding: 7px; }
.search-empty { margin: 0; padding: 26px 16px; text-align: center; color: var(--ink-3); font-size: 13.5px; }
.search-result { display: block; padding: 9px 11px; border-radius: 8px; text-decoration: none; }
.search-result.active { background: var(--brand-soft); }
.search-result-head { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.search-result-title { font-size: 13.5px; font-weight: 640; color: var(--ink); }
.search-result-crumb { font-size: 12px; color: var(--ink-3); }
.search-result-crumb::before { content: "› "; }
.search-result-lock { font-size: 9.5px; opacity: .6; }
.search-result.locked .search-result-title { color: var(--ink-3); }
.search-result-snippet {
  margin: 2px 0 0; font-size: 12.5px; color: var(--ink-3); line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.search-result mark { background: color-mix(in srgb, var(--brand) 22%, transparent); color: inherit; border-radius: 2px; padding: 0 1px; }
.search-footer {
  display: flex; gap: 14px; padding: 9px 16px; border-top: 1px solid var(--line);
  background: var(--bg-2); font-size: 11.5px; color: var(--ink-3);
}
.search-footer kbd { margin-right: 3px; }
body.search-open { overflow: hidden; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .content-inner { grid-template-columns: minmax(0, 1fr); }
  .content-aside { display: none; }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .nav-toggle { display: flex; }
  .sidebar {
    position: fixed; left: 0; top: var(--topbar-h); bottom: 0; width: var(--sidebar-w);
    z-index: 70; background: var(--bg); transform: translateX(-100%);
    transition: transform .18s ease; height: auto;
  }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  body.sidebar-open { overflow: hidden; }
  .content { padding: 28px 20px 56px; }
  .content h1 { font-size: 26px; }
  .search-trigger { min-width: 0; }
  .search-trigger span, .search-trigger kbd { display: none; }
  .user-menu, .topbar-actions .btn-ghost { display: none; }
  .brand-text em { display: none; }
  .card-grid { grid-template-columns: 1fr; }
  .prev-next { flex-direction: column; }
  .prev-next-link.next { text-align: left; align-items: flex-start; }
}

/* ---------- Print / PDF ---------- */
@media print {
  .topbar, .sidebar, .content-aside, .prev-next, .site-footer,
  .search-modal, .gate-overlay, .skip-link, .page-meta .linklike { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .gate-loading .protected { visibility: visible !important; }
  .layout, .content-inner { display: block; max-width: none; }
  .content { padding: 0; }
  .content-body { max-width: none; }
  .content h1 { font-size: 20pt; }
  .content h2 { font-size: 14pt; page-break-after: avoid; border-top: 1px solid #ccc; }
  .content h3 { page-break-after: avoid; }
  .callout, .access-banner, table, .steps > li { page-break-inside: avoid; }
  .card-grid { grid-template-columns: 1fr 1fr; }
  a { color: #000; text-decoration: underline; }
  .content a[href^="/"]::after { content: " (" attr(href) ")"; font-size: 8pt; color: #555; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
}
