/* ============================================
   CRITICAL FIX: SCREEN VISIBILITY (MUST BE FIRST)
=========================================== */
.screen {
    display: none !important;
    visibility: hidden;
    opacity: 0;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    background: #f2f2f7;
    z-index: 1;
    pointer-events: none;
}

.screen.active {
    display: block !important;
    visibility: visible;
    opacity: 1;
    z-index: 100;
    pointer-events: auto;
}

#splash.screen.active {
    display: flex !important;
    z-index: 9999;
}

/* ============================================
   CSS VARIABLES
=========================================== */
:root {
    --bg: #f2f2f7;
    --card: #ffffff;
    --text: #000000;
    --text-secondary: #6c6c70;
    --accent: #007aff;
    --danger: #ff3b30;
    --border: #e5e5ea;
    --shadow: 0 4px 20px rgba(0,0,0,0.08);
    --success: #34c759;
}

.dark {
    --bg: #000000;
    --card: #1c1c1e;
    --text: #ffffff;
    --text-secondary: #8e8e93;
    --border: #38383a;
    --shadow: 0 4px 20px rgba(0,0,0,0.3);
    --success: #30d158;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    overflow-x: hidden;
}

body {
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    font-size: 16px;
}

/* ============================================
   ANIMATIONS
=========================================== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@keyframes load {
    0% { width: 0%; }
    100% { width: 100%; }
}

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

@keyframes slideUp {
    from { transform: translateX(-50%) translateY(20px); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

@keyframes fadeInImage {
    to { opacity: 1; }
}

/* ============================================
   SPLASH SCREEN
=========================================== */
#splash {
    background: var(--card);
    align-items: center;
    justify-content: center;
}

.splash-wrapper {
    text-align: center;
    padding: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.splash-logo {
    font-size: 64px;
    margin-bottom: 20px;
    animation: pulse 2s ease-in-out infinite;
}

.splash-title {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 8px;
}

.splash-subtitle {
    color: var(--text-secondary);
    font-size: 16px;
    margin-bottom: 40px;
}

.loading-bar {
    width: 180px;
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.loading-progress {
    height: 100%;
    width: 0%;
    background: var(--accent);
    animation: load 2s ease-out forwards;
}

/* ============================================
   LOADING & EMPTY STATES
=========================================== */
.loading-spinner-container {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

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

.error-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 12px;
}

.retry-btn {
    margin-top: 16px;
    padding: 10px 20px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    transition: opacity 0.2s;
}

.retry-btn:active {
    opacity: 0.8;
}

.offline-banner {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 59, 48, 0.95);
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    z-index: 9999;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    animation: slideUp 0.3s ease;
}

/* ============================================
   ABOUT SCREEN
=========================================== */
#about {
    background: linear-gradient(180deg, var(--card) 0%, var(--bg) 100%);
}

.about-wrapper {
    min-height: 100vh;
    padding: 50px 24px 30px;
    display: flex;
    flex-direction: column;
    max-width: 400px;
    margin: 0 auto;
}

.about-header {
    text-align: center;
    margin-bottom: 40px;
}

.logo-circle {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    margin: 0 auto 20px;
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.3);
}

.about-header h1 {
    font-size: 28px;
    line-height: 1.2;
    margin-bottom: 10px;
    font-weight: 700;
}

.highlight {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.tagline {
    color: var(--text-secondary);
    font-size: 15px;
}

.features-list {
    margin-bottom: 30px;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    background: var(--card);
    border-radius: 14px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
    transition: transform 0.2s;
}

.feature-item:active {
    transform: scale(0.98);
}

.feature-emoji {
    font-size: 28px;
    flex-shrink: 0;
}

.feature-text h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
}

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

.about-actions {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.btn-main {
    background: var(--accent);
    color: white;
    border: none;
    padding: 16px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
}

.btn-main:active {
    transform: scale(0.98);
    opacity: 0.9;
}

.btn-text {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    padding: 8px;
    transition: color 0.2s;
}

.btn-text:active {
    color: var(--accent);
}

.version {
    text-align: center;
    font-size: 12px;
    color: var(--text-secondary);
}

/* ============================================
   LOGIN SCREEN
=========================================== */
#login {
    background: var(--card);
}

.login-wrapper {
    min-height: 100vh;
    padding: 16px 24px 30px;
    max-width: 400px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
}

.btn-back {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--accent);
    cursor: pointer;
    padding: 8px;
    margin-left: -8px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.btn-back:active {
    background: var(--bg);
}

.login-header {
    margin: 24px 0 32px;
}

.login-header h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 6px;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 15px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
}

.input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.input-wrapper label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-wrapper input {
    padding: 14px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 16px;
    background: transparent;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s;
}

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

.divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
    margin: 8px 0;
}

