:root {
    color-scheme: dark;

    --bg: #0b1022;
    --bg-deep: #070b18;
    --surface: rgba(23, 29, 57, .82);
    --surface-solid: #171d39;
    --surface-soft: #202746;

    --text: #f8f9ff;
    --muted: #adb7d5;

    --line: rgba(255,255,255,.10);

    --primary: #8475ff;
    --primary-2: #5f8dff;
    --accent: #dfc7ff;

    --shadow:
        0 30px 80px
        rgba(0,0,0,.30);

    --radius: 24px;
}

[data-theme="light"] {
    color-scheme: light;

    --bg: #f3f5ff;
    --bg-deep: #e9ecfa;
    --surface: rgba(255,255,255,.84);
    --surface-solid: #ffffff;
    --surface-soft: #f5f6ff;

    --text: #18203b;
    --muted: #66708e;

    --line: rgba(30,41,70,.10);

    --primary: #6858e8;
    --primary-2: #477cff;
    --accent: #7659da;

    --shadow:
        0 30px 70px
        rgba(65,72,112,.15);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;

    background: var(--bg);
    color: var(--text);

    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    line-height: 1.6;
}

button,
select,
input {
    font: inherit;
}

button,
a,
select {
    -webkit-tap-highlight-color: transparent;
}

a {
    color: inherit;
}

button {
    cursor: pointer;
}

[hidden] {
    display: none !important;
}

.sr-only {
    position: absolute;

    width: 1px;
    height: 1px;

    padding: 0;
    margin: -1px;

    overflow: hidden;
    clip: rect(0,0,0,0);

    white-space: nowrap;

    border: 0;
}

.skip-link {
    position: fixed;

    left: 14px;
    top: -100px;

    z-index: 9999;

    padding: 10px 14px;

    border-radius: 10px;

    background: #fff;
    color: #111827;

    text-decoration: none;
}

.skip-link:focus {
    top: 14px;
}

:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
}


/* HEADER */

.site-header {
    position: absolute;

    top: 0;
    left: 0;
    right: 0;

    z-index: 20;
}

.header-inner {
    width:
        min(
            1180px,
            calc(100% - 34px)
        );

    min-height: 78px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 20px;

    margin: 0 auto;
}

.brand {
    display: inline-flex;
    align-items: center;

    gap: 9px;

    color: #fff;

    font-size: 1.05rem;
    font-weight: 850;

    letter-spacing: -.035em;

    text-decoration: none;
}

.brand span span {
    color: #b9afff;
}

.brand-moon {
    width: 34px;
    height: 34px;

    display: grid;
    place-items: center;

    border:
        1px solid
        rgba(255,255,255,.15);

    border-radius: 50%;

    background:
        rgba(255,255,255,.08);

    color: #dfd6ff;

    font-size: 1.15rem;
}

.main-nav {
    display: flex;
    align-items: center;

    gap: 5px;
}

.main-nav > a,
.theme-button {
    min-height: 40px;

    display: inline-flex;
    align-items: center;

    padding: 8px 11px;

    border: 0;
    border-radius: 10px;

    background: transparent;

    color: rgba(255,255,255,.78);

    font-size: .84rem;
    font-weight: 650;

    text-decoration: none;
}

.main-nav > a:hover,
.theme-button:hover {
    background:
        rgba(255,255,255,.08);

    color: #fff;
}

.theme-button {
    width: 40px;

    justify-content: center;

    font-size: 1rem;
}


/* HERO */

.sleep-hero {
    position: relative;

    min-height: 790px;

    overflow: hidden;

    background:
        radial-gradient(
            circle at 50% 0%,
            rgba(118,96,255,.28),
            transparent 40%
        ),
        radial-gradient(
            circle at 8% 45%,
            rgba(54,89,218,.16),
            transparent 31%
        ),
        linear-gradient(
            180deg,
            #101630 0%,
            #0a1024 58%,
            #090e1f 100%
        );
}

.sleep-hero::after {
    content: '';

    position: absolute;

    left: 0;
    right: 0;
    bottom: 0;

    height: 145px;

    background:
        linear-gradient(
            180deg,
            transparent,
            var(--bg)
        );

    pointer-events: none;
}

.sleep-sky {
    position: absolute;

    inset: 0;

    pointer-events: none;
}

.moon {
    position: absolute;

    top: 118px;
    left: 12%;

    width: 86px;
    height: 86px;

    border-radius: 50%;

    background:
        linear-gradient(
            135deg,
            #f4efff,
            #c7b9ff
        );

    box-shadow:
        0 0 40px
        rgba(199,185,255,.36),
        0 0 90px
        rgba(144,124,255,.16);

    animation:
        moonFloat
        7s ease-in-out
        infinite;
}

.moon span {
    position: absolute;

    width: 70px;
    height: 70px;

    top: -7px;
    left: 25px;

    border-radius: 50%;

    background: #11172f;
}

.star {
    position: absolute;

    width: 3px;
    height: 3px;

    border-radius: 50%;

    background: #fff;

    box-shadow:
        0 0 8px
        rgba(255,255,255,.85);

    animation:
        twinkle
        3.8s ease-in-out
        infinite;
}

