/* ── Base & Theme ── */
html {
    height: 100%;
    min-height: 100%;
    min-height: -webkit-fill-available;
    background-color: #020705;
    overflow-x: hidden;
    overflow-y: auto;
}

body {
    background:
        radial-gradient(circle at 12% 22%, rgba(0, 167, 99, 0.2), transparent 38%),
        radial-gradient(circle at 86% 78%, rgba(0, 167, 99, 0.16), transparent 42%),
        linear-gradient(115deg, #04110b 0%, #020705 56%, #020a07 100%);
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
    will-change: auto;
    position: relative;
    --grid-size: 56px;
    --square-transition: 1300ms;
    --accent-rgb: 0, 167, 99;
}

/* ── Grid overlay ── */
body::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(0, 167, 99, 0.08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 167, 99, 0.08) 1px, transparent 1px);
    background-size: var(--grid-size) var(--grid-size);
    opacity: 0.2;
    z-index: 0;
    pointer-events: none;
}

/* ── Background squares ── */
.bg-square-layer {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    display: grid;
    overflow: hidden;
}

.bg-square {
    width: var(--grid-size);
    height: var(--grid-size);
    border: 1px solid rgba(26, 214, 132, 0.12);
    background: rgba(15, 160, 98, 0.2);
    box-shadow: inset 0 0 16px rgba(11, 145, 88, 0.14);
    opacity: 0;
    transition: opacity var(--square-transition) ease, background-color var(--square-transition) ease, box-shadow var(--square-transition) ease, border-color var(--square-transition) ease;
}

.bg-square.is-mid {
    opacity: 0.28;
    background: rgba(20, 175, 108, 0.3);
    border-color: rgba(30, 220, 137, 0.2);
    box-shadow: inset 0 0 22px rgba(16, 177, 109, 0.2);
}

.bg-square.is-high {
    opacity: 0.58;
    background: rgba(31, 195, 123, 0.46);
    border-color: rgba(47, 235, 152, 0.34);
    box-shadow: inset 0 0 26px rgba(28, 206, 130, 0.3);
}

body.low-power-mode {
    --square-transition: 1850ms;
}

body.low-power-mode .bg-square {
    box-shadow: none;
    border-color: rgba(26, 214, 132, 0.08);
}

body.low-power-mode .bg-square.is-mid {
    opacity: 0.2;
    box-shadow: none;
}

body.low-power-mode .bg-square.is-high {
    opacity: 0.42;
    box-shadow: none;
}

/* ── Main container (shared card shell) ── */
.main-container {
    background-color: rgba(4, 10, 8, 0.82);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 24px;
    max-width: 440px;
    width: 92%;
    max-height: min(96dvh, 920px);
    margin: auto;
    position: relative;
    z-index: 1;
    border: 1px solid rgba(0, 167, 99, 0.22);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06) inset, 0 16px 38px rgba(0, 0, 0, 0.38);
    opacity: 0;
    transform: scale(0.98);
    animation: fadeIn 0.8s ease forwards;
    overflow-x: visible;
    overflow-y: auto;
}

.main-container::-webkit-scrollbar {
    display: none;
}

/* ── Content container (transition wrapper) ── */
.content-container {
    transition: transform 0.6s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    position: relative;
    width: 100%;
}

.content-container.slide {
    transform: translateX(-100%);
}

/* ── Form styles ── */
input:focus,
textarea:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 167, 99, 0.5);
}

/* ── Button hover shine ── */
.btn-hover {
    position: relative;
    overflow: hidden;
}

.btn-hover::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: 0.5s;
}

.btn-hover:hover::after {
    left: 100%;
}

/* ── Frosted button ── */
.frosted-button {
    background-color: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

.frosted-button:hover {
    background-color: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* ── Keyframes ── */
@keyframes fadeIn {
    0% {
        opacity: 0;
        transform: scale(0.98);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideUp {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInIcons {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pillScroll {
    from {
        transform: translateX(0);
    }
    to {
        transform: translateX(-50%);
    }
}

/* ── Mobile viewport ── */
@media (hover: none) and (pointer: coarse) {
    body {
        min-height: 100vh;
        min-height: -webkit-fill-available;
        min-height: 100dvh;
        min-height: var(--screen-height, 100dvh);
        height: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ── Standalone web app mode (Add to Home Screen) ── */
@media (display-mode: standalone) {
    body {
        padding-top: calc(env(safe-area-inset-top, 2.75rem) + 0.5rem) !important;
        padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 0.5rem) !important;
    }
}

@media (display-mode: standalone) and (orientation: portrait) {
    body {
        align-items: flex-start !important;
    }
}
