/* ═══════════════════════════════════════════════════════
   亚弥雅保护 - Apple-Style Design System
   Light/Dark theme via prefers-color-scheme + manual toggle
   ═══════════════════════════════════════════════════════ */

/* ═══ Reset ═══ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

/* ═══ Theme Variables ═══ */
:root {
    --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', 'Microsoft YaHei UI', system-ui, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', Menlo, monospace;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
    --max-w: 1080px;
    --max-w-lg: 1200px;
    /* Accent */
    --accent: #0071e3;
    --accent-hover: #0077ED;
    --accent-light: rgba(0,113,227,0.1);
    --success: #34c759;
    --warning: #ff9f0a;
    --danger: #ff3b30;
}

/* ═══ Light Theme (default) ═══ */
:root, [data-theme="light"] {
    --bg: #ffffff;
    --bg-secondary: #f5f5f7;
    --bg-tertiary: #fbfbfd;
    --bg-elevated: #ffffff;
    --bg-blur: rgba(255,255,255,0.72);
    --border: rgba(0,0,0,0.08);
    --border-strong: rgba(0,0,0,0.14);
    --text-primary: #1d1d1f;
    --text-secondary: #6e6e73;
    --text-tertiary: #86868b;
    --text-quaternary: #aeaeb2;
    --card-bg: #ffffff;
    --card-border: rgba(0,0,0,0.06);
    --card-shadow: 0 2px 12px rgba(0,0,0,0.06);
    --input-bg: #f5f5f7;
    --input-border: rgba(0,0,0,0.1);
    --input-focus: var(--accent);
    --nav-bg: rgba(255,255,255,0.72);
    --badge-bg: #f5f5f7;
    --code-bg: #f5f5f7;
    --hover-bg: rgba(0,0,0,0.03);
    --overlay: rgba(0,0,0,0.4);
    --glow: rgba(0,113,227,0.15);
    --dot-color: rgba(0,0,0,0.04);
    --mesh-1: rgba(0,113,227,0.06);
    --mesh-2: rgba(88,86,214,0.05);
    --mesh-3: rgba(52,199,89,0.04);
    --noise-opacity: 0.03;
    --section-fade: linear-gradient(180deg, var(--bg) 0%, var(--bg-secondary) 100%);
}

/* ═══ Dark Theme ═══ */
[data-theme="dark"] {
    --bg: #000000;
    --bg-secondary: #1c1c1e;
    --bg-tertiary: #0a0a0a;
    --bg-elevated: #1c1c1e;
    --bg-blur: rgba(28,28,30,0.72);
    --border: rgba(255,255,255,0.08);
    --border-strong: rgba(255,255,255,0.14);
    --text-primary: #f5f5f7;
    --text-secondary: #a1a1a6;
    --text-tertiary: #86868b;
    --text-quaternary: #636366;
    --card-bg: #1c1c1e;
    --card-border: rgba(255,255,255,0.06);
    --card-shadow: 0 2px 12px rgba(0,0,0,0.3);
    --input-bg: #2c2c2e;
    --input-border: rgba(255,255,255,0.1);
    --input-focus: var(--accent);
    --nav-bg: rgba(28,28,30,0.72);
    --badge-bg: #2c2c2e;
    --code-bg: #2c2c2e;
    --hover-bg: rgba(255,255,255,0.04);
    --overlay: rgba(0,0,0,0.6);
    --glow: rgba(0,113,227,0.2);
    --dot-color: rgba(255,255,255,0.03);
    --mesh-1: rgba(0,113,227,0.08);
    --mesh-2: rgba(88,86,214,0.06);
    --mesh-3: rgba(52,199,89,0.05);
    --noise-opacity: 0.015;
    --section-fade: linear-gradient(180deg, var(--bg) 0%, var(--bg-secondary) 100%);
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
    --shadow: 0 2px 8px rgba(0,0,0,0.25);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
}

