* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    transition: background-color 0.3s, color 0.3s;
}

:where([hidden]) {
    display: none !important;
}

body {
    background: var(--bg);
    color: var(--text);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 1rem;
}

.container {
    max-width: 500px;
    width: 100%;
    background: var(--container-bg);
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1 1 auto;
    min-width: 0;
}

.brand-logo {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    object-fit: contain;
}

.brand header {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.brand-title-row {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    flex-wrap: nowrap;
    min-width: 0;
}

.brand--about {
    justify-content: center;
    margin-bottom: 0.25rem;
    flex: 0 0 auto;
}

.brand--about .brand-logo {
    width: 40px;
    height: 40px;
}

.brand--about h1 {
    font-size: 1.6rem;
}

header h1 {
    font-size: 2rem;
    color: var(--primary);
    margin: 0;
    flex: 0 1 auto;
    min-width: 0;
    white-space: nowrap;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: auto;
    flex-shrink: 0;
}

.settings-trigger {
    position: relative;
    display: inline-flex;
}

.header-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border);
    background: var(--container-bg);
    color: var(--primary);
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
    cursor: pointer;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, color 0.18s ease;
    padding: 0;
}

.header-button:hover,
.header-button:focus-visible {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);
    background: var(--container-bg);
}

.header-button[aria-expanded='true'] {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);
    background: var(--container-bg);
}

.header-button i {
    font-size: 1.05rem;
}

@media (max-width: 540px) {
    .header-container {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        gap: 0.5rem;
    }

    .preset-form-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .preset-form-time-signature-controls {
        flex-wrap: wrap;
        width: 100%;
    }

    .preset-form-time-signature {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .preset-use-current-toggle {
        align-self: flex-start;
        margin-left: 0;
        padding-bottom: 0;
    }

    .header-actions {
        gap: 0.5rem;
        justify-self: end;
    }

    header h1 {
        font-size: 1.75rem;
    }
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.beat-display {
    font-size: 6rem;
    font-weight: bold;
    color: var(--primary);
    margin-bottom: 0.5rem;
    border: 2px dashed var(--primary);
    border-radius: 1rem;
    padding: 1rem;
    cursor: pointer;
    position: relative;
    transition: background-color 0.1s;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

.beat-display.flash {
    background-color: var(--flash-color);
    color: white;
}

.beat-display-hint {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.tempo-control {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
}

.tempo-control button {
    flex-shrink: 0;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    width: 3rem;
    height: 3rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 0.75rem;
}

.tempo-control button i {
    font-size: 1.1rem;
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 100%;
}

.volume-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    flex: 0 0 8.75rem;
    max-width: 8.75rem;
}

.volume-control input[type="range"] {
    flex: 1;
}

.volume-label-text {
    font-weight: 500;
}

.volume-value-wrapper {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.15rem 0.5rem;
    border-radius: 0.5rem;
    background: var(--accent-soft);
    color: var(--primary);
    min-width: 4.5rem;
    justify-content: flex-end;
}

.volume-value-input {
    width: 2.8rem;
    border: none;
    background: transparent;
    color: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    text-align: right;
    -moz-appearance: textfield;
    appearance: textfield;
}

.volume-value-input:focus {
    outline: none;
}

.volume-value-input::-webkit-outer-spin-button,
.volume-value-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.volume-value-suffix {
    font-weight: 600;
    letter-spacing: 0.02em;
}

.bpm-input-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    border: 2px solid var(--border);
    border-radius: 0.65rem;
    background: var(--container-bg);
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.07);
    transition: border 0.2s ease, box-shadow 0.2s ease;
}

.bpm-input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.bpm-input {
    width: 4.5rem;
    padding: 0;
    margin: 0;
    font-size: 1.2rem;
    border: none;
    background: transparent;
    text-align: right;
    color: var(--text);
}

.bpm-input:focus {
    outline: none;
}

.bpm-input::-webkit-outer-spin-button,
.bpm-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.bpm-input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

.bpm-suffix {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.03em;
}

.time-sig {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    align-items: center;
}

.time-sig select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    padding: 0.55rem 2.5rem 0.55rem 1rem;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    border: 2px solid var(--border);
    border-radius: 0.75rem;
    background: var(--container-bg);
    color: var(--text);
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.12);
    transition: border 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.9rem center;
    background-size: 0.75rem;
}

.time-sig select:hover {
    border-color: rgba(96, 165, 250, 0.6);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.18);
}

.time-sig select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.time-sig span {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1;
    color: var(--text-secondary);
    padding: 0.55rem 0.25rem;
}

