:root {
    --bg: #07101a;
    --panel: #0d1926;
    --panel-2: #132233;
    --panel-3: #183048;
    --border: rgba(164, 196, 232, 0.14);
    --text: #f3f7fd;
    --muted: #95abc4;
    --accent: #6cb3ff;
    --accent-2: #c5ffd8;
    --danger: #ff9090;
    --shadow: 0 14px 50px rgba(0, 0, 0, 0.34);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background: radial-gradient(circle at top, #0e1c2d 0%, #07101a 54%, #050b12 100%);
    color: var(--text);
    font-family: Inter, system-ui, Arial, sans-serif;
}

body {
    overflow: hidden;
}

body.menu-open {
    overflow: hidden;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    border: 1px solid var(--border);
    background: linear-gradient(180deg, #8ec7ff, #6cb3ff);
    color: #06101a;
    border-radius: 12px;
    padding: 0.72rem 0.95rem;
    cursor: pointer;
    font-weight: 700;
    transition: transform 0.12s ease, filter 0.12s ease, background 0.12s ease;
}

button:hover {
    filter: brightness(1.03);
}

button:active {
    transform: translateY(1px);
}

button.secondary,
.icon-btn {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
}

button.danger-btn {
    background: rgba(255, 112, 112, 0.12);
    color: #ffd2d2;
    border-color: rgba(255, 112, 112, 0.3);
}

input,
select,
textarea {
    width: 100%;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(4, 10, 16, 0.78);
    color: var(--text);
    padding: 0.8rem 0.9rem;
}

textarea {
    resize: vertical;
}

h1,
h2,
h3,
h4,
p {
    margin-top: 0;
}

.eyebrow {
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.76rem;
    margin-bottom: 0.35rem;
}

.meta-line,
.subtle-line {
    color: var(--muted);
}

.top-gap {
    margin-top: 1rem;
}

.app-shell {
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.topbar {
    position: relative;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem 1rem;
    backdrop-filter: blur(14px);
    background: rgba(5, 11, 18, 0.74);
    border-bottom: 1px solid var(--border);
}

.topbar-left,
.topbar-right,
.song-head-actions,
.button-row,
.control-group,
.option-row,
.inline-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.topbar-title {
    font-weight: 700;
}

.stage-shell {
    flex: 1;
    min-height: 0;
    padding: 0 1rem 1rem;
    overflow: hidden;
}

.panel-flat {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
}

.song-head {
    padding: 1rem;
    margin-bottom: 0.85rem;
}

.song-head-main {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.song-head h2 {
    margin-bottom: 0.3rem;
}

.stage-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
    margin-top: 0.9rem;
}

.control-group {
    padding: 0.35rem;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.value-pill {
    min-width: 5.5rem;
    text-align: center;
    color: var(--muted);
    font-weight: 700;
}

.song-stage-scroll {
    height: 100%;
    overflow: auto;
    border-radius: 0;
    background: transparent;
    border: 0;
    padding: 1rem 0 5rem;
    box-shadow: none;
}

.song-body {
    --song-font-size: 1.95rem;
    --song-chord-size: 0.74em;
    --song-zoom: 1;
    transform: scale(var(--song-zoom));
    transform-origin: top left;
    width: max-content;
    min-width: 100%;
    padding-right: 8rem;
    display: flex;
    flex-direction: column;
    gap: 0.03rem;
}

.song-body.player-mode {
    font-size: var(--song-font-size);
}

.song-body.singer-mode {
    font-size: var(--song-font-size);
}

.song-line {
    display: block;
    width: max-content;
    min-width: 100%;
    padding: 0.08rem 0.28rem 0.1rem;
    border-radius: 12px;
    cursor: pointer;
    white-space: nowrap;
}

.song-line:hover {
    background: rgba(255, 255, 255, 0.04);
}

.song-line.active-line {
    background: rgba(108, 179, 255, 0.18);
    outline: 1px solid rgba(108, 179, 255, 0.45);
}

.song-line.section-line {
    margin-top: 0.4rem;
    padding-top: 0.4rem;
}

.song-line.section-line .lyric {
    color: var(--accent);
    font-weight: 800;
}

.song-line.meta-line .lyric {
    color: var(--muted);
    font-size: 0.78em;
}

.song-line.preview-disabled,
.song-line.lyric-only {
    cursor: default;
}

.segment {
    display: inline-grid;
    grid-template-rows: auto auto;
    align-items: start;
    justify-items: start;
    min-width: 1ch;
    margin-right: 0.02rem;
    vertical-align: top;
    pointer-events: none;
}

.chord,
.lyric {
    pointer-events: none;
}

.chord {
    color: var(--accent-2);
    font-size: var(--song-chord-size);
    font-weight: 800;
    line-height: 0.92;
    min-height: 0.9em;
    margin-bottom: -0.01em;
}

.lyric {
    white-space: pre;
    line-height: 1.02;
}

.segment-gap .lyric {
    opacity: 0;
}

.song-line.chord-only-line .segment {
    margin-right: 0.42ch;
}

.song-line.chord-only-line .segment-gap {
    min-width: 1.1ch;
}

.song-body.singer-mode .song-line {
    padding-top: 0.02rem;
    padding-bottom: 0.02rem;
}

.song-body.singer-mode .segment {
    display: inline;
    min-width: 0;
    margin-right: 0;
}

.song-body.singer-mode .lyric {
    line-height: 0.98;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.chip {
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.menu-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
    z-index: 70;
}

body.menu-open .menu-backdrop {
    opacity: 1;
    pointer-events: auto;
}

.menu-drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: min(440px, calc(100vw - 2rem));
    height: 100vh;
    overflow: auto;
    padding: 1rem;
    background: rgba(7, 16, 26, 0.98);
    border-right: 1px solid var(--border);
    transform: translateX(-110%);
    transition: transform 0.18s ease;
    z-index: 80;
    box-shadow: var(--shadow);
}

body.menu-open .menu-drawer {
    transform: translateX(0);
}

.drawer-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.drawer-head h1 {
    margin-bottom: 0;
}

.drawer-section {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 16px;
    margin-bottom: 0.8rem;
    overflow: hidden;
}

.drawer-section > summary {
    list-style: none;
    padding: 0.9rem 1rem;
    cursor: pointer;
    font-weight: 800;
}

.drawer-section > summary::-webkit-details-marker {
    display: none;
}

.drawer-section-body {
    padding: 0 1rem 1rem;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 0.8rem;
}

.compact-stack {
    margin-bottom: 0.6rem;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.7rem;
    color: var(--muted);
}

.checkbox-row input,
.option-row input {
    width: auto;
}

.provider-info,
.list-card,
.empty,
.archive-list,
.preview-body,
.editor-preview,
.live-box {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 14px;
}

.provider-info,
.empty,
.archive-list {
    padding: 0.85rem;
}

.provider-results,
.song-list,
.archive-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.list-card {
    padding: 0.85rem;
}

.list-card h4,
.list-card p {
    margin: 0;
}

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

.list-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.6rem;
}

.result-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    margin-top: 0.4rem;
    color: var(--muted);
    font-size: 0.92rem;
}

.result-preview {
    margin-top: 0.55rem;
    padding: 0.65rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    white-space: pre-wrap;
    line-height: 1.35;
}

.compact-row {
    margin-bottom: 0.5rem;
}

.align-end {
    justify-content: flex-end;
}

.inline-row input {
    flex: 1;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.62);
}

.modal.is-hidden {
    display: none;
}

.modal-card {
    width: min(1180px, 96vw);
    max-height: 94vh;
    overflow: auto;
    background: #0b1623;
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: var(--shadow);
    padding: 1rem;
}

.modal-wide {
    width: min(1100px, 96vw);
}

.modal-editor {
    width: min(1320px, 97vw);
}

.modal-head {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.editor-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.8rem;
}

.editor-grid.small-gap {
    gap: 0.6rem;
}

.span-2 {
    grid-column: span 2;
}

.editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    margin: 1rem 0;
}

