/* Reset and base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #fafafa;
    --surface: #ffffff;
    --border: #e2e2e2;
    --text: #1a1a1a;
    --text-muted: #6b7280;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --signal-5: #059669;
    --signal-4: #2563eb;
    --signal-3: #d97706;
    --signal-2: #dc2626;
    --signal-1: #7f1d1d;
    --topic-apple: #374151;
    --topic-apps: #7c3aed;
    --topic-app_development: #0891b2;
    --topic-ai: #c2410c;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #111111;
        --surface: #1a1a1a;
        --border: #2e2e2e;
        --text: #e5e5e5;
        --text-muted: #9ca3af;
        --shadow: 0 1px 3px rgba(0,0,0,0.3);
    }
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Nav */
header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

nav {
    max-width: 900px;
    margin: 0 auto;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text);
    text-decoration: none;
}

.nav-links { display: flex; gap: 1.25rem; }

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
}

.nav-links a.active, .nav-links a:hover { color: var(--primary); }

/* Main */
main {
    max-width: 900px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
}

/* Feed header */
.feed-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.feed-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
}

.post-count {
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--text-muted);
    margin-left: 0.5rem;
}

.feed-actions { display: flex; gap: 0.5rem; }
.inline-form { display: inline; }

/* Buttons */
.btn {
    padding: 0.4rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    background: var(--surface);
    color: var(--text);
}

.btn:hover { border-color: var(--text-muted); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); }

/* Filters */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding: 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.filter-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-right: 0.15rem;
}

.filter-pill {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 99px;
    font-size: 0.78rem;
    font-weight: 500;
    text-decoration: none;
    color: var(--text-muted);
    border: 1px solid var(--border);
    background: transparent;
}

.filter-pill:hover { border-color: var(--primary); color: var(--primary); }
.filter-pill.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Post cards */
.post-list { display: flex; flex-direction: column; gap: 0.5rem; }

.post-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.875rem 1rem;
    box-shadow: var(--shadow);
}

.post-card.signal-5 { border-left: 3px solid var(--signal-5); }
.post-card.signal-4 { border-left: 3px solid var(--signal-4); }

.post-header {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    margin-bottom: 0.5rem;
}

.signal-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.signal-badge.signal-5, .signal-bg-5 { background: var(--signal-5); }
.signal-badge.signal-4, .signal-bg-4 { background: var(--signal-4); }
.signal-badge.signal-3, .signal-bg-3 { background: var(--signal-3); }
.signal-badge.signal-2, .signal-bg-2 { background: var(--signal-2); }
.signal-badge.signal-1, .signal-bg-1 { background: var(--signal-1); }
.signal-badge.signal-0 { background: var(--text-muted); }
.signal-badge.signal-None { background: var(--text-muted); }

.post-meta { flex: 1; min-width: 0; }

.author { display: block; font-size: 0.9rem; }
.author strong { font-weight: 600; }

.handle {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-left: 0.25rem;
}

.boost-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-style: italic;
}

.original-author {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
}

.post-details {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.1rem;
}

.platform {
    text-transform: uppercase;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    background: var(--border);
    color: var(--text-muted);
}