button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

button:hover {
    background: var(--primary-hover);
}
#playButton,
#tapButton {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    font-weight: 600;
}

#playButton i {
    font-size: 1rem;
}

footer {
    margin-top: 0.5rem;
    padding-top: 1rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.footer-lines {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    line-height: 1.5;
}

.footer-line {
    margin: 0;
}

.footer-links {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 0 0 auto;
}

.link-text {
    text-decoration: underline;
    color: inherit;
}

.link-text:hover {
    color: var(--primary);
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: transparent;
    cursor: pointer;
}

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

input[type="range"]:focus-visible {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 30%, transparent);
    border-radius: 999px;
}

input[type="range"]::-webkit-slider-runnable-track {
    height: 6px;
    background: color-mix(in srgb, var(--primary) 32%, transparent);
    border-radius: 999px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid var(--container-bg);
    box-shadow: 0 2px 6px color-mix(in srgb, var(--primary) 18%, rgba(15, 23, 42, 0.35));
    margin-top: -6px;
    transition: transform 0.15s ease, background 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.05);
}

input[type="range"]::-webkit-slider-thumb:active {
    transform: scale(1.1);
    background: var(--primary-hover);
}

input[type="range"]::-moz-range-track {
    height: 6px;
    background: color-mix(in srgb, var(--primary) 25%, transparent);
    border-radius: 999px;
}

input[type="range"]::-moz-range-progress {
    height: 6px;
    background: linear-gradient(90deg, var(--primary), var(--primary-hover));
    border-radius: 999px;
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid var(--container-bg);
    box-shadow: 0 2px 6px color-mix(in srgb, var(--primary) 18%, rgba(15, 23, 42, 0.35));
    transition: transform 0.15s ease, background 0.2s ease;
}

input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.05);
}

input[type="range"]::-moz-range-thumb:active {
    transform: scale(1.1);
    background: var(--primary-hover);
}


.preset-panel,
.settings-panel {
    position: fixed;
    inset: 0;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.28s ease;
    z-index: 40;
}

.preset-panel.is-open,
.settings-panel.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.preset-panel.is-closing,
.settings-panel.is-closing {
    visibility: visible;
    pointer-events: none;
}

.preset-panel__backdrop,
.settings-panel__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.42);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.28s ease;
}

.preset-panel.is-open .preset-panel__backdrop,
.settings-panel.is-open .settings-panel__backdrop {
    opacity: 1;
}

.preset-panel.is-closing .preset-panel__backdrop,
.settings-panel.is-closing .settings-panel__backdrop {
    opacity: 0;
}

.preset-panel__content,
.settings-panel__content {
    position: absolute;
    top: 0;
    right: 0;
    width: min(420px, 100%);
    height: 100%;
    background: var(--container-bg);
    color: var(--text);
    box-shadow: -12px 0 32px rgba(15, 23, 42, 0.12), 0 24px 48px -28px rgba(15, 23, 42, 0.32);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    padding: 2rem 1.75rem 2.5rem;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    max-height: 100vh;
    overflow: visible;
}

.preset-panel.is-open .preset-panel__content,
.settings-panel.is-open .settings-panel__content {
    transform: translateX(0);
}

.preset-panel.is-closing .preset-panel__content,
.settings-panel.is-closing .settings-panel__content {
    transform: translateX(100%);
}

.preset-panel__content::after,
.settings-panel__content::after {
    content: "";
    position: absolute;
    left: 1.75rem;
    right: 1.75rem;
    bottom: 1.4rem;
    height: 2.25rem;
    pointer-events: none;
    border-radius: 999px;
    box-shadow: 0 22px 34px -26px rgba(15, 23, 42, 0.35);
    transform: translateY(70%);
}

.preset-panel__body,
.settings-panel__body {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    flex: 1 1 auto;
    overflow-y: auto;
    padding-right: 0.25rem;
    padding-bottom: 2.5rem;
}

.preset-panel__header,
.settings-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.preset-close,
.settings-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.65rem;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.preset-close:hover,
.preset-close:focus-visible,
.settings-close:hover,
.settings-close:focus-visible {
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
    background: transparent;
}

