/* ===== CSS Variables ===== */
:root {
    color-scheme: light;

    /* Modern Palette using OKLCH (Best Practices 2026) */
    --color-primary: oklch(0.74 0.13 228);
    --color-primary-dark: oklch(0.66 0.14 228);
    --color-secondary: oklch(0.8 0.12 78);
    --color-success: oklch(0.76 0.11 156);
    --color-success-dark: oklch(0.68 0.11 156);
    --color-danger: oklch(0.7 0.15 26);
    --color-danger-dark: oklch(0.63 0.15 26);
    --color-warning: oklch(0.86 0.12 88);

    --color-bg: oklch(0.985 0.01 90);
    --color-bg-light: oklch(0.965 0.02 235);
    --color-bg-card: oklch(0.995 0.006 100);
    --color-bg-hover: oklch(0.94 0.02 235);

    --color-text-high-contrast: oklch(0.32 0.03 255);
    --color-text-strong: oklch(0.36 0.03 255);
    --color-text-soft: oklch(0.5 0.03 250);
    --color-text: var(--color-text-strong);
    --color-text-muted: oklch(0.58 0.03 248);
    --color-text-dim: oklch(0.66 0.025 245);
    --color-border-strong: rgba(125, 149, 187, 0.26);
    --color-surface-strong: oklch(0.95 0.015 235);

    /* Fluid Typography (Step 1) */
    --text-xs: clamp(0.7rem, 0.65rem + 0.25vw, 0.8rem);
    --text-sm: clamp(0.8rem, 0.75rem + 0.25vw, 0.9rem);
    --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
    --text-lg: clamp(1.25rem, 1.1rem + 0.75vw, 1.5rem);
    --text-xl: clamp(1.5rem, 1.3rem + 1vw, 2rem);
    --text-2xl: clamp(2rem, 1.7rem + 1.5vw, 3rem);
    --text-3xl: clamp(1.95rem, 1.85rem + 1.4vw, 2.9rem);
    --text-4xl: clamp(2.5rem, 2.3rem + 1.8vw, 3.7rem);
    --text-5xl: clamp(3rem, 2.8rem + 2.25vw, 4.4rem);
    --text-display: clamp(3.6rem, 3.1rem + 2.6vw, 5rem);
    --text-helper: clamp(0.75rem, 0.75rem + 0.1vw, 0.85rem);
    --text-heading-tight: 1.1;
    --text-heading-loose: 1.4;
    --line-height-base: 1.6;
    --line-height-snug: 1.35;
    --line-height-relaxed: 1.8;
    --font-heading-weight: 700;
    --font-body-weight: 500;
    --type-scale: clamp(0.98, 0.92 + 0.05vw, 1.08);

    /* Spacing Tokens (Step 16) */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-6: 1.5rem;
    --space-8: 2rem;

    --touch-inline-gap: clamp(0.4rem, 0.35vw, 0.8rem);
    --touch-stack-gap: clamp(0.6rem, 0.45vw, 0.95rem);
    --touch-target-height: clamp(44px, 3vw, 52px);

    --gradient-primary: linear-gradient(135deg, var(--color-primary) 0%, oklch(0.74 0.12 12) 100%);
    --gradient-gold: linear-gradient(135deg, oklch(0.9 0.11 92) 0%, oklch(0.82 0.13 72) 100%);
    --gradient-success: linear-gradient(135deg, var(--color-success) 0%, var(--color-success-dark) 100%);
    --gradient-card: linear-gradient(145deg, rgba(255, 255, 255, 0.98) 0%, rgba(244, 249, 255, 0.94) 100%);

    --shadow-sm: 0 8px 18px rgba(108, 133, 176, 0.14);
    --shadow-md: 0 18px 34px rgba(108, 133, 176, 0.16);
    --shadow-lg: 0 28px 60px rgba(108, 133, 176, 0.18);
    --shadow-glow: 0 0 20px oklch(0.74 0.13 228 / 0.18);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s ease;

    /* Safe Area Insets (2026 Mobile support) */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);

    /* App shell metrics (synced in main.js) */
    --header-height: 96px;
    --bottom-nav-height: 0px;
    --fab-safe-offset: 76px;

    /* Layer map */
    --layer-toast: 2000;
    --layer-header: 2600;
    --layer-nav: 2200;
    --layer-dropdown: 2400;
    --layer-modal: 3000;
}

:root[data-age-theme='6-9'] {
    --color-primary: oklch(0.75 0.14 156);
    --color-secondary: oklch(0.8 0.12 220);
    --radius-md: 14px;
    --radius-lg: 18px;
    --text-base: clamp(1.02rem, 1rem + 0.25vw, 1.18rem);
}

:root[data-age-theme='10-14'] {
    --color-primary: oklch(0.72 0.13 228);
    --color-secondary: oklch(0.74 0.1 318);
}


/* ===== Reset & Base ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    overflow-x: clip;
}

body {
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--color-bg);
    color: var(--color-text-strong);
    min-height: 100vh;
    min-height: 100dvh;
    /* Dynamic viewport height */
    line-height: var(--line-height-base);
    /* Increased for better readability on mobile */
    font-weight: var(--font-body-weight);
    -webkit-font-smoothing: antialiased;
    padding-left: var(--safe-left);
    padding-right: var(--safe-right);
    font-size: var(--text-base);
    overflow-x: clip;
}

/* Global touch-target optimization */
button,
.btn,
.nav__btn,
.nav__more,
.nav__dropdown-item,
.section__buttons button,
.card__actions button,
.history-item button,
.modal button,
.input-field,
.header__balance {
    min-height: var(--touch-target-height);
    touch-action: manipulation;
}

/* ===== Accessibility & Focus (Step 15) ===== */
.header__balance:focus-visible,
.btn:focus-visible,
.nav__btn:focus-visible {
    outline: 3px solid var(--color-primary);
    outline-offset: 3px;
}

/* Base styles for scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--color-bg);
}

::-webkit-scrollbar-thumb {
    background: var(--color-bg-card);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-bg-hover);
}

/* ===== Utilities ===== */
.hidden {
    display: none !important;
}
/* ===== Motion Sensitivity (Step 14) ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}


/* ===== Header ===== */
.skip-link {
    position: absolute;
    left: -9999px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.skip-link:focus-visible {
    left: 1rem;
    top: calc(var(--safe-top) + 0.5rem);
    width: auto;
    height: auto;
    padding: 0.6rem 0.9rem;
    border-radius: var(--radius-md);
    background: var(--gradient-primary);
    color: #ffffff;
    font-weight: 700;
    z-index: 3100;
    box-shadow: var(--shadow-md);
}

.header {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0.9rem;
    padding: calc(0.7rem + var(--safe-top)) 1rem 0.55rem;
    background:
        linear-gradient(135deg, #ffb65c 0%, #ff8f70 100%);
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: var(--layer-header);
    backdrop-filter: saturate(1.05) blur(4px);
}

.header__system-row,
.header__status-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.header__system-row {
    flex: 1 1 auto;
    justify-content: space-between;
    min-width: 0;
}

.header__status-row {
    flex: 0 0 auto;
    justify-content: flex-end;
}

.header__logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header__icon {
    width: 2.4rem;
    height: 2.4rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    animation: coin-bounce 2s ease-in-out infinite;
}

@keyframes coin-bounce {

    0%,
    100% {
        transform: translateY(0) rotate(0deg);
    }

    50% {
        transform: translateY(-5px) rotate(10deg);
    }
}

.header h1 {
    font-size: var(--text-3xl);
    font-weight: var(--font-heading-weight);
    line-height: var(--text-heading-loose);
    letter-spacing: -0.02em;
    color: var(--color-text-high-contrast);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.header__actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.header__install {
    width: auto;
    max-width: 100%;
}

.header__profile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    white-space: nowrap;
    color: var(--color-text-high-contrast);
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(125, 149, 187, 0.28);
    box-shadow: 0 10px 22px rgba(108, 133, 176, 0.18);
}

.header__profile:hover {
    background: rgba(255, 255, 255, 0.96);
    color: var(--color-text-high-contrast);
}

.header__profile .gamified-icon {
    flex-shrink: 0;
}

.header__profile-label,
.header__child-nickname {
    color: var(--color-text-high-contrast);
}

.header__child-nickname {
    font-size: 0.82rem;
    line-height: 1.2;
    color: rgba(44, 63, 92, 0.88);
}

.header__install-hint {
    width: auto;
    max-width: 44%;
    font-size: 0.72rem;
    line-height: 1.25;
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.96);
}

.header__balance {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: transparent;
    padding: 0.1rem 0;
    border-radius: var(--radius-md);
    font-weight: 700;
    cursor: pointer;
    transition: color var(--transition-fast), transform var(--transition-normal);
    border: none;
    position: relative;
    will-change: transform;
    backface-visibility: hidden;
    min-height: 44px;
    margin-left: auto;
}

.header__balance:hover {
    transform: translateY(-1px);
}

.header__balance::after {
    content: 'История';
    position: absolute;
    right: 0;
    bottom: -0.7rem;
    font-size: 0.6rem;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.58);
    text-transform: uppercase;
}

.header__balance-main {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.section__header > h2,
.section > h2,
.cards h2 {
    font-size: var(--text-2xl);
    line-height: var(--line-height-snug);
    font-weight: var(--font-heading-weight);
    color: var(--color-text-high-contrast);
}

.header__earned {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-width: auto;
}

.header__earned-main {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.92);
    font-weight: 700;
}

.header__earned-limit {
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.72);
}

.header__balance-delta {
    position: absolute;
    top: -0.45rem;
    right: 0;
    padding: 0.15rem 0.35rem;
    border-radius: 999px;
    font-size: 0.74rem;
    line-height: 1;
    color: #ffffff;
    background: rgba(34, 197, 94, 0.95);
    transform: translateY(8px);
    opacity: 0;
    pointer-events: none;
}

.header__balance-delta.is-negative {
    background: rgba(239, 68, 68, 0.95);
}

