:root {
    --bg: #f4f6fb;
    --surface: #ffffff;
    --surface-strong: #f8f9ff;
    --text: #172033;
    --muted: #64708a;
    --border: #dfe4ef;
    --accent: #4f46e5;
    --accent-strong: #3730a3;
    --accent-soft: #eef2ff;
    --danger: #b42318;
    --shadow: 0 10px 30px rgba(23, 32, 51, 0.08);
    --radius: 18px;
}

* {
    box-sizing: border-box;
}

/* Base styles */
body {
    margin: 0;
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: linear-gradient(180deg, var(--bg) 0%, #edf2ff 100%);
    color: var(--text);
    line-height: 1.5;
}

img {
    max-width: 100%;
    display: block;
}

a {
    color: inherit;
}

button,
input {
    font: inherit;
}

button {
    border: 0;
    cursor: pointer;
    border-radius: 999px;
    padding: 0.8rem 1.05rem;
    background: var(--accent);
    color: white;
    transition: transform 180ms ease, background 180ms ease;
}

button:hover {
    background: var(--accent-strong);
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
    outline: 3px solid rgba(79, 70, 229, 0.25);
    outline-offset: 2px;
}

.page-shell {
    max-width: 1120px;
    margin: 0 auto;
    padding: 1rem;
}

.topbar {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.brand-mark {
    width: 2.6rem;
    height: 2.6rem;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    color: white;
    display: grid;
    place-items: center;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.brand h1 {
    margin: 0;
    font-size: 1.2rem;
}

.brand p {
    margin: 0.15rem 0 0;
    color: var(--muted);
    font-size: 0.95rem;
}

.nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.7rem 0.95rem;
    border-radius: 999px;
    text-decoration: none;
    color: var(--muted);
    background: var(--surface-strong);
    border: 1px solid transparent;
}

.nav-link.active {
    color: var(--accent-strong);
    background: var(--accent-soft);
    border-color: rgba(79, 70, 229, 0.15);
}

.count-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    padding: 0 0.45rem;
    height: 1.5rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    background: rgba(79, 70, 229, 0.12);
    color: var(--accent-strong);
}

.content {
    display: grid;
    gap: 1rem;
    margin-top: 1rem;
}

.composer-card,
.list-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem;
}

.section-heading {
    margin-bottom: 1rem;
}

.section-heading h2 {
    margin: 0 0 0.2rem;
    font-size: 1.08rem;
}

.section-heading p {
    margin: 0;
    color: var(--muted);
    font-size: 0.95rem;
}

.save-form label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.input-row {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.input-row input {
    width: 100%;
    padding: 0.9rem 1rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-strong);
    color: var(--text);
}

.input-row button {
    min-height: 3rem;
    font-weight: 600;
}

.error-list {
    margin-top: 0.9rem;
    padding: 0.85rem 1rem;
    border-radius: 14px;
    background: #fef3f2;
    color: var(--danger);
    border: 1px solid #f7c5c0;
}

.empty-state {
    padding: 1.5rem;
    text-align: center;
    color: var(--muted);
    background: var(--surface-strong);
    border-radius: 16px;
    border: 1px dashed var(--border);
}

.card-list {
    display: grid;
    gap: 0.9rem;
}

.item-card {
    display: grid;
    gap: 0.9rem;
    padding: 1rem;
    background: var(--surface-strong);
    border: 1px solid var(--border);
    border-radius: 16px;
}

.card-media {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-height: 2.4rem;
}

.favicon {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    object-fit: cover;
    background: white;
}

.thumbnail {
    width: 100%;
    max-height: 120px;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.card-title {
    font-size: 1rem;
    font-weight: 700;
    text-decoration: none;
    color: var(--text);
}

.card-site,
.card-url,
.card-meta {
    color: var(--muted);
    font-size: 0.92rem;
    word-break: break-word;
}

.card-url {
    text-decoration: none;
}

.card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 0.2rem;
}

.card-actions form {
    display: inline-flex;
}

.card-actions button {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 0.72rem 0.9rem;
}

.card-actions button:hover {
    background: var(--accent-soft);
    color: var(--accent-strong);
}

/* Responsive layout adjustments */
@media (min-width: 700px) {
    .page-shell {
        padding: 1.5rem;
    }

    .topbar {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .input-row {
        flex-direction: row;
    }

    .input-row button {
        min-width: 8rem;
    }

    .item-card {
        grid-template-columns: minmax(0, 1fr) 3fr;
        align-items: start;
    }

    .card-media {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Optional dark-mode support for later */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f172a;
        --surface: #111827;
        --surface-strong: #182233;
        --text: #f8fafc;
        --muted: #94a3b8;
        --border: #243244;
        --accent: #818cf8;
        --accent-strong: #a5b4fc;
        --accent-soft: rgba(129, 140, 248, 0.16);
        --danger: #fda4af;
        --shadow: 0 10px 30px rgba(2, 6, 23, 0.35);
    }
}
