/* ------------------------------------------------------------------
   Noorology Clients Portal — Admin styles
   Light mode only. Purple, white, black per the design system.
   ------------------------------------------------------------------ */

:root {
    --c-primary:        #6D28D9;
    --c-primary-hover:  #5B21B6;
    --c-secondary:      #8B5CF6;
    --c-soft:           #F5F3FF;
    --c-soft-2:         #EDE9FE;
    --c-text:           #111111;
    --c-text-2:         #555555;
    --c-muted:          #6B7280;
    --c-border:         #E5E7EB;
    --c-border-strong:  #D1D5DB;
    --c-bg:             #FFFFFF;
    --c-bg-soft:        #FAFAFB;
    --c-success:        #16A34A;
    --c-warning:        #D97706;
    --c-error:          #DC2626;

    --sidebar-w:        248px;
    --topbar-h:         64px;

    --radius-sm:        6px;
    --radius:           10px;
    --radius-lg:        16px;

    --shadow-sm:        0 1px 2px rgba(17,17,17,.04);
    --shadow:           0 4px 12px rgba(17,17,17,.06);
    --shadow-lg:        0 12px 32px rgba(17,17,17,.10);

    --font-body:        'Poppins', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-head:        'Playfair Display', Georgia, 'Times New Roman', serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font-body); color: var(--c-text); background: var(--c-bg-soft); line-height: 1.55; -webkit-font-smoothing: antialiased; }

a { color: var(--c-primary); text-decoration: none; }
a:hover { color: var(--c-primary-hover); text-decoration: underline; }

h1, h2, h3 { font-family: var(--font-head); color: var(--c-text); margin: 0 0 .4em; }
h2 { font-size: 22px; font-weight: 600; }
h3 { font-size: 16px; font-family: var(--font-body); font-weight: 600; }

p { margin: 0 0 1em; color: var(--c-text-2); }
.muted { color: var(--c-muted); }
.small { font-size: 13px; }

/* ----------------------------- Auth screen ----------------------------- */
.auth-body {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 32px 16px;
    background:
        radial-gradient(1200px 600px at 50% -200px, var(--c-soft) 0%, transparent 60%),
        var(--c-bg);
}
.auth-card {
    width: 100%; max-width: 440px;
    background: #fff; border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    padding: 32px 28px;
    box-shadow: var(--shadow-lg);
}
.auth-card h1 { font-size: 24px; margin-bottom: 4px; }
.auth-brand {
    display: flex; align-items: center; justify-content: center;
    color: var(--c-text); font-weight: 600; font-family: var(--font-head);
    margin-bottom: 24px;
    text-decoration: none;
}
.auth-brand:hover { text-decoration: none; color: var(--c-text); }
.auth-brand-logo {
    width: 100%;
    max-width: 260px;
    height: auto;
    display: block;
}
.cf-turnstile { margin: 12px 0 18px; }

/* ----------------------------- Admin shell ----------------------------- */
.admin-body { background: var(--c-bg-soft); }
.admin-shell { display: flex; min-height: 100vh; }

