:root {
    color-scheme: dark;
    --bg: #050711;
    --bg-deep: #02030a;
    --surface: rgba(12, 18, 34, 0.72);
    --surface-strong: rgba(18, 27, 48, 0.84);
    --surface-soft: rgba(255, 255, 255, 0.055);
    --panel: rgba(255, 255, 255, 0.075);
    --panel-strong: rgba(255, 255, 255, 0.105);
    --border: rgba(190, 220, 255, 0.16);
    --border-strong: rgba(88, 226, 255, 0.36);
    --text: #f4f8ff;
    --text-soft: #d9e5f6;
    --muted: #91a4bf;
    --muted-strong: #b5c5dc;
    --cyan: #27f3ff;
    --blue: #4c8dff;
    --violet: #8d5cff;
    --pink: #ff3bd4;
    --red: #ff2f67;
    --red-dark: #b91543;
    --green: #4cffb0;
    --warning: #ffd166;
    --danger: #ff6b8a;
    --shadow: 0 28px 90px rgba(0, 0, 0, 0.46);
    --shadow-soft: 0 18px 54px rgba(0, 0, 0, 0.28);
    --radius-xl: 30px;
    --radius-lg: 24px;
    --radius-md: 18px;
    --radius-pill: 999px;
    --gradient-accent: linear-gradient(135deg, var(--cyan), var(--blue) 38%, var(--violet) 68%, var(--pink));
    --gradient-danger: linear-gradient(135deg, #ff477e, #ff2f67 46%, #b91543);
    --focus-ring: 0 0 0 3px rgba(39, 243, 255, 0.18), 0 0 0 1px rgba(39, 243, 255, 0.78);
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    background: var(--bg-deep);
}

body {
    position: relative;
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden;
    color: var(--text);
    font-family: "Segoe UI Variable", "Segoe UI", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background:
        radial-gradient(circle at 12% 8%, rgba(39, 243, 255, 0.20), transparent 26rem),
        radial-gradient(circle at 86% 12%, rgba(255, 59, 212, 0.16), transparent 28rem),
        radial-gradient(circle at 52% 98%, rgba(76, 141, 255, 0.18), transparent 34rem),
        linear-gradient(145deg, #03040b 0%, #071023 45%, #10091f 100%);
    text-rendering: geometricPrecision;
}

body::before,
body::after {
    position: fixed;
    z-index: -1;
    width: 34rem;
    height: 34rem;
    border-radius: 50%;
    pointer-events: none;
    content: "";
    filter: blur(22px);
    opacity: 0.5;
}

body::before {
    top: -14rem;
    left: -12rem;
    background: radial-gradient(circle, rgba(39, 243, 255, 0.26), transparent 68%);
}

body::after {
    right: -15rem;
    bottom: -16rem;
    background: radial-gradient(circle, rgba(255, 59, 212, 0.22), transparent 68%);
}

a {
    color: inherit;
}

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

button,
a,
summary {
    -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* App shell and primary cards */
.shell {
    width: min(1180px, calc(100% - clamp(28px, 5vw, 56px)));
    margin: 0 auto;
    padding: clamp(24px, 5vw, 56px) 0 clamp(44px, 7vw, 76px);
}

.hero,
.panel,
.login-card {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border);
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.11), rgba(255, 255, 255, 0.045)),
        var(--surface);
    box-shadow: var(--shadow);
    backdrop-filter: blur(22px) saturate(140%);
}

.hero::before,
.panel::before,
.login-card::before {
    position: absolute;
    inset: 0;
    pointer-events: none;
    content: "";
    background:
        linear-gradient(135deg, rgba(39, 243, 255, 0.13), transparent 34%),
        radial-gradient(circle at 85% 0%, rgba(255, 59, 212, 0.14), transparent 30rem);
    opacity: 0.78;
}

.hero > *,
.panel > *,
.login-card > * {
    position: relative;
    z-index: 1;
}

.hero {
    display: grid;
    gap: clamp(18px, 4vw, 30px);
    align-items: end;
    padding: clamp(26px, 6vw, 58px);
    margin-bottom: clamp(18px, 3vw, 26px);
    border-radius: var(--radius-xl);
}