.header__balance-delta.is-visible {
    animation: balance-delta-rise 280ms ease-out forwards;
}

@keyframes balance-delta-rise {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(-2px);
    }
}

.balance__value {
    font-size: 1.7rem;
    color: #fef08a;
    text-shadow: 0 0 10px rgba(254, 240, 138, 0.5);
    min-width: 44px;
    text-align: center;
}

.balance__coin {
    width: 1.15rem;
    height: 1.15rem;
    animation: coin-rotate 5s linear infinite;
    transform-origin: center;
    will-change: transform;
    transform-style: preserve-3d;
    backface-visibility: hidden;
}

@keyframes coin-rotate {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* ===== Navigation ===== */
.nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--touch-stack-gap);
    padding: 0.75rem 1rem;
    background: var(--color-bg-light);
    border-bottom: 1px solid var(--color-bg-card);
    position: relative;
    z-index: var(--layer-nav);
    --nav-height: 68px;
    --nav-fab-size: 56px;
    min-height: var(--nav-height);
    box-shadow: inset 0 -1px 0 rgba(15, 23, 42, 0.1);
}

.nav__primary {
    display: flex;
    align-items: center;
    gap: var(--touch-inline-gap);
    flex-wrap: nowrap;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    justify-content: flex-start;
    overflow: visible;
    padding-inline: 0.5rem;
}

.nav__group {
    display: flex;
    align-items: center;
    gap: var(--touch-inline-gap);
    flex: 0 1 auto;
    flex-wrap: nowrap;
}

.nav__group--child {
    justify-content: flex-start;
    order: 0;
}

.nav__group--parent {
    justify-content: flex-start;
    order: 1;
}

.nav__child-switcher {
    margin-right: 0.25rem;
    flex-shrink: 0;
    position: sticky;
    left: 0;
    z-index: calc(var(--layer-nav) + 100);
    order: 2;
    flex: 0 0 auto;
}

.nav__more-wrapper {
    position: relative;
    flex-shrink: 0;
    z-index: calc(var(--layer-nav) + 100);
    order: 3;
    margin-left: auto;
}

.nav__more {
    padding: 0.65rem 0.75rem;
    border-radius: var(--radius-lg);
    border: 1px solid transparent;
    background: transparent;
    color: var(--color-text-muted);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition-normal), color var(--transition-normal), border-color var(--transition-normal);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 96px;
    justify-content: center;
}

.nav__more:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--color-text);
}

.nav__more.active {
    background: rgba(99, 102, 241, 0.22);
    color: #ffffff;
    border-color: rgba(165, 180, 252, 0.7);
}

.nav__dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    background: var(--color-bg-card);
    border-radius: var(--radius-lg);
    padding: 0.25rem 0;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    z-index: var(--layer-dropdown);
    min-width: 220px;
}

.nav__dropdown.is-floating {
    position: fixed;
    top: auto;
    left: 0;
    right: auto;
    bottom: auto;
    max-width: calc(100vw - 1rem);
    max-height: min(60vh, calc(100dvh - 120px));
    overflow-y: auto;
}

.nav__dropdown::before {
    content: '';
    position: absolute;
    top: -6px;
    right: 1rem;
    border: 6px solid transparent;
    border-bottom-color: var(--color-bg-card);
}

.nav__dropdown-item {
    width: 100%;
    padding: 0.65rem 1rem;
    border: none;
    background: transparent;
    color: var(--color-text);
    font-size: 1rem;
    text-align: left;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition-normal);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.nav__dropdown-item .gamified-icon {
    width: 1.2rem;
    height: 1.2rem;
    border-radius: 10px;
    flex: 0 0 auto;
}

.nav__dropdown-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.nav__dropdown-item.active {
    background: rgba(99, 102, 241, 0.28);
    color: #ffffff;
}

.nav--pending {
    opacity: 0;
    visibility: hidden;
    min-height: 66px;
}

.nav__btn {
    padding: 0.65rem 0.9rem;
    border: 1px solid transparent;
    border-radius: var(--radius-lg);
    background: transparent;
    color: var(--color-text-muted);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition-normal), color var(--transition-normal), transform 180ms ease, border-color var(--transition-normal);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    flex-shrink: 0;
    min-width: 112px;
    white-space: nowrap;
    text-align: center;
    scroll-snap-align: start;
}

.nav__btn-icon {
    font-size: 1rem;
    line-height: 1;
    min-width: 1.9rem;
    min-height: 1.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.nav__btn-label {
    line-height: 1.2;
}

.nav__btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--color-text);
}

.nav__btn.active {
    background: rgba(99, 102, 241, 0.24);
    color: white;
    border-color: rgba(165, 180, 252, 0.85);
    transform: scale(1.03);
}

.nav__fab {
    border: none;
    width: var(--nav-fab-size);
    height: var(--nav-fab-size);
    border-radius: 999px;
    background: var(--gradient-primary);
    color: #ffffff;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.12rem;
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(79, 70, 229, 0.35);
    transition: transform 180ms ease, box-shadow 180ms ease;
    margin-left: 0.2rem;
}

.nav__fab:hover {
    transform: translateY(-1px) scale(1.03);
    box-shadow: 0 10px 24px rgba(79, 70, 229, 0.45);
}

.nav__fab-icon {
    font-size: 1.15rem;
    line-height: 1;
    width: 1.6rem;
    height: 1.6rem;
}

.nav__fab .gamified-icon {
    width: 1.4rem;
    height: 1.4rem;
}

.nav__fab-label {
    font-size: 0.62rem;
    line-height: 1;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ===== Main Content ===== */
.main {
    padding: clamp(1rem, 1.4vw, 1.5rem);
    padding-bottom: max(1.5rem, calc(var(--bottom-nav-height) + var(--safe-bottom) + 1rem));
    max-width: 1200px;
    margin: 0 auto;
}

.offline-banner {
    margin: 0 0 0.85rem;
    padding: 0.7rem 0.85rem;
    border-radius: var(--radius-md);
    border: 1px solid rgba(245, 158, 11, 0.45);
    background: rgba(245, 158, 11, 0.12);
    color: #fde68a;
    font-size: 0.85rem;
    line-height: 1.35;
}

.app-footer {
    margin-top: 2rem;
    padding: 0.75rem 0 0.25rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.72rem;
    color: rgba(148, 163, 184, 0.6);
}

.app-footer__meta {
    letter-spacing: 0.25px;
}

.app-footer__dot {
    opacity: 0.55;
}

.hidden {
    display: none !important;
}

.section.hidden {
    display: none !important;
    content-visibility: auto;
    contain-intrinsic-size: auto 500px;
}

.section {
    animation: sectionFadeIn linear both;
    animation-timeline: view();
    animation-range: entry 5% cover 25%;
}

@keyframes sectionFadeIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.today-grid,
.progress-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    margin-top: 1rem;
}

.today-card,
.progress-card {
    background: var(--color-bg-card);
    border-radius: var(--radius-lg);
    padding: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: var(--shadow-md);
}

.today-card__label,
.progress-card__label {
    font-size: 0.9rem;
    color: var(--color-text-dim);
    margin-bottom: 0.35rem;
}

.today-card__value,
.progress-card__value {
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
}

.today-card__list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.today-card__list p {
    margin: 0;
    color: var(--color-text-dim);
}

.today-card__actions {
    margin-top: 0.75rem;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

#today-section .today-card--parent .btn--primary {
    background: linear-gradient(135deg, #ffb65c 0%, #ff8f70 100%);
    color: #ffffff;
    box-shadow: 0 16px 28px -18px rgba(255, 143, 112, 0.5);
}

#today-section .today-card--parent .btn--primary:hover {
    box-shadow: 0 20px 30px -18px rgba(255, 143, 112, 0.58);
}

#today-section .today-card--parent .btn--secondary {
    background: rgba(255, 255, 255, 0.92);
    color: #425a7d;
    border: 1px solid rgba(125, 149, 187, 0.18);
}

.today-card__summary {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    min-height: 80px;
}

.today-task {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.35rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.today-task:last-child {
    border-bottom: none;
}

.today-task__title {
    font-weight: 600;
    color: var(--color-text);
}

.today-task__meta {
    font-size: 0.85rem;
    color: var(--color-text-dim);
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.today-request-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.progress-card__meter {
    position: relative;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    overflow: hidden;
    margin: 0.65rem 0;
}

.progress-card__fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #22c55e, #06b6d4);
    width: 0;
    transition: width var(--transition-normal);
}

.progress-card__footnote,
.progress-card__note,
.today-card__note {
    font-size: 0.75rem;
    color: var(--color-text-dim);
}

.progress-card--spent .progress-card__fill {
    background: linear-gradient(90deg, #f97316, #ef4444);
}

.progress-card--level .progress-card__fill {
    background: linear-gradient(90deg, #a78bfa, #6366f1);
}

.today-card__note--child {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.7);
}

.progress-card__child {
    margin-top: 0.25rem;
    font-size: 0.85rem;
    color: var(--color-text-dim);
}

.progress-card--streak .progress-card__value {
    font-size: 2rem;
}

.tag--status {
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    font-size: 0.65rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    text-transform: uppercase;
    border: 1px solid transparent;
}

.tag--status.pending {
    background: var(--state-pending-bg);
    color: var(--state-pending-text);
    border-color: var(--state-pending-border);
}

.tag--status.approved {
    background: var(--state-approved-bg);
    color: var(--state-approved-text);
    border-color: var(--state-approved-border);
}

.tag--status.rejected {
    background: var(--state-rejected-bg);
    color: var(--state-rejected-text);
    border-color: var(--state-rejected-border);
}

.tag--status.expired {
    background: var(--state-expired-bg);
    color: var(--state-expired-text);
    border-color: var(--state-expired-border);
}

.section__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 0.75rem;
}

.section__subtitle {
    margin: 0.35rem 0 0;
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}

.requests-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--touch-stack-gap);
    margin-bottom: 1rem;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.requests-summary__item {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-lg);
    background: var(--color-bg-card);
    border: 1px solid rgba(255, 255, 255, 0.12);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-height: 96px;
    justify-content: center;
}

