/*
 * Modern theme for Abundant Music.
 * Sits on top of jQuery UI: every rule is prefixed with "body" so it wins over
 * whichever jQuery UI theme is loaded, without touching the JavaScript.
 */

:root {
    --bg: #07080d;
    --surface: rgba(18, 20, 31, 0.86);
    --surface-solid: #12141f;
    --surface-2: #1a1d2c;
    --surface-3: #232739;
    --border: rgba(255, 255, 255, 0.09);
    --border-strong: rgba(255, 255, 255, 0.18);
    --text: #e8eaf4;
    --text-dim: #9aa0b8;
    --accent: #8b7cff;
    --accent-2: #2fd6d0;
    --accent-grad: linear-gradient(135deg, #8b7cff 0%, #2fd6d0 100%);
    --danger: #ff6b81;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.4);
    --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

html {
    background: var(--bg);
    color-scheme: dark;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    -webkit-font-smoothing: antialiased;
}

body a { color: var(--accent-2); }
body a:hover { color: #fff; }

/* ---- Loading screen ---------------------------------------------------- */
body #hider-div {
    background: radial-gradient(ellipse at 50% 30%, #1a1633 0%, var(--bg) 70%) !important;
    color: var(--text);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    font-family: var(--font);
    letter-spacing: 0.04em;
}
body #hider-div p { color: var(--text-dim); margin: 0 0 18px; }
body #loader-progress { width: min(280px, 70vw) !important; height: 6px !important; }

/* ---- Top bar ------------------------------------------------------------ */
body #componentsdiv {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0;
    z-index: 990;
    box-sizing: border-box;
    padding: 10px 16px;
    background: linear-gradient(180deg, rgba(7, 8, 13, 0.92), rgba(7, 8, 13, 0.55));
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
}
body #buttonsDiv {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}
body #buttonsDiv::before {
    content: "Abundant Music";
    margin-right: 14px;
    font-weight: 700;
    font-size: 1.05em;
    letter-spacing: 0.02em;
    background: var(--accent-grad);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
body #progressdiv { margin-top: 6px; }

body .toggle-button,
body .toggle-button.ui-state-default {
    margin: 0;
}
body .toggle-button.ui-button.ui-state-default,
body .toggle-button.ui-button,
body .toggle-button.ui-widget {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-dim);
    border-radius: 999px;
    box-shadow: none;
    text-shadow: none;
}
body .toggle-button .ui-button-text { padding: 0.45em 0.95em; font-size: 0.9em; font-weight: 500; }
body .toggle-button.ui-button.ui-state-hover,
body .toggle-button.ui-button:hover { background: var(--surface-3); color: var(--text); }
body .toggle-button.ui-button.ui-state-active,
body .toggle-button.ui-button.ui-state-default.ui-state-active {
    background: rgba(139, 124, 255, 0.18);
    border-color: rgba(139, 124, 255, 0.55);
    color: #fff;
}

/* ---- Buttons ------------------------------------------------------------ */
body .ui-button,
body .ui-widget button,
body button.ui-button {
    font-family: var(--font);
}
body .ui-button.ui-state-default,
body .ui-widget-content .ui-state-default,
body .ui-widget-header .ui-state-default {
    background: var(--surface-3);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius-sm);
    font-weight: 500;
    text-shadow: none;
    box-shadow: none;
    background-image: none;
    transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
body .ui-button.ui-state-hover,
body .ui-button.ui-state-focus,
body .ui-state-hover {
    background: #2d3250;
    border-color: var(--border-strong);
    color: #fff;
    background-image: none;
}
body .ui-button:active:not(.toggle-button),
body .ui-button.ui-state-active:not(.toggle-button) {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
body .ui-button.ui-state-disabled,
body .ui-state-disabled { opacity: 0.4; }
body .ui-button .ui-icon { filter: invert(1) brightness(1.4); }

/* ---- Windows (dialogs) ---------------------------------------------------- */
body .ui-dialog.ui-widget {
    background: var(--surface);
    backdrop-filter: blur(18px) saturate(140%);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 0;
    overflow: hidden;
    color: var(--text);
}
body .ui-dialog .ui-dialog-titlebar {
    background: rgba(255, 255, 255, 0.04);
    border: 0;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    padding: 0.65em 1em;
    cursor: grab;
}
body .ui-dialog .ui-dialog-title {
    color: var(--text);
    font-weight: 600;
    font-size: 0.92em;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}
body .ui-dialog .ui-dialog-titlebar-close {
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: 6px;
    right: 0.7em;
    margin-top: -10px;
    height: 20px;
    width: 20px;
}
body .ui-dialog .ui-dialog-titlebar-close,
body .ui-dialog .ui-dialog-titlebar-close.ui-state-focus,
body .ui-dialog .ui-dialog-titlebar-close.ui-state-active {
    background: var(--surface-3);
    border-color: var(--border);
    outline: none;
}
body .ui-dialog .ui-dialog-titlebar-close:hover { background: var(--accent); }
body .ui-dialog .ui-dialog-titlebar-close .ui-icon { filter: invert(1); }
body .ui-dialog .ui-dialog-content,
body .ui-dialog .ui-dialog-content.ui-widget-content {
    background: transparent;
    color: var(--text);
    padding: 1em 1.1em;
}
body .ui-dialog .ui-dialog-buttonpane {
    background: rgba(255, 255, 255, 0.03);
    border-top: 1px solid var(--border);
}
body .ui-widget-overlay { background: #000; opacity: 0.6; }

body .ui-widget,
body .ui-widget .ui-widget {
    font-family: var(--font);
    font-size: 1em;
}
body .ui-widget-content {
    background: transparent;
    color: var(--text);
    border-color: var(--border);
}
body .ui-widget-header {
    background: transparent;
    color: var(--text);
    border-color: var(--border);
}
body .ui-widget-content a { color: var(--accent-2); }
body .ui-corner-all { border-radius: var(--radius-sm); }

/* ---- Tabs ----------------------------------------------------------------- */
body .ui-tabs {
    background: transparent;
    border: 0;
    padding: 0;
}
body .ui-tabs .ui-tabs-nav {
    background: var(--surface-solid);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 4px;
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
}
body .ui-tabs .ui-tabs-nav li {
    background: transparent;
    border: 0;
    border-radius: 7px;
    margin: 0;
    top: 0;
    float: none;
}
body .ui-tabs .ui-tabs-nav li a {
    color: var(--text-dim);
    padding: 0.45em 0.9em;
    font-size: 0.88em;
    font-weight: 500;
    outline: none;
}
body .ui-tabs .ui-tabs-nav li:hover a { color: var(--text); }
body .ui-tabs .ui-tabs-nav li.ui-tabs-active,
body .ui-tabs .ui-tabs-nav li.ui-state-active {
    background: var(--surface-3);
    box-shadow: inset 0 -2px 0 var(--accent);
}
body .ui-tabs .ui-tabs-nav li.ui-tabs-active a { color: #fff; }
body .ui-tabs .ui-tabs-panel {
    background: transparent;
    padding: 1em 0.2em 0.2em;
}

/* ---- Form controls ---------------------------------------------------------- */
body input[type="text"],
body input[type="number"],
body input[type="password"],
body input:not([type]),
body textarea,
body select,
body .ui-spinner-input,
body .ui-autocomplete-input {
    background: var(--surface-solid);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    padding: 0.3em 0.5em;
    font-family: var(--font);
    font-size: 0.95em;
    outline: none;
}
body input[type="text"]:focus,
body input[type="number"]:focus,
body textarea:focus,
body select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(139, 124, 255, 0.25);
}
body select option { background: var(--surface-solid); color: var(--text); }
body input[type="checkbox"],
body input[type="radio"] { accent-color: var(--accent); }
body label { color: var(--text); }

body .ui-spinner { border-radius: 6px; border: 1px solid var(--border-strong); background: var(--surface-solid); }
body .ui-spinner .ui-spinner-input { border: 0; box-shadow: none; }
body .ui-spinner-button { background: var(--surface-3); border: 0; color: var(--text); }

/* ---- Sliders & progress ------------------------------------------------------- */
body .ui-slider {
    background: var(--surface-3);
    border: 0;
    border-radius: 999px;
}
body .ui-slider-horizontal { height: 6px; }
body .ui-slider .ui-slider-range { background: var(--accent-grad); border-radius: 999px; }
body .ui-slider .ui-slider-handle {
    background: #fff;
    border: 0;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    top: -5px;
    margin-left: -8px;
    box-shadow: 0 0 0 3px rgba(139, 124, 255, 0.45), 0 2px 6px rgba(0, 0, 0, 0.5);
    outline: none;
}
body .ui-progressbar {
    background: var(--surface-3);
    border: 0;
    border-radius: 999px;
    overflow: hidden;
}
body .ui-progressbar .ui-progressbar-value {
    background: var(--accent-grad);
    border: 0;
    border-radius: 999px;
}

/* ---- Lists, tables, selection ------------------------------------------------------ */
body .ui-selecting { background: rgba(139, 124, 255, 0.35); }
body .ui-selected { background: var(--accent); color: #fff; }
body .object-list-item,
body .gui-property-component { color: var(--text); }
body .object-list-panel {
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
body .vertical-list-item-drag-handle { color: var(--text-dim); }
body .oddTableRow { background: rgba(255, 255, 255, 0.025); }
body .evenTableRow { background: rgba(255, 255, 255, 0.06); }
body table { color: var(--text); }
body .ui-state-highlight, body .ui-state-error { border-radius: var(--radius-sm); }
body .ui-state-highlight { background: rgba(47, 214, 208, 0.12); border-color: rgba(47, 214, 208, 0.4); color: var(--text); }
body .ui-state-error { background: rgba(255, 107, 129, 0.12); border-color: rgba(255, 107, 129, 0.5); color: var(--text); }
body .ui-tooltip { background: var(--surface-solid); color: var(--text); border: 1px solid var(--border-strong); border-radius: 6px; box-shadow: var(--shadow); }

/* ---- Player transport ---------------------------------------------------------------- */
body #watoolbar {
    display: inline-flex;
    gap: 6px;
    padding: 8px !important;
    background: var(--surface-solid);
    border: 1px solid var(--border);
    border-radius: 999px;
}
body #watoolbar button.ui-button { border-radius: 50%; width: 38px; height: 38px; margin: 0; }
body #waplaybutton.ui-button { background: var(--accent-grad); border: 0; width: 46px; height: 38px; border-radius: 999px; }

/* ---- Scrollbars ------------------------------------------------------------------------ */
body * { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
body *::-webkit-scrollbar { width: 10px; height: 10px; }
body *::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }

/* ---- Docked layout (see js/layout.js) -------------------------------------------------- */
body #dock {
    position: fixed;
    top: 56px;
    right: 0;
    bottom: 0;
    width: min(520px, 42vw);
    z-index: 980;
    box-sizing: border-box;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--surface-solid);
    border-left: 1px solid var(--border);
    box-shadow: -12px 0 40px rgba(0, 0, 0, 0.35);
}
body #dock.dock-empty { display: none; }

body #dock .ui-dialog.docked {
    position: static !important;
    width: auto !important;
    height: auto !important;
    top: auto !important;
    left: auto !important;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    opacity: 1 !important;
    overflow: visible;
}
body #dock .ui-dialog.docked .ui-dialog-titlebar {
    position: sticky;
    top: 0;
    z-index: 5;
    cursor: default;
    background: var(--surface-solid);
    padding: 0.9em 1.1em;
}
body #dock .ui-dialog.docked .ui-dialog-content {
    max-height: none !important;
    width: auto !important;
    opacity: 1 !important;
    overflow: visible;
}
body #dock .ui-dialog.docked .ui-dialog-title { font-size: 0.85em; color: var(--text-dim); }