.star-1 { top: 17%; left: 25%; }
.star-2 { top: 25%; left: 72%; animation-delay:.6s; }
.star-3 { top: 14%; left: 87%; animation-delay:1.2s; }
.star-4 { top: 38%; left: 8%; animation-delay:1.8s; }
.star-5 { top: 50%; left: 91%; animation-delay:.9s; }
.star-6 { top: 67%; left: 14%; animation-delay:2.1s; }
.star-7 { top: 62%; left: 79%; animation-delay:1.4s; }
.star-8 { top: 9%; left: 55%; animation-delay:.4s; }
.star-9 { top: 43%; left: 66%; animation-delay:2.4s; }
.star-10 { top: 31%; left: 35%; animation-delay:1.1s; }

.cloud {
    position: absolute;

    width: 170px;
    height: 42px;

    border-radius: 999px;

    background:
        rgba(167,179,229,.055);

    filter: blur(.2px);

    animation:
        cloudMove
        18s ease-in-out
        infinite;
}

.cloud::before,
.cloud::after {
    content: '';

    position: absolute;

    border-radius: 50%;

    background: inherit;
}

.cloud::before {
    width: 70px;
    height: 70px;

    left: 27px;
    top: -31px;
}

.cloud::after {
    width: 90px;
    height: 90px;

    right: 26px;
    top: -48px;
}

.cloud-a {
    left: -30px;
    top: 55%;

    opacity: .7;
}

.cloud-b {
    right: -40px;
    top: 25%;

    opacity: .65;

    animation-delay: -7s;
}

.cloud-c {
    right: 14%;
    bottom: 80px;

    opacity: .4;

    transform: scale(.7);

    animation-delay: -12s;
}

.hero-inner {
    position: relative;

    z-index: 5;

    width:
        min(
            760px,
            calc(100% - 30px)
        );

    margin: 0 auto;

    padding:
        118px 0
        72px;
}

.hero-copy {
    max-width: 660px;

    margin: 0 auto 28px;

    text-align: center;
}

.eyebrow,
.section-kicker {
    display: inline-flex;

    align-items: center;

    min-height: 30px;

    padding:
        5px 11px;

    border:
        1px solid
        rgba(255,255,255,.11);

    border-radius: 999px;

    background:
        rgba(255,255,255,.055);

    color: #c9c1ff;

    font-size: .68rem;
    font-weight: 850;

    letter-spacing: .085em;

    text-transform: uppercase;
}

.hero-copy h1 {
    margin:
        18px 0
        13px;

    color: #fff;

    font-size:
        clamp(
            2.25rem,
            7vw,
            4.25rem
        );

    line-height: .98;

    letter-spacing: -.065em;
}

.hero-copy h1 span {
    display: block;

    background:
        linear-gradient(
            90deg,
            #d8d1ff,
            #90a7ff
        );

    background-clip: text;

    -webkit-background-clip: text;

    color: transparent;
}

.hero-copy p {
    max-width: 570px;

    margin: 0 auto;

    color:
        rgba(235,239,255,.70);

    font-size:
        clamp(
            .95rem,
            2vw,
            1.08rem
        );
}


/* CALCULATOR */

.calculator-card {
    position: relative;

    width:
        min(
            100%,
            590px
        );

    margin: 0 auto;

    overflow: hidden;

    border:
        1px solid
        rgba(255,255,255,.12);

    border-radius: 28px;

    background:
        linear-gradient(
            180deg,
            rgba(31,38,73,.92),
            rgba(22,28,56,.94)
        );

    box-shadow:
        0 32px 90px
        rgba(0,0,0,.37),
        inset 0 1px 0
        rgba(255,255,255,.055);

    backdrop-filter:
        blur(18px);
}

.calculator-main,
.calculator-results {
    padding:
        clamp(
            25px,
            6vw,
            42px
        );
}

.sleep-icon,
.results-moon {
    width: 47px;
    height: 47px;

    display: grid;
    place-items: center;

    margin: 0 auto 13px;

    border:
        1px solid
        rgba(255,255,255,.11);

    border-radius: 50%;

    background:
        linear-gradient(
            145deg,
            rgba(137,116,255,.26),
            rgba(255,255,255,.035)
        );

    color: #d8ceff;

    font-size: 1.35rem;

    box-shadow:
        0 12px 35px
        rgba(71,59,178,.16);
}

.calculator-main > h2,
.calculator-results > h2 {
    max-width: 470px;

    margin:
        0 auto 6px;

    color: #fff;

    font-size:
        clamp(
            1.4rem,
            4vw,
            1.85rem
        );

    line-height: 1.15;

    letter-spacing: -.04em;

    text-align: center;
}

.calculator-main > p {
    margin:
        0 0
        23px;

    color:
        rgba(230,234,255,.59);

    font-size: .84rem;

    text-align: center;
}

.time-picker {
    display: grid;

    grid-template-columns:
        1fr auto 1fr 82px;

    align-items: center;

    gap: 9px;

    margin:
        0 auto
        18px;
}

.time-picker select,
.advanced-grid select {
    width: 100%;

    min-height: 58px;

    appearance: none;

    border:
        1px solid
        rgba(255,255,255,.10);

    border-radius: 15px;

    outline: 0;

    background:
        rgba(8,13,31,.58);

    color: #fff;

    font-weight: 800;

    text-align: center;

    text-align-last: center;
}

.time-picker select {
    font-size: 1.25rem;
}

.time-picker select:hover,
.time-picker select:focus {
    border-color:
        rgba(158,144,255,.60);

    background:
        rgba(8,13,31,.72);
}

.time-colon {
    color:
        rgba(255,255,255,.64);

    font-size: 1.5rem;
    font-weight: 800;
}

