/* ============================================================
   Flexscada Scripting Docs — instrumentation-inspired theme
   Palette: graphite ink on cool paper, "trace green" accent
   (the color of the Q5's status LED and an oscilloscope trace),
   dark scope-screen code blocks.
   ============================================================ */

:root {
  --paper: #f5f6f4;
  --panel: #ffffff;
  --ink: #1c242c;
  --ink-soft: #4d5a66;
  --line: #dde2dd;
  --line-strong: #c3ccc3;
  --trace: #0e7a52;
  --trace-bright: #14a06c;
  --trace-dim: #e2f0e9;
  --amber: #b0680e;
  --danger: #b03a2e;

  --code-bg: #131a20;
  --code-text: #d7dee6;
  --code-comment: #66788a;
  --code-key: #7cc4ff;
  --code-str: #8fe3ae;
  --code-num: #f0b56c;
  --code-fn: #e8d074;

  --sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Consolas, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15.5px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
}
a { color: var(--trace); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: var(--mono); }
:focus-visible { outline: 2px solid var(--trace-bright); outline-offset: 2px; }
img { max-width: 100%; }

h1, h2, h3 { line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 1.9rem; font-weight: 700; }
h2 { font-size: 1.35rem; font-weight: 600; }

/* ---------- Header ---------- */
.site-header {
  background: var(--ink);
  color: #e9eef2;
  border-bottom: 3px solid var(--trace-bright);
}
.header-inner {
  max-width: 1280px; margin: 0 auto; padding: 0.55rem 1.25rem;
  display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 0.6rem; color: #fff; font-weight: 600; }
.brand:hover { text-decoration: none; }
.brand-wave { width: 84px; height: 20px; color: var(--trace-bright); flex: none; }
.brand-name { white-space: nowrap; font-size: 0.95rem; letter-spacing: 0.02em; }
.header-product {
  font-family: var(--mono); font-size: 0.85rem; color: #cfe8db;
  border: 1px solid #3a4650; border-radius: 4px; padding: 0.2rem 0.6rem;
}
.header-product:hover, .header-product.active { border-color: var(--trace-bright); color: #fff; text-decoration: none; }
.header-search { flex: 1; min-width: 180px; max-width: 420px; }
.header-search input {
  width: 100%; padding: 0.42rem 0.7rem; border-radius: 4px;
  border: 1px solid #3a4650; background: #222c35; color: #e9eef2;
  font-family: var(--sans); font-size: 0.88rem;
}
.header-search input::placeholder { color: #8595a3; }
.header-search input:focus { border-color: var(--trace-bright); outline: none; }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 0.6rem; }
.link-quiet { color: #8595a3; font-size: 0.85rem; }
.link-quiet:hover { color: #fff; }

.btn {
  display: inline-block; padding: 0.42rem 0.95rem; border-radius: 4px;
  background: var(--trace); color: #fff; border: 1px solid var(--trace);
  font-family: var(--sans); font-size: 0.88rem; font-weight: 500; cursor: pointer;
}
.btn:hover { background: var(--trace-bright); border-color: var(--trace-bright); text-decoration: none; }
.btn-ghost { background: transparent; color: inherit; border-color: currentColor; opacity: 0.85; }
.btn-ghost:hover { background: rgba(20, 160, 108, 0.12); color: inherit; opacity: 1; }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-full { width: 100%; }
.inline-form { display: inline; }

/* ---------- Splash ---------- */
.splash { max-width: 1100px; margin: 0 auto; padding: 3rem 1.25rem 5rem; }
.splash-hero { text-align: center; margin-bottom: 3rem; }
.hero-wave { width: min(680px, 100%); height: 58px; color: var(--trace); opacity: 0.9; }
.splash-hero h1 { font-size: 2.5rem; margin: 0.8rem 0 0.4rem; }
.splash-sub { color: var(--ink-soft); max-width: 620px; margin: 0 auto; }
.splash-cta { font-family: var(--mono); font-size: 0.85rem; color: var(--trace); margin-top: 1.4rem; text-transform: uppercase; letter-spacing: 0.08em; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.4rem; }
.product-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  overflow: hidden; color: var(--ink); transition: border-color 0.15s, box-shadow 0.15s;
  display: flex; flex-direction: column;
}
.product-card:hover { text-decoration: none; border-color: var(--trace); box-shadow: 0 4px 18px rgba(28, 36, 44, 0.08); }
.product-card-img { background: #fff; aspect-ratio: 16 / 8; display: grid; place-items: center; }
.product-card-img img { width: 100%; height: 100%; object-fit: contain; }
.product-card-placeholder { color: var(--trace-bright); font-size: 1.1rem; }
.product-card-body { padding: 1rem 1.2rem 1.2rem; }
.product-card-body h2 { margin: 0 0 0.3rem; font-size: 1.2rem; }
.product-card-body p { margin: 0 0 0.7rem; color: var(--ink-soft); font-size: 0.92rem; }
.product-card-go { font-family: var(--mono); font-size: 0.82rem; color: var(--trace); }

/* ---------- Docs layout ---------- */
.docs-layout { max-width: 1280px; margin: 0 auto; display: flex; align-items: flex-start; }
.sidebar {
  width: 280px; flex: none; padding: 1.4rem 1rem 3rem 1.25rem;
  position: sticky; top: 0; max-height: 100vh; overflow-y: auto;
  border-right: 1px solid var(--line); font-size: 0.9rem;
}
.sidebar-section { margin-bottom: 1.2rem; }
.sidebar-home { font-weight: 600; }
.sidebar-cat {
  font-family: var(--mono); font-size: 0.7rem; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--ink-soft); margin-bottom: 0.4rem;
  border-bottom: 1px solid var(--line); padding-bottom: 0.25rem;
}
.sidebar a { color: var(--ink); }
.sidebar a.active { color: var(--trace); font-weight: 600; }
.sidebar-class summary { cursor: pointer; list-style: none; padding: 0.12rem 0; }
.sidebar-class summary::before { content: '▸ '; color: var(--line-strong); font-size: 0.7rem; }
.sidebar-class[open] summary::before { content: '▾ '; color: var(--trace); }
.sidebar-class ul { list-style: none; margin: 0.15rem 0 0.4rem; padding-left: 1.1rem; border-left: 1px solid var(--line); }
.sidebar-class li { padding: 0.08rem 0; }
.sidebar-class .mono { font-size: 0.8rem; }
.sidebar-examples { list-style: none; margin: 0; padding: 0; }
.sidebar-examples li { padding: 0.15rem 0; }

.docs-main { flex: 1; min-width: 0; padding: 1.8rem 2rem 5rem; }

.breadcrumb { font-size: 0.82rem; color: var(--ink-soft); margin-bottom: 0.8rem; display: flex; gap: 0.45rem; flex-wrap: wrap; }
.breadcrumb a { color: var(--ink-soft); }
.breadcrumb a:hover { color: var(--trace); }

.product-head { display: flex; gap: 1.5rem; align-items: center; margin-bottom: 1rem; }
.product-head-img { width: 170px; border-radius: 8px; flex: none; }
.product-head h1 { margin: 0; }
.head-accent { color: var(--trace); font-weight: 500; }
.product-tagline { color: var(--ink-soft); margin: 0.3rem 0 0; }

.section-head {
  margin-top: 2.6rem; padding-bottom: 0.4rem; border-bottom: 2px solid var(--ink);
  font-family: var(--mono); font-size: 1.05rem; text-transform: uppercase; letter-spacing: 0.05em;
}

.cat-grid { display: grid; gap: 1.2rem; margin-top: 1.2rem; }
.cat-card { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--trace); border-radius: 6px; padding: 1.1rem 1.3rem; }
.cat-card h3 { margin: 0 0 0.2rem; }
.cat-desc { color: var(--ink-soft); margin: 0 0 0.6rem; font-size: 0.92rem; }
.cat-classes { list-style: none; margin: 0; padding: 0; }
.cat-classes > li { padding: 0.55rem 0; border-top: 1px dashed var(--line); }
.cat-classes > li:first-child { border-top: 0; }
.cat-class-link { font-family: var(--mono); font-weight: 600; }
.cat-class-summary { color: var(--ink-soft); font-size: 0.92rem; }
.cat-fn-chips { margin-top: 0.45rem; display: flex; flex-wrap: wrap; gap: 0.35rem; }
.chip {
  font-size: 0.76rem; padding: 0.14rem 0.55rem; border: 1px solid var(--line-strong);
  border-radius: 20px; color: var(--ink); background: var(--paper);
}
.chip:hover { border-color: var(--trace); color: var(--trace); text-decoration: none; }

.example-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; margin-top: 1.2rem; }
.example-card { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 0.95rem 1.1rem; color: var(--ink); }
.example-card:hover { border-color: var(--trace); text-decoration: none; }
.example-card h3 { margin: 0 0 0.35rem; font-size: 1rem; }
.example-card p { margin: 0; color: var(--ink-soft); font-size: 0.86rem; }

/* ---------- Class / function pages ---------- */
.class-title { margin-bottom: 0.2rem; }
.class-summary { color: var(--ink-soft); font-size: 1.05rem; margin-top: 0.2rem; }

.tags-row { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; margin: 0.6rem 0 1.2rem; }
.tags-label { font-family: var(--mono); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-soft); }
.hw-tag {
  font-family: var(--mono); font-size: 0.75rem; padding: 0.12rem 0.6rem;
  border-radius: 3px; background: var(--trace-dim); color: var(--trace); border: 1px solid transparent;
}
.hw-tag.current { border-color: var(--trace); font-weight: 600; }
a.hw-tag:hover { text-decoration: none; border-color: var(--trace); }
.tag-inherit { font-size: 0.78rem; color: var(--ink-soft); font-style: italic; }

