:root {
    color-scheme: light dark;
    --background: #f3f5f8;
    --surface: #ffffff;
    --surface-alt: #eef1f5;
    --text: #20242c;
    --muted: #687080;
    --border: #d8dde6;
    --primary: #2f64d6;
    --primary-hover: #2452b5;
    --danger: #b53333;
    --success-bg: #e7f6ed;
    --success-text: #145c31;
    --error-bg: #fdeaea;
    --error-text: #842626;
    --info-bg: #e8f1ff;
    --info-text: #244e84;
    --shadow: 0 10px 30px rgba(25, 35, 55, 0.08);
    --radius: 16px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --background: #15181e;
        --surface: #20242c;
        --surface-alt: #292e38;
        --text: #f1f4f8;
        --muted: #b3bac6;
        --border: #3c4350;
        --primary: #7ea5ff;
        --primary-hover: #9bb9ff;
        --danger: #ff8585;
        --success-bg: #173725;
        --success-text: #b7f3ca;
        --error-bg: #492326;
        --error-text: #ffc4c8;
        --info-bg: #20334f;
        --info-text: #c7dcff;
        --shadow: 0 12px 35px rgba(0, 0, 0, 0.22);
    }
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
    min-height: 100vh;
    margin: 0;
    background: var(--background);
    color: var(--text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}
a { color: var(--primary); }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; }
.container { width: min(1180px, calc(100% - 32px)); margin-inline: auto; }
.site-header { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--surface) 94%, transparent); border-bottom: 1px solid var(--border); backdrop-filter: blur(12px); }
.header-inner { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 800; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border: 7px solid var(--primary); border-radius: 50%; }
.main-navigation { display: flex; align-items: center; gap: 20px; }
.main-navigation a { color: var(--text); text-decoration: none; font-weight: 650; }
.main-navigation a:hover { color: var(--primary); }
.menu-button { display: none; }
.main-content { min-height: calc(100vh - 138px); padding-block: 32px 48px; }
.site-footer { border-top: 1px solid var(--border); background: var(--surface); }
.footer-inner { min-height: 70px; display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 0.9rem; }
h1, h2 { line-height: 1.15; margin-top: 0; }
h1 { font-size: clamp(1.8rem, 4vw, 2.5rem); margin-bottom: 8px; }
h2 { font-size: 1.2rem; }
p { margin-top: 0; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.page-heading p { color: var(--muted); margin-bottom: 0; }
.button { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; padding: 9px 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-alt); color: var(--text); font-weight: 750; text-decoration: none; cursor: pointer; }
.button:hover { filter: brightness(0.97); }
.button-primary { border-color: var(--primary); background: var(--primary); color: #ffffff; }
.button-primary:hover { background: var(--primary-hover); }
.button-danger { color: var(--danger); }
.button-small { min-height: 38px; padding: 7px 12px; }
.button-push-right { margin-left: auto; }
.alert { padding: 14px 16px; margin-bottom: 20px; border-radius: 12px; }
.alert-success { background: var(--success-bg); color: var(--success-text); }
.alert-error { background: var(--error-bg); color: var(--error-text); }
.alert-info { background: var(--info-bg); color: var(--info-text); }
.auth-shell { min-height: 68vh; display: grid; place-items: center; }
.auth-panel { width: min(100%, 460px); }
.auth-panel > p { color: var(--muted); }
.auth-switch { margin: 22px 0 0; text-align: center; }
.form-stack { display: grid; gap: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.form-grid label, .form-stack label { display: grid; gap: 7px; font-weight: 700; }
.field-span-2 { grid-column: 1 / -1; }
input, select, textarea { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--background); color: var(--text); }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid color-mix(in srgb, var(--primary) 25%, transparent); border-color: var(--primary); }
.checkbox-group { display: flex; flex-wrap: wrap; gap: 16px 24px; border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.checkbox-group legend { padding-inline: 8px; font-weight: 800; }
.checkbox-group label { display: inline-flex; align-items: center; gap: 8px; }
.checkbox-group input { width: 20px; min-height: 20px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 12px; padding-top: 6px; }
.narrow-form { max-width: 620px; }
.filter-bar { display: grid; grid-template-columns: minmax(220px, 1fr) auto auto auto; gap: 12px; margin-bottom: 24px; padding: 16px; }
.filter-bar input, .filter-bar select { min-height: 44px; }
.pokemon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; }
.pokemon-card { overflow: hidden; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.pokemon-card.is-favorite { border-color: #e2b331; }
.pokemon-image-wrap { position: relative; display: grid; place-items: center; min-height: 210px; padding: 20px; background: linear-gradient(145deg, var(--surface-alt), var(--surface)); }
.pokemon-image-wrap img { width: 180px; height: 180px; object-fit: contain; }
.pokemon-card-body { padding: 18px; }
.pokemon-card-body h2 { margin-bottom: 4px; }
.pokemon-number { color: var(--muted); font-size: 0.85rem; font-weight: 800; }
.muted { color: var(--muted); }
.badge { position: absolute; left: 12px; top: 12px; padding: 5px 9px; border-radius: 999px; font-size: 0.78rem; font-weight: 800; }
.badge-shiny { background: #ffe69b; color: #604900; }
.favorite-mark { position: absolute; right: 14px; top: 10px; color: #e2b331; font-size: 1.6rem; }
.compact-details { margin: 16px 0; }
.compact-details div { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-bottom: 1px solid var(--border); }
.compact-details dt { color: var(--muted); }
.compact-details dd { margin: 0; text-align: right; font-weight: 700; }
.card-actions { display: flex; justify-content: flex-end; }
.empty-state { text-align: center; padding: 42px 24px; }
.empty-state img { width: 140px; margin-bottom: 12px; opacity: 0.75; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 760px) {
    .container { width: min(100% - 22px, 1180px); }
    .header-inner { min-height: 62px; }
    .menu-button { display: inline-flex; min-height: 40px; align-items: center; padding: 7px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-alt); color: var(--text); font-weight: 750; }
    .main-navigation { display: none; position: absolute; top: 62px; left: 11px; right: 11px; flex-direction: column; align-items: stretch; gap: 0; padding: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
    .main-navigation.is-open { display: flex; }
    .main-navigation a { padding: 12px; border-radius: 8px; }
    .main-content { padding-block: 22px 36px; }
    .page-heading { align-items: stretch; flex-direction: column; gap: 14px; }
    .page-heading .button { width: 100%; }
    .filter-bar { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; padding: 18px; }
    .field-span-2 { grid-column: auto; }
    .form-actions .button { flex: 1 1 140px; }
    .button-push-right { margin-left: 0; }
    .pokemon-grid { grid-template-columns: 1fr; }
    .pokemon-card { display: grid; grid-template-columns: 132px minmax(0, 1fr); }
    .pokemon-image-wrap { min-height: 100%; padding: 12px; }
    .pokemon-image-wrap img { width: 108px; height: 108px; }
    .pokemon-card-body { padding: 15px; }
    .compact-details div:nth-child(n+3) { display: none; }
    .footer-inner { padding-block: 16px; flex-direction: column; justify-content: center; gap: 4px; }
}

@media (max-width: 420px) {
    .brand span:last-child { display: none; }
    .pokemon-card { grid-template-columns: 112px minmax(0, 1fr); }
    .pokemon-image-wrap img { width: 92px; height: 92px; }
}
.field-help { color: var(--muted); font-size: 0.88rem; font-weight: 500; }