.panel {
    padding: clamp(20px, 4vw, 30px);
    margin-bottom: 20px;
    border-radius: var(--radius-lg);
}

.form-panel {
    display: grid;
    gap: 22px;
}

.login-card {
    width: min(460px, calc(100% - 32px));
    margin: 12vh auto;
    padding: clamp(24px, 5vw, 34px);
    border-radius: var(--radius-xl);
}

/* Typography */
h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    display: block;
    max-width: 900px;
    margin-bottom: 14px;
    padding-bottom: 0.12em;
    color: transparent;
    font-size: clamp(2.1rem, 13vw, 4rem);
    line-height: 1.08;
    letter-spacing: -0.055em;
    background: var(--gradient-accent);
    background-clip: text;
    -webkit-background-clip: text;
    filter: drop-shadow(0 0 24px rgba(39, 243, 255, 0.10));
}

h2 {
    margin-bottom: 18px;
    color: var(--text);
    font-size: clamp(1.18rem, 3vw, 1.55rem);
    letter-spacing: -0.025em;
}

h3 {
    color: var(--text);
    letter-spacing: -0.015em;
}

p,
.muted {
    max-width: 760px;
    color: var(--muted);
    line-height: 1.68;
}

.eyebrow {
    display: inline-flex;
    width: fit-content;
    align-items: center;
    gap: 8px;
    padding: 7px 11px;
    margin: 0 0 13px;
    border: 1px solid rgba(39, 243, 255, 0.22);
    border-radius: var(--radius-pill);
    color: #dffbff;
    background: rgba(39, 243, 255, 0.08);
    box-shadow: 0 0 28px rgba(39, 243, 255, 0.08);
    font-size: 0.74rem;
    font-weight: 900;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.eyebrow::before {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--cyan);
    box-shadow: 0 0 16px var(--cyan);
    content: "";
}

/* Buttons and action groups */
.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-start;
}

.hero-actions-vertical {
    flex-direction: column;
    align-items: stretch;
}

.hero-actions-vertical .button,
.hero-actions-vertical form {
    width: 100%;
}

.button {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border: 1px solid rgba(190, 220, 255, 0.18);
    border-radius: var(--radius-pill);
    color: var(--text);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.11), rgba(255, 255, 255, 0.045)),
        rgba(10, 16, 30, 0.74);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.10), 0 12px 28px rgba(0, 0, 0, 0.18);
    text-decoration: none;
    cursor: pointer;
    transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.button:hover {
    border-color: rgba(39, 243, 255, 0.42);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.13), 0 16px 34px rgba(39, 243, 255, 0.09);
    transform: translateY(-1px);
}

.button:active {
    transform: translateY(0);
}

.button:disabled {
    opacity: 0.48;
    cursor: not-allowed;
    transform: none;
}

.button-primary {
    border: 0;
    color: #ffffff;
    background: var(--gradient-accent);
    box-shadow: 0 14px 36px rgba(39, 243, 255, 0.14), 0 10px 36px rgba(255, 59, 212, 0.11);
    font-weight: 900;
}

.button-primary:hover {
    box-shadow: 0 18px 46px rgba(39, 243, 255, 0.18), 0 14px 42px rgba(255, 59, 212, 0.16);
}

.button-danger {
    border-color: rgba(255, 107, 138, 0.40);
    color: #ffeaf0;
    background:
        linear-gradient(135deg, rgba(255, 107, 138, 0.18), rgba(255, 47, 103, 0.08)),
        rgba(28, 8, 19, 0.70);
    font-weight: 900;
}

.button-badge,
.count-badge {
    display: inline-grid;
    place-items: center;
    border-radius: var(--radius-pill);
    color: #fff;
    background: var(--gradient-accent);
    font-weight: 950;
}

.button-badge {
    min-width: 24px;
    min-height: 22px;
    padding: 2px 7px;
    margin-left: 4px;
    font-size: 0.78rem;
}

