/* Tokyo Night Theme */
:root {
    --bg-dark: #1a1b26;
    --bg-medium: #24283b;
    --bg-light: #414868;
    --fg: #a9b1d6;
    --fg-dark: #7f8cca;
    --fg-bright: #c0caf5;
    --red: #f7768e;
    --orange: #ff9e64;
    --yellow: #e0af68;
    --green: #9ece6a;
    --cyan: #7dcfff;
    --blue: #7aa2f7;
    --purple: #bb9af7;
    --magenta: #c0caf5;
    --border: #414868;
    --accent: var(--blue);
    --panel-bg: rgba(36, 40, 59, 0.82);
    --panel-border: rgba(65, 72, 104, 0.5);
    --panel-blur: 20px;
    --radius: 8px;
}

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

html {
    background-color: var(--bg-dark);
    min-height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.6;
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    color: var(--fg);
    min-height: 100vh;
    position: relative;
    z-index: 0;
}

/* Background image: B&W photo re-colored into Tokyo Night's blue-purple palette.
   Filter chain: darken -> sepia base -> boost color -> rotate hue to blue */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    background: url('/static/bg.webp') center/cover no-repeat;
    filter: brightness(0.25) sepia(1) saturate(2) hue-rotate(190deg);
    pointer-events: none;
}

/* Header */
header {
    background: var(--panel-bg);
    backdrop-filter: blur(var(--panel-blur));
    -webkit-backdrop-filter: blur(var(--panel-blur));
    border-radius: var(--radius);
    border: 1px solid var(--panel-border);
    padding: 12px 20px;
    margin-bottom: 20px;
}

nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 20px;
}

nav a {
    color: var(--blue);
    text-decoration: none;
    transition: color 0.2s;
    white-space: nowrap;
}

nav a:hover {
    color: var(--cyan);
    text-decoration: underline;
}

.nav-brand,
.nav-user {
    color: var(--fg-bright);
}

.nav-user {
    margin-left: auto;
}

.logout-form {
    margin: 0;
}

.link-button {
    border: 0;
    padding: 0;
    background: transparent;
    color: var(--blue);
    font: inherit;
}

.link-button:hover {
    background: transparent;
    color: var(--cyan);
    text-decoration: underline;
}

.auth-panel {
    width: min(100%, 460px);
    margin: 8vh auto 0;
}

.auth-panel input,
.panel input[type="text"],
.panel input[type="password"] {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-dark);
    color: var(--fg-bright);
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-row label {
    margin: 0;
}

.account-table {
    width: 100%;
    border-collapse: collapse;
}

.account-table th,
.account-table td {
    padding: 8px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

/* Panel - frosted glass container */
.panel {
    background: var(--panel-bg);
    backdrop-filter: blur(var(--panel-blur));
    -webkit-backdrop-filter: blur(var(--panel-blur));
    border-radius: var(--radius);
    border: 1px solid var(--panel-border);
    padding: 24px;
}

.panel > h1:first-child,
.panel > h2:first-child {
    margin-top: 0;
}

.panel > *:last-child {
    margin-bottom: 0;
}

/* Main content - flex column, panels provide their own backgrounds */
main {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

h1 {
    margin-bottom: 20px;
    color: var(--fg-bright);
}

h2 {
    margin-top: 30px;
    margin-bottom: 15px;
    color: var(--purple);
}

h3 {
    margin-top: 20px;
    margin-bottom: 10px;
    color: var(--cyan);
}

p {
    margin-bottom: 15px;
}

a {
    color: var(--blue);
}

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

/* Focus indicator for keyboard navigation */
:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
}

textarea:focus-visible {
    outline: none;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: var(--fg-bright);
}

textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    /* >= 16px so iOS Safari does not auto-zoom the page on focus */
    font-size: 16px;
    resize: vertical;
    background-color: var(--bg-dark);
    color: var(--fg);
    transition: border-color 0.2s, box-shadow 0.2s;
}

textarea::placeholder {
    color: var(--fg-dark);
}

textarea:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 2px rgba(122, 162, 247, 0.25);
}