.divider::before, .divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border);
}

.divider span {
    margin: 0 12px;
}

.btn-secondary {
    background: transparent;
    color: var(--text);
    border: 1.5px solid var(--border);
    padding: 14px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:active {
    background: var(--bg);
    transform: scale(0.98);
}

.login-footer {
    text-align: center;
    margin-top: 16px;
    color: var(--text-secondary);
    font-size: 14px;
}

.login-footer a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

/* ============================================
   HOME SCREEN
=========================================== */
#home {
    background: var(--bg);
    padding-bottom: 80px;
}

.main-header {
    background: rgba(242, 242, 247, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border);
}

.dark .main-header {
    background: rgba(0, 0, 0, 0.95);
}

.header-title h1 {
    font-size: 18px;
    font-weight: 700;
}

.header-actions {
    display: flex;
    gap: 6px;
}

.icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: var(--card);
    color: var(--text);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
    transition: all 0.2s;
}

.icon-btn:active {
    transform: scale(0.9);
    background: var(--accent);
    color: white;
}

.main-body {
    padding: 16px;
    max-width: 500px;
    margin: 0 auto;
}

/* ============================================
   SAVED FOLDER
=========================================== */
.saved-folder {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
    color: white;
}

.saved-folder:active {
    transform: scale(0.98);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.folder-icon {
    font-size: 32px;
}

.folder-info {
    flex: 1;
}

.folder-info h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 2px;
}

.folder-info p {
    font-size: 13px;
    opacity: 0.9;
}

.folder-arrow {
    font-size: 20px;
    opacity: 0.8;
}

/* ============================================
   NEWS CARDS
=========================================== */
.feed-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.news-card {
    background: var(--card);
    border-radius: 14px;
    padding: 14px;
    display: flex;
    gap: 14px;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid var(--border);
}

.news-card:active {
    transform: scale(0.98);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.news-card.no-image .news-content {
    width: 100%;
}

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

.news-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 4px;
    line-height: 1.3;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.news-excerpt {
    font-size: 14px;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.news-meta {
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.saved-badge {
    color: var(--accent);
    font-weight: 500;
}

.news-thumb {
    width: 70px;
    height: 70px;
    border-radius: 10px;
    object-fit: cover;
    background: var(--border);
    flex-shrink: 0;
    transition: opacity 0.2s;
}

.news-thumb[loading="lazy"] {
    opacity: 0;
    animation: fadeInImage 0.3s ease forwards;
}

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

.empty-state.hidden {
    display: none !important;
}

.empty-icon {
    font-size: 56px;
    margin-bottom: 16px;
    display: block;
}

.empty-state h3 {
    color: var(--text);
    margin-bottom: 6px;
    font-size: 18px;
    font-weight: 600;
}

/* ============================================
   BOTTOM NAVIGATION
=========================================== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
    z-index: 1000;
}

.dark .bottom-nav {
    background: rgba(28, 28, 30, 0.98);
}

.nav-btn {
    flex: 1;
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    padding: 4px;
    transition: color 0.2s;
    max-width: 80px;
    position: relative;
}

.nav-btn.active {
    color: var(--accent);
}

.nav-btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    background: var(--accent);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s;
}

.nav-btn.active::after {
    opacity: 1;
}

.nav-icon-svg {
    width: 20px;
    height: 20px;
    stroke-width: 2;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.2s;
}

.nav-btn:active .nav-icon-svg {
    transform: scale(0.9);
}

.nav-label {
    font-size: 10px;
    margin-top: 1px;
}

/* ============================================
   PAGE HEADER
=========================================== */
/* ============================================
   FIXED PAGE HEADER
=========================================== */
.page-header {
    background: rgba(242, 242, 247, 0.98);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    height: 56px;
}

.dark .page-header {
    background: rgba(0, 0, 0, 0.98);
}

/* Back button container - fixed width */
.page-header .btn-back {
    background: none;
    border: none;
    font-size: 17px;
    color: var(--accent);
    cursor: pointer;
    padding: 8px 0;
    min-width: 80px;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 400;
}

/* Center title - takes remaining space */
.page-header h1 {
    font-size: 17px;
    font-weight: 600;
    text-align: center;
    flex: 1;
    margin: 0;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
}

/* Right side spacer - matches left side width */
.page-header .spacer,
.page-header > div:last-child {
    min-width: 80px;
    width: 80px;
}

/* Save button in detail page */
.page-header .btn-save {
    min-width: 80px;
    text-align: right;
}

/* ============================================
   PREFERENCES SCREEN
=========================================== */
#preferences {
    background: var(--bg);
    padding-bottom: 100px;
}

.pref-section {
    margin-bottom: 24px;
    padding: 0 16px;
}

.pref-section h3 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    margin-left: 4px;
    font-weight: 600;
}

.pref-card {
    background: var(--card);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.pref-row {
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.border-top {
    border-top: 1px solid var(--border);
}

.pref-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.pref-title {
    font-size: 16px;
    font-weight: 400;
    color: var(--text);
}

.pref-desc {
    font-size: 12px;
    color: var(--text-secondary);
}

.switch {
    position: relative;
    width: 48px;
    height: 28px;
}

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

.switch-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border);
    transition: .3s;
    border-radius: 28px;
}

.switch-slider:before {
    position: absolute;
    content: "";
    height: 24px;
    width: 24px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

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

input:checked + .switch-slider:before {
    transform: translateX(20px);
}

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

.size-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 2px solid var(--border);
    background: var(--card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
}

.size-btn[data-size="small"] {
    font-size: 12px;
}

.size-btn[data-size="medium"] {
    font-size: 16px;
}

.size-btn[data-size="large"] {
    font-size: 20px;
}

.size-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

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

.btn-logout {
    width: 100%;
    margin-top: 10px;
    padding: 14px;
    background: var(--card);
    border: none;
    border-radius: 12px;
    color: var(--danger);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: opacity 0.2s;
}

.btn-logout:active {
    opacity: 0.7;
}

.btn-danger {
    width: 100%;
    padding: 14px 16px;
    background: rgba(255, 59, 48, 0.1);
    border: none;
    border-radius: 12px;
    color: var(--danger);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
}

.btn-danger:active {
    background: rgba(255, 59, 48, 0.2);
}

/* ============================================
   ARTICLE DETAIL SCREEN
=========================================== */
#detail {
    background: var(--bg);
}

.btn-save {
    background: var(--accent);
    color: white;
    border: none;
    padding: 8px 14px;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
}

.btn-save.saved {
    background: var(--success);
}

.btn-save:active {
    transform: scale(0.95);
    opacity: 0.9;
}

.detail-content {
    background: var(--bg);
    min-height: calc(100vh - 60px);
    overflow-y: auto;
}

.article-image-container {
    width: 100%;
    height: 220px;
    overflow: hidden;
    background: var(--border);
    position: relative;
}

.article-image-container::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(to top, rgba(0,0,0,0.3), transparent);
    pointer-events: none;
}

