/* ─── Settings sections ─────────────────────────────────────────── */

.settings-section {
    display: flex;
    flex-direction: column;
    gap: var(--s-4);
}

/* Divider between groups — the drawer-body gap provides the breathing room. */
.settings-section + .settings-section {
    padding-top: var(--s-5);
    border-top: 1px solid var(--border-1);
}

.section-title {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    color: var(--fg-3);
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

/* Accordion header — the whole row toggles the section body (drawer.js).
   Inherits the section-title look via the button font/color reset. */
.section-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-2);
    width: 100%;
    text-align: left;
    transition: color var(--dur);
}

.section-toggle:hover {
    color: var(--fg-1);
}

.section-toggle [data-icon] {
    color: var(--fg-4);
    transition: transform var(--dur) var(--ease-out);
}

.settings-section[data-collapsed="true"] .section-toggle [data-icon] {
    transform: rotate(-90deg);
}

/* Label takes the slack so summary + chevron hug the right edge. */
.section-toggle > span:first-child {
    flex: 1;
    min-width: 0;
}

/* Collapsed-state status (filename, line count, palette · font, ratio · format) */
.section-summary {
    font-family: var(--font-sans);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
    color: var(--fg-4);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60%;
}

/* Only meaningful while the body is hidden — expanded shows the real thing. */
.settings-section:not([data-collapsed="true"]) .section-summary {
    display: none;
}

.settings-section-body {
    display: flex;
    flex-direction: column;
    gap: var(--s-4);
}

/* ─── Lyrics editor ─────────────────────────────────────────────── */

/* Action row at the top of the section body — tucked toward the list it
   operates on (the body's gap alone reads too far from it). */
.lyrics-toolbar {
    display: flex;
    gap: var(--s-1);
    margin-bottom: calc(-1 * var(--s-2));
}

.lyrics-tool {
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    color: var(--fg-2);
    border-radius: var(--r-sm);
}

.lyrics-tool:hover {
    color: var(--fg-0);
    background: var(--bg-2);
}

/* ── AI auto-sync panel ── */

.autosync-panel {
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
    padding: var(--s-3);
    background: var(--bg-2);
    border: 1px solid var(--border-1);
    border-radius: var(--r-md);
}

/* <summary> of the details panel — collapsed to one row by default. */
.autosync-panel-head {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--fg-1);
    cursor: pointer;
    list-style: none;          /* hide the native disclosure triangle */
    transition: color var(--dur);
}

.autosync-panel-head::-webkit-details-marker {
    display: none;
}

.autosync-panel-head:hover {
    color: var(--fg-0);
}

.autosync-panel-chevron {
    display: inline-flex;
    margin-left: auto;
    color: var(--fg-4);
    transition: transform var(--dur) var(--ease-out);
}

.autosync-panel:not([open]) .autosync-panel-chevron {
    transform: rotate(-90deg);
}

.autosync-panel-icon {
    display: inline-flex;
    color: var(--accent);
}

.autosync-panel-desc,
.autosync-panel-note {
    font-size: 11px;
    line-height: 1.5;
    color: var(--fg-3);
}

.autosync-textarea {
    resize: vertical;
    min-height: 64px;
    font-size: 12px;
    line-height: 1.5;
}

.autosync-actions {
    display: flex;
    align-items: center;
    gap: var(--s-2);
}

.autosync-btn {
    flex-shrink: 0;
    font-size: 12px;
}

.autosync-btn.running {
    color: var(--accent);
    border-color: var(--accent);
}

/* Live status line while Whisper downloads / transcribes */
.autosync-status {
    flex: 1;
    font-size: 11px;
    line-height: 1.4;
    color: var(--fg-3);
    animation: autosync-pulse 1.6s ease-in-out infinite;
}

@keyframes autosync-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}

.lyrics-container {
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
}

.lyrics-empty {
    padding: var(--s-4);
    font-size: 12px;
    line-height: 1.6;
    color: var(--fg-3);
    background: var(--bg-2);
    border: 1px dashed var(--border-1);
    border-radius: var(--r-md);
    text-align: center;
}

.lyrics-item {
    background: var(--bg-2);
    border: 1px solid var(--border-1);
    border-radius: var(--r-md);
    padding: var(--s-3);
    transition: border-color var(--dur);
}

.lyrics-item:focus-within {
    border-color: var(--accent);
}

.lyrics-item-header {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    margin-bottom: var(--s-2);
}

.lyrics-grip {
    display: inline-flex;
    color: var(--fg-4);
    cursor: grab;
    padding: 2px;
    border-radius: var(--r-sm);
    transition: color var(--dur), background var(--dur);
}

