/* ── Reset & base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
    --bg:        #f1f5f9;
    --surface:   #ffffff;
    --border:    #e2e8f0;
    --primary:   #4f46e5;
    --primary-h: #4338ca;
    --danger:    #ef4444;
    --danger-h:  #dc2626;
    --success:   #22c55e;
    --text:      #1e293b;
    --muted:     #64748b;
    --radius:    8px;
    --shadow:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border-radius: var(--radius);
    font-size: 14px; font-weight: 500; cursor: pointer;
    border: none; transition: background .15s, opacity .15s;
    text-decoration: none;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled)  { background: var(--primary-h); }
.btn-danger   { background: var(--danger);  color: #fff; }
.btn-danger:hover:not(:disabled)   { background: var(--danger-h); }
.btn-ghost    { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled)    { background: var(--bg); }
.btn-full     { width: 100%; justify-content: center; padding: 10px 16px; font-size: 15px; }
.btn-sm       { padding: 5px 10px; font-size: 12px; }

/* ── Forms ────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 5px; }
.form-group input {
    width: 100%; padding: 9px 12px;
    border: 1px solid var(--border); border-radius: var(--radius);
    font-size: 16px; font-family: inherit;
    transition: border-color .15s;
    background: var(--surface);
}
.form-group input:focus { outline: none; border-color: var(--primary); }
.form-error {
    font-size: 13px; color: var(--danger);
    background: #fef2f2; border: 1px solid #fecaca;
    border-radius: var(--radius); padding: 8px 12px;
    margin-bottom: 12px;
}
.form-success {
    font-size: 13px; color: #15803d;
    background: #f0fdf4; border: 1px solid #bbf7d0;
    border-radius: var(--radius); padding: 8px 12px;
    margin-bottom: 12px;
}

/* ── Auth page ────────────────────────────────────────────────────────── */
.auth-page {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 24px 16px;
}
.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 36px 32px;
    width: 100%; max-width: 400px;
    box-shadow: 0 4px 24px rgba(0,0,0,.08);
}
.auth-logo {
    font-size: 22px; font-weight: 800;
    color: var(--primary); margin-bottom: 6px;
}
.auth-title {
    font-size: 20px; font-weight: 700;
    margin-bottom: 24px; color: var(--text);
}
.auth-form { margin-top: 20px; }
.auth-footer {
    text-align: center; margin-top: 20px;
    color: var(--muted); font-size: 13px;
}
.auth-footer a { color: var(--primary); text-decoration: none; font-weight: 500; }
.auth-footer a:hover { text-decoration: underline; }