.count-badge {
    min-width: 34px;
    min-height: 28px;
    padding: 3px 10px;
    margin-left: 8px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    font-size: 0.88rem;
    vertical-align: middle;
}

/* Forms */
.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.field {
    display: grid;
    min-width: 0;
    gap: 8px;
}

.field-wide {
    grid-column: 1 / -1;
}

.field span {
    color: var(--muted-strong);
    font-size: 0.84rem;
    font-weight: 850;
}

.field input,
.field select,
.field textarea,
.password-change-form input,
.role-change-form select {
    width: 100%;
    min-height: 48px;
    padding: 0 15px;
    border: 1px solid rgba(190, 220, 255, 0.17);
    border-radius: 16px;
    color: var(--text);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.035)),
        rgba(3, 7, 17, 0.58);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), inset 0 -16px 34px rgba(0, 0, 0, 0.10);
    outline: none;
    transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.field textarea {
    min-height: 122px;
    padding-top: 13px;
    resize: vertical;
}

.field input::placeholder,
.field textarea::placeholder {
    color: rgba(181, 197, 220, 0.58);
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.password-change-form input:focus,
.role-change-form select:focus {
    border-color: rgba(39, 243, 255, 0.62);
    box-shadow: var(--focus-ring), inset 0 1px 0 rgba(255, 255, 255, 0.09);
}

.field small {
    color: var(--muted);
    font-size: 0.78rem;
    line-height: 1.45;
}

.field select,
.role-change-form select {
    color: #ffffff;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.105), rgba(255, 255, 255, 0.045)),
        #10182b;
    color-scheme: dark;
}

.field select option,
.role-change-form select option {
    color: #ffffff;
    background: #10182b;
}

.field select:disabled {
    color: color-mix(in srgb, var(--muted) 70%, white);
    opacity: 0.65;
}

.duration-field {
    min-width: 0;
}

.duration-picker {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 8px;
    align-items: center;
    padding: 4px;
    border: 1px solid rgba(190, 220, 255, 0.13);
    border-radius: 18px;
    background: rgba(2, 6, 16, 0.30);
}

.duration-picker label {
    min-width: 0;
}

.duration-picker select {
    border-color: transparent;
    background: rgba(255, 255, 255, 0.055);
}

.duration-separator {
    color: var(--cyan);
    font-size: 1.35rem;
    font-weight: 950;
    line-height: 1;
    text-shadow: 0 0 16px rgba(39, 243, 255, 0.42);
}

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

/* Feedback and stats */
.queue-count-card {
    display: flex;
    width: 100%;
    gap: 14px;
    align-items: center;
    padding: 18px 20px;
    margin-bottom: 18px;
    border: 1px solid rgba(39, 243, 255, 0.24);
    border-radius: var(--radius-lg);
    color: var(--muted-strong);
    background:
        linear-gradient(135deg, rgba(39, 243, 255, 0.13), rgba(141, 92, 255, 0.10) 52%, rgba(255, 59, 212, 0.09)),
        rgba(255, 255, 255, 0.055);
    box-shadow: 0 18px 48px rgba(39, 243, 255, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.10);
    backdrop-filter: blur(18px);
}

.queue-count-card strong {
    color: var(--text);
    font-size: clamp(2.15rem, 8vw, 3.15rem);
    line-height: 1;
    text-shadow: 0 0 24px rgba(39, 243, 255, 0.24);
}

.flash,
.form-message {
    display: flex;
    grid-column: 1 / -1;
    min-height: 48px;
    align-items: center;
    padding: 12px 16px;
    border: 1px solid rgba(76, 255, 176, 0.40);
    border-radius: 16px;
    color: #dffff0;
    background: rgba(76, 255, 176, 0.12);
    line-height: 1.35;
}

.form-message[hidden] {
    display: none;
}

.flash-error,
.form-message-error,
.form-message.is-error {
    border-color: rgba(255, 107, 138, 0.52);
    color: #ffe8ee;
    background: rgba(255, 107, 138, 0.14);
}

.form-message.is-info {
    border-color: rgba(76, 141, 255, 0.48);
    color: #e7f0ff;
    background: rgba(76, 141, 255, 0.13);
}

.form-message.is-success {
    border-color: rgba(76, 255, 176, 0.48);
    color: #dffff0;
    background: rgba(76, 255, 176, 0.13);
}

.closed-panel {
    border-color: rgba(255, 47, 103, 0.55);
    background:
        linear-gradient(135deg, rgba(255, 47, 103, 0.16), rgba(255, 59, 212, 0.08)),
        var(--surface);
}

.closed-panel .eyebrow {
    border-color: rgba(255, 47, 103, 0.34);
    background: rgba(255, 47, 103, 0.10);
}

.closed-panel .eyebrow::before {
    background: var(--red);
    box-shadow: 0 0 16px var(--red);
}

.closed-panel h2 {
    margin-bottom: 0;
}

/* Queue and lists */
.song-list,
.user-list,
.public-queue,
.application-list {
    display: grid;
    gap: 12px;
}

.song-row,
.user-row,
.public-queue-row,
.application-card {
    border: 1px solid rgba(190, 220, 255, 0.14);
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.085), rgba(255, 255, 255, 0.035)),
        var(--surface-strong);
    box-shadow: var(--shadow-soft);
}