.lyrics-grip:hover {
    color: var(--fg-2);
    background: var(--bg-3);
}

.lyrics-grip:active {
    cursor: grabbing;
}

.lyrics-item[data-dragging="true"] {
    opacity: 0.5;
}

.lyrics-item[data-drop-target="true"] {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.lyrics-item-title {
    flex: 1;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--fg-3);
    font-weight: 500;
}

.remove-lyrics-btn {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    color: var(--fg-3);
    font-size: 14px;
    line-height: 1;
    display: grid;
    place-items: center;
    transition: background var(--dur), color var(--dur);
}

.remove-lyrics-btn:hover {
    background: rgba(248, 113, 113, 0.12);
    color: var(--danger);
}

.lyrics-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--s-2);
}

.lyrics-inputs > .lyrics-text-wrap {
    grid-column: span 2;
}

.lyrics-inputs input {
    width: 100%;
    padding: 8px 10px;
    font-size: 13px;
    color: var(--fg-0);
    background: var(--bg-1);
    border: 1px solid var(--border-1);
    border-radius: var(--r-sm);
    transition: border-color var(--dur);
}

.lyrics-inputs input.time-input {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

.lyrics-inputs input:focus {
    border-color: var(--accent);
}

.lyrics-inputs input:invalid:not(:placeholder-shown) {
    border-color: var(--danger);
}

/* ─── Palette templates (one-tap harmony schemes) ───────────────── */

.palette-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--s-2);
}

.palette-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: var(--bg-2);
    border: 1px solid var(--border-1);
    border-radius: var(--r-md);
    text-align: left;
    transition: border-color var(--dur), background var(--dur);
}

.palette-chip:hover {
    border-color: var(--border-2);
    background: var(--bg-3);
}

.palette-chip.active {
    border-color: var(--accent);
    background: var(--accent-soft);
}

/* Mini preview — the chip's bg swatch carries the scheme's background,
   the three dots are accent / lyrics / title. */
.palette-chip-dots {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    width: 44px;
    height: 28px;
    border-radius: var(--r-sm);
    border: 1px solid var(--border-2);
    flex-shrink: 0;
}

.palette-chip-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.palette-chip-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.palette-chip-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--fg-0);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.palette-chip-scheme {
    font-size: 10px;
    color: var(--fg-3);
    line-height: 1.2;
}

/* ─── Color customization (6 elements, 2-col grid) ──────────────── */

.color-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: var(--s-2);
}

.color-row {
    position: relative;
    display: flex;
    align-items: center;
    flex-wrap: wrap;        /* lets the preset strip drop to its own line */
    gap: 8px;
    padding: 8px;
    background: var(--bg-2);
    border: 1px solid var(--border-1);
    border-radius: var(--r-md);
    transition: border-color var(--dur), background var(--dur);
}

.color-row:hover {
    border-color: var(--border-2);
    background: var(--bg-3);
}

/* A tinted border is enough — applying a palette overrides all six rows at
   once, and six accent-filled boxes drowned out everything else. */
.color-row[data-overridden="true"] {
    border-color: var(--accent-glow);
}

.color-row-swatch {
    width: 30px;
    height: 30px;
    border-radius: var(--r-sm);
    border: 2px solid rgba(255, 255, 255, 0.08);
    cursor: pointer;
    padding: 0;
    background: transparent;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow:
        0 2px 6px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
    transition: transform var(--dur), border-color var(--dur);
}

.color-row-swatch:hover {
    transform: scale(1.05);
    border-color: rgba(255, 255, 255, 0.2);
}

.color-row-swatch::-webkit-color-swatch-wrapper {
    padding: 0;
    border-radius: inherit;
}

.color-row-swatch::-webkit-color-swatch {
    border: none;
    border-radius: inherit;
}

.color-row-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.color-row-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--fg-0);
    line-height: 1.2;
}

.color-row-hex {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--fg-3);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.color-row[data-auto="true"] .color-row-hex {
    font-family: var(--font-sans);
    font-size: 10px;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}

.color-row-reset {
    width: 22px;
    height: 22px;
    border-radius: var(--r-sm);
    background: transparent;
    border: none;
    color: var(--fg-2);
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: background var(--dur), color var(--dur);
    flex-shrink: 0;
}

.color-row-reset:hover {
    background: rgba(0, 0, 0, 0.3);
    color: var(--accent);
}