.settings-panel__header-text {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.settings-panel__subtitle {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.45;
}

.settings-panel__tabs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.settings-tab {
    border: 1px solid var(--border);
    border-radius: 0.85rem;
    background: var(--container-bg);
    color: var(--text);
    padding: 0.65rem 0.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, color 0.18s ease, background-color 0.18s ease;
}

.settings-tab i {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.settings-tab:focus-visible {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}

.settings-tab--active {
    border-color: var(--primary);
    color: var(--primary);
    background: color-mix(in srgb, var(--accent-soft) 32%, transparent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 16%, transparent);
}

.settings-tab--active i {
    color: var(--primary);
}

.settings-section {
    display: none;
}

.settings-section.settings-section--active {
    display: block;
}

.settings-card {
    border: 1px solid var(--border);
    border-radius: 1rem;
    background: color-mix(in srgb, var(--container-bg) 80%, var(--accent-soft) 20%);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.settings-card--stacked {
    gap: 1.15rem;
}

.settings-card__title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
}

.settings-card__subtitle {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.settings-radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.settings-radio {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.9rem;
    padding: 0.85rem 1rem;
    background: var(--container-bg);
    cursor: pointer;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.settings-radio input[type="radio"] {
    width: 1.05rem;
    height: 1.05rem;
    margin-top: 0.2rem;
    flex-shrink: 0;
    accent-color: var(--primary);
}

.settings-radio__content {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.settings-radio__title {
    font-weight: 600;
    color: var(--text);
}

.settings-radio__description {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.settings-radio input[type="radio"]:checked + .settings-radio__content .settings-radio__title {
    color: var(--primary);
}

.settings-transfer {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.settings-transfer__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    border: none;
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.settings-transfer__button i {
    font-size: 0.95rem;
}

.settings-transfer__button:hover,
.settings-transfer__button:focus-visible {
    background: var(--primary-hover);
    outline: none;
}

.about-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.about-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px dashed var(--border);
    padding-bottom: 0.35rem;
}

.about-list li:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.about-list a {
    font-weight: 600;
}

.custom-alert__body {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.custom-alert__extra {
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 0.75rem;
    background: color-mix(in srgb, var(--accent-soft) 45%, transparent);
}

.custom-alert__extra[hidden] {
    display: none;
}

.alert-checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.alert-checkbox {
    display: flex;
    gap: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 0.65rem 0.85rem;
    background: var(--container-bg);
    cursor: pointer;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.alert-checkbox input {
    width: 1rem;
    height: 1rem;
    margin-top: 0.2rem;
    flex-shrink: 0;
    accent-color: var(--primary);
}

.alert-checkbox__content {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.alert-checkbox__title {
    font-weight: 600;
    color: var(--text);
}

.alert-checkbox__description {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.alert-checkbox input:disabled + .alert-checkbox__content .alert-checkbox__title {
    color: var(--text-secondary);
}

.alert-checkbox input:disabled + .alert-checkbox__content .alert-checkbox__description {
    color: rgba(107, 114, 128, 0.6);
}

.theme-panel__sections {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.theme-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.theme-panel__custom {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    border: 1px dashed var(--primary);
    border-radius: 1rem;
    padding: 1.25rem;
    background: color-mix(in srgb, var(--accent-soft) 55%, transparent 45%);
}

.theme-panel__custom-header {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.theme-panel__custom-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
}

.theme-panel__custom-subtitle {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.custom-theme-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.custom-theme-field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.custom-theme-field label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
}

.custom-theme-inputs {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0.65rem;
    align-items: center;
}

.custom-theme-inputs--with-action {
    grid-template-columns: auto minmax(0, 1fr) auto;
}

.custom-theme-inputs input[type="color"] {
    width: 48px;
    height: 48px;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 0;
    background: var(--container-bg);
    cursor: pointer;
    box-shadow: inset 0 0 0 2px rgba(15, 23, 42, 0.08);
}

.custom-theme-inputs input[type="text"] {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    background: var(--container-bg);
    color: var(--text);
}

.custom-theme-field-reset {
    width: 40px;
    height: 40px;
    border-radius: 0.75rem;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: color 0.18s ease, border-color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease;
}

.custom-theme-field-reset.is-active {
    border-color: var(--primary);
    color: var(--primary);
    background: color-mix(in srgb, var(--primary) 18%, transparent);
}

.custom-theme-field-reset:hover,
.custom-theme-field-reset:focus-visible {
    border-color: var(--primary);
    color: var(--primary);
    background: color-mix(in srgb, var(--primary) 14%, transparent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
    outline: none;
}

.custom-theme-field-reset[disabled] {
    opacity: 0.45;
    cursor: default;
    border-color: transparent;
    background: transparent;
    box-shadow: none;
}

.custom-theme-field-reset[disabled]:hover,
.custom-theme-field-reset[disabled]:focus-visible {
    color: var(--text-secondary);
    background: transparent;
    border-color: transparent;
    box-shadow: none;
}

.custom-theme-inputs input[type="text"]:focus-visible {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}

.custom-theme-hint {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.custom-theme-hint--advanced {
    margin-bottom: 0.75rem;
}

.custom-theme-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.theme-io {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
    margin-top: 1.25rem;
}

.theme-io__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border);
    background: var(--container-bg);
    color: var(--text);
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, color 0.18s ease, background-color 0.18s ease;
}

.theme-io__button i {
    font-size: 0.95rem;
    color: var(--primary);
}

.theme-io__button:hover {
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}

.theme-io__button:focus-visible {
    outline: none;
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent);
}

.custom-theme-field-reset--accent {
    width: 48px;
    height: 48px;
}

.custom-theme-error {
    margin: 0;
    font-size: 0.85rem;
    color: #ef4444;
}

.custom-theme-title-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.custom-theme-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.6rem;
    border-radius: 0.75rem;
    background: var(--accent-soft);
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    gap: 0.35rem;
}

.custom-theme-badge i {
    font-size: 0.7rem;
}

.custom-theme-form fieldset {
    border: 0;
    padding: 0;
    margin: 0;
}

.custom-theme-advanced {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.custom-theme-advanced-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border);
    background: var(--container-bg);
    color: var(--text);
    cursor: pointer;
    width: 100%;
    text-align: left;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, color 0.18s ease, background-color 0.18s ease, border-radius 0.2s ease;
}

.custom-theme-advanced-toggle:hover {
    border-color: var(--border);
    background: var(--container-bg);
    box-shadow: none;
}

.custom-theme-advanced-toggle:focus-visible {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}

.custom-theme-advanced-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
    flex: 1 1 auto;
    min-width: 0;
}

.custom-theme-advanced-toggle i {
    margin-left: auto;
    font-size: 0.95rem;
    transition: transform 0.2s ease, color 0.2s ease;
    color: var(--text-secondary);
}

.custom-theme--advanced-open .custom-theme-advanced-toggle i {
    transform: rotate(180deg);
    color: var(--primary);
}

.custom-theme--advanced-open .custom-theme-advanced-toggle {
    border-color: var(--primary);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom-color: transparent;
    background: color-mix(in srgb, var(--accent-soft) 35%, transparent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}

.custom-theme-advanced-label {
    font-weight: 600;
    font-size: 0.95rem;
}

.custom-theme-advanced-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
}


.custom-theme-advanced-fields {
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 0.75rem 0.75rem;
    background: color-mix(in srgb, var(--accent-soft) 45%, transparent);
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.25s ease;
    padding: 0;
    overflow: hidden;
    margin-top: -1px;
}

.custom-theme-advanced-fields.is-open {
    grid-template-rows: 1fr;
}

.custom-theme-advanced-fields-inner {
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 0 1rem;
    transition: padding 0.25s ease;
}

.custom-theme-advanced-fields.is-open .custom-theme-advanced-fields-inner {
    padding: 1rem;
}

.custom-theme-advanced-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.85rem;
}

.custom-theme-field--compact label {
    font-size: 0.85rem;
}

.custom-theme-field--compact .custom-theme-inputs input[type="text"] {
    padding: 0.65rem 0.9rem;
    font-size: 0.85rem;
}

.custom-theme-field--compact .custom-theme-inputs input[type="color"] {
    width: 42px;
    height: 42px;
}

.custom-theme-field--compact .custom-theme-field-reset {
    width: 36px;
    height: 36px;
    border-radius: 0.65rem;
}

.theme-panel__custom.is-active {
    border-style: solid;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 22%, transparent);
}

.theme-section__title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.theme-section__description {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.theme-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem;
}

.theme-item {
    display: inline-flex;
    flex-direction: column;
    align-items: stretch;
    border-radius: 0.9rem;
    border: 1px solid var(--border);
    background: var(--container-bg);
    padding: 0.9rem 1rem;
    gap: 0.75rem;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease, transform 0.2s ease;
}

.theme-item:hover,
.theme-item:focus-visible {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
    background: color-mix(in srgb, var(--accent-soft) 32%, transparent);
}

.theme-item--active {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent);
    background: color-mix(in srgb, var(--accent-soft) 34%, transparent);
}

.theme-item--system {
    grid-column: span 2;
}

.theme-item__swatches {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.theme-item__swatch {
    flex: 1 1 0;
    min-width: 0;
    height: 1.65rem;
    border-radius: 0.55rem;
    background: var(--swatch-color, var(--primary));
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08);
}

.theme-item__swatch::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(155deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0));
    opacity: 0.85;
    pointer-events: none;
}

.theme-item__info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.theme-item__name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}

.theme-item__description {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.theme-item__state {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    color: var(--primary);
    font-size: 0.85rem;
    gap: 0.3rem;
    visibility: hidden;
}

.theme-item--active .theme-item__state {
    visibility: visible;
}

.theme-item__state i {
    font-size: 0.85rem;
}

.theme-item__state-text {
    font-weight: 600;
    font-size: 0.8rem;
}

.preset-panel__controls {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.preset-card {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.9rem 1rem;
    border-radius: 0.85rem;
    border: 1px solid var(--border);
    background: color-mix(in srgb, var(--accent-soft) 28%, transparent);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
    position: relative;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.preset-card:hover,
.preset-card:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
    background: color-mix(in srgb, var(--accent-soft) 38%, transparent);
}

.preset-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.preset-card__info {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex: 1 1 auto;
}

.preset-card__meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    flex-wrap: wrap;
}

.preset-card--empty {
    background: color-mix(in srgb, var(--accent-soft) 18%, transparent);
}

.preset-card--empty .preset-card__meta {
    color: var(--text-secondary);
}

.preset-card__meta--single {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
}

.preset-card__title {
    font-size: 1.05rem;
    font-weight: 600;
}

.preset-card__play {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.65rem;
    border: 1px solid var(--border);
    background: var(--container-bg);
    color: var(--primary);
    cursor: pointer;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, color 0.18s ease;
}

.preset-card__play:hover,
.preset-card__play:focus-visible {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
    background: var(--container-bg);
}

.preset-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
}

.preset-action-button {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.75rem;
    width: 100%;
    text-align: left;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    background: var(--container-bg);
    color: var(--primary);
    font-weight: 600;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, color 0.18s ease, background-color 0.18s ease, border-radius 0.25s ease, padding 0.25s ease;
}

.preset-action-button i {
    font-size: 0.95rem;
}

.preset-action-button__label {
    flex: 1 1 auto;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.preset-action-button__chevron {
    margin-left: auto;
    font-size: 0.95rem;
    transition: transform 0.2s ease, color 0.2s ease;
    color: var(--text-secondary);
}

.preset-action-button--with-chevron[aria-expanded="true"] .preset-action-button__chevron,
.preset-action-button--with-chevron.is-expanded .preset-action-button__chevron {
    transform: rotate(180deg);
    color: var(--primary);
}

#presetAddCustomToggle i {
    transition: transform 0.25s ease;
}

#presetAddCustomToggle span {
    transition: transform 0.25s ease;
}