.fn-index { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 0.8rem 1.2rem 0.8rem 2.4rem; margin: 1rem 0 2rem; font-size: 0.92rem; }
.fn-index li { padding: 0.12rem 0; }

.fn-entry { border-top: 2px solid var(--ink); margin-top: 2.4rem; padding-top: 1rem; }
.docs-main > .fn-entry:first-of-type, .docs-main .breadcrumb + .tags-row + .fn-entry { border-top: 0; margin-top: 0.5rem; }
.fn-name { margin: 0 0 0.6rem; font-size: 1.35rem; }
.fn-name a { color: var(--ink); }
.fn-name a:hover { color: var(--trace); }
.signature {
  background: var(--code-bg); color: var(--code-text); border-radius: 6px;
  border-left: 3px solid var(--trace-bright);
  padding: 0.7rem 1rem; font-family: var(--mono); font-size: 0.86rem; overflow-x: auto; margin: 0 0 0.8rem;
}
.fn-summary { font-size: 1.02rem; }
.fn-subhead {
  font-family: var(--mono); font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--trace); margin: 1.4rem 0 0.5rem;
}
.args-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; background: var(--panel); }
.args-table th {
  text-align: left; font-family: var(--mono); font-size: 0.7rem; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--ink-soft); border-bottom: 2px solid var(--ink);
  padding: 0.4rem 0.6rem;
}
.args-table td { border-bottom: 1px solid var(--line); padding: 0.45rem 0.6rem; vertical-align: top; }
.arg-name { font-weight: 600; }
.arg-type { color: var(--amber); font-size: 0.8rem; }
.ret-type {
  font-family: var(--mono); font-size: 0.8rem; background: var(--trace-dim);
  color: var(--trace); padding: 0.1rem 0.5rem; border-radius: 3px; margin-right: 0.4rem;
}

