:root {
    --qii-bg-a: #fff7ed;
    --qii-bg-b: #ecfeff;
    --qii-bg-c: #fef9c3;
    --qii-brand: #0f766e;
    --qii-accent: #ea580c;
}

body {
    background: radial-gradient(circle at 10% 20%, var(--qii-bg-a), transparent 35%),
        radial-gradient(circle at 90% 10%, var(--qii-bg-b), transparent 35%),
        radial-gradient(circle at 50% 90%, var(--qii-bg-c), transparent 35%),
        #f8fafc;
    min-height: 100vh;
}

[data-bs-theme="dark"] body {
    background: radial-gradient(circle at 10% 20%, #1f2937, transparent 35%),
        radial-gradient(circle at 90% 10%, #0f172a, transparent 35%),
        radial-gradient(circle at 50% 90%, #334155, transparent 35%),
        #020617;
}

.navbar-brand {
    font-weight: 700;
}

.card {
    border: 0;
    box-shadow: 0 8px 22px rgba(2, 6, 23, 0.08);
}

[data-bs-theme="dark"] .card {
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}

.period-badge {
    font-size: 0.75rem;
}

.container-narrow {
    max-width: 900px;
}

.metric-box {
    background: #ffffff;
    border-radius: 0.75rem;
    padding: 0.75rem;
    border: 1px solid #e2e8f0;
}

[data-bs-theme="dark"] .metric-box {
    background: #0f172a;
    border-color: #334155;
}

.theme-toggle-btn .theme-icon {
    display: none;
}

[data-bs-theme="light"] .theme-toggle-btn .theme-icon-moon {
    display: inline-block;
}

[data-bs-theme="dark"] .theme-toggle-btn .theme-icon-sun {
    display: inline-block;
}

.scroll-to-top-btn {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 1050;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.scroll-to-top-btn--visible {
    opacity: 1;
    visibility: visible;
}

/* ── Icon-action buttons (icon + optional label) ─────────────────────── */
.btn-icon-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
}

/* ── Tracking tabs: icon + label layout ──────────────────────────────── */
#trackingTabs .nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    padding-inline: 0.75rem;
    padding-block: 0.5rem;
    font-size: 0.8rem;
    white-space: nowrap;
}

#trackingTabs .nav-link .tab-icon {
    flex-shrink: 0;
    width: 1.125rem;
    height: 1.125rem;
    color: var(--bs-success);
}

/* ── Sleep quality icon rating ───────────────────────────────────────── */
.sleep-quality-rating {
    display: flex;
    gap: 0.5rem;
    flex-wrap: nowrap;
}

.sleep-quality-rating input[type="radio"] {
    display: none;
}

.sleep-quality-rating label {
    cursor: pointer;
    color: #cbd5e1;
    transition: color 0.15s ease, transform 0.1s ease;
    line-height: 1;
}

.sleep-quality-rating label:hover {
    color: #f59e0b;
}

/* Star rating active state – set by JavaScript */
.sleep-quality-rating label.active {
    color: #f59e0b;
}

.sleep-quality-rating label:hover {
    transform: scale(1.15);
}

/* ── Mobile improvements ─────────────────────────────────────────────── */
@media (max-width: 575.98px) {
    /* Touch-friendly minimum tap targets */
    .form-control,
    .form-select {
        min-height: 44px;
    }

    .btn:not(.btn-close):not(.scroll-to-top-btn):not(.navbar-toggler) {
        min-height: 44px;
    }

    .btn-sm {
        min-height: 38px;
    }

    /* Hide button text labels on mobile – icons only */
    .btn .btn-label {
        display: none;
    }

    /* Reduce card inner padding on very small screens */
    .card.p-3 {
        padding: 0.625rem !important;
    }

    .card.p-4 {
        padding: 0.875rem !important;
    }

    /* Tracking date header: stack on tiny screens */
    .tracking-date-bar {
        flex-direction: column;
        align-items: stretch !important;
    }

    .tracking-date-bar .form-date-row {
        width: 100%;
    }

    /* Tab bar: horizontal scroll, never vertical, icons only */
    #trackingTabs {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none; /* Firefox */
    }

    #trackingTabs::-webkit-scrollbar {
        display: none; /* Chrome/Safari */
    }

    #trackingTabs .nav-link {
        padding-inline: 0.5rem;
        padding-block: 0.375rem;
        font-size: 0.7rem;
    }

    /* On very small screens hide tab label text, keep icons */
    #trackingTabs .tab-label {
        display: none;
    }

    /* Larger icons on mobile so they are easy to tap and identify */
    #trackingTabs .nav-link .tab-icon {
        width: 1.5rem;
        height: 1.5rem;
    }
}