.platform-mastodon { background: #563acc20; color: #563acc; }
.platform-bluesky { background: #0085ff20; color: #0085ff; }

@media (prefers-color-scheme: dark) {
    .platform-mastodon { background: #563acc40; color: #a78bfa; }
    .platform-bluesky { background: #0085ff40; color: #60a5fa; }
}

.btn-dismiss {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text-muted);
    padding: 0.1rem 0.3rem;
    line-height: 1;
    border-radius: 4px;
}

.btn-dismiss:hover { background: var(--border); color: var(--text); }

.post-content {
    font-size: 0.9rem;
    line-height: 1.55;
    margin-bottom: 0.4rem;
    white-space: pre-line;
    word-break: break-word;
}

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

.post-summary {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
    margin-bottom: 0.5rem;
    padding-left: 0.5rem;
    border-left: 2px solid var(--border);
}

.post-footer {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.78rem;
}

.topic-tags { display: flex; flex-wrap: wrap; gap: 0.25rem; }

.topic-pill {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 99px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #fff;
}

.topic-apple { background: var(--topic-apple); }
.topic-apps { background: var(--topic-apps); }
.topic-app_development { background: var(--topic-app_development); }
.topic-ai { background: var(--topic-ai); }

.post-badges { display: flex; gap: 0.25rem; }

.tone-badge, .substance-badge {
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    font-size: 0.7rem;
    background: var(--border);
    color: var(--text-muted);
}

.tone-constructive { background: #dcfce7; color: #166534; }
.tone-enthusiastic { background: #dbeafe; color: #1e40af; }
.tone-snarky { background: #fef3c7; color: #92400e; }
.tone-hostile { background: #fee2e2; color: #991b1b; }
.tone-alarmist { background: #fee2e2; color: #991b1b; }

@media (prefers-color-scheme: dark) {
    .tone-constructive { background: #166534; color: #bbf7d0; }
    .tone-enthusiastic { background: #1e3a5f; color: #93c5fd; }
    .tone-snarky { background: #78350f; color: #fde68a; }
    .tone-hostile { background: #7f1d1d; color: #fca5a5; }
    .tone-alarmist { background: #7f1d1d; color: #fca5a5; }
}

.link-badge {
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 600;
}

.link-badge.testflight { background: #dbeafe; color: #1e40af; }
.link-badge.appstore { background: #dbeafe; color: #1e40af; }

@media (prefers-color-scheme: dark) {
    .link-badge.testflight { background: #1e3a5f; color: #93c5fd; }
    .link-badge.appstore { background: #1e3a5f; color: #93c5fd; }
}

.post-link {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.78rem;
    margin-left: auto;
}

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

/* Maybe section */
.maybe-section {
    margin-top: 1.5rem;
}

.maybe-section summary {
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    padding: 0.5rem 0;
}

.maybe-section .post-list { margin-top: 0.5rem; }

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

.empty-state p:first-child { font-size: 1.1rem; margin-bottom: 0.5rem; }

.muted { color: var(--text-muted); font-size: 0.85rem; }

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.75rem;
    margin-bottom: 2rem;
}

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

.stat-number { font-size: 1.75rem; font-weight: 700; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.15rem; }

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

.stats-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
}

.stats-section h2 { font-size: 1rem; margin-bottom: 0.75rem; }

/* Bar chart */
.bar-chart { display: flex; flex-direction: column; gap: 0.4rem; }

.bar-row { display: flex; align-items: center; gap: 0.5rem; }
.bar-label { width: 1.6rem; flex-shrink: 0; font-size: 0.7rem; text-align: center; }

.bar-track {
    flex: 1;
    height: 1.1rem;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: 3px;
    min-width: 2px;
}

.bar-count { font-size: 0.8rem; color: var(--text-muted); width: 2.5rem; text-align: right; }

.topic-stat-row, .platform-stat-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.3rem 0;
}

.topic-count { font-weight: 600; }

/* Settings */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.settings-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
}

.settings-section h2 { font-size: 1rem; margin-bottom: 0.75rem; }

.settings-list dt {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-top: 0.5rem;
}

.settings-list dt:first-child { margin-top: 0; }

.settings-list dd {
    font-size: 0.9rem;
    margin-left: 0;
}

/* Responsive */
@media (max-width: 600px) {
    nav { padding: 0.6rem 0.75rem; }
    main { padding: 1rem 0.75rem; }
    .feed-header { flex-direction: column; align-items: flex-start; }
    .filters { flex-direction: column; }
    .post-card { padding: 0.75rem; }
    .post-footer { flex-direction: column; align-items: flex-start; }
    .post-link { margin-left: 0; }
}