/* Any future free-text input/select must stay >= 16px for the same
   iOS no-zoom reason. Non-text controls (checkbox/radio/file) are excluded. */
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
select {
    font-size: 16px;
}

button {
    background-color: var(--blue);
    color: var(--bg-dark);
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

button:hover {
    background-color: var(--cyan);
}

button:active {
    transform: scale(0.98);
}

button.secondary {
    background-color: var(--bg-light);
    color: var(--fg);
}

button.secondary:hover {
    background-color: var(--fg-dark);
}

.button-group {
    display: flex;
    gap: 10px;
}

/* Results section */
.results-section {
    padding: 20px;
    background: var(--panel-bg);
    backdrop-filter: blur(var(--panel-blur));
    -webkit-backdrop-filter: blur(var(--panel-blur));
    border: 1px solid var(--green);
    border-radius: var(--radius);
}

.results-section h2 {
    color: var(--green);
    margin-top: 0;
}

.results-section ul {
    list-style: none;
    padding: 0;
}

.results-section li {
    padding: 10px 0;
    border-bottom: 1px solid rgba(158, 206, 106, 0.2);
}

.results-section li:last-child {
    border-bottom: none;
}

.results-section a {
    color: var(--green);
    text-decoration: none;
    font-weight: 500;
}

.results-section a:hover {
    text-decoration: underline;
    color: var(--cyan);
}

/* Video result row: download link + iOS "Save to Photos" share button.
   The link grows and may wrap (long filenames); the button never shrinks. */
.video-result {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.video-result-link {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
}

.save-photos-btn {
    flex: 0 0 auto;
    padding: 8px 16px;
    background-color: var(--green);
}

/* Messages */
.success-message {
    padding: 15px;
    background: var(--panel-bg);
    backdrop-filter: blur(var(--panel-blur));
    -webkit-backdrop-filter: blur(var(--panel-blur));
    color: var(--green);
    border-radius: var(--radius);
    border: 1px solid var(--green);
}

.error-message {
    padding: 15px;
    background: var(--panel-bg);
    backdrop-filter: blur(var(--panel-blur));
    -webkit-backdrop-filter: blur(var(--panel-blur));
    color: var(--red);
    border-radius: var(--radius);
    border: 1px solid var(--red);
}

.warning-message {
    padding: 15px;
    background: var(--panel-bg);
    backdrop-filter: blur(var(--panel-blur));
    -webkit-backdrop-filter: blur(var(--panel-blur));
    color: var(--yellow);
    border-radius: var(--radius);
    border: 1px solid var(--yellow);
}

.warning-message pre {
    margin-top: 10px;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 13px;
    color: var(--fg);
}

.error-message pre {
    margin-top: 10px;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 13px;
    color: var(--fg);
}

.status-message {
    padding: 15px;
    background: var(--panel-bg);
    backdrop-filter: blur(var(--panel-blur));
    -webkit-backdrop-filter: blur(var(--panel-blur));
    color: var(--blue);
    border-radius: var(--radius);
    border: 1px solid var(--blue);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Let a long "link + name" status string shrink and wrap inside the flex
   row instead of overflowing the panel and squashing the spinner. */
#status-text,
.status-message > span:last-child {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
}

/* Spinner animation */
.spinner {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    border: 2px solid var(--blue);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Progress section */
.progress-section {
    padding: 15px;
    background: var(--panel-bg);
    backdrop-filter: blur(var(--panel-blur));
    -webkit-backdrop-filter: blur(var(--panel-blur));
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
}

.progress-bar-container {
    height: 8px;
    background-color: var(--bg-light);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-bar {
    height: 100%;
    background: var(--blue);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-info {
    text-align: center;
    color: var(--fg-dark);
    font-size: 14px;
    margin-bottom: 15px;
}

.progress-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 300px;
    overflow-y: auto;
}

.progress-item {
    padding: 8px 10px;
    margin-bottom: 5px;
    border-radius: 4px;
    font-size: 13px;
    overflow-wrap: anywhere;
}

.progress-item .status-icon {
    margin-right: 8px;
}

.progress-item.processing {
    background-color: rgba(122, 162, 247, 0.15);
    color: var(--blue);
    border-left: 3px solid var(--blue);
}

.progress-item.success {
    background-color: rgba(158, 206, 106, 0.1);
    color: var(--green);
    border-left: 3px solid var(--green);
}

.progress-item.failed {
    background-color: rgba(247, 118, 142, 0.1);
    color: var(--red);
    border-left: 3px solid var(--red);
}

.progress-item .error-detail {
    display: block;
    margin-top: 4px;
    margin-left: 24px;
    color: var(--fg-dark);
    font-size: 11px;
}

.results-section .summary {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(158, 206, 106, 0.2);
    color: var(--fg-dark);
    font-size: 13px;
}

.download-actions {
    align-items: center;
    gap: 10px;
    margin: 8px 0 12px;
}

.results-section .download-all-link {
    display: inline-flex;
    align-items: center;
    min-height: 42px;
    padding: 10px 14px;
    border: 1px solid var(--green);
    border-radius: var(--radius);
    background: var(--green);
    color: var(--bg-dark);
    font-weight: 700;
    line-height: 1.2;
}

.results-section .download-all-link:hover {
    background: var(--cyan);
    border-color: var(--cyan);
    color: var(--bg-dark);
    text-decoration: none;
}

/* Disabled button */
button:disabled {
    background-color: var(--bg-light);
    color: var(--fg-dark);
    cursor: not-allowed;
}

/* Supported sources hint */
.supported-sources {
    font-size: 14px;
    color: var(--fg-dark);
}

/* Instructions */
.instructions ol {
    margin-left: 20px;
    margin-bottom: 15px;
}

.instructions li {
    margin-bottom: 8px;
}

.instructions code {
    background-color: var(--bg-dark);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 14px;
    color: var(--orange);
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

.instructions ul {
    margin-left: 20px;
    margin-top: 5px;
}

/* Hints */
.setup-hint {
    padding: 15px;
    background: var(--panel-bg);
    backdrop-filter: blur(var(--panel-blur));
    -webkit-backdrop-filter: blur(var(--panel-blur));
    border: 1px solid var(--yellow);
    border-radius: var(--radius);
    font-size: 14px;
    color: var(--yellow);
}

.setup-hint a {
    color: var(--orange);
}

/* Footer */
footer {
    background: var(--panel-bg);
    backdrop-filter: blur(var(--panel-blur));
    -webkit-backdrop-filter: blur(var(--panel-blur));
    border-radius: var(--radius);
    border: 1px solid var(--panel-border);
    margin-top: 20px;
    padding: 16px 20px;
    text-align: center;
    color: var(--fg-dark);
    font-size: 14px;
}

footer .version {
    font-size: 11px;
    color: var(--fg-dark);
    margin-top: 5px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

/* Cookie status indicator */
.cookie-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    margin-left: auto;
    cursor: default;
    border: 1px solid transparent;
}

.cookie-status .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

/* Loading state */
.cookie-status.loading {
    background-color: var(--bg-light);
    color: var(--fg-dark);
}

.cookie-status.loading .status-dot {
    background-color: var(--fg-dark);
    animation: pulse 1s ease-in-out infinite;
}

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

/* Not configured state */
.cookie-status.not-configured {
    background-color: rgba(255, 158, 100, 0.15);
    color: var(--orange);
    border-color: var(--orange);
}

.cookie-status.not-configured .status-dot {
    background-color: var(--orange);
}

/* Configured but not tested */
.cookie-status.configured {
    background-color: rgba(122, 162, 247, 0.15);
    color: var(--blue);
    border-color: var(--blue);
}

.cookie-status.configured .status-dot {
    background-color: var(--blue);
}

/* Working state */
.cookie-status.working {
    background-color: rgba(158, 206, 106, 0.15);
    color: var(--green);
    border-color: var(--green);
}

.cookie-status.working .status-dot {
    background-color: var(--green);
}

/* Invalid state */
.cookie-status.invalid {
    background-color: rgba(247, 118, 142, 0.15);
    color: var(--red);
    border-color: var(--red);
}

.cookie-status.invalid .status-dot {
    background-color: var(--red);
}

/* Error state */
.cookie-status.error {
    background-color: rgba(187, 154, 247, 0.15);
    color: var(--purple);
    border-color: var(--purple);
}

.cookie-status.error .status-dot {
    background-color: var(--purple);
}

/* Cookie form section */
.form-hint {
    color: var(--fg-dark);
    font-size: 14px;
    margin-bottom: 20px;
}

/* Cookie input options (side by side) */
.cookie-input-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.input-option {
    background-color: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 15px;
}

.input-option h3 {
    margin-top: 0;
    margin-bottom: 8px;
    font-size: 14px;
}

.option-hint {
    color: var(--fg-dark);
    font-size: 12px;
    margin-bottom: 12px;
}

.cookie-form-inner {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cookie-form-inner textarea {
    min-height: 80px;
    /* keep >= 16px to avoid iOS focus zoom; monospace stays legible */
    font-size: 16px;
}

.cookie-form-inner .save-btn {
    font-size: 14px;
    padding: 10px 16px;
}

@media (max-width: 700px) {
    .cookie-input-options {
        grid-template-columns: 1fr;
    }
}

/* Current cookies display */
.cookies-table {
    background-color: var(--bg-dark);
    border-radius: 4px;
    padding: 15px;
    border: 1px solid var(--border);
}

.cookies-table table {
    width: 100%;
    border-collapse: collapse;
}

.cookies-table th,
.cookies-table td {
    text-align: left;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
}

.cookies-table th {
    color: var(--fg-dark);
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cookies-table td {
    font-size: 14px;
}

.cookies-table tr:last-child td {
    border-bottom: none;
}

.cookies-table code {
    background-color: var(--bg-medium);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

.cookies-table .masked-value {
    color: var(--fg-dark);
}

.cookies-table .status-ok {
    color: var(--green);
    font-size: 12px;
    font-weight: 500;
}

.cookies-table .status-extra {
    color: var(--fg-dark);
    font-size: 12px;
}

.no-cookies {
    color: var(--fg-dark);
    font-style: italic;
}

.cookie-warning {
    margin-top: 12px;
    padding: 10px;
    background-color: rgba(247, 118, 142, 0.15);
    border: 1px solid var(--red);
    border-radius: var(--radius);
    color: var(--red);
    font-size: 14px;
}

.cookie-complete {
    margin-top: 12px;
    padding: 10px;
    background-color: rgba(158, 206, 106, 0.15);
    border: 1px solid var(--green);
    border-radius: var(--radius);
    color: var(--green);
    font-size: 14px;
}

.loading-text {
    color: var(--fg-dark);
    font-style: italic;
}

.error-text {
    color: var(--red);
}

/* Bookmarks page */
.bookmarks-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
}

.bookmarks-header h2 {
    width: 100%;
    margin: 0;
}

.bookmarks-filter {
    display: flex;
    gap: 4px;
}

.filter-btn {
    background-color: var(--bg-light);
    color: var(--fg-dark);
    padding: 5px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

.filter-btn:hover {
    background-color: var(--fg-dark);
    color: var(--fg);
}

.filter-btn.active {
    background-color: var(--accent);
    color: var(--bg-dark);
    border-color: var(--accent);
}

.bookmarks-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.bookmark-displayname {
    font-size: 12px;
    color: var(--fg-dark);
}

.small-btn {
    background-color: var(--bg-light);
    color: var(--fg);
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 12px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.small-btn:hover {
    background-color: var(--fg-dark);
}

.selection-count {
    font-size: 12px;
    color: var(--fg-dark);
    margin-left: 5px;
}

.bookmarks-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 600px;
    overflow-y: auto;
}

.bookmark-item {
    padding: 10px 12px;
    margin-bottom: 6px;
    background-color: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.2s;
}

.bookmark-item:hover {
    border-color: var(--fg-dark);
}

.bookmark-item.has-article {
    border-left: 3px solid var(--green);
}

.bookmark-label {
    display: flex;
    gap: 10px;
    cursor: pointer;
    align-items: flex-start;
}

.bookmark-label input[type="checkbox"] {
    margin-top: 4px;
    accent-color: var(--blue);
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.bookmark-content {
    flex: 1;
    min-width: 0;
}

.bookmark-meta {
    font-size: 12px;
    color: var(--fg-dark);
    margin-bottom: 4px;
    display: flex;
    gap: 10px;
}

.bookmark-author {
    color: var(--cyan);
    font-weight: 500;
}

.bookmark-badge {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 3px;
    font-weight: 500;
    white-space: nowrap;
}

.badge-article {
    background-color: var(--blue);
    color: var(--bg-dark);
}

.badge-link {
    background-color: var(--bg-light);
    color: var(--fg-dark);
    border: 1px solid var(--border);
}

.badge-video {
    background-color: var(--purple);
    color: var(--bg-dark);
}

.bookmark-text {
    font-size: 13px;
    color: var(--fg);
    line-height: 1.4;
    margin-bottom: 4px;
    overflow-wrap: break-word;
}

.bookmark-links {
    font-size: 12px;
}

.article-link {
    color: var(--green);
    text-decoration: none;
    word-break: break-all;
}

.article-link:hover {
    text-decoration: underline;
    color: var(--cyan);
}

.no-link {
    color: var(--fg-dark);
    font-style: italic;
}

/* Resume banner */
.resume-banner {
    background: var(--panel-bg);
    backdrop-filter: blur(var(--panel-blur));
    -webkit-backdrop-filter: blur(var(--panel-blur));
    border: 1px solid var(--yellow);
    border-radius: var(--radius);
    padding: 16px 24px;
    color: var(--fg-bright);
}

.resume-banner .button-group {
    margin-top: 12px;
}

/* YouTube downloader */
.youtube-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.youtube-cookie-status {
    flex: 0 0 auto;
    padding: 5px 10px;
    border: 1px solid var(--orange);
    border-radius: 999px;
    color: var(--orange);
    background: rgba(255, 158, 100, 0.12);
    font-size: 12px;
    font-weight: 600;
}

.youtube-cookie-status.configured {
    border-color: var(--green);
    color: var(--green);
    background: rgba(158, 206, 106, 0.12);
}

.youtube-cookie-status.error {
    border-color: var(--red);
    color: var(--red);
    background: rgba(247, 118, 142, 0.12);
}

.mode-picker {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 0;
    margin: 0 0 20px;
    border: 0;
}

.mode-picker legend {
    grid-column: 1 / -1;
    margin-bottom: 5px;
    font-weight: 600;
    color: var(--fg-bright);
}

.mode-option {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 60px;
    padding: 12px;
    margin: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(26, 27, 38, 0.78);
    cursor: pointer;
}

.mode-option:has(input:checked) {
    border-color: var(--blue);
    box-shadow: 0 0 0 2px rgba(122, 162, 247, 0.18);
}

.mode-option input {
    accent-color: var(--blue);
}

.mode-option span {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.mode-option small {
    color: var(--fg-dark);
    font-size: 12px;
}

.youtube-session-panel {
    display: grid;
    gap: 18px;
}

.youtube-oauth-panel {
    display: grid;
    gap: 16px;
}

.youtube-oauth-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.youtube-oauth-header h2 {
    margin: 0 0 4px;
    color: var(--fg-bright);
}

.youtube-oauth-header p {
    margin: 0;
    color: var(--fg-dark);
}

.youtube-oauth-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.youtube-session-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.youtube-session-header h2 {
    margin: 0 0 4px;
    color: var(--fg-bright);
}

.youtube-session-header p {
    margin: 0;
    color: var(--fg-dark);
}

.youtube-session-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.youtube-session-state {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-height: 72px;
    padding: 14px 16px;
    border: 1px solid var(--yellow);
    border-radius: var(--radius);
    background: rgba(224, 175, 104, 0.12);
}

.youtube-session-state-marker {
    flex: 0 0 auto;
    width: 14px;
    height: 14px;
    margin-top: 5px;
    border-radius: 50%;
    background: var(--yellow);
    box-shadow: 0 0 0 4px rgba(224, 175, 104, 0.14);
}

.youtube-session-state strong {
    display: block;
    color: var(--fg-bright);
    font-size: 17px;
    line-height: 1.25;
}

.youtube-session-state small {
    display: block;
    margin-top: 4px;
    color: var(--fg);
    font-size: 14px;
    line-height: 1.35;
}

.youtube-session-state.saved,
.youtube-session-state.verified {
    border-color: var(--green);
    background: rgba(158, 206, 106, 0.14);
}

.youtube-session-state.saved .youtube-session-state-marker,
.youtube-session-state.verified .youtube-session-state-marker {
    background: var(--green);
    box-shadow: 0 0 0 4px rgba(158, 206, 106, 0.16);
}

.youtube-session-state.problem {
    border-color: var(--red);
    background: rgba(247, 118, 142, 0.13);
}

.youtube-session-state.problem .youtube-session-state-marker {
    background: var(--red);
    box-shadow: 0 0 0 4px rgba(247, 118, 142, 0.16);
}

.youtube-session-state.missing {
    border-color: var(--orange);
    background: rgba(255, 158, 100, 0.13);
}

.youtube-session-state.missing .youtube-session-state-marker {
    background: var(--orange);
    box-shadow: 0 0 0 4px rgba(255, 158, 100, 0.16);
}

.youtube-cookie-metadata {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.youtube-cookie-metadata div {
    min-width: 0;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(26, 27, 38, 0.62);
}

.youtube-cookie-metadata dt {
    margin-bottom: 3px;
    color: var(--fg-dark);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.youtube-cookie-metadata dd {
    overflow-wrap: anywhere;
    color: var(--fg-bright);
    font-size: 14px;
    font-weight: 600;
}

.youtube-cookie-form {
    display: grid;
    gap: 14px;
}

.youtube-cookie-upload-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 14px;
    align-items: end;
}

.youtube-cookie-upload-row .form-group {
    margin-bottom: 0;
}

input[type="file"] {
    width: 100%;
    min-height: 42px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-dark);
    color: var(--fg);
}

.youtube-session-paste {
    margin-bottom: 20px;
}

.youtube-session-paste summary {
    color: var(--blue);
    cursor: pointer;
    font-weight: 600;
    margin-bottom: 12px;
}

.youtube-session-paste[open] summary {
    color: var(--cyan);
}

button.danger {
    color: var(--red);
}

button.danger:hover {
    background-color: rgba(247, 118, 142, 0.16);
}

/* Responsive */
@media (max-width: 600px) {
    body {
        padding: 10px;
    }

    nav {
        gap: 12px;
    }

    nav a {
        font-size: 14px;
    }

    .panel {
        padding: 16px;
    }

    .button-group {
        flex-direction: column;
    }

    .youtube-head,
    .mode-picker,
    .youtube-cookie-metadata,
    .youtube-cookie-upload-row {
        grid-template-columns: 1fr;
    }

    .youtube-head {
        /* stack heading above the status pill so neither overflows narrow phones */
        flex-direction: column;
        align-items: stretch;
    }

    .youtube-session-header,
    .youtube-oauth-header {
        display: grid;
    }

    .youtube-session-actions,
    .youtube-oauth-actions {
        justify-content: stretch;
    }

    .youtube-session-actions button,
    .youtube-oauth-actions button {
        flex: 1 1 auto;
    }

    .cookie-status .status-text {
        display: none;
    }

    .small-btn {
        padding: 10px 14px;
        font-size: 14px;
    }

    .filter-btn {
        padding: 10px 16px;
        font-size: 14px;
    }
}

/* Scrollbar styling for dark theme */
.bookmarks-list,
.progress-list {
    scrollbar-width: thin;
    scrollbar-color: var(--bg-light) transparent;
}

.bookmarks-list::-webkit-scrollbar,
.progress-list::-webkit-scrollbar {
    width: 6px;
}

.bookmarks-list::-webkit-scrollbar-track,
.progress-list::-webkit-scrollbar-track {
    background: transparent;
}

.bookmarks-list::-webkit-scrollbar-thumb,
.progress-list::-webkit-scrollbar-thumb {
    background-color: var(--bg-light);
    border-radius: 3px;
}

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