/* Auto system preference */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --dot-color: rgba(255,255,255,0.03);
        --mesh-1: rgba(0,113,227,0.08);
        --mesh-2: rgba(88,86,214,0.06);
        --mesh-3: rgba(52,199,89,0.05);
        --noise-opacity: 0.015;
        --section-fade: linear-gradient(180deg, var(--bg) 0%, var(--bg-secondary) 100%);
        --bg: #000000;
        --bg-secondary: #1c1c1e;
        --bg-tertiary: #0a0a0a;
        --bg-elevated: #1c1c1e;
        --bg-blur: rgba(28,28,30,0.72);
        --border: rgba(255,255,255,0.08);
        --border-strong: rgba(255,255,255,0.14);
        --text-primary: #f5f5f7;
        --text-secondary: #a1a1a6;
        --text-tertiary: #86868b;
        --text-quaternary: #636366;
        --card-bg: #1c1c1e;
        --card-border: rgba(255,255,255,0.06);
        --card-shadow: 0 2px 12px rgba(0,0,0,0.3);
        --input-bg: #2c2c2e;
        --input-border: rgba(255,255,255,0.1);
        --input-focus: var(--accent);
        --nav-bg: rgba(28,28,30,0.72);
        --badge-bg: #2c2c2e;
        --code-bg: #2c2c2e;
        --hover-bg: rgba(255,255,255,0.04);
        --overlay: rgba(0,0,0,0.6);
        --glow: rgba(0,113,227,0.2);
        --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
        --shadow: 0 2px 8px rgba(0,0,0,0.25);
        --shadow-md: 0 4px 16px rgba(0,0,0,0.3);
        --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
    }
}

/* ═══ Base ═══ */
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.5;
    transition: background 0.4s ease, color 0.3s ease;
    overflow-x: hidden;
}
/* Subtle dot grid background */
body::before {
    content: '';
    position: fixed; inset: 0; z-index: -2;
    background-image: radial-gradient(circle, var(--dot-color) 1px, transparent 1px);
    background-size: 24px 24px;
    pointer-events: none;
    transition: background-image 0.4s ease;
}
/* Noise texture overlay */
body::after {
    content: '';
    position: fixed; inset: 0; z-index: -1;
    opacity: var(--noise-opacity);
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    pointer-events: none;
    transition: opacity 0.4s ease;
}
a { color: var(--accent); text-decoration: none; transition: opacity var(--transition); }
a:hover { opacity: 0.8; }
img { max-width: 100%; display: block; }

/* ═══ Typography ═══ */
.t-headline { font-size: 3.5rem; font-weight: 700; letter-spacing: -0.025em; line-height: 1.1; color: var(--text-primary); }
.t-title { font-size: 2.5rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; color: var(--text-primary); }
.t-subtitle { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.01em; line-height: 1.3; }
.t-body-lg { font-size: 1.125rem; line-height: 1.5; color: var(--text-secondary); }
.t-body { font-size: 0.9375rem; line-height: 1.5; color: var(--text-secondary); }
.t-caption { font-size: 0.8125rem; line-height: 1.4; color: var(--text-tertiary); }
.t-small { font-size: 0.75rem; color: var(--text-tertiary); }
.t-center { text-align: center; }

/* ═══ Layout ═══ */
.container { max-width: var(--max-w); margin: 0 auto; padding: 0 1.5rem; }
.container-lg { max-width: var(--max-w-lg); margin: 0 auto; padding: 0 1.5rem; }
.section { padding: 5rem 0; position: relative; }
.section-alt { background: var(--bg-secondary); transition: background 0.4s ease; }
/* Smooth gradient fade between sections */
.section-alt::before {
    content: ''; position: absolute; top: -2rem; left: 0; right: 0; height: 4rem;
    background: linear-gradient(180deg, var(--bg), var(--bg-secondary));
    pointer-events: none;
}
.section-alt::after {
    content: ''; position: absolute; bottom: -2rem; left: 0; right: 0; height: 4rem;
    background: linear-gradient(180deg, var(--bg-secondary), var(--bg));
    pointer-events: none; z-index: 1;
}

/* ═══ Navbar ═══ */
.nav {
    position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
    height: 52px;
    background: var(--nav-bg);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    transition: background 0.4s ease, border-color 0.4s ease;
}
.nav-inner {
    max-width: var(--max-w);
    width: 100%; padding: 0 1.5rem;
    display: flex; align-items: center; justify-content: space-between;
}
.nav-brand {
    font-size: 1.0625rem; font-weight: 600;
    color: var(--text-primary); letter-spacing: -0.01em;
}
.nav-links { display: flex; align-items: center; gap: 1.75rem; }
.nav-links a {
    font-size: 0.8125rem; color: var(--text-secondary);
    font-weight: 400; transition: color var(--transition);
}
.nav-links a:hover { color: var(--text-primary); opacity: 1; }
.nav-cta {
    background: var(--accent); color: #fff !important;
    padding: 0.375rem 0.875rem; border-radius: var(--radius-xl);
    font-size: 0.8125rem; font-weight: 500;
    transition: background var(--transition);
}
.nav-cta:hover { background: var(--accent-hover); opacity: 1 !important; }