/* ── Role badge ───────────────────────────────────────────────────────── */
.role-badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .04em;
    vertical-align: middle; margin-left: 6px;
}
.role-user  { background: #e0f2fe; color: #0369a1; }
.role-admin { background: #fef3c7; color: #92400e; }
.verified-badge, .unverified-badge {
    display: inline-block;
    padding: 1px 8px; border-radius: 999px;
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .04em;
    vertical-align: middle;
}
.verified-badge   { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.unverified-badge { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.you-badge  {
    display: inline-block;
    padding: 1px 8px; border-radius: 999px;
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .04em;
    vertical-align: middle; margin-left: 8px;
    background: #f0fdf4; color: #15803d;
    border: 1px solid #bbf7d0;
}

/* ── Verify banner ────────────────────────────────────────────────────── */
.verify-banner {
    position: fixed; top: 56px; left: 0; right: 0; z-index: 150;
    background: #fef3c7; border-bottom: 1px solid #fde68a;
    color: #78350f; font-size: 13px; font-weight: 500;
    text-align: center; padding: 8px 16px;
    display: flex; align-items: center; justify-content: center; gap: 10px;
}
.verify-banner-btn {
    background: none; border: none; padding: 0;
    color: #92400e; font-size: 13px; font-weight: 600;
    text-decoration: underline; cursor: pointer;
}
.verify-banner-btn:hover { color: #78350f; }
.verify-banner-btn:disabled { opacity: .6; cursor: not-allowed; }
.verify-banner-msg { font-size: 13px; font-weight: 500; color: #15803d; }
.verify-banner-msg--error { color: #b91c1c; }
.app-shell.has-verify-banner { padding-top: 92px; } /* 56px header + 36px banner */
.app-shell.has-verify-banner .main { padding-top: 16px; }

/* ── App header ───────────────────────────────────────────────────────── */
.app-header {
    position: fixed; top: 0; left: 0; right: 0; height: 56px;
    display: flex; align-items: center; gap: 16px;
    padding: 0 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    z-index: 200;
}
.header-logo {
    font-size: 17px; font-weight: 800;
    color: var(--primary); flex-shrink: 0;
}
.header-nav { display: flex; gap: 4px; flex: 1; }
.header-nav-item {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 6px 12px; border-radius: var(--radius);
    color: var(--muted); font-size: 14px; font-weight: 500;
    text-decoration: none; transition: background .15s, color .15s;
}
.header-nav-item:hover  { background: var(--bg); color: var(--text); }
.header-nav-item.active { background: #eef2ff; color: var(--primary); }
.header-user {
    display: flex; align-items: center;
    margin-left: auto; flex-shrink: 0;
}
.header-avatar-wrap { position: relative; }
.header-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 700; color: #fff;
    background: var(--primary);
    border: none; cursor: pointer;
    transition: opacity .15s;
}
.header-avatar:hover { opacity: .85; }


.header-menu {
    position: absolute; top: calc(100% + 8px); right: 0;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); min-width: 190px;
    box-shadow: 0 4px 16px rgba(0,0,0,.1);
    z-index: 300; overflow: hidden;
}
.header-menu-info {
    padding: 12px 14px 10px;
    display: flex; align-items: center; gap: 8px; overflow: hidden;
}
.header-menu-name { font-size: 13px; font-weight: 600; color: var(--text); min-width: 0; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.header-menu-divider { height: 1px; background: var(--border); margin: 0; }
.header-menu-item {
    display: flex; align-items: center; gap: 9px;
    width: 100%; padding: 10px 14px;
    font-size: 13px; font-weight: 500; color: var(--text);
    text-decoration: none; background: none; border: none;
    cursor: pointer; text-align: left;
    transition: background .12s;
}
.header-menu-item:hover { background: var(--bg); }

/* ── App shell (post-login layout) ───────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; padding-top: 56px; }

.main {
    padding: 28px 32px;
    flex: 1; min-height: 100vh;
    max-width: 1200px; margin: 0 auto; width: 100%;
}

/* ── Profile page ─────────────────────────────────────────────────────── */
.profile-page   { max-width: 560px; display: flex; flex-direction: column; gap: 24px; }
.profile-card   {
    display: flex; align-items: center; gap: 20px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 24px;
    box-shadow: var(--shadow);
}
.profile-avatar {
    width: 64px; height: 64px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; font-weight: 700; color: #fff;
    background: var(--primary);
}
.profile-info     { min-width: 0; }
.profile-name-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.profile-name-row .role-badge,
.profile-name-row .you-badge  { vertical-align: unset; margin-left: 0; flex-shrink: 0; }
.profile-name     { font-size: 18px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.profile-email    { font-size: 13px; color: var(--muted); margin-top: 2px; }.profile-meta-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.profile-meta     { font-size: 12px; color: var(--muted); }
.profile-section  {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 24px;
    box-shadow: var(--shadow);
}
.section-title    { font-size: 15px; font-weight: 600; margin-bottom: 16px; }
.danger-zone      { border-color: var(--danger); }
.danger-zone .section-title { color: var(--danger); }
.danger-zone-desc { font-size: 13px; color: var(--muted); margin-bottom: 16px; }

/* ── Admin section (profile page) ────────────────────────────────────── */
.admin-section    { border-color: #f97316; }
.admin-section > .section-title { color: #c2410c; }
.admin-subsection {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px 24px;
    box-shadow: var(--shadow); margin-top: 16px;
}
.admin-subsection:first-of-type { margin-top: 0; }
.subsection-title { font-size: 14px; font-weight: 600; margin-bottom: 14px; color: var(--text); }
.danger-title     { color: var(--danger); }
.admin-delete-error { margin-top: 10px; }

/* ── Section card (shared) ────────────────────────────────────────────── */
.section-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    overflow: hidden;
}

/* ── Users page ───────────────────────────────────────────────────────── */
.users-page   { max-width: 800px; }
.venues-page  { max-width: 900px; }
.venue-detail-card        { margin-top: 16px; }
.venue-detail-title       { margin-bottom: 16px; padding: 20px 24px 0; }
.venue-halls-header       { margin-bottom: 0; }
.venue-detail-dl  { display: grid; gap: 0; margin: 0; padding: 0 24px 4px; }
.venue-info { position: relative; display: inline-flex; align-items: center; margin-left: 6px; vertical-align: middle; }
.venue-info-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 15px; height: 15px; border-radius: 50%;
    border: 1px solid var(--muted); background: none; color: var(--muted);
    font-size: 10px; font-style: italic; font-family: Georgia, serif;
    cursor: pointer; line-height: 1; padding: 0; flex-shrink: 0;
}
.venue-info-btn:hover { border-color: var(--primary); color: var(--primary); }
.venue-info-tip {
    display: none; position: absolute;
    left: 50%; bottom: calc(100% + 7px); transform: translateX(-50%);
    width: 220px; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 8px 10px; font-size: 12px; font-weight: 400;
    color: var(--text); line-height: 1.5; white-space: normal;
    z-index: 100; pointer-events: none;
}
.venue-info-tip::after {
    content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
    border: 5px solid transparent; border-top-color: var(--border);
}
.venue-info-tip::before {
    content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
    border: 5px solid transparent; border-top-color: var(--surface);
    margin-top: -1px; z-index: 1;
}
@media (hover: hover) { .venue-info:hover .venue-info-tip { display: block; } }
.venue-info--open .venue-info-tip { display: block; pointer-events: auto; }
.venue-detail-row { display: grid; grid-template-columns: 120px 1fr; padding: 10px 0; border-bottom: 1px solid var(--border); }
.venue-detail-row:last-child { border-bottom: none; }
.venue-detail-row dt { font-size: 13px; color: var(--muted); font-weight: 500; }
.venue-detail-row dd { margin: 0; font-size: 14px; }
.users-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.users-total  { font-size: 13px; color: var(--muted); }
.users-title  { margin: 0; }

.users-table  { width: 100%; border-collapse: collapse; }
.users-table th {
    text-align: left; padding: 10px 24px;
    font-size: 12px; font-weight: 600; color: var(--muted);
    text-transform: uppercase; letter-spacing: .04em;
    background: var(--bg); border-bottom: 1px solid var(--border);
}
.users-table th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.users-table th.sortable:hover { color: var(--text); }
.users-table th.sort-asc::after  { content: ' ↓'; color: var(--primary); }
.users-table th.sort-desc::after { content: ' ↑'; color: var(--primary); }
.users-table th.sort-invert.sort-asc::after  { content: ' ↑'; color: var(--primary); }
.users-table th.sort-invert.sort-desc::after { content: ' ↓'; color: var(--primary); }
.users-table td { padding: 12px 24px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.users-table tr:last-child td { border-bottom: none; }
.users-table tbody tr.users-row { cursor: pointer; }
.users-table tbody tr:hover td { background: var(--bg); }

.users-username { font-size: 14px; font-weight: 500; color: var(--text); display: inline-block; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }
.users-email    { font-size: 13px; color: var(--muted); }
.users-date     { font-size: 13px; color: var(--muted); white-space: nowrap; }
.users-state    { text-align: center; padding: 40px 24px; color: var(--muted); font-size: 14px; }

.users-pagination {
    display: flex; align-items: center; justify-content: center; gap: 16px;
    padding: 16px 24px; border-top: 1px solid var(--border);
}
.users-page-info { font-size: 13px; color: var(--muted); }

/* ── Verify prompt (unverified dashboard) ─────────────────────────────── */
.verify-prompt { max-width: 520px; text-align: center; padding: 48px 40px; }
.verify-prompt-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 64px; height: 64px; border-radius: 50%;
    background: #eff6ff; color: #2563eb; margin-bottom: 20px;
}
.verify-prompt-title { font-size: 20px; font-weight: 700; margin-bottom: 12px; color: var(--text); }
.verify-prompt-body  { font-size: 14px; color: var(--muted); margin-bottom: 10px; line-height: 1.6; }
.verify-prompt-hint  { font-size: 13px; color: var(--muted); margin-top: 16px; opacity: .75; }

/* ── Dashboard placeholder ────────────────────────────────────────────── */
.dashboard-placeholder {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-height: 360px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--muted);
    box-shadow: var(--shadow);
}
.dashboard-placeholder svg { margin-bottom: 16px; opacity: .35; }
.dashboard-placeholder p   { font-size: 15px; }

/* ── Throbber ─────────────────────────────────────────────────────────── */
.throbber {
    display: flex; align-items: center; justify-content: center;
    padding: 48px 0;
}
.throbber::after {
    content: '';
    width: 28px; height: 28px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Splash / loading ─────────────────────────────────────────────────── */
.splash {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    color: var(--muted); font-size: 15px;
}

/* ── Toast ────────────────────────────────────────────────────────────── */
#toast {
    position: fixed; bottom: 24px; right: 24px;
    padding: 12px 20px; border-radius: var(--radius);
    color: #fff; font-size: 14px; font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,.2);
    transform: translateY(80px); opacity: 0;
    transition: transform .25s ease, opacity .25s ease;
    z-index: 500; pointer-events: none;
}
#toast.show    { transform: translateY(0); opacity: 1; }
#toast.success { background: var(--success); }
#toast.error   { background: var(--danger); }

/* ── Form textarea & select ───────────────────────────────────────────── */
.form-group textarea {
    width: 100%; padding: 9px 12px;
    border: 1px solid var(--border); border-radius: var(--radius);
    font-size: 15px; font-family: inherit; line-height: 1.5;
    transition: border-color .15s;
    background: var(--surface); resize: vertical; min-height: 80px;
}
.form-group textarea:focus { outline: none; border-color: var(--primary); }
.form-group select {
    width: 100%; padding: 9px 12px;
    border: 1px solid var(--border); border-radius: var(--radius);
    font-size: 14px; font-family: inherit;
    background: var(--surface); color: var(--text); cursor: pointer;
    transition: border-color .15s;
}
.form-group select:focus { outline: none; border-color: var(--primary); }

/* ── Article edit page ────────────────────────────────────────────────── */
.article-edit-page { max-width: 720px; margin: 0 auto; }

.article-edit-header {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; margin-bottom: 24px; flex-wrap: wrap;
}
.article-edit-title { font-size: 20px; font-weight: 700; flex: 1; margin: 0; }
.article-edit-actions { display: flex; align-items: center; gap: 8px; }

.pub-datetime { display: flex; gap: 8px; }
.pub-datetime input { flex: 1; min-width: 0; }

.block-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.block-empty { font-size: 13px; color: var(--muted); padding: 8px 0; }

.block-card {
    border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.block-card-header {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 12px;
    background: var(--bg); border-bottom: 1px solid var(--border);
}
.block-type-label {
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .05em; color: var(--muted); flex: 1;
}
.block-actions { display: flex; gap: 4px; }
.block-card-fields { padding: 0; }

/* ── Block editor WYSIWYG field styles ───────────────────────────────── */

/* Shared: bare textarea/input reset */
.block-edit-bare-input,
.block-edit-paragraph textarea,
.block-edit-subheading input,
.block-edit-conclusion textarea,
.block-edit-quote textarea,
.block-edit-quote input,
.block-edit-evidence textarea,
.block-edit-evidence input {
    width: 100%; border: none; outline: none; resize: vertical;
    background: transparent; font-family: inherit;
}

/* Paragraph */
.block-edit-paragraph { padding: 14px 16px; }
.block-edit-paragraph textarea {
    font-size: 17px; line-height: 1.75; color: var(--text);
    min-height: 72px;
}

/* Subheading */
.block-edit-subheading { padding: 12px 16px; }
.block-edit-subheading input {
    font-size: 1.3rem; font-weight: 700; color: var(--text);
    resize: none;
}

/* Quote */
.block-edit-quote {
    border-left: 4px solid var(--primary);
    background: #eef2ff;
    padding: 16px 20px;
}
.block-edit-quote textarea {
    font-size: 1.1rem; font-weight: 500; font-style: italic;
    line-height: 1.65; color: var(--text);
    min-height: 56px; margin-bottom: 10px;
}
.block-edit-quote input {
    font-size: 13px; color: var(--muted); resize: none;
}
.block-edit-quote input::placeholder { opacity: .6; }

/* Evidence */
.block-edit-evidence {
    background: var(--bg);
    border-left: 3px solid var(--muted);
    padding: 16px 20px;
}
.block-edit-evidence textarea {
    font-size: 15px; line-height: 1.6; color: var(--text);
    min-height: 56px; margin-bottom: 8px;
}
.block-edit-evidence input {
    font-size: 12px; font-style: italic; color: var(--muted); resize: none;
}
.block-edit-evidence input::placeholder { opacity: .6; }

/* Conclusion */
.block-edit-conclusion {
    border-top: 2px solid var(--border);
    padding: 16px 16px 14px;
}
.block-edit-conclusion textarea {
    font-size: 17px; line-height: 1.8; font-style: italic;
    color: var(--text); min-height: 72px;
}

/* Image */
.block-edit-image { padding: 14px 16px; }
.block-edit-image .form-group:last-child { margin-bottom: 0; }

.block-add {
    display: flex; align-items: center; gap: 8px;
    padding-top: 14px; border-top: 1px solid var(--border); margin-top: 4px;
}
.block-add select { width: auto; flex-shrink: 0; }

/* ── Article detail nav (back + edit) ────────────────────────────────── */
.article-nav {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 28px;
}
.article-nav > .article-back { margin-bottom: 0; }
.article-nav-actions { display: flex; gap: 8px; }

/* ── Articles list ────────────────────────────────────────────────────── */
.articles-page {}
.articles-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 28px;
}
.articles-title { font-size: 22px; font-weight: 700; color: var(--text); }
.articles-count { font-size: 13px; color: var(--muted); }
.articles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}
.articles-pagination {
    display: flex; align-items: center; justify-content: center; gap: 16px;
    padding: 28px 0 4px;
}
.article-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    cursor: pointer;
    transition: transform .18s, box-shadow .18s;
    display: flex; flex-direction: column;
}
.article-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,.11);
}
.article-card-img {
    width: 100%; aspect-ratio: 16/9;
    object-fit: cover; display: block;
    background: var(--bg);
}
.article-card-img-placeholder {
    width: 100%; aspect-ratio: 16/9;
    background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
    display: flex; align-items: center; justify-content: center;
    color: var(--primary); opacity: .45;
}
.article-card-body {
    padding: 20px; flex: 1;
    display: flex; flex-direction: column;
}
.article-card-meta {
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 10px; flex-wrap: wrap;
}
.article-card-draft {
    font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .06em;
    color: #92400e; background: #fef3c7;
    padding: 2px 8px; border-radius: 999px;
}
.article-card-category {
    font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .06em;
    color: var(--primary); background: #eef2ff;
    padding: 2px 8px; border-radius: 999px;
}
.article-card-date { font-size: 12px; color: var(--muted); }
.article-card-title {
    font-size: 17px; font-weight: 700; color: var(--text);
    margin-bottom: 8px; line-height: 1.35;
}
.article-card-subheading {
    font-size: 13px; color: var(--muted); line-height: 1.55; flex: 1;
}
.article-card-byline {
    font-size: 12px; color: var(--muted);
    margin-top: 14px; padding-top: 12px;
    border-top: 1px solid var(--border);
}
.articles-empty,
.articles-grid > .throbber {
    grid-column: 1 / -1;
    text-align: center; padding: 60px 20px;
    color: var(--muted); font-size: 15px;
}

/* ── Article detail ───────────────────────────────────────────────────── */
.article-page { max-width: 720px; margin: 0 auto; }

.article-back {
    display: inline-flex; align-items: center; gap: 6px;
    color: var(--muted); font-size: 13px; font-weight: 500;
    background: none; border: none; cursor: pointer;
    padding: 0; margin-bottom: 28px;
    transition: color .15s;
}
.article-back:hover { color: var(--primary); }

.article-header { margin-bottom: 32px; }

.article-meta {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 16px; flex-wrap: wrap;
}
.article-category {
    font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .06em;
    color: var(--primary); background: #eef2ff;
    padding: 3px 10px; border-radius: 999px;
}
.article-date { font-size: 13px; color: var(--muted); }

.article-headline {
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    font-weight: 800; line-height: 1.2;
    color: var(--text); margin-bottom: 14px;
    letter-spacing: -.02em;
}
.article-subheading {
    font-size: 1.15rem; font-weight: 400;
    color: var(--muted); line-height: 1.55;
    margin-bottom: 20px;
}
.article-byline {
    font-size: 13px; color: var(--muted);
    display: flex; align-items: center; gap: 6px;
    padding-bottom: 24px; border-bottom: 2px solid var(--border);
}
.article-byline strong { color: var(--text); }
.article-byline-link { color: inherit; text-decoration: none; }
.article-byline-link:hover strong { color: var(--primary); text-decoration: underline; }

.article-featured-img {
    width: 100%; border-radius: var(--radius);
    margin-bottom: 8px; display: block;
    object-fit: cover; max-height: 420px;
}
.article-featured-caption {
    font-size: 12px; color: var(--muted);
    text-align: center; margin-bottom: 32px;
    font-style: italic;
}

/* Body typography */
.article-body { font-size: 17px; line-height: 1.75; color: var(--text); }

.article-lead {
    font-size: 1.15rem; font-weight: 500; line-height: 1.7;
    color: var(--text); margin-bottom: 28px;
    padding-bottom: 28px; border-bottom: 1px solid var(--border);
}
.article-paragraph { margin-bottom: 24px; }

.article-body-subheading {
    font-size: 1.3rem; font-weight: 700; color: var(--text);
    margin: 36px 0 14px; line-height: 1.3;
}

.article-quote {
    margin: 32px 0;
    padding: 20px 24px;
    border-left: 4px solid var(--primary);
    background: #eef2ff;
    border-radius: 0 var(--radius) var(--radius) 0;
}
.article-quote-text {
    font-size: 1.1rem; font-weight: 500; font-style: italic;
    color: var(--text); line-height: 1.65; margin-bottom: 10px;
}
.article-quote-attribution {
    font-size: 13px; color: var(--muted); font-style: normal;
}
.article-quote-attribution::before { content: '\2014\00a0'; }

.article-evidence {
    margin: 28px 0;
    padding: 18px 22px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    border-left: 3px solid var(--muted);
}
.article-evidence-text {
    font-size: 15px; color: var(--text);
    line-height: 1.6; margin-bottom: 6px;
}
.article-evidence-source {
    font-size: 12px; color: var(--muted); font-style: italic;
}
.article-evidence-source::before { content: 'Source: '; }

.article-img-wrap { margin: 32px 0; }
.article-img {
    width: 100%; border-radius: var(--radius);
    display: block; max-height: 480px; object-fit: cover;
}
.article-img-caption {
    font-size: 12px; color: var(--muted);
    text-align: center; margin-top: 8px; font-style: italic;
}

.article-conclusion {
    margin-top: 40px; padding-top: 28px;
    border-top: 2px solid var(--border);
    font-size: 17px; line-height: 1.8;
    color: var(--text);
}
.article-conclusion p { font-style: italic; }

/* ── Image picker modal ───────────────────────────────────────────────── */
.img-picker-modal-overlay {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(0,0,0,.55);
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
}
.img-picker-modal {
    background: var(--surface);
    border-radius: 12px;
    width: 100%; max-width: 860px;
    max-height: 80vh;
    display: flex; flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
    overflow: hidden;
}
.img-picker-modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.img-picker-modal-title { font-weight: 600; font-size: 15px; }
.img-picker-close-btn {
    background: none; border: none; cursor: pointer;
    font-size: 22px; line-height: 1; color: var(--muted);
    padding: 2px 6px; border-radius: var(--radius);
}
.img-picker-close-btn:hover { background: var(--bg); color: var(--text); }
.img-picker-modal-body { overflow-y: auto; padding: 16px; flex: 1; }
.img-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}
.img-picker-thumb-wrap {
    aspect-ratio: 1 / 1; overflow: hidden;
    border-radius: var(--radius);
    border: 2px solid transparent;
    background: var(--bg); padding: 0; cursor: pointer;
    transition: border-color .15s, transform .15s;
}
.img-picker-thumb-wrap:hover { border-color: var(--primary); transform: scale(1.03); }
.img-picker-thumb-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-picker-pagination {
    display: flex; align-items: center; justify-content: center;
    gap: 12px; padding-top: 8px;
}
.img-picker-breadcrumb {
    display: flex; align-items: center; flex-wrap: wrap;
    gap: 4px; padding: 8px 20px;
    font-size: 13px; color: var(--muted);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.img-picker-folder-wrap {
    aspect-ratio: 1 / 1; overflow: hidden;
    border-radius: var(--radius);
    border: 2px solid transparent;
    background: var(--surface); padding: 0; cursor: pointer;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 6px;
    transition: border-color .15s;
}
.img-picker-folder-wrap:hover { border-color: var(--primary); }
.img-picker-folder-icon {
    width: 38px; height: 38px; color: var(--primary);
    display: flex; align-items: center; justify-content: center;
}
.img-picker-folder-icon svg { width: 100%; height: 100%; }
.img-picker-folder-name {
    font-size: 11px; font-weight: 500; color: var(--text);
    text-align: center; max-width: 90%;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ── Image picker inline row ──────────────────────────────────────────── */
.img-picker-row {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.img-picker-preview {
    width: 80px; height: 80px;
    object-fit: cover; border-radius: var(--radius);
    border: 1px solid var(--border);
    flex-shrink: 0;
}
.img-picker-empty {
    font-size: 13px; color: var(--muted);
    padding: 4px 0;
}

/* ── Gallery ──────────────────────────────────────────────────────────── */
.gallery-page { max-width: 1100px; margin: 0 auto; }
.gallery-header {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 20px;
}
.gallery-title { font-size: 1.4rem; font-weight: 700; }

.gallery-upload-card { margin-bottom: 24px; padding: 24px; }
.gallery-upload-hint {
    font-size: 13px; color: var(--muted);
    margin-bottom: 14px;
}
.gallery-upload-row {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.gallery-file-input {
    flex: 1; min-width: 0;
    font-size: 13px; color: var(--text);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 8px 10px;
    background: var(--bg);
    cursor: pointer;
}
.gallery-file-input::-webkit-file-upload-button {
    background: var(--primary); color: #fff;
    border: none; border-radius: calc(var(--radius) - 2px);
    padding: 5px 10px; font-size: 12px; cursor: pointer;
    margin-right: 8px;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}
.gallery-empty {
    grid-column: 1 / -1;
    text-align: center; color: var(--muted);
    padding: 48px 0; font-size: 14px;
}

.gallery-thumb-wrap {
    position: relative;
    aspect-ratio: 1 / 1;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg);
    cursor: default;
}
.gallery-thumb {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
    border-radius: calc(var(--radius) - 1px);
    transition: transform .2s;
}
.gallery-thumb-wrap:hover .gallery-thumb { transform: scale(1.04); }

.gallery-thumb-overlay {
    position: absolute; bottom: 0; left: 0; right: 0;
    padding: 20px 8px 6px;
    background: linear-gradient(transparent, rgba(0,0,0,.65));
    border-radius: 0 0 calc(var(--radius) - 1px) calc(var(--radius) - 1px);
    opacity: 0; transition: opacity .18s;
    pointer-events: none;
}
.gallery-thumb-wrap:hover .gallery-thumb-overlay { opacity: 1; }
.gallery-thumb-name {
    display: block; color: #fff; font-size: 11px; font-weight: 500;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
@media (hover: none) { .gallery-thumb-overlay { opacity: 1; } }

.gallery-pagination {
    display: flex; align-items: center; justify-content: center;
    gap: 12px; padding: 8px 0 16px;
}

/* ── Gallery: breadcrumb ─────────────────────────────────────────────── */
.gallery-breadcrumb {
    display: flex; align-items: center; flex-wrap: wrap;
    gap: 4px; margin-bottom: 14px;
    font-size: 13px; color: var(--muted);
    min-height: 24px;
}
.gallery-breadcrumb-link {
    color: var(--primary); cursor: pointer;
    border-radius: 4px; padding: 1px 4px;
    transition: background .12s;
}
.gallery-breadcrumb-link:hover { background: rgba(79,70,229,.08); }
.gallery-breadcrumb-link:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.gallery-breadcrumb-current { color: var(--text); font-weight: 500; }
.gallery-breadcrumb-sep { color: var(--muted); user-select: none; }

/* ── Gallery: folder tile ────────────────────────────────────────────── */
.gallery-folder-wrap {
    position: relative; aspect-ratio: 1 / 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 8px;
    border-radius: var(--radius); border: 1px solid var(--border);
    background: var(--surface); cursor: pointer;
    transition: border-color .15s, box-shadow .15s;
    user-select: none;
}
.gallery-folder-wrap:hover {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}
.gallery-folder-wrap:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.gallery-folder-icon {
    width: 48px; height: 48px; color: var(--primary);
    display: flex; align-items: center; justify-content: center;
}
.gallery-folder-icon svg { width: 100%; height: 100%; }
.gallery-folder-name {
    font-size: 12px; font-weight: 500; color: var(--text);
    text-align: center; max-width: 90%;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    padding: 0 24px 0 8px;
}
.gallery-folder-menu-btn {
    position: absolute; top: 4px; right: 4px;
    width: 24px; height: 24px;
    background: none; border: none; border-radius: 4px;
    font-size: 16px; line-height: 1; cursor: pointer;
    color: var(--muted); display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity .15s, background .12s;
}
.gallery-folder-wrap:hover .gallery-folder-menu-btn,
.gallery-thumb-wrap:hover .gallery-folder-menu-btn { opacity: 1; }
.gallery-folder-menu-btn:hover { background: rgba(0,0,0,.08); color: var(--text); }
.gallery-thumb-wrap .gallery-folder-menu-btn { color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.5); }
.gallery-thumb-wrap .gallery-folder-menu-btn:hover { background: rgba(0,0,0,.3); }
.gallery-folder-menu-btn:focus-visible { opacity: 1; outline: 2px solid var(--primary); }
@media (hover: none) { .gallery-folder-menu-btn { opacity: 1; } }
.gallery-folder-menu {
    position: absolute; top: 28px; right: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(0,0,0,.12);
    min-width: 110px; z-index: 10;
    display: flex; flex-direction: column;
    overflow: hidden;
}
.gallery-folder-menu button {
    width: 100%; background: none; border: none;
    padding: 8px 14px; text-align: left;
    font-size: 13px; color: var(--text); cursor: pointer;
    transition: background .1s;
}
.gallery-folder-menu button:hover { background: var(--bg); }
.gallery-folder-menu .gallery-folder-delete-btn,
.gallery-folder-menu .gallery-image-delete-btn { color: var(--danger, #dc2626); }

/* ── Gallery: create-folder modal ────────────────────────────────────── */
.gallery-modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.45);
    display: flex; align-items: center; justify-content: center; z-index: 900;
}
.gallery-modal {
    background: var(--surface); border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0,0,0,.18);
    width: min(400px, 90vw); overflow: hidden;
}
.gallery-modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.gallery-modal-title { font-weight: 600; font-size: 15px; }
.gallery-modal-close {
    background: none; border: none; cursor: pointer;
    font-size: 20px; color: var(--muted); line-height: 1;
    padding: 0 4px; border-radius: 4px; transition: background .12s;
}
.gallery-modal-close:hover { background: var(--bg); }
.gallery-modal-body { padding: 20px; }
.gallery-modal-actions {
    display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px;
}

/* ── Lightbox ─────────────────────────────────────────────────────────── */
.lightbox-overlay {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(0,0,0,.92);
    display: flex; align-items: center; justify-content: center;
    cursor: zoom-out;
}
.lightbox-img-wrap {
    max-width: 90vw; max-height: 90vh;
    display: flex; align-items: center; justify-content: center;
    cursor: default;
}
.lightbox-img {
    max-width: 90vw; max-height: 90vh;
    object-fit: contain;
    border-radius: var(--radius);
    box-shadow: 0 8px 48px rgba(0,0,0,.6);
}
.lightbox-close {
    position: fixed; top: 16px; right: 20px;
    background: rgba(255,255,255,.15); border: none;
    color: #fff; font-size: 28px; line-height: 1;
    width: 44px; height: 44px; border-radius: 50%;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: background .15s;
}
.lightbox-close:hover { background: rgba(255,255,255,.28); }

/* ── Grid page ────────────────────────────────────────────────────────── */
.main:has(.grid-page) {
    max-width: none;
    margin: 0;
    padding: 0;
    min-height: 0;
    overflow: hidden;
}

.grid-page {
    height: calc(100vh - 56px);
}

.grid-main {
    position: relative;
    width: 100%;
    height: 100%;
}

.grid-canvas-wrap {
    position: absolute;
    inset: 0;
    background: #f8fafc;
    overflow: hidden;
    cursor: grab;
}

.grid-canvas-wrap:active { cursor: grabbing; }

#gridCanvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* ── Grid sidebar ─────────────────────────────────────────────────────── */
.grid-sidebar {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 220px;
    max-height: calc(100% - 24px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0 !important;
    z-index: 10;
    box-shadow: 0 4px 16px rgba(0,0,0,.12);
}

.grid-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.grid-sidebar-title {
    font-size: 13px;
    font-weight: 600;
}

.grid-sidebar-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.grid-zone-list {
    flex: 1;
    overflow-y: auto;
    padding: 5px;
    min-height: 0;
}

.grid-zone-empty {
    font-size: 12px;
    color: var(--muted);
    text-align: center;
    padding: 16px 8px;
}

.grid-zone-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    border-radius: calc(var(--radius) - 2px);
    cursor: pointer;
    transition: background .12s;
    font-size: 13px;
    user-select: none;
}

.grid-zone-item:hover  { background: var(--bg); }
.grid-zone-item.selected { background: #eef2ff; color: var(--primary); }

.grid-zone-swatch {
    width: 11px;
    height: 11px;
    border-radius: 2px;
    flex-shrink: 0;
}

.grid-zone-item-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Zone properties form ─────────────────────────────────────────────── */
.grid-zone-props {
    border-top: 1px solid var(--border);
    padding: 12px 12px 14px;
    flex-shrink: 0;
}

.zp-row {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 7px;
}

.zp-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--muted);
    width: 46px;
    flex-shrink: 0;
}

.zp-input {
    flex: 1;
    min-width: 0;
    padding: 4px 7px;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 2px);
    font-size: 12px;
    font-family: inherit;
    background: var(--surface);
    transition: border-color .15s;
}

.zp-input:focus { outline: none; border-color: var(--primary); }

.zp-color {
    height: 27px;
    width: 48px;
    padding: 2px 3px;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 2px);
    cursor: pointer;
    background: var(--surface);
}


.grid-zone-delete-btn {
    width: 100%;
    margin-top: 4px;
    justify-content: center;
}

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .main            { padding: 16px; }
    .auth-card       { padding: 28px 20px; }

    /* Hide Email + Joined columns on small screens */
    .users-table th:nth-child(2),
    .users-table td:nth-child(2),
    .users-table th:nth-child(4),
    .users-table td:nth-child(4) { display: none; }

    .articles-grid { grid-template-columns: 1fr; }
    .article-headline { font-size: 1.6rem; }
    .article-body { font-size: 16px; }
    .article-lead { font-size: 1.05rem; }
}