.song-row,
.user-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    align-items: center;
    padding: 16px;
    border-radius: var(--radius-lg);
}

.song-row[draggable="true"] {
    cursor: grab;
}

.song-row[draggable="true"]:active {
    cursor: grabbing;
}

.song-row.is-dragging {
    opacity: 0.55;
    border-style: dashed;
    transform: scale(0.99);
}

.song-row.is-skipped,
.public-queue-row.is-priority {
    border-color: color-mix(in srgb, var(--warning) 66%, white);
    animation: skipped-track-pulse 1.8s ease-in-out infinite;
    box-shadow:
        0 0 0 1px rgba(255, 209, 102, 0.32),
        0 0 26px rgba(255, 209, 102, 0.22),
        0 0 58px rgba(255, 46, 86, 0.10);
}

@keyframes skipped-track-pulse {
    0%,
    100% {
        border-color: color-mix(in srgb, var(--warning) 62%, white);
        box-shadow:
            0 0 0 1px rgba(255, 209, 102, 0.30),
            0 0 22px rgba(255, 209, 102, 0.18),
            0 0 52px rgba(255, 46, 86, 0.08);
    }

    50% {
        border-color: color-mix(in srgb, var(--warning) 86%, white);
        box-shadow:
            0 0 0 2px rgba(255, 209, 102, 0.55),
            0 0 34px rgba(255, 209, 102, 0.42),
            0 0 78px rgba(255, 46, 86, 0.18);
    }
}

.public-queue-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 14px;
    align-items: center;
    padding: 14px;
    border-radius: 18px;
}

.queue-position {
    display: inline-grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border-radius: 50%;
    color: #061018;
    background: var(--gradient-accent);
    box-shadow: 0 0 22px rgba(39, 243, 255, 0.20);
    font-weight: 950;
    user-select: none;
}

.song-row[draggable="true"] .queue-position {
    cursor: grab;
}

.public-queue-row div {
    display: grid;
    min-width: 0;
    gap: 4px;
}

.public-queue-row strong,
.song-link-row a {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.public-queue-row span:not(.queue-position) {
    color: var(--muted);
    font-size: 0.9rem;
}

.song-main {
    min-width: 0;
}

.song-main h3 {
    margin-bottom: 7px;
    font-size: 1.12rem;
}

.song-main p {
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 0.92rem;
}

.song-main .song-played-at {
    color: var(--text-soft);
    font-weight: 800;
}

.song-link-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 8px;
    align-items: center;
    max-width: 820px;
}

.song-link-row a {
    display: block;
    color: var(--cyan);
    font-size: 0.9rem;
}