#presetAddCustomToggle[aria-expanded="true"] i {
    transform: rotate(45deg);
}

#presetAddCustomToggle[aria-expanded="true"] span {
    transform: translateX(4px);
}

.preset-action-button:hover {
    border-color: var(--border);
    color: inherit;
    background: var(--container-bg);
    box-shadow: none;
}

.preset-action-button:focus-visible {
    border-color: var(--primary);
    color: var(--primary);
    background: color-mix(in srgb, var(--accent-soft) 30%, transparent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}

.preset-action-button[aria-expanded="true"] {
    background: color-mix(in srgb, var(--accent-soft) 25%, transparent);
    color: var(--text);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom-color: transparent;
}

.preset-action-button[aria-expanded="true"]:hover {
    background: color-mix(in srgb, var(--accent-soft) 25%, transparent);
    color: var(--text);
    border-color: var(--border);
}

.preset-action-button[aria-expanded="true"]:focus-visible {
    background: color-mix(in srgb, var(--accent-soft) 25%, transparent);
    color: var(--text);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}

.preset-form {
    display: grid;
    gap: 1rem;
    border: 1px solid var(--border);
    border-top: none;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    border-bottom-left-radius: 0.85rem;
    border-bottom-right-radius: 0.85rem;
    padding: 0;
    background: color-mix(in srgb, var(--accent-soft) 25%, transparent);
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    visibility: hidden;
    transition: max-height 0.35s ease, opacity 0.25s ease, padding 0.35s ease, visibility 0s linear 0.35s;
}

.preset-form.preset-form--animating {
    transition: max-height 0.35s ease, opacity 0.25s ease, padding 0.35s ease, visibility 0s;
}

.preset-form.preset-form--visible {
    max-height: 600px;
    opacity: 1;
    padding: 1rem;
    visibility: visible;
}

.preset-form-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.25rem;
    font-weight: 600;
    gap: 1rem;
}

