/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #0066cc;
    --primary-dark: #0052a3;
    --secondary: #6c757d;
    --success: #28a745;
    --warning: #ffc107;
    --error: #dc3545;
    --info: #17a2b8;
    --bg: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e9ecef;
    --text: #212529;
    --text-secondary: #6c757d;
    --border: #dee2e6;
    --shadow: rgba(0, 0, 0, 0.1);
    --code-bg: #f5f5f5;
}

/* Dark Mode */
[data-theme="dark"] {
    --primary: #f59e0b;         /* Warm orange for links */
    --primary-dark: #d97706;   /* Darker orange for hover */
    --secondary: #adb5bd;
    --success: #51cf66;
    --warning: #ffd43b;
    --error: #ff6b6b;
    --info: #4dabf7;
    --bg: #1a1b1e;
    --bg-secondary: #25262b;
    --bg-tertiary: #2c2e33;
    --text: #c1c2c5;
    --text-secondary: #909296;
    --border: #373a40;
    --shadow: rgba(0, 0, 0, 0.3);
    --code-bg: #2c2e33;
}

/* Dark Mode Link States */
[data-theme="dark"] .article-content a:hover {
    color: #fbbf24; /* Warmer yellow for hover */
}

[data-theme="dark"] .article-content a:visited {
    color: #a78bfa; /* Purple tint for visited links */
}

[data-theme="dark"] .link {
    color: #f59e0b;
}

[data-theme="dark"] .link:hover {
    color: #fbbf24;
}

[data-theme="dark"] .link:visited {
    color: #a78bfa;
}

[data-theme="dark"] .link-external {
    color: #f59e0b;
}

[data-theme="dark"] .link-external:hover {
    color: #fbbf24;
}

[data-theme="dark"] .link-external:visited {
    color: #a78bfa;
}

/* Dark Mode Form Styles */
[data-theme="dark"] .input,
[data-theme="dark"] .select {
    background: var(--bg);
    color: var(--text);
    border-color: var(--border);
}

[data-theme="dark"] .input::placeholder,
[data-theme="dark"] .select::placeholder {
    color: var(--text-secondary);
}

[data-theme="dark"] .input:focus,
[data-theme="dark"] .select:focus {
    background: var(--bg);
    border-color: var(--primary);
}

/* Diff highlighting for compare page */
.diff-added {
    background-color: #e6f7e6;
    color: #2d5a2d;
    padding: 2px 4px;
    border-radius: 2px;
}

.diff-removed {
    background-color: #fceaea;
    color: #8b2a2a;
    padding: 2px 4px;
    border-radius: 2px;
    text-decoration: line-through;
}

[data-theme="dark"] .diff-added {
    background-color: #1a3d1a;
    color: #90d490;
}

[data-theme="dark"] .diff-removed {
    background-color: #3d1a1a;
    color: #d49090;
}

/* Loading indicator for infinite scroll */
.loading-indicator {
    text-align: center;
    padding: 1rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Smooth transitions for theme changes */
body {
    transition: background-color 0.3s ease, color 0.3s ease;
}

.header, .stat-item, .nav-link, .btn, .article-item-enhanced, .feed-item, .articles-list {
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg-secondary);
}

/* Header */
.header {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 4px var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    gap: 2rem;
}

.logo a {
    color: var(--primary);
    text-decoration: none;
    font-size: 1.5rem;
    font-weight: 600;
}

.nav {
    display: flex;
    gap: 1.5rem;
    flex: 1;
}

.nav-link {
    color: var(--text);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 0.25rem;
    transition: background 0.2s;
}

.nav-link:hover {
    background: var(--bg-secondary);
}

.stats {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.stat-item {
    padding: 0.25rem 0.75rem;
    background: var(--bg-secondary);
    border-radius: 0.25rem;
}

/* Mobile menu toggle */
.mobile-menu-toggle {
    display: none;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 0.25rem;
    padding: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text);
}

.mobile-menu-close {
    display: none;
}

.mobile-menu-toggle:hover {
    background: var(--bg-secondary);
    border-color: var(--primary);
}

.mobile-menu-toggle:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.mobile-menu-toggle svg {
    width: 1.5rem;
    height: 1.5rem;
    display: block;
}

