/* ==========================================================================
   smartdomprof.pl — global stylesheet  v3
   DARK-ONLY, MOBILE-FIRST, FULLY FLUID.

   Design contract:
     - Dark is the ONLY theme. There is no light variant (print excepted).
       color-scheme: dark tells the browser to render scrollbars, form
       controls, autofill and the address bar chrome dark too.
     - Base styles target a 320px phone. Every @media rule scales UP.
     - Typography is fluid via clamp(): no jumpy font sizes between
       breakpoints, no horizontal overflow at any width.
   Breakpoints: 360 / 480 / 600 / 900 / 1200 / 1600
   ========================================================================== */

/* ---------- Design tokens ---------- */
:root {
    color-scheme: dark;                 /* CRITICAL: dark UA widgets */

    /* Surfaces, darkest -> lightest */
    --bg:            #0f1419;           /* page / site chrome */
    --surface:       #161b22;           /* cards, article body */
    --surface-2:     #1c2430;           /* callouts */
    --surface-3:     #21262d;           /* nested boxes, table foot */
    --surface-head:  #1a2332;           /* header gradient end, table head */

    /* Text */
    --text:          #e6edf3;
    --text-strong:   #f0f6fc;
    --text-muted:    #b0bec5;
    --text-dim:      #8b949e;
    --text-soft:     #c9d1d9;

    /* Lines */
    --border:        #30363d;
    --border-soft:   rgba(255,255,255,0.08);

    /* Accents */
    --link:          #58a6ff;
    --link-hover:    #79c0ff;
    --link-bright:   #a5d6ff;
    --accent:        #4fc3f7;           /* brand cyan */
    --accent-green:  #5fbf7f;           /* smart-home green */
    --accent-green-2:#7ee0a0;
    --accent-warn:   #f0b429;           /* affiliate / price */

    /* Fluid type — min at 320px, max at 1200px */
    --fs-body:   clamp(1rem, 0.96rem + 0.2vw, 1.08rem);
    --fs-lead:   clamp(1.04rem, 0.99rem + 0.28vw, 1.18rem);
    --fs-h1:     clamp(1.5rem, 1.18rem + 1.6vw, 2.4rem);
    --fs-h2:     clamp(1.2rem, 1.08rem + 0.6vw, 1.5rem);
    --fs-h3:     clamp(1.04rem, 1rem + 0.25vw, 1.18rem);
    --fs-small:  clamp(0.84rem, 0.82rem + 0.1vw, 0.92rem);
    --fs-tiny:   clamp(0.76rem, 0.75rem + 0.07vw, 0.84rem);

    /* Fluid spacing */
    --gutter:    clamp(0.75rem, 0.4rem + 1.6vw, 1.5rem);
    --pad-card:  clamp(1.1rem, 0.7rem + 1.9vw, 2rem);
    --gap:       clamp(0.85rem, 0.6rem + 1vw, 1.35rem);

    --radius:    14px;
    --radius-sm: 8px;
    --tap:       44px;                  /* min touch target */
}

/* Dark stays dark even if the user forces a light preference.
   Declared explicitly so no UA stylesheet or extension flips surfaces. */
@media (prefers-color-scheme: light) {
    :root { color-scheme: dark; }
}

/* ---------- Base reset ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    overflow-x: hidden;
    scroll-behavior: smooth;
    scrollbar-color: var(--border) var(--bg);   /* Firefox dark scrollbar */
    background-color: var(--bg);
}