.editor-split {
    display: grid;
    grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
    gap: 1rem;
    align-items: start;
}

.editor-column {
    min-width: 0;
}

.editor-textarea {
    min-height: 65vh;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    line-height: 1.24;
    white-space: pre;
}

.preview-body,
.editor-preview {
    padding: 0.75rem;
    min-height: 320px;
}

.table-wrap {
    overflow: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    text-align: left;
    padding: 0.55rem 0.45rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    vertical-align: top;
}

.data-table td input {
    min-width: 120px;
}

.archive-item {
    display: flex;
    justify-content: space-between;
    gap: 0.8rem;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.archive-item:last-child {
    border-bottom: 0;
}

.icon-btn {
    min-width: 44px;
    padding-left: 0.8rem;
    padding-right: 0.8rem;
}

.is-hidden {
    display: none !important;
}

@media (max-width: 1080px) {
    .song-head-main,
    .modal-head,
    .topbar,
    .topbar-left,
    .topbar-right,
    .song-head-actions,
    .stage-controls,
    .inline-row,
    .button-row,
    .option-row,
    .control-group {
        flex-wrap: wrap;
    }

    .editor-grid,
    .editor-split {
        grid-template-columns: 1fr;
    }

    .span-2 {
        grid-column: auto;
    }

    .song-stage-scroll {
        height: auto;
        overflow: visible;
    }
}

@media (max-width: 640px) {
    .stage-shell,
    .topbar,
    .menu-drawer,
    .modal-card {
        padding: 0.8rem;
    }

    .song-body {
        padding-right: 3rem;
    }
}


/* === live focus refinements === */
.control-stack {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.control-group-menu {
    justify-content: space-between;
}

.session-list {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    padding: 0.2rem 0;
}

.session-card {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: center;
    padding: 0.75rem 0.8rem;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.session-card-main {
    min-width: 0;
}

.session-card-title {
    font-weight: 700;
    margin-bottom: 0.18rem;
}

.session-card-meta {
    color: var(--muted);
    font-size: 0.92rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.song-list {
    gap: 0.45rem;
}

.song-card-compact {
    cursor: pointer;
    padding: 0.75rem 0.8rem;
    transition: background 0.15s ease, transform 0.1s ease, border-color 0.15s ease;
}

.song-card-compact:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(108, 179, 255, 0.22);
}

.song-card-compact:active {
    transform: translateY(1px);
}

.song-card-compact h4 {
    margin: 0 0 0.18rem;
    font-size: 1rem;
}

.song-card-compact .muted {
    margin: 0;
    line-height: 1.25;
}

.song-sticky-bar {
    position: sticky;
    top: 0;
    z-index: 6;
    margin-bottom: 0.85rem;
    padding: 0.55rem 0.75rem;
    backdrop-filter: blur(14px);
    background: rgba(11, 22, 35, 0.9);
}

.song-sticky-main {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    justify-content: space-between;
}

.song-sticky-title {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.song-sticky-title strong {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.song-sticky-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    justify-content: flex-end;
}

.control-group-sticky {
    padding: 0.25rem;
    gap: 0.35rem;
}

.control-group-sticky button {
    padding: 0.55rem 0.8rem;
}

.song-body {
    padding-right: 12rem;
    padding-bottom: 3rem;
}

.song-line {
    padding-left: 0.16rem;
    padding-right: 0.16rem;
}

.song-line.chord-only-line .segment {
    margin-right: 0.72ch;
}

.song-line.chord-only-line .segment-gap {
    min-width: 1.8ch;
}

.song-line .segment:last-child .lyric {
    padding-right: 4ch;
}

.song-body.player-mode .chord {
    margin-bottom: 0.1em;
}

.song-body.singer-mode .song-line.section-line .lyric,
.song-body.player-mode .song-line.section-line .lyric {
    font-weight: 800;
}

@media (max-width: 1080px) {
    .song-sticky-main,
    .song-sticky-controls,
    .session-card {
        flex-wrap: wrap;
    }

    .song-body {
        padding-right: 6rem;
    }
}

@media (max-width: 640px) {
    .stage-shell {
        padding: 0 0.8rem 0.8rem;
    }

    .song-stage-scroll {
        padding-top: 0.8rem;
    }

    .song-body {
        padding-right: 3rem;
    }

    .song-sticky-title {
        width: 100%;
    }
}

.readonly-pill button {
    display: none;
}

.readonly-pill {
    padding-left: 0.7rem;
    padding-right: 0.7rem;
}

button:disabled {
    opacity: 0.55;
    cursor: default;
}