.copy-link-button,
.play-link-button {
    display: inline-grid;
    width: 36px;
    height: 36px;
    place-items: center;
    padding: 0;
    border: 1px solid rgba(190, 220, 255, 0.18);
    border-radius: 13px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
    cursor: pointer;
    text-decoration: none;
    font-size: 0.95rem;
    line-height: 1;
    transition: border-color 160ms ease, transform 160ms ease, background 160ms ease;
}

.copy-link-button:hover,
.play-link-button:hover {
    border-color: rgba(39, 243, 255, 0.44);
    background: rgba(39, 243, 255, 0.10);
    transform: translateY(-1px);
}

.copy-link-button[data-copied="1"] {
    color: #061018;
    background: var(--green);
}

.play-link-button span {
    display: block;
    line-height: 1;
    transform: translate(1px, 1.5px);
}

.platform {
    display: inline-flex;
    width: fit-content;
    margin-bottom: 8px;
    padding: 5px 10px;
    border-radius: var(--radius-pill);
    color: #07101f;
    background: var(--gradient-accent);
    font-size: 0.72rem;
    font-weight: 950;
    text-transform: uppercase;
}

.song-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-start;
}

/* Users, settings and applications */
.panel-head {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

.panel-head h2 {
    margin-bottom: 0;
}

.user-form,
.settings-form {
    margin-bottom: 22px;
}

.settings-divider {
    padding-top: 8px;
    border-top: 1px solid rgba(190, 220, 255, 0.14);
}

.user-row div {
    display: grid;
    gap: 4px;
}

.user-row span {
    color: var(--muted);
    font-size: 0.9rem;
}

.user-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.password-change-form,
.role-change-form {
    display: flex;
    min-width: min(100%, 430px);
    flex: 1;
    gap: 10px;
}

.application-columns {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.application-card {
    padding: 16px;
    border-radius: var(--radius-lg);
}

.application-card[open] {
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.22);
}

.application-summary {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    align-items: center;
    cursor: pointer;
    list-style: none;
}

.application-summary::-webkit-details-marker {
    display: none;
}

.application-summary::after {
    display: inline-grid;
    width: 30px;
    height: 30px;
    place-items: center;
    border: 1px solid rgba(190, 220, 255, 0.18);
    border-radius: var(--radius-pill);
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
    font-weight: 950;
    content: "+";
}

.application-card[open] .application-summary::after {
    content: "-";
}

.application-summary > span:not(.platform) {
    overflow: hidden;
    color: var(--muted);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.application-details {
    padding-top: 16px;
}

.application-card h3,
.application-card p {
    margin-bottom: 8px;
}

.application-message {
    white-space: pre-wrap;
}

.application-card a {
    color: var(--cyan);
}

/* Footer */
.site-footer {
    margin-top: 26px;
    color: color-mix(in srgb, var(--muted) 68%, transparent);
    font-size: 0.74rem;
    text-align: center;
}

.site-footer-fixed {
    position: fixed;
    right: 14px;
    bottom: 10px;
    left: 14px;
    pointer-events: none;
}

/* Responsive refinements */
@media (min-width: 680px) {
    .hero {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .hero-actions {
        justify-content: flex-end;
    }

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

    .song-row {
        grid-template-columns: auto minmax(0, 1fr) auto;
        padding: 18px;
    }

    .song-actions {
        justify-content: flex-end;
    }

    .application-summary {
        grid-template-columns: auto minmax(140px, 1fr) minmax(120px, auto) minmax(160px, auto) auto;
    }
}

@media (min-width: 980px) {
    h1 {
        font-size: clamp(3rem, 5.8vw, 5.25rem);
    }
}

@media (max-width: 760px) {
    .shell {
        width: min(100% - 24px, 1180px);
        padding-top: 18px;
    }

    .hero {
        align-items: start;
    }

    .hero-actions,
    .hero-actions .button,
    .hero-actions form {
        width: 100%;
    }

    .button {
        width: 100%;
    }

    .song-row .queue-position {
        width: 34px;
        height: 34px;
    }

    .password-change-form,
    .role-change-form {
        min-width: 100%;
        flex-direction: column;
    }

    .song-link-row {
        grid-template-columns: minmax(0, 1fr) auto auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