.period-select {
    font-size: .9rem !important;
}

.primary-action,
.secondary-action {
    width: 100%;

    min-height: 52px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    gap: 10px;

    border: 0;

    border-radius: 15px;

    font-weight: 850;

    text-decoration: none;

    transition:
        transform .18s ease,
        box-shadow .18s ease,
        opacity .18s ease;
}

.primary-action {
    background:
        linear-gradient(
            135deg,
            #8374ff,
            #667ff4
        );

    color: #fff;

    box-shadow:
        0 14px 30px
        rgba(98,88,231,.25);
}

.primary-action:hover,
.secondary-action:hover {
    transform:
        translateY(-2px);
}

.primary-action:hover {
    box-shadow:
        0 18px 38px
        rgba(98,88,231,.34);
}

.or-divider {
    position: relative;

    display: flex;
    align-items: center;
    justify-content: center;

    margin: 19px 0;
}

.or-divider::before {
    content: '';

    position: absolute;

    left: 0;
    right: 0;

    height: 1px;

    background:
        rgba(255,255,255,.08);
}

.or-divider span {
    position: relative;

    padding:
        0 10px;

    background: #191f3c;

    color:
        rgba(227,232,255,.48);

    font-size: .7rem;
    font-weight: 800;

    text-transform: uppercase;
}

.sleep-now {
    display: grid;

    gap: 3px;

    text-align: center;
}

.sleep-now strong {
    color: #fff;

    font-size: .92rem;
}

.sleep-now > span {
    color:
        rgba(230,234,255,.55);

    font-size: .78rem;
}

.secondary-action {
    min-height: 45px;

    margin-top: 10px;

    border:
        1px solid
        rgba(255,255,255,.11);

    background:
        rgba(255,255,255,.055);

    color: #eae8ff;
}

.advanced-options {
    margin-top: 22px;

    border-top:
        1px solid
        rgba(255,255,255,.075);
}

.advanced-options summary {
    padding-top: 18px;

    color:
        rgba(231,235,255,.65);

    font-size: .76rem;
    font-weight: 750;

    text-align: center;

    cursor: pointer;
}

.advanced-grid {
    display: grid;

    grid-template-columns:
        1fr 1fr;

    gap: 10px;

    margin-top: 15px;
}

.advanced-grid label {
    display: grid;

    gap: 6px;

    color:
        rgba(231,235,255,.62);

    font-size: .72rem;
}

.advanced-grid select {
    min-height: 43px;

    font-size: .76rem;
}

.advanced-options > p {
    margin:
        11px 0 0;

    color:
        rgba(231,235,255,.43);

    font-size: .67rem;

    text-align: center;
}


/* RESULTS */

.calculator-results {
    position: relative;

    min-height: 525px;
}

.back-button {
    position: absolute;

    top: 17px;
    left: 18px;

    border: 0;

    background: transparent;

    color:
        rgba(236,239,255,.58);

    font-size: .72rem;
    font-weight: 700;
}

.results-moon {
    margin-top: 11px;
}

.results-eyebrow {
    display: block;

    margin-bottom: 7px;

    color: #bdb4ff;

    font-size: .67rem;
    font-weight: 850;

    letter-spacing: .09em;

    text-align: center;

    text-transform: uppercase;
}

.results-intro {
    max-width: 420px;

    margin:
        9px auto
        19px;

    color:
        rgba(231,235,255,.56);

    font-size: .79rem;

    text-align: center;
}

.result-times {
    display: grid;

    gap: 9px;
}

.result-time {
    display: grid;

    grid-template-columns:
        minmax(0, 1fr)
        auto;

    align-items: center;

    gap: 15px;

    min-height: 67px;

    padding:
        10px 16px;

    border:
        1px solid
        rgba(255,255,255,.085);

    border-radius: 15px;

    background:
        rgba(255,255,255,.042);
}

.result-time.is-best {
    border-color:
        rgba(151,136,255,.42);

    background:
        linear-gradient(
            135deg,
            rgba(129,111,255,.15),
            rgba(255,255,255,.035)
        );
}

.result-time strong {
    color: #fff;

    font-size: 1.18rem;

    letter-spacing: -.025em;
}

.result-meta {
    display: flex;

    flex-wrap: wrap;

    gap: 5px;

    margin-top: 1px;

    color:
        rgba(229,233,255,.48);

    font-size: .67rem;
}

.result-badge {
    padding:
        4px 7px;

    border-radius: 999px;

    background:
        rgba(130,116,255,.15);

    color: #c8c0ff;

    font-size: .61rem;
    font-weight: 850;

    text-transform: uppercase;
}

.results-note {
    margin:
        15px 0;

    color:
        rgba(230,234,255,.43);

    font-size: .66rem;

    text-align: center;
}

.hero-trust {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;

    gap: 15px;

    margin-top: 17px;

    color:
        rgba(230,235,255,.48);

    font-size: .68rem;
    font-weight: 650;
}


/* CONTENT */

.section {
    padding:
        82px 0;
}

.content-width {
    width:
        min(
            980px,
            calc(100% - 34px)
        );

    margin: 0 auto;
}

.section-kicker {
    border-color:
        var(--line);

    background:
        var(--surface-soft);

    color:
        var(--primary);

    font-size: .65rem;
}

.section h2,
.simple-page h1 {
    margin:
        15px 0
        12px;

    color: var(--text);

    font-size:
        clamp(
            1.8rem,
            4vw,
            2.7rem
        );

    line-height: 1.05;

    letter-spacing: -.05em;
}