body {
    font-family: 'Georgia', 'Times New Roman', serif;
    background-color: var(--bg);
    color: var(--text);
    font-size: var(--fs-body);
    line-height: 1.75;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    max-width: 100%;
    min-height: 100vh;
    min-height: 100dvh;                 /* no address-bar jump on mobile */
    -webkit-tap-highlight-color: rgba(79,195,247,0.2);   /* no white flash */
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* WebKit/Blink dark scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #484f58; }

::selection { background: rgba(79,195,247,0.32); color: var(--text-strong); }

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

img, svg, video, iframe, table, pre, blockquote { max-width: 100%; }
img, svg, video { height: auto; }
img { background-color: var(--surface-2); }   /* dark placeholder while loading */

/* Dark form controls (contact forms, future search) */
input, select, textarea, button {
    font-family: inherit;
    font-size: inherit;
    color: var(--text);
    background-color: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    max-width: 100%;
}
input, select, textarea { padding: 0.6rem 0.7rem; min-height: var(--tap); }
input::placeholder, textarea::placeholder { color: var(--text-dim); }
input:focus, select:focus, textarea:focus { border-color: var(--link); outline: none; }
/* kill Chrome's white autofill box */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--text);
    -webkit-box-shadow: 0 0 0 1000px var(--surface-3) inset;
    transition: background-color 9999s ease-out 0s;
}

hr { border: 0; border-top: 1px solid var(--border); margin: 1.6rem 0; }
code, pre, kbd, samp {
    font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
    background: var(--surface-3);
    color: var(--accent);
    border-radius: 4px;
}
code { padding: 0.1em 0.35em; font-size: 0.9em; overflow-wrap: anywhere; }
pre { padding: 0.9rem 1rem; overflow-x: auto; -webkit-overflow-scrolling: touch; }
pre code { background: none; padding: 0; }
blockquote {
    margin: 1.4rem 0;
    padding: 0.2rem 0 0.2rem 1rem;
    border-left: 3px solid var(--link);
    color: var(--text-soft);
    font-style: italic;
}

/* ---------- Header (site chrome) ---------- */
header {
    background: linear-gradient(135deg, var(--bg) 0%, var(--surface-head) 100%);
    color: var(--text-strong);
    padding: 1rem var(--gutter);
    padding-top: max(1rem, env(safe-area-inset-top));   /* notch */
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.45);
    border-bottom: 1px solid var(--border);
}
.header-inner { max-width: 1100px; margin: 0 auto; }
.site-name {
    font-size: clamp(1.15rem, 1rem + 0.8vw, 1.6rem);
    font-weight: 700;
    margin: 0;
    color: var(--accent);
    letter-spacing: 0.5px;
    line-height: 1.25;
    overflow-wrap: break-word;
}
.site-name a { color: inherit; text-decoration: none; }
.site-tagline, .tagline {
    margin: 0.25rem 0 0;
    font-size: var(--fs-tiny);
    color: var(--text-muted);
    font-weight: 400;
    line-height: 1.45;
}

.logo { display: flex; align-items: center; justify-content: center; gap: 0.5rem; min-width: 0; }
.logo svg { flex: 0 0 auto; width: clamp(30px, 8vw, 40px); height: auto; }
.logo-text {
    font-size: clamp(1.1rem, 1rem + 0.8vw, 1.5rem);
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.5px;
    overflow-wrap: break-word;
}

nav.top-nav {
    margin-top: 0.75rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.25rem 0.5rem;
    font-size: var(--fs-small);
}
nav.top-nav a {
    color: var(--text-soft);
    text-decoration: none;
    padding: 0.5rem 0.45rem;
    min-height: var(--tap);
    display: inline-flex;
    align-items: center;
    border-radius: 6px;
}
nav.top-nav a:focus-visible { outline-offset: -2px; }

