:root {
    color-scheme: dark;
    --bg: #07110e;
    --bg-grid: rgba(98, 255, 173, .045);
    --surface: #0b1713;
    --surface-2: #0e1e18;
    --text: #e7fff2;
    --muted: #7e9f8f;
    --line: #244437;
    --line-bright: #397157;
    --accent: #71ffad;
    --accent-2: #b8ff44;
    --accent-ink: #04120b;
    --danger: #ff735d;
    --warning: #ffad42;
    --caution: #e7d55a;
    --shadow: 0 28px 90px rgba(0, 0, 0, .34);
    --scan: .16;
    --mono: "JetBrains Mono", "Cascadia Code", "SFMono-Regular", Consolas, "Noto Sans SC", "Microsoft YaHei", monospace;
    --sans: "Space Grotesk", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme]) {
        color-scheme: light;
        --bg: #edf3ed;
        --bg-grid: rgba(5, 55, 32, .055);
        --surface: #f9fcf8;
        --surface-2: #e5eee6;
        --text: #10251b;
        --muted: #557064;
        --line: #b9cbbf;
        --line-bright: #789b86;
        --accent: #0aa85d;
        --accent-2: #397700;
        --accent-ink: #f3fff7;
        --danger: #bc351f;
        --warning: #a65300;
        --caution: #766700;
        --shadow: 0 28px 80px rgba(30, 62, 43, .14);
        --scan: .05;
    }
}

:root[data-theme="light"] {
    color-scheme: light;
    --bg: #edf3ed;
    --bg-grid: rgba(5, 55, 32, .055);
    --surface: #f9fcf8;
    --surface-2: #e5eee6;
    --text: #10251b;
    --muted: #557064;
    --line: #b9cbbf;
    --line-bright: #789b86;
    --accent: #087f49;
    --accent-2: #397700;
    --accent-ink: #f3fff7;
    --danger: #bc351f;
    --warning: #a65300;
    --caution: #766700;
    --shadow: 0 28px 80px rgba(30, 62, 43, .14);
    --scan: .05;
}

:root[data-theme="dark"] { color-scheme: dark; }

*, *::before, *::after { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }
body {
    margin: 0;
    min-height: 100vh;
    background:
        linear-gradient(var(--bg-grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px),
        var(--bg);
    background-size: 38px 38px;
    color: var(--text);
    font-family: var(--sans);
    -webkit-font-smoothing: antialiased;
    font-kerning: normal;
    font-synthesis: none;
    text-rendering: optimizeLegibility;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 20;
    pointer-events: none;
    opacity: var(--scan);
    background: repeating-linear-gradient(180deg, transparent 0 3px, rgba(0, 0, 0, .12) 4px);
    mix-blend-mode: multiply;
}

button, input { font: inherit; }
button { color: inherit; }
button, a, input, label { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, output:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
::selection { background: var(--accent); color: var(--accent-ink); }

.skip-link { position: fixed; left: 16px; top: 12px; z-index: 100; padding: 10px 14px; background: var(--accent); color: var(--accent-ink); transform: translateY(-150%); }
.skip-link:focus { transform: translateY(0); }

.site-header {
    width: min(1180px, calc(100% - 40px));
    margin: 0 auto;
    min-height: 68px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); font: 800 17px/1 var(--mono); letter-spacing: -1px; box-shadow: 5px 5px 0 color-mix(in srgb, var(--accent) 22%, transparent); }
.brand-copy { font: 500 10px/1.12 var(--mono); letter-spacing: .12em; color: var(--muted); }
.brand-copy b { color: var(--text); font-weight: 800; }

.header-actions { display: flex; align-items: center; gap: 10px; }
.theme-switch { display: flex; padding: 4px; border: 1px solid var(--line); background: var(--surface); }
.theme-switch button, .language-switch { border: 0; background: transparent; cursor: pointer; }
.theme-switch button { min-width: 40px; height: 32px; padding: 0 10px; display: inline-flex; align-items: center; color: var(--muted); font: 600 11px/1 var(--mono); }
.theme-switch button span { font-size: 16px; line-height: 1; }
.theme-switch button em { font-style: normal; margin-left: 5px; }
.theme-switch button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.language-switch { height: 42px; min-width: 48px; border: 1px solid var(--line); background: var(--surface); font: 800 12px/1 var(--mono); }
.language-switch:hover { border-color: var(--accent); color: var(--accent); }

.page-shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 40px; padding: clamp(18px, 2.8vh, 34px) 0 clamp(22px, 3.2vh, 38px); }
.hero-copy { min-width: 0; }
.eyebrow { display: flex; align-items: center; gap: 10px; margin: 0 0 13px; color: var(--accent); font: 700 12px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.pulse-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent); animation: pulse 1.8s infinite; }
.hero h1 { margin: 0; font-size: clamp(30px, 4.4vw, 54px); line-height: 1.03; letter-spacing: -.042em; font-weight: 600; font-feature-settings: "kern" 1, "liga" 1; }
.hero h1 strong { color: var(--accent); font-weight: 820; }
.hero-note { max-width: 56ch; margin: 14px 0 0; color: var(--muted); font-size: 15px; line-height: 1.7; }
.hero-spec { flex: 0 0 auto; margin: 0 0 5px; padding: 2px 0 2px 16px; list-style: none; display: grid; gap: 8px; border-left: 1px solid var(--line-bright); color: var(--muted); font: 600 10px/1 var(--mono); letter-spacing: .22em; }
.hero-spec b { color: var(--accent); font-weight: 700; }

