:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --accent: #0f9f6e;
    --ink: #162033;
    --muted: #657084;
    --soft: #f6f8fb;
    --panel: #ffffff;
    --line: #dfe5ef;
    --warning: #b45309;
    --danger: #dc2626;
    --shadow: 0 18px 45px rgba(22, 32, 51, 0.09);
    --radius: 8px;
}

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

body {
    background: var(--soft);
    color: var(--ink);
    font-family: 'Inter', sans-serif;
}

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

button,
a {
    -webkit-tap-highlight-color: transparent;
}

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 292px;
    background: var(--panel);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 20;
}

.sidebar-header {
    min-height: 82px;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
}

.logo {
    max-width: 156px;
    height: auto;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
}

.nav-divider {
    height: 1px;
    background: var(--line);
    margin: 10px 6px;
}

.category-btn {
    width: 100%;
    min-height: 42px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--ink);
    cursor: pointer;
    display: grid;
    grid-template-columns: 28px 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    text-align: left;
}

.category-btn > span {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    background: #eef4ff;
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 800;
}

.category-btn strong {
    font-size: 14px;
    font-weight: 700;
}

.category-btn em {
    color: var(--muted);
    font-style: normal;
    font-size: 12px;
}

.category-btn:hover,
.category-btn.active {
    background: #eef4ff;
    color: var(--primary);
}

.category-btn.active > span {
    background: var(--primary);
    color: #fff;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--line);
}

.admin-link {
    color: var(--primary);
    font-weight: 800;
    text-decoration: none;
}

.main-panel {
    flex: 1;
    min-width: 0;
}

.topbar {
    min-height: 82px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 30px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.eyebrow {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.topbar h1 {
    font-size: 24px;
    line-height: 1.2;
}

.content-area {
    width: min(1180px, 100%);
    margin: 0 auto;
    padding: 26px 30px 42px;
}

.toolbar {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 220px;
    gap: 14px;
    padding: 16px;
    box-shadow: 0 8px 24px rgba(22, 32, 51, 0.04);
}

.toolbar label {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    margin-bottom: 6px;
    text-transform: uppercase;
}

.toolbar input,
.toolbar select {
    width: 100%;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--ink);
    background: #fff;
    padding: 0 12px;
}

.quick-lanes {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-top: 18px;
}

.quick-lanes > div {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
}

.quick-lanes h2 {
    font-size: 15px;
    margin-bottom: 10px;
}

.mini-list {
    display: grid;
    gap: 8px;
}

.mini-list button {
    width: 100%;
    border: 1px solid var(--line);
    background: #fbfcfe;
    border-radius: 7px;
    padding: 10px;
    text-align: left;
    cursor: pointer;
}

.mini-list strong {
    display: block;
    color: var(--ink);
    font-size: 13px;
    margin-bottom: 2px;
}

.mini-list span,
.mini-list p {
    color: var(--muted);
    font-size: 12px;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin: 26px 0 14px;
}

.results-header h2 {
    font-size: 22px;
}

.results-header p {
    color: var(--muted);
    margin-top: 4px;
}

.content-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.content-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    min-height: 318px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(22, 32, 51, 0.05);
}

.card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 16px 0;
}

.card-header h3 {
    font-size: 17px;
    line-height: 1.3;
    margin: 8px 0 5px;
}

.card-header p {
    color: var(--muted);
    font-size: 13px;
}

.type-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 24px;
    border-radius: 999px;
    background: #e8f7f0;
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
    padding: 3px 9px;
}

.favorite-btn {
    width: 34px;
    height: 34px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
    color: var(--muted);
    cursor: pointer;
    flex: 0 0 auto;
    font-size: 19px;
    line-height: 1;
}

.favorite-btn.active {
    border-color: #f59e0b;
    color: #d97706;
    background: #fffbeb;
}

