/* ==========================================================================
   Dl4All: modern theme for DataLife Engine
   Loaded after css/engine.css: anything here overrides the engine styles.
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  --bg: #eef2f5;
  --surface: #ffffff;
  --surface-2: #f5f8fa;
  --ink: #15222c;
  --ink-2: #33444f;
  --muted: #5f707c;
  --line: #d9e1e7;
  --line-strong: #c3ced6;
  --brand: #0a6aa1;          /* evolution of the original #00659a */
  --brand-hover: #085784;
  --brand-soft: #e3f0f8;
  --band: #0b2f47;           /* header band */
  --band-2: #0e3a58;
  --band-ink: #e8f1f7;
  --band-muted: #9fbbd0;
  --cat: #3f8a1c;            /* category green, from the original #6BAD23 */
  --ok: #2f8a3a;
  --warn: #b5541c;
  --bad: #c23a2b;
  --focus: #f0a81c;

  --radius-s: 6px;
  --radius: 10px;
  --radius-l: 14px;
  --font: "Archivo", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --wrap: 1360px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c151c;
    --surface: #131f28;
    --surface-2: #192833;
    --ink: #e4ecf2;
    --ink-2: #c3d0da;
    --muted: #8ea0ad;
    --line: #233441;
    --line-strong: #2f4555;
    --brand: #4fa9de;
    --brand-hover: #74bce6;
    --brand-soft: #16354a;
    --band: #08202f;
    --band-2: #0c2a3e;
    --cat: #8cc456;
    --ok: #63c072;
    --warn: #e59156;
    --bad: #ef6f60;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c151c;
  --surface: #131f28;
  --surface-2: #192833;
  --ink: #e4ecf2;
  --ink-2: #c3d0da;
  --muted: #8ea0ad;
  --line: #233441;
  --line-strong: #2f4555;
  --brand: #4fa9de;
  --brand-hover: #74bce6;
  --brand-soft: #16354a;
  --band: #08202f;
  --band-2: #0c2a3e;
  --cat: #8cc456;
  --ok: #63c072;
  --warn: #e59156;
  --bad: #ef6f60;
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 16px; }
html, body { height: auto; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; }
a { color: var(--brand); text-decoration: none; font: inherit; }
a:hover { color: var(--brand-hover); text-decoration: underline; text-underline-offset: 2px; }
p { margin: 0 0 .9em; }
h1, h2, h3, h4, h5 { color: var(--ink); font-weight: 700; line-height: 1.25; margin: 0 0 .5em; padding: 0; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.15rem; }
table { border-collapse: collapse; }
svg { width: 1em; height: 1em; flex: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--brand); color: #fff; }