.requests-summary__label {
    font-size: var(--text-xs);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-text-muted);
}

.requests-summary__hint {
    font-size: 0.75rem;
    color: var(--color-text-dim);
    margin-top: 0.2rem;
}

.requests-summary__empty {
    grid-column: 1 / -1;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-lg);
    border: 1px dashed rgba(255, 255, 255, 0.3);
    text-align: center;
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}

.section h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.section__buttons {
    display: flex;
    gap: var(--touch-inline-gap);
}


/* ===== Pull To Refresh ===== */
.pull-refresh-indicator {
    position: fixed;
    top: 0.55rem;
    left: 50%;
    transform: translate(-50%, -140%);
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: var(--shadow-sm);
    z-index: 2100;
    pointer-events: none;
    opacity: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.pull-refresh-indicator.active {
    opacity: 1;
}

.pull-refresh-indicator.ready .pull-refresh-indicator__icon {
    color: #86efac;
}

.pull-refresh-indicator.loading .pull-refresh-indicator__icon {
    animation: pullRefreshSpin 0.8s linear infinite;
}

.pull-refresh-indicator__icon {
    font-size: 0.95rem;
    color: #e2e8f0;
}

.pull-refresh-indicator__text {
    font-size: 0.75rem;
    color: #e2e8f0;
    white-space: nowrap;
}

@keyframes pullRefreshSpin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn:hover {
    transform: translateY(-2px);
}

.btn:active {
    transform: translateY(0);
}

.btn--primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn--primary:hover {
    box-shadow: var(--shadow-glow);
}

.btn--secondary {
    background: var(--color-bg-card);
    color: var(--color-text);
}

.btn--secondary:hover {
    background: var(--color-bg-hover);
}

.btn--success {
    background: var(--gradient-success);
    color: white;
}

.btn--danger {
    background: var(--color-danger);
    color: white;
}

.btn--danger:hover {
    background: var(--color-danger-dark);
}

.btn--admin {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn--admin:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn--admin.active {
    background: var(--gradient-gold);
    color: #1e293b;
    border-color: transparent;
}

.btn--add {
    background: var(--gradient-success);
    color: white;
}

.btn--small {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
}

/* ===== Accessible typography helpers ===== */
h1,
h2,
h3,
h4,
.section__header > h2,
.cards h3 {
    color: var(--color-text-high-contrast);
    line-height: var(--line-height-snug);
    font-weight: var(--font-heading-weight);
    letter-spacing: -0.01em;
}

p,
.card__comment,
.card__meta,
.history-item__note,
.section__subhead,
.modal__hint {
    color: var(--color-text-soft);
    line-height: var(--line-height-relaxed);
    font-weight: var(--font-body-weight);
}

/* ===== Cards Grid ===== */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    container-type: inline-size;
}

.card {
    background: linear-gradient(145deg, var(--color-bg-card) 0%, var(--color-surface-strong) 100%);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border-strong);
    color: var(--color-text-high-contrast);
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 100%;
}

.card__icon {
    width: 2.4rem;
    height: 2.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card__icon .gamified-icon {
    width: 2rem;
    height: 2rem;
}

#settings-cards .card {
    display: flex;
    flex-direction: column;
    grid-row: auto;
}

#settings-cards .card__actions {
    margin-top: 0.75rem;
}

#settings-cards {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

#settings-cards .settings-card {
    width: 100%;
    box-sizing: border-box;
    min-height: 360px;
    margin: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

@container (max-width: 350px) {
    .card {
        padding: 1rem;
    }

    .card__title {
        font-size: 1rem;
    }
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-primary);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: var(--shadow-md), var(--shadow-glow);
}

.card:active {
    transform: translateY(-2px) scale(1.01);
}

.card:hover::before {
    opacity: 1;
}

/* Step 4: Scroll-driven Animation for Cards */
.card {
    animation: cardAppear linear both;
    animation-timeline: view();
    animation-range: entry 0% entry 80%;
}

@keyframes cardAppear {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.card__badge-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.card__badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.75rem;
    border-radius: 999px;
    font-size: var(--text-xs);
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
    color: var(--color-text);
    white-space: nowrap;
}

.gamified-icon {
    width: 1.9rem;
    height: 1.9rem;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.gamified-icon.icon-calendar { background-image: url('/img/gamified/icon-calendar.svg'); }
.gamified-icon.icon-tasks { background-image: url('/img/gamified/icon-tasks.svg'); }
.gamified-icon.icon-shop { background-image: url('/img/gamified/icon-shop.svg'); }
.gamified-icon.icon-trophy { background-image: url('/img/gamified/icon-trophy.svg'); }
.gamified-icon.icon-eye { background-image: url('/img/gamified/icon-eye.svg'); }
.gamified-icon.icon-envelope { background-image: url('/img/gamified/icon-envelope.svg'); }
.gamified-icon.icon-dots { background-image: url('/img/gamified/icon-dots.svg'); }
.gamified-icon.icon-coin-stack { background-image: url('/img/gamified/icon-coin-stack.svg'); }
.gamified-icon.icon-chart { background-image: url('/img/gamified/icon-chart.svg'); }
.gamified-icon.icon-wallet { background-image: url('/img/gamified/icon-wallet.svg'); }
.gamified-icon.icon-magnifier { background-image: url('/img/gamified/icon-magnifier.svg'); }
.gamified-icon.icon-star { background-image: url('/img/gamified/icon-star.svg'); }
.gamified-icon.icon-palette { background-image: url('/img/gamified/icon-palette.svg'); }
.gamified-icon.icon-key { background-image: url('/img/gamified/icon-key.svg'); }
.gamified-icon.icon-link { background-image: url('/img/gamified/icon-link.svg'); }
.gamified-icon.icon-child { background-image: url('/img/gamified/icon-child.svg'); }
.gamified-icon.icon-empty { background-image: url('/img/gamified/icon-empty.svg'); }
.gamified-icon.icon-profile { background-image: url('/img/gamified/icon-profile.svg'); }
.gamified-icon.icon-logout { background-image: url('/img/gamified/icon-logout.svg'); }
.gamified-icon.icon-settings-menu { background-image: url('/img/gamified/icon-settings-menu.svg'); }
.gamified-icon.icon-child-link-menu { background-image: url('/img/gamified/icon-child-link-menu.svg'); }
.gamified-icon.icon-history-menu { background-image: url('/img/gamified/icon-history-menu.svg'); }
.gamified-icon.icon-rules-menu { background-image: url('/img/gamified/icon-rules-menu.svg'); }

.icon-label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.icon-label .gamified-icon {
    width: 1rem;
    height: 1rem;
    border-radius: 8px;
}

.coin-unit {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.coin-unit .gamified-icon {
    width: 1rem;
    height: 1rem;
    border-radius: 8px;
}

.card__badge--group {
    border-color: rgba(59, 130, 246, 0.35);
    color: var(--color-primary);
    background: rgba(59, 130, 246, 0.08);
}

.card__badge--type {
    border-color: rgba(163, 63, 218, 0.35);
    color: var(--color-secondary);
    background: rgba(163, 63, 218, 0.08);
}

.card__badge--money {
    border-color: rgba(245, 158, 11, 0.45);
    color: var(--color-warning);
    background: rgba(245, 158, 11, 0.12);
}

.card__status {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.75rem;
    border-radius: 999px;
    font-size: var(--text-xs);
    font-weight: 600;
    margin-top: 0.35rem;
    border: 1px solid transparent;
}

.card__status--available {
    color: var(--color-success);
    border-color: rgba(16, 185, 129, 0.45);
    background: rgba(16, 185, 129, 0.12);
}

.card__status--locked {
    color: var(--color-danger);
    border-color: rgba(239, 68, 68, 0.45);
    background: rgba(239, 68, 68, 0.08);
}

.card__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
}

.card__title {
    font-size: var(--text-xl);
    font-weight: var(--font-heading-weight);
    color: var(--color-text-high-contrast);
    line-height: var(--text-heading-tight);
    flex: 1;
    min-width: 0;
}

.card__coins {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    background: var(--gradient-gold);
    color: #1e293b;
    padding: 0.4rem 0.85rem;
    border-radius: var(--radius-xl);
    font-weight: 700;
    font-size: var(--text-lg);
    min-width: 70px;
    flex-shrink: 0;
}

.card__coins .gamified-icon {
    width: 1rem;
    height: 1rem;
    border-radius: 8px;
}

.card__comment {
    color: var(--color-text-muted);
    font-size: var(--text-sm);
    margin: 0;
    line-height: 1.5;
}

.card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    line-height: var(--line-height-snug);
}

.card__meta-item {
    white-space: nowrap;
}

.card__meta-sep {
    color: rgba(255, 255, 255, 0.5);
}

.card__actions {
    display: flex;
    gap: var(--touch-stack-gap);
    flex-wrap: wrap;
    justify-content: flex-start;
}

.card__actions--spaced {
    margin-top: 0.5rem;
}

.card__actions .btn {
    min-width: 120px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

.card--disabled {
    opacity: 0.5;
    pointer-events: none;
}

.card--affordable .card__coins {
    background: var(--gradient-success);
    color: white;
}
/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 2.5rem;
    color: var(--color-text-dim);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    border-radius: var(--radius-lg);
    background: rgba(15, 23, 42, 0.45);
    border: 1px dashed rgba(148, 163, 184, 0.5);
    max-width: 360px;
    margin: 0 auto;
}

.empty-state__icon {
    font-size: 3rem;
    opacity: 0.6;
}

.empty-state__icon .gamified-icon {
    font-size: 0;
    width: 2.8rem;
    height: 2.8rem;
}

.empty-state__title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text);
    margin: 0;
}

.empty-state__hint {
    font-size: 0.95rem;
    margin: 0;
    line-height: 1.4;
}