.related { margin-top: 3rem; border-top: 1px solid var(--line); padding-top: 1.2rem; }
.related h3 { font-size: 0.95rem; }

/* ---------- Code blocks ---------- */
.codeblock { position: relative; margin: 0.6rem 0 1rem; }
.codeblock pre, .doc-body pre {
  background: var(--code-bg); color: var(--code-text); border-radius: 6px;
  padding: 1rem 1.2rem; overflow-x: auto; font-size: 0.83rem; line-height: 1.55;
  margin: 0; font-family: var(--mono);
}
.doc-body pre { margin: 0.8rem 0 1.2rem; }
.doc-body code, p code, li code, .admin-help code, label code, small code {
  font-family: var(--mono); font-size: 0.85em; background: #e8ebe6;
  padding: 0.08em 0.35em; border-radius: 3px;
}
.doc-body pre code, .codeblock pre code { background: none; padding: 0; font-size: inherit; }
.copy-btn {
  position: absolute; top: 0.55rem; right: 0.6rem; z-index: 2;
  font-family: var(--mono); font-size: 0.7rem; padding: 0.22rem 0.6rem;
  background: #26313c; color: #aebac6; border: 1px solid #3a4650; border-radius: 4px; cursor: pointer;
}
.copy-btn:hover { color: #fff; border-color: var(--trace-bright); }
.copy-btn.copied { color: var(--trace-bright); border-color: var(--trace-bright); }

/* Syntax highlighting (applied client-side) */
.tok-c { color: var(--code-comment); font-style: italic; }
.tok-k { color: var(--code-key); }
.tok-s { color: var(--code-str); }
.tok-n { color: var(--code-num); }
.tok-f { color: var(--code-fn); }

/* ---------- Markdown doc bodies ---------- */
.doc-body { max-width: 78ch; }
.doc-body h1, .doc-body h2, .doc-body h3 { margin-top: 1.6rem; }
.doc-body blockquote {
  margin: 1rem 0; padding: 0.6rem 1rem; border-left: 3px solid var(--amber);
  background: #f7f1e4; color: #5c4a25; border-radius: 0 4px 4px 0;
}
.doc-body table { border-collapse: collapse; font-size: 0.9rem; }
.doc-body table th, .doc-body table td { border: 1px solid var(--line-strong); padding: 0.4rem 0.7rem; }
.doc-img { border: 1px solid var(--line); border-radius: 6px; background: #fff; padding: 4px; }
.pdf-badge {
  font-family: var(--mono); font-size: 0.62rem; background: var(--danger); color: #fff;
  padding: 0.05rem 0.35rem; border-radius: 3px; vertical-align: middle;
}

.search-count { color: var(--ink-soft); }
.search-list { list-style: none; padding: 0; }
.search-list li { padding: 0.7rem 0; border-bottom: 1px solid var(--line); }
.search-list p { margin: 0.2rem 0 0; color: var(--ink-soft); font-size: 0.9rem; }
.search-context { color: var(--ink-soft); font-size: 0.85rem; }

.empty-state { padding: 2.5rem; text-align: center; color: var(--ink-soft); background: var(--panel); border: 1px dashed var(--line-strong); border-radius: 8px; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); margin-top: 2rem; background: var(--panel); }
.footer-inner { max-width: 1280px; margin: 0 auto; padding: 1rem 1.25rem; display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; font-size: 0.82rem; color: var(--ink-soft); }

.error-main { max-width: 700px; margin: 0 auto; padding: 4rem 1.25rem; }

/* ---------- Admin ---------- */
.admin-header { border-bottom-color: var(--amber); }
.admin-nav { display: flex; gap: 0.2rem; flex-wrap: wrap; }
.admin-nav a { color: #aebac6; padding: 0.3rem 0.7rem; border-radius: 4px; font-size: 0.88rem; }
.admin-nav a:hover { color: #fff; text-decoration: none; }
.admin-nav a.active { color: #fff; background: #26313c; }
.admin-main { max-width: 1100px; margin: 0 auto; padding: 1.8rem 1.25rem 5rem; }
.admin-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.admin-hint { color: var(--ink-soft); font-size: 0.9rem; }
.admin-table { width: 100%; border-collapse: collapse; background: var(--panel); font-size: 0.9rem; }
.admin-table th { text-align: left; font-family: var(--mono); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); border-bottom: 2px solid var(--ink); padding: 0.5rem 0.6rem; }
.admin-table td { border-bottom: 1px solid var(--line); padding: 0.5rem 0.6rem; vertical-align: middle; }
.admin-table input, .admin-table select { padding: 0.3rem 0.5rem; border: 1px solid var(--line-strong); border-radius: 4px; font-family: inherit; font-size: 0.88rem; width: 100%; }
.row-actions { white-space: nowrap; display: flex; gap: 0.35rem; align-items: center; }
.thumb { width: 64px; border-radius: 4px; background: var(--ink); padding: 3px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; margin: 1.4rem 0 2rem; }
.stat-card { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 1rem 1.2rem; color: var(--ink); }
.stat-card:hover { border-color: var(--trace); text-decoration: none; }
.stat-num { display: block; font-size: 1.9rem; font-weight: 700; color: var(--trace); font-family: var(--mono); }
.admin-help { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 0.5rem 1.4rem 1rem; }

.admin-form { display: flex; flex-direction: column; gap: 1rem; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 1.5rem; }
.admin-form-main { max-width: 760px; }
.admin-form-main.wide { max-width: 980px; }
.admin-form label { display: flex; flex-direction: column; gap: 0.3rem; font-weight: 500; font-size: 0.92rem; }
.admin-form small { color: var(--ink-soft); font-weight: 400; }
.admin-form input[type="text"], .admin-form input:not([type]), .admin-form input[type="password"], .admin-form input[type="number"], .admin-form input[type="search"],
.admin-form select, .admin-form textarea {
  padding: 0.5rem 0.7rem; border: 1px solid var(--line-strong); border-radius: 4px;
  font-family: inherit; font-size: 0.92rem; background: #fff;
}
.admin-form textarea.mono, .admin-form input.mono { font-family: var(--mono); font-size: 0.84rem; }
.admin-form textarea.code-editor { background: var(--code-bg); color: var(--code-text); tab-size: 2; }
.admin-form input:focus, .admin-form textarea:focus, .admin-form select:focus { border-color: var(--trace); outline: none; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-actions { display: flex; gap: 0.6rem; }
.form-error { color: var(--danger); background: #f8e8e6; border: 1px solid #e5c1bc; padding: 0.6rem 0.9rem; border-radius: 4px; }
.form-ok { color: var(--trace); background: var(--trace-dim); border: 1px solid #bcdccd; padding: 0.6rem 0.9rem; border-radius: 4px; }
.tag-fieldset, .args-fieldset { border: 1px solid var(--line-strong); border-radius: 6px; padding: 0.8rem 1rem; }
.tag-fieldset legend, .args-fieldset legend { font-family: var(--mono); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-soft); padding: 0 0.4rem; }
.check-label { display: inline-flex !important; flex-direction: row !important; align-items: center; gap: 0.4rem !important; margin-right: 1.2rem; font-weight: 400 !important; }
.args-editor { width: 100%; border-collapse: collapse; margin-bottom: 0.6rem; }
.args-editor th { text-align: left; font-size: 0.72rem; font-family: var(--mono); text-transform: uppercase; color: var(--ink-soft); padding: 0.2rem 0.3rem; }
.args-editor td { padding: 0.2rem 0.3rem; }
.args-editor input { width: 100%; padding: 0.35rem 0.5rem; border: 1px solid var(--line-strong); border-radius: 4px; }
.args-editor .center { text-align: center; }

.media-upload { display: flex; gap: 0.8rem; align-items: center; flex-wrap: wrap; background: var(--panel); border: 1px dashed var(--line-strong); border-radius: 8px; padding: 1rem 1.2rem; margin: 1rem 0 1.6rem; }
.media-upload small { flex-basis: 100%; color: var(--ink-soft); }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }
.media-card { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.media-preview { aspect-ratio: 16/9; background: repeating-conic-gradient(#eceeeb 0% 25%, #fff 0% 50%) 50% / 20px 20px; display: grid; place-items: center; }
.media-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.media-type { font-family: var(--mono); font-weight: 700; color: var(--ink-soft); letter-spacing: 0.1em; }
.media-meta { padding: 0.7rem 0.8rem; display: flex; flex-direction: column; gap: 0.4rem; }
.media-name { font-weight: 600; font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-size { color: var(--ink-soft); font-size: 0.78rem; }
.media-embed { font-size: 0.72rem; padding: 0.3rem 0.5rem; border: 1px solid var(--line); border-radius: 4px; background: var(--paper); color: var(--ink-soft); }

/* ---------- Login ---------- */
.login-body { background: var(--ink); min-height: 100vh; display: grid; place-items: center; }
.login-main { width: 100%; display: grid; place-items: center; padding: 1rem; }
.login-card { background: var(--panel); border-radius: 10px; padding: 2.2rem 2.4rem; width: min(400px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,0.4); }
.login-card .brand-wave { color: var(--trace); width: 120px; height: 26px; }
.login-card h1 { font-size: 1.3rem; margin: 0.6rem 0 1.2rem; }
.login-card form { display: flex; flex-direction: column; gap: 1rem; }
.login-card label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.9rem; font-weight: 500; }
.login-card input { padding: 0.55rem 0.7rem; border: 1px solid var(--line-strong); border-radius: 4px; font-size: 0.95rem; }
.login-back { margin: 1.2rem 0 0; font-size: 0.85rem; }

/* ---------- Print view ---------- */
.print-body { background: #fff; }
.print-toolbar {
  position: sticky; top: 0; z-index: 10; background: var(--ink); color: #e9eef2;
  display: flex; align-items: center; gap: 1rem; padding: 0.6rem 1.25rem; flex-wrap: wrap;
}
.print-hint { font-size: 0.82rem; color: #8595a3; flex: 1; }
.print-main { max-width: 880px; margin: 0 auto; padding: 2rem 1.5rem 5rem; }
.print-cover { text-align: center; padding: 4rem 0 3rem; border-bottom: 3px solid var(--ink); margin-bottom: 2rem; }
.print-cover h1 { font-size: 2.6rem; margin: 1rem 0 0.2rem; }
.print-cover-sub { font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.15em; color: var(--trace); font-size: 1rem; }
.print-cover-img { max-width: 90%; margin-top: 1.5rem; }
.print-cover-date { color: var(--ink-soft); font-size: 0.85rem; }
.print-toc { border-bottom: 1px solid var(--line); padding-bottom: 1.5rem; margin-bottom: 2rem; }
.print-toc ol { line-height: 1.9; }
.print-cat-head {
  font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.06em;
  border-bottom: 2px solid var(--ink); padding-bottom: 0.4rem; margin-top: 3rem;
}
.print-class { margin-top: 2rem; }
.print-class > h3 { font-size: 1.4rem; border-left: 4px solid var(--trace); padding-left: 0.7rem; }
.print-example { margin-top: 2.4rem; page-break-inside: avoid; }

@media print {
  .no-print, .copy-btn { display: none !important; }
  body { font-size: 11.5px; }
  .print-main { max-width: none; padding: 0; }
  .print-cover { page-break-after: always; border-bottom: 0; }
  .print-toc { page-break-after: always; }
  .print-section h2 { page-break-before: always; }
  .fn-entry, .print-example .codeblock { page-break-inside: avoid; }
  .codeblock pre, .doc-body pre, .signature { background: #f2f4f2 !important; color: #1c242c !important; border: 1px solid #ccc; white-space: pre-wrap; word-break: break-word; }
  .tok-c { color: #6a737d; } .tok-k { color: #005cc5; } .tok-s { color: #0a7a3d; } .tok-n { color: #a35200; } .tok-f { color: #6f42c1; }
  a { color: inherit; text-decoration: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .docs-layout { flex-direction: column; }
  .sidebar { position: static; width: 100%; max-height: none; border-right: 0; border-bottom: 1px solid var(--line); }
  .docs-main { padding: 1.4rem 1.1rem 4rem; }
  .form-row { grid-template-columns: 1fr; }
  .product-head { flex-direction: column; align-items: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}

/* ---------- Admin reordering (drag & drop / up-down) ---------- */
.sort-cell {
  width: 2rem;
  white-space: nowrap;
  padding-right: 0.25rem !important;
  vertical-align: middle;
}
.sort-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.4rem;
  height: 1.8rem;
  color: var(--ink-faint, #8a97a3);
  cursor: grab;
  border-radius: 4px;
  vertical-align: middle;
}
.sort-handle:hover { color: var(--accent, #0e7a52); background: rgba(14, 122, 82, 0.08); }
.sort-handle:active { cursor: grabbing; }
tr.dragging { opacity: 0.45; }
tr.dragging td { background: rgba(14, 122, 82, 0.06); }
tr.sort-flash td { animation: sortFlash 0.5s ease-out; }
@keyframes sortFlash {
  from { background: rgba(20, 160, 108, 0.22); }
  to { background: transparent; }
}
.admin-table tr.group-row td {
  background: var(--paper-deep, #e9ece8);
  color: var(--ink-soft, #4d5a66);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.35rem 0.75rem;
  border-top: 1px solid var(--rule, #d7dcd9);
}
.sort-toast {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  background: var(--ink, #1c242c);
  color: #eef3f0;
  padding: 0.5rem 0.9rem;
  border-radius: 6px;
  font-size: 0.8rem;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
  z-index: 200;
  box-shadow: 0 4px 16px rgba(16, 24, 32, 0.25);
}
.sort-toast.show { opacity: 1; transform: translateY(0); }
.sort-toast.error { background: #8c2f2f; }
@media print { .sort-cell, .sort-toast { display: none !important; } }

/* ---------- Categories page ---------- */
.cat-table td { vertical-align: middle; }
.cat-table .col-name { width: 16rem; }
.cat-table .col-actions { width: 11rem; }
.cat-table input {
  width: 100%;
  box-sizing: border-box;
}
.cat-table .row-actions {
  white-space: nowrap;
  text-align: right;
}
.cat-table .row-actions .btn { margin-left: 0.35rem; }
.add-bar {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  background: var(--paper-deep, #eef0ec);
  border: 1px dashed var(--rule, #cdd4d0);
  border-radius: 8px;
}
.add-bar-form {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}
.add-bar-form input[name="name"] { flex: 0 0 16rem; }
.add-bar-form input[name="description"] { flex: 1; }
@media (max-width: 720px) {
  .add-bar-form { flex-wrap: wrap; }
  .add-bar-form input[name="name"] { flex: 1 1 100%; }
}

/* ---------- Inline edit links (visible when logged in) ---------- */
.edit-link {
  display: inline-block;
  margin-left: 0.6rem;
  padding: 0.1rem 0.5rem;
  font-family: var(--font-sans, "IBM Plex Sans", sans-serif);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  vertical-align: middle;
  color: var(--accent, #0e7a52);
  background: rgba(14, 122, 82, 0.07);
  border: 1px solid rgba(14, 122, 82, 0.25);
  border-radius: 999px;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.edit-link:hover {
  background: rgba(14, 122, 82, 0.14);
  border-color: var(--accent, #0e7a52);
  text-decoration: none;
}
@media print { .edit-link { display: none !important; } }

.help-code {
  background: var(--ink, #1c242c);
  color: #d7e3dc;
  padding: 0.7rem 0.9rem;
  border-radius: 6px;
  font-size: 0.78rem;
  line-height: 1.5;
  overflow-x: auto;
}

/* ---------- Auto-linked code references ---------- */
a.code-link { text-decoration: none; }
a.code-link code {
  color: var(--accent, #0e7a52);
  border-bottom: 1px dotted rgba(14, 122, 82, 0.55);
  transition: border-color 0.12s ease, background 0.12s ease;
}
a.code-link:hover code {
  border-bottom-style: solid;
  border-bottom-color: var(--accent, #0e7a52);
  background: rgba(14, 122, 82, 0.08);
}
@media print {
  a.code-link code { color: inherit; border-bottom: none; }
}

/* ---------- Versioning ---------- */
.version-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.5rem 1.25rem;
  background: #3a3323;
  color: #f0e6c8;
  font-size: 0.82rem;
}
.version-banner a { color: #ffd97a; text-decoration: none; font-weight: 600; white-space: nowrap; }
.version-banner a:hover { text-decoration: underline; }
.release-note { margin: 0.4rem 0 0.6rem; font-size: 0.8rem; color: var(--ink-soft, #4d5a66); }
.release-note p { margin: 0.2rem 0; }
.version-archive { margin-top: 3rem; }
.archive-sub { color: var(--ink-soft, #4d5a66); max-width: 46rem; }
.version-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; margin-top: 1rem; }
.version-card {
  display: block;
  padding: 1rem 1.1rem;
  background: var(--card, #fff);
  border: 1px solid var(--rule, #d7dcd9);
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.version-card:hover { border-color: var(--accent, #0e7a52); box-shadow: 0 3px 14px rgba(16,24,32,0.07); text-decoration: none; }
.version-card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.75rem; }
.version-label { font-weight: 600; color: var(--accent, #0e7a52); }
.version-date, .version-meta { font-size: 0.72rem; color: var(--ink-faint, #8a97a3); }
.version-desc { margin: 0.5rem 0; font-size: 0.8rem; color: var(--ink-soft, #4d5a66); }
.version-desc p { margin: 0.25rem 0; }
.version-go { font-size: 0.78rem; font-weight: 600; color: var(--accent, #0e7a52); }
.archive-return { margin-top: 2rem; }
.admin-card {
  background: var(--card, #fff);
  border: 1px solid var(--rule, #d7dcd9);
  border-radius: 10px;
  padding: 1.1rem 1.25rem;
  margin: 1rem 0;
}
.admin-card h2 { margin-top: 0; font-size: 1.05rem; }
.admin-subhead { margin-top: 2rem; }
.version-admin-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.version-edit-form { margin-top: 0.75rem; border-top: 1px dashed var(--rule, #d7dcd9); padding-top: 0.75rem; }
@media print { .version-banner { display: none !important; } }


/* Product/version cards are divs (descriptions may contain links); the
   image, title and CTA are the clickable areas. */
.product-card-img { display: block; text-decoration: none; }
.product-card-body h2 a { color: inherit; text-decoration: none; }
.product-card-body h2 a:hover { color: var(--accent, #0e7a52); }
a.product-card-go { display: inline-block; text-decoration: none; }
a.product-card-go:hover { text-decoration: underline; }
.product-card:hover { border-color: var(--accent, #0e7a52); box-shadow: 0 3px 14px rgba(16,24,32,0.07); }
a.version-label { text-decoration: none; }
a.version-label:hover { text-decoration: underline; }
a.version-go { display: inline-block; text-decoration: none; }
a.version-go:hover { text-decoration: underline; }
.release-note code { font-size: 0.9em; }

/* Versions admin page */
.admin-card .admin-form { border: 0; padding: 0; background: none; }
.version-admin-card .row-actions { white-space: nowrap; }