.io-group {
    margin-top: 1.25rem;
}

.io-panel {
    border: 1px solid var(--border);
    border-top: none;
    border-bottom-left-radius: 0.85rem;
    border-bottom-right-radius: 0.85rem;
    background: color-mix(in srgb, var(--accent-soft) 22%, transparent);
    margin-top: -1px;
    padding: 0;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    display: grid;
    gap: 1rem;
    transition: max-height 0.35s ease, opacity 0.25s ease, padding 0.35s ease;
}

.io-panel.is-open {
    max-height: 520px;
    opacity: 1;
    padding: 1rem 1.1rem 1.1rem;
}

.io-panel__actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    width: 100%;
}

.io-panel__export-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.65rem 1.2rem;
    border-radius: 0.65rem;
    border: none;
    background: var(--primary);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.io-panel__export-button i {
    font-size: 0.95rem;
}

.io-panel__export-button:hover,
.io-panel__export-button:focus-visible {
    background: var(--primary-hover);
    outline: none;
}

.io-dropzone {
    display: flex;
    align-items: center;
    gap: 1rem;
    border: 1.5px dashed var(--border);
    border-radius: 0.9rem;
    background: color-mix(in srgb, var(--container-bg) 85%, var(--accent-soft) 15%);
    padding: 1rem 1.25rem;
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.io-dropzone:hover {
    border-color: var(--primary);
    background: color-mix(in srgb, var(--accent-soft) 35%, transparent);
}

.io-dropzone:focus-visible {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}

.io-dropzone.is-dragover {
    border-color: var(--primary);
    background: color-mix(in srgb, var(--accent-soft) 55%, transparent);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 16%, transparent);
    transform: translateY(-1px);
}