.visually-hidden {
  position: absolute !important; 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: 12px; top: -60px; z-index: 1000; background: var(--focus); color: #111; padding: 8px 14px; border-radius: var(--radius-s); font-weight: 700; }
.skip-link:focus { top: 12px; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 20px; }
.dd-muted { color: var(--muted); }

/* ---------- Buttons ---------- */
.btn-primary, .btn-ghost, .link-btn,
.fbutton, .bbcodes, .btn, .ui-button, button.vresult {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 18px;
  border-radius: var(--radius-s);
  font: 600 14px/1 var(--font);
  cursor: pointer; text-decoration: none !important;
  box-shadow: none; white-space: nowrap;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn-primary, .fbutton, .btn, .bbcodes, .ui-button {
  background: var(--brand); color: #fff !important; border: 1px solid var(--brand);
}
.btn-primary:hover, .fbutton:hover, .btn:hover, .bbcodes:hover, .ui-button:hover {
  background: var(--brand-hover); border-color: var(--brand-hover); color: #fff;
}
.btn-ghost, button.vresult {
  background: transparent; color: var(--brand) !important; border: 1px solid var(--line-strong);
}
.btn-ghost:hover { border-color: var(--brand); background: var(--brand-soft); }
.link-btn { background: none; border: 0; padding: 0; height: auto; color: var(--brand); font-weight: 500; }
.link-btn:hover { text-decoration: underline !important; }
.btn-lg { height: 46px; padding: 0 26px; font-size: 15px; }
.btn-block { width: 100%; }

/* ---------- Header ---------- */
.site-header { background: var(--band); color: var(--band-ink); position: relative; z-index: 50; }
.header-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center;
  gap: 28px; padding-top: 14px; padding-bottom: 14px;
}
.brand { display: block; line-height: 0; }
.brand img { width: 150px; height: auto; }
.header-row .drawer-toggle { display: none; }

.header-search {
  position: relative; display: flex; align-items: center;
  max-width: 720px; width: 100%; justify-self: center;
  background: #fff; border-radius: var(--radius); padding: 4px;
  box-shadow: 0 0 0 1px rgba(255,255,255,.08), 0 6px 18px rgba(0,0,0,.18);
}
.header-search .hs-icon { position: absolute; left: 16px; width: 20px; height: 20px; color: #6b7c88; pointer-events: none; }
.header-search input[type="search"] {
  flex: 1; min-width: 0; width: auto; height: 44px;
  border: 0 !important; box-shadow: none !important; background: transparent !important;
  padding: 0 12px 0 46px; font: 500 16px var(--font); color: #15222c;
}
.header-search input[type="search"]::placeholder { color: #7d8c96; }
.header-search .hs-btn {
  height: 44px; padding: 0 22px; border: 0; border-radius: 7px;
  background: var(--brand); color: #fff; font: 700 15px var(--font); cursor: pointer;
}
:root[data-theme="dark"] .header-search .hs-btn { background: #0a6aa1; }
.header-search .hs-btn:hover { background: #085784; }

.header-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px;
  border-radius: var(--radius-s); border: 1px solid rgba(255,255,255,.18);
  background: transparent; color: var(--band-ink); cursor: pointer; padding: 0;
}
.icon-btn:hover { background: rgba(255,255,255,.08); }
.icon-btn svg { width: 20px; height: 20px; }
.theme-toggle .ico-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .ico-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .ico-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .ico-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .ico-moon { display: none; }
}

.site-header .btn-ghost { color: var(--band-ink) !important; border-color: rgba(255,255,255,.28); }
.site-header .btn-ghost:hover { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.5); }
.site-header .btn-primary { background: #fff; border-color: #fff; color: var(--band) !important; }
.site-header .btn-primary:hover { background: #dcebf5; border-color: #dcebf5; }

/* Section bar */
.topnav { background: var(--band-2); border-top: 1px solid rgba(255,255,255,.06); }
.topnav-row { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.topnav-row::-webkit-scrollbar { display: none; }
.topnav a {
  flex: none; padding: 12px 14px; color: var(--band-muted);
  font-weight: 600; font-size: 14px; border-bottom: 3px solid transparent;
}
.topnav a:hover { color: #fff; text-decoration: none; }
.topnav a[aria-current="page"] { color: #fff; border-bottom-color: var(--focus); }

/* ---------- Dropdowns (login + user menu) ---------- */
.dropdown { position: relative; }
.dropdown > summary { list-style: none; cursor: pointer; }
.dropdown > summary::-webkit-details-marker { display: none; }
.dropdown-panel {
  position: absolute; right: 0; top: calc(100% + 10px); width: 300px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 18px 40px rgba(5, 25, 40, .25);
  padding: 8px; z-index: 100;
}
.dropdown[open] .dropdown-panel { animation: dd-in .14s ease-out; }
@keyframes dd-in { from { opacity: 0; transform: translateY(-4px); } }

.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 12px 4px 4px; border-radius: 999px;
  border: 1px solid rgba(255,255,255,.2); color: var(--band-ink); font-weight: 600;
}
.user-chip:hover { background: rgba(255,255,255,.08); }
.user-chip img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: #fff; }
.user-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dd-head { display: flex; align-items: center; gap: 12px; padding: 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.dd-head img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; }
.dd-head strong { display: block; }
.dd-head span { color: var(--muted); font-size: 13px; }
.dd-links { list-style: none; margin: 0; padding: 0; }
.dd-links a {
  display: flex; align-items: center; gap: 12px; padding: 9px 10px;
  border-radius: var(--radius-s); color: var(--ink); font-weight: 500;
}
.dd-links a:hover { background: var(--surface-2); text-decoration: none; }
.dd-links svg { width: 18px; height: 18px; color: var(--muted); }
.dd-sep { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 6px; }
.badge {
  display: inline-grid; place-items: center; min-width: 22px; height: 20px; padding: 0 6px;
  background: var(--brand); color: #fff; border-radius: 999px; font-size: 12px; font-weight: 700; margin-left: auto;
}

.login-panel { width: 320px; padding: 20px; }
.login-panel h2 { font-size: 1.15rem; margin-bottom: 14px; }
.login-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 14px; font-size: 14px; }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr) 290px;
  grid-template-areas: "left main right";
  gap: 28px; padding-top: 28px; padding-bottom: 40px; align-items: start;
}
.sidebar-left { grid-area: left; position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; scrollbar-width: thin; }
.content { grid-area: main; min-width: 0; }
.sidebar-right { grid-area: right; display: grid; gap: 20px; }
.drawer-head, .drawer-backdrop { display: none; }

/* ---------- Panels ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px;
}
.panel-title { font-size: 1rem; font-weight: 700; margin: 0 0 12px; }
.panel-note { color: var(--muted); font-size: 14px; margin-bottom: 12px; }
.page-panel { margin-bottom: 20px; padding: 24px; }
.page-title { font-size: 1.6rem; font-stretch: 88%; margin-bottom: 18px; }

/* Category tree */
.cat-tree { padding: 12px; }
.cat-tree .panel-title { padding: 6px 8px 0; }
.cat-tree a { color: var(--ink-2); }
.cat-tree a:hover { color: var(--brand); text-decoration: none; }
.cat-root, .cat-tree summary { display: flex; align-items: center; padding: 7px 8px; border-radius: var(--radius-s); font-weight: 600; }
.cat-root:hover, .cat-tree summary:hover { background: var(--surface-2); }
.cat-tree summary { list-style: none; cursor: pointer; justify-content: space-between; }
.cat-tree summary::-webkit-details-marker { display: none; }
.cat-tree summary::after {
  content: ""; width: 8px; height: 8px; margin-right: 4px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg); transition: transform .15s;
}
.cat-tree details[open] > summary::after { transform: rotate(45deg); }
.cat-tree ul { list-style: none; margin: 2px 0 6px 14px; padding: 0 0 0 10px; border-left: 2px solid var(--line); }
.cat-tree li a { display: block; padding: 5px 8px; font-size: 14px; border-radius: var(--radius-s); font-weight: 400; }
.cat-tree li a:hover { background: var(--surface-2); }
.cat-tree a[aria-current="page"] { color: var(--brand); background: var(--brand-soft); }
.cat-sitemap { display: block; margin-top: 10px; padding: 10px 8px 4px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted) !important; }

/* Top list */
/* Most popular: locandine + titolo */
.top-list { margin: 0; padding: 0; list-style: none; counter-reset: top; display: grid; gap: 4px; }
.top-item {
  counter-increment: top; position: relative;
  display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 12px; align-items: center;
  padding: 6px; margin: 0 -6px; border-radius: var(--radius-s);
}
.top-item:hover { background: var(--surface-2); }
.top-poster {
  position: relative; display: block; width: 58px; aspect-ratio: 2 / 3;
  border-radius: 6px; overflow: hidden; background: var(--surface-2);
  box-shadow: 0 0 0 1px var(--line);
}
.top-poster img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s ease; }
.top-item:hover .top-poster img { transform: scale(1.05); }
.top-poster::after {
  content: counter(top); position: absolute; left: 0; top: 0;
  min-width: 20px; height: 20px; padding: 0 5px; display: grid; place-items: center;
  background: var(--band); color: #fff; font-size: 11.5px; font-weight: 700;
  border-bottom-right-radius: 6px; font-variant-numeric: tabular-nums;
}
.top-item:nth-child(-n+3) .top-poster::after { background: var(--focus); color: #1b1300; }
.top-info { min-width: 0; }
.top-title {
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  color: var(--ink); font-size: 14px; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere;
}
.top-title:hover { color: var(--brand); text-decoration: none; }
/* tutta la riga cliccabile */
.top-title::before { content: ""; position: absolute; inset: 0; }
.top-meta { display: flex; gap: 12px; margin-top: 4px; font-size: 12.5px; color: var(--muted); }
.top-meta span { display: inline-flex; align-items: center; gap: 4px; }
.top-meta svg { width: 13px; height: 13px; }
.link-list { margin: 0; padding-left: 18px; }

/* Newsletter (overrides old Mailchimp styles) */
#mc_embed_signup { background: none; font: inherit; clear: none; }
#mc_embed_signup form { padding: 0; display: grid; gap: 10px; }
#mc_embed_signup input.email { width: 100% !important; margin: 0; padding: 0 12px; text-indent: 0; }

/* ---------- Intro / category head ---------- */
.intro { margin-bottom: 22px; }
.intro h1 { font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.3rem); font-stretch: 85%; letter-spacing: -.01em; margin-bottom: 8px; }
.intro p { color: var(--muted); margin: 0; }
.cat-head { margin-bottom: 22px; }
.cat-head h1 { font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.2rem); font-stretch: 85%; margin-bottom: 6px; }
.cat-desc { color: var(--muted); max-width: 75ch; }
.about-block { margin-top: 36px; padding-top: 24px; border-top: 1px solid var(--line); color: var(--ink-2); max-width: 78ch; font-size: 14.5px; }
.about-block h2 { font-size: 1.1rem; }