/* Mobile Navigation */
@media (max-width: 768px) {
    .header-content {
        padding: 0.75rem 1rem;
        gap: 0.5rem;
        flex-wrap: nowrap;
        justify-content: space-between;
        align-items: center;
    }

    .logo {
        flex: 0 1 auto;
        text-align: center;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        min-width: 0;
    }

    .logo a {
        font-size: 1.1rem;
        display: block;
        padding: 0.25rem 0.5rem;
    }

    .mobile-menu-toggle {
        display: block;
        order: -1;
        flex-shrink: 0;
    }

    .header-actions {
        flex-shrink: 0;
        display: flex;
        align-items: center;
        gap: 0.25rem;
    }



    .mobile-menu-close {
        position: absolute;
        top: 1rem;
        left: 50%;
        transform: translateX(-50%);
        background: var(--bg-secondary);
        border: 1px solid var(--border);
        border-radius: 50%;
        width: 3rem;
        height: 3rem;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        z-index: 1000;
        transition: all 0.2s;
        color: var(--text);
    }

    .mobile-menu-close:hover {
        background: var(--primary);
        border-color: var(--primary);
        color: white;
    }

    .mobile-menu-close svg {
        width: 1.25rem;
        height: 1.25rem;
    }

    .nav {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background: var(--bg);
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 1rem;
        padding: 2rem;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 999;
    }

    .nav.show {
        transform: translateX(0);
    }

    .nav-link {
        font-size: 1.25rem;
        padding: 1rem 2rem;
        width: 100%;
        text-align: center;
    }

    /* Ensure header items stay on one line */
    .logo {
        flex: 1;
        text-align: center;
    }

    .header-actions {
        gap: 0.5rem;
    }
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-header h2 {
    font-size: 1.75rem;
    color: var(--text);
}

.actions {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: stretch;
    gap: 0.5rem;
}

/* Buttons */
.btn {
	padding: 0.5rem 1rem;
	border: none;
	border-radius: 0.25rem;
	font-size: 0.875rem;
	font-weight: 500;
	cursor: pointer;
	transition: all 0.2s;
	text-decoration: none;
	display: inline-block;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-text {
    background: none;
    border: none;
    color: var(--primary);
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
}

.btn-text:hover {
    text-decoration: underline;
}

.btn-danger {
    color: var(--error);
}

.btn-block {
    display: block;
    width: 100%;
    text-align: center;
}

/* Cards */
.card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px var(--shadow);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.empty-state p {
    margin: 0.5rem 0;
}

/* Article Item */
.articles-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.article-item {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px var(--shadow);
    transition: box-shadow 0.2s;
}

.article-item:hover {
    box-shadow: 0 4px 6px var(--shadow);
}

.article-meta {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.article-title {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.article-title a {
    color: var(--text);
    text-decoration: none;
}

.article-title a:hover {
    color: var(--primary);
}

.article-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.separator {
    color: var(--border);
}

.article-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* Icon buttons for article actions */
.btn-icon {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 0.375rem;
    transition: background-color 0.2s, transform 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.btn-icon:hover {
    background-color: var(--bg-secondary);
    color: var(--text);
}

.btn-icon:active {
    transform: scale(0.95);
}

/* Bookmark button */
.bookmark-btn.bookmarked {
    color: var(--accent);
}

.bookmark-btn.bookmarked svg {
    fill: currentColor;
}

/* Read button */
.read-btn.read {
    color: var(--success);
}

.read-btn.read svg {
    fill: currentColor;
}

/* Swipe gesture feedback toast */
.swipe-toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-secondary);
    color: var(--text);
    padding: 0.75rem 1.5rem;
    border-radius: 2rem;
    box-shadow: 0 4px 12px var(--shadow);
    z-index: 1000;
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    pointer-events: none;
    font-size: 0.875rem;
    font-weight: 500;
}

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

.swipe-toast-success {
    background: var(--success);
    color: white;
}

.swipe-toast-info {
    background: var(--primary);
    color: white;
}

/* Enhanced Article List with Thumbnails */
.article-item-enhanced {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1rem;
    box-shadow: 0 1px 3px var(--shadow);
    transition: box-shadow 0.2s, opacity 0.3s ease, transform 0.3s ease;
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

/* HTMX swap animations for article removal */
.article-item-enhanced.htmx-swapping {
    opacity: 0;
    transform: translateX(-20px);
}

.article-item-enhanced.htmx-settling {
    opacity: 1;
    transform: translateX(0);
}

.article-item-enhanced:hover {
    box-shadow: 0 4px 6px var(--shadow);
}

.article-thumbnail {
    flex-shrink: 0;
    width: 180px;
    height: 120px;
    border-radius: 0.375rem;
    overflow: hidden;
    background: var(--bg-secondary);
}

.article-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.thumbnail-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    font-weight: bold;
    color: white;
    text-transform: uppercase;
}

.feed-initial {
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

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

.article-item-enhanced .article-meta {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.article-item-enhanced .article-title {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.article-item-enhanced .article-title a {
    color: var(--text);
    text-decoration: none;
}

.article-item-enhanced .article-title a:hover {
    color: var(--primary);
}

.article-item-enhanced .article-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    flex-wrap: wrap;
}

/* Badges */
.badge {
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-unread {
    background: var(--info);
    color: white;
}

.badge-updated {
    background: var(--warning);
    color: var(--text);
}

.badge-success {
    background: var(--success);
    color: white;
}

.badge-warning {
    background: var(--warning);
    color: var(--text);
}

.badge-error {
    background: var(--error);
    color: white;
}

.badge-info {
    background: var(--info);
    color: white;
}

.badge-feed {
    padding: 0.25rem 0.75rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

/* Feed Item */
.feeds-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.feed-item {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px var(--shadow);
}

.feed-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 0.5rem;
}

.feed-title h3 {
    font-size: 1.125rem;
    margin-bottom: 0.25rem;
}

.feed-title h3 a {
    color: var(--text);
    text-decoration: none;
}

.feed-title h3 a:hover {
    color: var(--primary);
}

.feed-description {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.feed-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.feed-actions {
    display: flex;
    gap: 1rem;
}

/* Form Styles */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.input,
.select {
	padding: 0.5rem 1rem;
	border: 1px solid var(--border);
	border-radius: 0.25rem;
	font-size: 1rem;
}

.input:focus,
.select:focus {
    outline: none;
    border-color: var(--primary);
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

/* Article Detail */
.article-detail {
    background: var(--bg);
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: 0 2px 8px var(--shadow);
}

.article-header {
    padding: 2rem;
    border-bottom: 1px solid var(--border);
}

.breadcrumb {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.breadcrumb a {
    color: var(--primary);
    text-decoration: none;
}

.article-header h1 {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.article-badges {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.article-body {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 2rem;
}

.sidebar {
    padding: 2rem;
    border-right: 1px solid var(--border);
    background: var(--bg-secondary);
}

.sidebar-section {
    margin-bottom: 2rem;
}

.sidebar-section h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
}

.versions-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.version-item {
    padding: 0.75rem;
    border-radius: 0.25rem;
    border: 1px solid var(--border);
    background: var(--bg);
}

.version-item.active {
    border-color: var(--primary);
    background: rgba(0, 102, 204, 0.05);
}

.version-item.last-read {
    border-color: var(--success);
}

.version-item a {
    text-decoration: none;
    color: var(--text);
}

.version-number {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.version-date {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.version-label {
    font-size: 0.75rem;
    color: var(--success);
    margin-top: 0.25rem;
}

.actions-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.content {
    padding: 2rem;
}

.version-info {
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 0.25rem;
    margin-bottom: 2rem;
}

.article-content {
    line-height: 1.8;
}

.article-content img {
    max-width: 100%;
    height: auto;
    border-radius: 0.25rem;
    margin: 1rem 0;
}

.article-content a {
    color: var(--primary);
}

.article-content p {
    margin-bottom: 1rem;
}

.article-content h1,
.article-content h2,
.article-content h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

/* Links */
.link {
    color: var(--primary);
    text-decoration: none;
}

.link:hover {
    text-decoration: underline;
}

.link-external::after {
	content: " ↗";
	font-size: 0.75em;
}

.hostname {
	color: var(--text-secondary);
	font-size: 0.875rem;
	margin-left: 0.25rem;
}

/* Footer */
.footer {
    background: var(--bg);
    border-top: 1px solid var(--border);
    margin-top: 4rem;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.footer-content a {
    color: var(--primary);
    text-decoration: none;
}

/* Sidebar toggle button - only visible on mobile */
.sidebar-toggle-container {
    display: none;
    margin-top: 1rem;
    text-align: center;
}

.sidebar-toggle-container .btn {
    width: auto;
    padding: 0.5rem 1rem;
}

/* Hide sidebar close button on desktop */
#sidebar-close {
    display: none;
}

/* Responsive */
@media (max-width: 768px) {
    .header-content {
        gap: 1rem;
    }

    .nav {
        width: 100%;
    }

    .article-body {
        display: block; /* Change from grid to block for mobile */
    }

    .sidebar {
        display: none; /* Hidden by default on mobile */
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background: var(--bg);
        z-index: 1000;
        overflow-y: auto;
        padding: 2rem 1rem;
        box-sizing: border-box;
        border: none;
    }

    .sidebar.mobile-visible {
        display: block;
    }

    .sidebar-header {
        display: flex;
        justify-content: flex-end;
        margin-bottom: 1rem;
    }

    #sidebar-close {
        display: block;
    }

    .sidebar-toggle-container {
        display: block;
        margin-top: 1rem;
        text-align: center;
        z-index: 10;
    }

    .sidebar-toggle-container .btn {
        width: auto;
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
        font-weight: 500;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        border: 1px solid var(--primary);
        background: var(--primary);
        color: white;
        border-radius: 0.25rem;
        display: inline-flex;
        align-items: center;
        gap: 0.5rem;
        transition: all 0.2s ease;
        min-width: 120px;
        justify-content: center;
    }

    .sidebar-toggle-container .btn:hover {
        background: var(--primary-dark);
        border-color: var(--primary-dark);
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }

    .sidebar-toggle-container .btn:active {
        transform: translateY(0);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }


}

/* Reader Mode Styles */
.article-content.reader-mode {
    max-width: none;
    margin: 0;
    padding: 2rem 2rem 2rem 1rem;
    background: var(--bg);
    font-family: Georgia, 'Times New Roman', serif;
    line-height: 1.8;
    color: var(--text);
}

.article-content.reader-mode p {
    margin-bottom: 1.5rem;
    line-height: 1.8;
}

.article-content.reader-mode h1,
.article-content.reader-mode h2,
.article-content.reader-mode h3,
.article-content.reader-mode h4,
.article-content.reader-mode h5,
.article-content.reader-mode h6 {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-weight: 600;
    margin-top: 2rem;
    margin-bottom: 1rem;
    line-height: 1.3;
}

.article-content.reader-mode h1 { font-size: 2rem; }
.article-content.reader-mode h2 { font-size: 1.75rem; }
.article-content.reader-mode h3 { font-size: 1.5rem; }
.article-content.reader-mode h4 { font-size: 1.25rem; }

.article-content.reader-mode a {
    color: var(--primary);
    text-decoration: underline;
}

.article-content.reader-mode img {
    max-width: 100%;
    height: auto;
    margin: 2rem auto;
    display: block;
    border-radius: 0.5rem;
}

.article-content.reader-mode blockquote {
    border-left: 4px solid var(--primary);
    padding-left: 1.5rem;
    margin: 1.5rem 0;
    color: var(--text-secondary);
    font-style: italic;
}

.article-content.reader-mode pre,
.article-content.reader-mode code {
    font-family: 'Courier New', Courier, monospace;
    background: var(--bg-secondary);
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
}

.article-content.reader-mode pre {
    padding: 1rem;
    overflow-x: auto;
    margin: 1rem 0;
}

.article-content.reader-mode ul,
.article-content.reader-mode ol {
    margin: 1rem 0;
    padding-left: 2rem;
}

.article-content.reader-mode li {
    margin-bottom: 0.5rem;
}

/* Hide clutter in reader mode */
.article-content.reader-mode nav,
.article-content.reader-mode header,
.article-content.reader-mode footer,
.article-content.reader-mode aside,
.article-content.reader-mode .advertisement,
.article-content.reader-mode .sidebar,
.article-content.reader-mode .social-share,
.article-content.reader-mode .comments,
.article-content.reader-mode iframe[src*="ads"],
.article-content.reader-mode iframe[src*="tracking"] {
    display: none !important;
}

/* Reader mode with custom font sizes */
.article-content.reader-mode[data-font-size="small"] {
    font-size: 14px;
}

.article-content.reader-mode[data-font-size="medium"] {
    font-size: 16px;
}

.article-content.reader-mode[data-font-size="large"] {
    font-size: 18px;
}

.article-content.reader-mode[data-font-size="x-large"] {
    font-size: 20px;
}

.article-content.reader-mode[data-font-size="xx-large"] {
    font-size: 22px;
}

/* Reader controls styling */
.reader-controls {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.font-size-controls button {
    padding: 0.25rem 0.5rem;
    font-weight: 600;
}

/* Original content iframe styling */
.article-content.original-view {
    position: relative;
}

.article-content.original-view .original-warning {
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 0.25rem;
    color: var(--text-secondary);
}

.article-content.original-view iframe {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 0.25rem;
    background: var(--bg);
}

/* Responsive iframe height */
@media (max-width: 768px) {
    .article-content.original-view iframe {
        height: 400px;
    }
}

/* Search Page Styles */
.search-page {
    max-width: 900px;
    margin: 0 auto;
}

.search-form {
    margin-bottom: 2rem;
    position: relative;
}

.search-form .input {
    font-size: 1.125rem;
    padding: 1rem;
}

#search-indicator {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.htmx-indicator {
    opacity: 0;
    transition: opacity 200ms ease-in;
}

.htmx-indicator.htmx-request {
    opacity: 1;
}

.search-results-header {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 0.5rem;
    color: var(--text-secondary);
}

/* Feed Detail Page Styles */
.feed-detail {
    max-width: 1200px;
    margin: 0 auto;
}

.feed-description {
    color: var(--text-secondary);
    margin-top: 0.5rem;
    font-size: 1rem;
}

.feed-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin: 2rem 0;
}

.stat-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1.5rem;
    text-align: center;
    box-shadow: 0 1px 3px var(--shadow);
}

.stat-value {
    font-size: 2rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.feed-detail-actions {
    display: flex;
    gap: 1rem;
    margin: 2rem 0;
    flex-wrap: wrap;
}

.feed-info-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1.5rem;
    margin: 2rem 0;
    box-shadow: 0 1px 3px var(--shadow);
}

.feed-info-card h3 {
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.info-item {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.info-label {
    font-weight: 600;
    min-width: 120px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.info-item > span:last-child {
    flex: 1;
    word-break: break-word;
}

.feed-articles-section {
    margin: 2rem 0;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.section-header h3 {
    font-size: 1.5rem;
}

.article-filters {
    display: flex;
    gap: 0.5rem;
}

.filter-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    background: var(--bg);
    border-radius: 0.25rem;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.875rem;
}

.filter-btn:hover {
    background: var(--bg-secondary);
}

.filter-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg);
    border-radius: 0.5rem;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: var(--text);
}

.modal form {
    padding: 1.5rem;
}

/* Version Comparison Styles */
.compare-page {
    max-width: 1400px;
    margin: 0 auto;
}

.version-selector {
    display: flex;
    gap: 1rem;
    align-items: end;
    margin: 2rem 0;
    padding: 1.5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    flex-wrap: wrap;
}

.version-select-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
    min-width: 250px;
}

.version-select-group label {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.comparison-container {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 0;
    margin: 2rem 0;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    overflow: hidden;
}

.comparison-column {
    background: var(--bg);
    overflow-y: auto;
    max-height: 800px;
}

.comparison-header {
    padding: 1.5rem;
    border-bottom: 2px solid var(--primary);
    background: var(--bg-secondary);
    position: sticky;
    top: 0;
    z-index: 10;
}

.comparison-header h3 {
    margin: 0;
    font-size: 1.25rem;
}

.version-date {
    margin: 0.5rem 0 0 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.comparison-content {
    padding: 1.5rem;
    line-height: 1.8;
}

.comparison-content p {
    margin-bottom: 1rem;
}

.comparison-content h1,
.comparison-content h2,
.comparison-content h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.comparison-content img {
    max-width: 100%;
    height: auto;
}

.comparison-divider {
    width: 4px;
    background: var(--border);
}

.comparison-actions {
    display: flex;
    gap: 1rem;
    margin: 2rem 0;
    justify-content: center;
}

@media (max-width: 1024px) {
    .comparison-container {
        grid-template-columns: 1fr;
    }

    .comparison-divider {
        display: none;
    }

    .comparison-column:first-child {
        border-bottom: 4px solid var(--border);
    }
}

/* Timeline View */
.timeline-page {
    max-width: 1200px;
    margin: 0 auto;
}

.timeline-page .subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-top: 0.5rem;
}

.timeline-container {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 2rem;
    margin-top: 2rem;
}

.timeline {
    position: relative;
}

.timeline-item {
    display: grid;
    grid-template-columns: 40px 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
    position: relative;
}

.timeline-marker {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.timeline-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary);
    border: 3px solid var(--bg);
    box-shadow: 0 0 0 2px var(--primary);
    z-index: 2;
    flex-shrink: 0;
}

.timeline-line {
    width: 2px;
    flex: 1;
    background: var(--border);
    margin-top: 0.5rem;
    min-height: 60px;
}

.timeline-content {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    position: relative;
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.75rem;
}

.timeline-header h3 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--text);
}

.timeline-date {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.timeline-meta {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.meta-item {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.meta-item strong {
    color: var(--text);
    margin-right: 0.25rem;
}

.timeline-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

.timeline-badge {
    display: inline-block;
    margin-top: 0.75rem;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: rgb(16, 185, 129);
}

.badge-primary {
    background: rgba(59, 130, 246, 0.1);
    color: rgb(59, 130, 246);
}

.timeline-stats {
    position: sticky;
    top: 2rem;
    height: fit-content;
}

.timeline-stats h3 {
    margin: 0 0 1rem 0;
    font-size: 1.125rem;
}

.stats-grid {
    display: grid;
    gap: 1rem;
}

.stat-box {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
}

.stat-box .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.25rem;
}

.stat-box .stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

@media (max-width: 768px) {
    .timeline-container {
        grid-template-columns: 1fr;
    }

    .timeline-stats {
        position: static;
        order: -1;
    }

    .timeline-item {
        grid-template-columns: 30px 1fr;
        gap: 1rem;
    }

    .timeline-dot {
        width: 12px;
        height: 12px;
    }

    .timeline-content {
        padding: 1rem;
    }

    .timeline-header {
        flex-direction: column;
        gap: 0.25rem;
    }

    .timeline-meta {
        flex-direction: column;
        gap: 0.5rem;
    }

    .timeline-actions {
        flex-direction: column;
    }

    .timeline-actions .btn {
        width: 100%;
    }
}

/* Article Filters */
.article-filters {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    padding: 1.5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 180px;
    flex: 1;
}

.filter-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
}

.filter-select {
    min-width: 180px;
}

.filter-actions {
    display: flex;
    align-items: flex-end;
}

.articles-count {
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(59, 130, 246, 0.1);
    border-left: 3px solid var(--primary);
    border-radius: 4px;
    font-size: 0.875rem;
    color: var(--text);
}

@media (max-width: 768px) {
    .article-filters {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-group {
        width: 100%;
    }

    .filter-actions {
        width: 100%;
    }

    .filter-actions .btn {
        width: 100%;
    }
}

/* Dark Mode Toggle */
.theme-toggle {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--text);
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.25rem;
    transition: background 0.2s;
}

.theme-toggle:hover {
    background: var(--bg-secondary);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* Keyboard Shortcuts Overlay */
.keyboard-shortcuts {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 2rem;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px var(--shadow);
    z-index: 1000;
    display: none;
}

.keyboard-shortcuts.active {
    display: block;
}

.shortcuts-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
}

.shortcuts-overlay.active {
    display: block;
}

.shortcuts-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.shortcuts-header h3 {
    font-size: 1.5rem;
    color: var(--text);
}

.shortcuts-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0.25rem;
}

.shortcuts-list {
    display: grid;
    gap: 1rem;
}

.shortcut-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: 0.25rem;
}

.shortcut-desc {
    color: var(--text);
}

.shortcut-keys {
    display: flex;
    gap: 0.5rem;
}

.key {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 0.25rem;
    padding: 0.25rem 0.5rem;
    font-family: monospace;
    font-size: 0.875rem;
    color: var(--text);
    min-width: 2rem;
    text-align: center;
}

/* Print Styles */
@media print {
    .header,
    .nav,
    .stats,
    .actions,
    .sidebar,
    .article-actions,
    .theme-toggle,
    .keyboard-shortcuts,
    .shortcuts-overlay {
        display: none !important;
    }

    body {
        background: white;
        color: black;
    }

    .container {
        max-width: 100%;
        padding: 0;
    }

    .article-detail {
        box-shadow: none;
        border: none;
    }

    .article-content {
        max-width: 100%;
        font-size: 12pt;
        line-height: 1.6;
    }

    .article-content img {
        max-width: 100%;
        page-break-inside: avoid;
    }

    a[href]:after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }

    .page-header h2 {
        page-break-after: avoid;
    }
}

/* Improved Mobile Responsiveness */
@media (max-width: 768px) {
    .header-content {
        padding: 1rem;
    }

    .nav {
        order: 3;
        flex-basis: 100%;
        gap: 0.5rem;
    }

    .stats {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .container {
        padding: 1rem;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

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

    .actions .btn {
        width: auto;
        flex-shrink: 0;
    }

    .article-item-enhanced {
        flex-direction: column;
    }

    .article-thumbnail {
        width: 100%;
        height: 200px;
    }

    .article-body {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        margin-bottom: 2rem;
    }

    .content {
        width: 100%;
    }

    .feed-item {
        flex-direction: column;
        gap: 1rem;
    }

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

    .feed-actions .btn {
        width: 100%;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .btn, .nav-link, .theme-toggle {
        min-height: 44px;
        min-width: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .btn-icon {
        padding: 0.75rem;
    }

    /* Remove hover effects on touch devices */
    .btn:hover, .nav-link:hover, .theme-toggle:hover {
        background: inherit;
    }

    /* Add active states for touch feedback */
    .btn:active {
        transform: scale(0.95);
    }

    .nav-link:active, .theme-toggle:active {
        background: var(--bg-secondary);
    }
}

/* Accessibility improvements */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary);
    color: white;
    padding: 0.5rem 1rem;
    text-decoration: none;
    z-index: 1001;
}

.skip-link:focus {
    top: 0;
}

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

button:focus-visible, a:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Error Pages */
.error-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    padding: 2rem;
}

.error-content {
    text-align: center;
    max-width: 600px;
}

.error-icon {
    color: var(--error);
    margin-bottom: 1rem;
    opacity: 0.8;
}

.error-icon svg {
    display: inline-block;
}

.error-code {
    font-size: 6rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

.error-title {
    font-size: 2rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 1rem;
}

.error-message {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    line-height: 1.6;
}

.error-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.error-actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    text-decoration: none;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.2s;
}

.error-actions .btn-primary {
    background-color: var(--primary);
    color: white;
}

.error-actions .btn-primary:hover {
    background-color: var(--primary-dark);
}

.error-actions .btn-secondary {
    background-color: var(--bg-secondary);
    color: var(--text);
    border: 1px solid var(--border);
}

.error-actions .btn-secondary:hover {
    background-color: var(--bg-tertiary);
}

.error-actions .btn svg {
    flex-shrink: 0;
}

/* Mobile responsiveness for error pages */
@media (max-width: 768px) {
    .error-code {
        font-size: 4rem;
    }

    .error-title {
        font-size: 1.5rem;
    }

    .error-message {
        font-size: 1rem;
    }

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

    .error-actions .btn {
        width: 100%;
        justify-content: center;
    }
}

/* ================================
   Authentication Pages
   ================================ */

/* Auth page layout */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    padding: 1rem;
}

.auth-container {
    width: 100%;
    max-width: 440px;
}

.auth-card {
    background: var(--bg);
    border-radius: 1rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 2.5rem;
}

.auth-card h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0 0 0.5rem 0;
    text-align: center;
}

.auth-card h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 1.5rem 0;
    text-align: center;
}

.auth-description {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9375rem;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

/* Auth form */
.auth-form {
    margin-bottom: 1.5rem;
}

.auth-form .form-group {
    margin-bottom: 1.25rem;
}

.auth-form .form-group:last-child {
    margin-bottom: 0;
}

.auth-form label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text);
    font-size: 0.9375rem;
}

.auth-form .input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: 0.5rem;
    font-size: 1rem;
    background: var(--bg);
    color: var(--text);
    transition: all 0.2s;
}

.auth-form .input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-hint {
    display: block;
    margin-top: 0.375rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Form actions */
.form-actions {
    margin-top: 1.5rem;
}

.btn-block {
    width: 100%;
    justify-content: center;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
}

/* Auth links */
.auth-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
    font-size: 0.9375rem;
}

.auth-links .separator {
    color: var(--text-secondary);
}

.auth-links .link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.auth-links .link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* OAuth divider */
.oauth-divider {
    display: flex;
    align-items: center;
    margin: 1.5rem 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.oauth-divider::before,
.oauth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.oauth-divider span {
    padding: 0 1rem;
}

/* OAuth buttons */
.oauth-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.btn-oauth {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 1.5rem;
    border: 2px solid var(--border);
    border-radius: 0.5rem;
    background: var(--bg);
    color: var(--text);
    font-size: 0.9375rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
    cursor: pointer;
}

.btn-oauth:hover {
    background: var(--bg-secondary);
    border-color: var(--text-secondary);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.btn-oauth svg {
    flex-shrink: 0;
}

.btn-google:hover {
    border-color: #4285F4;
}

.btn-microsoft:hover {
    border-color: #00a4ef;
}

.btn-apple:hover {
    border-color: #000;
}

/* Alert messages */
.alert {
    padding: 0.875rem 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
    font-size: 0.9375rem;
    line-height: 1.5;
}

.alert-info {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    color: var(--primary);
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: #10b981;
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

/* Profile page */
.profile {
    max-width: 800px;
    margin: 0 auto;
}

.profile .card {
    margin-bottom: 1.5rem;
}

.profile-info {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.info-row {
    display: flex;
    align-items: center;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 0.5rem;
    gap: 1rem;
}

.info-label {
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 150px;
    font-size: 0.9375rem;
}

.info-value {
    color: var(--text);
    flex: 1;
}

.profile-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.profile-form .form-group {
    margin-bottom: 0;
}

.danger-zone {
    padding: 1.5rem;
    background: rgba(239, 68, 68, 0.05);
    border: 2px solid rgba(239, 68, 68, 0.1);
    border-radius: 0.5rem;
}

.danger-zone p {
    margin: 0 0 1rem 0;
    color: var(--text-secondary);
}

.btn-danger {
    background-color: #ef4444;
    color: white;
    border: none;
}

.btn-danger:hover {
    background-color: #dc2626;
}

/* Dark mode adjustments for auth pages */
:root[data-theme="dark"] .auth-page {
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%);
}

:root[data-theme="dark"] .auth-card {
    background: var(--bg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

:root[data-theme="dark"] .btn-oauth {
    background: var(--bg-secondary);
}

:root[data-theme="dark"] .btn-oauth:hover {
    background: var(--bg-tertiary);
}

/* Mobile responsiveness for auth pages */
@media (max-width: 768px) {
    .auth-card {
        padding: 2rem 1.5rem;
    }

    .auth-card h1 {
        font-size: 1.5rem;
    }

    .auth-card h2 {
        font-size: 1.125rem;
    }

    .info-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .info-label {
        min-width: auto;
    }
}

/* Touch-friendly buttons on mobile */
@media (max-width: 768px) and (hover: none) {
    .btn-oauth {
        min-height: 44px;
    }

    .auth-form .input {
        min-height: 44px;
        font-size: 16px; /* Prevents iOS zoom */
    }
}

/* Print styles for profile page */
@media print {
    .profile .card h3,
    .profile .card .form-actions,
    .danger-zone {
        display: none;
    }

    .info-row {
        border: 1px solid #ddd;
        page-break-inside: avoid;
    }
}

/* ============================================================================
   User Menu
   ============================================================================ */

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-menu {
    position: relative;
}

.user-menu-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text);
    font-size: 0.875rem;
}

.user-menu-toggle:hover {
    background: var(--bg-secondary);
    border-color: var(--primary);
}

.user-menu-toggle:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.user-avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    object-fit: cover;
}

.user-avatar-placeholder {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
}

.user-name {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chevron-icon {
    width: 1rem;
    height: 1rem;
    transition: transform 0.2s;
}

.user-menu-toggle[aria-expanded="true"] .chevron-icon {
    transform: rotate(180deg);
}

.user-menu-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    min-width: 250px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s;
    z-index: 1000;
}

.user-menu-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-menu-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.user-menu-name {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.25rem;
}

.user-menu-email {
    font-size: 0.875rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-menu-divider {
    height: 1px;
    background: var(--border);
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    color: var(--text);
    text-decoration: none;
    font-size: 0.9375rem;
    cursor: pointer;
    transition: background-color 0.2s;
    text-align: left;
}

.user-menu-item:hover {
    background: var(--bg-secondary);
}

.user-menu-item svg {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
}

.user-menu-logout {
    color: var(--danger);
}

.user-menu-logout-form {
    margin: 0;
}

/* Dark mode adjustments */
[data-theme="dark"] .user-menu-dropdown {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* Mobile responsive */
@media (max-width: 768px) {
    .user-name {
        display: none;
    }

    .user-menu-dropdown {
        right: auto;
        left: 50%;
        transform: translateX(-50%) translateY(-10px);
    }

    .user-menu-dropdown.show {
        transform: translateX(-50%) translateY(0);
    }

    .header-actions {
        gap: 0.5rem;
    }
}

/* Touch-friendly sizing for mobile */
@media (hover: none) and (pointer: coarse) {
    .user-menu-toggle {
        min-height: 44px;
        min-width: 44px;
        padding: 0.625rem;
    }

    .user-menu-item {
        min-height: 44px;
        padding: 0.75rem 1rem;
    }
}



/* Mobile-specific overrides to prevent horizontal scrolling */
@media (max-width: 768px) {
    /* Prevent horizontal scrolling at root level */
    html, body {
        overflow-x: hidden;
    }

    /* Reduce content padding on mobile */
    .content {
        padding: 1rem;
    }

    /* Ensure reader mode doesn't cause horizontal scrolling */
    .article-content.reader-mode {
        padding: 0;
        max-width: none;
        margin: 0;
        width: 100%;
        box-sizing: border-box;
    }

    /* Ensure container doesn't overflow */
    .container {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    /* Prevent horizontal scrolling in pre/code blocks on mobile */
    .article-content.reader-mode pre,
    .article-content.reader-mode code {
        overflow-x: hidden;
        word-wrap: break-word;
        white-space: pre-wrap;
    }

    /* Ensure all text can wrap on mobile */
    .article-content.reader-mode * {
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }
}

/* Tablet-specific adjustments (769px to 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    /* Ensure reader mode content is responsive on tablets */
    .article-content.reader-mode {
        max-width: none;
        padding: 1.5rem;
        width: 100%;
        box-sizing: border-box;
    }

    /* Prevent horizontal scrolling on tablets */
    .article-content.reader-mode * {
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }

    /* Adjust article body grid for tablets */
    .article-body {
        gap: 1.5rem;
    }

    /* Ensure sidebar doesn't cause overflow */
    .sidebar {
        width: 220px; /* Slightly narrower than desktop */
    }

    .article-body {
        grid-template-columns: 220px 1fr;
    }
}
}
