/* =============================================================================
   Melodia web — look & feel of the mobile app (Cairo font, dark palettes, tiles)
   ============================================================================= */

/* ----- Appearance palettes (same values as lib/global/app_themes.dart) ----- */
.app-root[data-theme="0"] { --prime: #B8D8D8; --prime-bright: #7A9E9F; --sec: #4F6367; --accent: #FE5F55; --white: #EEF5DB; --black: #2C3E3F; --grey: #8FA9AA; --dark-grey: #3D5053; }
.app-root[data-theme="1"] { --prime: #9B8EC4; --prime-bright: #7C5CFC; --sec: #0F0E1A; --accent: #FF8A6B; --white: #F0EDF6; --black: #1A1528; --grey: #8B82A8; --dark-grey: #1E1A2E; }
.app-root[data-theme="2"] { --prime: #64B5F6; --prime-bright: #1E88E5; --sec: #0A1628; --accent: #FFAB40; --white: #E8F0FE; --black: #0D2137; --grey: #7090B0; --dark-grey: #132B45; }
.app-root[data-theme="3"] { --prime: #80DEEA; --prime-bright: #26C6DA; --sec: #0D1B2A; --accent: #CE93D8; --white: #E0F7FA; --black: #102030; --grey: #6B9EA8; --dark-grey: #152535; }
.app-root[data-theme="4"] { --prime: #FFAB91; --prime-bright: #FF7043; --sec: #1A0F0A; --accent: #FFD54F; --white: #FFF3E0; --black: #2D1810; --grey: #B08070; --dark-grey: #2A1A14; }
.app-root[data-theme="5"] { --prime: #A5D6A7; --prime-bright: #66BB6A; --sec: #0A1A0F; --accent: #DCE775; --white: #E8F5E9; --black: #1B2E1F; --grey: #78A67C; --dark-grey: #152618; }
.app-root[data-theme="6"] { --prime: #D4A76A; --prime-bright: #C08B3E; --sec: #1A150D; --accent: #EF5350; --white: #F5EDE0; --black: #2E2518; --grey: #A89070; --dark-grey: #2A2015; }
.app-root[data-theme="7"] { --prime: #F48FB1; --prime-bright: #EC407A; --sec: #1A0D14; --accent: #CE93D8; --white: #FCE4EC; --black: #2D1520; --grey: #A87088; --dark-grey: #251520; }
.app-root[data-theme="8"] { --prime: #B0BEC5; --prime-bright: #78909C; --sec: #10171E; --accent: #4FC3F7; --white: #ECEFF1; --black: #1C252E; --grey: #7E919C; --dark-grey: #1A2530; }
.app-root[data-theme="9"] { --prime: #69F0AE; --prime-bright: #00C853; --sec: #071A10; --accent: #FF6E40; --white: #E0F2F1; --black: #0E2818; --grey: #5CA87A; --dark-grey: #0F2518; }

.app-root {
    --prime: #9B8EC4; --prime-bright: #7C5CFC; --sec: #0F0E1A; --accent: #FF8A6B;
    --white: #F0EDF6; --black: #1A1528; --grey: #8B82A8; --dark-grey: #1E1A2E;
    --max-width: 1000px;
}

/* ----- Base ----- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    background: #0F0E1A;
}

body {
    font-family: "Cairo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-weight: 500;
    color: #F0EDF6;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

button, select, input { font-family: inherit; }
img { max-width: 100%; }

.app-root {
    position: relative;
    min-height: 100dvh;
    background: var(--sec);
    color: var(--white);
}

.app-shell {
    position: relative;
    z-index: 1;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 16px 40px;
}

.page { display: block; }

/* ----- Splash / loading ----- */
.splash {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 32px;
}

.splash-logo { width: 130px; height: 130px; filter: drop-shadow(0 0 24px color-mix(in srgb, var(--prime) 45%, transparent)); }

.spinner {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 3px solid color-mix(in srgb, var(--prime) 25%, transparent);
    border-top-color: var(--prime-bright);
    animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-block { display: grid; place-items: center; min-height: 40vh; }
.error-block { text-align: center; color: var(--accent); }

/* ----- Top bar ----- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 8px;
}

.topbar-logo { display: block; width: 44px; height: 44px; opacity: 0.9; transition: transform 0.15s, opacity 0.15s; }
.topbar-logo img { width: 100%; height: 100%; display: block; }
.topbar-logo:hover { opacity: 1; transform: scale(1.06); }
.icon-btn.hidden { visibility: hidden; pointer-events: none; }

/* ----- Home page (StartPage of the app) ----- */
.home-bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    background: linear-gradient(135deg, var(--sec) 0%, var(--dark-grey) 35%, color-mix(in srgb, var(--prime) 8%, var(--sec)) 65%, var(--sec) 100%);
}

.home-bg::after {
    content: "";
    position: absolute;
    inset: 0;
    background-color: var(--prime);
    -webkit-mask: url("bg.svg") 0 0 / 233px 176px repeat;
    mask: url("bg.svg") 0 0 / 233px 176px repeat;
    opacity: 0.12;
}

.home-glow {
    position: fixed;
    top: 6vh;
    left: 50%;
    z-index: -1;
    width: 260px;
    height: 260px;
    transform: translateX(-50%);
    border-radius: 50%;
    background: radial-gradient(circle, color-mix(in srgb, var(--prime) 10%, transparent) 0%, transparent 70%);
    pointer-events: none;
}

.home {
    padding: 14px 8px 160px;
    text-align: left;
}

.home-title {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    line-height: 1.1;
}

.home-divider {
    height: 1px;
    margin: 18px 0;
    background: color-mix(in srgb, var(--white) 60%, transparent);
}

.home-text {
    margin: 0 0 32px;
    font-size: 15px;
    font-weight: 400;
    line-height: 1.2;
}

.home-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 14px 16px;
    border-radius: 14px;
    background: linear-gradient(to right, var(--prime-bright), var(--prime));
    color: var(--black);
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    box-shadow: 0 4px 12px color-mix(in srgb, var(--prime) 30%, transparent);
    transition: transform 0.15s, box-shadow 0.15s;
}

.home-cta:hover { transform: translateY(-1px); box-shadow: 0 6px 16px color-mix(in srgb, var(--prime) 40%, transparent); }

.home-cta.primary {
    margin-bottom: 14px;
    padding: 16px;
    border-radius: 16px;
    font-size: 18px;
    font-weight: 700;
    box-shadow: 0 6px 16px color-mix(in srgb, var(--prime) 38%, transparent);
}

/* ----- Device profile card (home) ----- */
.profile {
    margin-top: 28px;
    padding: 16px;
    border-radius: 14px;
    border: 1px solid color-mix(in srgb, var(--prime-bright) 30%, transparent);
    background: color-mix(in srgb, var(--dark-grey) 85%, transparent);
}

.profile-head { display: flex; align-items: center; gap: 12px; }
.profile-head > div { flex: 1; min-width: 0; }
.profile-head > i { font-size: 22px; color: var(--prime); width: 28px; text-align: center; }
.profile-name { font-size: 17px; font-weight: 600; line-height: 1.2; }
.profile-device { font-size: 13px; font-weight: 400; color: var(--grey); }

.profile-badges { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--white) 10%, transparent);
    color: var(--white);
    font-size: 13px;
    font-weight: 500;
}

.badge.premium { background: color-mix(in srgb, var(--prime-bright) 25%, transparent); color: var(--prime); }
.badge.premium i { color: #ffc107; }
.badge.trial { background: color-mix(in srgb, var(--prime) 18%, transparent); color: var(--prime); }
.badge.expired { background: color-mix(in srgb, #ff5252 18%, transparent); color: #ff8a80; }

.profile-details {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 16px;
    margin: 14px 0 0;
    font-size: 14px;
}

.profile-details dt { color: var(--grey); font-weight: 400; }
.profile-details dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.profile-details .mono { font-family: ui-monospace, Consolas, monospace; font-size: 13px; color: var(--grey); }
.profile-missing { margin-top: 24px; font-size: 14px; color: var(--grey); text-align: center; }

/* ----- DeviceID entry page (first launch) ----- */
.device-setup {
    max-width: 520px;
    margin: 0 auto;
    padding: 48px 8px 40px;
    text-align: center;
}

.device-logo { width: 110px; height: 110px; filter: drop-shadow(0 0 24px color-mix(in srgb, var(--prime) 45%, transparent)); }
.device-title { margin: 20px 0 0; font-size: 26px; font-weight: 600; line-height: 1.1; }
.device-text { margin: 16px 0 24px; font-size: 15px; font-weight: 400; line-height: 1.3; color: var(--white); }
.device-form { display: flex; flex-direction: column; gap: 14px; }

.device-form input[type="text"] {
    width: 100%;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid color-mix(in srgb, var(--prime) 40%, transparent);
    background: color-mix(in srgb, var(--dark-grey) 85%, transparent);
    color: var(--white);
    font-size: 18px;
    font-family: ui-monospace, Consolas, monospace;
    text-align: center;
}

.device-form input[type="text"]:focus { outline: none; border-color: var(--prime-bright); }

.device-error {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0;
    padding: 12px 14px;
    border-radius: 12px;
    background: color-mix(in srgb, #ff5252 15%, transparent);
    color: #ff8a80;
    font-size: 14px;
    font-weight: 500;
    text-align: left;
}

.device-error i { margin-top: 2px; }
.device-submit { border: none; cursor: pointer; font-family: inherit; }
.device-submit:disabled { opacity: 0.5; cursor: default; transform: none; }

/* ----- Quick session page ----- */
.quick { padding: 12px 8px 40px; text-align: left; }

.quick-title {
    margin: 0 0 20px;
    font-size: 20px;
    font-weight: 600;
    line-height: 1.1;
}

.quick-option {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    margin-bottom: 12px;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid color-mix(in srgb, var(--prime-bright) 30%, transparent);
    background: var(--dark-grey);
    color: var(--white);
    font-size: 15px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.quick-option i { color: var(--prime); font-size: 16px; width: 20px; text-align: center; }
.quick-option:hover { border-color: var(--prime-bright); background: color-mix(in srgb, var(--prime-bright) 12%, var(--dark-grey)); }

.drawer-action {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid color-mix(in srgb, var(--prime) 40%, transparent);
    background: transparent;
    color: var(--white);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
}

.drawer-action i { color: var(--prime); }
.drawer-action:hover { background: color-mix(in srgb, var(--prime) 12%, transparent); }
.drawer-action:disabled { opacity: 0.6; cursor: default; }

.home-logo-float {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 20px;
    display: flex;
    justify-content: center;
    pointer-events: none;
    animation: home-float 3s ease-in-out infinite alternate;
}

.home-logo-float img {
    width: 90px;
    height: 90px;
    animation: home-glow 2.2s ease-in-out infinite alternate;
}

@keyframes home-float { from { transform: translateY(0); } to { transform: translateY(-10px); } }
@keyframes home-glow {
    from { filter: drop-shadow(0 0 18px color-mix(in srgb, var(--prime) 18%, transparent)); }
    to { filter: drop-shadow(0 0 26px color-mix(in srgb, var(--prime) 55%, transparent)); }
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--prime);
    cursor: pointer;
    display: grid;
    place-items: center;
    padding: 0;
    transition: opacity 0.15s, transform 0.15s;
}

.icon-btn:hover { transform: scale(1.05); }
.icon-btn:disabled { opacity: 0.35; cursor: default; transform: none; }

.icon-btn.back {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 3px solid var(--prime);
    font-size: 26px;
}

.icon-btn.menu { width: 44px; height: 44px; font-size: 26px; }

/* ----- Progress indicator (1 ... 5) ----- */
.progress {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 8px 0 16px;
}

.progress-number {
    width: 44px;
    height: 44px;
    margin: 0 4px;
    border-radius: 50%;
    border: 2px solid color-mix(in srgb, var(--prime) 50%, transparent);
    background: color-mix(in srgb, var(--white) 5%, transparent);
    color: var(--prime);
    font-size: 18px;
    font-weight: 700;
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.progress-number.done {
    border-color: var(--prime);
    background: color-mix(in srgb, var(--white) 15%, transparent);
}

.progress-number.current {
    border-color: var(--prime);
    background: color-mix(in srgb, var(--prime) 20%, transparent);
    color: var(--white);
}

.progress-line { display: flex; align-items: center; }
.progress-line span { width: 4px; height: 2px; background: color-mix(in srgb, var(--prime) 50%, transparent); }
.progress-line span.gap { width: 2px; background: transparent; }
.progress-line.done span.gap { background: color-mix(in srgb, var(--prime) 50%, transparent); }

/* ----- Wizard steps ----- */
.step { padding: 16px 0; text-align: center; }

.step-title {
    margin: 0;
    font-size: 28px;
    font-weight: 500;
    line-height: 1.1;
}

.divider {
    width: 150px;
    height: 1px;
    margin: 20px auto;
    background: color-mix(in srgb, var(--white) 60%, transparent);
}

.step-subtitle {
    margin: 0;
    font-size: 15px;
    font-weight: 400;
    line-height: 1.2;
}

.options-title {
    margin: 28px 0 10px;
    font-size: 18px;
    font-weight: 500;
    text-align: left;
}

/* ----- Grids ----- */
.grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.grid.themes { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }

.grid-item {
    position: relative;
    min-height: 118px;
    padding: 14px 8px;
    border-radius: 12px;
    background: color-mix(in srgb, var(--white) 10%, transparent);
    color: var(--white);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s, color 0.15s;
    outline: none;
}

.grid-item:hover, .grid-item:focus-visible, .grid-item.selected {
    background: var(--prime-bright);
    color: var(--black);
}

.grid-icon { font-size: 20px; color: var(--prime); }
.grid-item:hover .grid-icon, .grid-item:focus-visible .grid-icon, .grid-item.selected .grid-icon { color: var(--black); }
.grid-item.locked .grid-icon { color: #9e9e9e; }

/* Premium sound without premium access: disabled tile */
.grid-item.locked, .theme-item.locked {
    opacity: 0.55;
    cursor: not-allowed;
}

.grid-item.locked:hover, .grid-item.locked:focus-visible {
    background: color-mix(in srgb, var(--white) 10%, transparent);
    color: var(--white);
}

.grid-item.locked:hover .grid-icon { color: #9e9e9e; }
.grid-item.locked:hover .grid-badge { color: #ffc107; }
.theme-item.locked:hover, .theme-item.locked:focus-visible { background: transparent; }
.theme-item.locked:hover .theme-name { color: #9e9e9e; font-weight: 500; }
.badge.locked { background: color-mix(in srgb, #ffc107 16%, transparent); color: #ffd54f; }

.grid-label {
    font-size: 15px;
    font-weight: 500;
    line-height: 1.2;
    text-align: center;
    padding: 0 22px;
}

.grid-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    padding: 4px;
    background: none;
    border: none;
    color: var(--prime);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.grid-item:hover .grid-badge, .grid-item.selected .grid-badge { color: var(--black); }
.grid-item.locked .grid-badge { color: #ffc107; cursor: default; }

.btn-more {
    display: inline-block;
    margin-top: 16px;
    padding: 10px 24px;
    border: none;
    border-radius: 8px;
    background: var(--prime);
    color: var(--white);
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.btn-more:hover { filter: brightness(1.08); }

/* ----- Theme tiles ----- */
.theme-item {
    padding: 0 0 6px;
    border-radius: 12px;
    text-align: left;
    cursor: pointer;
    user-select: none;
    outline: none;
    transition: background 0.15s;
}

.theme-item:hover, .theme-item:focus-visible, .theme-item.selected {
    background: color-mix(in srgb, var(--white) 10%, transparent);
}

.theme-image {
    position: relative;
    aspect-ratio: 1 / 1.1;
    border-radius: 12px;
    overflow: hidden;
    background: var(--dark-grey);
}

.theme-image img { width: 100%; height: 100%; object-fit: cover; display: block; }

.theme-image-none {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    font-size: 32px;
    color: var(--prime);
}

.theme-badge {
    position: absolute;
    top: 3px;
    right: 3px;
    padding: 4px;
    background: none;
    border: none;
    color: var(--prime);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

.theme-item.locked .theme-badge { color: #ffc107; cursor: default; }

.theme-name {
    margin: 12px 6px 0;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.2;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    color: var(--white);
}

.theme-item:hover .theme-name, .theme-item.selected .theme-name { color: var(--prime-bright); font-weight: 600; }
.theme-item.locked .theme-name { color: #9e9e9e; }

.theme-underline {
    width: 50px;
    height: 2px;
    margin: 4px 6px 0;
    border-radius: 12px;
    background: #ac7cea;
}

/* ----- Player ----- */
.player-bg {
    position: fixed;
    inset: 0;
    z-index: -1; /* behind the top bar and the player, above the page background */
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
    filter: brightness(0.3);
    pointer-events: none;
}

.player { padding: 1px; text-align: center; }

.player-title {
    margin: 0;
    font-size: 32px;
    font-weight: 300;
    line-height: 1.1;
}

.player-divider { margin: 10px auto 12px; }

.player-slider { padding: 0 8px; }

.time-current { font-size: 36px; font-weight: 300; line-height: 1.1; }
.time-total { margin-top: 2px; font-size: 14px; font-weight: 400; color: var(--grey); }

/* Range sliders: --fill drives the coloured part of the track */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    background: transparent;
    cursor: pointer;
    margin: 0;
}

input[type="range"]:focus { outline: none; }

input[type="range"].seek {
    margin-top: 12px;
    height: 28px;
    --track: linear-gradient(to right, var(--prime) 0 var(--fill, 0%), color-mix(in srgb, var(--dark-grey) 55%, transparent) var(--fill, 0%) 100%);
}

input[type="range"].seek::-webkit-slider-runnable-track { height: 5px; border-radius: 3px; background: var(--track); }
input[type="range"].seek::-moz-range-track { height: 5px; border-radius: 3px; background: var(--track); }
input[type="range"].seek::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px; height: 22px; margin-top: -8.5px;
    border-radius: 50%; border: none;
    background: var(--accent);
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--prime-bright) 18%, transparent);
    transition: box-shadow 0.15s;
}
input[type="range"].seek::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; border: none; background: var(--accent); }
input[type="range"].seek:hover::-webkit-slider-thumb, input[type="range"].seek:active::-webkit-slider-thumb { box-shadow: 0 0 0 10px color-mix(in srgb, var(--prime-bright) 18%, transparent); }

input[type="range"].vol {
    height: 24px;
    --track: linear-gradient(to right, var(--white) 0 var(--fill, 0%), color-mix(in srgb, var(--white) 35%, transparent) var(--fill, 0%) 100%);
}

input[type="range"].vol::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: var(--track); }
input[type="range"].vol::-moz-range-track { height: 4px; border-radius: 2px; background: var(--track); }
input[type="range"].vol::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px; height: 20px; margin-top: -8px;
    border-radius: 50%; border: none;
    background: var(--prime);
}
input[type="range"].vol::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; border: none; background: var(--prime); }

.sub-player {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 22px;
}

.sub-title {
    width: 244px;
    padding-left: 44px;
    font-size: 16px;
    font-weight: 400;
    line-height: 1.1;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sub-row { display: flex; align-items: center; gap: 12px; margin-top: 6px; }

.vol-btn {
    width: 32px;
    padding: 0;
    background: none;
    border: none;
    color: var(--prime);
    font-size: 24px;
    cursor: pointer;
    text-align: center;
}

.vol { width: 200px; }

.download {
    position: relative;
    width: 250px;
    height: 30px;
    margin-top: 10px;
    border-radius: 2px;
    background: color-mix(in srgb, var(--grey) 10%, transparent);
    overflow: hidden;
}

.download-fill {
    position: absolute;
    inset: 0 auto 0 0;
    background: color-mix(in srgb, var(--prime-bright) 40%, transparent);
    transition: width 0.2s;
}

.download-text {
    position: relative;
    padding-left: 60px;
    font-size: 15px;
    font-weight: 700;
    line-height: 30px;
    text-align: left;
    white-space: nowrap;
}

.play-row { margin-top: 24px; }

.play-btn {
    padding: 0;
    background: none;
    border: none;
    color: var(--prime-bright);
    font-size: 48px;
    line-height: 1;
    cursor: pointer;
    transition: transform 0.15s;
}

.play-btn:hover { transform: scale(1.06); }

.loop-note {
    margin-top: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--prime-bright);
}

/* ----- Info dialog ----- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.55);
}

.modal {
    width: min(560px, 100%);
    max-height: 85dvh;
    display: flex;
    flex-direction: column;
    border-radius: 16px;
    background: var(--dark-grey);
    color: var(--white);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

.modal-title { margin: 0; padding: 20px 24px 8px; font-size: 20px; font-weight: 600; }

.modal-body {
    padding: 4px 24px;
    overflow-y: auto;
    font-size: 15px;
    font-weight: 400;
    line-height: 1.5;
    white-space: normal;
    text-align: left;
}

.modal-body a { color: var(--prime-bright); }
.modal-actions { display: flex; justify-content: flex-end; padding: 12px 16px 16px; }

.btn-text {
    padding: 8px 16px;
    background: none;
    border: none;
    border-radius: 8px;
    color: var(--prime);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

.btn-text:hover { background: color-mix(in srgb, var(--prime) 12%, transparent); }

/* ----- Toast (snackbar) ----- */
.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    z-index: 90;
    transform: translateX(-50%);
    width: max-content;
    max-width: calc(100vw - 32px);
    padding: 12px 20px;
    border-radius: 10px;
    background: var(--dark-grey);
    color: var(--prime-bright);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
    animation: toast-in 0.2s ease-out;
}

.toast-title { font-weight: 700; }
.toast-message { font-weight: 400; }

@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ----- Menu drawer ----- */
.drawer-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, 0.45); }

.drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 61;
    width: min(320px, 85vw);
    padding: 16px 20px 24px;
    background: var(--dark-grey);
    color: var(--white);
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.4);
    transform: translateX(100%);
    transition: transform 0.2s ease-out;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.drawer.open { transform: translateX(0); }
.drawer-header { display: flex; align-items: center; justify-content: space-between; }
.drawer-logo { width: 48px; height: 48px; }
.drawer-field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--grey); }

.drawer-field select {
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid color-mix(in srgb, var(--prime) 40%, transparent);
    background: var(--sec);
    color: var(--white);
    font-size: 15px;
}

.drawer-field input[type="text"] {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid color-mix(in srgb, var(--prime) 40%, transparent);
    background: var(--sec);
    color: var(--white);
    font-size: 15px;
    font-family: ui-monospace, Consolas, monospace;
}

.drawer-field input[type="text"]:focus { outline: none; border-color: var(--prime-bright); }
.drawer-inline { display: flex; gap: 8px; }

.drawer-apply {
    width: 44px;
    border: none;
    border-radius: 10px;
    background: var(--prime-bright);
    color: var(--black);
    font-size: 16px;
    cursor: pointer;
}

.drawer-apply:disabled { opacity: 0.35; cursor: default; }
.drawer-hint { font-size: 12px; color: var(--grey); font-weight: 400; }
.drawer-error { font-size: 12px; color: #ff8a80; font-weight: 500; }

.drawer-links { margin-top: auto; font-size: 14px; }
.drawer-links a { color: var(--prime); text-decoration: none; }

/* ----- Blazor error bar ----- */
#blazor-error-ui {
    display: none;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 1000;
    padding: 12px 16px;
    background: #ffe5e5;
    color: #222;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
}

#blazor-error-ui .dismiss { position: absolute; right: 12px; top: 10px; cursor: pointer; }

/* ----- Desktop (the app switches layout above 750px) ----- */
@media (min-width: 750px) {
    .icon-btn.back { width: 72px; height: 72px; border-width: 3px; font-size: 40px; }
    .icon-btn.menu { font-size: 32px; }
    .topbar-logo { width: 56px; height: 56px; }

    .home { padding: 32px 8px 220px; }
    .home-title { font-size: 30px; }
    .home-divider { margin: 32px 0; }
    .home-text { font-size: 20px; }
    .home-cta { font-size: 22px; padding: 16px; }
    .home-cta.primary { font-size: 24px; }
    .profile { margin-top: 36px; padding: 20px 24px; }
    .profile-name { font-size: 20px; }
    .profile-details, .badge { font-size: 15px; }
    .device-title { font-size: 34px; }
    .device-text { font-size: 18px; }
    .quick-title { font-size: 30px; }
    .quick-option { font-size: 20px; }
    .quick-option i { font-size: 20px; }
    .home-glow { width: 380px; height: 380px; }
    .home-logo-float img { width: 130px; height: 130px; }

    .progress { margin: 32px 0 24px; }
    .progress-number { width: 70px; height: 70px; margin: 0 8px; border-width: 4px; font-size: 30px; }
    .progress-line span { width: 8px; height: 4px; }
    .progress-line span.gap { width: 4px; }

    .step-title { font-size: 36px; }
    .step-subtitle { font-size: 22px; }
    .options-title { font-size: 22px; }

    .grid.cols-3-desktop { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .grid.themes { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .grid-item { min-height: 150px; }
    .grid-icon { font-size: 28px; }
    .grid-label { font-size: 16px; }
    .theme-name { font-size: 16px; }

    .player-title { font-size: 40px; }
    .player-divider { width: 250px; margin: 24px auto 40px; }
    .player-slider { padding: 0 24px; }
    .time-current { font-size: 52px; }
    .time-total { font-size: 20px; }
    input[type="range"].seek { margin-top: 18px; }
    input[type="range"].seek::-webkit-slider-runnable-track { height: 6px; }
    input[type="range"].seek::-webkit-slider-thumb { width: 28px; height: 28px; margin-top: -11px; }

    .sub-player { margin-top: 36px; }
    .sub-title { width: 544px; font-size: 20px; }
    .sub-row { gap: 16px; }
    .vol { width: 500px; }
    .vol-btn { font-size: 32px; width: 40px; }
    input[type="range"].vol::-webkit-slider-thumb { width: 28px; height: 28px; margin-top: -12px; }
    .download { width: 500px; height: 60px; }
    .download-text { font-size: 30px; line-height: 60px; }

    .play-row { margin-top: 40px; }
    .play-btn { font-size: 80px; }
    .loop-note { font-size: 16px; }
}

@media (max-width: 499px) {
    .grid-label { font-size: 15px; }
    .theme-name { font-size: 13px; }
}