/* Theme toggle */
.theme-toggle {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--hover-bg); border: none;
    color: var(--text-secondary); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem; transition: all var(--transition);
}
.theme-toggle:hover { background: var(--border); }

/* ═══ Buttons ═══ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none; border-radius: var(--radius-xl);
    font-family: var(--font); font-size: 0.9375rem; font-weight: 500;
    cursor: pointer; transition: all var(--transition);
    text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); opacity: 1; transform: scale(1.02); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn-secondary {
    background: transparent; color: var(--accent);
    border: 1px solid var(--border-strong);
}
.btn-secondary:hover { background: var(--hover-bg); opacity: 1; }
.btn-sm {
    padding: 0.4rem 0.85rem; font-size: 0.8125rem;
    border-radius: var(--radius-sm);
}
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }

/* ═══ Cards ═══ */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow);
    padding: 1.5rem;
    transition: background 0.4s ease, border-color 0.4s ease, box-shadow 0.3s ease, transform 0.2s ease;
}
.card:hover { box-shadow: var(--shadow-md); }
/* Gradient mesh utility — apply to sections for colored orbs */
.mesh-bg { position: relative; overflow: hidden; }
.mesh-bg::before {
    content: ''; position: absolute; top: -20%; right: -10%; width: 50%; height: 60%;
    background: radial-gradient(ellipse, var(--mesh-1) 0%, transparent 70%);
    pointer-events: none; filter: blur(60px);
}
.mesh-bg::after {
    content: ''; position: absolute; bottom: -20%; left: -10%; width: 40%; height: 50%;
    background: radial-gradient(ellipse, var(--mesh-2) 0%, transparent 70%);
    pointer-events: none; filter: blur(60px);
}
.card-title {
    font-size: 0.8125rem; font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase; letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

/* ═══ Forms ═══ */
.form-group { margin-bottom: 1rem; }
.form-label {
    display: block; font-size: 0.8125rem; font-weight: 500;
    color: var(--text-secondary); margin-bottom: 0.375rem;
}
.form-input {
    width: 100%; padding: 0.625rem 0.875rem;
    background: var(--input-bg); border: 1px solid var(--input-border);
    border-radius: var(--radius-sm); color: var(--text-primary);
    font-family: var(--font); font-size: 0.9375rem;
    outline: none; transition: background 0.4s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.2s ease;
}
.form-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.form-input::placeholder { color: var(--text-quaternary); }

select.form-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2386868b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}

/* Checkbox / Radio — Apple style */
.opt-check, .opt-radio {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.5rem 0.625rem; border-radius: var(--radius-sm);
    cursor: pointer; transition: background var(--transition);
    font-size: 0.875rem; color: var(--text-primary);
}
.opt-check:hover, .opt-radio:hover { background: var(--hover-bg); }
.opt-check input[type="checkbox"], .opt-radio input[type="radio"] {
    appearance: none; width: 18px; height: 18px;
    border: 1.5px solid var(--border-strong); background: var(--input-bg);
    cursor: pointer; flex-shrink: 0; transition: all var(--transition);
}
.opt-check input[type="checkbox"] { border-radius: 5px; }
.opt-radio input[type="radio"] { border-radius: 50%; }
.opt-check input:checked, .opt-radio input:checked {
    background: var(--accent); border-color: var(--accent);
}
.opt-check input:checked::after {
    content: ''; display: block; width: 5px; height: 9px;
    border: solid #fff; border-width: 0 2px 2px 0;
    transform: rotate(45deg); margin: 1px auto 0;
}
.opt-radio input:checked::after {
    content: ''; display: block; width: 8px; height: 8px;
    background: #fff; border-radius: 50%; margin: 3px auto 0;
}
.opt-desc { font-size: 0.75rem; color: var(--text-tertiary); margin-left: auto; }
.opt-warn { font-size: 0.7rem; color: var(--warning); margin-left: 0.5rem; }

/* ═══ Badge ═══ */
.badge {
    display: inline-flex; align-items: center;
    padding: 0.2rem 0.6rem; border-radius: 6px;
    font-size: 0.75rem; font-weight: 500;
}
.badge-blue { background: var(--accent-light); color: var(--accent); }
.badge-green { background: rgba(52,199,89,0.12); color: var(--success); }
.badge-red { background: rgba(255,59,48,0.12); color: var(--danger); }
.badge-orange { background: rgba(255,159,10,0.12); color: var(--warning); }
.badge-gray { background: var(--badge-bg); color: var(--text-tertiary); }

