:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef1f4;
  --text: #16202a;
  --muted: #5b6875;
  --border: #dde2e8;
  --accent: #0f8f7e;
  --accent-ink: #ffffff;
  --accent-soft: #e0f3ef;
  --header-bg: #0f1720;
  --header-text: #e8eef3;
  --danger: #c53a32;
  --ok: #1d7a46;
  --warn: #a86b00;
  --code-bg: #0f1720;
  --code-text: #dce6ee;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 32, .06), 0 4px 16px rgba(16, 24, 32, .06);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c1117;
    --surface: #141b23;
    --surface-2: #1b242e;
    --text: #e3e9ef;
    --muted: #93a1ae;
    --border: #26313c;
    --accent: #2fc0a8;
    --accent-ink: #06201b;
    --accent-soft: #123029;
    --header-bg: #080c11;
    --danger: #ef6a61;
    --ok: #4cc47f;
    --warn: #e0a83a;
    --code-bg: #080c11;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 var(--font);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
main { flex: 1; }
a { color: var(--accent); }
img { max-width: 100%; height: auto; }
.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.inline { display: inline; }
.icon { flex-shrink: 0; }

/* ---------- Header / footer ---------- */
.site-header { background: var(--header-bg); color: var(--header-text); position: sticky; top: 0; z-index: 10; }
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-weight: 700; letter-spacing: -.01em; }
.brand-icon { color: #2fc0a8; }
.header-nav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.nav-link { color: var(--header-text); text-decoration: none; opacity: .85; font-size: .95rem; }
.nav-link:hover { opacity: 1; }
.lang-switch { display: flex; border: 1px solid #33414f; border-radius: 8px; overflow: hidden; }
.lang-switch a { padding: 4px 10px; color: var(--header-text); text-decoration: none; font-size: .85rem; font-weight: 600; }
.lang-switch a.active { background: #2fc0a8; color: #06201b; }

.site-footer { margin-top: 64px; padding: 28px 0; border-top: 1px solid var(--border); font-size: .9rem; }
.site-footer p { margin: 4px 0; }

/* ---------- Buttons & chips ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 8px; border: 1px solid transparent;
  font: inherit; font-weight: 600; font-size: .95rem; cursor: pointer; text-decoration: none; line-height: 1.2;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.site-header .btn-ghost { color: var(--header-text); border-color: #33414f; }
.site-header .btn-ghost:hover { background: #1b242e; }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: .82rem; }
.btn-block { width: 100%; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .75rem; font-weight: 600;
  background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.chip.lvl-beginner { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.chip.lvl-intermediate { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.chip.lvl-advanced { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }

/* ---------- Hero & filters ---------- */
.hero { padding: 48px 0 28px; }
.hero h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); line-height: 1.15; margin: 0 0 10px; letter-spacing: -.02em; }
.lead { font-size: 1.1rem; color: var(--muted); margin: 0 0 24px; max-width: 720px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters input[type="search"] { flex: 1 1 260px; }
.filters select { flex: 0 1 200px; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; width: 100%; min-width: 0;
  font-weight: 400;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.filters input, .filters select { width: auto; }

.result-count { margin: 8px 0 16px; font-size: .9rem; }
.empty { padding: 40px 0; color: var(--muted); }

/* ---------- Card grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 20px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); transition: transform .15s, border-color .15s;
}
.card:hover { transform: translateY(-2px); border-color: var(--accent); }
.card-link { display: flex; flex-direction: column; height: 100%; color: inherit; text-decoration: none; }
.card-cover { aspect-ratio: 16 / 9; overflow: hidden; background: var(--surface-2); }
.card-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card h2 { font-size: 1.12rem; line-height: 1.3; margin: 4px 0 0; }
.card p { margin: 0; color: var(--muted); font-size: .94rem; }
.card-foot { margin-top: auto; padding-top: 8px; display: flex; justify-content: space-between; font-size: .85rem; }
.read { color: var(--accent); font-weight: 600; margin-left: auto; }

.cover-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-fallback {
  width: 100%; height: 100%; display: grid; place-items: center; color: var(--accent);
  background:
    radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--accent) 22%, transparent) 1px, transparent 0) 0 0 / 16px 16px,
    linear-gradient(135deg, var(--accent-soft), var(--surface-2));
}
.cover-fallback.cat-lighting { color: #c98a00; }
.cover-fallback.cat-camera { color: #6a5acd; }
.cover-fallback.cat-sensors { color: #d0573a; }
.cover-fallback.cat-wireless { color: #2a7fd4; }
.cover-fallback.cat-display { color: #7c4dbe; }
.cover-fallback.cat-automation { color: #2f9a4a; }

/* ---------- Article ---------- */
.article { max-width: 820px; padding-top: 28px; }
.back { display: inline-block; margin-bottom: 20px; text-decoration: none; font-size: .95rem; }
.article-head h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); line-height: 1.2; margin: 12px 0 10px; letter-spacing: -.02em; }
.meta { display: flex; flex-wrap: wrap; gap: 10px 32px; margin: 0 0 16px; }
.meta dt { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.meta dd { margin: 0; font-weight: 600; }
.article-cover { aspect-ratio: 21 / 9; border-radius: var(--radius); overflow: hidden; margin: 20px 0 32px; border: 1px solid var(--border); }
.notice { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); padding: 8px 12px; border-radius: 8px; margin-bottom: 16px; font-weight: 600; }

.prose { font-size: 1.03rem; }
.prose h2 { font-size: 1.45rem; margin: 2em 0 .6em; letter-spacing: -.01em; }
.prose h3 { font-size: 1.15rem; margin: 1.6em 0 .5em; }
.prose p, .prose ul, .prose ol { margin: 0 0 1em; }
.prose li { margin: .25em 0; }
.prose code { font-family: var(--mono); font-size: .88em; background: var(--surface-2); padding: .12em .38em; border-radius: 5px; }
.prose pre {
  background: var(--code-bg); color: var(--code-text); padding: 16px 18px; border-radius: var(--radius);
  overflow-x: auto; font-size: .86rem; line-height: 1.55; margin: 0 0 1.4em;
}
.prose pre code { background: none; padding: 0; font-size: inherit; color: inherit; }
.prose table { width: 100%; border-collapse: collapse; margin: 0 0 1.4em; font-size: .95rem; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--border); padding: 7px 11px; text-align: left; }
.prose th { background: var(--surface-2); }
.prose blockquote { margin: 0 0 1.2em; padding: 10px 16px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 8px 8px 0; }
.prose blockquote p:last-child { margin: 0; }
.prose img { border-radius: 8px; }

