:root {
    --ui-modal-bg: linear-gradient(160deg, rgba(42, 50, 61, 0.98), rgba(24, 30, 38, 0.98));
    --ui-modal-border: rgba(255, 215, 0, 0.28);
    --ui-modal-border-soft: rgba(255, 255, 255, 0.08);
    --ui-modal-text: #f1f3f5;
    --ui-modal-muted: #adb5bd;
    --ui-modal-highlight: #ffd166;
    --ui-modal-shadow: 0 22px 54px rgba(0, 0, 0, 0.5);
}

.modal-backdrop.show {
    opacity: 0.65;
    backdrop-filter: blur(2px);
}

.modal .modal-dialog {
    margin-top: 6vh;
}

.modal.fade .modal-dialog {
    transform: translateY(12px) scale(0.98);
    transition: transform 0.24s ease-out, opacity 0.24s ease-out;
}

.modal.show .modal-dialog {
    transform: translateY(0) scale(1);
}

.modal .modal-content {
    background: var(--ui-modal-bg);
    color: var(--ui-modal-text);
    border: 1px solid var(--ui-modal-border);
    border-radius: 16px;
    box-shadow: var(--ui-modal-shadow), inset 0 0 0 1px var(--ui-modal-border-soft);
    overflow: hidden;
}

.modal .modal-header,
.modal .modal-footer {
    border-color: rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.02);
}

.modal .modal-title {
    color: var(--ui-modal-highlight);
    font-weight: 700;
    letter-spacing: 0.01em;
}

.modal .modal-body {
    color: var(--ui-modal-text);
}

.modal .form-label,
.modal label {
    color: var(--ui-modal-text) !important;
    font-weight: 600;
}

.modal .form-text,
.modal .text-muted {
    color: var(--ui-modal-muted) !important;
}

.modal .form-control,
.modal .form-select {
    background: rgba(14, 19, 26, 0.86);
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: var(--ui-modal-text);
}

.modal .form-control:focus,
.modal .form-select:focus {
    border-color: rgba(255, 209, 102, 0.72);
    box-shadow: 0 0 0 0.2rem rgba(255, 209, 102, 0.18);
}

.modal .btn-close {
    filter: invert(1) grayscale(1) brightness(1.1);
    opacity: 0.75;
}

.modal .btn-close:hover {
    opacity: 1;
}

.modal .btn-secondary {
    background: rgba(114, 120, 128, 0.3);
    border-color: rgba(173, 181, 189, 0.38);
    color: #f1f3f5;
}

.modal .btn-secondary:hover {
    background: rgba(134, 142, 150, 0.45);
    border-color: rgba(206, 212, 218, 0.5);
}

.modal .btn-primary,
.modal .btn-yellow {
    background: linear-gradient(135deg, #ffd166, #e6aa32);
    border-color: #e3a71a;
    color: #171b21;
    font-weight: 700;
}

.modal .btn-primary:hover,
.modal .btn-yellow:hover {
    background: linear-gradient(135deg, #ffe08a, #f0b84a);
    border-color: #f0b84a;
    color: #11151a;
}

.modal .list-group-item {
    background: rgba(17, 23, 31, 0.82);
    border-color: rgba(255, 255, 255, 0.09);
    color: var(--ui-modal-text);
}

.modal .list-group-item:hover {
    background: rgba(28, 35, 45, 0.92);
    color: #ffffff;
}

.modal .list-group-item.active {
    background: linear-gradient(135deg, rgba(255, 209, 102, 0.22), rgba(210, 151, 36, 0.2));
    border-color: rgba(255, 209, 102, 0.6);
    color: #fff3d4;
}

/* Custom track-detail edit modal (non-Bootstrap modal wrapper) */
.modal-edit.custom-width {
    width: 42%;
    max-width: 82vw;
    margin: 10vh auto 0;
}

.custom-width .modal-content {
    background: var(--ui-modal-bg);
    color: var(--ui-modal-text);
}

@media (max-width: 768px) {
    .modal .modal-dialog {
        margin-top: 1.2rem;
    }

    .modal-edit.custom-width {
        width: 92%;
        max-width: 92%;
        margin-top: 1.2rem;
    }
}