/* Settings panels were designed for wide windows: let rows wrap instead of overflowing */
body #dock .ui-dialog.docked .gui-property-component,
body #dock .ui-dialog.docked .ui-tabs-panel { max-width: 100%; }
body #dock .ui-dialog.docked table { max-width: 100%; }
body #dock .ui-dialog.docked input[type="text"],
body #dock .ui-dialog.docked select { max-width: 100%; box-sizing: border-box; }

/* Transport lives in the top bar */
body #buttonsDiv #watoolbar.transport { margin-left: auto; }

/* Narrow screens: panels become a bottom sheet */
@media (max-width: 800px) {
    body #dock {
        top: auto !important;
        left: 0;
        width: auto;
        height: 58vh;
        border-left: 0;
        border-top: 1px solid var(--border-strong);
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.5);
    }
    body #buttonsDiv { overflow-x: auto; flex-wrap: nowrap; }
    body #buttonsDiv::before { display: none; }
}

body #buttonsDiv #watoolbar.transport { font-size: 12px; padding: 4px !important; gap: 4px; }
body #buttonsDiv #watoolbar.transport button.ui-button { width: 30px; height: 30px; }
body #buttonsDiv #watoolbar.transport #waplaybutton.ui-button { width: 40px; height: 30px; }

/* ---- Polish pass -------------------------------------------------------------------------- */

