* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --panel-bg: rgba(59, 66, 82, 0.42);
    --panel-border: rgba(216, 222, 233, 0.08);
}

body {
    background: linear-gradient(135deg, var(--color-15) 0%, var(--color-0) 100%);
    color: var(--color-4);
    font-family: var(--font-stack);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 14px;
}

.effect-wrapper {
    position: fixed;
    inset: 0;
    z-index: -1;
}

#effect-canvas {
    width: 100vw;
    height: 100vh;
    display: block;
}

.app-container {
    width: 100%;
    max-width: 980px;
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    padding: 18px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
}

.menu {
    display: flex;
    gap: 10px;
    align-items: center;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding-bottom: 16px;
}

.topbar > div {
    display: flex;
    flex-direction: column;
}

.topbar h1 {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(90deg, var(--color-5), var(--color-8));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: 0.82rem;
    color: var(--color-9);
    margin-top: 3px;
}

.main-layout {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr);
    grid-template-rows: auto auto;
    gap: 14px;
    align-items: start;
}

.page-settings .main-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
}

.page-settings .editor-panel,
.page-settings .controls-panel,
.page-settings .actions {
    grid-column: auto;
    grid-row: auto;
}

.page-library .main-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
}

.page-library .editor-panel,
.page-library .controls-panel,
.page-library .actions {
    grid-column: auto;
    grid-row: auto;
}


.editor-panel {
    grid-column: 1;
    grid-row: 1 / span 2;
    display: flex;
    flex-direction: column;
}

.controls-panel {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.actions {
    grid-column: 2;
    grid-row: 2;
    display: flex;
    gap: 10px;
    align-self: end;
}

label {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.8px;
    color: var(--color-9);
    margin-bottom: 6px;
}

textarea {
    width: 100%;
    min-height: 430px;
    padding: 12px;
    border-radius: 10px;
    background-color: var(--color-2);
    color: var(--color-5);
    border: 1px solid transparent;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
        "Liberation Mono", "Courier New", monospace;
    font-size: 0.9rem;
    line-height: 1.45;
    resize: none;
    outline: none;
    transition: 0.2s ease;
}

textarea:focus {
    border-color: var(--color-8);
    box-shadow: 0 0 0 3px rgba(136, 192, 208, 0.18);
}

#error-display {
    font-size: 0.75rem;
    color: var(--color-11);
    margin-top: 6px;
    transition: 0.2s ease;
}

.error-hidden {
    opacity: 0;
    visibility: hidden;
    height: 0;
}

.error-visible {
    opacity: 1;
    visibility: visible;
    height: auto;
}

.control-item {
    display: flex;
    flex-direction: column;
}

.control-item input[type="number"],
.control-item select {
    width: 100%;
    background-color: var(--color-2);
    color: var(--color-5);
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 0.9rem;
    outline: none;
    transition: 0.2s ease;
}

.control-item input[type="number"]:focus,
.control-item select:focus {
    border-color: var(--color-8);
}

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

.control-item input[type=number] {
    appearance: textfield;
    -moz-appearance: textfield;
    -webkit-appearance: textfield;
}

.control-item select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    cursor: pointer;
    padding-right: 36px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23cccccc' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 14px;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
}

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

input[type="range"]::-moz-range-track {
    height: 6px;
    background: var(--color-3);
    border-radius: 4px;
}

input[type="range"]::-moz-range-thumb {
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: var(--color-8);
    border: none;
    cursor: pointer;
    transition: 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb {
    transition: 0.2s ease;
}

input[type="range"]::-webkit-slider-runnable-track {
    height: 6px;
    background: var(--color-3);
    border-radius: 4px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: var(--color-8);
    margin-top: -5px;
    cursor: pointer;
    transition: 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.08);
    background: var(--color-5);
}

.combo-textbox-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    background-color: var(--color-2);
    border: 1px solid transparent;
    border-radius: 8px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease; 
    overflow: hidden; 
}

.combo-textbox-wrapper:focus-within,
.combo-textbox-wrapper:has(input:focus),
.combo-textbox-wrapper:has(select:focus) {
    border-color: var(--color-8) !important;
}