.generator-card { border: 1px solid var(--line-bright); background: color-mix(in srgb, var(--surface) 94%, transparent); box-shadow: var(--shadow); }
.terminal-bar { min-height: 48px; padding: 0 18px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; border-bottom: 1px solid var(--line); color: var(--muted); font: 600 11px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; }
.terminal-bar p { margin: 0; justify-self: center; }
.terminal-bar > span { justify-self: end; display: flex; align-items: center; gap: 8px; color: var(--accent); }
.terminal-lights { display: flex; gap: 7px; }
.terminal-lights i { width: 8px; height: 8px; border-radius: 50%; background: var(--line-bright); }
.terminal-lights i:first-child { background: #ff6b56; }
.terminal-lights i:nth-child(2) { background: #f5bd4f; }
.terminal-lights i:last-child { background: var(--accent); }
.status-led { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); }

.password-stage { padding: clamp(22px, 3.2vw, 40px); border-bottom: 1px solid var(--line); }
.password-meta { margin-bottom: 14px; display: flex; justify-content: space-between; align-items: center; color: var(--muted); font: 700 11px/1 var(--mono); letter-spacing: .1em; }
.strength-badge, .strength-track span { --strength-color: var(--accent); }
.strength-badge[data-level="critical"], .strength-track span[data-level="critical"] { --strength-color: var(--danger); }
.strength-badge[data-level="weak"], .strength-track span[data-level="weak"] { --strength-color: var(--warning); }
.strength-badge[data-level="good"], .strength-track span[data-level="good"] { --strength-color: var(--caution); }
.strength-badge[data-level="strong"], .strength-badge[data-level="extreme"], .strength-track span[data-level="strong"], .strength-track span[data-level="extreme"] { --strength-color: var(--accent); }
.strength-badge { padding: 7px 9px; border: 1px solid color-mix(in srgb, var(--strength-color) 68%, var(--line)); background: color-mix(in srgb, var(--strength-color) 7%, transparent); color: var(--strength-color); letter-spacing: .04em; transition: color .2s ease, border-color .2s ease, background-color .2s ease; }
.password-row { display: grid; grid-template-columns: minmax(0, 1fr) 58px 170px; gap: 10px; }
.password-output { min-width: 0; min-height: 66px; padding: 14px 20px; display: block; overflow: visible; border: 1px solid var(--line-bright); background: var(--bg); color: var(--text); white-space: normal; overflow-wrap: anywhere; word-break: break-all; font-family: var(--mono); font-size: clamp(18px, 2.45vw, 31px); font-weight: 700; font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0, "zero" 1; line-height: 1.25; letter-spacing: .02em; cursor: copy; }
.password-output.is-generated { animation: output-in .22s steps(3, end); }
.icon-button, .copy-button { height: 66px; border: 1px solid var(--line-bright); cursor: pointer; font-family: var(--mono); font-weight: 800; }
.icon-button { background: var(--surface-2); color: var(--accent); font-size: 29px; }
.icon-button:hover { background: var(--line); }
.regenerate-button.is-spinning span { display: block; animation: spin .45s cubic-bezier(.3,.8,.5,1); }
.copy-button { display: flex; align-items: center; justify-content: center; gap: 9px; background: var(--accent); color: var(--accent-ink); font-size: 13px; letter-spacing: .03em; }
.copy-button:hover { background: var(--accent-2); }
.copy-button.is-copied { box-shadow: inset 0 0 0 3px var(--accent-ink); }
.copy-icon { font-size: 16px; }
.strength-track { height: 3px; margin-top: 14px; background: var(--surface-2); overflow: hidden; }
.strength-track span { display: block; width: 100%; height: 100%; background: linear-gradient(90deg, color-mix(in srgb, var(--strength-color) 72%, white), var(--strength-color)); box-shadow: 0 0 14px var(--strength-color); transition: width .25s ease, background-color .2s ease, box-shadow .2s ease; }

.control-grid { display: grid; grid-template-columns: 1fr 1fr; }
.control-panel { min-width: 0; padding: clamp(22px, 3.2vw, 38px); }
.control-panel + .control-panel { border-left: 1px solid var(--line); }
.control-heading { min-height: 40px; margin-bottom: 24px; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.control-heading > div { display: flex; align-items: center; gap: 12px; }
.control-heading h2 { margin: 0; font-size: 15px; letter-spacing: .02em; }
.step { color: var(--accent); font: 700 11px/1 var(--mono); }
.length-input-wrap { height: 38px; display: flex; align-items: center; border: 1px solid var(--line-bright); background: var(--bg); color: var(--muted); font: 700 10px/1 var(--mono); }
.length-input-wrap input { width: 54px; height: 100%; border: 0; background: transparent; color: var(--accent); text-align: center; font: 800 18px/1 var(--mono); appearance: textfield; }
.length-input-wrap input::-webkit-inner-spin-button { display: none; }
.length-input-wrap span { padding-right: 10px; }
.pool-count { color: var(--muted); font: 700 11px/1 var(--mono); text-transform: uppercase; }
.pool-count b { color: var(--accent); font-size: 18px; }

.length-range { width: 100%; height: 20px; margin: 4px 0 0; background: transparent; appearance: none; cursor: pointer; }
.length-range::-webkit-slider-runnable-track { height: 3px; background: linear-gradient(90deg, var(--accent) var(--range-progress, 13%), var(--line) var(--range-progress, 13%)); }
.length-range::-moz-range-track { height: 3px; background: var(--line); }
.length-range::-moz-range-progress { height: 3px; background: var(--accent); }
.length-range::-webkit-slider-thumb { width: 20px; height: 20px; margin-top: -8px; appearance: none; border: 5px solid var(--surface); border-radius: 0; background: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.length-range::-moz-range-thumb { width: 11px; height: 11px; border: 5px solid var(--surface); border-radius: 0; background: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.range-scale { display: flex; justify-content: space-between; color: var(--muted); font: 600 10px/1 var(--mono); }
.presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-top: 24px; }
.presets button { min-height: 56px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 5px; padding: 9px 12px; border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; }
.presets button:hover { border-color: var(--line-bright); color: var(--text); }
.presets button.is-active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, transparent); color: var(--accent); }
.presets button span { font-size: 11px; }
.presets button b { font: 800 15px/1 var(--mono); }

.type-options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.type-options input { position: absolute; opacity: 0; pointer-events: none; }
.check-ui { min-height: 61px; padding: 12px; display: grid; grid-template-columns: 16px 1fr; column-gap: 10px; border: 1px solid var(--line); cursor: pointer; }
.check-ui i { grid-row: 1 / 3; align-self: center; width: 16px; height: 16px; border: 1px solid var(--line-bright); position: relative; }
.check-ui b { align-self: end; font: 800 14px/1 var(--mono); }
.check-ui small { align-self: start; margin-top: 5px; color: var(--muted); font-size: 11px; }
.type-options input:checked + .check-ui { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, transparent); }
.type-options input:checked + .check-ui i { background: var(--accent); border-color: var(--accent); }
.type-options input:checked + .check-ui i::after { content: ""; position: absolute; left: 4.5px; top: 2.5px; width: 5px; height: 9px; border: solid var(--accent-ink); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.type-options input:focus-visible + .check-ui { outline: 2px solid var(--accent); outline-offset: 2px; }
.check-ui.is-denied { animation: denied .32s ease; border-color: var(--danger); }
.ambiguous-option { min-height: 48px; margin-top: 12px; padding: 9px 12px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border: 1px solid var(--line); cursor: pointer; }
.ambiguous-option > span { display: flex; flex-direction: column; gap: 4px; }
.ambiguous-option b { font-size: 12px; }
.ambiguous-option small { color: var(--muted); font: 600 10px/1 var(--mono); letter-spacing: .08em; }
.ambiguous-option input { position: absolute; opacity: 0; }
.switch-ui { width: 34px; height: 18px; padding: 2px; border: 1px solid var(--line-bright); flex: 0 0 auto; }
.switch-ui::after { content: ""; display: block; width: 12px; height: 12px; background: var(--muted); transition: transform .2s ease, background .2s ease; }
.ambiguous-option input:checked + .switch-ui::after { background: var(--accent); transform: translateX(16px); }
.ambiguous-option input:focus-visible + .switch-ui { outline: 2px solid var(--accent); outline-offset: 3px; }

.security-strip { padding: 17px clamp(22px, 3.2vw, 38px); border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 32px; background: var(--surface-2); }
.security-strip > div { display: flex; align-items: center; gap: 12px; }
.security-icon { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--accent); color: var(--accent); font: 800 22px/1 var(--mono); }
.security-strip p { margin: 0; display: flex; flex-direction: column; gap: 5px; }
.security-strip p b { font-size: 12px; }
.security-strip p small { color: var(--muted); font-size: 11px; }
.security-strip dl { margin: 0; display: flex; gap: 36px; }
.security-strip dl div { display: flex; flex-direction: column; gap: 5px; }
.security-strip dt { color: var(--muted); font-size: 11px; }
.security-strip dd { margin: 0; color: var(--accent); font: 700 11px/1 var(--mono); }

