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

:root {
    --bg-deep: #0a0a12;
    --bg-surface: rgba(255,255,255,0.035);
    --bg-surface-hover: rgba(255,255,255,0.065);
    --bg-header: rgba(10,10,18,0.85);
    --border: rgba(255,255,255,0.075);
    --border-strong: rgba(255,255,255,0.12);
    --border-focus: rgba(94,234,212,0.35);
    --text-primary: #ececf1;
    --text-secondary: rgba(236,236,241,0.72);
    --text-muted: rgba(236,236,241,0.48);
    --accent: #5eead4;
    --accent-magenta: #f472b6;
    --accent-alt: #a78bfa;
    --gradient: linear-gradient(135deg, var(--accent-magenta), var(--accent-alt));
    --pill-site-bg: rgba(255,255,255,0.08);
    --radius-card: 12px;
    --radius-pill: 999px;
    --max-width: 1240px;

    --font-display: 'Bricolage Grotesque', system-ui, -apple-system, sans-serif;
    --font-sans: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
    --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

html { background: var(--bg-deep); color: var(--text-primary); }
body {
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.skip-link {
    position: absolute; left: -9999px; top: auto;
    padding: 8px 16px; background: var(--accent); color: var(--bg-deep);
    z-index: 100; border-radius: 4px; font-weight: 600;
}
.skip-link:focus { left: 16px; top: 16px; }

/* === Header === */
.header {
    position: sticky; top: 0; z-index: 50;
    background: var(--bg-header);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-bottom: 1px solid var(--border);
}
.header-inner {
    display: flex; align-items: center; gap: 20px;
    max-width: var(--max-width); margin: 0 auto;
    padding: 16px 32px;
}
.logo {
    display: flex; align-items: center; gap: 12px;
    text-decoration: none; flex-shrink: 0; line-height: 1.1;
}
.logo-icon {
    width: 32px; height: 32px; flex-shrink: 0;
}
.logo-text {
    display: flex; flex-direction: column; gap: 2px;
}
.logo-name {
    font-family: var(--font-display);
    font-size: 17px; font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text-primary);
}
.logo-tag {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}
.filters {
    display: flex; align-items: center; gap: 6px;
    flex: 1; overflow: hidden;
    min-width: 0;
}
.pill {
    padding: 5px 12px; border-radius: var(--radius-pill);
    font-size: 12px; font-weight: 500;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 220px;
    font-family: var(--font-sans);
}
.pill--media { background: var(--gradient); color: white; }
.pill--site {
    background: var(--pill-site-bg);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.pill-dismiss {
    color: rgba(255,255,255,0.7); font-size: 16px; line-height: 1;
    text-decoration: none; flex-shrink: 0;
    width: 20px; height: 20px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    transition: background 0.15s, color 0.15s;
}
.pill-dismiss:hover { color: white; background: rgba(255,255,255,0.08); }
.search-btn {
    display: flex; align-items: center; gap: 10px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 14px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 11px;
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.search-btn:hover { border-color: var(--accent); color: var(--text-primary); background: rgba(94,234,212,0.04); }
.search-btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.search-btn-label { font-family: var(--font-sans); font-size: 12px; font-weight: 500; }
.search-btn-kbd {
    font-family: inherit;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border);
    color: var(--text-muted);
    margin-left: 2px;
}

.filter-summary {
    max-width: var(--max-width); margin: 0 auto;
    padding: 20px 32px 0;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.02em;
}
.filter-summary strong {
    color: var(--accent);
    font-weight: 500;
}

/* === Feed === */
.feed {
    max-width: var(--max-width); margin: 0 auto;
    padding: 40px 32px 72px;
}

/* === Shared card image === */
.card-image {
    aspect-ratio: 16 / 9;
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
}
.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.card-image--fallback {
    background:
        linear-gradient(135deg, rgba(94,234,212,0.12), transparent 60%),
        linear-gradient(315deg, rgba(244,114,182,0.12), transparent 60%),
        repeating-linear-gradient(45deg, rgba(255,255,255,0.02) 0 2px, transparent 2px 6px),
        #14141f;
    display: flex;
    align-items: center;
    justify-content: center;
}
.column--anitube .card-image--fallback {
    background:
        linear-gradient(135deg, rgba(244,114,182,0.14), transparent 60%),
        linear-gradient(315deg, rgba(167,139,250,0.12), transparent 60%),
        repeating-linear-gradient(45deg, rgba(255,255,255,0.02) 0 2px, transparent 2px 6px),
        #14141f;
}
.card-image__watermark {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 13px;
    letter-spacing: -0.01em;
    color: rgba(236,236,241,0.28);
    text-align: center;
    padding: 0 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
    position: relative; z-index: 1;
}

.card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.02em;
    color: var(--text-muted);
    min-width: 0;
}

/* === Grid Section (single mode) === */
.grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.grid-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: background 0.2s, border-color 0.2s;
}
.grid-card:hover {
    background: var(--bg-surface-hover);
    border-color: rgba(94,234,212,0.22);
}