/* Breadcrumb */
.speedbar { font-size: 13.5px; color: var(--muted); margin-bottom: 16px; }
.speedbar a { color: var(--muted); }
.speedbar a:hover { color: var(--brand); }

/* ---------- Stories ---------- */
.story {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 18px; overflow: hidden;
}
.story-head { padding: 20px 24px 0; }
.story-cat { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--cat); margin-bottom: 6px; }
.story-cat svg { width: 15px; height: 15px; }
.story-cat a { color: var(--cat); }
.story-title { font-size: 1.4rem; font-stretch: 88%; line-height: 1.2; letter-spacing: -.005em; margin: 0 0 10px; overflow-wrap: anywhere; }
.story-title a { color: var(--ink); }
.story-title a:hover { color: var(--brand); text-decoration: none; }
.story-full .story-title { font-size: clamp(1.6rem, 1.25rem + 1.2vw, 2.2rem); font-stretch: 85%; }
.story-meta { display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--muted); font-size: 13.5px; }
.story-meta span, .story-meta a { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.story-meta a:hover { color: var(--brand); }
.story-meta svg { width: 15px; height: 15px; }
.meta-edit a { color: var(--brand) !important; }

.story-text { padding: 16px 24px 4px; color: var(--ink-2); overflow-wrap: anywhere; display: flow-root; }
.story-text img { border-radius: var(--radius-s); }

/* Ridimensionamento immagini articoli: non escono mai dalla colonna, anche con
   width/height o style inline; le proporzioni restano corrette. */
.story-text img,
.comment-text img {
  max-width: 100% !important;
  height: auto !important;
  object-fit: contain;
  vertical-align: middle;
}
/* Nelle anteprime le immagini molto alte (screenshot lunghi) vengono limitate */
.story-short .story-text img { max-height: 420px; }
/* Nell'articolo completo: al massimo l'altezza dello schermo */
.story-full .story-text img { max-height: 85vh; }
.comment-text img { max-height: 360px; }
/* Immagini ridotte: cliccabili per vederle a dimensione piena */
.story-text img.is-zoomable, .comment-text img.is-zoomable { cursor: zoom-in; }
.story-text img.is-zoomable:hover, .comment-text img.is-zoomable:hover { opacity: .92; }
/* Video e iframe incorporati */
.story-text iframe, .story-text video, .story-text embed, .story-text object { max-width: 100% !important; }
.story-text iframe[src*="youtube"], .story-text iframe[src*="youtu.be"], .story-text iframe[src*="vimeo"] {
  width: 100% !important; height: auto !important; aspect-ratio: 16 / 9; border: 0; border-radius: var(--radius-s);
}

/* Lightbox */
.lightbox {
  position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center;
  background: rgba(5, 14, 22, .9); padding: 56px 16px 16px; overflow: auto;
  animation: lb-in .15s ease-out;
}
.lightbox[hidden] { display: none; }
@keyframes lb-in { from { opacity: 0; } }
.lightbox img {
  display: block; max-width: 100%; max-height: calc(100vh - 72px);
  width: auto; height: auto; border-radius: var(--radius-s); cursor: zoom-in;
  box-shadow: 0 20px 60px rgba(0,0,0,.5); background: #fff;
}
.lightbox.is-actual { place-items: start center; }
.lightbox.is-actual img { max-width: none; max-height: none; cursor: zoom-out; }
.lightbox-bar { position: fixed; top: 10px; right: 12px; left: 12px; display: flex; justify-content: space-between; align-items: center; gap: 10px; color: #cfdbe4; font-size: 13px; pointer-events: none; }
.lightbox-bar > * { pointer-events: auto; }
.lightbox-bar a { color: #fff; }
.lightbox-close { width: 40px; height: 40px; border-radius: 50%; border: 1px solid rgba(255,255,255,.3); background: rgba(255,255,255,.08); color: #fff; display: grid; place-items: center; cursor: pointer; }
.lightbox-close svg { width: 20px; height: 20px; }
body.lb-open { overflow: hidden; }
.story-text a { color: var(--brand); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--brand) 35%, transparent); text-underline-offset: 2px; }
.story-text a:hover { text-decoration-color: currentColor; }
.story-text img[align="left"], .story-text img[style*="float:left"], .story-text img[style*="float: left"] { margin: 4px 18px 10px 0; }
.story-text img[align="right"], .story-text img[style*="float:right"], .story-text img[style*="float: right"] { margin: 4px 0 10px 18px; }
.story-text ul, .story-text ol { padding-left: 1.3em; }
.story-text table { max-width: 100%; display: block; overflow-x: auto; }
.story-body { font-size: 16px; line-height: 1.7; padding-top: 20px; padding-bottom: 12px; }
.story-body h2, .story-body h3 { margin-top: 1.2em; }

.story-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 24px 18px;
}
.story-short .story-foot .btn-primary { height: 36px; }

.story-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-top: 14px; padding: 12px 0 16px; border-top: 1px solid var(--line); font-size: 13.5px; }
.story-tools .tool, .story-tools .tool a { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.story-tools .tool a:hover { color: var(--brand); }
.story-tools svg { width: 15px; height: 15px; }

.story-tags { display: flex; gap: 10px; align-items: flex-start; padding: 10px 24px 4px; color: var(--muted); }
.story-tags svg { width: 16px; height: 16px; margin-top: 6px; }
.tag-list { font-size: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.tag-list a, .tag-cloud a {
  font-size: 13px; display: inline-block; padding: 4px 10px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); line-height: 1.4;
}
.tag-list a:hover, .tag-cloud a:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }

.story-seo { padding: 6px 24px 20px; margin: 0; font-size: 13px; color: var(--muted); }

/* Rating (engine stars) */
.story-rating .rating { margin: 0; }
.story-rating { display: inline-flex; align-items: center; }

/* Related */
/* Related downloads: griglia di locandine */
.related { margin-bottom: 24px; }
.related-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 18px 14px;
}
.rel-link { display: flex; flex-direction: column; gap: 8px; color: var(--ink); text-decoration: none !important; }
.rel-poster {
  display: block; aspect-ratio: 2 / 3; border-radius: var(--radius-s); overflow: hidden;
  background: var(--surface-2); box-shadow: 0 0 0 1px var(--line);
}
.rel-poster img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s ease; }
.rel-link:hover .rel-poster img { transform: scale(1.04); }
.rel-title {
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  font-size: 13.5px; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere;
}
.rel-link:hover .rel-title { color: var(--brand); }
@media (max-width: 640px) {
  .related-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 10px; }
  .rel-title { font-size: 12.5px; }
}

/* ---------- Pagination ---------- */
.pager { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px; margin: 24px 0; }
.pager-pages { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.pager-pages a, .pager-pages span, .pager > a, .pager > span, .pager-step {
  display: inline-grid; place-items: center; min-width: 40px; height: 40px; padding: 0 12px;
  border-radius: var(--radius-s); border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-2); font-weight: 600; font-size: 14px;
}
.pager-pages a:hover, .pager > a:hover .pager-step, .pager a:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.pager-pages > span:not(.nav_ext) { background: var(--brand); border-color: var(--brand); color: #fff; }
.pager-pages .nav_ext { border-color: transparent; background: none; }
.pager > span.pager-step, .pager > .pager-step { opacity: .45; }       /* no link = disabled */
.pager > a { border: 0; padding: 0; background: none; }
.pager > a .pager-step { opacity: 1; }

/* ---------- Comments ---------- */
.comments-area { margin-top: 8px; }
.section-title { font-size: 1.25rem; display: flex; align-items: center; gap: 10px; margin: 0 0 14px; }
.section-title .count { font-size: 13px; font-weight: 700; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; color: var(--muted); }

.comment {
  display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 14px;
  padding: 16px 18px; margin-bottom: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.comment-avatar { position: relative; width: 48px; height: 48px; }
.comment-avatar img { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; background: var(--surface-2); }
.presence { position: absolute; right: -1px; bottom: -1px; width: 13px; height: 13px; border-radius: 50%; background: var(--line-strong); border: 2px solid var(--surface); }
.presence.is-online { background: var(--ok); }
.presence-text { font-size: 13px; color: var(--muted); }
.presence-text.is-online { color: var(--ok); font-weight: 600; }
.comment-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 6px; }
.comment-author, .comment-author a { color: var(--ink); font-weight: 700; }
.comment-date { color: var(--muted); font-size: 13px; }
.comment-mass { margin-left: auto; }
.comment-text { color: var(--ink-2); overflow-wrap: anywhere; }
.comment-text img { border-radius: var(--radius-s); }
.signature { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--line); font-size: 13px; color: var(--muted); }
.comment-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px; margin-top: 10px; font-size: 13px; }
.comment-stats { color: var(--muted); }
.comment-actions { display: inline-flex; flex-wrap: wrap; gap: 14px; }
.comment-actions a { color: var(--muted); font-weight: 600; }
.comment-actions a:hover { color: var(--brand); }

