/* Moderne Farbpalette & Variablen */
:root {
    --primary: #ef4444;
    --primary-hover: #dc2626;
    --bg-color: #f3f4f6;
    --card-bg: #ffffff;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
    --focus-ring: rgba(239, 68, 68, 0.2);
    --success: #10b981;
}

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-color);
    color: var(--text-main);
    margin: 0;
    padding: 30px 20px;
    line-height: 1.5;
    overflow-y: scroll;
}

.container { max-width: 1100px; margin: 0 auto; }

h2 { text-align: center; margin-bottom: 30px; font-size: 28px; font-weight: 700; color: #111827; }

h3 { margin-top: 0; font-size: 18px; color: #111827; border-bottom: 2px solid var(--bg-color); padding-bottom: 10px; margin-bottom: 20px; }

/* Symmetrisches Grid-Layout */
.grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
    align-items: stretch;
}

.card {
    background: var(--card-bg);
    padding: 28px;
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03);
    display: flex;
    flex-direction: column;
    min-width: 0;
}



@media (max-width: 850px) {
    .grid { grid-template-columns: minmax(0, 1fr); }
    .card { min-height: 400px; }
}

/* Formular-Elemente */
input[type="text"], select {
    width: 100%;
    padding: 12px 16px;
    margin: 0 0 16px 0;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-sizing: border-box;
    font-size: 15px;
    background-color: #f9fafb;
    transition: all 0.2s ease;
}

.form-row { display: flex; gap: 12px; margin-bottom: 16px; }
.form-row select { margin: 0; }

input[type="text"]:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    background-color: #ffffff;
    box-shadow: 0 0 0 4px var(--focus-ring);
}

button {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 15px;
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

button:hover:not(:disabled) { background: var(--primary-hover); transform: translateY(-1px); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { background: #9ca3af; cursor: not-allowed; transform: none; opacity: 0.8; }

.search-row { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; }
.search-row input { margin: 0; flex-grow: 1; }
.search-row button { margin: 0; width: 130px; flex-shrink: 0; }

hr { border: 0; height: 1px; background: var(--border-color); margin: 30px 0; }

/* Suchergebnisse Styling */
#searchResults { max-height: 380px; overflow-y: auto; padding-right: 5px; }

.result-item {
    display: flex;
    align-items: flex-start;
    background: #ffffff;
    padding: 12px;
    margin-bottom: 12px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.result-item:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.06); border-color: #d1d5db; }

.result-item img {
    width: 120px;
    aspect-ratio: 16/9;
    object-fit: cover;
    border-radius: 6px;
    margin-right: 15px;
    flex-shrink: 0;
    background: #e5e7eb;
}

.result-info { flex-grow: 1; display: flex; flex-direction: column; justify-content: space-between; min-height: 68px; min-width: 0; }
.result-title { font-weight: 600; font-size: 14px; margin: 0 0 4px 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.4; word-break: break-word; }
.result-meta { font-size: 12px; color: var(--text-muted); margin: 0 0 8px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; gap: 8px; }

.btn-dl-small { width: max-content; padding: 6px 14px; font-size: 12px; border-radius: 6px; background: #111827; }
.btn-dl-small:hover { background: #374151; }

/* Log Fenster */
.log-box {
    background: #111827;
    color: #34d399;
    padding: 20px;
    border-radius: 12px;
    font-family: 'Consolas', 'Courier New', monospace;
    flex-grow: 1;

    max-height: 400px;
    height: 400px;
    overflow-y: auto;

    white-space: pre-wrap;
    word-break: break-all;
    font-size: 13px;
    line-height: 1.6;
    box-shadow: inset 0 4px 6px rgba(0,0,0,0.2);
}

.fallback-btn {
    display: inline-block;
    margin-top: 12px;
    padding: 10px 20px;
    background: var(--success);
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-weight: bold;
    transition: 0.2s;
}

.fallback-btn:hover { background: #059669; }

/* Styling für den finalen Download-Button */
.btn-success {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 16px;
    background: var(--success);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: bold;
    font-size: 16px;
    transition: all 0.2s ease;
    box-sizing: border-box;
    box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
    background: #059669;
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(16, 185, 129, 0.4);
}

.btn-success:active {
    transform: translateY(1px);
}

/* Textarea Styling (Playlists) */
textarea {
    width: 100%;
    padding: 12px 16px;
    margin: 0 0 16px 0;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-sizing: border-box;
    font-size: 14px;
    background-color: #f9fafb;
    transition: all 0.2s ease;
    font-family: 'Consolas', 'Courier New', monospace; /* Monospace für URLs besser lesbar */
    resize: vertical;
    white-space: pre;
    overflow-wrap: normal;
    overflow-x: auto;
}

textarea:focus {
    outline: none;
    border-color: var(--primary);
    background-color: #ffffff;
    box-shadow: 0 0 0 4px var(--focus-ring);
}

/* Layout für die Speichern-Zeile */
.save-row {
    display: flex;
    align-items: center;
    gap: 16px;
}

.save-row button {
    width: auto;
    padding: 12px 24px;
}

.status-text {
    color: var(--success);
    font-weight: 600;
    font-size: 14px;
}

/* Volle Breite für Karten im Grid erzwingen (für die Playlist-Karte) */
.full-width {
    grid-column: 1 / -1;
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
.log-box::-webkit-scrollbar-thumb { background: #4b5563; }
.log-box::-webkit-scrollbar-thumb:hover { background: #6b7280; }