:root,
[data-theme="dark"] {
    --bg-primary: #0a0a0b;
    --bg-secondary: #141416;
    --bg-tertiary: #1c1c1f;
    --text-primary: #f5f5f5;
    --text-secondary: #888;
    --accent: #22c55e;
    --accent-dim: #166534;
    --error: #ef4444;
    --warning: #f59e0b;
    --border: #2a2a2d;
}

[data-theme="light"] {
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e8e8eb;
    --text-primary: #1a1a1a;
    --text-secondary: #666;
    --accent: #16a34a;
    --accent-dim: #bbf7d0;
    --error: #dc2626;
    --warning: #d97706;
    --border: #d4d4d8;
}

/* Warning banner for misconfiguration */
.warning-banner {
    background: var(--warning);
    color: #000;
    padding: 10px 16px;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.warning-banner a {
    color: #000;
    font-weight: 600;
}

.warning-dismiss {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #000;
    opacity: 0.7;
    padding: 0 4px;
}

.warning-dismiss:hover {
    opacity: 1;
}

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

body {
    font-family: 'Outfit', -apple-system, sans-serif;
    font-size: 17px;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    line-height: 1.5;
}

a {
    color: var(--accent);
    text-decoration-color: var(--accent);
    text-underline-offset: 2px;
}

a:hover {
    color: var(--accent);
}

.container {
    max-width: 640px;
    margin: 0 auto;
    padding: 20px;
    padding-bottom: max(60px, env(safe-area-inset-bottom, 60px));
}

header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.logo {
    width: 40px;
    height: 40px;
    border-radius: 10px;
}

h1 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.search-box {
    position: relative;
    margin-bottom: 8px;
}

/* Toggle chip that reveals the playlist selector */
.playlist-selector-toggle {
    padding: 4px 10px;
    font-size: 12px;
    font-family: inherit;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.playlist-selector-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.playlist-selector-toggle.active {
    background: var(--bg-tertiary);
    border-color: var(--accent);
    color: var(--accent);
}

/* Expanded selector panel (sits inline after the toggle chip) */
.playlist-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.playlist-selector-select {
    padding: 5px 10px;
    font-size: 13px;
    font-family: inherit;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    outline: none;
    cursor: pointer;
    max-width: 280px;
}

.playlist-selector-select:focus {
    border-color: var(--accent);
}

.playlist-selector-warn {
    font-size: 12px;
    color: var(--warning, #f59e0b);
}

.playlist-selector-clear {
    padding: 3px 7px;
    font-size: 13px;
    font-family: inherit;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
}

.playlist-selector-clear:hover {
    border-color: var(--error, #ef4444);
    color: var(--error, #ef4444);
}

/* Track list panel  -  full track view per watched playlist */
.track-list-summary {
    margin-bottom: 10px;
    color: var(--text-secondary);
    font-size: 12px;
}

.track-list-section-header {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 10px 0 4px;
    padding-bottom: 3px;
    border-bottom: 1px solid var(--border);
}

.track-list-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 0;
    flex-wrap: wrap;
}

.track-list-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.track-list-actions {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-shrink: 0;
}

.track-status-chip {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
}

.track-status-ok    { color: var(--success, #22c55e); }
.track-status-fail  { color: var(--error, #ef4444); }
.track-status-pending { color: var(--text-secondary); }
.track-status-removed { color: var(--text-secondary); font-style: italic; }

.track-action-btn, .track-replace-btn {
    padding: 2px 8px;
    font-size: 12px;
    font-family: inherit;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
    color: var(--text-secondary);
}

.track-replace-btn {
    color: var(--warning, #f59e0b);
    border-color: var(--warning, #f59e0b);
}

.track-replace-btn:hover {
    background: var(--warning, #f59e0b);
    color: #000;
}

.track-action-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.search-input {
    width: 100%;
    padding: 16px 20px;
    padding-right: 140px;
    font-size: 16px;
    font-family: inherit;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

.search-input::placeholder {
    color: var(--text-secondary);
}

.search-history {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 50;
    display: none;
}

.search-history.show {
    display: block;
}

.history-item {
    padding: 12px 16px;
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background 0.2s;
}

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

.history-item:hover {
    background: var(--bg-tertiary);
}

.related-suggestions {
    margin-top: 16px;
    margin-bottom: 20px;
    padding: 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.related-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.suggestion-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.suggestion-chip {
    padding: 6px 12px;
    font-size: 13px;
    font-family: inherit;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.suggestion-chip:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.search-clear-btn {
    position: absolute;
    right: 100px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, opacity 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-clear-btn:hover {
    background: var(--border);
    color: var(--text-primary);
}

.search-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    padding: 10px 20px;
    font-size: 15px;
    font-family: inherit;
    font-weight: 600;
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.search-btn:hover {
    background: #16a34a;
}

.search-btn:active {
    transform: translateY(-50%) scale(0.98);
}

.search-btn:disabled {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: not-allowed;
}

.source-selector {
    position: absolute;
    right: 90px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 2px;
    padding: 3px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    z-index: 2;
}

.source-option {
    padding: 5px 8px;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
    line-height: 1;
}

.source-option.active {
    background: var(--accent);
    color: #000;
}

.source-option:hover:not(.active) {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.format-option {
    padding: 5px 8px;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
    line-height: 1;
}

.format-option.active {
    background: var(--accent);
    color: #000;
}

.format-option:hover:not(.active) {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

/* Tab panel transitions -- fade up on enter */
@keyframes tabFadeUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tab-panel {
    display: none;
}

.tab-panel.tab-visible {
    display: block;
    animation: tabFadeUp 0.2s ease forwards;
}

/* Results tab is a flex container */
#resultsTab.tab-panel.tab-visible {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tabs::-webkit-scrollbar {
    display: none;
}

.tab {
    padding: 8px 16px;
    font-size: 14px;
    font-family: inherit;
    font-weight: 600;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    flex: 1;
    text-align: center;
}

.tab.active {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--accent);
}

.tab:hover:not(.active) {
    color: var(--text-primary);
}

.results {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.result-item {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    padding: 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.result-item:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent);
}

/* Custom tooltip for result items */
.result-item::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
    z-index: 100;
    margin-bottom: 4px;
}

.result-item:hover::after {
    opacity: 1;
    transition-delay: 0.25s;
}

.result-item:active {
    transform: scale(0.99);
}

.result-item.downloading {
    border-color: var(--warning);
    opacity: 0.7;
    pointer-events: none;
}

.result-item.previewing {
    border-color: var(--accent);
    background: var(--bg-tertiary);
}

.result-item.loading-preview {
    border-color: var(--text-secondary);
}

.preview-indicator {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    background: rgba(34, 197, 94, 0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    opacity: 0.5;
    transition: opacity 0.2s, background 0.2s, color 0.2s;
    color: var(--accent);
}

.result-item:hover .preview-indicator {
    opacity: 1;
    background: var(--accent);
    color: #000;
}

.result-item.loading-preview .preview-indicator {
    opacity: 1;
    background: var(--text-secondary);
    color: #000;
    animation: pulse 0.8s infinite;
}

.result-item.previewing .preview-indicator {
    opacity: 1;
    background: var(--accent);
    color: #000;
    animation: pulse 1s infinite;
}

/* Mobile preview button  -  styled here, visibility controlled by .mobile-actions */
.preview-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: 12px;
    font-family: inherit;
    font-weight: 600;
    background: rgba(34, 197, 94, 0.15);
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    flex: 1;
}

.preview-btn:active {
    background: var(--accent);
    color: #000;
}

.result-item.previewing .preview-btn,
.result-item.loading-preview .preview-btn {
    background: var(--accent);
    color: #000;
}

/* Actions row  -  sits below the card content.
   On desktop: hidden by default, shows on hover with only the ~ Similar button.
   On mobile: always visible as a full-width button strip with both buttons. */
.mobile-actions {
    display: none;
    gap: 8px;
    width: 100%;
}

/* Desktop (hover-capable): show on hover  -  explore-btn only, preview-btn hidden */
@media (hover: hover) {
    .result-item:hover .mobile-actions {
        display: flex;
    }

    /* Preview is handled by hover-to-preview on desktop; keep it out of the row */
    .result-item:hover .mobile-actions .preview-btn {
        display: none;
    }
}

/* Touch devices: always show the full row with both buttons */
@media (hover: none) {
    .mobile-actions {
        display: flex;
    }

    /* Hover tooltip doesn't make sense on touch  -  hide it */
    .result-item::after {
        display: none;
    }
}

.result-thumb {
    width: 64px;
    height: 64px;
    border-radius: 8px;
    object-fit: cover;
    background: var(--bg-tertiary);
    flex-shrink: 0;
}

.result-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
}

.result-title {
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-meta {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-duration {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 4px;
    align-self: flex-start;
}

.result-badges {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-top: 4px;
}

.source-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 3px;
    text-transform: uppercase;
}

.source-badge.youtube {
    background: #ff0000;
    color: white;
}

.source-badge.soundcloud {
    background: #ff5500;
    color: white;
}

.source-badge.monochrome {
    background: #111111;
    color: white;
}

.source-badge.mp3phoenix {
    background: #e05c00;
    color: white;
}

.source-badge.soulseek {
    background: #4a9eff;
    color: white;
}

.job-source-badge {
    position: absolute;
    bottom: 2px;
    right: 2px;
    border-radius: 4px 0 10px 0;
    font-size: 10px;
    padding: 3px 7px 3px 6px;
    line-height: 1;
}

.quality-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 3px;
    background: var(--accent);
    color: white;
}

.quality-badge.hires {
    background: linear-gradient(135deg, #ffd700, #ff8c00);
    color: #000;
}

.quality-badge.flac {
    background: #ffc107;
    color: #000;
}

.quality-badge.mp3-high {
    background: #28a745;
    color: white;
}

.result-item.soulseek .result-thumb {
    background: linear-gradient(135deg, #4a9eff 0%, #2d7dd2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.result-item.soulseek .result-thumb::before {
    content: '\f58f';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    color: white;
}

.job-item {
    display: flex;
    gap: 14px;
    padding: 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    position: relative;
    overflow: hidden;
}

.job-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 6px;
}

.job-status.queued { background: var(--warning); }
.job-status.downloading {
    background: var(--warning);
    animation: pulse 1s infinite;
}
.job-status.completed { background: var(--accent); }
.job-status.completed_with_errors { background: var(--warning); }
.job-status.failed { background: var(--error); }

.job-warning-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 3px;
    background: var(--warning);
    color: #000;
    margin-left: 6px;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.job-info {
    flex: 1;
    min-width: 0;
}

.job-title {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.job-meta {
    font-size: 13px;
    color: var(--text-secondary);
}

.job-error {
    font-size: 13px;
    color: var(--error);
    margin-top: 4px;
}

.job-item.has-details {
    cursor: pointer;
    transition: background 0.15s;
}

.job-item.has-details:hover {
    background: var(--bg-hover, rgba(255,255,255,0.05));
}

.job-item.expanded {
    background: var(--bg-hover, rgba(255,255,255,0.05));
}

.job-details {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-secondary);
}

.job-details-row {
    margin-bottom: 3px;
    word-break: break-all;
}

.job-details-label {
    color: var(--text-secondary);
    opacity: 0.7;
    margin-right: 4px;
}

.job-details a {
    color: var(--accent);
    text-decoration: none;
}

.job-details a:hover {
    text-decoration: underline;
}

.job-details-url {
    opacity: 0.8;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.loading {
    display: flex;
    justify-content: center;
    padding: 40px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--bg-tertiary);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 14px 24px;
    background: var(--accent);
    color: #000;
    font-weight: 600;
    border-radius: 10px;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 100;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.error {
    background: var(--error);
    color: #fff;
}

.queue-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.clear-btn {
    padding: 8px 16px;
    font-size: 13px;
    font-family: inherit;
    font-weight: 600;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.clear-btn:hover {
    color: var(--error);
    border-color: var(--error);
}

.clear-btn:active {
    transform: scale(0.98);
}

.clear-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.bulk-textarea {
    width: 100%;
    min-height: 200px;
    max-height: 400px;
    padding: 14px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    line-height: 1.5;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    resize: vertical;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.bulk-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

.bulk-textarea::placeholder {
    color: var(--text-secondary);
    opacity: 0.5;
}

.file-upload {
    display: inline-block;
    padding: 10px 20px;
    font-size: 14px;
    font-family: inherit;
    font-weight: 600;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.file-upload:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.file-upload input[type="file"] {
    display: none;
}

.watched-controls-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
    margin-bottom: 8px;
}

.watched-control-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

.watched-select {
    padding: 6px 10px;
    font-size: 13px;
    font-family: inherit;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
}

/* Watched playlist cards */
.watched-card {
    padding: 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.watched-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.watched-card-name {
    font-weight: 600;
    flex: 1;
}

.watched-card-paused {
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
}

.watched-card-refreshing {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
    padding: 2px 7px;
    border-radius: 999px;
}

.watched-refresh-spinner {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid color-mix(in srgb, var(--accent) 30%, transparent);
    border-top-color: var(--accent);
    animation: spin 0.8s linear infinite;
}

.badge-alpha {
    font-size: 10px;
    font-weight: 600;
    color: var(--warning);
    background: color-mix(in srgb, var(--warning) 15%, transparent);
    padding: 2px 5px;
    border-radius: 4px;
    vertical-align: middle;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.watched-card-meta {
    font-size: 13px;
    color: var(--text-secondary);
}

.watched-card-refresh-error {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid color-mix(in srgb, var(--error) 35%, transparent);
    background: color-mix(in srgb, var(--error) 10%, transparent);
    color: var(--text-primary);
    font-size: 12px;
    line-height: 1.35;
}

.watched-card-refresh-error i {
    color: var(--error);
    margin-top: 1px;
    flex-shrink: 0;
}

.watched-card-settings {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding-top: 6px;
    border-top: 1px solid var(--border);
}

.watched-card-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
}

.watched-card-select {
    padding: 3px 6px;
    font-size: 12px;
    font-family: inherit;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
}

.watched-card-stale-warning {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 10px;
    background: color-mix(in srgb, var(--warning, #f59e0b) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--warning, #f59e0b) 40%, transparent);
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-primary);
    line-height: 1.4;
}

.watched-card-stale-warning i {
    color: var(--warning, #f59e0b);
    margin-top: 2px;
    flex-shrink: 0;
}

.watched-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.watched-action-btn {
    padding: 5px 12px;
    font-size: 13px;
    font-family: inherit;
    font-weight: 500;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.watched-action-btn:hover {
    background: var(--border);
    color: var(--text-primary);
}

.watched-action-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.watched-action-pause {
    color: var(--accent);
}

.watched-action-pause:hover {
    color: var(--accent);
}

.watched-action-delete {
    color: var(--error);
    margin-left: auto;
}

.watched-action-delete:hover {
    color: var(--error);
}

.watched-card-expanded {
    padding-top: 10px;
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-secondary);
}

.toggle-switch {
    position: relative;
    width: 36px;
    height: 20px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border);
    transition: 0.3s;
    border-radius: 20px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 2px;
    bottom: 2px;
    background-color: var(--text-secondary);
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--accent-dim);
    border-color: var(--accent);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(16px);
    background-color: var(--accent);
}

/* Settings tab styles */
.settings-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}

.settings-section-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.settings-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.settings-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
}

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.settings-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.settings-row label {
    font-size: 13px;
    color: var(--text-secondary);
}

.settings-row input {
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s;
}

.settings-row input:focus {
    border-color: var(--accent);
}

.settings-row input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

.settings-row textarea {
    padding: 10px 12px;
    font-size: 13px;
    font-family: monospace;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s;
    resize: vertical;
    min-height: 80px;
}

.settings-row textarea:focus {
    border-color: var(--accent);
}

.settings-row textarea::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
    font-family: inherit;
}

.settings-row input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.settings-hint {
    font-size: 13px;
    color: var(--text-secondary);
    opacity: 0.8;
    line-height: 1.45;
}

/* Lift tiny helper copy in Settings where inline styles were 10-11px */
#settingsTabContainer .settings-row > span {
    font-size: 13px !important;
    line-height: 1.45;
}

#settingsTabContainer .settings-label span span {
    font-size: 12px !important;
}

.password-field {
    display: flex;
    gap: 8px;
}

.password-field input {
    flex: 1;
}

.password-toggle {
    padding: 8px 12px;
    font-size: 12px;
    font-family: inherit;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.password-toggle:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.setting-clear-btn {
    padding: 8px 12px;
    font-size: 12px;
    font-family: inherit;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.setting-clear-btn:hover {
    color: var(--error);
    border-color: var(--error);
}

.setting-input-group {
    display: flex;
    gap: 8px;
}

.setting-input-group input,
.setting-input-group .password-field {
    flex: 1;
}

.test-btn {
    padding: 10px 16px;
    font-size: 14px;
    font-family: inherit;
    font-weight: 600;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    align-self: flex-start;
}

.test-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.test-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.test-result {
    font-size: 13px;
    padding: 8px 12px;
    border-radius: 6px;
    display: none;
}

.test-result.success {
    display: block;
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid var(--accent);
    color: var(--accent);
}

.test-result.error {
    display: block;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error);
    color: var(--error);
}

.test-result.warning {
    display: block;
    background: rgba(234, 179, 8, 0.1);
    border: 1px solid var(--warning);
    color: var(--warning);
}

.settings-details {
    margin-top: 12px;
}

.settings-details summary {
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px 0;
}

.settings-details summary:hover {
    color: var(--text-primary);
}

.settings-actions {
    display: flex;
    align-items: stretch;
    gap: 16px;
    margin-top: 8px;
}

.donation-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex: 1;
    padding: 14px 28px;
    font-size: 14px;
    font-family: inherit;
    font-weight: 600;
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: 10px;
    text-decoration: none;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    isolation: isolate;
    transition: all 0.2s;
    animation: donation-link-magnify 4s ease-in-out infinite;
}

.donation-link > * {
    position: relative;
    z-index: 2;
}

.donation-link::before {
    content: "";
    position: absolute;
    left: -24%;
    top: 50%;
    width: 62px;
    height: 62px;
    border-radius: 999px;
    pointer-events: none;
    z-index: 1;
    opacity: 0;
    background:
        radial-gradient(circle at 34% 34%, rgba(255, 255, 255, 0.85) 0%, rgba(255, 255, 255, 0.35) 40%, rgba(255, 255, 255, 0.10) 70%, rgba(255, 255, 255, 0) 100%);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.28), 0 0 14px rgba(255, 255, 255, 0.22);
    animation: donation-link-lens-roll 4s linear infinite;
}

.donation-link i {
    display: inline-block;
    animation: donation-link-icon-roll 4s ease-in-out infinite;
}

@keyframes donation-link-magnify {
    0%, 100% { transform: scale(1); }
    2% { transform: scale(1.02); }
    8% { transform: scale(1.035); }
    10% { transform: scale(1); }
}

@keyframes donation-link-lens-roll {
    0% {
        transform: translate(-170%, -50%) scale(0.72) rotate(-60deg);
        opacity: 0;
    }
    1.5% {
        opacity: 0.95;
    }
    8.5% {
        transform: translate(700%, -50%) scale(1.2) rotate(340deg);
        opacity: 0.95;
    }
    10% {
        transform: translate(760%, -50%) scale(1.25) rotate(400deg);
        opacity: 0;
    }
    100% {
        transform: translate(760%, -50%) scale(1.25) rotate(400deg);
        opacity: 0;
    }
}

@keyframes donation-link-icon-roll {
    0%, 100% { transform: translateX(0) rotate(0deg) scale(1); }
    2% { transform: translateX(-2px) rotate(-10deg) scale(1.05); }
    8% { transform: translateX(2px) rotate(20deg) scale(1.14); }
    10% { transform: translateX(0) rotate(0deg) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    .donation-link,
    .donation-link::before,
    .donation-link i {
        animation: none !important;
    }
}

.donation-link:hover {
    background: #16a34a;
    color: #000;
}

.save-btn {
    flex: 1;
    padding: 14px 28px;
    font-size: 14px;
    font-family: inherit;
    font-weight: 600;
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.save-btn:hover {
    background: #16a34a;
}

.save-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.release-notes-btn {
    flex: 1;
    padding: 14px 28px;
    font-size: 14px;
    font-family: inherit;
    font-weight: 600;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.release-notes-btn:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.release-notes-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.release-notes-nav-btn {
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s;
}

.release-notes-nav-btn:hover:not(:disabled) {
    color: var(--text-primary);
    border-color: var(--text-secondary);
    background: var(--bg-tertiary);
}

.release-notes-nav-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.save-result {
    font-size: 13px;
    color: var(--accent);
}

.save-result.error {
    color: var(--error);
}

.env-locked {
    position: relative;
    opacity: 0.55;
    cursor: not-allowed;
}

.env-locked * {
    cursor: not-allowed !important;
}

.env-locked::after {
    content: "CONFIG LOCKED";
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 9px;
    padding: 2px 8px;
    background: var(--warning);
    color: #000;
    border-radius: 4px;
    font-weight: 600;
}

/* For toggle rows, shift the pill to sit just left of the switch */
.settings-label.env-locked::after {
    right: 72px;
}

@media (max-width: 400px) {
    .container {
        padding: 16px;
    }

    .result-thumb {
        width: 56px;
        height: 56px;
    }

    .result-title {
        font-size: 14px;
    }
}

/* Settings readability/layout on phones */
@media (max-width: 760px) {
    #settingsTabContainer .settings-section {
        padding: 14px;
    }

    #settingsTabContainer .settings-section-title {
        font-size: 16px;
    }

    #settingsTabContainer .settings-label {
        font-size: 15px;
    }

    #settingsTabContainer .settings-row label {
        font-size: 14px;
    }

    #settingsTabContainer .settings-row input,
    #settingsTabContainer .settings-row select,
    #settingsTabContainer .settings-row textarea {
        font-size: 16px;
    }

    #settingsTabContainer .password-field,
    #settingsTabContainer .setting-input-group {
        flex-direction: column;
        align-items: stretch;
    }

    #settingsTabContainer .password-field input,
    #settingsTabContainer .setting-input-group input,
    #settingsTabContainer .setting-input-group .password-field {
        width: 100%;
        min-width: 0;
    }

    #settingsTabContainer .password-toggle,
    #settingsTabContainer .setting-clear-btn {
        width: 100%;
        text-align: center;
    }

    #settingsTabContainer .settings-hint,
    #settingsTabContainer .settings-row > span {
        font-size: 14px !important;
        line-height: 1.5;
    }

    #settingsTabContainer .settings-label span span {
        font-size: 13px !important;
        line-height: 1.35;
    }

    /* Lift tiny inline helper copy without touching desktop */
    #settingsTabContainer [style*="font-size:10px"],
    #settingsTabContainer [style*="font-size: 10px"],
    #settingsTabContainer [style*="font-size:11px"],
    #settingsTabContainer [style*="font-size: 11px"],
    #settingsTabContainer [style*="font-size:12px"],
    #settingsTabContainer [style*="font-size: 12px"] {
        font-size: 14px !important;
        line-height: 1.5;
    }

    /* Several settings controls are inline-width 240/320px in HTML */
    #settingsTabContainer input[style*="width: 240px"],
    #settingsTabContainer input[style*="width: 120px"],
    #settingsTabContainer input[style*="width: 320px"],
    #settingsTabContainer select[style*="width: 320px"],
    #settingsTabContainer #customSubdirInput,
    #settingsTabContainer #customPlaylistsSubdirInput {
        width: 100% !important;
        max-width: 100%;
    }

    #settingsTabContainer .settings-actions {
        align-items: stretch;
        flex-direction: column;
    }

    #settingsTabContainer .save-btn,
    #settingsTabContainer .donation-link,
    #settingsTabContainer .release-notes-btn {
        width: 100%;
        justify-content: center;
    }
}

/* Explore similar  -  "~ Similar" button on result cards */
/* Desktop: hidden by default, shown on hover via .result-item:hover */
/* Mobile: lives in .mobile-actions row, always visible */
.explore-btn {
    display: none;
    font-size: 12px;
    font-family: inherit;
    font-weight: 500;
    padding: 4px 10px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    flex: 1;
}

.explore-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--bg-tertiary);
}

/* On mobile the button is inside .mobile-actions  -  always show it there */
.mobile-actions .explore-btn {
    display: inline-block;
}

/* Explore bar  -  shown above results when in similar mode */
.explore-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 10px;
    font-size: 13px;
}

.explore-bar-label {
    color: var(--text-secondary);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.explore-bar-label strong {
    color: var(--text-primary);
}

.explore-bar-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.explore-download-all-btn {
    font-size: 13px;
    font-family: inherit;
    font-weight: 500;
    padding: 4px 10px;
    background: var(--accent);
    color: var(--bg-primary);
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.explore-download-all-btn:hover {
    opacity: 0.85;
}

.explore-download-all-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.explore-back-btn {
    font-size: 13px;
    font-family: inherit;
    padding: 4px 10px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s;
}

.explore-back-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.explore-playlist-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
}

.explore-playlist-label input[type="checkbox"] {
    accent-color: var(--accent);
    cursor: pointer;
}