.card-preview {
    height: 132px;
    margin: 14px 16px 0;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fbfcfe;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-preview img,
.card-preview video,
.card-preview iframe {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border: 0;
}

.card-preview p {
    color: var(--muted);
    line-height: 1.5;
    padding: 14px;
    font-size: 13px;
    width: 100%;
    max-height: 100%;
    overflow: hidden;
    white-space: pre-wrap;
}

.tag-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 12px 16px 0;
}

.tag-row span {
    background: #f1f5f9;
    border-radius: 999px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    padding: 4px 8px;
}

.card-actions {
    margin-top: auto;
    padding: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.btn {
    min-height: 38px;
    border: 0;
    border-radius: 7px;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 13px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 800;
}

.btn:hover {
    background: var(--primary-dark);
}

.btn.secondary {
    background: #edf2f7;
    color: var(--ink);
}

.btn.secondary:hover {
    background: #e2e8f0;
}

.btn.ghost {
    background: #fff;
    color: var(--primary);
    border: 1px solid var(--line);
}

.btn.ghost:hover {
    background: #eef4ff;
}

.icon-btn {
    width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
    color: var(--ink);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.menu-btn {
    display: none;
    flex-direction: column;
    gap: 4px;
}

.menu-btn span {
    width: 18px;
    height: 2px;
    background: currentColor;
    display: block;
}

.close-sidebar-btn {
    display: none;
    font-size: 24px;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.48);
    z-index: 15;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    z-index: 50;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 22px;
}

.modal-backdrop.active {
    display: flex;
}

.modal {
    width: min(860px, 100%);
    max-height: calc(100vh - 44px);
    background: var(--panel);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    gap: 18px;
}

.modal-header h2 {
    font-size: 24px;
    line-height: 1.25;
    margin: 8px 0 5px;
}

.modal-header p {
    color: var(--muted);
}

.modal-body {
    padding: 20px;
    overflow: auto;
    display: grid;
    gap: 16px;
}

.modal-media {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    background: #f8fafc;
}

.modal-media img,
.modal-media video {
    width: 100%;
    max-height: 460px;
    object-fit: contain;
    display: block;
}

.modal-media iframe {
    display: block;
}

.content-text {
    white-space: pre-wrap;
    line-height: 1.62;
    background: #fbfcfe;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--ink);
    padding: 16px;
    font-family: 'Inter', sans-serif;
    font-size: 15px;
}

.modal-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.internal-note {
    border-left: 4px solid var(--warning);
    background: #fffbeb;
    border-radius: 7px;
    padding: 13px 14px;
}

.internal-note strong {
    color: var(--warning);
    display: block;
    margin-bottom: 5px;
}

.internal-note p {
    color: #5f3b0b;
    line-height: 1.5;
}

.modal-actions {
    padding: 16px 20px;
    border-top: 1px solid var(--line);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.toast {
    position: fixed;
    right: 22px;
    bottom: 22px;
    transform: translateY(18px);
    opacity: 0;
    pointer-events: none;
    background: var(--ink);
    color: #fff;
    border-radius: 7px;
    padding: 12px 14px;
    box-shadow: var(--shadow);
    transition: all .2s ease;
    z-index: 80;
    font-weight: 700;
}

.toast.active {
    opacity: 1;
    transform: translateY(0);
}

.empty-state {
    grid-column: 1 / -1;
    background: var(--panel);
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    color: var(--muted);
    padding: 32px;
    text-align: center;
}

@media (max-width: 1080px) {
    .content-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 820px) {
    .app-shell {
        display: block;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        transition: transform .24s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.active {
        display: block;
    }

    .menu-btn,
    .close-sidebar-btn {
        display: inline-flex;
    }

    .topbar {
        padding: 0 18px;
    }

    .content-area {
        padding: 18px;
    }

    .toolbar,
    .quick-lanes {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 520px) {
    .sidebar {
        width: min(292px, 88vw);
    }

    .topbar h1,
    .modal-header h2 {
        font-size: 20px;
    }

    .card-actions,
    .modal-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
}
