/* =========================================================
   Webcam Test Base Design System (Light default + Dark toggle)
   ========================================================= */
:root {
    --bg: #f6f8fb;
    --bg-elev: #ffffff;
    --bg-subtle: #eef2f7;
    --bg-inset: #e6ebf2;
    --text: #0f172a;
    --text-muted: #475569;
    --text-soft: #64748b;
    --border: #dce3ee;
    --border-strong: #c5d0e0;
    --header-bg: rgba(255, 255, 255, 0.9);
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 18px 44px rgba(15, 23, 42, 0.12);
    --tool-accent: #2563eb;
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    --header-h: 64px;
}

[data-theme="dark"] {
    --bg: #0b1120;
    --bg-elev: #111a2e;
    --bg-subtle: #18233a;
    --bg-inset: #0e1627;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --text-soft: #64748b;
    --border: #22304d;
    --border-strong: #324468;
    --header-bg: rgba(11, 17, 32, 0.9);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.42);
    --shadow-lg: 0 22px 54px rgba(0, 0, 0, 0.55);
}

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    transition: background-color 0.2s ease, color 0.2s ease;
}

img, video, canvas, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.container {
    width: 100%;
    max-width: 1260px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header & Navigation */
.site-header {
    position: relative;
    z-index: 100;
    height: var(--header-h);
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 1.12rem;
    letter-spacing: -0.02em;
    flex-shrink: 0;
}

.brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--tool-accent);
    color: #ffffff;
    box-shadow: 0 4px 12px color-mix(in srgb, var(--tool-accent) 35%, transparent);
}

.primary-nav {
    display: flex;
    align-items: center;
}

.nav-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 4px;
}

.nav-item {
    position: relative;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 13px;
    border-radius: 10px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.92rem;
    font-weight: 600;
    white-space: nowrap;
    transition: background-color 0.16s ease, color 0.16s ease;
}

.nav-link:hover,
.nav-link.is-active,
.nav-item.is-category-active > .nav-link,
.nav-item.is-open > .nav-link {
    color: var(--text);
    background: var(--bg-subtle);
}

.nav-item.is-category-active > .nav-link,
.nav-link.is-active {
    color: var(--tool-accent);
}

.nav-chevron {
    transition: transform 0.18s ease;
    opacity: 0.7;
}

.nav-item.is-open .nav-chevron {
    transform: rotate(180deg);
}

.nav-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 248px;
    padding: 8px;
    border-radius: 14px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 0.16s ease, transform 0.16s ease, visibility 0.16s ease;
    z-index: 120;
}

.nav-item.is-open > .nav-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

@media (hover: hover) and (min-width: 961px) {
    .nav-item.has-dropdown:hover > .nav-dropdown {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }
    .nav-item.has-dropdown:hover .nav-chevron {
        transform: rotate(180deg);
    }
}

.dropdown-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 11px;
    border-radius: 9px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: background-color 0.15s ease, color 0.15s ease;
}

.dropdown-link:hover {
    background: var(--bg-subtle);
    color: var(--text);
}

.dropdown-link.is-active {
    background: color-mix(in srgb, var(--tool-accent) 12%, transparent);
    color: var(--tool-accent);
    font-weight: 600;
}

.dropdown-ico {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-subtle);
    flex-shrink: 0;
}

.dropdown-link.is-active .dropdown-ico {
    background: var(--tool-accent);
    color: #fff;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-elev);
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.16s ease, border-color 0.16s ease, transform 0.12s ease;
}

.icon-btn:hover {
    background: var(--bg-subtle);
    border-color: var(--border-strong);
}

.icon-btn:active { transform: scale(0.96); }

[data-theme="light"] .theme-icon-dark { display: none; }
[data-theme="dark"] .theme-icon-light { display: none; }

.mobile-menu-btn { display: none; }
.mobile-menu-btn .menu-ico-close { display: none; }
.mobile-menu-btn[aria-expanded="true"] .menu-ico-open { display: none; }
.mobile-menu-btn[aria-expanded="true"] .menu-ico-close { display: inline-flex; }

/* Main area */
.site-main {
    flex: 1 0 auto;
    padding: 28px 0 44px;
}

/* Reusable Button & Form Primitives */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-elev);
    color: var(--text);
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1.2;
    transition: all 0.16s ease;
    white-space: nowrap;
}

.btn:hover:not(:disabled) {
    background: var(--bg-subtle);
    border-color: var(--border-strong);
}

.btn:disabled {
    opacity: 0.48;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--tool-accent);
    border-color: var(--tool-accent);
    color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
    filter: brightness(1.08);
    background: var(--tool-accent);
    border-color: var(--tool-accent);
}

.btn-danger {
    background: #dc2626;
    border-color: #dc2626;
    color: #ffffff;
}

.btn-danger:hover:not(:disabled) {
    background: #b91c1c;
    border-color: #b91c1c;
}

.btn-sm {
    padding: 7px 12px;
    font-size: 0.84rem;
    border-radius: 8px;
}

.select-control, .input-control {
    padding: 9px 12px;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: var(--bg-elev);
    color: var(--text);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.15s ease;
}

.select-control:focus, .input-control:focus {
    border-color: var(--tool-accent);
}