.nav-toggle {
    display: none;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    padding: 0.5rem 0.75rem;
    font-size: 1.25rem;
    cursor: pointer;
    min-height: var(--tap);
    min-width: var(--tap);
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.nav-toggle[aria-expanded="true"] .nav-toggle-open { display: none; }
.nav-toggle[aria-expanded="false"] .nav-toggle-close { display: none; }

/* ---------- Main container ---------- */
main.container {
    width: 100%;
    max-width: min(800px, 100%);
    margin: 0 auto;
    padding: clamp(1rem, 0.7rem + 1.4vw, 2rem) var(--gutter);
    color: var(--text);
}
main.container > a, main.container p > a { color: var(--link); }

/* ==========================================================================
   HOMEPAGE
   ========================================================================== */
section.hero { margin: 0 0 clamp(1.25rem, 1rem + 1vw, 2rem); }
section.hero h1 {
    font-size: var(--fs-h1);
    line-height: 1.2;
    color: var(--text-strong);
    margin: 0 0 0.5rem;
    overflow-wrap: break-word;
    hyphens: auto;
}
.hero-lead {
    font-size: var(--fs-lead);
    color: var(--text-muted);
    margin: 0;
    line-height: 1.6;
    overflow-wrap: break-word;
}

section.articles, section.why { margin: clamp(1.75rem, 1.4rem + 1.4vw, 3rem) 0 0; }
section.articles > h2, section.why > h2 {
    font-size: var(--fs-h2);
    color: var(--text-soft);
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
    margin-bottom: var(--gap);
    overflow-wrap: break-word;
}
section.why ul { padding-left: 1.2rem; }
section.why li { margin-bottom: 0.7rem; overflow-wrap: break-word; }
section.why strong { color: var(--text-strong); }

/* Article grid — 1 column at phone width, auto-fit above */
.article-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--gap);
    width: 100%;
}

/* Cards: .article-card (static) and .article (injected by app.js) */
.article-grid > .article,
.article-card {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    min-width: 0;               /* CRITICAL: lets grid children shrink */
    transition: border-color 0.2s ease, transform 0.2s ease;
}
.article-grid > .article.featured {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(79,195,247,0.25);
}

.thumb-link { display: block; line-height: 0; background: var(--bg); }
.thumb {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    display: block;
}