/* Only show the reset button when an override is active — no clutter otherwise. */
.color-row:not([data-overridden="true"]) .color-row-reset {
    display: none;
}

/* ─── Per-color quick presets (collapsed behind the chevron) ────── */

.color-row-presets-toggle {
    width: 22px;
    height: 22px;
    border-radius: var(--r-sm);
    color: var(--fg-3);
    display: grid;
    place-items: center;
    flex-shrink: 0;
    transition: color var(--dur), transform var(--dur) var(--ease-out);
}

.color-row-presets-toggle:hover {
    color: var(--fg-0);
}

.color-row[data-presets-open="true"] .color-row-presets-toggle {
    transform: rotate(180deg);
    color: var(--accent);
}

.color-row-presets {
    flex-basis: 100%;
    display: none;
    flex-wrap: wrap;
    gap: 6px;
    padding-top: 2px;
}

.color-row[data-presets-open="true"] .color-row-presets {
    display: flex;
}

.color-preset-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.12);
    flex-shrink: 0;
    transition: transform var(--dur), border-color var(--dur);
}

.color-preset-dot:hover {
    transform: scale(1.15);
    border-color: rgba(255, 255, 255, 0.4);
}

.color-preset-dot.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-soft);
}

/* ─── Player font picker ────────────────────────────────────────── */

.font-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--s-2);
}

.font-option {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 12px;
    background: var(--bg-2);
    border: 1px solid var(--border-1);
    border-radius: var(--r-md);
    text-align: left;
    min-width: 0;
    transition: border-color var(--dur), background var(--dur);
}

.font-option:hover {
    border-color: var(--border-2);
    background: var(--bg-3);
}

.font-option.active {
    border-color: var(--accent);
    background: var(--accent-soft);
}

