:root {
    color-scheme: dark;
    --bg: #07080d;
    --bg2: #111326;
    --panel: #151829;
    --panel2: #1b2035;
    --line: rgba(255, 255, 255, .12);
    --text: #f6f7ff;
    --muted: #a9b0c6;
    --pink: #ff4fd8;
    --cyan: #39d9ff;
    --blue: #5d7cff;
    --green: #54e29b;
    --red: #ff6b7b;
    --shadow: 0 24px 80px rgba(0, 0, 0, .45);
    --bottom-gap: env(safe-area-inset-bottom, 0px);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--bg);
    overflow-x: hidden;
}

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    color: var(--text);
    font: 16px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(57, 217, 255, .18), transparent 34rem),
        radial-gradient(circle at bottom right, rgba(255, 79, 216, .14), transparent 32rem),
        linear-gradient(135deg, var(--bg), var(--bg2));
    overflow-x: hidden;
}

button, input, textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

.app-shell {
    width: min(100%, 760px);
    max-width: 100vw;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0 auto;
    padding: 18px 16px calc(28px + var(--bottom-gap));
    display: grid;
    align-content: center;
    min-width: 0;
}

.app-shell[data-step="karaokeSearch"] {
    width: min(100%, 900px);
    align-content: start;
}

.text-page {
    align-content: start;
    padding-top: 48px;
}

.panel {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    background: linear-gradient(180deg, rgba(27, 32, 53, .96), rgba(14, 16, 28, .96));
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: var(--shadow);
    padding: clamp(20px, 4vw, 34px);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
    min-width: 0;
}

.brand {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.brand-name {
    font-size: .82rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--cyan);
    font-weight: 800;
}

.progress {
    color: var(--muted);
    font-size: .92rem;
    overflow-wrap: anywhere;
}

.top-actions {
    display: flex;
    gap: 8px;
    flex: 0 0 auto;
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--cyan);
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
    font-size: .82rem;
}

h1 {
    margin: 0 0 10px;
    font-size: clamp(2rem, 9vw, 4.2rem);
    line-height: .98;
    letter-spacing: 0;
    overflow-wrap: anywhere;
}

.step h1 {
    font-size: clamp(1.8rem, 7vw, 3rem);
}

.step-karaokeSearch h1 {
    max-width: 100%;
    font-size: clamp(1.85rem, 5vw, 2.7rem);
    line-height: 1.04;
}

.subtitle {
    color: var(--muted);
    margin: 0 0 22px;
    font-size: 1.05rem;
}

.choice-grid {
    display: grid;
    gap: 14px;
    margin-top: 20px;
}

.choice {
    width: 100%;
    min-height: 72px;
    text-align: left;
    padding: 16px 18px;
    border-radius: 9px;
    border: 1px solid rgba(255, 255, 255, .16);
    color: var(--text);
    background: linear-gradient(135deg, rgba(93, 124, 255, .24), rgba(255, 79, 216, .16));
    box-shadow: 0 0 0 1px rgba(57, 217, 255, .05), 0 16px 42px rgba(0, 0, 0, .26);
}

.choice strong {
    display: block;
    font-size: 1.16rem;
    margin-bottom: 2px;
}

.choice span {
    color: var(--muted);
}

.choice.alt {
    background: linear-gradient(135deg, rgba(57, 217, 255, .2), rgba(93, 124, 255, .14));
}

.button-row {
    display: flex;
    gap: 10px;
    margin-top: 22px;
    flex-wrap: wrap;
}

.button, .ghost {
    min-height: 54px;
    border-radius: 8px;
    padding: 13px 16px;
    border: 1px solid var(--line);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--text);
    background: rgba(255, 255, 255, .06);
}

.primary {
    background: linear-gradient(135deg, var(--cyan), var(--blue));
    border-color: transparent;
    color: #050711;
    font-weight: 850;
}

.danger {
    background: rgba(255, 107, 123, .13);
    color: #ffd4da;
}

.full {
    width: 100%;
}

.field-stack {
    display: grid;
    gap: 16px;
}

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-weight: 700;
    min-width: 0;
}