.source-box { margin-top: 40px; padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); font-size: .95rem; }
.source-box p { margin: 6px 0 0; font-size: .85rem; }
.empty-page { text-align: center; padding: 80px 16px; }
.empty-page h1 { font-size: 4rem; margin: 0; color: var(--accent); }

/* ---------- Admin ---------- */
.admin-main { padding-top: 24px; }
.admin-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.admin-bar h1 { margin: 0; font-size: 1.5rem; margin-right: auto; }
.admin-bar input { width: 260px; }
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.alert ul { margin: 0; padding-left: 18px; }
.alert-ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.alert-error { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.admin-table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.admin-table th, .admin-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.admin-table th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-2); }
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table td a { text-decoration: none; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.actions-cell { width: 1%; }
.status { border: 0; border-radius: 999px; padding: 3px 10px; font: inherit; font-size: .78rem; font-weight: 600; cursor: pointer; }
.status.on { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.status.off { background: var(--surface-2); color: var(--muted); }

.login-box { max-width: 360px; margin: 60px auto; background: var(--surface); padding: 28px; border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); }
.login-box h1 { margin: 0 0 18px; font-size: 1.35rem; }
.stack { display: flex; flex-direction: column; gap: 14px; }

label { display: flex; flex-direction: column; gap: 5px; font-size: .88rem; font-weight: 600; }
label.check, label.switch { flex-direction: row; align-items: center; gap: 8px; }
label.check input, label.switch input { width: auto; }
fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px 14px; margin: 0; display: flex; flex-direction: column; gap: 10px; }
legend { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 0 4px; }

