:root {
    color-scheme: light;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: #f5f5f8;
    color: #1f1f24;
}

#topmenu {
    color: #1f1f24;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: rgba(255, 255, 255, 0.9);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 0;
    backdrop-filter: blur(12px);
    z-index: 20;
}

#topmenu a {
    color: inherit;
    text-decoration: none;
}

#topmenu .topmenu-left,
#topmenu .topmenu-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

#topmenu .topmenu-right {
    margin-left: auto;
}

#topmenu .topmenu-right:empty {
    display: none;
}

button.link-button {
    background: transparent;
    color: inherit;
    padding: 8px 14px;
    border-radius: 999px;
    transform: none;
}

button.link-button:hover {
    background: rgba(99, 102, 241, 0.12);
    transform: none;
}

button.link-button:active {
    transform: none;
}

#pagewrapper {
    max-width: 1600px;
    margin: 40px auto;
    padding: 0 24px 48px;
}

.layout {
    display: flex;
    gap: 28px;
    align-items: flex-start;
}

.layout-left,
.layout-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.layout-right {
    min-width: 320px;
}

.card {
    background: #ffffff;
    border-radius: 18px;
    padding: 28px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
    border: 1px solid rgba(15, 23, 42, 0.06);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.card-header h2 {
    margin: 0;
    font-weight: 650;
}

h1, h2, h3, h4 {
    margin: 0 0 12px;
    font-weight: 650;
}

p {
    margin: 0 0 12px;
}

.rules-list {
    padding-left: 20px;
    margin: 0 0 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.muted {
    color: #64748b;
    font-size: 14px;
}

button,
#twitch_login {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 18px;
    border-radius: 999px;
    border: none;
    font-weight: 600;
    font-size: 14px;
    background: #eef2ff;
    color: #312e81;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    text-decoration: none;
}

button:hover,
#twitch_login:hover {
    background: #c7d2fe;
    transform: translateY(-1px);
}

button:active,
#twitch_login:active {
    transform: translateY(0);
}

button.primary {
    background: #4f46e5;
    color: #ffffff;
}

button.primary:hover {
    background: #4338ca;
}

button.secondary {
    background: rgba(15, 23, 42, 0.08);
    color: #1f2937;
}

button.secondary:hover {
    background: rgba(15, 23, 42, 0.14);
}

button.danger {
    background: #fee2e2;
    color: #991b1b;
}

button.danger:hover {
    background: #fecaca;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(79, 70, 229, 0.12);
    color: #312e81;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.status-inline {
    margin-left: auto;
}

.alert {
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 14px;
    margin-bottom: 16px;
}

.alert-info {
    background: #e0f2fe;
    color: #0369a1;
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
}

.tabs {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.tab-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.tab-buttons.pills {
    background: rgba(15, 23, 42, 0.04);
    border-radius: 999px;
    padding: 6px;
}

.tab-buttons.pills .tab-button {
    border-radius: 999px;
}

.tab-button {
    padding: 10px 18px;
    border-radius: 12px;
    border: 1px solid transparent;
    background: rgba(99, 102, 241, 0.12);
    color: #312e81;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab-button:hover {
    background: rgba(99, 102, 241, 0.24);
}

.tab-button.active {
    background: #4f46e5;
    color: #fff;
    box-shadow: 0 10px 20px rgba(79, 70, 229, 0.25);
}

.tab-panel {
    display: none;
    flex-direction: column;
    gap: 16px;
}

.tab-panel.active {
    display: flex;
}

.search-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

label {
    font-weight: 600;
    display: block;
    margin-bottom: 6px;
}

input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(15, 23, 42, 0.12);
    background: #fff;
    font: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type="text"]:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.media-list,
.media-results,
.queue-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.media-item,
.queue-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    border-radius: 16px;
    background: #f8fafc;
    border: 1px solid rgba(148, 163, 184, 0.25);
}

.media-cover {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    overflow: hidden;
    flex-shrink: 0;
    background: #e0e7ff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #3730a3;
    text-transform: uppercase;
}

.media-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.media-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.media-title {
    font-weight: 600;
    font-size: 16px;
}

.media-subtitle {
    font-size: 13px;
    color: #475569;
}

.media-meta {
    font-size: 12px;
    color: #94a3b8;
}

.media-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.media-actions button {
    flex: 0 0 auto;
}

.queue-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.queue-section h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 650;
}

.queue-sublist {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.queue-link {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 16px;
    color: inherit;
    text-decoration: none;
}

.queue-item .media-content {
    min-width: 0;
}

.queue-item .media-title,
.queue-item .media-subtitle {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.queue-item .media-actions {
    margin-left: auto;
}

.accept-rules {
    margin-top: 12px;
    display: flex;
    justify-content: flex-start;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 30;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: #ffffff;
    border-radius: 20px;
    width: min(520px, 100%);
    max-height: 90vh;
    overflow-y: auto;
    padding: 28px;
    box-shadow: 0 24px 48px rgba(15, 23, 42, 0.2);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.modal-close {
    background: transparent;
    color: #475569;
    font-size: 28px;
    line-height: 1;
    padding: 4px 10px;
    transform: none;
}

.modal-close:hover {
    background: rgba(15, 23, 42, 0.06);
    transform: none;
}

.modal-close:active {
    transform: none;
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
}

body.modal-open {
    overflow: hidden;
}

.toast-container {
    position: fixed;
    right: 24px;
    bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 40;
}

.toast {
    background: #0f172a;
    color: #ffffff;
    padding: 12px 18px;
    border-radius: 14px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.25);
    transform: translateY(12px);
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s ease;
    font-size: 14px;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-success {
    background: #16a34a;
}

.toast-error {
    background: #dc2626;
}

.toast-info {
    background: #2563eb;
}

.wish-form .input-row {
    display: flex;
    gap: 10px;
}

.wish-form button {
    white-space: nowrap;
}

.queue-card {
    position: sticky;
    top: 110px;
}

.queue-card.disabled {
    opacity: 0.8;
}

.empty-state {
    padding: 18px;
    border-radius: 12px;
    text-align: center;
    border: 1px dashed rgba(148, 163, 184, 0.4);
    color: #64748b;
    background: rgba(248, 250, 252, 0.7);
}

@media (max-width: 992px) {
    #pagewrapper {
        padding: 0 16px 32px;
    }

    .layout {
        flex-direction: column;
    }

    .layout-right {
        width: 100%;
        min-width: auto;
    }

    .queue-card {
        position: static;
    }

    button,
    #twitch_login {
        width: 100%;
    }

    .wish-form .input-row {
        flex-direction: column;
    }
}
