/* OpenWiring · manuale sul sito (chiaro o scuro come il sistema) */
:root {
  --bg: #ffffff; --bg-2: #f6f8fb; --panel: #ffffff; --line: #e4e8ef; --line-2: #d3d9e3;
  --text: #18202c; --muted: #5a6577; --dim: #8a94a5; --accent: #0b84c6; --accent-soft: rgba(11, 132, 198, .09);
  --code-bg: #f1f4f8; --top: rgba(255, 255, 255, .85); --shadow: 0 10px 40px -12px rgba(16, 24, 40, .25);
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0d13; --bg-2: #0e131b; --panel: #111722; --line: #1d2532; --line-2: #2a3444;
    --text: #e6ebf2; --muted: #9aa5b6; --dim: #6b7587; --accent: #46c8f5; --accent-soft: rgba(70, 200, 245, .1);
    --code-bg: #151c28; --top: rgba(10, 13, 19, .82); --shadow: 0 10px 40px -12px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { scroll-padding-top: 80px; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.7 Inter, system-ui, -apple-system, 'Segoe UI', sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

.top {
  position: sticky; top: 0; z-index: 30; height: 60px; display: flex; align-items: center; gap: 16px; padding: 0 20px;
  background: var(--top); backdrop-filter: saturate(160%) blur(12px); -webkit-backdrop-filter: saturate(160%) blur(12px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand img { width: 26px; height: 26px; }
.brand span { font-weight: 500; color: var(--muted); padding-left: 10px; border-left: 1px solid var(--line-2); }
.search { position: relative; margin-left: auto; width: min(380px, 40vw); }
.search input { width: 100%; height: 36px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--bg-2); color: var(--text); padding: 0 40px 0 12px; font: inherit; font-size: 14px; outline: none; }
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search kbd { position: absolute; right: 9px; top: 8px; font: 11px var(--mono); color: var(--dim); border: 1px solid var(--line-2); border-radius: 5px; padding: 1px 6px; }
#results { position: absolute; top: 44px; right: 0; width: min(560px, 92vw); max-height: 70vh; overflow: auto; background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; }
#results a { display: block; padding: 10px 12px; border-radius: 8px; color: var(--text); }
#results a:hover, #results a.sel { background: var(--accent-soft); text-decoration: none; }
#results small { display: block; color: var(--dim); font-size: 12px; }
#results p { margin: 2px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
#results mark { background: rgba(243, 169, 59, .3); color: inherit; border-radius: 3px; padding: 0 1px; }
#results .none { padding: 14px; color: var(--dim); font-size: 14px; }
.lang { height: 36px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--bg-2); color: var(--text); padding: 0 8px; font: inherit; font-size: 14px; }
.gh { color: var(--muted); display: flex; }
.gh:hover { color: var(--text); }
.menu-btn { display: none; width: 36px; height: 36px; border: 0; background: none; cursor: pointer; padding: 0; position: relative; }
.menu-btn span, .menu-btn span::before, .menu-btn span::after { position: absolute; left: 8px; width: 20px; height: 2px; background: var(--text); border-radius: 2px; content: ''; }
.menu-btn span { top: 17px; } .menu-btn span::before { left: 0; top: -6px; } .menu-btn span::after { left: 0; top: 6px; }

.side {
  position: fixed; top: 60px; bottom: 0; left: 0; width: 280px; overflow-y: auto; padding: 20px 12px 40px;
  border-right: 1px solid var(--line); background: var(--bg);
}
.side a { display: flex; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--muted); font-size: 14.5px; line-height: 1.4; }
.side a:hover { background: var(--bg-2); color: var(--text); text-decoration: none; }
.side a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side .n { font: 12px/1.7 var(--mono); color: var(--dim); min-width: 18px; text-align: right; }
.side a.on .n { color: var(--accent); }