.lead {
    max-width: 700px;

    color: var(--muted);

    font-size: 1.03rem;
}

.three-cards {
    display: grid;

    grid-template-columns:
        repeat(
            3,
            minmax(0,1fr)
        );

    gap: 14px;

    margin-top: 31px;
}

.three-cards article,
.fact-row article,
.article-card {
    border:
        1px solid
        var(--line);

    border-radius: 20px;

    background:
        var(--surface);

    box-shadow:
        0 12px 30px
        rgba(0,0,0,.035);
}

.three-cards article {
    padding: 22px;
}

.three-cards article > span {
    width: 31px;
    height: 31px;

    display: grid;
    place-items: center;

    border-radius: 10px;

    background:
        rgba(125,111,255,.12);

    color: var(--primary);

    font-size: .72rem;
    font-weight: 900;
}

.three-cards h3 {
    margin:
        14px 0
        6px;

    font-size: .98rem;
}

.three-cards p {
    margin: 0;

    color: var(--muted);

    font-size: .84rem;
}

.soft-section {
    background:
        linear-gradient(
            180deg,
            transparent,
            rgba(127,112,255,.045),
            transparent
        );
}

.split-heading {
    display: grid;

    grid-template-columns:
        1fr 1fr;

    align-items: end;

    gap: 45px;
}

.split-heading p {
    color: var(--muted);
}

.fact-row {
    display: grid;

    grid-template-columns:
        repeat(
            3,
            minmax(0,1fr)
        );

    gap: 14px;

    margin-top: 27px;
}

.fact-row article {
    padding: 22px;

    text-align: center;
}

.fact-row strong {
    display: block;

    color: var(--primary);

    font-size: 1.55rem;

    letter-spacing: -.04em;
}

.fact-row span {
    display: block;

    margin-top: 6px;

    color: var(--muted);

    font-size: .8rem;
}

.source-note {
    margin:
        20px 0 0;

    color: var(--muted);

    font-size: .7rem;

    text-align: center;
}

.faq-list {
    display: grid;

    gap: 10px;

    margin-top: 28px;
}

.faq-list details {
    padding:
        17px 19px;

    border:
        1px solid
        var(--line);

    border-radius: 16px;

    background: var(--surface);
}

.faq-list summary {
    font-weight: 800;

    cursor: pointer;
}

.faq-list p {
    margin:
        12px 0
        1px;

    color: var(--muted);

    font-size: .88rem;
}


/* SIMPLE PAGES */

.simple-page {
    min-height:
        calc(100vh - 170px);

    padding:
        135px 0
        85px;

    background:
        radial-gradient(
            circle at 50% 0,
            rgba(126,111,255,.09),
            transparent 32%
        );
}

.simple-page .content-width {
    max-width: 800px;
}

.article-card {
    padding:
        clamp(
            22px,
            5vw,
            42px
        );
}

.article-card h1 {
    margin-top: 0;
}

.article-card h2 {
    margin-top: 30px;

    font-size: 1.25rem;
}

.article-card p {
    color: var(--muted);
}

.inline-action {
    width: auto;

    margin-top: 10px;

    padding:
        0 22px;
}


/* FOOTER */

.site-footer {
    border-top:
        1px solid
        var(--line);

    background:
        var(--bg-deep);
}

.footer-inner {
    width:
        min(
            1060px,
            calc(100% - 34px)
        );

    display: grid;

    grid-template-columns:
        1fr auto;

    gap: 35px;

    padding:
        40px 0
        27px;

    margin: 0 auto;
}

.footer-inner strong {
    font-size: .94rem;
}

.footer-inner p {
    max-width: 430px;

    margin:
        7px 0 0;

    color: var(--muted);

    font-size: .76rem;
}

.footer-inner nav {
    display: flex;
    flex-wrap: wrap;

    justify-content: flex-end;

    gap: 7px;
}

.footer-inner nav a {
    padding:
        6px 8px;

    color: var(--muted);

    font-size: .72rem;

    text-decoration: none;
}

.footer-inner nav a:hover {
    color: var(--text);
}

.footer-bottom {
    padding:
        15px;

    border-top:
        1px solid
        var(--line);

    color: var(--muted);

    font-size: .66rem;

    text-align: center;
}


/* ANIMATION */

@keyframes twinkle {
    0%,
    100% {
        opacity: .25;
        transform: scale(.8);
    }

    50% {
        opacity: 1;
        transform: scale(1.3);
    }
}

@keyframes moonFloat {
    0%,
    100% {
        transform:
            translateY(0);
    }

    50% {
        transform:
            translateY(-9px);
    }
}

@keyframes cloudMove {
    0%,
    100% {
        transform:
            translateX(0);
    }

    50% {
        transform:
            translateX(23px);
    }
}


/* LIGHT MODE */

[data-theme="light"] .sleep-hero {
    background:
        radial-gradient(
            circle at 50% 0,
            rgba(140,119,255,.17),
            transparent 40%
        ),
        linear-gradient(
            180deg,
            #7588c8 0%,
            #788ccb 36%,
            #a8b7dc 100%
        );
}

[data-theme="light"] .moon span {
    background: #788ccb;
}

[data-theme="light"] .calculator-card {
    background:
        linear-gradient(
            180deg,
            rgba(255,255,255,.92),
            rgba(247,248,255,.94)
        );

    border-color:
        rgba(255,255,255,.55);
}