.empty-state__actions {
    margin-top: 0.25rem;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.empty-state__tip {
    display: block;
    background: rgba(79, 70, 229, 0.1);
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    color: var(--color-warning);
    font-weight: 600;
}

/* ===== History ===== */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: var(--color-bg-light);
    border-radius: var(--radius-md);
    border-left: 4px solid;
    transition: all var(--transition-fast);
    /* Simple Virtual Scrolling hint */
    content-visibility: auto;
    contain-intrinsic-size: auto 70px;
}

.history-item:hover {
    background: var(--color-bg-card);
}

.history-item--earn {
    border-color: var(--color-success);
}

.history-item--spend {
    border-color: var(--color-danger);
}

.history-item__icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
}

.history-item__icon .gamified-icon {
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 10px;
}

.history-item--earn .history-item__icon {
    background: rgba(16, 185, 129, 0.2);
}

.history-item--spend .history-item__icon {
    background: rgba(239, 68, 68, 0.2);
}

.history-item__content {
    flex: 1;
    min-width: 0;
}

.history-item__desc {
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item__date {
    font-size: 0.85rem;
    color: var(--color-text-dim);
}

.history-item__amount {
    font-weight: 700;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.history-item--earn .history-item__amount {
    color: var(--color-success);
}

.history-item--spend .history-item__amount {
    color: var(--color-danger);
}

.history-item--request-task {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.08);
}

.history-item--request-purchase {
    border-color: #f59e0b;
    background: rgba(245, 158, 11, 0.1);
}

.history-item--request-task:hover {
    background: rgba(59, 130, 246, 0.14);
}

.history-item--request-purchase:hover {
    background: rgba(245, 158, 11, 0.16);
}

.history-item--request-task .history-item__icon {
    background: rgba(59, 130, 246, 0.2);
}

.history-item--request-purchase .history-item__icon {
    background: rgba(245, 158, 11, 0.22);
}

/* ===== Modal ===== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: var(--layer-modal);
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.active {
    display: flex;
}

/* Native Dialog support (Step 11) */
dialog.modal {
    border: none;
    background: transparent;
    padding: 0;
    max-width: none;
    max-height: none;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
}

dialog.modal[open] {
    display: flex;
}

.modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: opacity 0.3s ease;
}

dialog.modal::backdrop {
    background: rgba(0, 0, 0, 0);
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
    transition: all 0.3s ease;
}

dialog.modal[open]::backdrop {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.modal__content {
    position: relative;
    background: var(--color-bg-light);
    border-radius: var(--radius-xl);
    padding: 2rem;
    max-width: 400px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
    margin-top: var(--safe-top);
    margin-bottom: var(--safe-bottom);
    box-sizing: border-box;
}

@keyframes modalSlide {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal__content h3 {
    font-size: 1.35rem;
    margin-bottom: 1rem;
    text-align: center;
}

.modal__content--wide {
    max-width: 500px;
}

.textarea--large {
    min-height: 150px;
}

.modal__content p {
    text-align: center;
    color: var(--color-text-muted);
    margin-bottom: 1rem;
}

.modal__actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
    width: 100%;
}

.modal__actions .btn {
    flex: 1;
    min-width: 0;
}

/* ===== Form Elements ===== */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--color-bg-card);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-family: inherit;
    font-size: 1rem;
    transition: all var(--transition-fast);
}

.input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.input::placeholder {
    color: var(--color-text-dim);
}

.textarea {
    resize: vertical;
    min-height: 80px;
}

.hint {
    font-size: 0.85rem;
    color: var(--color-text-dim);
    text-align: center;
    margin-top: 1rem;
}

/* ===== Toast Notifications ===== */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: var(--layer-toast);
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: var(--color-bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    animation: toastSlide 0.3s ease;
    max-width: 320px;
}

@keyframes toastSlide {
    from {
        opacity: 0;
        transform: translateX(100px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast--success {
    border-left: 4px solid var(--color-success);
}

.toast--error {
    border-left: 4px solid var(--color-danger);
}

.toast--info {
    border-left: 4px solid var(--color-primary);
}

.toast__icon {
    font-size: 1.25rem;
}

.toast__message {
    flex: 1;
    font-weight: 500;
}

.toast.hiding {
    animation: toastHide 0.3s ease forwards;
}

@keyframes toastHide {
    to {
        opacity: 0;
        transform: translateX(100px);
    }
}

/* ===== Budget Stats ===== */
.budget-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--gradient-card);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-card__icon {
    font-size: 2.5rem;
    background: rgba(255, 255, 255, 0.1);
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.stat-card__icon .gamified-icon {
    width: 2.2rem;
    height: 2.2rem;
    font-size: 0;
}

.stat-card__content {
    flex: 1;
}

.stat-card__value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 0.25rem;
}

.stat-card__label {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.stat-card__progress {
    margin-top: 0.5rem;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--gradient-success);
    width: 0%;
    transition: width 0.5s ease;
}

.progress-bar.warning {
    background: var(--color-warning);
}

.progress-bar.danger {
    background: var(--color-danger);
}

.stat-card__value-head {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 1.35rem;
}

.stat-card__value-unit {
    width: 1rem;
    height: 1rem;
}

.stat-card__value-note {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-top: 0.15rem;
}

.stat-card__progress--coins {
    margin-top: 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    height: 6px;
    border-radius: 3px;
}

.stat-card__meta {
    margin-top: 0.4rem;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
}

/* ===== Rules Page ===== */
.rules-content {
    background: var(--color-bg-light);
    border-radius: var(--radius-lg);
    padding: 2rem;
    max-width: 900px;
    margin: 0 auto;
}

.rules-list {
    list-style: none;
    margin-bottom: 2rem;
}

.rules-list li {
    margin-bottom: 0.75rem;
    padding-left: 1.5rem;
    position: relative;
}

.rules-list li::before {
    content: "•";
    color: var(--color-primary);
    position: absolute;
    left: 0;
    font-weight: bold;
}

.rules-list--quotes li::before {
    content: "💬";
    font-size: 0.9em;
}

.rules-list--quotes li {
    font-style: italic;
    color: var(--color-text-muted);
}

.rules-highlight {
    background: rgba(99, 102, 241, 0.1);
    border-left: 4px solid var(--color-primary);
    padding: 1rem;
    margin: 1.5rem 0;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    font-size: 1.1rem;
}

/* Markdown Rules Styling */
.rules-content h1,
.rules-content h2,
.rules-content h3 {
    color: var(--color-text);
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.rules-content h2 {
    font-size: 1.5rem;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 0.5rem;
}

.rules-content p {
    margin-bottom: 1rem;
    line-height: 1.6;
    color: var(--color-text-muted);
}

.rules-content ul,
.rules-content ol {
    margin-bottom: 1.5rem;
    padding-left: 1.5rem;
}

.rules-content li {
    margin-bottom: 0.5rem;
    color: var(--color-text-muted);
}

.rules-content strong {
    color: var(--color-text);
    font-weight: 700;
}

.rules-content em {
    color: var(--color-secondary);
    font-style: italic;
}

.rules-content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.rules-content th,
.rules-content td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.rules-content th {
    background: rgba(255, 255, 255, 0.1);
    font-weight: 700;
    color: var(--color-text);
}

.rules-content tr:last-child td {
    border-bottom: none;
}

.rules-content blockquote {
    border-left: 4px solid var(--color-primary);
    padding-left: 1rem;
    margin: 1.5rem 0;
    font-style: italic;
    color: var(--color-text-dim);
}



.rules-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 2rem;
    font-size: 0.95rem;
}

.rules-table th,
.rules-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--color-bg-card);
}