.article-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.article-image-container:active .article-image {
    transform: scale(1.02);
}

.article-text-content {
    padding: 20px 16px;
    max-width: 600px;
    margin: 0 auto;
}

.article-headline {
    font-size: 24px;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 10px;
    color: var(--text);
}

.article-meta {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
}

.article-body-text {
    font-size: 17px;
    line-height: 1.6;
    color: var(--text);
    white-space: pre-wrap;
    word-wrap: break-word;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    /* your existing styles */
}

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

.btn-share, .btn-save {
    background: #007bff;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
}

.btn-share:hover, .btn-save:hover {
    background: #0056b3;
}

.btn-share {
    background: #28a745; /* Green color for share */
}

.btn-share:hover {
    background: #218838;
}
/* ============================================
   TOAST NOTIFICATIONS
=========================================== */
.toast {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(0,0,0,0.9);
    color: white;
    padding: 12px 24px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 10000;
    pointer-events: none;
    max-width: 90%;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.dark .toast {
    background: rgba(255,255,255,0.95);
    color: #000;
}

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

/* ============================================
   TEXT SIZE CLASSES
=========================================== */
body[data-font-size="small"] {
    font-size: 14px;
}

body[data-font-size="small"] .news-title {
    font-size: 15px;
}

body[data-font-size="small"] .article-headline {
    font-size: 22px;
}

body[data-font-size="large"] {
    font-size: 18px;
}

body[data-font-size="large"] .news-title {
    font-size: 18px;
}

body[data-font-size="large"] .article-headline {
    font-size: 28px;
}

body[data-font-size="large"] .article-body-text {
    font-size: 19px;
}

.page-content {
    padding: 16px;
    max-width: 500px;
    margin: 0 auto;
    padding-bottom: 100px;
}

/* ============================================
   RESPONSIVE
=========================================== */
@media (min-width: 768px) {
    body {
        max-width: 414px;
        margin: 0 auto;
        border-left: 1px solid var(--border);
        border-right: 1px solid var(--border);
        box-shadow: 0 0 20px rgba(0,0,0,0.05);
    }
    
    .bottom-nav {
        max-width: 414px;
        left: 50%;
        transform: translateX(-50%);
    }
    
    .offline-banner,
    .toast {
        max-width: 380px;
    }
}

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

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

/* ============================================
   SCROLLBAR
=========================================== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}
/* ============================================
   OTP LOGIN STYLES
=========================================== */

.hidden {
    display: none !important;
}

.otp-info {
    text-align: center;
    margin-bottom: 24px;
}

.otp-info p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 4px;
}