[data-theme="light"] .calculator-main > h2,
[data-theme="light"] .calculator-results > h2,
[data-theme="light"] .sleep-now strong,
[data-theme="light"] .result-time strong {
    color: #1c2545;
}

[data-theme="light"] .calculator-main > p,
[data-theme="light"] .sleep-now > span,
[data-theme="light"] .results-intro,
[data-theme="light"] .results-note {
    color: #7180a3;
}

[data-theme="light"] .time-picker select,
[data-theme="light"] .advanced-grid select {
    background:
        rgba(238,240,251,.92);

    border-color:
        rgba(63,71,110,.10);

    color: #202847;
}

[data-theme="light"] .or-divider::before {
    background:
        rgba(40,52,90,.10);
}

[data-theme="light"] .or-divider span {
    background: #fafaff;

    color: #8992ad;
}

[data-theme="light"] .secondary-action,
[data-theme="light"] .result-time {
    border-color:
        rgba(50,61,100,.10);

    background:
        rgba(85,92,140,.045);

    color: #303956;
}

[data-theme="light"] .advanced-options {
    border-color:
        rgba(40,51,89,.08);
}

[data-theme="light"] .advanced-options summary,
[data-theme="light"] .advanced-grid label,
[data-theme="light"] .advanced-options > p {
    color: #77819f;
}


/* RESPONSIVE */

@media (max-width: 760px) {

    .header-inner {
        min-height: 67px;
    }

    .main-nav > a:nth-child(2),
    .main-nav > a:nth-child(3) {
        display: none;
    }

    .sleep-hero {
        min-height: 760px;
    }

    .hero-inner {
        padding-top: 92px;
    }

    .moon {
        width: 65px;
        height: 65px;

        top: 82px;
        left: 5%;

        opacity: .66;
    }

    .moon span {
        width: 54px;
        height: 54px;

        left: 20px;
    }

    .three-cards,
    .fact-row,
    .split-heading {
        grid-template-columns: 1fr;
    }

    .split-heading {
        gap: 5px;
    }

    .footer-inner {
        grid-template-columns: 1fr;
    }

    .footer-inner nav {
        justify-content: flex-start;
    }

}

@media (max-width: 520px) {

    .brand {
        font-size: .92rem;
    }

    .brand-moon {
        width: 30px;
        height: 30px;
    }

    .hero-copy h1 {
        font-size: 2.45rem;
    }

    .calculator-card {
        border-radius: 23px;
    }

    .calculator-main,
    .calculator-results {
        padding:
            27px 20px;
    }

    .time-picker {
        grid-template-columns:
            1fr auto 1fr 72px;

        gap: 6px;
    }

    .time-picker select {
        min-height: 53px;

        font-size: 1rem;
    }

    .advanced-grid {
        grid-template-columns: 1fr;
    }

    .section {
        padding:
            64px 0;
    }

}

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;

        animation-duration:
            .01ms !important;

        animation-iteration-count:
            1 !important;

        transition-duration:
            .01ms !important;
    }

}


/* =====================================================
   PHASE 2 — ADVANCED SLEEP TOOLS
   ===================================================== */


/* HEADER TOOLS MENU */

.tools-menu {
    position: relative;
}

.tools-menu > summary {
    min-height: 40px;

    display: inline-flex;
    align-items: center;

    gap: 5px;

    padding: 8px 11px;

    border-radius: 10px;

    color:
        rgba(255,255,255,.78);

    font-size: .84rem;
    font-weight: 650;

    list-style: none;

    cursor: pointer;
}

.tools-menu > summary::-webkit-details-marker {
    display: none;
}

.tools-menu > summary::after {
    content: '⌄';

    opacity: .65;

    transform:
        translateY(-1px);
}

.tools-menu[open] > summary,
.tools-menu > summary:hover {
    background:
        rgba(255,255,255,.08);

    color: #fff;
}

.tools-dropdown {
    position: absolute;

    top:
        calc(100% + 9px);

    right: 0;

    z-index: 50;

    width: 285px;

    display: grid;

    gap: 4px;

    padding: 8px;

    border:
        1px solid
        rgba(255,255,255,.11);

    border-radius: 16px;

    background:
        rgba(17,22,48,.97);

    box-shadow:
        0 22px 60px
        rgba(0,0,0,.34);

    backdrop-filter:
        blur(18px);
}

.tools-dropdown a {
    display: grid;

    gap: 1px;

    padding:
        10px 11px;

    border-radius: 11px;

    text-decoration: none;
}

.tools-dropdown a:hover {
    background:
        rgba(255,255,255,.065);
}

.tools-dropdown strong {
    color: #fff;

    font-size: .79rem;
}

.tools-dropdown span {
    color:
        rgba(230,234,255,.52);

    font-size: .67rem;
}


/* TOOL PAGES */

.tool-page {
    min-height:
        calc(100vh - 160px);

    padding:
        128px 0 86px;

    background:
        radial-gradient(
            circle at 50% -5%,
            rgba(128,111,255,.17),
            transparent 35%
        ),
        linear-gradient(
            180deg,
            var(--bg-deep),
            var(--bg)
        );
}

.tool-page-width {
    width:
        min(
            760px,
            calc(100% - 32px)
        );

    margin: 0 auto;
}

.tool-hero {
    max-width: 650px;

    margin:
        0 auto
        28px;

    text-align: center;
}