.article-body, .article-content { min-width: 0; }
.article-body {
    padding: var(--gap) clamp(0.9rem, 0.7rem + 0.8vw, 1.25rem) 1.15rem;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.article-title, .article-card h3 {
    font-size: var(--fs-h3);
    line-height: 1.35;
    margin: 0 0 0.5rem;
    color: var(--text-strong);
    overflow-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
}
.article-title a, .article-card h3 a { color: inherit; text-decoration: none; }

.article-card > a {
    text-decoration: none;
    color: inherit;
    display: block;
    padding: var(--gap) clamp(0.9rem, 0.7rem + 0.8vw, 1.25rem) 1.15rem;
}

.article-excerpt, .article-card p {
    font-size: var(--fs-small);
    color: var(--text-muted);
    margin: 0 0 0.9rem;
    line-height: 1.6;
    overflow-wrap: break-word;
}
.article-card p.meta { font-size: var(--fs-tiny); color: var(--text-dim); margin: 0; }

.read-more {
    margin-top: auto;
    align-self: flex-start;
    color: var(--link);
    text-decoration: none;
    font-size: var(--fs-small);
    font-weight: 600;
    padding: 0.4rem 0;
    min-height: 32px;
    display: inline-flex;
    align-items: center;
}

/* ==========================================================================
   ARTICLE PAGES (article.article) + LEGAL PAGES (.article-item)
   ========================================================================== */
article.article,
.article-item {
    background: var(--surface);
    padding: var(--pad-card);
    border-radius: var(--radius);
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    box-shadow: 0 2px 10px rgba(0,0,0,0.35);
    color: var(--text);
    line-height: 1.75;
    border: 1px solid var(--border);

    /* --- responsive containment --- */
    column-count: 1;            /* CRITICAL: no multi-column on rotation */
    columns: auto;
    overflow-wrap: anywhere;
    word-break: break-word;
    hyphens: auto;
}

.article-item { border-left: 4px solid var(--accent); }
.article-item h1 { color: var(--text-strong); font-size: var(--fs-h1); line-height: 1.25; margin-top: 0; }
.article-item h2 {
    font-size: var(--fs-h2);
    color: var(--text-soft);
    margin-top: 2rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}
.article-item h3 { font-size: var(--fs-h3); color: var(--text-soft); }
.article-item a { color: var(--link-hover); overflow-wrap: anywhere; }
.article-item ul, .article-item ol { padding-left: 1.2rem; }
.article-item li { margin-bottom: 0.4rem; }
.article-item p { overflow-wrap: break-word; }
.article-item strong { color: var(--text-strong); }

article.article h1 {
    color: var(--text-strong);
    font-size: var(--fs-h1);
    line-height: 1.22;
    margin-top: 0;
    overflow-wrap: break-word;
    hyphens: auto;
}
article.article h2 {
    font-size: var(--fs-h2);
    color: var(--text-soft);
    margin-top: 2.2rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
    line-height: 1.35;
    overflow-wrap: break-word;
}
article.article h3 {
    font-size: var(--fs-h3);
    color: var(--text-soft);
    margin-top: 1.5rem;
    line-height: 1.4;
}
article.article a { color: var(--link-hover); overflow-wrap: anywhere; }
article.article p { overflow-wrap: break-word; }
article.article .lead { font-size: var(--fs-lead); color: var(--text); }
article.article .byline { color: var(--text-dim); font-size: var(--fs-small); margin-top: -0.3rem; }
article.article strong { color: var(--text-strong); }

article.article .disclaimer,
aside.disclaimer {
    background: var(--surface-3);
    border-left: 4px solid var(--link);
    padding: 0.9rem 1rem;
    margin: 1.4rem 0;
    font-size: var(--fs-small);
    border-radius: 6px;
    color: var(--text-soft);
    display: block;
    overflow-wrap: break-word;
}
aside.disclaimer strong { color: var(--text-strong); }

article.article .faq {
    background: var(--surface-3);
    border: 1px solid var(--border);
    padding: var(--gap) 1.1rem;
    border-radius: 10px;
    margin-top: 1.4rem;
    color: var(--text-soft);
}
article.article .faq h3 { margin-top: 0; color: var(--text-strong); }
article.article .faq-item { margin-bottom: 1rem; }
article.article .faq-item:last-child { margin-bottom: 0; }

article.article .nav { font-size: var(--fs-small); margin-bottom: 1.4rem; }
article.article .nav a { margin-right: 0.9rem; color: var(--link-hover); }

article.article .toc {
    background: var(--surface-3);
    border: 1px solid var(--border);
    padding: var(--gap) 1.1rem;
    border-radius: 10px;
    margin: 1.4rem 0;
    color: var(--text-soft);
}
article.article .toc h3, article.article .toc p { margin-top: 0; color: var(--text-strong); }
article.article .toc ol { padding-left: 1.3rem; margin: 0.3rem 0; }
article.article .toc ol li { margin-bottom: 0.35rem; }
article.article .toc a { overflow-wrap: break-word; }

/* Hint / pro-tip callout */
.hint {
    background: var(--surface-2);
    border-left: 3px solid var(--accent-green);
    border-radius: 6px;
    padding: 0.8rem 1rem;
    margin: 1.25rem 0;
    font-size: var(--fs-small);
    color: var(--text-soft);
    overflow-wrap: break-word;
}
.hint strong { color: var(--accent-green-2); }

/* CTA box */
.cta-box {
    background: linear-gradient(135deg, var(--surface-head) 0%, var(--surface-3) 100%);
    border: 1px solid var(--link);
    border-radius: 12px;
    padding: var(--gap) 1.2rem;
    margin: 2rem 0;
    color: var(--text);
}
.cta-box p { margin: 0 0 0.7rem; overflow-wrap: break-word; }
.cta-box p:last-child { margin-bottom: 0; }
.cta-box strong { color: var(--accent); }
.cta-box a { color: var(--link-hover); font-weight: 600; }

/* Ceneo / affiliate link list */
.affiliate-box {
    background: var(--surface-3);
    border-left: 4px solid var(--accent-warn);
    border-radius: 6px;
    padding: 0.8rem 1rem;
    margin: 1.6rem 0 0.6rem;
    font-size: var(--fs-small);
    color: var(--text-soft);
    overflow-wrap: break-word;
}
.affiliate-box strong { color: var(--text-strong); }
.affiliate-links {
    list-style: none;
    padding: 0;
    margin: 0 0 1.6rem;
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
}
.affiliate-links li {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.7rem 0.85rem;
    font-size: var(--fs-small);
    line-height: 1.5;
    margin: 0;
    min-width: 0;
    overflow-wrap: anywhere;
}
.affiliate-links a {
    color: var(--link-hover);
    font-weight: 600;
    text-decoration: underline;
    display: inline-block;
    min-height: 32px;
    padding: 0.15rem 0;
}

article.article .internal-links {
    background: var(--surface-3);
    border: 1px solid var(--border);
    padding: var(--gap) 1.1rem;
    border-radius: 10px;
    margin-top: 1.6rem;
    font-size: var(--fs-small);
    color: var(--text-soft);
}
article.article .internal-links h3 { margin-top: 0; color: var(--text-strong); }
article.article .internal-links ul {
    padding-left: 1.2rem;
    margin: 0.3rem 0 0;
    columns: 1;                 /* phone: single column */
}
article.article .internal-links li { margin-bottom: 0.45rem; break-inside: avoid; overflow-wrap: anywhere; }
article.article .internal-links a { color: var(--link-hover); }

article.article footer {
    margin-top: 2rem;
    padding: 1.2rem 0 0;
    border-top: 1px solid var(--border);
    font-size: var(--fs-small);
    color: var(--text-dim);
    background: none;
    text-align: left;
}
article.article footer a {
    color: var(--link-hover);
    margin-right: 0.9rem;
    min-height: auto;
    display: inline;
    padding: 0;
}

article.article ul, article.article ol { padding-left: 1.2rem; }
article.article li { margin-bottom: 0.35rem; overflow-wrap: break-word; }

/* ---------- Hero images & media ---------- */
.hero img, .inline img {
    width: 100%;
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 10px;
    margin: 1rem auto;
}
.hero figcaption, .video figcaption, .inline figcaption {
    font-size: var(--fs-tiny);
    color: var(--text-dim);
    margin-top: 0.5rem;
    text-align: center;
    font-style: italic;
    overflow-wrap: break-word;
}
article.article .hero, article.article .video { margin: 1.5rem 0; }
.video iframe {
    width: 100%;
    max-width: 100%;
    aspect-ratio: 16 / 9;
    height: auto;
    border: 0;
    border-radius: 10px;
    display: block;
    margin: 0 auto;
    background: #000;
}

/* ---------- Affiliate box (generic) ---------- */
.affiliate, article.article .affiliate {
    background: var(--surface-3);
    border-left: 4px solid var(--link);
    border-radius: 10px;
    padding: var(--gap) 1.2rem;
    margin: 2rem 0;
    color: var(--text-soft);
}
.affiliate h3, article.article .affiliate h3 {
    color: var(--text-strong);
    margin-top: 0;
    font-size: var(--fs-h3);
    font-family: inherit;
}
.affiliate h3::before { content: "\2605 "; color: var(--link); }
.aff-lead strong { color: var(--text-strong); }
.aff-price { color: var(--text-dim); font-size: var(--fs-small); margin: 0.3rem 0 0.8rem 0; }
.affiliate .aff-note { font-size: var(--fs-tiny); color: var(--text-dim); margin-top: 0.8rem; font-style: italic; }
.affiliate a { color: var(--link-hover); text-decoration: underline; font-weight: 600; }

/* ==========================================================================
   TABLES — must never push page width
   ========================================================================== */
.table-scroll {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 1rem 0;
    border-radius: 6px;
    overscroll-behavior-x: contain;
}

/* Raw table (no wrapper) — scrolls inside itself */
article.article table.comparison,
article.article table,
.article-item table {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: var(--fs-small);
    table-layout: fixed;
    background: var(--surface);
    border-radius: 6px;
    color: var(--text);
    min-width: 0; /* ensure it can shrink within container */
    box-sizing: border-box;
}

/* Force comparison tables to fill container width */
article.article table.comparison {
    width: 100%;
}
/* Wrapped table — wrapper scrolls, table behaves normally */
article.article .table-scroll table.comparison,
article.article .table-scroll table {
    display: table;
    overflow-x: visible;
    margin: 0;
}
article.article table.comparison th,
article.article table.comparison td,
article.article table th,
article.article table td,
.article-item table th,
.article-item table td {
    padding: 0.5rem 0.55rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    word-break: break-word;
    max-width: 0;               /* containment: cells respect column algo */
    min-width: 56px;            /* lower min so % cols work on narrow screens */
    vertical-align: top;
    hyphens: auto;
}
article.article table.comparison thead,
article.article table thead { background: var(--surface-head); }
article.article table.comparison thead th,
article.article table thead th { color: var(--text-strong); font-weight: 700; }
article.article table.comparison tfoot,
article.article table tfoot { background: var(--surface-3); font-weight: 600; color: var(--text); }
article.article table.comparison tbody tr:nth-child(even) { background: rgba(255,255,255,0.022); }

/* ==========================================================================
   MEDIA QUERIES — scale UP from the mobile base
   ========================================================================== */

/* Hover effects only on real pointers (no sticky :hover on touch) */
@media (hover: hover) and (pointer: fine) {
    main.container a:hover { color: var(--link-hover); }
    nav.top-nav a:hover, nav.top-nav a:focus { color: var(--accent); }
    .nav-toggle:hover { background: var(--surface-head); }
    .article-grid > .article:hover,
    .article-card:hover { border-color: var(--link); transform: translateY(-2px); }
    .article-title a:hover, .article-card h3 a:hover { color: var(--link-hover); }
    .read-more:hover { color: var(--link-hover); text-decoration: underline; }
    .affiliate-links a:hover, .affiliate a:hover { color: var(--link-bright); }
    body > footer a:hover, .footer-inner a:hover { color: var(--text-strong); }
    .error-home:hover { background: var(--link); }
    article.article a:hover { color: var(--link-bright); }
}

/* Very small phones (<=359px) — tighten everything */
@media (max-width: 359px) {
    :root { --tap: 42px; }
    article.article, .article-item { border-radius: 10px; }
    article.article table th, article.article table td { min-width: 52px; }
    nav.top-nav { font-size: 0.86rem; }
}

/* Mobile hamburger nav (below 600px) */
@media (max-width: 599px) {
    .nav-toggle { display: inline-flex; }
    .header-inner {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        text-align: left;
        gap: 0.25rem;
    }
    .site-name, .logo { order: 1; margin-right: auto; min-width: 0; }
    .logo { justify-content: flex-start; }
    .nav-toggle { order: 2; flex: 0 0 auto; }
    .site-tagline, .tagline { order: 3; width: 100%; margin-top: 0.4rem; }
    nav.top-nav {
        order: 4;
        width: 100%;
        display: none;
        flex-direction: column;
        gap: 0;
        margin-top: 0.6rem;
        padding-top: 0.5rem;
        border-top: 1px solid var(--border-soft);
        text-align: left;
        font-size: 0.95rem;
    }
    nav.top-nav.open { display: flex; }
    nav.top-nav a {
        display: block;
        width: 100%;
        border-top: 1px solid var(--border-soft);
        padding: 0.8rem 0.25rem;
        border-radius: 0;
    }
    nav.top-nav a:first-child { border-top: none; }
}

/* Phone in landscape — short viewport, reclaim vertical space */
@media (max-width: 899px) and (orientation: landscape) and (max-height: 500px) {
    header { padding-top: 0.6rem; padding-bottom: 0.6rem; }
    .site-tagline, .tagline { display: none; }
    main.container { padding-top: 0.9rem; }
    section.hero { margin-bottom: 1rem; }
    article.article h2 { margin-top: 1.5rem; }
    nav.top-nav { max-height: 55vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
}

/* Large phone / small tablet */
@media (min-width: 480px) {
    .affiliate-links { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
}

/* Tablet and up */
@media (min-width: 600px) {
    main.container { max-width: min(984px, 100%); }
    article.article, .article-item { max-width: 984px; border-radius: 15px; }
    .article-grid { grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); }
    article.article footer a { margin-right: 1.1rem; }
}

/* Tablet landscape / small laptop */
@media (min-width: 900px) {
    main.container { max-width: min(1060px, 100%); }
    article.article, .article-item { max-width: 1060px; }
    .article-grid { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
    article.article table.comparison th,
    article.article table.comparison td,
    article.article table th,
    article.article table td { padding: 0.65rem 0.8rem; }
}

/* Desktop */
@media (min-width: 1200px) {
    article.article .internal-links ul { columns: 2; column-gap: 1.6rem; }
    article.article, .article-item { max-width: 1100px; }
    main.container { max-width: min(1140px, 100%); }
}

/* Large monitors — cap measure so lines stay readable */
@media (min-width: 1600px) {
    main.container { max-width: 1240px; }
    article.article, .article-item { max-width: 1180px; }
    .article-grid { grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); }
}

/* ---------- Footer (site chrome) ---------- */
body > footer {
    text-align: center;
    padding: 1.5rem var(--gutter);
    padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
    font-size: var(--fs-small);
    background: var(--bg);
    color: var(--text-muted);
    margin-top: clamp(1.75rem, 1.4rem + 1.4vw, 3rem);
    border-top: 1px solid var(--border);
}
.footer-inner { max-width: 1100px; margin: 0 auto; }
.footer-inner p { margin: 0.4rem 0; overflow-wrap: break-word; }
body > footer a, .footer-inner a {
    color: var(--accent);
    text-decoration: none;
    margin: 0 0.2rem;
    padding: 0.4rem 0.3rem;
    min-height: var(--tap);
    display: inline-flex;
    align-items: center;
    border-radius: 6px;
}

/* ---------- 404 page ---------- */
.error-page { text-align: center; padding: clamp(2rem, 1.5rem + 4vw, 4rem) var(--gutter); }
.error-code {
    font-size: clamp(3.5rem, 2rem + 9vw, 6rem);
    font-weight: 800;
    color: var(--accent);
    margin: 0;
    line-height: 1;
}
.error-msg { font-size: var(--fs-lead); margin: 1rem 0 2rem; color: var(--text-muted); }
.error-home {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #1f6feb;
    color: var(--text-strong);
    padding: 0.8rem 1.5rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-weight: 600;
    min-height: var(--tap);
}

/* ---------- Print (the only intentionally light context) ---------- */
@media print {
    header, body > footer, nav, .affiliate, .cta-box, .nav-toggle,
    .affiliate-box, .affiliate-links { display: none; }
    html, body { background: #fff; color: #000; font-size: 12pt; padding: 0; }
    article.article, .article-item {
        box-shadow: none;
        padding: 0;
        max-width: none;
        background: #fff;
        color: #000;
        border: none;
    }
    article.article h1, article.article h2, article.article h3,
    .article-item h1, .article-item h2, .article-item h3 { color: #000; }
    a { color: #000; text-decoration: none; }
    a[href^="http"]:after { content: " (" attr(href) ")"; font-size: 90%; }
    article.article table, article.article table.comparison {
        display: table;
        overflow: visible;
        background: #fff;
    }
    article.article table th, article.article table td { color: #000; border-bottom: 1px solid #999; }
    article.article table thead { background: #eee; }
    article.article table thead th { color: #000; }
    .hint, .disclaimer, aside.disclaimer, .toc, .faq {
        background: #f5f5f5;
        color: #000;
        border-color: #999;
    }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .article-grid > .article:hover, .article-card:hover { transform: none; }
}

/* ---------- High contrast ---------- */
@media (prefers-contrast: more) {
    :root {
        --text: #ffffff;
        --text-muted: #d4dde6;
        --text-soft: #e6edf3;
        --text-dim: #b0bec5;
        --border: #5a6472;
        --link: #79c0ff;
        --link-hover: #a5d6ff;
    }
}