/* The old script scaled text with window size, which made it tiny on small screens */
body { font-size: clamp(13px, calc(1.5vmin + 5px), 17px) !important; }

/* Readable close button */
body .ui-dialog .ui-dialog-titlebar-close { font-size: 0; display: block; }
body .ui-dialog .ui-dialog-titlebar-close .ui-icon { display: none; }
body .ui-dialog .ui-dialog-titlebar-close::before {
    content: "\2715";
    font-size: 11px;
    line-height: 20px;
    display: block;
    text-align: center;
    color: var(--text);
}

body .toggle-button { white-space: nowrap; }
body #dock ul.song-list,
body #dock ul.preset-list { padding-left: 0.5em; margin: 0.5em 0; }
body #dock ul.song-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5em 1em; padding: 0.35em 0; }

@media (max-width: 800px) {
    body #componentsdiv { padding: 8px 10px; }
    body #buttonsDiv {
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
        padding-bottom: 2px;
    }
    body #buttonsDiv::-webkit-scrollbar { display: none; }
    body #buttonsDiv > * { flex: 0 0 auto; }
    body #buttonsDiv #watoolbar.transport {
        order: -2;
        margin-left: 0;
        position: sticky;
        left: 0;
        z-index: 3;
    }
    body #buttonsDiv > button { order: -1; }
    body #dock { height: 55vh; }
}