.tool-hero h1 {
    margin:
        14px 0 10px;

    font-size:
        clamp(
            2rem,
            6vw,
            3.35rem
        );

    line-height: 1;

    letter-spacing: -.055em;
}

.tool-hero p {
    max-width: 610px;

    margin: 0 auto;

    color: var(--muted);

    font-size: .96rem;
}

.sleep-tool-card {
    width:
        min(
            100%,
            610px
        );

    margin: 0 auto;

    padding:
        clamp(
            23px,
            5vw,
            37px
        );

    border:
        1px solid
        var(--line);

    border-radius: 25px;

    background:
        linear-gradient(
            180deg,
            var(--surface),
            color-mix(
                in srgb,
                var(--surface-solid) 94%,
                var(--primary)
            )
        );

    box-shadow:
        var(--shadow);
}

.tool-icon {
    width: 46px;
    height: 46px;

    display: grid;
    place-items: center;

    margin:
        0 auto 10px;

    border:
        1px solid
        var(--line);

    border-radius: 14px;

    background:
        color-mix(
            in srgb,
            var(--primary) 12%,
            var(--surface)
        );

    color: var(--primary);

    font-size: 1.1rem;
}

.sleep-tool-card > h2 {
    margin:
        0 0 22px;

    font-size: 1.2rem;

    letter-spacing: -.035em;

    text-align: center;
}

.tool-form-grid {
    display: grid;

    grid-template-columns:
        repeat(
            2,
            minmax(0,1fr)
        );

    gap: 11px;
}

.tool-form-grid label,
.tool-field {
    display: grid;

    gap: 6px;
}

.tool-field {
    margin-top: 11px;
}

.tool-form-grid label > span,
.tool-field > span {
    color: var(--muted);

    font-size: .72rem;
    font-weight: 750;
}

.tool-form-grid input,
.tool-form-grid select,
.tool-field input,
.tool-field select {
    width: 100%;

    min-height: 51px;

    padding:
        0 13px;

    border:
        1px solid
        var(--line);

    border-radius: 13px;

    outline: 0;

    background:
        color-mix(
            in srgb,
            var(--surface-soft) 88%,
            transparent
        );

    color: var(--text);

    font-weight: 750;
}

.tool-form-grid input:focus,
.tool-form-grid select:focus,
.tool-field input:focus,
.tool-field select:focus {
    border-color:
        color-mix(
            in srgb,
            var(--primary) 65%,
            var(--line)
        );
}

.tool-field small {
    color: var(--muted);

    font-size: .67rem;
}

.tool-primary {
    width: 100%;

    min-height: 51px;

    margin-top: 17px;

    border: 0;

    border-radius: 14px;

    background:
        linear-gradient(
            135deg,
            var(--primary),
            var(--primary-2)
        );

    color: #fff;

    font-weight: 850;

    box-shadow:
        0 13px 28px
        rgba(90,77,218,.22);

    transition:
        transform .18s ease,
        box-shadow .18s ease;
}

.tool-primary:hover {
    transform:
        translateY(-2px);

    box-shadow:
        0 18px 36px
        rgba(90,77,218,.28);
}


/* RESULTS */

.tool-result {
    margin-top: 17px;

    padding:
        19px;

    border:
        1px solid
        color-mix(
            in srgb,
            var(--primary) 30%,
            var(--line)
        );

    border-radius: 16px;

    background:
        color-mix(
            in srgb,
            var(--primary) 7%,
            var(--surface)
        );

    text-align: center;
}

.tool-result-label {
    display: block;

    margin-bottom: 4px;

    color: var(--muted);

    font-size: .68rem;
    font-weight: 800;

    letter-spacing: .055em;

    text-transform: uppercase;
}

.tool-result > strong {
    display: block;

    color: var(--text);

    font-size:
        clamp(
            1.55rem,
            5vw,
            2.1rem
        );

    letter-spacing: -.045em;
}

.tool-result p {
    margin:
        6px 0 0;

    color: var(--muted);

    font-size: .76rem;
}

.tool-result small {
    display: block;

    margin-top: 10px;

    color: var(--muted);

    font-size: .63rem;
}

.location-result-grid {
    display: grid;

    grid-template-columns:
        1fr 1fr;

    gap: 8px;

    margin-bottom: 18px;
}

.location-result-grid > div {
    padding: 12px;

    border:
        1px solid
        var(--line);

    border-radius: 12px;

    background: var(--surface);
}

.location-result-grid span {
    display: block;

    color: var(--muted);

    font-size: .65rem;
}

.location-result-grid strong {
    display: block;

    margin-top: 2px;

    font-size: 1rem;
}

.location-status {
    margin:
        0 0 16px;

    padding:
        9px 11px;

    border-radius: 10px;

    background:
        var(--surface-soft);

    color: var(--muted);

    font-size: .7rem;

    text-align: center;
}

.privacy-note {
    margin:
        13px 0 0;

    color: var(--muted);

    font-size: .65rem;

    text-align: center;
}


/* SUPPORTING COPY */

.tool-info {
    width:
        min(
            100%,
            650px
        );

    margin:
        54px auto 0;
}

.tool-info h2 {
    margin:
        0 0 12px;

    font-size:
        clamp(
            1.45rem,
            4vw,
            2rem
        );

    letter-spacing: -.04em;
}

.tool-info p {
    color: var(--muted);

    font-size: .9rem;
}