.rules-table th {
    color: var(--color-text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.rules-table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* ===== Form Improvements ===== */
.form-row {
    display: flex;
    gap: 1rem;
}

.form-row .form-group {
    flex: 1;
}

.input-group {
    display: flex;
    gap: 0.5rem;
    width: 100%;
}

.input-group .input {
    flex: 1;
    min-width: 0;
}

/* Badge styles for shop cards */
.tag {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    margin-right: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    color: var(--color-text-muted);
}

.tag--micro {
    color: #A7F3D0;
    background: rgba(16, 185, 129, 0.2);
}

.tag--small {
    color: #FDE68A;
    background: rgba(245, 158, 11, 0.2);
}

.tag--large {
    color: #FCA5A5;
    background: rgba(239, 68, 68, 0.2);
}

.tag--money {
    color: #BAE6FD;
    background: rgba(14, 165, 233, 0.2);
}

.tag--activity {
    color: #fca5f1;
    background: rgba(232, 121, 249, 0.2);
}

@media (max-width: 768px) {
    .header {
        padding: 0.5rem 0.75rem;
        gap: 0.45rem;
        flex-wrap: nowrap;
    }

    .header h1 {
        font-size: 1.05rem;
        line-height: 1.1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 44vw;
    }

    .header__logo {
        gap: 0.35rem;
        min-width: 0;
    }

    .header__icon {
        font-size: 1.2rem;
    }

    .header__balance {
        order: 0;
        width: auto;
        min-width: 0;
        max-width: 54vw;
        padding: 0.3rem 0.5rem;
        flex-direction: row;
        align-items: center;
        gap: 0.3rem;
    }

    .header__balance-main {
        width: auto;
        gap: 0.2rem;
    }

    .header__earned {
        min-width: 94px;
        gap: 0.15rem;
    }

    .header__earned-label {
        font-size: 0.58rem;
    }

    .header__earned-track {
        height: 4px;
    }

    .header__earned-meta {
        font-size: 0.62rem;
        gap: 0.2rem;
    }

    .header__earned-number {
        font-size: 0.75rem;
    }

    .header__earned-limit {
        font-size: 0.58rem;
    }

    .balance__value {
        font-size: 1rem;
        min-width: 0;
    }

    .balance__coin {
        font-size: 0.95rem;
    }

    .header__balance-hint,
    .header__balance::after {
        display: none;
    }

    .nav {
        position: fixed;
        inset: auto 0 0 0;
        overflow: visible;
        padding: 0.5rem;
        padding-bottom: calc(0.5rem + var(--safe-bottom));
        gap: 0.35rem;
        justify-content: stretch;
        border-radius: 0;
        margin: 0;
        background: var(--color-bg-light);
        border-top: 1px solid var(--color-bg-card);
        border-bottom: none;
        box-shadow: var(--shadow-md);
    }

    .nav__primary {
        gap: var(--touch-inline-gap);
        flex-wrap: wrap;
        overflow: visible;
        padding-bottom: 0;
        justify-content: stretch;
    }

    .nav__child-switcher,
    .nav__more-wrapper {
        position: relative;
        z-index: 2200;
    }

    .nav__btn {
        padding: 0.5rem 0.45rem;
        font-size: 0.82rem;
        line-height: 1.2;
        white-space: normal;
        min-height: var(--touch-target-height);
        flex: 1 1 calc(25% - 0.35rem);
    }

    #nav-analytics {
        display: none;
    }

    .nav__more {
        min-height: var(--touch-target-height);
        min-width: var(--touch-target-height);
        height: var(--touch-target-height);
        padding: 0 0.7rem;
        line-height: 1;
    }

    .main {
        padding: 0.55rem;
        padding-bottom: calc(132px + var(--safe-bottom));
        overflow-x: clip;
    }

    .section__header {
        flex-direction: row;
        align-items: center;
        gap: 0.4rem;
        margin-bottom: 0.7rem;
    }

    .section h2 {
        font-size: 1.05rem;
    }

    .section>h2,
    .section__header>h2 {
        display: block;
    }

    .section__buttons {
        width: auto;
        overflow: visible;
        padding-bottom: 0;
        display: flex;
        gap: var(--touch-inline-gap);
    }

    #tasks-section .section__buttons,
    #shop-section .section__buttons {
        position: fixed;
        right: 0.55rem;
        bottom: 0.65rem;
        z-index: 2300;
        margin: 0;
    }

    #tasks-section #add-task-btn,
    #shop-section #add-shop-btn {
        border-radius: 999px;
        padding: 0.5rem 0.8rem;
        font-size: 0.78rem;
        box-shadow: var(--shadow-md);
        border: 1px solid rgba(255, 255, 255, 0.24);
    }

    .cards {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .card {
        padding: 1.1rem;
        border-radius: var(--radius-md);
    }

    .card__header {
        margin-bottom: 0;
        flex-direction: column;
        gap: 0.6rem;
    }

    .card__title {
        font-size: 1rem;
        line-height: 1.25;
    }

    .card__coins {
        padding: 0.35rem 0.65rem;
        font-size: var(--text-base);
        align-self: flex-start;
    }

    .card__comment {
        font-size: var(--text-sm);
        margin: 0;
        line-height: 1.4;
    }

    .card__actions {
        gap: 0.5rem;
    }

    .btn {
        padding: 0.4rem 0.7rem;
        font-size: 0.8rem;
    }

    .modal__content {
        padding: 1.25rem;
        margin: 1rem;
        max-height: 90vh;
        overflow-y: auto;
    }

    .modal__actions {
        flex-direction: column;
    }

    .input-group {
        flex-direction: column;
    }

    .history-item {
        padding: 0.75rem 1rem;
        gap: 0.75rem;
    }

    .history-item__icon {
        width: 32px;
        height: 32px;
        font-size: 1.25rem;
    }

    .history-item__desc {
        font-size: 0.9rem;
    }

    .history-item__amount {
        font-size: 1rem;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .budget-stats {
        grid-template-columns: 1fr;
        gap: 0;
        margin-bottom: 0.55rem;
        padding: 0.45rem 0.55rem;
        border-radius: 10px;
        background: var(--color-bg-light);
        border: 1px solid rgba(255, 255, 255, 0.08);
    }

    .budget-stats .stat-card {
        background: transparent;
        box-shadow: none;
        border: none;
        border-radius: 0;
        padding: 0.35rem 0;
        display: grid;
        grid-template-columns: auto 1fr;
        gap: 0.45rem;
        align-items: center;
    }

    .budget-stats .stat-card__content {
        min-width: 0;
    }

    .budget-stats .stat-card:nth-child(3) {
        display: none;
    }

    .budget-stats .stat-card__icon {
        width: 24px;
        height: 24px;
        font-size: 0.95rem;
    }

    .budget-stats .stat-card__label {
        font-size: 0.65rem;
    }

    .budget-stats .stat-card__value {
        font-size: 0.86rem;
        margin-bottom: 0.1rem;
        line-height: 1.15;
    }

    .budget-stats .stat-card__progress {
        margin-top: 0.28rem;
        height: 4px;
        grid-column: 1 / -1;
        width: 100%;
    }

    .budget-stats .stat-card__value-head {
        font-size: 0.88rem;
    }

    .budget-stats .stat-card__value-note,
    .budget-stats .stat-card__meta {
        font-size: 0.62rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .rules-content {
        padding: 1.25rem;
    }

    .rules-table {
        display: block;
        overflow-x: auto;
    }

    .toast-container {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
    }

    .toast {
        max-width: none;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 0.95rem;
    }

    .header__icon {
        font-size: 1rem;
    }

    .btn {
        padding: 0.38rem 0.6rem;
        font-size: 0.75rem;
    }

    .header {
        padding: 0.4rem 0.6rem;
        gap: 0.35rem;
    }

    .header__balance {
        padding: 0.26rem 0.4rem;
        gap: 0.26rem;
        max-width: 56vw;
    }

    .header__balance-main {
        gap: 0.12rem;
    }

    .header__earned {
        min-width: 82px;
        gap: 0.1rem;
    }

    .header__earned-label {
        font-size: 0.52rem;
    }

    .header__earned-meta {
        font-size: 0.56rem;
    }

    .header__earned-number {
        font-size: 0.65rem;
    }

    .header__earned-limit {
        font-size: 0.5rem;
    }

    .header__earned-track {
        height: 3px;
    }

    .balance__value {
        font-size: 0.9rem;
    }

    .balance__coin {
        font-size: 0.82rem;
    }

    .nav {
        padding: 0.45rem 0.35rem;
        inset: auto 0 0 0;
        margin: 0;
    }

    .nav__btn {
        padding: 0.42rem 0.38rem;
        font-size: 0.78rem;
        min-height: 52px;
    }

    .nav__more {
        height: 52px;
        min-height: 52px;
        padding: 0 0.55rem;
        font-size: 1.2rem;
        line-height: 1;
    }

    .main {
        padding: 0.4rem;
        padding-bottom: calc(126px + var(--safe-bottom));
    }

    .section__header {
        gap: 0.25rem;
        align-items: center;
        flex-direction: row;
        justify-content: space-between;
        flex-wrap: nowrap;
        margin-bottom: 0.55rem;
    }

    .section h2 {
        font-size: 0.95rem;
    }

    #tasks-section .section__buttons,
    #shop-section .section__buttons {
        right: 0.4rem;
        bottom: 0.45rem;
    }

    #tasks-section #add-task-btn,
    #shop-section #add-shop-btn {
        padding: 0.42rem 0.66rem;
        font-size: 0.72rem;
    }

    .cards {
        gap: var(--touch-stack-gap);
    }

    .card {
        padding: 0.6rem;
    }

    .card__header {
        margin-bottom: 0.35rem;
    }

    .card__title {
        font-size: 0.86rem;
    }

    .card__coins {
        font-size: 0.68rem;
        padding: 0.18rem 0.38rem;
    }

    .card__comment {
        font-size: 0.74rem;
        margin-bottom: 0.38rem;
    }

    .card__actions {
        gap: 0.25rem;
    }

    .budget-stats {
        padding: 0.35rem 0.45rem;
        margin-bottom: 0.45rem;
    }

    .budget-stats .stat-card {
        gap: 0.35rem;
        padding: 0.28rem 0;
    }

    .budget-stats .stat-card__progress {
        grid-column: 1 / -1;
        width: 100%;
    }

    .budget-stats .stat-card__icon {
        width: 20px;
        height: 20px;
        font-size: 0.8rem;
    }

    .budget-stats .stat-card__value {
        font-size: 0.78rem;
        line-height: 1.1;
    }

    .budget-stats .stat-card__label {
        font-size: 0.58rem;
    }

    .budget-stats .stat-card__value-note,
    .budget-stats .stat-card__meta {
        font-size: 0.56rem;
    }

    .modal__content {
        padding: 0.85rem;
        margin: 0.65rem;
        max-height: 88vh;
    }

    .history-item {
        padding: 0.65rem 0.8rem;
        gap: 0.6rem;
    }

    .history-item__icon {
        width: 32px;
        height: 32px;
        font-size: 1.1rem;
    }

    .history-item__desc {
        font-size: 0.82rem;
        white-space: normal;
        line-height: 1.25;
        overflow: visible;
        text-overflow: clip;
    }

    .history-item__date {
        font-size: 0.72rem;
    }

    .history-item__amount {
        font-size: 0.95rem;
    }

    .history-item__comment {
        font-size: 0.75rem !important;
    }
}

.tag--group {
    background: rgba(139, 92, 246, 0.2);
    color: #a78bfa;
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.group-header {
    grid-column: 1 / -1;
    margin: 1.5rem 0 0.75rem 0.25rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--color-primary);
    font-size: 0.95rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#shop-section {
    position: relative;
    padding: 1.2rem;
    border-radius: 1.6rem;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.66), rgba(247, 250, 255, 0.34));
    border: 1px solid rgba(125, 149, 187, 0.12);
}

#shop-section::before {
    content: '';
    position: absolute;
    inset: -0.5rem 0 auto;
    height: 18rem;
    pointer-events: none;
    background:
        radial-gradient(34rem 18rem at 8% 8%, rgba(92, 199, 243, 0.18), transparent 58%),
        radial-gradient(30rem 18rem at 92% 10%, rgba(255, 214, 107, 0.2), transparent 56%),
        radial-gradient(22rem 14rem at 72% 88%, rgba(255, 156, 188, 0.14), transparent 58%);
    opacity: 0.95;
}