.admin-sidebar {
    width: var(--sidebar-w);
    background: #fff;
    border-right: 1px solid var(--c-border);
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
    flex-shrink: 0;
    z-index: 30;
}
.sidebar-brand {
    display: flex; align-items: center; justify-content: center;
    padding: 18px 16px;
    color: var(--c-text);
    border-bottom: 1px solid var(--c-border);
    text-decoration: none;
}
.sidebar-brand:hover { text-decoration: none; color: var(--c-text); }
.sidebar-brand-logo {
    width: 100%;
    max-width: 200px;
    height: auto;
    display: block;
}
.sidebar-nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.sidebar-link {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: var(--c-text-2);
    font-size: 14px;
    transition: background .12s ease, color .12s ease;
}
.sidebar-link i { width: 18px; text-align: center; color: var(--c-muted); }
.sidebar-link:hover { background: var(--c-soft); color: var(--c-primary); text-decoration: none; }
.sidebar-link:hover i { color: var(--c-primary); }
.sidebar-link.is-active {
    background: linear-gradient(135deg, var(--c-primary), var(--c-secondary));
    color: #fff;
}
.sidebar-link.is-active i { color: #fff; }
.sidebar-footer { padding: 12px 10px; border-top: 1px solid var(--c-border); }

.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.admin-topbar {
    height: var(--topbar-h);
    background: #fff;
    border-bottom: 1px solid var(--c-border);
    display: flex; align-items: center; gap: 16px;
    padding: 0 24px;
    position: sticky; top: 0; z-index: 20;
}
.sidebar-toggle {
    display: none;
    background: transparent; border: 1px solid var(--c-border);
    width: 38px; height: 38px; border-radius: var(--radius);
    cursor: pointer; color: var(--c-text);
}
.page-title {
    font-family: var(--font-body);
    font-size: 18px; font-weight: 600; color: var(--c-text);
    margin: 0; flex: 1;
}
.topbar-user { display: flex; align-items: center; gap: 10px; }
.topbar-link {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px;
    color: var(--c-text-2);
    border-radius: var(--radius);
    transition: background .12s ease, color .12s ease;
}
.topbar-link:hover { background: var(--c-soft); color: var(--c-primary); text-decoration: none; }
.user-name { font-size: 14px; color: var(--c-text-2); }
.user-avatar {
    width: 36px; height: 36px;
    background: var(--c-soft); color: var(--c-primary);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 14px;
}

.admin-content { padding: 24px; flex: 1; min-height: calc(100vh - var(--topbar-h)); }

.page-header {
    display: flex; align-items: flex-end; justify-content: space-between;
    gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}
.page-h { font-family: var(--font-head); font-size: 26px; font-weight: 600; margin: 0; }
.page-sub { margin: 4px 0 0; color: var(--c-text-2); }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ------------------------------- Buttons ------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 16px;
    border-radius: var(--radius);
    font: inherit; font-size: 14px; font-weight: 500;
    border: 1px solid transparent; cursor: pointer;
    text-decoration: none;
    transition: background .15s ease, color .15s ease, border-color .15s ease, transform .05s ease;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-primary { background: var(--c-primary); color: #fff; }
.btn-primary:hover { background: var(--c-primary-hover); color: #fff; }
.btn-secondary { background: #111; color: #fff; }
.btn-secondary:hover { background: #000; color: #fff; }
.btn-ghost { background: transparent; color: var(--c-text); border-color: var(--c-border-strong); }
.btn-ghost:hover { background: var(--c-soft); border-color: var(--c-primary); color: var(--c-primary); }
.btn-danger { background: var(--c-error); color: #fff; }
.btn-danger:hover { background: #B91C1C; color: #fff; }
.btn-block { display: flex; width: 100%; }

/* ------------------------------- Forms -------------------------------- */
label { display: block; margin-bottom: 14px; }
label > span { display: block; font-size: 13px; color: var(--c-text); margin-bottom: 6px; font-weight: 500; }
label small { display: block; color: var(--c-muted); font-size: 12px; margin-top: 4px; }

input[type="text"], input[type="email"], input[type="password"], input[type="url"],
input[type="date"], input[type="datetime-local"], input[type="number"],
input[type="search"], textarea, select {
    width: 100%; padding: 10px 12px;
    border: 1px solid var(--c-border-strong);
    border-radius: var(--radius);
    font: inherit; font-size: 14px;
    color: var(--c-text); background: #fff;
    transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, textarea:focus, select:focus {
    outline: none; border-color: var(--c-primary);
    box-shadow: 0 0 0 3px rgba(109,40,217,.15);
}
textarea { min-height: 110px; resize: vertical; }

/* ----------------------------- Flash messages -------------------------- */
.flash {
    border-radius: var(--radius);
    padding: 11px 14px; margin-bottom: 16px;
    font-size: 14px; border: 1px solid transparent;
}
.flash-success { background: #ECFDF5; color: #065F46; border-color: #A7F3D0; }
.flash-error   { background: #FEF2F2; color: #991B1B; border-color: #FECACA; }
.flash-warning { background: #FFFBEB; color: #92400E; border-color: #FDE68A; }
.flash-info    { background: var(--c-soft); color: #4C1D95; border-color: #DDD6FE; }

/* -------------------------------- Stats -------------------------------- */
.stat-grid {
    display: grid; gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    margin-bottom: 24px;
}
.stat-card {
    background: #fff; border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
    transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--c-soft-2); }
.stat-card.stat-purple { background: linear-gradient(135deg, var(--c-primary), var(--c-secondary)); color: #fff; border-color: transparent; }
.stat-card.stat-purple .stat-label, .stat-card.stat-purple .stat-meta { color: rgba(255,255,255,.85); }
.stat-label { font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--c-muted); margin-bottom: 6px; }
.stat-value { font-family: var(--font-head); font-size: 30px; font-weight: 600; line-height: 1.1; }
.stat-meta  { font-size: 12px; color: var(--c-muted); margin-top: 6px; }

/* -------------------------------- Panels ------------------------------- */
.dash-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.dash-side { display: flex; flex-direction: column; gap: 20px; }
.panel {
    background: #fff; border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.panel-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px; border-bottom: 1px solid var(--c-border);
}
.panel-head h3 { margin: 0; font-size: 15px; }
.panel-body { padding: 18px; }
.empty-state { padding: 24px; text-align: center; color: var(--c-muted); margin: 0; }

.portal-list { list-style: none; margin: 0; padding: 6px 0; }
.portal-list-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 18px;
    border-bottom: 1px solid var(--c-border);
}
.portal-list-item:last-child { border-bottom: none; }
.portal-list-thumb { width: 56px; height: 40px; border-radius: var(--radius-sm); overflow: hidden; background: var(--c-soft); flex-shrink: 0; }
.portal-list-thumb img { width: 100%; height: 100%; object-fit: cover; }
.portal-list-thumb .thumb-empty { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--c-primary); }
.portal-list-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.portal-list-title { font-weight: 500; color: var(--c-text); }
.portal-list-title:hover { color: var(--c-primary); }
.portal-list-tags { display: flex; gap: 6px; }
.portal-list-views { font-size: 12px; color: var(--c-muted); }

.badge {
    display: inline-block;
    padding: 3px 8px; border-radius: 999px;
    font-size: 11px; font-weight: 600;
    background: var(--c-soft); color: var(--c-primary);
    text-transform: uppercase; letter-spacing: 0.5px;
}
.badge-published  { background: #ECFDF5; color: #065F46; }
.badge-draft      { background: #F3F4F6; color: #374151; }
.badge-archived   { background: #FEF3C7; color: #92400E; }
.badge-public     { background: #ECFDF5; color: #065F46; }
.badge-pin        { background: #FEF3C7; color: #92400E; }
.badge-disabled   { background: #FEE2E2; color: #991B1B; }
.badge-youtube    { background: #FEE2E2; color: #B91C1C; }
.badge-hosted     { background: var(--c-soft); color: var(--c-primary); }
.badge-external   { background: #E0E7FF; color: #3730A3; }

.rank-list { list-style: decimal inside; padding: 12px 18px 18px; margin: 0; }
.rank-list li { padding: 6px 0; display: flex; align-items: baseline; gap: 8px; }
.rank-list li::marker { color: var(--c-primary); font-weight: 600; }
.rank-list a { flex: 1; color: var(--c-text); }
.rank-list a:hover { color: var(--c-primary); }

.activity-feed { list-style: none; padding: 12px 18px 18px; margin: 0; }
.activity-feed li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--c-border); }
.activity-feed li:last-child { border-bottom: none; }
.activity-dot {
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--c-primary);
    margin-top: 6px; flex-shrink: 0;
    box-shadow: 0 0 0 4px var(--c-soft);
}

/* ------------------------------- Tables -------------------------------- */
.table-wrap { background: #fff; border: 1px solid var(--c-border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm); }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td {
    padding: 12px 16px; text-align: left;
    border-bottom: 1px solid var(--c-border);
    font-size: 14px;
}
table.data th { background: var(--c-bg-soft); font-weight: 600; color: var(--c-text); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: var(--c-bg-soft); }

/* ----------------------------- Responsive ------------------------------ */
@media (max-width: 900px) {
    .dash-grid { grid-template-columns: 1fr; }
    .edit-layout { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
    :root { --sidebar-w: 0px; }
    .admin-sidebar {
        position: fixed; left: 0; top: 0;
        width: 260px; transform: translateX(-100%);
        transition: transform .2s ease;
        box-shadow: var(--shadow-lg);
    }
    .admin-shell.is-sidebar-open .admin-sidebar { transform: translateX(0); }
    .sidebar-toggle { display: inline-flex; align-items: center; justify-content: center; }
    .admin-content { padding: 16px; }
    .user-name { display: none; }
    .stat-value { font-size: 24px; }
    .form-grid-2 { grid-template-columns: 1fr; }
    .portal-cards { grid-template-columns: 1fr; }
    .edit-side { position: static; }
}

/* ----------------------------- Phase 2 --------------------------------- */
.filter-bar {
    display: flex; gap: 8px; flex-wrap: wrap;
    margin-bottom: 18px;
}
.filter-bar input[type="search"] {
    flex: 1; min-width: 220px; max-width: 360px;
    padding: 9px 12px; font-size: 14px;
    border: 1px solid var(--c-border-strong); border-radius: var(--radius);
}
.filter-bar select {
    padding: 9px 12px; font-size: 14px;
    border: 1px solid var(--c-border-strong); border-radius: var(--radius);
    background: #fff;
}
.filter-bar input:focus, .filter-bar select:focus {
    outline: none; border-color: var(--c-primary);
    box-shadow: 0 0 0 3px rgba(109,40,217,.15);
}

.portal-cards {
    display: grid; gap: 16px;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.portal-card-item {
    background: #fff;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    /* overflow stays visible so the ⋯ dropdown isn't clipped; the cover
       image clips its own top corners instead. */
    display: flex; flex-direction: column;
    position: relative;
    transition: box-shadow .12s ease, border-color .12s ease;
}
.portal-card-item:hover { box-shadow: var(--shadow); border-color: var(--c-soft-2); }
/* The card with its menu open lifts above neighbouring cards. */
.portal-card-item:has(details.action-menu[open]) { z-index: 30; }
.portal-card-cover {
    display: block; aspect-ratio: 16/9;
    background: var(--c-soft);
    overflow: hidden;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.portal-card-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-empty {
    display: flex; align-items: center; justify-content: center;
    width: 100%; height: 100%;
    color: var(--c-primary); opacity: .6; font-size: 26px;
}
.portal-card-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.portal-card-head { display: flex; flex-direction: column; }
.portal-card-title { font-weight: 600; color: var(--c-text); font-size: 15px; }
.portal-card-title:hover { color: var(--c-primary); }
.portal-card-slug { font-size: 12px; color: var(--c-muted); }
.portal-card-slug code { background: transparent; color: var(--c-muted); padding: 0; font-size: 12px; }
.portal-card-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.portal-card-meta {
    display: flex; gap: 12px; flex-wrap: wrap;
    font-size: 12px; color: var(--c-muted);
}
.portal-card-meta i { margin-right: 4px; }
.portal-card-actions {
    display: flex; gap: 6px; flex-wrap: wrap;
    padding-top: 8px; border-top: 1px solid var(--c-border);
    margin-top: auto;
}
.action-menu { position: relative; }
.action-menu summary {
    list-style: none; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    padding: 6px 10px; font-size: 13px;
    border: 1px solid var(--c-border-strong); border-radius: var(--radius);
    color: var(--c-text); background: transparent;
    transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.action-menu summary::-webkit-details-marker { display: none; }
.action-menu summary:hover { background: var(--c-soft); border-color: var(--c-primary); color: var(--c-primary); }
.action-menu-pop {
    position: absolute; right: 0; top: calc(100% + 4px);
    min-width: 180px;
    background: #fff; border: 1px solid var(--c-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    z-index: 50;
}
.action-menu-pop form { display: contents; }
.action-menu-pop button {
    display: flex; align-items: center; gap: 8px; width: 100%;
    padding: 8px 10px; border: 0; background: transparent; text-align: left;
    font: inherit; font-size: 13px; color: var(--c-text); cursor: pointer;
    border-radius: var(--radius-sm, 6px);
}
.action-menu-pop button:hover { background: var(--c-soft); color: var(--c-primary); }
.action-menu-pop button.danger { color: var(--c-error); }
.action-menu-pop button.danger:hover { background: #FEF2F2; color: var(--c-error); }

/* Edit page */
.edit-layout {
    display: grid; grid-template-columns: 1fr 320px;
    gap: 20px; align-items: start;
}
.edit-side { position: sticky; top: calc(var(--topbar-h) + 16px); }

.form-grid { display: grid; gap: 14px; }
.form-grid-2 { grid-template-columns: 1fr 1fr; }
label.checkbox {
    display: flex; align-items: center; gap: 8px; margin-bottom: 0;
}
label.checkbox > span { margin: 0; font-size: 14px; }
label.checkbox input { width: auto; }

.kv {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 0; border-bottom: 1px solid var(--c-border);
    font-size: 13px;
}
.kv:last-child { border-bottom: none; }
.kv > span:first-child { color: var(--c-muted); }
.kv > span:last-child  { color: var(--c-text); font-weight: 500; }

.copy-row {
    display: flex; gap: 6px; align-items: center;
}
.copy-row input {
    flex: 1; font-size: 12px;
    padding: 8px 10px;
    background: var(--c-bg-soft);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    color: var(--c-text-2);
}
.copy-row input:focus { outline: none; border-color: var(--c-primary); }

em { color: var(--c-error); font-style: normal; }

/* Brand image fallback (when logo file is missing) */
.brand-dot-fallback {
    display: inline-flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--c-primary), var(--c-secondary));
    color: #fff;
    border-radius: 50%;
    font-family: var(--font-head);
    font-weight: 600;
    aspect-ratio: 1 / 1;
}

/* ----------------------------- Link list ------------------------------ */
.link-list { list-style: none; margin: 0; padding: 0; }
.link-item {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--c-border);
    background: #fff;
}
.link-item:last-child { border-bottom: none; }
.link-ghost { opacity: .4; background: var(--c-soft); }
.link-handle {
    color: var(--c-muted); cursor: grab; padding: 4px 6px;
    border-radius: var(--radius);
    transition: background .12s ease, color .12s ease;
}
.link-handle:hover { background: var(--c-soft); color: var(--c-primary); }
.link-handle:active { cursor: grabbing; }
.link-icon {
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    background: var(--c-soft); color: var(--c-primary);
    border-radius: 10px;
    flex-shrink: 0; font-size: 16px;
}
.link-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.link-meta strong { color: var(--c-text); }
.link-url { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.link-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.link-actions { display: flex; gap: 6px; flex-shrink: 0; }

@media (max-width: 600px) {
    .link-item { flex-wrap: wrap; }
    .link-meta { width: 100%; order: 2; }
    .link-actions { order: 1; margin-left: auto; }
}

/* Galleries admin list */
.gallery-list { list-style: none; margin: 0; padding: 0; }
.gallery-list-item {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--c-border);
    background: #fff;
}
.gallery-list-item:last-child { border-bottom: none; }
.gallery-list-thumb {
    width: 80px; height: 56px;
    background: var(--c-soft);
    border-radius: var(--radius-sm, 6px);
    overflow: hidden;
    flex-shrink: 0;
}
.gallery-list-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Videos admin list — thumbnail with play overlay (used inside .link-item) */
.video-thumb {
    position: relative;
    width: 80px; height: 56px;
    background: #111;
    border-radius: var(--radius-sm, 6px);
    overflow: hidden;
    flex-shrink: 0;
}
.video-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.video-thumb .thumb-empty {
    display: flex; align-items: center; justify-content: center;
    height: 100%; color: #fff; opacity: .7;
}
.video-thumb-play {
    position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
    color: #fff; font-size: 14px;
    text-shadow: 0 1px 4px rgba(0,0,0,.6);
    pointer-events: none;
}
.gallery-list-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.gallery-list-title { color: var(--c-text); font-weight: 500; }
.gallery-list-title:hover { color: var(--c-primary); }
.gallery-list-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }

@media (max-width: 600px) {
    .gallery-list-item { flex-wrap: wrap; }
    .gallery-list-meta { width: 100%; order: 2; }
    .gallery-list-actions { order: 1; margin-left: auto; }
}

/* ---- Analytics charts (Phase 8) ---- */
.chart-bars {
    display: flex; align-items: flex-end; gap: 3px;
    height: 180px; padding-top: 6px;
}
.chart-col { flex: 1 1 0; display: flex; align-items: flex-end; height: 100%; min-width: 0; }
.chart-bar {
    width: 100%; min-height: 2px;
    background: linear-gradient(180deg, var(--c-secondary), var(--c-primary));
    border-radius: 4px 4px 0 0;
    transition: filter .12s ease;
}
.chart-col:hover .chart-bar { filter: brightness(1.12); }
.chart-axis {
    display: flex; justify-content: space-between;
    margin-top: 8px; color: var(--c-muted); font-size: 11px;
}
.heatstrip { display: grid; grid-template-columns: repeat(24, 1fr); gap: 4px; }
.heatcell {
    aspect-ratio: 1 / 1; border-radius: 5px;
    background: var(--c-primary);
}
.heataxis {
    display: flex; justify-content: space-between;
    margin-top: 8px; color: var(--c-muted); font-size: 11px;
}

/* ---- Share modal ---- */
.share-modal {
    position: fixed; inset: 0; z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.share-modal[hidden] { display: none; }
.share-modal-backdrop {
    position: absolute; inset: 0;
    background: rgba(17, 17, 17, .5);
    backdrop-filter: blur(2px);
}
.share-modal-card {
    position: relative;
    width: 100%; max-width: 480px;
    max-height: 90vh; overflow-y: auto;
    background: #fff; border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex; flex-direction: column;
}
.share-modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--c-border);
}
.share-modal-head h3 { margin: 0; font-size: 16px; }
.share-modal-x {
    border: 0; background: transparent; cursor: pointer;
    font-size: 26px; line-height: 1; color: var(--c-muted);
    padding: 0 4px;
}
.share-modal-x:hover { color: var(--c-text); }
.share-modal-body { padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.share-modal-body label { display: block; }
.share-modal-body label > span { display: block; font-size: 13px; font-weight: 500; margin-bottom: 4px; }
.share-modal-body textarea, .share-modal-body input[type="text"] {
    width: 100%; font: inherit; font-size: 14px;
    padding: 9px 11px; border: 1px solid var(--c-border-strong);
    border-radius: var(--radius); background: #fff; color: var(--c-text);
}
.share-modal-body small { color: var(--c-muted); font-size: 12px; }
.share-modal-foot {
    display: flex; gap: 10px; justify-content: flex-end;
    padding: 14px 20px; border-top: 1px solid var(--c-border);
    background: var(--c-bg-soft);
    position: sticky; bottom: 0;
}
.share-result {
    font-size: 13px; line-height: 1.6;
    padding: 12px 14px; border-radius: var(--radius);
    border: 1px solid var(--c-border);
}
.share-result.is-ok    { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.share-result.is-warn  { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.share-result.is-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.share-result-detail { margin-top: 8px; font-size: 12px; opacity: .9; word-break: break-word; }