main { margin-left: 280px; display: flex; gap: 40px; justify-content: center; padding: 40px 32px 80px; }
.doc { min-width: 0; max-width: 820px; flex: 1; }
.toc { position: sticky; top: 92px; align-self: flex-start; width: 220px; flex: none; font-size: 13.5px; max-height: calc(100vh - 120px); overflow-y: auto; }
.toc p { margin: 0 0 10px; font: 600 12px var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--dim); }
.toc a { display: block; color: var(--muted); padding: 4px 0 4px 12px; border-left: 1px solid var(--line); line-height: 1.4; }
.toc a:hover { color: var(--text); text-decoration: none; border-left-color: var(--muted); }
.toc a.on { color: var(--accent); border-left-color: var(--accent); }

.doc h1 { font-size: clamp(30px, 4vw, 40px); line-height: 1.15; letter-spacing: -.025em; margin: 0 0 24px; }
.doc h2 { font-size: 25px; letter-spacing: -.02em; margin: 52px 0 14px; padding-top: 8px; border-top: 1px solid var(--line); padding-top: 28px; }
.doc h3 { font-size: 19px; margin: 34px 0 10px; }
.doc h4 { font-size: 16px; margin: 26px 0 8px; }
.doc h1, .doc h2, .doc h3, .doc h4 { position: relative; }
.anchor { position: absolute; left: -22px; color: var(--dim); opacity: 0; font-weight: 400; }
h1:hover .anchor, h2:hover .anchor, h3:hover .anchor, h4:hover .anchor { opacity: 1; text-decoration: none; }
.doc p, .doc li { color: var(--text); }
.doc img { max-width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--line); box-shadow: var(--shadow); margin: 8px 0; background: #fff; }
.doc p:has(> img) + p > em:only-child { display: block; text-align: center; color: var(--muted); font-size: 14px; margin-top: -6px; }
.doc code { font: .88em var(--mono); background: var(--code-bg); border: 1px solid var(--line); padding: 1px 6px; border-radius: 5px; }
.doc pre { background: var(--code-bg); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; overflow: auto; font-size: 13.5px; line-height: 1.6; }
.doc pre code { background: none; border: 0; padding: 0; }
.doc blockquote { margin: 20px 0; padding: 12px 18px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 10px 10px 0; color: var(--muted); }
.doc blockquote p { margin: 6px 0; color: inherit; }
.table-wrap { overflow-x: auto; margin: 18px 0; border: 1px solid var(--line); border-radius: 10px; }
.doc table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
.doc th, .doc td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.doc th { background: var(--bg-2); font-weight: 600; white-space: nowrap; }
.doc tr:last-child td { border-bottom: 0; }
.doc kbd { font: 12px var(--mono); border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 64px; }
.pager a { border: 1px solid var(--line-2); border-radius: 12px; padding: 14px 18px; color: var(--text); font-weight: 600; }
.pager a:hover { border-color: var(--accent); text-decoration: none; }
.pager small { display: block; color: var(--dim); font-weight: 500; font-size: 12.5px; margin-bottom: 2px; }
.pager .next { text-align: right; }
.edit { margin-top: 28px; font-size: 13px; color: var(--dim); }
.edit a { color: var(--muted); }
.scrim { display: none; }

@media (max-width: 1200px) { .toc { display: none; } }
@media (max-width: 860px) {
  .menu-btn { display: block; }
  .brand span { display: none; }
  .side { transform: translateX(-100%); transition: transform .25s ease; z-index: 40; width: 290px; box-shadow: var(--shadow); }
  body.nav-open .side { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 60px 0 0; background: rgba(0, 0, 0, .35); z-index: 35; }
  main { margin-left: 0; padding: 28px 16px 64px; }
  .search { width: auto; flex: 1; }
  .search kbd { display: none; }
  .top { gap: 10px; padding: 0 12px; }
  .gh { display: none; }
  .anchor { display: none; }
  .pager { grid-template-columns: 1fr; }
}
@media (max-width: 480px) { .brand b { display: none; } .search { min-width: 0; } }