#shop-section .creation-wizard,
#shop-section .empty-state,
#shop-section .card.card--shop,
#shop-section .group-header {
    position: relative;
    z-index: 1;
}

#shop-section .section__header {
    position: relative;
    z-index: 1;
    margin-bottom: 1rem;
}

#shop-section .section__header > h2,
#shop-section.section > h2 {
    color: #26344f;
}

#shop-section .section__buttons .btn,
#shop-section .creation-wizard .btn {
    border: 1px solid rgba(125, 149, 187, 0.16);
}

#shop-section .btn--secondary {
    background: rgba(255, 255, 255, 0.92);
    color: #425a7d;
    border-color: rgba(125, 149, 187, 0.18);
    box-shadow: none;
}

#shop-section .btn--secondary:hover {
    background: rgba(247, 250, 255, 1);
}

#shop-section .btn--add {
    background: linear-gradient(135deg, #5cc7f3 0%, #8ddfb7 100%);
    color: #ffffff;
    box-shadow: 0 18px 28px -18px rgba(92, 199, 243, 0.5);
}

#shop-section .btn--primary {
    background: linear-gradient(135deg, #ffb65c 0%, #ff8f70 100%);
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 16px 28px -18px rgba(255, 143, 112, 0.5);
}

#shop-section .btn--primary:hover {
    background: linear-gradient(135deg, #ffb65c 0%, #ff8f70 100%);
    box-shadow: 0 20px 30px -18px rgba(255, 143, 112, 0.58);
}

#shop-section .btn--primary:disabled,
#shop-section .btn--primary[aria-disabled='true'] {
    background: linear-gradient(135deg, rgba(255, 182, 92, 0.55) 0%, rgba(255, 143, 112, 0.5) 100%);
    color: rgba(255, 255, 255, 0.92);
    box-shadow: none;
}

#shop-section .creation-wizard {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(245, 249, 255, 0.9)),
        linear-gradient(135deg, rgba(92, 199, 243, 0.1), rgba(255, 214, 107, 0.12));
    border: 1px solid rgba(125, 149, 187, 0.18);
    box-shadow: 0 24px 52px -34px rgba(104, 133, 176, 0.28);
}

#shop-section .creation-wizard__tag {
    color: #56749a;
    background: linear-gradient(135deg, rgba(92, 199, 243, 0.14), rgba(255, 214, 107, 0.22));
    border-color: rgba(92, 199, 243, 0.28);
}

#shop-section .creation-wizard__hint {
    color: #61738c;
}

#shop-section .creation-wizard__header h3 {
    color: #26344f;
}

#shop-section .wizard-step {
    border-color: rgba(125, 149, 187, 0.16);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

#shop-section .wizard-step h4 {
    color: #26344f;
}

#shop-section .wizard-step p {
    color: #647792;
}

#shop-section .group-header {
    border-bottom: 1px solid rgba(125, 149, 187, 0.16);
    color: #547198;
}

#shop-section .cards {
    position: relative;
    z-index: 1;
}

#shop-section .card.card--shop {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.99), rgba(246, 249, 255, 0.93));
    border: 1px solid rgba(125, 149, 187, 0.17);
    box-shadow: 0 22px 46px -34px rgba(104, 133, 176, 0.25);
}

#shop-section .card.card--shop::before {
    background: linear-gradient(90deg, #5cc7f3 0%, #ffd86b 55%, #ff9cbc 100%);
    opacity: 0.92;
}

#shop-section .card.card--shop .card__title {
    color: #26344f;
}

#shop-section .card.card--shop .card__comment,
#shop-section .card.card--shop .card__meta {
    color: #647792;
}

#shop-section .card.card--shop .card__meta-sep {
    color: rgba(100, 119, 146, 0.45);
}

#shop-section .card.card--shop .card__badge {
    border-color: rgba(125, 149, 187, 0.14);
    background: rgba(255, 255, 255, 0.82);
    color: #4e6485;
}

#shop-section .card.card--shop .card__badge--group {
    border-color: rgba(92, 199, 243, 0.26);
    background: rgba(92, 199, 243, 0.12);
    color: #3d82aa;
}

#shop-section .card.card--shop .card__badge--type {
    border-color: rgba(255, 156, 188, 0.26);
    background: rgba(255, 156, 188, 0.12);
    color: #bf5f84;
}

#shop-section .card.card--shop .card__badge--money {
    border-color: rgba(255, 182, 92, 0.28);
    background: rgba(255, 214, 107, 0.18);
    color: #a16f1a;
}

#shop-section .card.card--shop .card__coins {
    background: linear-gradient(135deg, #ffe385 0%, #ffbf69 100%);
    color: #6c4d15;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.62);
}

#shop-section .card.card--shop.card--affordable .card__coins {
    background: linear-gradient(135deg, #8ddfb7 0%, #5cc7f3 100%);
    color: #ffffff;
}

#shop-section .card.card--shop .card__status--available {
    color: #318a61;
    border-color: rgba(120, 197, 138, 0.36);
    background: rgba(141, 223, 183, 0.18);
}

#shop-section .card.card--shop .card__status--locked {
    color: #b35e17;
    border-color: rgba(255, 182, 92, 0.36);
    background: rgba(255, 214, 107, 0.18);
}

#shop-section .card.card--shop .card__quick-bookmark {
    border-color: rgba(125, 149, 187, 0.16);
    background: rgba(255, 255, 255, 0.88);
    color: #506783;
}

#shop-section .card.card--shop .card__quick-bookmark--active {
    background: linear-gradient(135deg, rgba(92, 199, 243, 0.18), rgba(255, 214, 107, 0.22));
    color: #2d577b;
    border-color: rgba(92, 199, 243, 0.24);
}

#shop-section .empty-state {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(247, 250, 255, 0.9));
    border: 1px dashed rgba(125, 149, 187, 0.28);
    color: #647792;
    box-shadow: 0 20px 42px -34px rgba(104, 133, 176, 0.22);
}

#shop-section .empty-state__title {
    color: #26344f;
}

#shop-section .empty-state__hint,
#shop-section .empty-state__actions {
    color: #647792;
}

#shop-section .empty-state__tip {
    background: linear-gradient(135deg, rgba(92, 199, 243, 0.14), rgba(255, 214, 107, 0.2));
    color: #8c6517;
}

.history-month-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 2rem 0 1rem 0;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--color-primary);
}

.month-title {
    font-weight: 700;
    text-transform: capitalize;
    font-size: 1.1rem;
}

.month-stats {
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

.month-stats .earn {
    color: var(--color-success);
    font-weight: 600;
}

.month-stats .spend {
    color: var(--color-danger);
    font-weight: 600;
}

.month-stats .money {
    color: var(--color-warning);
    font-weight: 600;
}

/* ===== Nav Counter ===== */
.nav__counter {
    background: var(--color-danger);
    color: white;
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 12px;
    margin-left: 0.5rem;
    vertical-align: middle;
    font-weight: 700;
    box-shadow: 0 0 5px rgba(239, 68, 68, 0.5);
}

/* ===== Analytics Section ===== */
.analytics-filters {
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: center;
}

.analytics-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.analytics-summary .stat-card {
    background: rgba(255, 255, 255, 0.05);
    padding: 1.25rem;
    border-radius: 1rem;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: block;
}

.analytics-summary .stat-card__value.earn {
    color: var(--color-success);
}

.analytics-summary .stat-card__value.spend {
    color: var(--color-danger);
}

.analytics-mini {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.analytics-mini__item {
    padding: 1rem;
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.analytics-mini__header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 0.95rem;
    color: var(--color-text-muted);
}

.analytics-mini__value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--color-text-high-contrast);
}

.progress-track {
    position: relative;
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.25);
    overflow: hidden;
}

.progress-fill {
    display: block;
    height: 100%;
    width: calc(var(--progress, 0) * 100%);
    background: linear-gradient(135deg, var(--color-success), #facc15);
    border-radius: inherit;
    transition: width 0.3s ease;
}

.analytics-mini__hint {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin: 0;
    line-height: 1.3;
}

.analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}

.analytics-group {
    margin-bottom: 2.5rem;
}