.io-dropzone__icon {
    width: 3rem;
    height: 3rem;
    border-radius: 0.85rem;
    background: color-mix(in srgb, var(--primary) 16%, transparent);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 30%, transparent);
}

.io-dropzone__icon i {
    font-size: 1.15rem;
}

.io-dropzone__content {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    align-items: flex-start;
}

.io-dropzone__content strong {
    font-size: 1rem;
    font-weight: 600;
}

.io-dropzone__separator {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
}

.io-dropzone__browse {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.75rem;
    border-radius: 0.65rem;
    border: 1px solid var(--primary);
    background: color-mix(in srgb, var(--primary) 10%, transparent);
    color: var(--primary);
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.io-dropzone__browse:hover,
.io-dropzone__browse:focus-visible {
    background: var(--primary);
    color: white;
}

.io-dropzone__hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.theme-panel__custom .io-group {
    margin-top: 1.5rem;
}

@media (max-width: 640px) {
    .io-panel.is-open {
        padding: 0.85rem;
    }

    .io-dropzone {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .io-dropzone__icon {
        width: 2.75rem;
        height: 2.75rem;
        border-radius: 0.75rem;
    }
}

.preset-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem 0.85rem;
    align-items: start;
}

.preset-form-grid label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.preset-form-grid input {
    width: 100%;
}

.preset-form-label {
    font-weight: 600;
    color: var(--text-secondary);
}

.preset-form-time-signature .preset-form-label {
    margin-bottom: 0;
}

.preset-form-time-signature-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: nowrap;
    width: 100%;
    min-width: 0;
}

.preset-form-time-signature-controls span {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1;
    color: var(--text-secondary);
    padding: 0.55rem 0.25rem;
}

.preset-form-time-signature-controls .preset-select {
    flex: 0 0 auto;
}

@media (max-width: 560px) {
    .preset-form-time-signature-controls {
        flex-wrap: wrap;
        gap: 0.5rem 0.75rem;
    }

    .preset-use-current-toggle {
        width: 100%;
        justify-content: flex-start;
        margin-left: 0;
    }
}


.preset-select {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.preset-select select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    padding: 0.55rem 2.5rem 0.55rem 1rem;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    border: 2px solid var(--border);
    border-radius: 0.75rem;
    background: var(--container-bg);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.9rem center;
    background-size: 0.75rem;
    color: var(--text);
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.12);
    transition: border 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
    min-width: 0;
}

.preset-select select:hover {
    border-color: rgba(96, 165, 250, 0.6);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.18);
}

.preset-select select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.preset-use-current-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-left: auto;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    padding-top: 0;
    padding-bottom: 0.1rem;
    white-space: nowrap;
}

.preset-use-current-toggle input {
    width: 1.05rem;
    height: 1.05rem;
    accent-color: var(--primary);
}