.otp-email {
    color: var(--accent);
    font-weight: 600;
    font-size: 16px !important;
}

.otp-input-container {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 24px;
}

.otp-input {
    width: 48px;
    height: 56px;
    border: 2px solid var(--border);
    border-radius: 12px;
    text-align: center;
    font-size: 24px;
    font-weight: 600;
    color: var(--text);
    background: var(--card);
    transition: all 0.2s;
    caret-color: var(--accent);
}

.otp-input:focus {
    border-color: var(--accent);
    outline: none;
    transform: scale(1.05);
}

.otp-input.filled {
    border-color: var(--accent);
    background: rgba(0, 122, 255, 0.1);
}

.otp-timer {
    text-align: center;
    margin-bottom: 24px;
    color: var(--text-secondary);
    font-size: 14px;
}

.otp-timer .btn-text {
    color: var(--accent);
    font-weight: 600;
}

/* Loading spinner for button */
.btn-main.loading {
    position: relative;
    color: transparent;
}

.btn-main.loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-left: -10px;
    margin-top: -10px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
/* ============================================
   ANDROID WEBVIEW FIXES
=========================================== */

/* Make toggle slider show correct state */
.switch-slider {
    position: relative;
    display: block;
    width: 50px;
    height: 30px;
    background: #ccc;
    border-radius: 30px;
    transition: 0.3s;
}

.switch-slider::after {
    content: "";
    position: absolute;
    height: 22px;
    width: 22px;
    left: 4px;
    bottom: 4px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}

/* When checkbox is checked, move slider and knob */
#darkToggle:checked ~ .switch-slider {
    background: #007aff !important;
}

#darkToggle:checked ~ .switch-slider::after {
    transform: translateX(20px);
}

/* Ensure checkbox is clickable but invisible */
#darkToggle {
    position: absolute;
    width: 50px;
    height: 30px;
    opacity: 0;
    cursor: pointer;
    z-index: 100;
    margin: 0;
}

/* Android button fixes */
.btn-logout, .btn-danger {
    -webkit-tap-highlight-color: rgba(0,0,0,0.1);
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    outline: none;
}

/* Active state for touch */
.btn-logout:active, .btn-danger:active {
    opacity: 0.7;
    transform: scale(0.98);
}

/* Prevent text selection on buttons */
button {
    -webkit-user-select: none;
    user-select: none;
}
/* Dark mode for saved screen */
body.dark #saved {
    background: #1c1c1e !important;
}

body.dark #saved .page-content {
    background: #1c1c1e !important;
}

body.dark #saved #savedList {
    background: #1c1c1e !important;
}

body.dark #saved article {
    background: #2c2c2e !important;
    color: #ffffff !important;
}

body.dark #saved .page-header {
    background: #1c1c1e !important;
    color: #ffffff !important;
}
button {
    position: relative;
    z-index: 9999;
    pointer-events: auto;
}

.pref-section {
    position: relative;
    z-index: 9999;
}

.screen {
    pointer-events: auto;
}

.bottom-nav {
    z-index: 1;
}
/* --- ANDROID WEBVIEW TOUCH FIX --- */

button,
.btn-logout,
.btn-danger {
    pointer-events: auto !important;
    touch-action: manipulation !important;
    z-index: 9999;
    position: relative;
}

.pref-section {
    position: relative;
    z-index: 9999;
}

.screen {
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

/* THIS IS THE IMPORTANT ONE */
body, html {
    height: auto !important;
    overflow-x: hidden !important;
}
.settings-actions{
    padding:16px;
}

#logoutButton{
    display:block !important;
    width:100% !important;
    padding:18px !important;
    margin-top:14px !important;
    background:#2a2a2a !important;
    color:#ff3b30 !important;
    border:none !important;
    border-radius:16px !important;
    font-size:18px !important;
    font-weight:600 !important;
    text-align:center !important;
}

#deleteDataButton{
    display:block !important;
    width:100% !important;
    padding:18px !important;
    margin-top:14px !important;
    background:#3a0000 !important;
    color:#ff3b30 !important;
    border:none !important;
    border-radius:16px !important;
    font-size:18px !important;
    font-weight:600 !important;
    text-align:center !important;
}
.date {
    color: #9aa0a6;
    font-size: 13px;
    font-weight: 500;
}
.article-meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 10px 0;
    padding-bottom: 10px;
    border-bottom: 1px solid #333;
}

.article-date {
    color: #888;
    font-size: 14px;
}

.btn-share-inline {
    background: #28a745;
    color: white;
    border: none;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
}

.btn-share-inline:hover {
    background: #218838;
}
