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

:root {
    --bg: #0a0a0f;
    --bg-card: #141420;
    --bg-elevated: #1c1c2e;
    --text: #e8e8f0;
    --text-muted: #8888a0;
    --accent: #f59e0b;
    --accent-hover: #d97706;
    --danger: #ef4444;
    --success: #22c55e;
    --exploration: #8b5cf6;
    --radius: 16px;
    --radius-sm: 10px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

html, body {
    height: 100%;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

#app { height: 100%; position: relative; }

/* Screens */
.screen { display: none; height: 100%; overflow-y: auto; padding: 0 20px 40px; }
.screen.active { display: flex; flex-direction: column; }

/* Loading */
.loading-container {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 16px;
}
.logo-mark { font-size: 48px; }
.loading-container h1 { font-size: 28px; font-weight: 700; }
.loading-container p { color: var(--text-muted); }

/* Auth */
.auth-container {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 20px;
    max-width: 360px; margin: 0 auto; width: 100%;
}
.auth-container h1 { font-size: 24px; }
#auth-form { display: flex; flex-direction: column; gap: 12px; width: 100%; }
input[type="email"], input[type="password"], input[type="text"] {
    width: 100%; padding: 14px 16px; border-radius: var(--radius-sm);
    border: 1px solid #2a2a40; background: var(--bg-card);
    color: var(--text); font-size: 16px; outline: none;
    transition: border-color 0.2s;
}
input:focus { border-color: var(--accent); }
.error-text { color: var(--danger); font-size: 14px; min-height: 20px; }

/* Buttons */
.btn-primary {
    padding: 14px 24px; border-radius: var(--radius-sm);
    background: var(--accent); color: #000; font-weight: 600;
    font-size: 16px; border: none; cursor: pointer;
    transition: background 0.2s;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary {
    padding: 14px 24px; border-radius: var(--radius-sm);
    background: transparent; color: var(--text); font-weight: 500;
    font-size: 16px; border: 1px solid #2a2a40; cursor: pointer;
}
.btn-text { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 15px; padding: 8px 0; }
.btn-icon { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 22px; padding: 4px; }
.btn-danger { padding: 14px 24px; border-radius: var(--radius-sm); background: var(--danger); color: #fff; font-weight: 600; font-size: 16px; border: none; cursor: pointer; width: 100%; }

/* Onboarding */
.onboarding-container {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; padding-top: 60px; gap: 12px;
    max-width: 500px; margin: 0 auto; width: 100%;
}
.onboarding-container h1 { font-size: 24px; text-align: center; }
.subtitle { color: var(--text-muted); text-align: center; }
.onboarding-options { display: flex; flex-direction: column; gap: 16px; width: 100%; margin-top: 20px; }
.onboard-option {
    display: flex; flex-direction: column; gap: 6px;
    padding: 20px; border-radius: var(--radius); border: 1px solid #2a2a40;
    background: var(--bg-card); cursor: pointer; text-align: left;
    transition: border-color 0.2s;
}
.onboard-option:hover { border-color: var(--accent); }
.option-icon { font-size: 28px; }
.option-title { font-size: 18px; font-weight: 600; color: var(--text); }
.option-desc { font-size: 14px; color: var(--text-muted); }
.onboard-subview { width: 100%; }
.hidden { display: none !important; }

/* Screenshot upload */
.screenshot-preview { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.screenshot-preview img { width: 80px; height: 80px; object-fit: cover; border-radius: 8px; }
input[type="file"] { margin: 12px 0; }

/* Topic grid */
.topic-grid { width: 100%; }
.topic-category { margin-bottom: 20px; }
.topic-category h3 { font-size: 15px; color: var(--accent); margin-bottom: 8px; font-weight: 600; }
.topic-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.topic-chip {
    padding: 8px 14px; border-radius: 20px; font-size: 13px;
    border: 1px solid #2a2a40; background: var(--bg-card);
    color: var(--text-muted); cursor: pointer; transition: all 0.2s;
    user-select: none;
}
.topic-chip.selected { border-color: var(--accent); background: rgba(245,158,11,0.15); color: var(--accent); }
.topic-actions {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 0; position: sticky; bottom: 0; background: var(--bg);
    width: 100%;
}
#topic-count { color: var(--text-muted); font-size: 14px; }

/* Brief */
.brief-header { padding: 20px 0 12px; flex-shrink: 0; }
.header-top { display: flex; justify-content: space-between; align-items: center; }
.brief-title { font-size: 26px; font-weight: 700; }
.brief-date { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.brief-greeting { color: var(--text-muted); font-size: 15px; margin-top: 2px; }

.stories-container { display: flex; flex-direction: column; gap: 16px; padding-bottom: 40px; }

/* Story card */
.story-card {
    border-radius: var(--radius);
    background: var(--bg-card); border: 1px solid #1e1e30;
    cursor: pointer; transition: transform 0.15s, border-color 0.2s;
    touch-action: pan-y; overflow: hidden;
}
.story-card:active { transform: scale(0.98); }
.story-card:hover { border-color: #2e2e48; }
.card-image-wrap { width: 100%; height: 180px; overflow: hidden; }
.card-image { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-body { padding: 16px 20px 20px; }
.story-card .card-confidence {
    display: inline-block; font-size: 11px; font-weight: 600;
    padding: 3px 8px; border-radius: 6px; margin-bottom: 8px;
    text-transform: uppercase; letter-spacing: 0.5px;
}
.story-card .card-confidence.high { background: rgba(34,197,94,0.15); color: var(--success); }
.story-card .card-confidence.exploration { background: rgba(139,92,246,0.15); color: var(--exploration); }
.story-card .card-headline { font-size: 18px; font-weight: 600; line-height: 1.35; margin-bottom: 8px; }
.story-card .card-summary { font-size: 14px; color: var(--text-muted); line-height: 1.5; margin-bottom: 12px; }
.story-card .card-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.story-card .card-tag {
    font-size: 11px; padding: 3px 8px; border-radius: 6px;
    background: var(--bg-elevated); color: var(--text-muted);
}
.story-card .card-meta {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: 10px; font-size: 12px; color: var(--text-muted);
}
.card-read-hint { color: var(--accent); font-weight: 600; font-size: 12px; }

/* Brief empty / loading */
.brief-empty, .brief-loading {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 12px;
    color: var(--text-muted);
}
.spinner {
    width: 32px; height: 32px; border: 3px solid #2a2a40;
    border-top-color: var(--accent); border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Story detail */
.story-header { padding: 16px 0; flex-shrink: 0; }
.story-detail { padding-bottom: 60px; }
.detail-hero-wrap { margin: 0 -20px 20px; overflow: hidden; max-height: 240px; }
.detail-hero { width: 100%; height: 240px; object-fit: cover; display: block; }
.btn-read-article {
    display: block; width: 100%; padding: 14px 20px; margin: 16px 0;
    background: var(--accent); color: #000; font-weight: 700;
    font-size: 15px; border-radius: var(--radius-sm); text-decoration: none;
    text-align: center; transition: background 0.2s;
}
.btn-read-article:hover { background: var(--accent-hover); }
.story-detail .detail-confidence {
    display: inline-block; font-size: 12px; font-weight: 600;
    padding: 4px 10px; border-radius: 6px; margin-bottom: 12px;
    text-transform: uppercase;
}
.story-detail .detail-confidence.high { background: rgba(34,197,94,0.15); color: var(--success); }
.story-detail .detail-confidence.exploration { background: rgba(139,92,246,0.15); color: var(--exploration); }
.story-detail h1 { font-size: 24px; line-height: 1.3; margin-bottom: 16px; }
.story-detail .detail-section { margin-bottom: 20px; }
.story-detail .detail-section h3 { font-size: 13px; color: var(--accent); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.story-detail .detail-section p { font-size: 15px; line-height: 1.6; color: var(--text-muted); }
.story-detail .detail-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 16px 0; }
.story-detail .detail-tag { font-size: 12px; padding: 4px 10px; border-radius: 6px; background: var(--bg-elevated); color: var(--text-muted); }
.story-detail .detail-sources { margin-top: 20px; }
.story-detail .detail-sources h3 { margin-bottom: 8px; }
.story-detail .source-link {
    display: block; padding: 10px 0; border-bottom: 1px solid #1e1e30;
    color: var(--accent); text-decoration: none; font-size: 14px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Settings */
.settings-header { display: flex; align-items: center; gap: 12px; padding: 16px 0; }
.settings-header h1 { font-size: 20px; }
.settings-content { padding-bottom: 40px; }
.settings-section { margin-bottom: 32px; }
.settings-section h2 { font-size: 16px; margin-bottom: 12px; color: var(--text-muted); }
.interests-list { display: flex; flex-direction: column; gap: 8px; }
.interest-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 16px; border-radius: var(--radius-sm);
    background: var(--bg-card); font-size: 14px;
}
.interest-weight { color: var(--accent); font-weight: 600; }

/* Responsive */
@media (min-width: 600px) {
    .screen { max-width: 560px; margin: 0 auto; padding: 0 24px 40px; }
}