.combo-textbox-wrapper input {
    width: 100px;
    padding-right: 0;
    background: transparent;
    border: none !important; 
    outline: none !important;
    box-shadow: none !important; 
    color: var(--color-5);
    font-size: 0.9rem;
    padding: 8px 10px;
    height: 100%;
}

.combo-textbox-wrapper select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    cursor: pointer;
    width: 32px;
    padding: 0;
    background-color: transparent;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23cccccc' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 14px;
    color: transparent; 
}

button {
    flex: 1;
    padding: 10px 14px;
    border-radius: 8px;
    border: none;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-8), var(--color-9));
    color: var(--color-0);
}

.btn-primary:hover {
    filter: brightness(1.08);
}

.btn-primary.playing {
    background: var(--color-14);
}

.btn-secondary {
    background: transparent;
    color: var(--color-4);
    border: 1px solid var(--color-3);
}

.btn-secondary:hover {
    background: rgba(218, 222, 233, 0.05);
    border-color: var(--color-4);
}

@media (max-width: 820px) {
    .main-layout {
        grid-template-columns: 1fr;
    }

    .editor-panel,
    .controls-panel,
    .actions {
        grid-column: auto;
        grid-row: auto;
    }

    textarea {
        min-height: 280px;
    }

    .actions {
        margin-top: 4px;
    }
}

.library-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.library-status {
    font-size: 0.85rem;
    color: var(--color-9);
    padding: 8px 4px;
}

.repo-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-height: 600px;
    padding-right: 6px;
    overflow-y: auto;
}

.repo-list::-webkit-scrollbar {
    width: 6px;
}
.repo-list::-webkit-scrollbar-track {
    background: transparent;
}
.repo-list::-webkit-scrollbar-thumb {
    background-color: var(--panel-border);
    border-radius: 10px;
}

.repo-card {
    background: rgba(0, 0, 0, 0.12);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    overflow: hidden;
    transition: border-color 0.2s ease;
    flex-shrink: 0;
}

.repo-card:hover {
    border-color: rgba(216, 222, 233, 0.15);
}

.repo-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;
}

.repo-header:hover {
    background: rgba(255, 255, 255, 0.03);
}

.repo-meta {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.repo-name {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--color-5);
}

.repo-desc {
    font-size: 0.82rem;
    color: var(--color-9);
}

.repo-toggle-icon {
    color: var(--color-9);
    display: flex;
    align-items: center;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.repo-header.active .repo-toggle-icon {
    transform: rotate(180deg);
    color: var(--color-5);
}

.repo-drawer {
    display: flex;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.08);
    border-top: 1px solid var(--panel-border);
    max-height: 500px;
    opacity: 1;
    transition: max-height 0.25s ease-out, opacity 0.2s ease;
    overflow-y: auto;
}

.repo-drawer.collapsed {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    border-top-color: transparent;
}

.track-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    border-bottom: 1px solid rgba(216, 222, 233, 0.03);
    gap: 16px;
    flex-shrink: 0;
}

.track-item:last-child {
    border-bottom: none;
}

.track-info {
    font-size: 0.9rem;
    color: var(--color-4);
}

.track-author {
    font-size: 0.8rem;
    color: var(--color-9);
}

.track-actions {
    display: flex;
    gap: 8px;
}

.track-actions button:nth-child(n+4) {
    display: none;
}

.btn-compact {
    padding: 6px 12px;
    font-size: 0.78rem;
    border-radius: 6px;
    flex: none;
}

.error-card {
    opacity: 0.6;
    border-color: rgba(191, 97, 106, 0.2);
}

@media (max-width: 500px) {
    .app-container {
        overflow-x: hidden;
    }

    .main-layout {
        grid-template-columns: 1fr;
    }

    .menu {
        flex-direction: column;
        width: 100%;
    }

    .menu button {
        width: 100%;
        flex: none;
    }

    .actions {
        display: flex;
        flex-direction: column;
        width: 100%;
        grid-column: 1 / -1;
    }

    .actions button {
        flex: none;
        width: 100%;
    }

    textarea {
        min-height: 0;
    }
}