.preset-form-row input {
    border-radius: 0.65rem;
    border: 1px solid var(--border);
    padding: 0.55rem 0.85rem;
    font-size: 0.95rem;
    font-weight: 600;
    background: var(--container-bg);
    color: var(--text);
    box-shadow: none;
    transition: border 0.18s ease, box-shadow 0.18s ease;
}

.preset-form-row input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}

.preset-form-row input:disabled,
.preset-form .preset-select select:disabled {
    background-color: rgba(148, 163, 184, 0.15);
    border-color: rgba(148, 163, 184, 0.4);
    color: var(--text-secondary);
    cursor: not-allowed;
    box-shadow: none;
}

.preset-form-row input:disabled::-webkit-inner-spin-button,
.preset-form-row input:disabled::-webkit-outer-spin-button {
    opacity: 0.4;
}

.preset-form-row input:disabled::-webkit-input-placeholder {
    color: var(--text-secondary);
}

.preset-form-row input:disabled::placeholder {
    color: var(--text-secondary);
}

.preset-form-grid {
    gap: 0.75rem;
}

.preset-form-grid label {
    flex: 1;
}

.preset-form-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.preset-save-button {
    padding: 0.65rem 1.2rem;
    border-radius: 0.65rem;
    border: none;
    font-weight: 600;
    cursor: pointer;
    background: var(--primary);
    color: white;
    width: 100%;
}

.preset-save-button:hover {
    background: var(--primary-hover);
}

.preset-sort {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.preset-sort-controls {
    display: flex;
    gap: 0.65rem;
    align-items: stretch;
}

.preset-sort select {
    flex: 1;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    border-radius: 0.7rem;
    border: 2px solid var(--border);
    padding: 0.55rem 2.5rem 0.55rem 1rem;
    background: var(--container-bg);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.9rem center;
    background-size: 0.75rem;
    color: var(--text);
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.1);
    font-weight: 600;
    font-size: 1rem;
    font-family: inherit;
    transition: border 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.preset-sort select:hover {
    border-color: rgba(96, 165, 250, 0.6);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.18);
}

.preset-sort select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.preset-group-toggle {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    border: 1px solid var(--border);
    padding: 0.5rem 0.8rem;
    border-radius: 0.65rem;
    background: color-mix(in srgb, var(--accent-soft) 40%, transparent);
    color: var(--text);
    cursor: pointer;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, color 0.18s ease;
    align-self: stretch;
}

.preset-group-toggle input {
    accent-color: var(--primary);
}

.preset-group-toggle span {
    font-weight: 600;
    color: var(--text-secondary);
    transition: color 0.18s ease;
}

.preset-group-toggle:hover,
.preset-group-toggle:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);
}

.preset-group-toggle input:checked + span {
    color: var(--primary);
}

.preset-list {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    flex: 1 1 auto;
}

.preset-section {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.preset-section__title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.preset-item {
    border: 1px solid var(--border);
    border-radius: 0.85rem;
    background: var(--container-bg);
    padding: 0.8rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    box-shadow: none;
    transition: border-color 0.18s ease, background-color 0.18s ease;
}

.preset-item:hover,
.preset-item:focus-within {
    border-color: var(--primary);
    background: color-mix(in srgb, var(--accent-soft) 38%, transparent);
}

.preset-item__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.preset-item__title {
    font-size: 1rem;
    font-weight: 600;
}

.preset-item__meta {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    flex-wrap: wrap;
}

.preset-item__actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.preset-item__button {
    flex: 1 1 120px;
    border-radius: 0.65rem;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    font-weight: 600;
    padding: 0.45rem 0.75rem;
    cursor: pointer;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, color 0.18s ease;
}

.preset-item__button:hover,
.preset-item__button:focus-visible {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
    background: transparent;
}

.preset-item__button--danger {
    border-color: rgba(248, 113, 113, 0.4);
    color: #b91c1c;
}

.preset-item__button--danger:hover,
.preset-item__button--danger:focus-visible {
    border-color: rgba(220, 38, 38, 0.65);
    box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.25);
}

.preset-item__button--primary {
    border-color: var(--primary);
    color: var(--primary);
}

.preset-item__button--primary:hover,
.preset-item__button--primary:focus-visible {
    background: transparent;
}

.preset-item__order-controls {
    display: inline-flex;
    gap: 0.35rem;
}

.preset-item__order-button {
    width: 2rem;
    height: 2rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.18s ease, color 0.18s ease;
}

.preset-item__order-button:hover,
.preset-item__order-button:focus-visible {
    border-color: var(--primary);
    color: var(--primary);
}

.preset-empty {
    font-size: 0.95rem;
    color: var(--text-secondary);
    text-align: center;
    border: 1px dashed var(--border);
    border-radius: 0.85rem;
    padding: 1.25rem;
}