.faq { display: grid; grid-template-columns: minmax(0, .72fr) minmax(0, 1.28fr); gap: clamp(26px, 4.5vw, 60px); padding: clamp(44px, 7vh, 84px) 0; }
.faq-head { position: sticky; top: 26px; align-self: start; }
.section-index { margin: 0 0 14px; color: var(--accent); font: 700 11px/1 var(--mono); }
.faq h2 { margin: 0; font-size: clamp(26px, 3.2vw, 40px); line-height: 1.14; letter-spacing: -.035em; }
.faq-lede { margin: 14px 0 0; color: var(--muted); font-size: 13px; line-height: 1.75; }
.faq-list article { padding: 21px 0; border-top: 1px solid var(--line); }
.faq-list article:last-child { border-bottom: 1px solid var(--line); }
.faq-list h3 { margin: 0; font-size: 16px; letter-spacing: -.01em; }
.faq-list p { max-width: 68ch; margin: 10px 0 0; color: var(--muted); font-size: 14px; line-height: 1.85; }
.site-footer { width: min(1180px, calc(100% - 40px)); min-height: 96px; margin: 0 auto; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 20px; color: var(--muted); font: 700 11px/1 var(--mono); letter-spacing: .08em; }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 50; min-height: 54px; padding: 0 20px; display: flex; align-items: center; gap: 11px; border: 1px solid var(--accent); background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-size: 12px; transform: translateY(130%); opacity: 0; transition: transform .25s ease, opacity .25s ease; }
.toast span { color: var(--accent); font: 800 18px/1 var(--mono); }
.toast.is-visible { transform: translateY(0); opacity: 1; }
.toast.is-error { border-color: var(--danger); }
.toast.is-error span { color: var(--danger); }

