:root {
    --primary: #2563eb;
    --bg-color: #ffffff;
    --card-bg: #f8fafc;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --accent: #3b82f6;
    --border-color: #e2e8f0;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    padding-bottom: 80px;
}

header {
    padding: 0.75rem 1rem;
    background: #ffffff;
    border-bottom: 2px solid var(--primary);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.header-title {
    font-size: 1.25rem;
    color: var(--primary);
    font-weight: 800;
    margin: 0;
    white-space: nowrap;
}

.header-meta {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.update-text {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: 600;
    white-space: nowrap;
}

.refresh-inline {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 50%;
    transition: background 0.2s, transform 0.2s;
}

.refresh-inline:active {
    transform: scale(0.9);
    background: rgba(37, 99, 235, 0.1);
}

/* Mobile optimization */
@media (max-width: 480px) {
    .header-title {
        font-size: 1.1rem;
    }
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 1rem;
}

.selection-container {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.select-btn {
    flex: 1;
    padding: 0.6rem;
    border-radius: 8px;
    background: #f1f5f9;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
}

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

.tabs {
    display: flex;
    overflow-x: auto;
    padding: 0.5rem 0;
    margin-bottom: 1rem;
}

.tab {
    padding: 0.4rem 1rem;
    margin-right: 0.5rem;
    border-radius: 20px;
    background: #f1f5f9;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    white-space: nowrap;
    cursor: pointer;
    font-size: 0.85rem;
}

.tab.active {
    background: #334155;
    color: white;
    border-color: #334155;
}

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

.news-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.card-source {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: #111827;
}

.card-description {
    font-size: 0.95rem;
    color: #4b5563;
    line-height: 1.6;
    margin-bottom: 1rem;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #f1f5f9;
    padding-top: 0.75rem;
}

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

.btn-read {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
}

/* Old refresh button removed */
#refresh-btn.spinning svg {
    animation: rotate 1s linear infinite;
}

.spinning svg {
    animation: rotate 1s linear infinite;
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.loading {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

/* Portadas Grid */
.portada-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 15px;
    padding: 10px 0;
}

.portada-item {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s;
    display: flex;
    flex-direction: column;
}

.portada-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.portada-img {
    width: 100%;
    aspect-ratio: 1 / 1.4;
    object-fit: cover;
    background: #f1f5f9;
}

.portada-name {
    padding: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    text-align: center;
    color: var(--text-primary);
    border-top: 1px solid var(--border-color);
}

/* Modal View */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    display: none;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    overflow-y: auto;
}

.modal.active {
    display: flex;
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    z-index: 1001;
}

.modal-img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
}

/* Toasts */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #333;
    color: white;
    padding: 12px 24px;
    border-radius: 25px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 2000;
    transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    font-size: 0.9rem;
    font-weight: 600;
    max-width: 90%;
    text-align: center;
}

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

.toast-success {
    background: #10b981;
}

.toast-warning {
    background: #f59e0b;
    color: #111;
}

.toast-error {
    background: #ef4444;
}