.custom-alert {
    position: fixed;
    inset: 0;
    padding: 1rem;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.custom-alert.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.custom-alert__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
}

.custom-alert__content {
    position: relative;
    background: var(--container-bg);
    border-radius: 1rem;
    padding: 1.5rem;
    max-width: 420px;
    width: calc(100% - 2rem);
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.25);
    transform: scale(0.95);
    transition: transform 0.25s ease;
}

.custom-alert.is-open .custom-alert__content {
    transform: scale(1);
}

.custom-alert__title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.75rem;
}

.custom-alert__message {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 1.5rem;
}

.custom-alert__actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.custom-alert__button {
    padding: 0.65rem 1.2rem;
    border-radius: 0.65rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s ease;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
}

.custom-alert__button:hover,
.custom-alert__button:focus-visible {
    border-color: var(--primary);
    color: var(--primary);
    background: transparent;
}

.custom-alert__button--primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.custom-alert__button--primary:hover,
.custom-alert__button--primary:focus-visible {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
    color: white;
}

.custom-alert__button--danger {
    background: transparent;
    color: #dc2626;
    border-color: rgba(220, 38, 38, 0.7);
}

.custom-alert__button--danger:hover,
.custom-alert__button--danger:focus-visible {
    border-color: #dc2626;
    color: #dc2626;
    box-shadow: 0 0 0 2px rgba(248, 113, 113, 0.25);
    background: transparent;
}

.preset-panel__body.is-dragover,
.theme-panel__body.is-dragover,
#customThemeSection.is-dragover {
    position: relative;
    outline: 2px dashed var(--primary);
    outline-offset: 6px;
}

.preset-panel__body.is-dragover::after,
.theme-panel__body.is-dragover::after,
#customThemeSection.is-dragover::after {
    content: "Drop JSON to import";
    position: absolute;
    inset: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 1rem;
    background: rgba(59, 130, 246, 0.08);
    color: var(--primary);
    font-weight: 600;
    pointer-events: none;
}

@media (max-width: 720px) {
    .preset-panel__content,
    .theme-panel__content,
    .settings-panel__content {
        width: 100%;
        padding: 1.75rem 1.25rem 2.25rem;
    }

    .preset-actions {
        flex-direction: column;
    }

    .preset-action-button {
        width: 100%;
    }

    .preset-io,
    .theme-io {
        grid-template-columns: 1fr;
    }

    .preset-item__actions {
        justify-content: flex-start;
    }

    .preset-item__button {
        flex: 0 1 auto;
    }

}

@media (max-width: 600px) {
    .header-actions {
        gap: 0.5rem;
    }

    .preset-panel__content,
    .theme-panel__content,
    .settings-panel__content {
        border-radius: 0;
        box-shadow: none;
        bottom: 0;
        top: auto;
        height: 100%;
        width: 100%;
        right: 0;
        left: 0;
        transform: translateY(100%);
        padding-top: calc(1.5rem + env(safe-area-inset-top));
        padding-bottom: calc(2.5rem + env(safe-area-inset-bottom));
    }

    .preset-panel__body,
    .theme-panel__body,
    .settings-panel__body {
        padding-right: 0;
    }

    .preset-panel.is-open .preset-panel__content,
    .theme-panel.is-open .theme-panel__content,
    .settings-panel.is-open .settings-panel__content {
        transform: translateY(0);
    }

    .preset-panel.is-closing .preset-panel__content,
    .theme-panel.is-closing .theme-panel__content,
    .settings-panel.is-closing .settings-panel__content {
        transform: translateY(100%);
    }
}

@media (max-width: 600px) {
    body {
        background: var(--container-bg);
        padding: 0;
    }

    .container {
        max-width: none;
        min-height: 100vh;
        border-radius: 0;
        box-shadow: none;
        padding: 2rem 1.5rem 2.5rem;
    }

    .header-container {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 1.5rem;
    }

    .brand {
        justify-content: flex-start;
    }

    .brand header {
        width: 100%;
    }

    .brand-title-row {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .theme-selector {
        align-self: flex-start;
    }

    .beat-display {
        font-size: 4.5rem;
    }

    .controls {
        gap: 1rem;
    }

    footer {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
        gap: 1rem;
    }

    .footer-links {
        justify-content: center;
        width: 100%;
        gap: 0.75rem;
    }

    .footer-lines {
        width: 100%;
    }

    .volume-label {
        flex: 0 0 7.5rem;
        max-width: 7.5rem;
    }
}