/* ═══ Table ═══ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th {
    text-align: left; padding: 0.625rem 0.75rem;
    font-size: 0.75rem; font-weight: 600;
    color: var(--text-tertiary); text-transform: uppercase;
    letter-spacing: 0.04em; border-bottom: 1px solid var(--border);
}
td {
    padding: 0.625rem 0.75rem; border-bottom: 1px solid var(--border);
    vertical-align: middle; color: var(--text-primary);
}
tr:hover td { background: var(--hover-bg); }
.td-mono { font-family: var(--font-mono); font-size: 0.8125rem; }

/* ═══ Modal ═══ */
.modal-overlay {
    display: none; position: fixed; inset: 0; z-index: 2000;
    background: var(--overlay); align-items: center; justify-content: center;
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--bg-elevated); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg); padding: 1.5rem;
    min-width: 380px; max-width: 90vw;
    border: 1px solid var(--border);
}
.modal h3 {
    font-size: 1.125rem; font-weight: 600;
    margin-bottom: 1.25rem; color: var(--text-primary);
}
.modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1.25rem; }

/* ═══ Log box ═══ */
.log-box {
    background: var(--code-bg); border-radius: var(--radius-sm); transition: background 0.4s ease, color 0.3s ease;
    padding: 0.75rem; max-height: 280px; overflow-y: auto;
    font-family: var(--font-mono); font-size: 0.78rem;
    line-height: 1.6; color: var(--text-secondary);
}
.log-line { padding: 0.1rem 0; }
.log-info { color: var(--text-secondary); }
.log-warn { color: var(--warning); }
.log-err { color: var(--danger); }

/* ═══ Alert ═══ */
.alert {
    padding: 0.75rem 1rem; border-radius: var(--radius-sm);
    font-size: 0.8125rem; margin-bottom: 1rem;
}
.alert-info { background: var(--accent-light); color: var(--accent); }
.alert-warn { background: rgba(255,159,10,0.1); color: var(--warning); }
.alert-success { background: rgba(52,199,89,0.1); color: var(--success); }
.alert-error { background: rgba(255,59,48,0.1); color: var(--danger); }

/* ═══ Progress ═══ */
.progress-wrap {
    height: 4px; background: var(--border); border-radius: 2px;
    overflow: hidden; margin: 0.75rem 0;
}
.progress-bar {
    height: 100%; background: var(--accent); border-radius: 2px;
    transition: width 0.3s ease;
}
.progress-bar.indeterminate {
    width: 30%; animation: indeterminate 1.5s infinite ease-in-out;
}
@keyframes indeterminate {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(400%); }
}

/* ═══ Utility ═══ */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-sm { gap: 0.5rem; }
.gap { gap: 1rem; }
.gap-lg { gap: 1.5rem; }
.mt-1 { margin-top: 0.5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; }
.pt-nav { padding-top: 52px; }
.hidden { display: none !important; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.text-warn { color: var(--warning); }
.text-accent { color: var(--accent); }
.text-dim { color: var(--text-secondary); }
.fw-600 { font-weight: 600; }
.tabular { font-variant-numeric: tabular-nums; }

/* Grid */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }

/* ═══ Responsive ═══ */
@media (max-width: 768px) {
    .t-headline { font-size: 2.25rem; }
    .t-title { font-size: 1.75rem; }
    .t-subtitle { font-size: 1.25rem; }
    .section { padding: 3rem 0; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .nav-links { gap: 1rem; }
    .nav-links .hide-mobile { display: none; }
    .container, .container-lg { padding: 0 1rem; }
    .modal { min-width: auto; margin: 1rem; }
}
@media (max-width: 480px) {
    .t-headline { font-size: 1.875rem; }
    .nav-links { gap: 0.75rem; }
    .btn { padding: 0.625rem 1.25rem; font-size: 0.875rem; }
}

/* ═══ Footer ═══ */
.site-footer {
    border-top: 1px solid var(--border);
    padding: 2rem 0;
    text-align: center;
}
.site-footer p { font-size: 0.75rem; color: var(--text-tertiary); }
.footer-links { display: flex; gap: 1.5rem; justify-content: center; margin-bottom: 0.75rem; }
.footer-links a { font-size: 0.8125rem; color: var(--text-secondary); }