/* Rendered in its own typeface (set inline by font-manager.js). */
.font-option-name {
    font-size: 15px;
    color: var(--fg-0);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.font-option-category {
    font-size: 10px;
    color: var(--fg-3);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ─── Export ────────────────────────────────────────────────────── */

/* Sticky dock pinned to the drawer's bottom edge: bleeds over the
   drawer-body padding (negative margins) so the fade spans full width,
   and the gradient masks form content scrolling underneath.
   margin-top: auto bottoms it out when the (collapsed) form is shorter
   than the drawer; once content overflows, sticky takes over. */
.export-field {
    position: sticky;
    bottom: 0;
    z-index: 5;
    margin: auto calc(-1 * var(--s-6)) 0;
    padding: var(--s-4) var(--s-6) var(--s-5);
    background: linear-gradient(180deg, transparent 0%, var(--bg-1) 32%);
}

.export-btn {
    position: relative;
    overflow: hidden;          /* keep the fill inside the rounded corners */
    width: 100%;
    padding: 14px;
    font-size: 14px;
}

/* Horizontal "water fill" — width driven by EXPORT_PROGRESS in settings.js.
   Hidden when idle so the wave pseudo-elements don't peek out at width 0. */
.export-btn-fill {
    position: absolute;
    inset: 0;
    width: 0%;
    display: none;
    background: linear-gradient(90deg, var(--accent), var(--accent-hi), var(--accent));
    background-size: 200% 100%;
    /* Progress ticks every 200ms; a slightly longer linear transition strings
       the steps into one continuous pour. */
    transition: width 0.35s linear;
    pointer-events: none;
}

/* The waterline IS the fill's own right edge: a mask carves it into a sine
   wave (layer 2) unioned with the rectangular body (layer 1), and the wave
   tile scrolls vertically — one coherent surface, no overlay on top. */
.export-btn.exporting .export-btn-fill {
    display: block;
    mask-image:
        linear-gradient(#000, #000),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='48'%3E%3Cpath d='M0 0 H6 C11 8 1 16 6 24 C11 32 1 40 6 48 H0 Z'/%3E%3C/svg%3E");
    mask-size: calc(100% - 11px) 100%, 12px 48px;   /* 1px overlap — no hairline seam */
    mask-position: 0 0, 100% 0;
    mask-repeat: no-repeat, repeat-y;
    animation:
        export-flow 2.5s linear infinite,   /* water "flows" inside the fill */
        export-lap 1.4s linear infinite;    /* waves lap along the waterline */
}

@keyframes export-flow {
    to { background-position: -200% 0; }
}

/* Shift the wave tile by exactly one period (48px) for a seamless loop. */
@keyframes export-lap {
    from { mask-position: 0 0, 100% 0; }
    to   { mask-position: 0 0, 100% 48px; }
}

/* Label/icon sit above the fill layer. */
.export-btn-content,
.export-btn-cancel {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
}

.export-btn-cancel {
    display: none;
}

/* Exporting: the button becomes the progress track — accent fill pours over
   a neutral base. Stays enabled so a click cancels. */
.export-btn.exporting {
    background: var(--bg-3);
    color: var(--fg-0);
    cursor: pointer;
}

.export-btn.exporting:hover:not(:disabled) {
    background: var(--bg-3);
    box-shadow: none;
}

/* Same metrics for the progress label and the Cancel swap — hovering must
   not change the text size or the button's height. */
.export-btn.exporting #export-btn-label,
.export-btn.exporting .export-btn-cancel {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 500;
    line-height: 21px;
}

.export-btn.exporting .export-icon {
    display: none;
}

/* Hover while exporting reveals the cancel affordance. */
.export-btn.exporting:hover .export-btn-content {
    display: none;
}

.export-btn.exporting:hover .export-btn-cancel {
    display: inline-flex;
    color: var(--danger);
}

/* ─── Modal (JSON import) ───────────────────────────────────────── */

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(6px);
    padding: var(--s-4);
    animation: fadeIn var(--dur) var(--ease-out);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.modal-content {
    background: var(--bg-1);
    border: 1px solid var(--border-1);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    width: min(560px, 100%);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: slideUp var(--dur-slow) var(--ease-out);
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--s-5) var(--s-6);
    border-bottom: 1px solid var(--border-1);
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.modal-body {
    padding: var(--s-5) var(--s-6) var(--s-6);
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
    overflow-y: auto;
}

.modal-description {
    font-size: 13px;
    color: var(--fg-2);
    line-height: 1.5;
}

.modal-description code {
    padding: 1px 6px;
    background: var(--bg-2);
    border-radius: var(--r-sm);
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--accent);
}

.modal-warning {
    padding: 10px 14px;
    background: rgba(251, 191, 36, 0.08);
    border: 1px solid rgba(251, 191, 36, 0.3);
    border-radius: var(--r-md);
    font-size: 13px;
    color: var(--warn);
    line-height: 1.5;
}

.import-mode-toggle {
    display: inline-flex;
    padding: 3px;
    background: var(--bg-2);
    border: 1px solid var(--border-1);
    border-radius: var(--r-md);
    gap: 2px;
}

.import-mode-btn {
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--fg-3);
    background: transparent;
    border: none;
    border-radius: calc(var(--r-md) - 4px);
    cursor: pointer;
    transition: background var(--dur), color var(--dur);
}

.import-mode-btn:hover {
    color: var(--fg-1);
}

.import-mode-btn.active {
    background: var(--bg-3);
    color: var(--fg-0);
}

/* ─── Aspect ratio toggle ──────────────────────────────────────── */

.ratio-toggle {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    padding: 3px;
    background: var(--bg-2);
    border: 1px solid var(--border-1);
    border-radius: var(--r-md);
    gap: 2px;
}

.ratio-btn {
    padding: 8px 0;
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 500;
    color: var(--fg-3);
    background: transparent;
    border: none;
    border-radius: calc(var(--r-md) - 4px);
    cursor: pointer;
    transition: background var(--dur), color var(--dur);
}

.ratio-btn:hover {
    color: var(--fg-1);
}

.ratio-btn.active {
    background: var(--bg-3);
    color: var(--fg-0);
}

/* Video format reuses the ratio-toggle styling, with two columns. */
.format-toggle {
    grid-template-columns: repeat(2, 1fr);
}

.ratio-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.field-help {
    font-size: 11px;
    color: var(--fg-3);
    line-height: 1.4;
}

.json-example {
    padding: var(--s-3);
    background: var(--bg-2);
    border: 1px solid var(--border-1);
    border-radius: var(--r-md);
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--fg-2);
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-x: auto;
}

.json-textarea {
    min-height: 180px;
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.5;
    resize: vertical;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--s-2);
    margin-top: var(--s-2);
}

/* ─── Browser support list ─────────────────────────────────────── */

.support-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
}

.support-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg-2);
    border: 1px solid var(--border-1);
    border-radius: var(--r-md);
    font-size: 13px;
    color: var(--fg-1);
}

.support-list .support-value {
    font-family: var(--font-mono);
    font-size: 12px;
}

.support-list .support-ok    { color: var(--success); }
.support-list .support-fail  { color: var(--danger); }

@media (max-width: 480px) {
    .modal-actions {
        flex-direction: column-reverse;
    }
    .modal-actions .btn {
        width: 100%;
    }
}