input, textarea {
    width: 100%;
    min-height: 54px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, .08);
    color: var(--text);
    padding: 13px 14px;
    font-size: 16px;
    outline: none;
    min-width: 0;
}

textarea {
    min-height: 112px;
    resize: vertical;
}

input:focus, textarea:focus, button:focus-visible, a:focus-visible {
    outline: 3px solid rgba(57, 217, 255, .55);
    outline-offset: 2px;
}

.error {
    color: #ffd0d7;
    background: rgba(255, 107, 123, .13);
    border: 1px solid rgba(255, 107, 123, .35);
    padding: 10px 12px;
    border-radius: 8px;
    margin: 12px 0 0;
}

.review {
    display: grid;
    gap: 10px;
    margin-top: 18px;
}

.review-row, .result-card {
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, .06);
    border-radius: 8px;
    padding: 13px 14px;
}

.review-row span {
    display: block;
    color: var(--muted);
    font-size: .86rem;
    margin-bottom: 2px;
}

.search-meta {
    margin: 14px 0 10px;
    min-height: 24px;
    color: var(--muted);
}

.results {
    display: grid;
    gap: 10px;
    margin-top: 10px;
    min-width: 0;
}

.result-card {
    width: 100%;
    min-width: 0;
    color: var(--text);
    text-align: left;
    min-height: 72px;
    display: grid;
    align-content: center;
    gap: 4px;
    overflow: hidden;
}

.result-card strong {
    display: block;
    font-size: 1.05rem;
    line-height: 1.22;
    white-space: normal;
    overflow-wrap: anywhere;
}

.result-card span {
    color: var(--muted);
    line-height: 1.25;
    white-space: normal;
    overflow-wrap: anywhere;
}

.az {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
    gap: 8px;
    min-width: 0;
    padding: 4px 0 8px;
    margin-top: 12px;
}

.az button {
    width: 100%;
    min-width: 0;
    min-height: 42px;
    border-radius: 7px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, .06);
    color: var(--text);
}

.az button.active {
    background: var(--cyan);
    color: #051018;
    font-weight: 850;
}

.toast {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: calc(18px + var(--bottom-gap));
    z-index: 50;
    max-width: 720px;
    margin: 0 auto;
    padding: 13px 14px;
    border-radius: 8px;
    background: rgba(255, 107, 123, .95);
    color: #170208;
    font-weight: 800;
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transform: translateY(12px);
    transition: .2s ease;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .68);
    display: grid;
    place-items: center;
    z-index: 80;
    padding: 18px;
}

.modal {
    width: min(100%, 420px);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.hidden {
    display: none !important;
}

@media (max-width: 520px) {
    .app-shell {
        align-content: stretch;
        padding: 10px 10px calc(18px + var(--bottom-gap));
    }
    .panel {
        min-height: calc(100dvh - 36px - var(--bottom-gap));
        display: flex;
        flex-direction: column;
        justify-content: center;
        padding: 18px;
    }
    .app-shell[data-step="karaokeSearch"] .panel {
        min-height: calc(100dvh - 20px - var(--bottom-gap));
        justify-content: flex-start;
    }
    .topbar {
        align-items: flex-start;
        display: grid;
        grid-template-columns: 1fr;
    }
    .top-actions {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
    .top-actions .ghost {
        min-height: 44px;
    }
    .step-karaokeSearch h1 {
        max-width: 12ch;
        font-size: clamp(1.72rem, 9vw, 2.22rem);
    }
    .az {
        display: flex;
        gap: 6px;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        scrollbar-width: none;
        padding: 2px 0 8px;
        margin-top: 10px;
        scroll-snap-type: x proximity;
    }
    .az::-webkit-scrollbar {
        display: none;
    }
    .az button {
        flex: 0 0 38px;
        width: 38px;
        min-height: 36px;
        padding-inline: 4px;
        scroll-snap-align: start;
    }
    .az button[data-letter="0"] {
        flex-basis: 46px;
        width: 46px;
    }
    .result-card {
        min-height: 74px;
        padding: 13px 14px;
    }
    .button-row {
        display: grid;
    }
    .button-row .button, .button-row .ghost {
        width: 100%;
    }
}