.grid-card .card-image { aspect-ratio: 16 / 9; }

.grid-card-content { padding: 12px 14px 14px; }

.grid-card-title {
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.018em;
    margin-top: 2px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--text-primary);
}

/* === Column Mode (split feed) === */
.columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
}

.column {
    min-width: 0;
    --col-accent: var(--accent);
}
.column--anitube { --col-accent: var(--accent-magenta); }

.column-head {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-bottom: 16px;
    margin-bottom: 22px;
    border-bottom: 1px solid var(--border);
    position: relative;
}
.column-head::after {
    content: '';
    position: absolute; bottom: -1px; left: 0;
    height: 2px; width: 48px;
    background: var(--col-accent);
    border-radius: 2px;
}

.column-kicker {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--col-accent);
    display: inline-flex; align-items: center; gap: 6px;
    line-height: 1;
}
.column-kicker-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 10px currentColor;
    flex-shrink: 0;
    animation: col-pulse 2.4s ease-in-out infinite;
}
@keyframes col-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}
@media (prefers-reduced-motion: reduce) {
    .column-kicker-dot { animation: none; }
}

.column-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 36px;
    letter-spacing: -0.035em;
    line-height: 1;
    color: var(--text-primary);
    min-width: 0;
}

.column-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.column-empty {
    color: var(--text-muted);
    font-size: 12px;
    padding: 16px 0;
    font-family: var(--font-mono);
}

.column-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: background 0.2s, border-color 0.2s;
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 0;
}
.column-card:hover {
    background: var(--bg-surface-hover);
    border-color: color-mix(in srgb, var(--col-accent) 28%, transparent);
}

.column-card .card-image {
    width: 100%;
    aspect-ratio: 16 / 9;
}

.column-card-content {
    padding: 12px 14px;
    flex: 1;
    min-width: 0;
}

.column-card-title {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.018em;
    margin-bottom: 6px;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.column-card-excerpt {
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.55;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Lead card: stacked, larger title, optional excerpt. */
.column-card--lead {
    grid-template-columns: 1fr;
    border-color: color-mix(in srgb, var(--col-accent) 18%, var(--border));
    position: relative;
}
.column-card--lead::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--col-accent), transparent);
    z-index: 2;
    pointer-events: none;
}
.column-card--lead .card-image {
    width: 100%;
    aspect-ratio: 16 / 9;
}
.column-card--lead .column-card-content {
    padding: 18px 20px 20px;
}
.column-card--lead .column-card-title {
    font-size: 24px;
    font-weight: 700;
    line-height: 1.12;
    letter-spacing: -0.03em;
    margin-bottom: 10px;
    -webkit-line-clamp: 3;
}
.column-card--lead .column-card-excerpt {
    font-size: 13px;
    line-height: 1.6;
    -webkit-line-clamp: 3;
}

/* Stack columns on narrow viewports. */
@media (max-width: 960px) {
    .columns {
        grid-template-columns: 1fr;
        gap: 40px;
    }
    .column-title { font-size: 30px; }
    .column-card--lead .column-card-title { font-size: 22px; }
}

/* === Card meta (shared) === */
.post-site {
    color: var(--col-accent, var(--accent));
    font-weight: 500;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    max-width: 70%;
}
.grid-card .post-site { color: var(--accent); }
.badge-yt {
    color: var(--accent-magenta);
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: 0.1em;
    background: rgba(244,114,182,0.15);
    border: 1px solid rgba(244,114,182,0.25);
    padding: 1px 5px;
    border-radius: 3px;
    font-weight: 500;
}
.post-time { color: var(--text-muted); flex-shrink: 0; }
.post-title {
    font-family: var(--font-display);
    color: var(--text-primary);
    font-size: 14px; font-weight: 600;
    letter-spacing: -0.018em;
    line-height: 1.3;
    margin-bottom: 6px;
    display: -webkit-box; -webkit-line-clamp: 2;
    -webkit-box-orient: vertical; overflow: hidden;
}
.post-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.tag {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 4px;
    background: color-mix(in srgb, var(--col-accent, var(--accent)) 10%, transparent);
    color: var(--col-accent, var(--accent));
    border: 1px solid color-mix(in srgb, var(--col-accent, var(--accent)) 22%, transparent);
    cursor: pointer;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s;
}
.tag:hover {
    background: color-mix(in srgb, var(--col-accent, var(--accent)) 18%, transparent);
    border-color: color-mix(in srgb, var(--col-accent, var(--accent)) 40%, transparent);
}