.analytics-group-title {
    color: var(--color-warning);
    margin-bottom: 1rem;
    font-size: 1.25rem;
    border-left: 4px solid var(--color-warning);
    padding-left: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.group-total-badge {
    font-size: 0.95rem;
    background: rgba(255, 215, 0, 0.15);
    color: var(--color-warning);
    padding: 0.2rem 0.6rem;
    border-radius: 0.5rem;
    font-weight: 700;
}

.analytics-chart-card {
    background: rgba(255, 255, 255, 0.03);
    padding: 1rem;
    min-height: 300px;
    display: flex;
    flex-direction: column;
}

.card__subtitle {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    margin: 0 0 0.5rem;
    font-weight: 600;
}

.chart-container {
    flex: 1;
    position: relative;
}

.tab-group {
    display: inline-flex;
    background: rgba(255, 255, 255, 0.1);
    padding: 0.25rem;
    border-radius: 0.75rem;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 0.6rem;
    transition: all var(--transition-fast);
    font-family: inherit;
}

.tab-btn.active {
    background: var(--color-warning);
    color: #000;
}

/* HTML Chart */
.html-chart-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.html-chart {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    width: 100%;
    margin-top: 0.5rem;
}

.html-chart-row {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 1rem;
}

.html-chart-label {
    flex: 0 0 45%;
    font-size: 0.9rem;
    color: var(--color-text-muted);
    word-break: break-word;
    line-height: 1.3;
    text-align: right;
}

.html-chart-bar-container {
    flex: 1;
    display: flex;
    align-items: center;
    position: relative;
}

.html-chart-bar {
    height: 24px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    padding: 0 8px;
    min-width: 30px;
    transition: width 0.3s ease;
}

.html-chart-value {
    font-size: 0.8rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.95);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Recommendations */
.recommendations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.recommendation-card {
    background: rgba(255, 215, 0, 0.05);
    border: 1px dashed rgba(255, 215, 0, 0.3);
    padding: 1rem;
    border-radius: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.recommendation-card__title {
    font-weight: 700;
    color: var(--color-warning);
    font-size: 1rem;
}

.recommendation-card__reason {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.recommendation-card__coins {
    font-weight: 800;
    color: var(--color-success);
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

/* Pull-to-refresh safe inset */
.pull-refresh-indicator {
    top: calc(0.55rem + var(--safe-top));
}

@media (max-width: 480px) {
    .analytics-grid {
        grid-template-columns: 1fr;
    }

    .analytics-summary {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 0.5rem;
    }

    .analytics-summary .stat-card {
        padding: 0.75rem 0.25rem;
    }

    .analytics-summary .stat-card__label {
        font-size: 0.65rem;
        margin-bottom: 0.25rem;
    }

    .analytics-summary .stat-card__value {
        font-size: 0.9rem;
    }
}

/* ===== Friends Section ===== */
.search-results-item,
.friend-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
}

.friend-info {
    display: flex;
    flex-direction: column;
}

.friend-nickname {
    font-weight: 700;
}

.friend-balance {
    font-size: 0.85rem;
    color: var(--color-warning);
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
}

.friends-challenge {
    margin-top: 0.5rem;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.16), rgba(59, 130, 246, 0.12));
}

.friends-challenge__title {
    font-weight: 700;
    font-size: 0.92rem;
    color: var(--color-text-high-contrast);
}

.friends-challenge__status {
    margin-top: 0.25rem;
    font-size: 0.86rem;
    color: var(--color-text);
}

.friends-challenge__hint {
    margin-top: 0.25rem;
    font-size: 0.8rem;
    color: var(--color-text-soft);
}

.age-theme-switch {
    display: grid;
    gap: 0.5rem;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    margin-top: 0.75rem;
}

.age-theme-current {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.35rem;
    font-size: 0.82rem;
    color: var(--color-text-soft);
}

.age-theme-switch__btn {
    width: 100%;
    justify-content: flex-start;
    gap: 0.55rem;
}

.age-theme-switch__btn--active {
    background: var(--gradient-primary);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.age-theme-switch__swatch {
    display: inline-flex;
    width: 14px;
    height: 14px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.45);
    flex-shrink: 0;
}

.age-theme-switch__swatch--mint {
    background: linear-gradient(135deg, #34d399 0%, #22d3ee 100%);
}

.age-theme-switch__swatch--ocean {
    background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
}

.age-theme-switch__swatch--sun {
    background: linear-gradient(135deg, #facc15 0%, #f97316 100%);
}

.age-theme-switch__swatch--coral {
    background: linear-gradient(135deg, #fb7185 0%, #f97316 100%);
}

.age-theme-switch__swatch--cosmos {
    background: linear-gradient(135deg, #a855f7 0%, #ec4899 100%);
}

/* ===== Catalog Section ===== */
.filter-card {
    background: rgba(255, 255, 255, 0.1);
    padding: 1rem;
    border-radius: 1rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.filter-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 100%;
    max-width: 300px;
}

.age-slider {
    flex: 1;
    cursor: pointer;
}

.age-slider::-webkit-slider-thumb {
    pointer-events: auto;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}

.age-slider::-moz-range-thumb {
    pointer-events: auto;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}

.category-header {
    text-align: left;
    font-size: 0.9rem;
    color: var(--color-primary);
    margin: 1rem 0 0.5rem 0.5rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.catalog-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.catalog-column h3 {
    color: var(--color-primary);
    margin-bottom: 1rem;
    border-bottom: 2px solid rgba(99, 102, 241, 0.3);
    padding-bottom: 0.5rem;
}

.catalog-item {
    background: rgba(255, 255, 255, 0.05);
    padding: 1rem;
    border-radius: 0.8rem;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.catalog-info {
    flex: 1;
    text-align: left;
}

.catalog-name {
    font-weight: 700;
    display: block;
}

.catalog-meta {
    font-size: 0.8em;
    opacity: 0.7;
}

.btn-add {
    background: var(--color-success);
    color: white;
    border: none;
    padding: 0.5rem 0.8rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: 700;
    margin-left: 0.5rem;
    font-family: inherit;
    transition: background var(--transition-fast);
}

.btn-add:hover {
    background: var(--color-success-dark);
}

@media (max-width: 768px) {
    .catalog-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .catalog-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .btn-add {
        width: 100%;
        margin-left: 0;
        padding: 0.75rem;
    }
}

/* ===== About Section (markdown content) ===== */
.about-card {
    background: rgba(255, 255, 255, 0.05);
    padding: 2rem;
    border-radius: 1.5rem;
    line-height: 1.6;
}

.markdown-content h1 {
    color: var(--color-warning);
    margin-bottom: 1.5rem;
    text-align: center;
}

.markdown-content h2 {
    color: var(--color-warning);
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 215, 0, 0.2);
    padding-bottom: 0.5rem;
}

.markdown-content h3 {
    color: var(--color-text);
    margin-top: 1.2rem;
}

.markdown-content ul {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.markdown-content li {
    margin-bottom: 0.5rem;
}

.markdown-content p {
    margin-bottom: 1rem;
}


/* ===== View Transitions API (Step 5) ===== */
@media (prefers-reduced-motion: no-preference) {
    ::view-transition-old(root) {
        animation: 0.3s ease both fade-out;
    }

    ::view-transition-new(root) {
        animation: 0.3s ease both fade-in;
    }
}

@keyframes fade-out {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

@keyframes fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}
/* ===== Skeleton Loading (Microanimations) ===== */
.skeleton {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.05) 25%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.05) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: var(--radius-sm);
    color: transparent !important;
    pointer-events: none;
    border-color: transparent !important;
    box-shadow: none !important;
}

.skeleton * {
    visibility: hidden !important;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.stagger-in {
    animation: stagger-in 320ms ease-out both;
    animation-delay: calc(var(--stagger-index, 0) * 36ms);
}

@keyframes stagger-in {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.coin-burst {
    position: fixed;
    pointer-events: none;
    z-index: 4000;
}

.coin-burst__coin {
    position: absolute;
    left: 0;
    top: 0;
    display: inline-block;
    transform: translate(-50%, -50%);
    animation: coin-burst-pop 500ms ease-out forwards;
    width: 0.95rem;
    height: 0.95rem;
    background: url('/img/gamified/icon-coin-stack.svg') center / contain no-repeat;
}

@keyframes coin-burst-pop {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.4);
    }

    20% {
        opacity: 1;
    }

    100% {
        opacity: 0;
        transform: translate(
            calc(-50% + var(--burst-x, 0px)),
            calc(-50% + var(--burst-y, -60px))
        ) scale(0.9);
    }
}

@media (prefers-reduced-motion: reduce) {
    .stagger-in,
    .coin-burst__coin {
        animation: none !important;
    }
}


/* ===== Responsive Styles (Mobile & Tablet) ===== */

html {
    font-size: clamp(15px, 1rem + 0.3vw, 18px);
}

@media (max-width: 640px) {
    body {
        font-size: clamp(1rem, 1rem + 0.1vw, 1.08rem);
        line-height: var(--line-height-relaxed);
    }
}

@media (min-width: 1200px) {
    body {
        font-size: clamp(1.05rem, 1.1rem + 0.2vw, 1.25rem);
    }

    :root {
        --touch-target-height: clamp(48px, 3vw, 56px);
    }
}

@media (max-width: 900px) {

    /* Mobile Navigation (Bottom Tab Bar) */
    .nav {
        --nav-mobile-height: 66px;
        --bottom-nav-height: calc(var(--mobile-nav-height, var(--nav-mobile-height)) + var(--safe-bottom));
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: var(--bottom-nav-height);
        min-height: var(--bottom-nav-height);
        max-height: var(--bottom-nav-height);
        padding: 0.35rem 0.45rem;
        padding-bottom: calc(0.35rem + var(--safe-bottom));
        background: var(--color-bg-light);
        border-top: 1px solid var(--color-bg-card);
        border-bottom: none;
        z-index: var(--layer-nav);
        overflow: visible;
        gap: 0.35rem;
    }

    .nav__primary {
        display: flex;
        flex-wrap: nowrap;
        overflow: visible;
        gap: 0.35rem;
        width: 100%;
        max-width: 100%;
        justify-content: stretch;
        align-items: stretch;
    }

    .nav__group {
        width: auto;
        min-width: 0;
        flex: 1 1 0;
        justify-content: stretch;
    }

    .nav__child-switcher {
        flex: 0 1 34%;
        max-width: 34%;
        min-width: 108px;
        margin-bottom: 0;
    }

    .nav__more-wrapper {
        flex: 0 0 64px;
    }

    .nav__fab {
        width: 52px;
        height: 52px;
        flex: 0 0 52px;
        margin-left: 0;
    }

    .nav__fab-label {
        display: none;
    }

    /* Parent mobile layout: keep all controls in a single row */
    #child-switcher-container:not(.hidden) {
        order: 0;
    }

    #child-switcher-container:not(.hidden) ~ .nav__group--parent {
        order: 1;
        flex: 1 1 0;
        width: auto;
        min-width: 0;
        flex-wrap: nowrap;
        justify-content: stretch;
    }

    #child-switcher-container:not(.hidden) ~ .nav__group--parent .nav__btn {
        flex: 1 1 0;
    }

    #child-switcher-container:not(.hidden) ~ .nav__group--parent ~ .nav__more-wrapper {
        order: 2;
        flex: 0 0 64px;
        margin-left: 0;
    }

    #child-switcher-container,
    #child-switcher-container .child-menu,
    #child-switcher-container .child-menu-dropdown {
        overflow: visible;
    }

    .nav__btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0.3rem;
        font-size: 0.8rem;
        padding: 0.45rem 0.35rem;
        border-radius: var(--radius-sm);
        text-align: center;
        flex: 1 1 calc(25% - 0.35rem);
        min-width: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: 1.05;
        min-height: 52px;
    }

    .nav__btn.active,
    .nav__more.active {
        transform: none;
    }

    .nav__btn-label {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    #nav-analytics {
        display: none;
    }

    .nav__more .nav__btn-label {
        display: none;
    }

    .nav__more {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 52px;
        min-width: 52px;
        height: 52px;
        padding: 0;
        width: 52px;
        border-radius: var(--radius-sm);
        font-size: 0.8rem;
        line-height: 1;
    }

    .nav__dropdown {
        top: auto;
        bottom: calc(100% + 0.5rem);
        right: 0;
        left: auto;
        width: min(320px, calc(100vw - 1rem));
        max-width: calc(100vw - 1rem);
        min-width: 220px;
        z-index: var(--layer-dropdown);
        flex-direction: column-reverse;
    }

    .nav__dropdown::before {
        top: auto;
        bottom: -6px;
        border-bottom-color: transparent;
        border-top-color: var(--color-bg-card);
    }

    .section > h2,
    .section__header > h2 {
        display: block;
        line-height: 1.3;
        overflow: visible;
        overflow-wrap: anywhere;
        word-break: normal;
    }

    .section__header {
        align-items: flex-start;
        flex-wrap: wrap;
        row-gap: 0.45rem;
    }

    /* Main padding adjustment for Mobile */
    .main {
        overflow-x: clip;
        padding-bottom: calc(var(--bottom-nav-height, var(--mobile-main-bottom-offset, 132px)) + 1rem);
        background: linear-gradient(180deg, var(--color-bg-light), var(--color-bg));
        border-radius: 24px 24px 0 0;
        border: 1px solid rgba(255, 255, 255, 0.08);
        border-bottom: none;
        box-shadow: 0 12px 24px rgba(2, 6, 23, 0.6), 0 -18px 40px rgba(2, 6, 23, 0.55);
        padding-top: 1rem;
        backdrop-filter: blur(6px);
    }

    .cards {
        background: rgba(9, 15, 26, 0.6);
        border-radius: var(--radius-lg);
        padding: 0.65rem;
        box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06), 0 10px 25px rgba(2, 6, 23, 0.5);
    }

    .card {
        background: linear-gradient(135deg, rgba(15, 23, 42, 0.92), rgba(30, 41, 59, 0.95));
        border: 1px solid rgba(255, 255, 255, 0.12);
        box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
        filter: saturate(1.08);
    }

    .card:hover {
        box-shadow: var(--shadow-md), 0 0 0 1px rgba(255, 255, 255, 0.08);
        transform: translateY(-1px);
    }

    #settings-cards {
        display: flex;
        flex-direction: column;
        gap: 1rem;
        width: 100%;
    }

    #settings-cards .settings-card,
    #child-link-section .card {
        min-width: 0;
        width: 100%;
        max-width: 100%;
        min-height: 0;
    }

    /* Mobile Header Compact */
    .header {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: calc(0.35rem + var(--safe-top)) 0.65rem 0.35rem;
        gap: 0.35rem;
        max-height: none;
        overflow: visible;
    }

    .header__system-row,
    .header__status-row {
        display: contents;
    }

    .header__logo {
        flex: 1 1 auto;
        min-width: 0;
    }

    .header__titles {
        min-width: 0;
    }

    .header__titles h1 {
        font-size: 0.88rem;
        line-height: 1.15;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .header__shop-name {
        font-size: 0.9rem !important;
    }

    .header__child-nickname {
        display: none;
    }

    .header__balance {
        order: 2;
        margin-left: 0;
        gap: 0.35rem;
        min-height: 36px;
        padding: 0;
    }

    .header__actions {
        order: 3;
        align-items: center;
        width: auto;
        gap: 0.25rem;
    }

    .header__install,
    .header__install-hint {
        display: none !important;
    }

    .header__profile {
        width: 36px;
        min-width: 36px;
        min-height: 36px;
        height: 36px;
        padding: 0;
        font-size: 0.85rem;
        border-radius: 10px;
    }

    .header__profile .header__profile-label {
        display: none;
    }

    .header__profile .gamified-icon {
        width: 1rem;
        height: 1rem;
    }

    .balance__value {
        font-size: 1.1rem;
        min-width: 0;
    }

    .balance__coin {
        font-size: 0.9rem;
    }

    .header__earned-main {
        font-size: 0.78rem;
    }

    .header__earned-limit {
        display: none;
    }

    .header__earned {
        min-width: 0;
        gap: 0.2rem;
    }

    .header__balance::after {
        display: none;
    }

    /* Modals - Bottom Sheet on Mobile (div & native dialog) */
    .modal,
    dialog.modal {
        align-items: flex-end;
        padding: 0;
    }

    dialog.modal {
        /* override UA-sheet centering for bottom-sheet on mobile */
        position: fixed;
        inset: 0;
    }

    .modal__content {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        border-radius: 16px 16px 0 0;
        max-height: 85vh;
        overflow-y: auto;
        padding: 1.5rem;
        margin: 0;
        max-width: 100%;
    }

    /* Drag handle indicator */
    .modal__content::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        background: rgba(255, 255, 255, 0.2);
        border-radius: 2px;
        margin: -0.5rem auto 1rem;
    }

    /* Sticky submit button inside mobile modals */
    .modal__actions {
        position: sticky;
        bottom: -1.5rem;
        background: var(--color-bg-light);
        padding: 1rem 0 calc(1.5rem + var(--safe-bottom));
        margin: 1rem -1.5rem -1.5rem -1.5rem;
        border-top: 1px solid rgba(255, 255, 255, 0.05);
        z-index: 10;
        padding-inline: 1.5rem;
    }

    /* History & Tables */
    .history-item {
        padding: 0.75rem 1rem;
        gap: 0.75rem;
    }

    .history-item__amount {
        font-size: 1rem;
    }

    #requests-section .section__subtitle {
        font-size: 0.78rem;
        line-height: 1.35;
        margin-top: 0.25rem;
    }

    #requests-section .requests-summary {
        grid-template-columns: 1fr;
        gap: 0.55rem;
    }

    #requests-section .history-item.request-item {
        display: grid;
        grid-template-columns: 32px minmax(0, 1fr);
        grid-template-areas:
            'icon content'
            'amount amount'
            'actions actions';
        align-items: start;
        column-gap: 0.65rem;
        row-gap: 0.45rem;
    }

    #requests-section .history-item.request-item .history-item__icon {
        grid-area: icon;
    }

    #requests-section .history-item.request-item .history-item__content {
        grid-area: content;
        min-width: 0;
    }

    #requests-section .history-item.request-item .history-item__desc {
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        line-height: 1.25;
        word-break: normal;
        overflow-wrap: anywhere;
    }

    #requests-section .history-item.request-item .history-item__date {
        display: flex;
        flex-wrap: wrap;
        gap: 0.3rem;
        align-items: center;
        line-height: 1.25;
        min-width: 0;
        overflow-wrap: anywhere;
    }

    #requests-section .history-item.request-item .history-item__amount {
        grid-area: amount;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 0.35rem;
        font-size: 0.95rem;
    }

    #requests-section .history-item.request-item .request-item__actions {
        grid-area: actions;
        margin-left: 0 !important;
        width: 100%;
        display: flex;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 0.45rem;
    }

    #requests-section .history-item.request-item .request-item__actions .btn {
        min-width: 40px;
        min-height: 36px;
    }

    #requests-section .history-item.request-item .request-item__money,
    #requests-section .history-item.request-item .request-item__group,
    #requests-section .history-item.request-item .request-item__child {
        margin: 0;
        flex: 0 0 auto;
    }

    #requests-section .history-item.request-item .request-item__comment {
        margin-top: 0.2rem;
        font-size: 0.78rem !important;
        color: var(--color-text-dim);
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .btn,
    .card__actions .btn,
    .section__buttons .btn {
        min-height: 44px;
    }

    .toast-container {
        bottom: calc(var(--bottom-nav-height, 0px) + 0.75rem);
    }
}