/* ---- Random button ------------------------------------------------------------------------ */
body #randomsongbutton {
    display: inline-flex;
    align-items: center;
    gap: 0.55em;
    margin-left: auto;
    padding: 0.55em 1.5em;
    font-family: var(--font);
    font-size: 1.25em;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #fff;
    background: var(--accent-grad);
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 6px 22px rgba(139, 124, 255, 0.45);
    transition: transform 0.12s, box-shadow 0.12s, filter 0.12s;
    white-space: nowrap;
}
body #randomsongbutton:hover { transform: translateY(-1px) scale(1.03); box-shadow: 0 10px 28px rgba(47, 214, 208, 0.45); }
body #randomsongbutton:active { transform: scale(0.97); }
body #randomsongbutton:disabled { cursor: progress; filter: saturate(0.6) brightness(0.85); transform: none; }
body #randomsongbutton .random-icon { font-size: 1.15em; line-height: 1; }
body #randomsongbutton.busy .random-icon { display: inline-block; animation: random-spin 0.9s linear infinite; }
@keyframes random-spin { to { transform: rotate(360deg); } }

body #buttonsDiv #watoolbar.transport { margin-left: 8px; }

@media (max-width: 800px) {
    body #buttonsDiv #randomsongbutton { order: -3; margin-left: 0; font-size: 1.1em; padding: 0.45em 1.1em; }
    body #buttonsDiv #watoolbar.transport { margin-left: 0; }
}

/* ---- Style picker ------------------------------------------------------------------------- */
body #stylepicker {
    appearance: none;
    -webkit-appearance: none;
    padding: 0.6em 2.2em 0.6em 1.1em;
    font-family: var(--font);
    font-size: 1em;
    font-weight: 600;
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    background-color: var(--surface-3);
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1.5l5 5 5-5' fill='none' stroke='%23e8eaf4' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/></svg>");
    background-repeat: no-repeat;
    background-position: right 0.95em center;
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s;
}
body #stylepicker:hover { border-color: var(--accent); background-color: #2d3250; }
body #stylepicker:focus-visible { box-shadow: 0 0 0 3px rgba(139, 124, 255, 0.35); outline: none; }
body #stylepicker:disabled { opacity: 0.5; cursor: progress; }

@media (max-width: 800px) {
    body #buttonsDiv #stylepicker { order: -3; }
}