/* === Skeletons === */
.skeletons { display: flex; flex-direction: column; gap: 8px; }
.skel-line {
    height: 12px; border-radius: 4px;
    background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.04) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    margin-bottom: 6px;
}
.skel-short { width: 40%; }
.skel-long { width: 80%; height: 14px; }
.skel-medium { width: 30%; }

.skeleton .card-image {
    background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.04) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
    .skel-line { animation: none; }
    .skeleton .card-image { animation: none; }
}

/* === Empty state === */
.empty-state {
    display: flex; flex-direction: column; align-items: center;
    padding: 72px 20px; text-align: center;
    font-family: var(--font-sans);
}
.empty-icon {
    font-size: 32px;
    opacity: 0.6;
    margin-bottom: 14px;
    color: var(--accent);
}
.empty-state h2 {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 8px;
}
.empty-state p {
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.5;
    max-width: 320px;
}
.btn-clear {
    margin-top: 18px;
    display: inline-block;
    background: var(--gradient);
    color: white;
    padding: 8px 18px;
    border-radius: var(--radius-pill);
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    transition: transform 0.15s;
}
.btn-clear:hover { transform: translateY(-1px); }

/* === End marker, back-to-top === */
.end-marker {
    display: flex; align-items: center; gap: 14px;
    padding: 28px 0 8px;
}
.end-line {
    flex: 1; height: 1px;
    background: linear-gradient(90deg, transparent, rgba(94,234,212,0.3), transparent);
}
.end-marker span {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
}
#back-to-top { text-align: center; padding: 12px 0; }
#back-to-top a {
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-decoration: none;
}
#back-to-top a:hover { color: var(--text-primary); }

/* === Search modal === */
.modal {
    position: fixed; inset: 0;
    z-index: 100;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 80px;
}
.modal[hidden] { display: none; }
.modal-backdrop {
    position: absolute; inset: 0;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.modal-content {
    position: relative;
    width: 92%;
    max-width: 440px;
    background: rgba(16,16,26,0.98);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-strong);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 24px 72px rgba(0,0,0,0.5);
}
.search-input-wrap {
    display: flex; align-items: center; gap: 10px;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border-focus);
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 14px;
}
.search-input-wrap svg { color: var(--accent); flex-shrink: 0; }
#search-input {
    flex: 1;
    background: none;
    border: none; outline: none;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
}
#search-input::placeholder { color: var(--text-muted); }
.search-tabs {
    display: flex;
    background: rgba(255,255,255,0.04);
    border-radius: 8px;
    padding: 3px;
    margin-bottom: 14px;
    gap: 2px;
}
.tab {
    flex: 1; text-align: center;
    padding: 6px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    background: none;
    color: var(--text-muted);
    transition: color 0.15s, background 0.15s;
}
.tab:hover { color: var(--text-primary); }
.tab.active {
    background: var(--gradient);
    color: white;
}
.search-results { max-height: 320px; overflow-y: auto; }
.search-result {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    transition: background 0.12s;
}
.search-result:hover,
.search-result.highlighted {
    background: rgba(94,234,212,0.08);
}
.search-result-name { color: var(--text-primary); font-size: 13px; }
.search-result-count {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 11px;
}
mark { color: var(--accent); background: none; }

.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    border: 0;
}

/* === Tablet === */
@media (max-width: 1100px) {
    .grid { grid-template-columns: repeat(2, 1fr); }
    .feed { padding: 32px 24px 64px; }
    .header-inner { padding: 14px 24px; }
}

/* === Mobile === */
@media (max-width: 767px) {
    .header-inner { padding: 12px 16px; gap: 12px; }
    .logo-tag { display: none; }
    .feed { padding: 24px 16px 56px; }
    .pill { max-width: 160px; }
    .filter-summary { padding: 14px 16px 0; }

    .grid { grid-template-columns: 1fr; }

    .column-title { font-size: 26px; }
    .column-card { grid-template-columns: 120px 1fr; }
    .column-card--lead .column-card-title { font-size: 20px; }

    .grid-card-title { font-size: 13px; }
    .search-btn-label, .search-btn-kbd { display: none; }
    .search-btn { padding: 8px; }
}