.badge-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    background: var(--bg-subtle);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8;
    display: inline-block;
}
.status-dot.is-live { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25); }
.status-dot.is-rec  { background: #ef4444; box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.28); animation: pulse-dot 1s infinite; }
.status-dot.is-warn { background: #f59e0b; }

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

.alert-banner {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 10px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #dc2626;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 16px;
}
[data-theme="dark"] .alert-banner { color: #fca5a5; }
.alert-banner.is-visible { display: flex; }

/* Article Section — Plain, clean editorial typography */
.article-slot {
    margin-top: 44px;
    padding-top: 32px;
    border-top: 1px solid var(--border);
}
.article-slot-inner[data-empty="true"] {
    min-height: 0;
    padding: 0;
}
.tool-article {
    max-width: 820px;
    margin: 0 auto;
    color: var(--text);
    font-size: 1rem;
    line-height: 1.75;
}
.tool-article h2 {
    margin: 34px 0 12px;
    font-size: 1.38rem;
    font-weight: 700;
    line-height: 1.35;
    letter-spacing: -0.015em;
    color: var(--text);
}
.tool-article h2:first-child {
    margin-top: 0;
}
.tool-article h3 {
    margin: 22px 0 8px;
    font-size: 1.08rem;
    font-weight: 700;
    line-height: 1.4;
    color: var(--text);
}
.tool-article p {
    margin: 0 0 15px;
    color: var(--text-muted);
}
.tool-article ul,
.tool-article ol {
    margin: 0 0 18px;
    padding-left: 22px;
    color: var(--text-muted);
}
.tool-article li {
    margin-bottom: 7px;
}
.tool-article strong {
    color: var(--text);
    font-weight: 600;
}
.tool-article .faq-list {
    margin-top: 14px;
    border-top: 1px solid var(--border);
}
.tool-article .faq-item {
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}
.tool-article .faq-item h3 {
    margin: 0 0 6px;
    font-size: 1.02rem;
}
.tool-article .faq-item p {
    margin: 0;
    font-size: 0.96rem;
}

/* Footer */
.site-footer {
    background: var(--bg-elev);
    border-top: 1px solid var(--border);
    padding: 48px 0 28px;
    margin-top: auto;
}

.footer-grid {
    display: grid;
    grid-template-columns: 1.5fr repeat(4, 1fr);
    gap: 32px;
    padding-bottom: 36px;
    border-bottom: 1px solid var(--border);
}

.footer-tagline {
    margin: 12px 0 16px;
    font-size: 0.9rem;
    color: var(--text-muted);
    max-width: 280px;
}

.footer-privacy {
    display: inline-flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--bg-subtle);
    color: var(--text-muted);
    font-size: 0.8rem;
    line-height: 1.4;
}

.privacy-ico { flex-shrink: 0; margin-top: 1px; color: #16a34a; }

.footer-heading {
    margin: 0 0 12px;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text);
}

.footer-links {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.footer-links a {
    font-size: 0.88rem;
    color: var(--text-muted);
    transition: color 0.15s ease;
}

.footer-links a:hover { color: var(--tool-accent); }

.footer-bottom {
    padding-top: 20px;
    font-size: 0.84rem;
    color: var(--text-soft);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.footer-bottom p { margin: 0; }

.footer-bottom-left {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 20px;
}

.footer-legal-links {
    display: inline-flex;
    align-items: center;
    gap: 14px;
}

.footer-legal-links a {
    color: var(--text-muted);
    transition: color 0.15s ease;
}

.footer-legal-links a:hover {
    color: var(--tool-accent);
}

.footer-lang-switcher {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.lang-switch-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
}
.lang-select {
    padding: 6px 10px;
    font-size: 0.84rem;
    border-radius: 8px;
}

/* 404 Page */
.notfound-card {
    max-width: 520px;
    margin: 64px auto;
    padding: 40px 32px;
    text-align: center;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}
.notfound-code {
    font-size: 4rem;
    font-weight: 900;
    line-height: 1;
    color: var(--tool-accent);
    margin-bottom: 12px;
}

/* Mobile Responsive Navigation & Layout */
@media (max-width: 960px) {
    .mobile-menu-btn { display: inline-flex; }

    .primary-nav {
        position: fixed;
        top: var(--header-h);
        left: 0;
        right: 0;
        bottom: 0;
        background: var(--bg-elev);
        padding: 16px 20px 32px;
        overflow-y: auto;
        display: none;
        border-top: 1px solid var(--border);
        z-index: 99;
    }

    .primary-nav.is-mobile-open {
        display: block;
    }

    .nav-list {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }

    .nav-link {
        width: 100%;
        justify-content: flex-start;
        padding: 12px 14px;
        font-size: 0.98rem;
    }

    .nav-chevron { margin-left: auto; }

    .nav-dropdown {
        position: static;
        box-shadow: none;
        border: none;
        background: var(--bg-subtle);
        margin-top: 4px;
        padding: 6px;
        opacity: 1;
        visibility: visible;
        transform: none;
        display: none;
    }

    .nav-item.is-open > .nav-dropdown {
        display: block;
    }

    .footer-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .footer-brand-col {
        grid-column: 1 / -1;
    }
}

@media (max-width: 560px) {
    .container { padding: 0 14px; }
    .site-main { padding: 18px 0 32px; }
    .footer-grid { grid-template-columns: 1fr; gap: 24px; }
}