/* ---- Sound loading status ----------------------------------------------------------------- */
body #sound-status {
    position: fixed;
    left: 50%;
    bottom: 18px;
    transform: translate(-50%, 20px);
    z-index: 1200;
    padding: 0.6em 1.2em;
    border-radius: 999px;
    background: var(--surface-solid);
    border: 1px solid var(--border-strong);
    color: var(--text);
    font-size: 0.9em;
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
}
body #sound-status.visible { opacity: 1; transform: translate(-50%, 0); }

/* ---- Simple / Advanced / Expert settings (js/settingsmodes.js) ------------------------------------ */
body #settings-modes { margin: 0 0 1em; }
body .mode-switcher {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--surface-solid);
    border: 1px solid var(--border);
    border-radius: 999px;
}
body .mode-tab {
    flex: 1;
    padding: 0.5em 0.8em;
    font-family: var(--font);
    font-size: 0.92em;
    font-weight: 600;
    color: var(--text-dim);
    background: transparent;
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
body .mode-tab:hover { color: var(--text); background: var(--surface-3); }
body .mode-tab.active { color: #fff; background: var(--accent-grad); box-shadow: 0 4px 14px rgba(139, 124, 255, 0.35); }
body .mode-description { margin: 0.6em 0.4em 0; font-size: 0.85em; color: var(--text-dim); }

body .mode-view { padding: 0.4em 0.2em 1em; }
body .mode-lead { color: var(--text-dim); font-size: 0.9em; line-height: 1.5; margin: 0.4em 0 0.8em; }
body .mode-subtitle {
    margin: 1.4em 0 0.2em;
    font-size: 0.78em;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent-2);
}
body .mode-row { padding: 0.75em 0; border-bottom: 1px solid var(--border); }
body .mode-row:last-child { border-bottom: 0; }
body .mode-row-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1em; }
body .mode-label { font-weight: 600; }
body .mode-value { font-size: 0.85em; color: var(--accent-2); text-align: right; white-space: nowrap; }
body .mode-control { margin: 0.8em 0.5em 0.3em; }
body .mode-hint { font-size: 0.82em; line-height: 1.45; color: var(--text-dim); margin-top: 0.4em; }
body .mode-intro { margin: 0 0 0.3em; }

body .mode-slider.ui-slider { margin: 0.4em 0; }

body .mode-number { width: 8em; }

/* On/off switch */
body .mode-switch { position: relative; display: inline-block; width: 42px; height: 24px; margin: 0; }
body .mode-switch input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
body .mode-switch-track {
    position: absolute;
    inset: 0;
    background: var(--surface-3);
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    transition: background 0.15s;
}
body .mode-switch-track::after {
    content: "";
    position: absolute;
    top: 2px; left: 2px;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.15s;
}
body .mode-switch input:checked + .mode-switch-track { background: var(--accent); border-color: var(--accent); }
body .mode-switch input:checked + .mode-switch-track::after { transform: translateX(18px); }
body .mode-switch input:focus-visible + .mode-switch-track { box-shadow: 0 0 0 3px rgba(139, 124, 255, 0.35); }

/* Collapsible groups in Advanced */
body .mode-group {
    margin: 0 0 0.6em;
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
body .mode-group > summary {
    padding: 0.8em 1em;
    cursor: pointer;
    font-weight: 600;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
body .mode-group > summary::-webkit-details-marker { display: none; }
body .mode-group > summary::after { content: "+"; font-size: 1.2em; color: var(--text-dim); }
body .mode-group[open] > summary::after { content: "\2212"; }
body .mode-group[open] > summary { border-bottom: 1px solid var(--border); }
body .mode-group-body { padding: 0 1em 0.4em; }

/* Song number and buttons */
body .mode-seed-row { display: flex; gap: 0.6em; margin: 0.6em 0.2em 0; }
body .mode-seed { flex: 1; min-width: 0; font-variant-numeric: tabular-nums; }
body .mode-button {
    padding: 0.5em 1em;
    font-family: var(--font);
    font-weight: 600;
    color: var(--text);
    background: var(--surface-3);
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    cursor: pointer;
}
body .mode-button:hover { background: #2d3250; border-color: var(--accent); }
body .mode-reset-row { margin: 1.4em 0.2em 0; }

/* ---- Song Info overview (js/songinfo.js) ---------------------------------------------------------- */
body #songinfo-overview {
    --si-intro: #5b6b8c;
    --si-verse: #2fd6d0;
    --si-chorus: #8b7cff;
    --si-bridge: #ff9f5a;
    --si-extra: #f2d45c;
    --si-connect: #4a5470;
    --si-end: #7a8aa8;
    margin-bottom: 1em;
}
body .si-technical { margin-top: 1.2em; }

body .si-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(7.5em, 1fr)); gap: 0.5em; margin: 0.4em 0 1.2em; }
body .si-fact { padding: 0.6em 0.8em; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--border); border-radius: var(--radius-sm); }
body .si-fact-label { display: block; font-size: 0.72em; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-dim); }
body .si-fact-value { display: block; margin-top: 0.15em; font-weight: 700; }