.tool-source {
    padding:
        12px 14px;

    border-left:
        3px solid
        var(--primary);

    border-radius:
        0 10px 10px 0;

    background:
        var(--surface);

    font-size:
        .76rem !important;
}

.related-tools {
    width:
        min(
            100%,
            650px
        );

    display: flex;
    flex-wrap: wrap;

    gap: 7px;

    margin:
        32px auto 0;
}

.related-tools a {
    padding:
        7px 11px;

    border:
        1px solid
        var(--line);

    border-radius: 999px;

    background: var(--surface);

    color: var(--muted);

    font-size: .69rem;
    font-weight: 750;

    text-decoration: none;
}

.related-tools a:hover {
    border-color:
        color-mix(
            in srgb,
            var(--primary) 45%,
            var(--line)
        );

    color: var(--text);
}


/* LIGHT */

[data-theme="light"] .tools-dropdown {
    border-color:
        rgba(30,40,80,.10);

    background:
        rgba(255,255,255,.98);

    box-shadow:
        0 20px 55px
        rgba(42,53,100,.17);
}

[data-theme="light"] .tools-dropdown strong {
    color: #1d2542;
}

[data-theme="light"] .tools-dropdown span {
    color: #737e9d;
}


/* RESPONSIVE */

@media (max-width: 760px) {

    .tools-menu {
        display: block;
    }

    .tools-dropdown {
        position: fixed;

        top: 66px;
        left: 16px;
        right: 16px;

        width: auto;
    }

    .tool-page {
        padding-top: 104px;
    }
}

@media (max-width: 540px) {

    .tool-form-grid,
    .location-result-grid {
        grid-template-columns: 1fr;
    }

    .sleep-tool-card {
        border-radius: 21px;
    }

}



/* =====================================================
   PHASE 3 — SEO AEO GEO
   ===================================================== */


.tools-all-link {
    margin-top: 3px;

    border-top:
        1px solid
        rgba(255,255,255,.08);

    border-radius:
        5px 5px 11px 11px !important;
}


.tool-directory-width {
    width:
        min(
            930px,
            calc(100% - 32px)
        );
}


.sleep-tool-directory {
    display: grid;

    grid-template-columns:
        repeat(
            3,
            minmax(0, 1fr)
        );

    gap: 12px;
}


.sleep-directory-card {
    min-height: 145px;

    display: flex;
    align-items: flex-start;

    gap: 13px;

    padding: 19px;

    border:
        1px solid
        var(--line);

    border-radius: 18px;

    background:
        var(--surface);

    text-decoration: none;

    transition:
        transform .18s ease,
        border-color .18s ease,
        background .18s ease;
}


.sleep-directory-card:hover {
    transform:
        translateY(-3px);

    border-color:
        color-mix(
            in srgb,
            var(--primary) 40%,
            var(--line)
        );

    background:
        color-mix(
            in srgb,
            var(--surface) 95%,
            var(--primary)
        );
}


.sleep-directory-card > span {
    width: 36px;
    height: 36px;

    flex: 0 0 36px;

    display: grid;
    place-items: center;

    border-radius: 11px;

    background:
        color-mix(
            in srgb,
            var(--primary) 11%,
            var(--surface)
        );
}


.sleep-directory-card strong {
    display: block;

    margin-top: 1px;

    color: var(--text);

    font-size: .9rem;
}


.sleep-directory-card p {
    margin:
        5px 0 0;

    color: var(--muted);

    font-size: .75rem;

    line-height: 1.5;
}


.sleep-directory-card.is-featured {
    border-color:
        color-mix(
            in srgb,
            var(--primary) 38%,
            var(--line)
        );

    background:
        linear-gradient(
            135deg,
            color-mix(
                in srgb,
                var(--primary) 11%,
                var(--surface)
            ),
            var(--surface)
        );
}


/* SEO calculator */

.seo-sleep-calculator
.tool-form-grid {
    margin-top: 11px;
}


.tool-subtle-button {
    width: 100%;

    min-height: 40px;

    margin-top: 8px;

    border:
        1px solid
        var(--line);

    border-radius: 11px;

    background:
        var(--surface-soft);

    color: var(--muted);

    font-size: .72rem;
    font-weight: 800;
}


.tool-subtle-button:hover {
    color: var(--text);
}


.seo-results {
    display: grid;

    gap: 8px;

    padding: 10px;

    text-align: left;
}


.seo-result-row {
    display: flex;

    align-items: center;
    justify-content: space-between;

    gap: 14px;

    min-height: 72px;

    padding:
        10px 12px;

    border:
        1px solid
        var(--line);

    border-radius: 12px;

    background:
        var(--surface);
}


.seo-result-row.is-featured {
    border-color:
        color-mix(
            in srgb,
            var(--primary) 40%,
            var(--line)
        );

    background:
        color-mix(
            in srgb,
            var(--primary) 7%,
            var(--surface)
        );
}


.seo-result-row strong {
    display: block;

    color: var(--text);

    font-size: 1.08rem;
}


.seo-result-row span,
.seo-result-row small {
    display: block;
}


.seo-result-row span {
    margin-top: 1px;

    color: var(--primary);

    font-size: .68rem;
    font-weight: 800;
}


.seo-result-row small {
    margin-top: 2px;

    color: var(--muted);

    font-size: .63rem;
}


.seo-result-row b {
    flex: 0 0 auto;

    padding:
        5px 7px;

    border-radius: 999px;

    background:
        color-mix(
            in srgb,
            var(--primary) 13%,
            var(--surface)
        );

    color: var(--primary);

    font-size: .58rem;

    text-transform: uppercase;
}


