:root {
    color-scheme: dark;
    --bg-primary: #000000;
    --bg-secondary: #121212;
    --bg-tertiary: #252525;
    --bg-card: #191919;
    --border-color: #404040;
    --text-primary: #ffffff;
    --text-secondary: #c8c8c8;
    --text-muted: #a5a5a5;
    --accent-primary: #7CFF00;
    --accent-secondary: #a8ff4d;
    --accent-rgb: 124, 255, 0;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --font-ui: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-data: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
    --font-brand: Orbitron, Inter, sans-serif;
    --header-height: 64px;
}

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

html {
    min-width: 320px;
    background: var(--bg-primary);
    scroll-behavior: smooth;
}

body {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    overflow-x: clip;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: 16px;
    line-height: 1.5;
    text-rendering: optimizeLegibility;
}

body.dialog-open {
    overflow: hidden;
}

button,
input,
select {
    color: inherit;
    font: inherit;
}

button,
select,
input[type="date"] {
    cursor: pointer;
}

button:disabled,
select:disabled,
input:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

a {
    color: inherit;
}

img,
svg {
    display: block;
}

.icon {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.is-hidden,
[hidden] {
    display: none !important;
}

.skip-link {
    position: fixed;
    top: 8px;
    left: 8px;
    z-index: 3000;
    padding: 10px 14px;
    border: 1px solid var(--accent-primary);
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text-primary);
    font-weight: 700;
    text-decoration: none;
    transform: translateY(-160%);
}

.skip-link:focus {
    transform: translateY(0);
}

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

.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    min-height: var(--header-height);
    padding-top: env(safe-area-inset-top, 0px);
    border-bottom: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.96);
}

.nav-container {
    width: min(100%, 1400px);
    min-height: var(--header-height);
    margin: 0 auto;
    padding: 0 20px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 24px;
}

.app-title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    font-family: var(--font-brand);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.08em;
    line-height: 1;
    text-decoration: none;
}

.app-title-mark {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
}

.app-title-wordmark {
    display: inline-flex;
    align-items: baseline;
    gap: 7px;
}

.app-title-accent {
    color: var(--accent-primary);
}

@media (max-width: 480px) {
    .app-title { gap: 7px; }
}

.nav-links {
    display: flex;
    align-items: stretch;
    gap: 4px;
    min-height: var(--header-height);
}

.nav-toggle {
    display: none;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-card);
}

.nav-link {
    position: relative;
    display: inline-flex;
    min-height: 44px;
    padding: 0 14px;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
}

.nav-link::after {
    content: "";
    position: absolute;
    right: 14px;
    bottom: -1px;
    left: 14px;
    height: 2px;
    background: transparent;
}

.nav-link:hover {
    color: var(--text-primary);
}

.nav-link.active {
    color: var(--text-primary);
}

.nav-link.active::after {
    background: var(--accent-primary);
}

.nav-link-external {
    font-weight: 500;
}

.score-toggle {
    min-width: 136px;
    min-height: 40px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 650;
}

.score-toggle:hover {
    border-color: #3a3a3a;
    color: var(--text-primary);
}

.score-toggle.is-active {
    border-color: rgba(var(--accent-rgb), 0.55);
    background: rgba(var(--accent-rgb), 0.08);
    color: var(--accent-secondary);
}

#main-content {
    min-width: 0;
    padding-inline: env(safe-area-inset-left, 0px) env(safe-area-inset-right, 0px);
}

.app-footer {
    margin-top: 48px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 13px;
}

.footer-container {
    width: min(100% - 32px, 1400px);
    margin: 0 auto;
    padding: 20px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 16px;
}

.footer-branding,
.footer-container nav {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 16px;
}

.footer-version {
    color: var(--text-muted);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
}

.footer-container a:hover {
    color: var(--text-primary);
}

.content-page {
    width: min(100% - 32px, 760px);
    margin: 0 auto;
    padding: 56px 0;
}

.content-page h1 {
    margin: 0 0 16px;
    font-size: clamp(32px, 6vw, 48px);
    line-height: 1.05;
}

.content-page h2 {
    margin: 32px 0 8px;
    font-size: 20px;
}

.content-page p,
.content-page li {
    color: var(--text-secondary);
}

.content-page a {
    color: var(--accent-secondary);
}

.pwa-update-notice {
    position: fixed;
    z-index: 90;
    right: max(16px, env(safe-area-inset-right, 0px));
    bottom: max(16px, env(safe-area-inset-bottom, 0px));
    max-width: min(360px, calc(100vw - 32px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
    box-sizing: border-box;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5);
    font-size: 12px;
}

@media (max-width: 900px) {
    :root {
        --header-height: 60px;
    }

    .nav-container {
        padding: 0 12px;
        gap: 12px;
    }

    .nav-container {
        grid-template-columns: auto 1fr auto;
        position: relative;
    }

    .nav-toggle {
        display: inline-flex;
        grid-column: 2;
        justify-self: end;
    }

    .nav-links {
        position: absolute;
        top: calc(100% - 1px);
        right: 12px;
        left: 12px;
        min-height: 0;
        padding: 8px;
        display: none;
        flex-direction: column;
        border: 1px solid var(--border-color);
        border-radius: 10px;
        background: var(--bg-secondary);
        box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
    }

    .nav-links.is-open {
        display: flex;
    }

    .nav-link::after {
        inset: auto auto 8px 14px;
        width: 24px;
    }
}

@media (max-width: 430px) {
    .nav-container { gap: 10px; }

    .app-title {
        gap: 6px;
        font-size: 10px;
    }

    .app-title-mark {
        width: 30px;
        height: 30px;
    }

    .app-title-wordmark {
        gap: 4px;
    }

    .nav-link {
        padding-inline: 10px;
    }

    .score-toggle {
        min-width: 44px;
        min-height: 44px;
        padding: 0;
    }

    .score-toggle span {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-delay: 0s !important;
        animation-duration: 0s !important;
        animation-iteration-count: 1 !important;
        animation-name: none !important;
        scroll-behavior: auto !important;
        transition-delay: 0s !important;
        transition-duration: 0s !important;
    }
}

.operations-shell {
    width: min(1100px, calc(100% - 32px));
    margin: 32px auto 64px;
}

.operations-heading { max-width: 720px; }
.operations-heading p:last-child { color: var(--text-secondary); }
.operations-auth {
    max-width: 620px;
    display: flex;
    align-items: end;
    gap: 10px;
    margin: 24px 0 10px;
}
.operations-auth label { display: grid; gap: 5px; color: var(--text-secondary); font-size: 12px; }
.operations-auth input {
    min-height: 42px;
    min-width: 0;
    flex: 1;
    padding: 0 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text-primary);
}
.operations-auth .control-button {
    min-height: 42px;
    padding: 0 14px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text-primary);
    font-weight: 650;
}
.operations-auth .control-button:hover { border-color: var(--accent-secondary); }
.operations-values { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; margin-top: 20px; }
.operations-value { min-width: 0; padding: 14px; border: 1px solid var(--border-color); border-radius: 8px; background: var(--bg-card); }
.operations-value h2 { margin: 0 0 10px; font-size: 14px; }
.operations-value pre { max-height: 280px; margin: 0; overflow: auto; color: var(--text-secondary); font: 11px/1.5 var(--font-data); white-space: pre-wrap; overflow-wrap: anywhere; }

@media (max-width: 430px) {
    .operations-shell { width: min(100% - 20px, 1100px); margin-top: 20px; }
    .operations-auth { align-items: stretch; flex-direction: column; }
}