@media (hover: none) and (pointer: coarse) {
    #settings-cards {
        display: flex;
        flex-direction: column;
        gap: 1rem;
        width: 100%;
    }

    #settings-cards .settings-card,
    #child-link-section .card {
        min-width: 0;
        width: 100%;
        max-width: 100%;
        min-height: 0;
    }
}

@media (max-width: 360px) {
    .nav__btn-label,
    .nav__more .nav__btn-label {
        display: none;
    }

    .nav__btn,
    .nav__more {
        position: relative;
    }

    .nav__btn:focus-visible::after,
    .nav__btn.active::after,
    .nav__more:focus-visible::after,
    .nav__more.active::after {
        content: attr(data-label);
        position: absolute;
        bottom: calc(100% + 0.35rem);
        left: 50%;
        transform: translateX(-50%);
        font-size: 0.65rem;
        line-height: 1;
        white-space: nowrap;
        background: rgba(15, 23, 42, 0.96);
        color: #ffffff;
        padding: 0.2rem 0.35rem;
        border-radius: 999px;
        pointer-events: none;
    }

    .nav__more {
        min-width: 52px;
        width: 52px;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: more) {
    :root {
        --color-text: #ffffff;
        --color-text-high-contrast: #ffffff;
        --color-text-strong: #f8fafc;
        --color-text-soft: #e5e7eb;
        --color-text-muted: #d1d5db;
        --color-bg: #000000;
        --color-bg-light: #070b1a;
        --color-bg-card: #02050f;
        --gradient-primary: #6366f1;
        /* fallback solid for gradient */
    }

    .card {
        border: 2px solid #ffffff;
    }

    .btn,
    .input {
        border: 2px solid #ffffff;
    }
}