.form-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.content-panel .tab-panel { display: flex; flex-direction: column; gap: 14px; }
.content-panel .tab-panel[hidden] { display: none; }
.side-panel { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 76px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cover-thumb { border-radius: 6px; aspect-ratio: 16/9; object-fit: cover; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: -4px 0 16px; }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 14px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; display: flex; align-items: center; gap: 8px; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.dot.partial { background: var(--warn); }
.dot.full { background: var(--ok); }

.editor-head { display: flex; justify-content: space-between; align-items: center; font-size: .88rem; font-weight: 600; flex-wrap: wrap; gap: 8px; }
.seg { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg-btn { background: none; border: 0; padding: 4px 10px; font: inherit; font-size: .8rem; color: var(--muted); cursor: pointer; }
.seg-btn.active { background: var(--accent); color: var(--accent-ink); }
.editor { display: grid; gap: 12px; margin-top: -6px; }
.md-input { font-size: .88rem; line-height: 1.55; resize: vertical; min-height: 420px; }
.md-preview > :first-child { margin-top: .6em; }
.md-preview { border: 1px dashed var(--border); border-radius: 8px; padding: 4px 16px; min-height: 420px; max-height: 70vh; overflow: auto; }
.editor.mode-edit .md-preview { display: none; }
.editor.mode-preview .md-input { display: none; }
.editor.mode-split { grid-template-columns: 1fr 1fr; }
.editor.mode-split .md-preview { max-height: none; }

@media (max-width: 900px) {
  .form-layout { grid-template-columns: 1fr; }
  .side-panel { position: static; }
  .editor.mode-split { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .brand span { font-size: .95rem; }
  .filters > * { flex: 1 1 100%; }
  .filters input, .filters select { width: 100%; }
  .admin-bar input { width: 100%; }
  .hero { padding-top: 32px; }
}

/* ---------- Footer links & cookie banner ---------- */
.footer-links { display: flex; gap: 18px; flex-wrap: wrap; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); text-decoration: underline; cursor: pointer; }
.prose h1 { font-size: clamp(1.7rem, 4vw, 2.2rem); line-height: 1.2; margin: 0 0 6px; letter-spacing: -.02em; }
.prose mark { background: color-mix(in srgb, var(--warn) 25%, transparent); color: inherit; padding: 0 4px; border-radius: 4px; }

.cookie-banner {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 50;
  max-width: 720px; margin: 0 auto; padding: 16px 18px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0, 0, 0, .25);
}
.cookie-banner[hidden] { display: none; }
.cookie-banner p { margin: 0; flex: 1 1 320px; font-size: .92rem; }
.cookie-actions { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 560px) {
  .cookie-actions { width: 100%; }
  .cookie-actions .btn { flex: 1; }
}

/* ---------- 2FA ---------- */
.alert-warn { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }
.warn-text { color: var(--warn); }
.code-input { font-size: 1.3rem; letter-spacing: .2em; text-align: center; max-width: 220px; }
.login-box .code-input { max-width: none; }
.help-details { margin-top: 16px; }
.help-details summary { cursor: pointer; }
.panel h2 { font-size: 1.1rem; margin: 0 0 4px; }
.security-grid { margin-top: 16px; align-items: start; }
.security-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.setup-steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 22px; }
.setup-steps p { margin: 4px 0 8px; }
.qr-wrap { background: #fff; display: block; width: fit-content; padding: 10px; border-radius: 8px; margin: 10px 0 4px; line-height: 0; }
.secret { display: inline-block; background: var(--surface-2); padding: 6px 10px; border-radius: 6px; margin-right: 8px; word-break: break-all; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.recovery-codes { columns: 2; font-size: 1.15rem; padding-left: 28px; margin: 0 0 18px; }
.recovery-codes li { padding: 4px 0; }
.recovery-actions { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 480px) { .recovery-codes { columns: 1; } }

/* ---------- simulator promo & nav ---------- */
.nav-link.active { opacity: 1; color: #2fc0a8; }
.sim-promo { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: -12px 0 28px; padding: 14px 16px; border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--border)); background: var(--accent-soft); border-radius: var(--radius); }
.sim-promo p { margin: 0; flex: 1 1 260px; font-size: .95rem; }
.sim-promo .icon { color: var(--accent); display: block; }

/* ---------- Admin statistics ---------- */
.admin-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; background: var(--surface); }
.seg a { padding: 6px 14px; font-size: .88rem; color: var(--muted); text-decoration: none; }
.seg a + a { border-left: 1px solid var(--border); }
.seg a.active { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.seg a:not(.active):hover { color: var(--text); background: var(--surface-2); }
.stat-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat-card, .stat-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.stat-label { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 1.9rem; font-weight: 700; line-height: 1.2; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.delta { font-size: .82rem; color: var(--muted); }
.delta.up { color: var(--ok); }
.delta.down { color: var(--danger); }
.stat-panel { margin-bottom: 14px; }
.stat-panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.stat-panel h2 { font-size: 1rem; margin: 0; }
.legend { display: flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--muted); }
.legend span { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-left: 8px; }
.lg-views { background: color-mix(in srgb, var(--accent) 55%, transparent); }
.lg-visitors { background: var(--warn); height: 3px !important; }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 10.5px; font-family: var(--font); }
.chart .bar { fill: color-mix(in srgb, var(--accent) 55%, transparent); }
.chart .hover { fill: transparent; }
.chart .day:hover .hover { fill: var(--surface-2); }
.chart .day:hover .bar { fill: var(--accent); }
.chart .vline { fill: none; stroke: var(--warn); stroke-width: 2; stroke-linejoin: round; pointer-events: none; }
.chart .vdot { fill: var(--surface); stroke: var(--warn); stroke-width: 1.6; pointer-events: none; }
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.stat-grid .wide { grid-column: 1 / -1; }
.stat-list { list-style: none; margin: 0; padding: 0; }
.stat-list li { position: relative; display: flex; justify-content: space-between; gap: 12px; padding: 6px 10px; font-size: .92rem; border-radius: 6px; }
.stat-list li::before { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--w); background: var(--accent-soft); border-radius: 6px; z-index: 0; }
.stat-list li > * { position: relative; }
.stat-list li + li { margin-top: 3px; }
.stat-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.stat-name a { color: inherit; text-decoration: none; }
.stat-name a:hover { color: var(--accent); text-decoration: underline; }
.stat-n { font-variant-numeric: tabular-nums; font-weight: 600; }
.stat-note { max-width: 80ch; margin-top: 4px; }
@media (max-width: 900px) { .stat-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) {
  .stat-grid { grid-template-columns: 1fr; }
  .stat-value { font-size: 1.5rem; }
  .chart .axis { font-size: 22px; }
}

/* ---------- Ads (shown to everyone; personalised only with cookie consent) ---------- */
.ad { margin: 32px 0; padding-top: 6px; border-top: 1px solid var(--border); }
.ad-label { display: block; font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
/* no empty boxes: without consent, with an ad blocker or when Google has no ad for the slot */
.ad[hidden], .ad:not(:has(ins[data-ad-status="filled"])) { display: none; }
.grid > .ad-feed { grid-column: 1 / -1; margin: 0; }
