:root {
    /* Nord Color Palette */
    --nord0: #2e3440;
    --nord1: #3b4252;
    --nord2: #434c5e;
    --nord3: #4c566a;
    --nord4: #d8dee9;
    --nord5: #e5e9f0;
    --nord6: #eceff4;
    --nord7: #8fbcbb;
    --nord8: #88c0d0;
    --nord9: #81a1c1;
    --nord10: #5e81ac;
    --nord11: #bf616a;
    --nord12: #d08770;
    --nord13: #ebcb8b;
    --nord14: #a3be8c;
    --nord15: #b48ead;

    /* Semantic Theme Tokens */
    --bg-page: var(--nord0);
    --bg-surface: var(--nord1);
    --bg-surface-elevated: var(--nord2);
    --bg-surface-hover: var(--nord3);

    --text-main: var(--nord4);
    --text-heading: var(--nord8);
    --text-muted: var(--nord9);
    --text-highlight: var(--nord7);
    --text-important: var(--nord14);
    --text-footer: var(--nord9);

    --accent-primary: var(--nord8);
    --accent-hover: var(--nord7);
    --accent-visited: var(--nord10);
    --accent-active: var(--nord15);

    /* Shared Design Tokens */
    --radius-sm: 6px;
    --shadow-card: 0 3px 6px 0 rgba(15, 17, 21, 0.2);

    --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
}

/* ==========================================================================
   Base & Resets
   ========================================================================== */

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

body {
    background-color: var(--bg-page);
    color: var(--text-main);
    min-height: 100vh;
    line-height: 1.5;
    font-family: var(--font-sans);
    -webkit-font-smoothing: antialiased;
}

input, button, textarea, select {
    font: inherit;
}

a {
    color: var(--accent-primary);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: rgba(136, 192, 208, 0.4);
    transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

a:visited {
    color: var(--accent-visited);
    text-decoration-color: rgba(94, 129, 172, 0.4);
}

a:hover {
    color: var(--accent-hover);
    text-decoration-color: var(--accent-hover);
}

a:active {
    color: var(--accent-active);
}

h1, h2 {
    color: var(--text-heading);
}

h2 a {
    color: var(--text-heading);
    text-decoration: none;
    transition: color 0.15s ease;
}

h2 a:visited {
    color: var(--text-heading);
}

h2 a:hover {
    color: var(--accent-hover);
}

strong {
    color: var(--text-highlight);
}

::selection {
    background-color: var(--nord8);
    color: var(--nord0);
}

/* ==========================================================================
   Layout
   ========================================================================== */

.container {
    padding: 2rem 1.5rem;
    max-width: 1300px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(320px, 1fr);
    gap: 2rem;
    align-items: start;
}

.feed,
.sidebar {
    min-width: 0;
}

/* ==========================================================================
   Feed & Articles
   ========================================================================== */

.feed ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.feed li {
    padding: 1.5rem;
    background-color: var(--bg-surface);
    box-shadow: var(--shadow-card);
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.feed li > a {
    align-self: flex-start;
}

.feed h3 {
    color: var(--text-important);
}

.deets {
    color: var(--text-muted);
    line-height: 1.6;
}

/* ==========================================================================
   Sidebar & Search
   ========================================================================== */

.sidebar {
    background-color: var(--bg-surface);
    padding: 1.75rem 1.25rem;
    position: sticky;
    top: 2rem;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 2rem;
    box-shadow: var(--shadow-card);
    border-radius: var(--radius-sm);
}

.sidebar h1 {
    margin: 0;
}

.sidebar .stats {
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.5;
    padding: 1rem 0.5rem;
    border-top: 1px solid var(--nord2);
    border-bottom: 1px solid var(--nord2);
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.sidebar .stats p {
    margin: 0;
}

.sidebar search,
.sidebar search form {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

input[type=search] {
    width: 100%;
    padding: 0.65rem 0.85rem;
    background-color: var(--bg-surface-elevated);
    color: var(--nord4);
    box-shadow: var(--shadow-card);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

input[type=search]::placeholder {
    color: var(--nord9);
    opacity: 0.75;
}

input[type=search]:focus {
    outline: none;
    border-color: var(--accent-primary);
    background-color: var(--nord2);
}

.limit-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--nord4);
}

.limit-selector label {
    width: auto;
    display: inline;
    margin: 0;
    color: var(--nord4);
}

.limit-selector select {
    width: auto;
    padding: 0.4rem 0.65rem;
    background-color: var(--bg-surface-elevated);
    color: var(--nord4);
    box-shadow: var(--shadow-card);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.limit-selector select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

footer {
    color: var(--text-footer);
    margin: auto 0 0;
}

/* ==========================================================================
   Tags
   ========================================================================== */

.tags {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    padding: 0;
}

.tag-pill {
    display: inline-block;
    font-size: 0.9rem;
    border-radius: var(--radius-sm);
    background-color: var(--bg-surface-elevated);
    color: var(--nord4);
    text-decoration: none;
    margin: 0.2rem;
    padding: 0.5rem;
    box-shadow: var(--shadow-card);
    user-select: none;
}

.tag-pill:visited {
    color: var(--nord4);
}

.tag-pill:hover {
    background-color: var(--bg-surface-hover);
    color: var(--nord6);
}

.tag-pill.active {
    background-color: var(--accent-primary);
    color: var(--nord0);
}

.tag-pill:active {
    color: var(--accent-primary);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
    .container {
        grid-template-columns: 1fr;
        padding: 1rem;
    }

    .sidebar {
        position: static;
        max-height: none;
        order: -1;
    }
}