@keyframes pulse { 70% { box-shadow: 0 0 0 8px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes output-in { 0% { opacity: .2; transform: translateX(4px); } 50% { opacity: .65; transform: translateX(-2px); } 100% { opacity: 1; transform: translateX(0); } }
@keyframes denied { 33% { transform: translateX(-3px); } 66% { transform: translateX(3px); } }

@media (min-width: 821px) and (max-height: 850px) {
    .site-header { min-height: 58px; }
    .hero { padding: 14px 0 20px; }
    .eyebrow { margin-bottom: 11px; }
    .hero h1 { font-size: clamp(28px, 3vw, 38px); }
    .hero-note { margin-top: 10px; font-size: 14px; line-height: 1.6; }
    .password-stage, .control-panel { padding: 22px 26px; }
    .password-meta { margin-bottom: 11px; }
    .control-heading { margin-bottom: 18px; }
    .presets { margin-top: 18px; }
    .strength-track { margin-top: 11px; }
    .security-strip { padding: 13px 26px; }
    .faq { padding: 56px 0; }
    .site-footer { min-height: 78px; }
}

@media (max-width: 820px) {
    .site-header { min-height: 76px; }
    .theme-switch button em { display: none; }
    .hero { padding: 32px 0 26px; }
    .hero-spec { display: none; }
    .faq { grid-template-columns: 1fr; gap: 4px; }
    .faq-head { position: static; }
    .password-row { grid-template-columns: minmax(0, 1fr) 58px; }
    .copy-button { grid-column: 1 / -1; height: 54px; }
    .control-grid { grid-template-columns: 1fr; }
    .control-panel + .control-panel { border-left: 0; border-top: 1px solid var(--line); }
    .security-strip { align-items: flex-start; }
    .security-strip dl { gap: 22px; }
}

@media (max-width: 560px) {
    .site-header, .page-shell, .site-footer { width: min(100% - 24px, 1180px); }
    .site-header { align-items: flex-start; padding: 16px 0; }
    .brand-copy { display: none; }
    .header-actions { gap: 6px; }
    .theme-switch button { min-width: 34px; padding: 0 8px; }
    .language-switch { min-width: 42px; }
    .hero { padding: 26px 0 22px; }
    .hero h1 { font-size: clamp(30px, 9.4vw, 44px); }
    .hero-note { font-size: 14px; }
    .terminal-bar { grid-template-columns: auto 1fr; }
    .terminal-bar p { display: none; }
    .password-stage, .control-panel { padding: 24px 18px; }
    .password-meta { align-items: flex-end; }
    .strength-badge { font-size: 10px; }
    .password-row { grid-template-columns: 58px minmax(0, 1fr); }
    .password-output { grid-column: 1 / -1; padding: 15px 14px; font-size: 19px; }
    .icon-button { height: 54px; }
    .copy-button { grid-column: 2; }
    .presets { grid-template-columns: repeat(2, 1fr); }
    .security-strip { padding: 20px 18px; flex-direction: column; }
    .security-strip dl { width: 100%; justify-content: space-between; gap: 12px; }
    .faq { padding: 52px 0; }
    .faq-lede { display: none; }
    .faq-list p { font-size: 13.5px; line-height: 1.8; }
    .site-footer { padding: 30px 0; min-height: 0; flex-direction: column; align-items: flex-start; }
    .site-footer p:nth-child(2) { display: none; }
    .toast { left: 12px; right: 12px; bottom: 12px; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