/* ---------- Forms ---------- */
.form-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l);
  padding: 28px; margin-bottom: 20px;
}
.form-title { font-size: 1.5rem; font-stretch: 88%; margin-bottom: 6px; }
.form-sub { color: var(--muted); margin-bottom: 22px; }
.form-grid { display: grid; gap: 0 18px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { margin-bottom: 18px; min-width: 0; }
.field > label, .field-label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; color: var(--ink); }
.req { color: var(--bad); }
.opt { color: var(--muted); font-weight: 400; }
.field-hint { font-size: 13px; color: var(--muted); margin-top: 6px; }
.field-hint:empty { display: none; }
.field-hint.is-warn { color: var(--warn); }
.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; min-width: 0; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 6px; }
fieldset { border: 0; border-top: 1px solid var(--line); margin: 0 0 8px; padding: 20px 0 0; }
legend { font-weight: 700; font-size: 1rem; padding: 0 10px 0 0; color: var(--ink); }

/* Inputs: override the engine defaults (fixed 302px width etc.) */
select, textarea,
input[type="text"], input[type="password"], input[type="file"], input[type="email"], input[type="url"],
input[type="search"], input[type="tel"], input[type="number"], input[type="date"],
input[type="datetime"], input[type="datetime-local"], input[type="month"], input[type="time"], input[type="week"],
.f_input, .f_textarea, .a_field, .s_field {
  width: 100%; max-width: 100%;
  height: 42px; padding: 0 12px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: var(--radius-s);
  font: 400 15px var(--font); box-shadow: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea, .f_textarea, select[multiple], select[size] { height: auto; min-height: 110px; padding: 10px 12px; line-height: 1.5; resize: vertical; }
select { padding-right: 32px; }
input[type="file"], .file-input { height: auto; padding: 9px 10px; background: var(--surface-2); }
input:focus, textarea:focus, select:focus, .f_input:focus {
  outline: none; border-color: var(--brand) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent) !important;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; accent-color: var(--brand); margin: 0; vertical-align: middle; }

.check { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; color: var(--ink-2); margin: 4px 0 16px; cursor: pointer; }
.check input { margin-top: 2px; }
.checkbox { margin: 8px 0; font-size: 14px; }

.captcha-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.captcha-img img { border-radius: var(--radius-s); border: 1px solid var(--line); display: block; }
.captcha-input { max-width: 180px; }

.xfields-table { width: 100%; }
.xfields-table:empty { display: none; }
.xfields-table td { padding: 0 0 14px; vertical-align: top; }
.xfields-table td.label, .xfields-table td:first-child:not(:only-child) { width: 30%; padding-right: 14px; font-weight: 600; font-size: 14px; padding-top: 10px; }