/* Direct answer */

.direct-answer-card,
.evidence-card {
    width:
        min(
            100%,
            650px
        );

    margin:
        34px auto 0;

    padding:
        clamp(
            20px,
            5vw,
            29px
        );

    border:
        1px solid
        var(--line);

    border-radius: 20px;

    background: var(--surface);
}


.direct-answer-card > span {
    display: inline-block;

    color: var(--primary);

    font-size: .64rem;
    font-weight: 900;

    letter-spacing: .07em;

    text-transform: uppercase;
}


.direct-answer-card h2,
.evidence-card h2 {
    margin:
        8px 0 8px;

    font-size:
        clamp(
            1.3rem,
            4vw,
            1.75rem
        );

    letter-spacing: -.04em;
}


.direct-answer-card p,
.evidence-card p {
    margin-bottom: 0;

    color: var(--muted);

    font-size: .87rem;
}


/* Evidence */

.evidence-card {
    margin-top: 14px;
}


.evidence-facts {
    display: grid;

    grid-template-columns:
        1fr 1fr;

    gap: 9px;

    margin-top: 19px;
}


.evidence-facts article {
    padding: 14px;

    border:
        1px solid
        var(--line);

    border-radius: 13px;

    background:
        var(--surface-soft);
}


.evidence-facts strong {
    display: block;

    color: var(--primary);

    font-size: 1.25rem;
}


.evidence-facts span {
    display: block;

    margin-top: 3px;

    color: var(--muted);

    font-size: .68rem;

    line-height: 1.5;
}


.source-links {
    margin-top:
        15px !important;

    padding-top: 13px;

    border-top:
        1px solid
        var(--line);

    font-size:
        .7rem !important;
}


.source-links a {
    color: var(--primary);

    font-weight: 800;
}


/* Homepage supporting tool cluster */

.homepage-tools-section {
    padding-top: 60px;
}


.homepage-tool-grid {
    display: grid;

    grid-template-columns:
        repeat(
            4,
            minmax(0, 1fr)
        );

    gap: 10px;

    margin-top: 28px;
}


.homepage-tool-grid a {
    display: grid;

    gap: 5px;

    min-height: 128px;

    padding: 17px;

    border:
        1px solid
        var(--line);

    border-radius: 17px;

    background: var(--surface);

    text-decoration: none;

    transition:
        transform .18s ease,
        border-color .18s ease;
}


.homepage-tool-grid a:hover {
    transform:
        translateY(-3px);

    border-color:
        color-mix(
            in srgb,
            var(--primary) 45%,
            var(--line)
        );
}


.homepage-tool-grid a > span {
    font-size: 1.1rem;
}


.homepage-tool-grid strong {
    color: var(--text);

    font-size: .84rem;
}


.homepage-tool-grid small {
    color: var(--muted);

    font-size: .68rem;
}


.seo-tool-faq {
    width:
        min(
            100%,
            650px
        );

    margin:
        54px auto 0;

    padding: 0;
}


@media (max-width: 820px) {

    .sleep-tool-directory {
        grid-template-columns:
            repeat(
                2,
                minmax(0, 1fr)
            );
    }

    .homepage-tool-grid {
        grid-template-columns:
            repeat(
                2,
                minmax(0, 1fr)
            );
    }
}


@media (max-width: 520px) {

    .sleep-tool-directory,
    .homepage-tool-grid,
    .evidence-facts {
        grid-template-columns: 1fr;
    }

    .sleep-directory-card {
        min-height: auto;
    }
}



/* =====================================================
   PHASE 4 — FINAL LAUNCH POLISH
   ===================================================== */

html {
    overflow-x: hidden;
}

body {
    min-width: 320px;
}

h1,
h2,
h3 {
    text-wrap: balance;
}

p {
    text-wrap: pretty;
}

a,
button,
input,
select,
summary {
    touch-action: manipulation;
}

.tool-result,
.result-times {
    scroll-margin-top: 100px;
}

.sleep-directory-card,
.homepage-tool-grid a,
.related-tools a {
    overflow-wrap: anywhere;
}


/*
 * Avoid automatic iOS zoom when form controls
 * receive focus on small devices.
 */

@media (max-width: 760px) {

    input,
    select,
    textarea {
        font-size: 16px;
    }

    .main-nav {
        gap: 2px;
    }

    .main-nav > a,
    .theme-button,
    .tools-menu > summary {
        min-height: 44px;
    }
}


/*
 * High-contrast / forced-color accessibility.
 */

@media (forced-colors: active) {

    .calculator-card,
    .sleep-tool-card,
    .article-card,
    .sleep-directory-card,
    .faq-list details,
    .direct-answer-card,
    .evidence-card {
        border: 1px solid CanvasText;
    }

    .primary-action,
    .secondary-action,
    .tool-primary {
        border: 1px solid ButtonText;
    }
}


/*
 * Printing should show useful content rather than
 * decorative animated sky elements.
 */

@media print {

    .site-header,
    .sleep-sky,
    .site-footer,
    .theme-button,
    .tools-menu {
        display: none !important;
    }

    body,
    .sleep-hero,
    .tool-page,
    .simple-page {
        background: #fff !important;
        color: #000 !important;
    }

    .sleep-hero {
        min-height: auto;
    }

    .calculator-card,
    .sleep-tool-card {
        box-shadow: none !important;
    }
}