body .si-grid { display: flex; align-items: stretch; gap: 0.7em; }
body .si-labels { flex: 0 0 4.6em; display: flex; flex-direction: column; gap: 6px; }
body .si-tracks { flex: 1; min-width: 0; position: relative; display: flex; flex-direction: column; gap: 6px; cursor: pointer; }
body .si-label { height: 30px; box-sizing: border-box; display: flex; align-items: center; font-size: 0.8em; color: var(--text-dim); }
body .si-row { position: relative; height: 30px; box-sizing: border-box; background: rgba(255, 255, 255, 0.03); border-radius: 6px; overflow: hidden; }
body .si-label.si-structure, body .si-row.si-structure { height: 40px; }
body .si-label.si-intensity, body .si-row.si-intensity { height: 44px; }

body .si-block, body .si-segment, body .si-bar { position: absolute; top: 0; bottom: 0; box-sizing: border-box; }
body .si-block {
    border-left: 2px solid var(--bg);
    display: flex; align-items: center; padding: 0 0.5em; overflow: hidden;
    color: #0b0d14; font-weight: 700; font-size: 0.78em; white-space: nowrap;
    transition: filter 0.15s, box-shadow 0.15s;
}
body .si-block:first-child { border-left: 0; }
body .si-block-text { overflow: hidden; text-overflow: ellipsis; }
body .si-block.si-current { filter: brightness(1.15); box-shadow: inset 0 -3px 0 #fff; }

body .si-intro, body .si-swatch.si-intro { background: var(--si-intro); }
body .si-verse, body .si-swatch.si-verse { background: var(--si-verse); }
body .si-chorus, body .si-swatch.si-chorus { background: var(--si-chorus); }
body .si-bridge, body .si-swatch.si-bridge { background: var(--si-bridge); }
body .si-extra, body .si-swatch.si-extra { background: var(--si-extra); }
body .si-connect, body .si-swatch.si-connect { background: var(--si-connect); }
body .si-end, body .si-swatch.si-end { background: var(--si-end); }
body .si-intro, body .si-connect, body .si-end { color: #fff; }

body .si-bar { top: auto; background: linear-gradient(180deg, rgba(139, 124, 255, 0.95), rgba(47, 214, 208, 0.6)); border-left: 2px solid var(--bg); border-radius: 3px 3px 0 0; }

body .si-segment { top: 3px; bottom: 3px; border-left: 2px solid var(--bg); border-radius: 5px; display: flex; align-items: center; padding: 0 0.45em; overflow: hidden; font-size: 0.7em; font-weight: 600; white-space: nowrap; color: #0b0d14; }
body .si-role-melody .si-segment { background: #ff8fa3; }
body .si-role-inner1 .si-segment { background: #6fe3a1; }
body .si-role-inner2 .si-segment { background: #b295ff; }
body .si-role-bass .si-segment { background: #5fc4ff; }
body .si-role-percussion .si-segment { background: #ffc46b; }

body .si-playhead { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: #fff; box-shadow: 0 0 10px rgba(255, 255, 255, 0.9); pointer-events: none; display: none; }

body .si-legend { display: flex; flex-wrap: wrap; gap: 0.4em 1.1em; margin: 0.9em 0 0.3em; font-size: 0.8em; color: var(--text-dim); }
body .si-legend-item { display: inline-flex; align-items: center; gap: 0.45em; }
body .si-swatch { width: 0.9em; height: 0.9em; border-radius: 3px; display: inline-block; }

body .si-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(14em, 1fr)); gap: 0.7em; margin-top: 0.6em; }
body .si-card { padding: 0.9em 1em; background: rgba(255, 255, 255, 0.035); border: 1px solid var(--border); border-radius: var(--radius-sm); border-top-width: 3px; }
body .si-card.si-role-melody { border-top-color: #ff8fa3; }
body .si-card.si-role-inner1 { border-top-color: #6fe3a1; }
body .si-card.si-role-inner2 { border-top-color: #b295ff; }
body .si-card.si-role-bass { border-top-color: #5fc4ff; }
body .si-card.si-role-percussion { border-top-color: #ffc46b; }
body .si-card-title { font-weight: 700; }
body .si-chips { display: flex; flex-direction: column; gap: 0.5em; margin-top: 0.8em; }
body .si-chip { display: flex; align-items: center; gap: 0.7em; }
body .si-chip-icon { font-size: 1.3em; width: 1.6em; text-align: center; }
body .si-chip-name { display: block; font-weight: 600; font-size: 0.92em; }
body .si-chip-use { display: block; font-size: 0.75em; color: var(--text-dim); }
body .si-chip.si-unused { opacity: 0.45; }

/* ---- Tunes switch ------------------------------------------------------------------------------- */
body #tunestoggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
    padding: 0.55em 1em;
    font-family: var(--font);
    font-size: 1em;
    font-weight: 600;
    color: var(--text-dim);
    background: var(--surface-3);
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
body #tunestoggle:hover { border-color: var(--accent); color: var(--text); }
body #tunestoggle .tunes-state {
    font-size: 0.75em;
    padding: 0.15em 0.6em;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
}
body #tunestoggle .tunes-state::after { content: "Off"; }
body #tunestoggle.on { color: #fff; background: rgba(139, 124, 255, 0.22); border-color: rgba(139, 124, 255, 0.6); }
body #tunestoggle.on .tunes-state { background: var(--accent); }
body #tunestoggle.on .tunes-state::after { content: "On"; }

@media (max-width: 800px) {
    body #buttonsDiv #tunestoggle { order: -3; }
}

/* ---- Expression switch ------------------------------------------------------------------------------- */
body #expressiontoggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
    padding: 0.55em 1em;
    font-family: var(--font);
    font-size: 1em;
    font-weight: 600;
    color: var(--text-dim);
    background: var(--surface-3);
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
body #expressiontoggle:hover { border-color: var(--accent); color: var(--text); }
body #expressiontoggle .tunes-state {
    font-size: 0.75em;
    padding: 0.15em 0.6em;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
}
body #expressiontoggle .tunes-state::after { content: "Off"; }
body #expressiontoggle.on { color: #fff; background: rgba(139, 124, 255, 0.22); border-color: rgba(139, 124, 255, 0.6); }
body #expressiontoggle.on .tunes-state { background: var(--accent); }
body #expressiontoggle.on .tunes-state::after { content: "On"; }

@media (max-width: 800px) {
    body #buttonsDiv #expressiontoggle { order: -2; }
}

/* ---- Orchestra switch ------------------------------------------------------------------------------- */
body #orchestratoggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
    padding: 0.55em 1em;
    font-family: var(--font);
    font-size: 1em;
    font-weight: 600;
    color: var(--text-dim);
    background: var(--surface-3);
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
body #orchestratoggle:hover { border-color: var(--accent); color: var(--text); }
body #orchestratoggle .tunes-state {
    font-size: 0.75em;
    padding: 0.15em 0.6em;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
}
body #orchestratoggle .tunes-state::after { content: "Off"; }
body #orchestratoggle.on { color: #fff; background: rgba(139, 124, 255, 0.22); border-color: rgba(139, 124, 255, 0.6); }
body #orchestratoggle.on .tunes-state { background: var(--accent); }
body #orchestratoggle.on .tunes-state::after { content: "On"; }

@media (max-width: 800px) {
    body #buttonsDiv #orchestratoggle { order: -2; }
}

/* ---- Narrow screens: the switches keep only their icon and state, so that the top bar has room ------------ */
@media (max-width: 1000px) {
    body #tunestoggle .tunes-label,
    body #expressiontoggle .tunes-label,
    body #orchestratoggle .tunes-label { display: none; }
    body #tunestoggle,
    body #expressiontoggle,
    body #orchestratoggle { padding: 0.55em 0.75em; }
}