/* ---------- Auth pages ---------- */
.auth-layout {
  display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.4fr);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l);
  overflow: hidden; margin-bottom: 24px;
}
.auth-aside {
  background: var(--band); color: var(--band-ink); padding: 34px 30px;
  background-image: radial-gradient(circle at 100% 0, rgba(79,169,222,.22), transparent 55%);
}
.auth-aside h1 { color: #fff; font-size: 1.9rem; font-stretch: 85%; margin-bottom: 10px; }
.auth-aside p { color: var(--band-muted); }
.auth-aside a { color: #fff; text-decoration: underline; }
.perk-list { list-style: none; margin: 22px 0; padding: 0; display: grid; gap: 12px; }
.perk-list li { display: flex; gap: 10px; align-items: flex-start; }
.perk-list svg { width: 18px; height: 18px; color: #7fd18a; margin-top: 3px; }
.auth-help { font-size: 14px; margin-top: 28px; }
.auth-layout .form-card { border: 0; border-radius: 0; margin: 0; padding: 34px 34px 30px; }

.auth-single { max-width: 520px; margin: 8px auto 24px; }
.auth-single.wide { max-width: 760px; }
.form-icon { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); margin-bottom: 14px; }
.form-icon svg { width: 24px; height: 24px; }

.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 70px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  height: 30px; padding: 0 10px; border: 0; border-radius: 5px;
  background: var(--surface-2); color: var(--ink-2); font: 600 12.5px var(--font); cursor: pointer;
}
.pw-toggle:hover { color: var(--brand); }
.pw-meter { display: grid; grid-template-columns: repeat(4, 1fr) auto; gap: 4px; align-items: center; margin-top: 8px; }
.pw-meter i { height: 4px; border-radius: 2px; background: var(--line); transition: background-color .2s; }
.pw-label { font-size: 12.5px; color: var(--muted); min-width: 48px; text-align: right; }
.pw-meter[data-level="1"] i:nth-child(-n+1) { background: var(--bad); }
.pw-meter[data-level="2"] i:nth-child(-n+2) { background: var(--warn); }
.pw-meter[data-level="3"] i:nth-child(-n+3) { background: #c9a227; }
.pw-meter[data-level="4"] i { background: var(--ok); }
.pw-match { font-size: 13px; margin-top: 8px; min-height: 1em; }
.pw-match.is-ok { color: var(--ok); }
.pw-match.is-bad { color: var(--bad); }
#result-registration { font-weight: 600; }
#result-registration font[color="red"], #result-registration .error { color: var(--bad) !important; }
#result-registration font[color="green"] { color: var(--ok) !important; }

/* ---------- Notices (info.tpl) ---------- */
.notice {
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--brand);
  border-radius: var(--radius); padding: 16px 20px; margin-bottom: 20px;
}
.notice-title { display: block; font-size: 1.05rem; margin-bottom: 4px; }
.notice-body { color: var(--ink-2); }
.notice-body ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------- Profile ---------- */
.profile-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); overflow: hidden; margin-bottom: 20px; }
.profile-top {
  display: flex; gap: 22px; align-items: center; padding: 28px;
  background: linear-gradient(180deg, var(--brand-soft), var(--surface));
}
.profile-avatar { width: 104px; height: 104px; border-radius: 50%; object-fit: cover; border: 4px solid var(--surface); box-shadow: 0 0 0 1px var(--line); flex: none; }
.profile-id h1 { font-size: 1.8rem; font-stretch: 85%; margin-bottom: 6px; overflow-wrap: anywhere; }
.profile-sub { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-bottom: 12px; }
.group-pill { font-size: 13px; font-weight: 700; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 999px; padding: 2px 10px; }
.profile-actions { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 14px; font-weight: 600; }
.profile-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.profile-stats > div { padding: 16px 22px; border-left: 1px solid var(--line); }
.profile-stats > div:first-child { border-left: 0; }
.profile-stats dt { font-size: 13px; color: var(--muted); }
.profile-stats dd { margin: 2px 0 0; font-size: 1.15rem; font-weight: 700; }
.stat-link { font-size: 13px; font-weight: 500; }
.rss-ico { width: 14px; height: 14px; margin-left: 6px; vertical-align: -1px; }
.profile-about { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 24px; margin: 0; padding: 22px 28px 26px; }
.profile-about .wide { grid-column: 1 / -1; }
.profile-about dt { font-size: 13px; color: var(--muted); }
.profile-about dd { margin: 2px 0 0; color: var(--ink-2); overflow-wrap: anywhere; }

.popup-profile { display: flex; gap: 16px; align-items: flex-start; font-size: 14px; }
.pp-avatar { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; flex: none; }
.pp-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }

/* ---------- Private messages ---------- */
.pm-header { margin-bottom: 18px; }
.pm-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.pm-tabs a { display: inline-flex; align-items: center; height: 36px; padding: 0 14px; border-radius: var(--radius-s); border: 1px solid var(--line-strong); color: var(--ink-2); font-weight: 600; background: var(--surface); }
.pm-tabs a:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.pm-quota { font-size: 13px; color: var(--muted); max-width: 360px; }
.pm-quota .progress { margin-top: 6px; }
.pm-subject { font-size: 1.1rem; margin: 0 0 8px; }
.pm-list { padding: 0; overflow-x: auto; }
table.pm { width: 100%; border: 0; }
table.pm td, .pm td.pm_list, .pm td.pm_head { padding: 10px 12px; border-bottom: 1px solid var(--line); background: none; }
.pm td.pm_head { font-weight: 700; color: var(--muted); font-size: 13px; }
table.pm select { width: auto; }

/* ---------- Stats ---------- */
.stat-groups { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat-group { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stat-group h2 { font-size: 1rem; margin-bottom: 8px; }
.stat-group dl { margin: 0; }
.stat-group dl > div { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; font-size: 14px; border-top: 1px solid var(--line); }
.stat-group dl > div:first-child { border-top: 0; }
.stat-group dt { color: var(--muted); }
.stat-group dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-period { width: 100%; margin-bottom: 14px; font-size: 14px; }
.stat-period th, .stat-period td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; }
.stat-period th:first-child { text-align: left; }
.stat-period thead th { color: var(--muted); font-size: 13px; }
.table-scroll { overflow-x: auto; }
table.userstop { width: 100%; font-size: 14px; }
.userstop td { padding: 8px 10px !important; border-bottom: 1px solid var(--line); }
.userstop thead td { font-weight: 700; color: var(--muted); background: none; }

/* ---------- Polls ---------- */
.poll, .vote { margin-bottom: 20px; }
.vtitle { margin-bottom: 10px; }
.pollvotelist, .vote-list { margin-bottom: 12px; font-size: 14px; }
.pollvotelist label, .vote-list label { display: inline; }
.vote .link-btn { margin-top: 12px; font-size: 13px; }

/* ---------- Add news ---------- */
.poll-box { border: 1px solid var(--line); border-radius: var(--radius); padding: 0 16px; margin-bottom: 18px; }
.poll-box > summary { cursor: pointer; padding: 12px 0; font-weight: 600; color: var(--brand); }
.poll-box[open] > summary { margin-bottom: 8px; }
.admintag:empty { display: none; }
.admintag { margin-bottom: 18px; }
#related_news { display: block; font-size: 14px; }
.bb-editor textarea { width: 100% !important; border-radius: 0 0 var(--radius-s) var(--radius-s); }

/* ---------- Search page ---------- */
.searchtable table { width: 100%; }
.searchtable td { padding: 4px 6px 4px 0; vertical-align: middle; }
.searchtable fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin: 0 0 12px; }
.search-msg { margin-top: 14px; color: var(--muted); }

/* ---------- Attachments ---------- */
.attachment { display: inline-flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; padding: 6px 12px; border: 1px dashed var(--line-strong); border-radius: var(--radius-s); background: var(--surface-2); }
.att-meta { font-size: 13px; color: var(--muted); }
.att-locked { color: var(--muted); font-size: 14px; }

/* ---------- Engine elements re-themed ---------- */
.quote, blockquote, .scriptcode, .title_quote, .title_spoiler, .text_spoiler {
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2);
}
.title_quote { border-left: 3px solid var(--brand); border-bottom: 0; border-radius: var(--radius-s) var(--radius-s) 0 0; font-style: normal; }
.quote, blockquote { border-left: 3px solid var(--brand); font-style: normal; border-radius: 0 var(--radius-s) var(--radius-s) 0; margin: 10px 0; }
.title_spoiler { border-radius: var(--radius-s); font-weight: 600; }
.title_spoiler a { color: var(--brand); text-decoration: none !important; }
.text_spoiler { border-top: 0; border-radius: 0 0 var(--radius-s) var(--radius-s); }
.scriptcode, pre { overflow-x: auto; border-radius: var(--radius-s); font-size: 13.5px; }
.hide { background: var(--brand-soft); border: 1px dashed var(--brand); border-radius: var(--radius-s); padding: 10px 14px; color: var(--ink-2); }
.hide a { color: var(--brand); }

#loading-layer { background: var(--band); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0,0,0,.3); font: 600 14px var(--font); }

.ui-dialog { background: var(--surface) !important; color: var(--ink); border: 1px solid var(--line) !important; border-radius: var(--radius-l) !important; box-shadow: 0 24px 60px rgba(5,25,40,.35) !important; overflow: hidden; }
.ui-dialog-titlebar { background: var(--surface-2) !important; border-bottom: 1px solid var(--line) !important; color: var(--ink) !important; font-family: var(--font); }
.ui-dialog-title { font-weight: 700 !important; color: var(--ink) !important; }
.ui-dialog-content { color: var(--ink-2) !important; }
.ui-dialog .ui-dialog-buttonpane { background: var(--surface-2) !important; border-top: 1px solid var(--line) !important; }
.ui-widget-overlay { background: rgba(5, 18, 28, .6) !important; }

#searchsuggestions { background: var(--surface) !important; border: 1px solid var(--line) !important; border-radius: var(--radius) !important; box-shadow: 0 18px 40px rgba(5,25,40,.25) !important; overflow: hidden; z-index: 200; }
#searchsuggestions a, #searchsuggestions span.notfound { color: var(--ink) !important; border-bottom: 1px solid var(--line) !important; }
#searchsuggestions a:hover { background: var(--surface-2) !important; text-decoration: none; }
#searchsuggestions a span { color: var(--muted) !important; }
#searchsuggestions span.seperator a { color: var(--brand) !important; }

#dropmenudiv { background: var(--surface) !important; border: 1px solid var(--line) !important; border-radius: var(--radius-s); box-shadow: 0 12px 30px rgba(5,25,40,.2); }
#dropmenudiv a { color: var(--ink) !important; border-bottom-color: var(--line) !important; }
#dropmenudiv a:hover { background: var(--surface-2) !important; }

.progress { background: var(--line) !important; border-radius: 999px; overflow: hidden; height: 8px !important; }
.progress .progress-bar, .progress-blue { background: var(--brand) !important; }

/* ---------- Footer ---------- */
.site-footer { background: var(--surface); border-top: 1px solid var(--line); padding: 30px 0 34px; color: var(--muted); font-size: 14px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 6px 22px; justify-content: center; margin-bottom: 22px; }
.footer-links a { color: var(--ink-2); font-weight: 500; }
.footer-links a:hover { color: var(--brand); }
.disclaimer { max-width: 760px; margin: 0 auto 16px; padding: 14px 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); font-size: 13px; line-height: 1.55; }
.disclaimer strong { display: block; color: var(--ink); margin-bottom: 4px; }
.disclaimer p { margin: 0; }
.copyright { text-align: center; margin: 0; font-size: 13px; }

/* ---------- Responsive ---------- */
@media (max-width: 1240px) {
  .layout { grid-template-columns: 220px minmax(0, 1fr); grid-template-areas: "left main" "left right"; }
  .sidebar-right { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
}

@media (max-width: 920px) {
  .header-row { grid-template-columns: auto auto 1fr; gap: 12px; row-gap: 12px; }
  .header-row .drawer-toggle { display: inline-grid; }
  .brand img { width: 100px; }
  .header-actions { justify-self: end; }
  .header-search { grid-column: 1 / -1; grid-row: 2; max-width: none; }
  .hdr-register { display: none; }

  .layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "main" "right"; padding-top: 20px; gap: 22px; }
  .sidebar-left {
    position: fixed; z-index: 300; top: 0; left: 0; bottom: 0; width: min(320px, 86vw);
    max-height: none; background: var(--surface); padding: 0 12px 24px; border-right: 1px solid var(--line);
    transform: translateX(-102%); transition: transform .22s ease; visibility: hidden;
  }
  .drawer-open .sidebar-left { transform: none; visibility: visible; }
  .drawer-open { overflow: hidden; }
  .drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 4px; position: sticky; top: 0; background: var(--surface); font-weight: 700; font-size: 1.05rem; }
  .drawer-head .icon-btn { color: var(--ink); border-color: var(--line); }
  .sidebar-left .cat-tree { border: 0; padding: 0; }
  .sidebar-left .cat-tree .panel-title { display: none; }
  .drawer-backdrop { display: block; position: fixed; inset: 0; z-index: 250; background: rgba(5, 18, 28, .55); }
  .drawer-backdrop[hidden] { display: none; }

  .auth-layout { grid-template-columns: 1fr; }
  .auth-aside { padding: 26px 22px; }
  .perk-list { margin: 16px 0 0; }
  .auth-help { margin-top: 16px; }
  .auth-layout .form-card { padding: 24px 22px; }
}

@media (max-width: 640px) {
  body { font-size: 15px; }
  .wrap { padding: 0 16px; }
  .header-search .hs-btn { padding: 0 14px; }
  .header-search input[type="search"] { font-size: 16px; }
  .user-name { display: none; }
  .user-chip { padding-right: 4px; }
  .dropdown-panel { position: fixed; left: 12px; right: 12px; top: 70px; width: auto; }

  .story-head { padding: 16px 16px 0; }
  .story-text { padding: 12px 16px 4px; }
  .story-tags, .story-seo { padding-left: 16px; padding-right: 16px; }
  .story-foot { padding: 10px 16px 16px; }
  .story-title { font-size: 1.25rem; }
  .story-text img[align], .story-text img[style*="float"] { float: none !important; display: block; margin: 8px auto !important; }

  .form-card, .page-panel { padding: 20px 16px; }
  .form-grid.two, .form-grid.three { grid-template-columns: 1fr; }
  .input-row { flex-direction: column; }
  .profile-top { flex-direction: column; text-align: center; padding: 22px 16px; }
  .profile-sub, .profile-actions { justify-content: center; }
  .profile-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .profile-stats > div:nth-child(3) { border-left: 0; }
  .profile-stats > div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .profile-about { grid-template-columns: 1fr; padding: 18px 16px; }
  .stat-groups { grid-template-columns: 1fr; }
  .comment { grid-template-columns: 40px minmax(0, 1fr); padding: 14px; gap: 12px; }
  .comment-avatar, .comment-avatar img { width: 40px; height: 40px; }
  .xfields-table td { display: block; width: auto !important; padding-right: 0 !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

@media print {
  .site-header, .sidebar, .site-footer, .comments-area, .story-foot, .story-tools { display: none !important; }
  .layout { display: block; }
  .story { border: 0; }
}

/* ---------- Fixes ---------- */
.field > label.check { display: flex; font-weight: 400; color: var(--ink-2); margin: 10px 0 0; }
@media (max-width: 640px) { .input-row input { flex: none; } }
/* the engine star sprite has a white background: give it a chip so it sits well in dark mode */
.story-rating .rating { background: #fff; border-radius: 6px; padding: 3px 6px; height: auto; width: auto; }
:root:not([data-theme="dark"]) .story-rating .rating { padding: 0; background: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .story-rating .rating { background: #fff; padding: 3px 6px; } }

/* ---------- Sticky header that shrinks on scroll ---------- */
.site-header { position: sticky; top: 0; z-index: 60; transition: box-shadow .2s; }
.header-row { transition: padding .2s ease; }
.brand img { transition: width .2s ease; }
.site-header.is-compact { box-shadow: 0 6px 20px rgba(0, 0, 0, .25); }
.site-header.is-compact .header-row { padding-top: 6px; padding-bottom: 6px; }
.site-header.is-compact .brand img { width: 84px; }
.site-header.is-compact .topnav a { padding-top: 8px; padding-bottom: 8px; }
.sidebar-left { top: calc(var(--hdr-h, 0px) + 16px); max-height: calc(100vh - var(--hdr-h, 0px) - 32px); }
html { scroll-padding-top: calc(var(--hdr-h, 0px) + 16px); }
@media (max-width: 920px) {
  .sidebar-left { top: 0; max-height: none; }
  .site-header.is-compact .brand img { width: 64px; }
  .site-header.is-compact .header-row { row-gap: 6px; }
  .site-header.is-compact .header-search input[type="search"],
  .site-header.is-compact .header-search .hs-btn { height: 38px; }
}

/* ---------- Logo centrato sopra la sidebar sinistra ----------
   L'header usa le stesse colonne del layout, così il logo sta
   esattamente al centro della colonna delle categorie. */
@media (min-width: 921px) {
  .header-row { grid-template-columns: 236px minmax(0, 1fr) 290px; column-gap: 28px; }
  .brand { justify-self: center; }
  .header-search { justify-self: stretch; max-width: none; }
  .header-actions { justify-self: end; }
}
@media (min-width: 921px) and (max-width: 1240px) {
  .header-row { grid-template-columns: 220px minmax(0, 1fr) auto; }
}

/* contatore visite nascosto quando vale 0 */
.js-views[hidden] { display: none !important; }

.js-related[hidden] { display: none !important; }
