/* ==========================================================
   Maclife — theme tối giản, mobile-first
   Brand palette: #12c3f4 #39a4dc #0066ab #003664
========================================================== */

/* --- Lucide icon system ---------------------------------- */
.icon {
    display: inline-block;
    vertical-align: -3px;
    flex-shrink: 0;
}
/* Tab / button labels with icon: keep them on the same baseline */
.tab .icon, .btn .icon, .action-btn .icon, .post-more-item .icon,
.tools-dropdown a .icon, .admin-nav a .icon, .lb-rank .icon,
.notif-text .icon, .feed-title .icon, h1 .icon, h2 .icon, h3 .icon {
    vertical-align: -3px;
}
/* Saved bookmark: CSS-only filled state via parent class */
.is-saved .icon-bookmark { fill: currentColor; }
.feed-title .icon-bookmark.is-filled { fill: currentColor; }

/* Follow chip: two icons (plus + check), toggled by .is-following */
.follow-chip .follow-icon-plus,
.follow-chip .follow-icon-check { display: inline-flex; align-items: center; }
.follow-chip .follow-icon-check { display: none; }
.follow-chip.is-following .follow-icon-plus { display: none; }
.follow-chip.is-following .follow-icon-check { display: inline-flex; }
.follow-btn .follow-icon-plus,
.follow-btn .follow-icon-check { display: inline-flex; align-items: center; }
.follow-btn .follow-icon-check { display: none; }
.follow-btn.is-following .follow-icon-plus { display: none; }
.follow-btn.is-following .follow-icon-check { display: inline-flex; }

/* Vote arrows: bigger tap target, no underline weirdness */
.vote-btn .icon, .comment-vote-btn .icon { vertical-align: middle; }

/* Theme toggle: only one of moon/sun shows at a time */
.theme-toggle .icon-moon, .theme-toggle .icon-sun {
    width: 20px; height: 20px;
}


:root {
    --c-primary:    #0066ab;
    --c-primary-d:  #004f87;
    --c-accent:     #12c3f4;
    --c-secondary:  #39a4dc;
    --c-heading:    #003664;
    --c-text:       #1f2937;
    --c-muted:      #6b7280;
    --c-down:       #e11d48;
    --c-bg:         #f5f7fa;
    --c-card:       #ffffff;
    --c-card-2:     #ffffff;
    --c-input-bg:   #ffffff;
    --c-border:     #e5e7eb;
    --c-border-2:   #d1d5db;
    --c-tag-bg:     rgba(18, 195, 244, .12);
    --c-tag-bg-h:   rgba(18, 195, 244, .22);
    --c-overlay:    rgba(0,54,100,.55);
    --c-img-bg:     #0a0f1a;

    --radius:       10px;
    --radius-sm:    6px;
    --shadow:       0 1px 2px rgba(0,54,100,.06), 0 2px 8px rgba(0,54,100,.04);
    --shadow-h:     0 2px 6px rgba(0,54,100,.10), 0 6px 18px rgba(0,54,100,.08);

    --header-h:     56px;
    --container:    1100px;
    --feed-w:       620px;
    --gap:          16px;
}

[data-theme="dark"] {
    --c-primary:    #2db8ff;
    --c-primary-d:  #1aa7ee;
    --c-accent:     #38d4ff;
    --c-secondary:  #5cb8e8;
    --c-heading:    #f1f5f9;
    --c-text:       #d1d5db;
    --c-muted:      #94a3b8;
    --c-down:       #f87171;
    --c-bg:         #0b1220;
    --c-card:       #131c2e;
    --c-card-2:     #1a2438;
    --c-input-bg:   #1a2438;
    --c-border:     #25324a;
    --c-border-2:   #2f3e5a;
    --c-tag-bg:     rgba(45, 184, 255, .14);
    --c-tag-bg-h:   rgba(45, 184, 255, .26);
    --c-overlay:    rgba(0,0,0,.7);
    --c-img-bg:     #050a14;

    --shadow:       0 1px 2px rgba(0,0,0,.4), 0 2px 8px rgba(0,0,0,.3);
    --shadow-h:     0 4px 12px rgba(0,0,0,.5), 0 8px 24px rgba(0,0,0,.35);
}

[data-theme="dark"] body { color-scheme: dark; }

* { box-sizing: border-box; }

/* Global: any element with `hidden` attribute is hidden, even when CSS overrides display */
[hidden] { display: none !important; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--c-bg);
    color: var(--c-text);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

img, video { max-width: 100%; height: auto; display: block; }

button {
    font: inherit;
    cursor: pointer;
    background: none;
    border: 0;
    color: inherit;
}

/* ----- Header ----- */
.site-header {
    background: var(--c-card);
    border-bottom: 1px solid var(--c-border);
    position: sticky;
    top: 0;
    z-index: 50;
}
.header-inner {
    max-width: var(--container);
    margin: 0 auto;
    height: var(--header-h);
    padding: 0 16px;
    display: flex;
    align-items: center;
    gap: 16px;
}
.brand { display: flex; align-items: center; flex-shrink: 0; }
.brand-logo { height: 28px; width: auto; }

/* Wrapper around tabs + search. On desktop it's invisible to layout
   (display: contents passes the children straight to .header-inner's flex
   layout). On tablet/mobile (≤960px, see media query below) it becomes a
   real flex row that the children share. */
.header-row-2 { display: contents; }
.tabs { display: flex; gap: 4px; }
.tab {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--c-text);
    font-weight: 500;
    font-size: 14px;
    transition: background .12s;
}
.tab:hover { background: var(--c-bg); text-decoration: none; }
.tab.is-active {
    background: rgba(18, 195, 244, .14);
    color: var(--c-primary);
    font-weight: 600;
}

.search { flex: 1; max-width: 360px; }
.search input {
    width: 100%;
    height: 36px;
    padding: 0 12px;
    border: 1px solid var(--c-border);
    border-radius: 18px;
    font-size: 14px;
    background: var(--c-bg);
    transition: border-color .12s, background .12s;
}
.search input:focus {
    outline: none;
    border-color: var(--c-secondary);
    background: var(--c-card);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.lang-switch {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: var(--c-muted);
    margin-right: 4px;
}
.lang-switch a { color: var(--c-muted); padding: 2px 4px; }
.lang-switch a:hover { color: var(--c-primary); text-decoration: none; }
.lang-switch a.is-active { color: var(--c-heading); font-weight: 700; }

/* ----- Buttons ----- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    transition: background .12s, color .12s, border-color .12s;
    white-space: nowrap;
}
.btn-primary {
    background: var(--c-primary);
    color: #fff !important;
}
.btn-primary:hover { background: var(--c-primary-d); text-decoration: none; }
.btn-ghost {
    background: transparent;
    color: var(--c-heading) !important;
    border: 1px solid var(--c-border);
}
.btn-ghost:hover { background: var(--c-bg); text-decoration: none; }

/* ----- Layout ----- */
.container {
    max-width: var(--container);
    margin: 0 auto;
    padding: 20px 16px 60px;
}
.layout-grid {
    display: grid;
    grid-template-columns: minmax(0, var(--feed-w)) 300px;
    gap: 24px;
    justify-content: center;
}

.feed { min-width: 0; }
.feed-head { margin-bottom: 16px; }
.feed-title {
    margin: 0;
    font-size: 22px;
    color: var(--c-heading);
    font-weight: 700;
}
.feed-sub {
    margin: 4px 0 0;
    color: var(--c-muted);
    font-size: 13px;
}

.empty {
    background: var(--c-card);
    border: 1px dashed var(--c-border-2);
    border-radius: var(--radius);
    padding: 40px;
    text-align: center;
    color: var(--c-muted);
}

/* ----- Post card ----- */
.post-card {
    background: var(--c-card);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    margin-bottom: 16px;
    overflow: hidden;
    transition: box-shadow .15s, transform .15s;
}
@media (hover: hover) and (pointer: fine) {
    .post-card:hover { box-shadow: var(--shadow-h); }
}

/* Right padding keeps the title clear of the absolute-positioned "..." menu in
   the top-right corner (28px button at right:12px → need ~48px clearance). */
.post-head { padding: 14px 48px 8px 16px; }
.post-title {
    margin: 0;
    font-size: 17px;
    line-height: 1.35;
    font-weight: 700;
}
.post-title a { color: var(--c-heading); }
@media (hover: hover) and (pointer: fine) {
    .post-title a:hover { color: var(--c-primary); text-decoration: none; }
}

.post-meta {
    margin: 6px 0 0;
    font-size: 12px;
    color: var(--c-muted);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}
.post-meta .dot { color: var(--c-border-2); }

.tag-chip {
    display: inline-block;
    padding: 1px 8px;
    background: rgba(18, 195, 244, .12);
    color: var(--c-primary);
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}
@media (hover: hover) and (pointer: fine) {
    .tag-chip:hover { background: rgba(18, 195, 244, .22); text-decoration: none; }
}

.post-media {
    display: block;
    background: var(--c-img-bg);
    text-align: center;
}
/* Image gets zoom-cursor hint so it's obvious clicking opens the lightbox. */
.post-media img { cursor: zoom-in; }
.post-media img,
.post-media video {
    width: 100%;
    max-height: 700px;
    object-fit: contain;
    margin: 0 auto;
}

.post-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    border-top: 1px solid var(--c-border);
}
.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    color: var(--c-muted);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    transition: background .12s, color .12s;
}
@media (hover: hover) and (pointer: fine) {
    .action-btn:hover {
        background: var(--c-bg);
        color: var(--c-heading);
        text-decoration: none;
    }
}

.vote-group {
    display: inline-flex;
    align-items: center;
    background: var(--c-bg);
    border-radius: 999px;
    padding: 2px;
    margin-right: 4px;
}
.vote-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    color: var(--c-muted);
    font-size: 14px;
    line-height: 1;
    transition: background .12s, color .12s, transform .08s;
}
@media (hover: hover) and (pointer: fine) {
    .vote-btn:hover { background: var(--c-card); }
}
.vote-btn:active { transform: scale(0.92); }
.vote-up.is-active   { color: var(--c-primary); background: rgba(18,195,244,.18); }
.vote-down.is-active { color: var(--c-down);    background: rgba(225,29,72,.12); }
.score {
    min-width: 28px;
    text-align: center;
    font-size: 13px;
    font-weight: 700;
    color: var(--c-heading);
    padding: 0 4px;
}

/* ----- Sidebar ----- */
.sidebar { display: flex; flex-direction: column; gap: 16px; }
.card {
    background: var(--c-card);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 16px;
}
.sidebar-title {
    margin: 0 0 10px;
    font-size: 14px;
    font-weight: 700;
    color: var(--c-heading);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.sidebar-text {
    margin: 0;
    color: var(--c-text);
    font-size: 14px;
    line-height: 1.55;
}
.tag-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.tag-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid var(--c-border);
}
.tag-list li:last-child { border-bottom: 0; }
.tag-list a { font-weight: 600; }
.tag-count { color: var(--c-muted); font-size: 12px; }

/* ----- Footer ----- */
.site-footer {
    border-top: 1px solid var(--c-border);
    background: var(--c-card);
    margin-top: 40px;
}
.footer-inner {
    max-width: var(--container);
    margin: 0 auto;
    padding: 20px 16px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
.footer-nav { display: flex; gap: 16px; flex-wrap: wrap; }
.footer-nav a { color: var(--c-muted); font-size: 13px; }
.footer-nav a:hover { color: var(--c-primary); }
.footer-copy { margin: 0; color: var(--c-muted); font-size: 13px; }

/* ----- Error page ----- */
.error-page {
    text-align: center;
    padding: 60px 20px;
}
.error-page h1 {
    margin: 0;
    font-size: 88px;
    color: var(--c-primary);
    line-height: 1;
}
.error-page h2 { margin: 8px 0; color: var(--c-heading); }
.error-page p { color: var(--c-muted); margin-bottom: 20px; }

/* ----- Post detail ----- */
.post-detail {
    background: var(--c-card);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    overflow: hidden;
}
.post-detail .post-title { font-size: 22px; }
.post-media-detail img,
.post-media-detail video {
    width: 100%;
    max-height: none;
    object-fit: contain;
}
.post-media-detail img[data-lightbox] { cursor: zoom-in; }

/* ----- Lightbox (full-screen image viewer) ----- */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 2500;
    display: flex;
    align-items: center;
    justify-content: center;
}
.lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .94);
    cursor: zoom-out;
}
.lightbox-image {
    position: relative;
    max-width: 95vw;
    max-height: 95vh;
    object-fit: contain;
    cursor: zoom-out;
    user-select: none;
    box-shadow: 0 10px 40px rgba(0,0,0,.6);
    background: #0a0f1a;
}
.lightbox-close {
    position: fixed;
    top: 14px;
    right: 14px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .12);
    color: #fff;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    z-index: 2;
    transition: background .15s;
}
.lightbox-close:hover { background: rgba(255, 255, 255, .25); }
.post-actions-detail { padding: 10px 16px; }
.action-report { color: var(--c-down); }
.action-delete { color: var(--c-down); }
.action-delete:hover { background: #fef2f2; }
.post-actions form { display: inline-flex; align-items: center; margin: 0; }

/* ----- Comments ----- */
.comments {
    padding: 20px 16px;
    border-top: 1px solid var(--c-border);
}
.section-title {
    margin: 0 0 14px;
    font-size: 16px;
    color: var(--c-heading);
    font-weight: 700;
}
.comment-form textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
    min-height: 70px;
    transition: border-color .12s;
}
.comment-form textarea:focus { outline: none; border-color: var(--c-secondary); }
.comment-form-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
}
.comment-hint { font-size: 13px; color: var(--c-muted); }
.comment-login-cta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    background: var(--c-bg);
    border: 1px dashed var(--c-border-2);
    border-radius: var(--radius);
}
.empty-small {
    color: var(--c-muted);
    text-align: center;
    padding: 18px 0;
    margin: 0;
}

.comment-list, .comment-children {
    list-style: none;
    margin: 18px 0 0;
    padding: 0;
}
.comment-children { margin-top: 10px; padding-left: 12px; border-left: 2px solid var(--c-border); }
.comment {
    display: flex;
    gap: 10px;
    padding: 10px 0;
}
.comment-avatar {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 50%;
    overflow: hidden;
    background: var(--c-bg);
}
.comment-avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: var(--c-secondary);
    color: #fff;
    font-weight: 700;
    font-size: 14px;
}
.comment-body { flex: 1; min-width: 0; }
.comment-head { font-size: 13px; }
.comment-head .muted { color: var(--c-muted); font-weight: 400; }
.comment-text {
    margin: 4px 0 6px;
    color: var(--c-text);
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}
.comment-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

/* Comment vote group: compact version of post vote */
.comment-vote-group {
    display: inline-flex;
    align-items: center;
    background: var(--c-bg);
    border-radius: 999px;
    padding: 1px;
}
.comment-vote-btn {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    color: var(--c-muted);
    font-size: 10px;
    line-height: 1;
    transition: background .12s, color .12s, transform .08s;
}
@media (hover: hover) and (pointer: fine) {
    .comment-vote-btn:hover { background: var(--c-card); }
}
.comment-vote-btn:active { transform: scale(0.9); }
.comment-vote-up.is-active   { color: var(--c-primary); background: rgba(18,195,244,.18); }
.comment-vote-down.is-active { color: var(--c-down);    background: rgba(225,29,72,.12); }
[data-theme="dark"] .comment-vote-up.is-active   { background: rgba(45,184,255,.22); }
[data-theme="dark"] .comment-vote-down.is-active { background: rgba(248,113,113,.18); }
.comment-score {
    min-width: 20px;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    color: var(--c-heading);
    padding: 0 4px;
}

/* Comment action buttons (Reply, Edit, Delete) */
.comment-action-btn {
    color: var(--c-muted);
    font-size: 12px;
    font-weight: 600;
    padding: 4px 6px;
    border-radius: 4px;
    background: transparent;
    transition: background .12s, color .12s;
}
@media (hover: hover) and (pointer: fine) {
    .comment-action-btn:hover { background: var(--c-bg); color: var(--c-heading); }
}
.comment-action-danger { color: var(--c-down); }
@media (hover: hover) and (pointer: fine) {
    .comment-action-danger:hover { background: rgba(225,29,72,.08); color: var(--c-down); }
}

/* Reply form */
.comment-reply-form {
    margin: 8px 0 4px;
    padding: 8px;
    background: var(--c-bg);
    border-radius: var(--radius-sm);
}
.comment-reply-form textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
    background: var(--c-input-bg);
    color: var(--c-text);
}
.comment-reply-form textarea:focus { outline: none; border-color: var(--c-secondary); }
.comment-reply-form .btn { height: 30px; padding: 0 10px; font-size: 13px; }

/* ----- Tag header ----- */
.tag-header { margin-bottom: 12px; }
.tag-title {
    margin: 0;
    color: var(--c-heading);
    font-size: 24px;
    font-weight: 700;
}
.tag-desc { margin: 4px 0; color: var(--c-text); font-size: 14px; }
.tag-stats { margin: 0; color: var(--c-muted); font-size: 12px; }

.tag-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 14px;
    background: var(--c-card);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 6px;
}

/* ----- Search ----- */
.search-header { margin-bottom: 14px; }
.search-big {
    display: flex;
    gap: 8px;
}
.search-big input {
    flex: 1;
    height: 40px;
    padding: 0 14px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    background: var(--c-bg);
}
.search-big input:focus { outline: none; border-color: var(--c-secondary); background: var(--c-card); }
.search-big .btn { height: 40px; }
.search-header .muted { margin: 8px 0 0; color: var(--c-muted); font-size: 13px; }

/* ----- Related ----- */
.related-list { list-style: none; margin: 0; padding: 0; }
.related-list li { margin-bottom: 10px; }
.related-list li:last-child { margin-bottom: 0; }
.related-item {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    color: var(--c-heading);
    font-size: 13px;
    line-height: 1.4;
    font-weight: 600;
}
.related-item:hover { color: var(--c-primary); text-decoration: none; }
.related-item img {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.tag-list a.is-active { color: var(--c-primary); }
.muted { color: var(--c-muted); }
.small { font-size: 12px; }

/* Visually hidden but available to screen readers / SEO crawlers */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* ----- Auth & forms ----- */
.auth-wrap, .upload-wrap {
    max-width: 460px;
    margin: 40px auto;
    padding: 0 16px;
}
.upload-wrap { max-width: 720px; }
.auth-card, .upload-card { padding: 28px; }

/* Upload page: form + rules sidebar */
.upload-grid {
    display: grid;
    grid-template-columns: minmax(0, 640px) 300px;
    gap: 24px;
    max-width: 1000px;
    margin: 24px auto;
    padding: 0 16px;
    align-items: start;
}
.upload-sidebar { position: sticky; top: calc(var(--header-h) + 16px); }

.rules-card { padding: 16px; }
.rules-list {
    margin: 0;
    padding: 0 0 0 22px;
    color: var(--c-text);
    font-size: 14px;
    line-height: 1.6;
}
.rules-list li {
    padding: 4px 0;
    border-bottom: 1px dashed var(--c-border);
}
.rules-list li:last-child { border-bottom: 0; }

@media (max-width: 900px) {
    .upload-grid { grid-template-columns: 1fr; max-width: 720px; }
    .upload-sidebar { position: static; }
}
.auth-title { margin: 0 0 4px; color: var(--c-heading); font-size: 24px; font-weight: 700; }
.auth-sub   { margin: 0 0 20px; color: var(--c-muted); font-size: 14px; }

.auth-form .field, .admin-form .field {
    display: block;
    margin-bottom: 14px;
}
.field-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--c-heading);
    margin-bottom: 4px;
}
.field-hint { display: block; margin-top: 4px; color: var(--c-muted); font-size: 12px; }
.auth-form input[type=text],
.auth-form input[type=email],
.auth-form input[type=password],
.auth-form input[type=number],
.auth-form input[type=search],
.admin-form input[type=text],
.admin-form input[type=email],
.admin-form input[type=password],
.admin-form input[type=number],
.admin-form input[type=search] {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    background: var(--c-input-bg);
    color: var(--c-text);
    transition: border-color .12s, box-shadow .12s;
}
.auth-form textarea,
.admin-form textarea {
    display: block;
    width: 100%;
    min-height: 96px;
    padding: 10px 12px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    background: var(--c-input-bg);
    color: var(--c-text);
    resize: vertical;
    transition: border-color .12s, box-shadow .12s;
}
.auth-form input:focus,
.auth-form textarea:focus,
.admin-form input:focus,
.admin-form textarea:focus {
    outline: none;
    border-color: var(--c-secondary);
    box-shadow: 0 0 0 3px rgba(57,164,220,.16);
}
.field-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--c-text);
}
.field-check input { width: auto; height: auto; }

.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.alert {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    font-size: 14px;
}
.alert-error   { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-success { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }

.auth-foot { margin: 18px 0 0; text-align: center; color: var(--c-muted); font-size: 14px; }

.oauth-buttons { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.btn-oauth {
    height: 42px;
    background: #fff;
    color: var(--c-heading) !important;
    border: 1px solid var(--c-border);
    justify-content: center;
}
.btn-oauth:hover { background: var(--c-bg); }
.btn-oauth-google   { /* default */ }
.btn-oauth-facebook { background: #1877f2; color: #fff !important; border-color: #1877f2; }
.btn-oauth-facebook:hover { background: #166ad8; }
.oauth-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px; height: 22px;
    border-radius: 50%;
    background: var(--c-bg);
    color: var(--c-primary);
    font-weight: 700;
    font-size: 13px;
}
.btn-oauth-facebook .oauth-icon { background: #fff; color: #1877f2; }

.auth-divider {
    text-align: center;
    color: var(--c-muted);
    font-size: 12px;
    margin: 12px 0;
    position: relative;
}
.auth-divider::before, .auth-divider::after {
    content: '';
    position: absolute;
    top: 50%; width: 40%;
    border-top: 1px solid var(--c-border);
}
.auth-divider::before { left: 0; }
.auth-divider::after  { right: 0; }
.auth-divider span { background: var(--c-card); padding: 0 8px; }

/* ----- Upload ----- */
.upload-drop {
    display: block;
    position: relative;
    border: 2px dashed var(--c-border-2);
    border-radius: var(--radius);
    padding: 30px 20px;
    text-align: center;
    background: var(--c-bg);
    transition: border-color .15s, background .15s;
    cursor: pointer;
}
.upload-drop:hover { border-color: var(--c-secondary); background: #eef5fb; }
.upload-drop.is-drag { border-color: var(--c-primary); background: rgba(18,195,244,.06); }

/* sr-only style — input nằm trong label nhưng ẩn hoàn toàn, click vẫn được trigger qua label */
.upload-input-hidden {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

.upload-drop-hint p { margin: 4px 0; }
.upload-preview {
    margin-top: 14px;
}

.studio-cta {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: linear-gradient(135deg, rgba(18,195,244,.12), rgba(0,102,171,.12));
    border: 1px solid var(--c-secondary);
    border-radius: var(--radius);
    color: var(--c-heading);
    font-size: 14px;
    transition: background .15s, transform .15s;
    margin-bottom: 8px;
}
.studio-cta:hover {
    background: linear-gradient(135deg, rgba(18,195,244,.22), rgba(0,102,171,.22));
    text-decoration: none;
    transform: translateY(-1px);
}
.studio-cta-icon { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; color: var(--c-primary); }
.studio-cta-text { flex: 1; }
.studio-cta-text strong { display: block; color: var(--c-heading); font-size: 15px; }
.studio-cta-text small  { display: block; color: var(--c-muted); font-size: 12px; margin-top: 2px; }
.studio-cta-arrow { font-size: 20px; color: var(--c-primary); }

.upload-or {
    position: relative;
    text-align: center;
    margin: 8px 0;
    color: var(--c-muted);
    font-size: 12px;
}
.upload-or::before, .upload-or::after {
    content: '';
    position: absolute; top: 50%;
    width: calc(50% - 20px);
    border-top: 1px solid var(--c-border);
}
.upload-or::before { left: 0; }
.upload-or::after  { right: 0; }
.upload-or span { background: var(--c-card); padding: 0 8px; }
.upload-preview img, .upload-preview video {
    max-height: 400px;
    max-width: 100%;
    margin: 0 auto;
    border-radius: var(--radius-sm);
    display: block;
}
/* Reserve a sensible minimum so a video element that fails to decode (e.g.
   iOS Photo Library HEVC clips) doesn't collapse to 0px and look "vanished". */
.upload-preview-video { min-height: 200px; background: #000; }

.upload-preview-error {
    margin: 0 auto;
    max-width: 480px;
    padding: 14px 16px;
    background: rgba(225, 29, 72, .06);
    border: 1px solid rgba(225, 29, 72, .35);
    border-radius: var(--radius-sm);
    color: var(--c-down);
    font-size: 13px;
    line-height: 1.5;
    text-align: left;
}

.tag-suggest {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}
.tag-suggest .tag-chip { cursor: pointer; border: 0; font-family: inherit; }

/* ----- Tools dropdown ----- */
.tools-menu { position: relative; }
.tools-trigger {
    padding: 0 10px;
    height: 34px;
    font-size: 13px;
}
.tools-dropdown {
    position: absolute;
    right: 0; top: calc(100% + 6px);
    min-width: 200px;
    background: var(--c-card);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-h);
    padding: 4px 0;
    display: none;
    z-index: 100;
}
.tools-menu.is-open .tools-dropdown { display: block; }
.tools-dropdown a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    font-size: 14px;
    color: var(--c-text);
}
.tools-dropdown a:hover { background: var(--c-bg); text-decoration: none; }
.tools-dropdown .tool-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    object-fit: contain;
    border-radius: 4px;
}

@media (max-width: 720px) {
    .tools-trigger { padding: 0 8px; font-size: 12px; }
}

/* ----- User menu ----- */
.user-menu { position: relative; }
.user-trigger {
    padding: 0;
    background: transparent;
    border: 0;
}
.user-avatar {
    display: block;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--c-secondary);
}
.user-avatar.avatar-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
}
.user-dropdown {
    position: absolute;
    right: 0; top: calc(100% + 6px);
    min-width: 200px;
    background: var(--c-card);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-h);
    padding: 4px 0;
    display: none;
    z-index: 100;
}
.user-menu.is-open .user-dropdown { display: block; }
.user-dropdown a, .user-dropdown button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 14px;
    font-size: 14px;
    color: var(--c-text);
    background: transparent;
    border: 0;
    cursor: pointer;
}
.user-dropdown a:hover, .user-dropdown button:hover { background: var(--c-bg); text-decoration: none; }
.user-dropdown hr { margin: 4px 0; border: 0; border-top: 1px solid var(--c-border); }
.user-info {
    padding: 10px 14px;
    border-bottom: 1px solid var(--c-border);
}
.user-info strong { display: block; color: var(--c-heading); }
.user-info small  { display: block; color: var(--c-muted); font-size: 12px; }
.user-dropdown form { margin: 0; }

/* ----- Profile ----- */
.profile-header {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
    align-items: center;
}
.profile-avatar {
    width: 72px; height: 72px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--c-secondary);
}
.profile-avatar img,
.profile-avatar .avatar-fallback {
    width: 100%; height: 100%;
}
.profile-avatar .avatar-fallback { font-size: 28px; }
.profile-info h1 { margin: 0; font-size: 22px; color: var(--c-heading); }
.profile-bio { margin: 4px 0; color: var(--c-text); }
.profile-stats { margin: 4px 0 0; color: var(--c-muted); font-size: 13px; }
.role-badge {
    display: inline-block;
    padding: 1px 6px;
    background: var(--c-primary);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    border-radius: 999px;
    margin-left: 6px;
    text-transform: uppercase;
    vertical-align: middle;
}

/* ----- Admin ----- */
body.admin { background: #f0f3f7; }
.admin-header {
    background: var(--c-heading);
    color: #fff;
    border-bottom: 1px solid #002847;
}
.admin-header-inner {
    max-width: 1300px;
    margin: 0 auto;
    height: 56px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}
.admin-header .brand {
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
}
.admin-header .brand:hover { text-decoration: none; }
.admin-header .brand-logo { height: 24px; filter: brightness(2); }
.admin-header .header-actions { margin-left: auto; }
.admin-header .btn-ghost { color: #fff !important; border-color: rgba(255,255,255,.3); }
.admin-header .btn-ghost:hover { background: rgba(255,255,255,.1); }

.admin-shell {
    display: grid;
    grid-template-columns: 220px 1fr;
    max-width: 1300px;
    margin: 0 auto;
    gap: 0;
    min-height: calc(100vh - 56px);
}
.admin-nav {
    background: var(--c-card);
    border-right: 1px solid var(--c-border);
    padding: 16px 8px;
}
.admin-nav a {
    display: block;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--c-text);
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 2px;
}
.admin-nav a:hover { background: var(--c-bg); text-decoration: none; }
.admin-nav a.is-active { background: var(--c-primary); color: #fff; font-weight: 600; }

.admin-main { padding: 24px; min-width: 0; }
.admin-page-title { margin: 0 0 20px; color: var(--c-heading); font-size: 22px; }
.admin-section-title { margin: 28px 0 12px; color: var(--c-heading); font-size: 16px; font-weight: 700; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}
.stat-card {
    background: var(--c-card);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 16px;
}
.stat-card.is-warn { border-color: #f59e0b; background: #fffbeb; }
.stat-num { font-size: 28px; font-weight: 700; color: var(--c-heading); line-height: 1; }
.stat-label { font-size: 13px; color: var(--c-muted); margin-top: 4px; }
.stat-delta { font-size: 12px; color: var(--c-primary); margin-top: 4px; }

.admin-table-wrap {
    background: var(--c-card);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    overflow-x: auto;
}
.admin-table {
    width: 100%;
    border-collapse: collapse;
}
.admin-table th, .admin-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--c-border);
    font-size: 14px;
}
.admin-table th { background: var(--c-bg); color: var(--c-heading); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.admin-table tr:last-child td { border-bottom: 0; }

.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}
.status-pending    { background: #fef3c7; color: #92400e; }
.status-resolved   { background: #d1fae5; color: #065f46; }
.status-dismissed  { background: #e5e7eb; color: #4b5563; }
.status-active     { background: #d1fae5; color: #065f46; }
.status-banned     { background: #fee2e2; color: #991b1b; }
.status-admin      { background: #dbeafe; color: #1e40af; }
.status-user       { background: #e5e7eb; color: #4b5563; }
.status-published  { background: #d1fae5; color: #065f46; }
.status-hidden     { background: #fef3c7; color: #92400e; }
.status-deleted    { background: #fee2e2; color: #991b1b; }

.admin-filter {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.admin-filter input[type=search],
.admin-filter select {
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    background: #fff;
    font-size: 14px;
}
.admin-filter input[type=search] { flex: 1; min-width: 200px; }

.action-cell { white-space: nowrap; }
.action-cell form, .action-cell .btn-mini { margin-right: 4px; }

.btn-mini {
    display: inline-flex;
    align-items: center;
    height: 26px;
    padding: 0 8px;
    background: var(--c-bg);
    border: 1px solid var(--c-border);
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    color: var(--c-text);
    cursor: pointer;
    transition: background .12s, border-color .12s;
}
.btn-mini:hover { background: #fff; border-color: var(--c-secondary); }
.btn-mini-danger  { color: var(--c-down); border-color: #fecaca; background: #fff; }
.btn-mini-danger:hover  { background: #fef2f2; border-color: var(--c-down); }
.btn-mini-success { color: #047857; border-color: #a7f3d0; background: #fff; }
.btn-mini-success:hover { background: #ecfdf5; border-color: #047857; }

.admin-pagination {
    display: flex;
    gap: 4px;
    margin-top: 14px;
    justify-content: center;
}
.page-link {
    display: inline-flex;
    align-items: center;
    height: 32px;
    padding: 0 10px;
    background: var(--c-card);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--c-text);
}
.page-link:hover { background: var(--c-bg); text-decoration: none; }
.page-link.is-active { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }

/* Tag management list */
.tag-create-form { display: flex; gap: 8px; align-items: center; }
.tag-create-form input {
    flex: 1;
    height: 36px;
    min-height: 36px;
    box-sizing: border-box;
    line-height: 1;
    padding: 0 10px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    font-size: 14px;
}
.tag-create-form input:first-of-type { max-width: 200px; }

.tag-list-admin { display: flex; flex-direction: column; gap: 6px; }
.tag-row {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--c-card);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
}
.tag-row-form { display: flex; flex: 1; gap: 8px; align-items: center; margin: 0; }
.tag-row-form input {
    height: 36px;
    min-height: 36px;
    box-sizing: border-box;
    line-height: 1;
    padding: 0 10px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    font-size: 14px;
}
.tag-row-name { width: 140px; }
.tag-row-desc { flex: 1; min-width: 0; }
.tag-row-slug { width: 110px; }
.tag-row-count { font-size: 12px; color: var(--c-muted); width: 70px; }
.tag-row-delete { margin: 0; }
.tag-row-meta { display: flex; align-items: center; gap: 8px; }
.tag-row-actions { display: flex; gap: 6px; align-items: center; }


.admin-form { max-width: 720px; }
.admin-fieldset {
    background: var(--c-card);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}
.admin-fieldset legend {
    padding: 0 8px;
    color: var(--c-heading);
    font-weight: 700;
    font-size: 14px;
}
.admin-form code {
    background: var(--c-bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    color: var(--c-primary);
    user-select: all;
}
.form-actions { margin-top: 16px; }

/* ----- Share popup ----- */
.share-popup {
    position: absolute;
    z-index: 1500;
    min-width: 200px;
    padding: 6px;
    background: var(--c-card);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-h);
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.share-popup[hidden] { display: none !important; }
.share-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    text-align: left;
    font-size: 14px;
    color: var(--c-text);
    background: transparent;
    cursor: pointer;
    transition: background .12s;
}
.share-item:hover { background: var(--c-bg); }
.share-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px; height: 24px;
    border-radius: 50%;
    background: var(--c-bg);
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

/* ----- Toast ----- */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #003664;
    color: #fff;
    padding: 10px 18px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 6px 20px rgba(0,0,0,.25);
    z-index: 2000;
    opacity: 0;
    transition: opacity .22s ease, transform .22s ease;
    pointer-events: none;
    max-width: 90vw;
}
.toast.is-show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ----- Pagination ----- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 20px 0;
    padding: 12px 16px;
    background: var(--c-card);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
}
.page-indicator {
    color: var(--c-muted);
    font-size: 13px;
    font-weight: 600;
}

/* ----- Avatar edit ----- */
.avatar-edit {
    display: flex;
    align-items: center;
    gap: 14px;
}
.avatar-edit .profile-avatar { width: 64px; height: 64px; }
.avatar-edit .btn { height: 36px; }
.avatar-edit input[type=file] { display: none; }

/* ----- Modal ----- */
.modal[hidden] { display: none !important; }
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: var(--c-overlay);
    backdrop-filter: blur(2px);
}
.modal-dialog {
    position: relative;
    width: 100%;
    max-width: 460px;
    background: var(--c-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-h);
    padding: 24px;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-close {
    position: absolute;
    top: 10px; right: 12px;
    width: 32px; height: 32px;
    border-radius: 50%;
    font-size: 22px;
    line-height: 1;
    color: var(--c-muted);
}
.modal-close:hover { background: var(--c-bg); color: var(--c-heading); }
.modal-title { margin: 0 0 4px; color: var(--c-heading); font-size: 18px; }

/* ----- Comment edit form ----- */
.comment-edit-form { margin-top: 6px; }
.comment-edit-form textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
}
.comment-edit-form .btn { height: 32px; padding: 0 10px; font-size: 13px; }

/* ----- Responsive ----- */
@media (max-width: 960px) {
    .layout-grid { grid-template-columns: 1fr; }
    .sidebar { order: 2; }
}
/* ─── HEADER responsive: ≤960px = tablet/landscape phone too ───────────
   Header drops to 2-row layout (brand+actions on top, tabs below) as soon
   as content gets cramped. Previously kicked in at 720 — left tablets
   trying to squeeze everything onto 1 row and breaking. */
@media (max-width: 960px) {
    .header-inner {
        flex-wrap: wrap;
        height: auto;
        min-height: var(--header-h);
        padding: 6px 10px;
        gap: 6px;
        row-gap: 0;
    }
    .brand { order: 1; }
    .header-actions { order: 2; margin-left: auto; gap: 6px; }

    /* Row 2 becomes a real flex row containing tabs + search. width: 100%
       forces it onto a new line below brand+actions. */
    .header-row-2 {
        display: flex;
        align-items: center;
        gap: 8px;
        order: 10;
        flex-basis: 100%;
        width: 100%;
        margin: 4px -10px 0;
        padding: 4px 10px 2px;
        border-top: 1px solid var(--c-border);
    }
    .header-row-2 .tabs {
        flex: 1 1 auto;
        min-width: 0;
        gap: 2px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .header-row-2 .tabs::-webkit-scrollbar { display: none; }
    .header-row-2 .tabs .tab {
        padding: 7px 10px;
        font-size: 13px;
        white-space: nowrap;
        flex-shrink: 0;
    }
    .header-row-2 .search {
        flex: 0 0 auto;
        width: 160px;
        max-width: 200px;
    }
    .header-row-2 .search input { height: 32px; font-size: 13px; }
    .header-actions > .btn-ghost { display: none; }
    .header-actions .btn-primary {
        padding: 0 10px;
        font-size: 13px;
        height: 32px;
        gap: 4px;
    }
    .brand-logo { height: 22px; }
    .lang-switch { font-size: 12px; margin-right: 0; }
    .theme-toggle { width: 30px; height: 30px; }
}

/* ─── BODY/CONTENT responsive: ≤720px = phones only ─────────────────────
   Tighter padding + smaller fonts kick in only on phone-sized devices.
   Tablets at 720-960px keep desktop-style content density. */
@media (max-width: 720px) {
    .container { padding: 12px 8px 40px; }
    .post-head { padding: 12px 44px 6px 14px; }
    .post-title { font-size: 16px; }
    .post-actions { flex-wrap: nowrap; gap: 2px; padding: 8px 6px; }
    .post-actions .action-btn { padding: 6px 8px; }
    .auth-wrap, .upload-wrap { margin: 16px auto; }
    .auth-card, .upload-card { padding: 18px; }
    .feed-title { font-size: 18px; }
    .pagination { padding: 8px 10px; }
    .pagination .btn { padding: 0 10px; font-size: 13px; }
    .page-indicator { font-size: 12px; }
    .profile-header { flex-direction: column; align-items: flex-start; text-align: left; }
    .modal-dialog { padding: 18px; }
}

/* Below 640px, Tools dropdown collapses to wrench-icon-only (the dropdown
   still works on click). Hide the "Tools" label + chevron, keep the icon. */
@media (max-width: 640px) {
    .tools-trigger .btn-label,
    .tools-trigger .tools-chevron { display: none; }
    .tools-trigger { padding: 0 8px; }
}

/* Mobile-only magnifying-glass button in the header. Hidden by default;
   only the ≤520px breakpoint reveals it (where the inline search bar hides). */
.search-toggle {
    display: none;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 0;
    background: transparent;
    color: var(--c-muted);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: background .12s, color .12s;
}
.search-toggle:hover { background: var(--c-bg); color: var(--c-heading); }
.is-search-open .search-toggle { background: var(--c-tag-bg); color: var(--c-primary); }

/* Below 520px, the "+ Post" button label disappears too — only the plus icon
   remains. The inline search bar hides; instead a 🔍 button in the header
   toggles a slide-down search row. */
@media (max-width: 520px) {
    .search-toggle { display: inline-flex; }

    /* Search input is hidden until the magnifying-glass is clicked.
       When .is-search-open, the search input takes over the tabs row entirely
       (tabs hide). User closes by clicking the icon again, hitting Esc, or
       submitting the search. */
    .header-row-2 .search { display: none; }
    .site-header.is-search-open .header-row-2 .tabs { display: none; }
    .site-header.is-search-open .header-row-2 .search {
        display: block;
        flex: 1;
        width: 100%;
        max-width: none;
        animation: search-slide-in .15s ease-out;
    }
    .site-header.is-search-open .header-row-2 .search input {
        width: 100%;
        height: 36px;
        font-size: 14px;
    }

    .header-actions .btn-primary .btn-label { display: none; }
    .header-actions .btn-primary { padding: 0 10px; }
    .header-actions .btn-primary .icon { width: 20px; height: 20px; }
}

@keyframes search-slide-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

@media (max-width: 420px) {
    /* Tightest layout: shrink avatar + lang switch even more */
    .header-actions .btn-primary { padding: 0 9px; }
    .lang-switch { padding: 0 2px; font-size: 11px; }
    .header-inner { gap: 4px; }
}

/* Hide action button text labels on small screens so vote / comment / share /
   save / more all fit in one row. Icons + counts remain visible. */
@media (max-width: 520px) {
    .post-actions .action-label { display: none; }
}

/* ============ PWA install prompt (bottom banner) ============ */
.install-prompt {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 200;
    background: var(--c-card);
    border: 1px solid var(--c-border);
    border-radius: 14px;
    box-shadow: var(--shadow-h);
    padding: 12px 14px;
    animation: install-slide-up .25s ease-out;
}
@keyframes install-slide-up {
    from { transform: translateY(120%); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}
.install-prompt-inner {
    display: flex;
    align-items: center;
    gap: 12px;
}
.install-prompt-icon img {
    border-radius: 10px;
    display: block;
}
.install-prompt-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.install-prompt-text strong {
    color: var(--c-heading);
    font-size: 14px;
}
.install-prompt-sub {
    color: var(--c-muted);
    font-size: 12px;
    line-height: 1.35;
}
.install-prompt-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}
.install-prompt-actions .btn-link-mini {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 0;
    background: transparent;
    color: var(--c-muted);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}
.install-prompt-actions .btn-link-mini:hover { background: var(--c-bg); color: var(--c-heading); }
@media (min-width: 540px) {
    .install-prompt { left: auto; right: 16px; bottom: 16px; max-width: 380px; }
}

/* Guest avatar — round person-icon link used on mobile (≤720px) when the
   Login text button is hidden. Replaces the empty pill that previously
   appeared next to the lang switch for non-authenticated viewers.       */
.guest-avatar {
    display: none;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--c-bg);
    color: var(--c-muted);
    transition: background .12s, color .12s;
}
.guest-avatar:hover { background: var(--c-tag-bg); color: var(--c-primary); text-decoration: none; }
@media (max-width: 720px) {
    .guest-avatar { display: inline-flex; }
    /* Register text button is redundant once the guest-avatar is visible. */
    .header-actions .btn-primary[href$="/register"] { display: none; }
}
@media (max-width: 480px) {
    .footer-inner { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 900px) {
    .admin-shell { grid-template-columns: 1fr; }
    .admin-nav {
        display: flex;
        align-items: center;        /* don't vertical-stretch items (was making active link huge) */
        align-self: start;          /* don't stretch nav itself to fill grid row */
        gap: 4px;
        padding: 8px;
        border-right: 0;
        border-bottom: 1px solid var(--c-border);
        overflow-x: auto;
    }
    .admin-nav a {
        white-space: nowrap;
        margin-bottom: 0;           /* desktop has 2px bottom margin — kill on mobile */
        flex-shrink: 0;
    }
}

/* ===== Mobile (<=720px): tag tabs scroll horizontally instead of overflow ===== */
@media (max-width: 720px) {
    .tag-header { padding: 14px; }
    .tag-title { font-size: 20px; }
    .tag-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        flex-wrap: nowrap;
    }
    .tag-tabs::-webkit-scrollbar { display: none; }
    .tag-tabs .tab {
        white-space: nowrap;
        flex-shrink: 0;
        padding: 7px 10px;
        font-size: 13px;
    }

    /* ===== Mobile: admin tables → stacked card layout =====
       Each <tr> becomes a card; each <td> shows its column label via data-label. */
    .admin-table-wrap {
        background: transparent;
        border: 0;
        overflow: visible;
    }
    .admin-table,
    .admin-table tbody,
    .admin-table tr,
    .admin-table td {
        display: block;
        width: 100%;
    }
    .admin-table thead { display: none; }
    .admin-table tr {
        background: var(--c-card);
        border: 1px solid var(--c-border);
        border-radius: var(--radius);
        padding: 4px 0;
        margin-bottom: 10px;
    }
    .admin-table td {
        padding: 8px 14px;
        border-bottom: 1px solid var(--c-border);
        font-size: 13px;
        white-space: normal;
        word-break: break-word;
    }
    .admin-table tr td:last-child { border-bottom: 0; }
    .admin-table td::before {
        content: attr(data-label);
        display: block;
        font-size: 10px;
        font-weight: 600;
        color: var(--c-muted);
        text-transform: uppercase;
        letter-spacing: .04em;
        margin-bottom: 4px;
    }
    .admin-table td[data-label=""]::before,
    .admin-table td:not([data-label])::before { display: none; }
    .admin-table td:empty { display: none; }
    /* Actions cell: stack buttons full-width on mobile */
    .admin-table .action-cell { white-space: normal; }
    .admin-table .action-cell form {
        display: block;
        margin: 0 0 6px 0;
    }
    .admin-table .action-cell .btn-mini { width: 100%; }

    /* Admin filter inputs stack and take full width */
    .admin-filter input[type=search],
    .admin-filter select { min-width: 0; width: 100%; }

    /* ===== Admin Tags: stack form rows vertically, no fixed widths ===== */
    .tag-create-form {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    .tag-create-form input,
    .tag-create-form input:first-of-type {
        max-width: none;
        width: 100%;
        /* Hard-lock height so "Tên tag" and "Mô tả" render identically */
        height: 36px !important;
        min-height: 36px;
        max-height: 36px;
        box-sizing: border-box;
        line-height: 1;
    }
    .tag-create-form .btn { width: 100%; }

    .tag-row {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 10px 12px;
    }
    .tag-row-form {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        width: 100%;
    }
    .tag-row-form input,
    .tag-row-name,
    .tag-row-desc {
        width: 100%;
        min-width: 0;
        /* Hard-lock height so name and desc render identically regardless of value/font metrics */
        height: 36px !important;
        min-height: 36px;
        max-height: 36px;
        box-sizing: border-box;
        line-height: 1;
    }
    .tag-id {
        font-size: 11px;
        color: var(--c-muted);
        font-weight: 600;
        text-transform: uppercase;
    }
    /* Meta row: slug + count on the left, Save/Delete buttons on the right — all on ONE line */
    .tag-row-meta {
        display: flex;
        align-items: center;
        gap: 8px;
        flex-wrap: nowrap;
        width: 100%;
    }
    .tag-row-meta .tag-row-slug,
    .tag-row-meta .tag-row-count {
        width: auto;
        font-size: 12px;
        flex-shrink: 1;
        min-width: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .tag-row-actions {
        margin-left: auto;
        gap: 6px;
        flex-shrink: 0;
    }
    .tag-row-actions .btn-mini {
        height: 30px;
        padding: 0 12px;
        font-size: 13px;
    }
    .tag-row-actions .btn-mini-danger {
        padding: 0;
        min-width: 38px;
    }
}

/* ============ Sidebar leaderboard widget ============ */
.sidebar-leaderboard { list-style: none; padding: 0; margin: 0; }
.sidebar-lb-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid var(--c-border);
}
.sidebar-lb-row:last-of-type { border-bottom: 0; }
.sidebar-lb-rank {
    width: 24px;
    font-size: 14px;
    font-weight: 700;
    text-align: center;
    color: var(--c-muted);
    flex-shrink: 0;
}
.sidebar-lb-user {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
    color: var(--c-text);
}
.sidebar-lb-user:hover { text-decoration: none; }
.sidebar-lb-user img,
.sidebar-lb-user .avatar-fallback {
    width: 24px; height: 24px; border-radius: 50%;
    object-fit: cover; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 11px;
    background: var(--c-bg);
}
.sidebar-lb-name {
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--c-heading);
}
.sidebar-lb-score {
    font-size: 12px;
    font-weight: 600;
    color: var(--c-primary);
    flex-shrink: 0;
}
.sidebar-more {
    display: block;
    margin-top: 10px;
    text-align: right;
    font-size: 12px;
    color: var(--c-primary);
}

/* ============ Leaderboard ============ */
.leaderboard-tabs {
    display: flex;
    gap: 4px;
    margin: 16px 0;
    background: var(--c-bg);
    padding: 4px;
    border-radius: var(--radius-sm);
}
.leaderboard-tabs a {
    flex: 1;
    text-align: center;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 13px;
    color: var(--c-muted);
    font-weight: 500;
}
.leaderboard-tabs a:hover { color: var(--c-heading); text-decoration: none; }
.leaderboard-tabs a.is-active {
    background: var(--c-card);
    color: var(--c-primary);
    font-weight: 600;
}
.leaderboard-list { list-style: none; padding: 0; margin: 0; }
.leaderboard-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 8px;
    border-bottom: 1px solid var(--c-border);
}
.leaderboard-row:last-child { border-bottom: 0; }
.lb-rank {
    width: 44px;
    font-weight: 700;
    font-size: 18px;
    text-align: center;
    color: var(--c-muted);
}
.lb-rank-1 { font-size: 22px; }
.lb-rank-2, .lb-rank-3 { font-size: 20px; }
.lb-user {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    color: var(--c-text);
}
.lb-user:hover { text-decoration: none; }
.lb-user strong { color: var(--c-heading); }
.lb-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.lb-score { font-weight: 700; color: var(--c-primary); white-space: nowrap; }

@media (max-width: 720px) {
    .leaderboard-row { gap: 8px; padding: 10px 4px; }
    .lb-rank { width: 32px; font-size: 14px; }
    .lb-avatar { width: 32px; height: 32px; }
}

/* ============ Blocked users settings page ============ */
.blocked-list { list-style: none; padding: 0; margin: 16px 0 0; }
.blocked-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--c-border);
}
.blocked-row:last-child { border-bottom: 0; }
.blocked-user {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
    color: var(--c-text);
}
.blocked-user:hover { text-decoration: none; }
.blocked-user img,
.blocked-user .avatar-fallback {
    width: 44px; height: 44px; border-radius: 50%;
    object-fit: cover; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--c-primary);
    color: #fff;
    font-weight: 700;
}
.blocked-user strong { color: var(--c-heading); display: block; }

/* ============ Pull-to-refresh indicator ============ */
.ptr-indicator {
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%) translateY(-60px);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--c-card);
    box-shadow: 0 4px 12px rgba(0,0,0,.18);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    z-index: 9999;
    transition: opacity .15s;
}
.ptr-indicator.is-visible { /* opacity set inline during pull */ }
.ptr-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--c-border);
    border-top-color: var(--c-primary);
    border-radius: 50%;
    transition: transform .2s;
}
.ptr-indicator.is-ready .ptr-spinner { border-top-color: var(--c-down); transform: rotate(180deg); }
.ptr-indicator.is-refreshing .ptr-spinner { animation: ptr-spin .8s linear infinite; }
@keyframes ptr-spin { to { transform: rotate(360deg); } }

/* ============ Admin: bar chart + analytics layout ============ */
.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 160px;
    padding: 0 4px;
}
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.bar {
    width: 100%;
    max-width: 32px;
    background: linear-gradient(180deg, var(--c-primary), var(--c-secondary, var(--c-primary)));
    border-radius: 4px 4px 0 0;
    transition: opacity .12s;
    position: relative;
}
.bar:hover { opacity: .8; }
.bar::after {
    content: attr(data-value);
    position: absolute;
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    font-weight: 600;
    color: var(--c-muted);
}
.bar-label { font-size: 10px; color: var(--c-muted); }

.layout-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
@media (max-width: 720px) { .layout-2col { grid-template-columns: 1fr; } }

.rank-list { list-style: decimal; padding-left: 20px; margin: 0; }
.rank-list li { margin-bottom: 8px; line-height: 1.4; }

/* ============ Admin: moderation queue ============ */
.queue-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
    margin-top: 14px;
}
.queue-item { padding: 12px; }
.queue-thumb {
    width: 100%;
    max-height: 200px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    background: var(--c-bg);
}
.queue-meta h3 { margin: 0 0 6px; font-size: 15px; }
.queue-actions { display: flex; gap: 8px; margin-top: 10px; }
.queue-actions .btn-mini { flex: 1; }

.stat-card.is-warn { background: rgba(245, 158, 11, .1); border: 1px solid rgba(245, 158, 11, .3); }

/* ============ Post "..." more menu (top-right corner) ============
   Used by both feed cards (.post-card) and post detail (.post-detail).
   The parent must be position:relative so the absolute trigger anchors. */
.post-card,
.post-detail { position: relative; }
.post-more-menu {
    position: absolute;
    top: 10px;
    right: 12px;
    z-index: 5;
}
.post-more-trigger {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 0;
    background: transparent;
    color: var(--c-muted);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .12s, color .12s;
}
@media (hover: hover) and (pointer: fine) {
    .post-more-trigger:hover { background: var(--c-bg); color: var(--c-heading); }
}
.post-more-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    min-width: 180px;
    background: var(--c-card);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-h);
    padding: 4px 0;
    display: none;
}
.post-more-menu.is-open .post-more-dropdown { display: block; }
.post-more-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    background: transparent;
    border: 0;
    text-align: left;
    color: var(--c-text);
    font-size: 14px;
    cursor: pointer;
    font-family: inherit;
}
.post-more-item:hover { background: var(--c-bg); text-decoration: none; color: var(--c-heading); }
.post-more-danger { color: var(--c-down); }
.post-more-danger:hover { background: rgba(225, 29, 72, .08); color: var(--c-down); }

/* ============ Follow chip (inline, used on post cards next to author) ============
   Subtle tinted pill in primary color — visually pairs with the adjacent tag chips
   instead of competing with them. Hover fills solid to signal action.            */
.follow-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0 10px;
    height: 22px;
    margin-left: 6px;
    border-radius: 999px;
    background: var(--c-tag-bg);
    color: var(--c-primary);
    border: 0;
    font-size: 11.5px;
    font-weight: 500;
    letter-spacing: .01em;
    cursor: pointer;
    transition: background .15s, color .15s;
    vertical-align: middle;
}
@media (hover: hover) and (pointer: fine) {
    .follow-chip:hover {
        background: var(--c-primary);
        color: #fff;
    }
}
.follow-chip .icon { width: 12px; height: 12px; stroke-width: 2.4; }
.follow-chip.is-following {
    background: transparent;
    color: var(--c-muted);
    border: 1px solid var(--c-border);
    padding: 0 9px;     /* compensate for 1px border so width stays consistent */
}
@media (hover: hover) and (pointer: fine) {
    .follow-chip.is-following:hover {
        background: rgba(225, 29, 72, .08);
        color: var(--c-down);
        border-color: rgba(225, 29, 72, .35);
    }
}

/* Post-meta author link (now a hyperlink, not just text) */
.post-author { color: var(--c-muted); }
@media (hover: hover) and (pointer: fine) {
    .post-author:hover { color: var(--c-heading); text-decoration: none; }
}

/* ============ Follow button (full size, on profile page) ============ */
.follow-btn { margin-top: 10px; min-width: 120px; }
/* `!important` needed because .btn-primary forces color:#fff !important on text */
.follow-btn.is-following {
    background: var(--c-card) !important;
    color: var(--c-text) !important;
    border: 1px solid var(--c-border);
}
.follow-btn.is-following:hover {
    background: rgba(225, 29, 72, .08) !important;
    color: var(--c-down) !important;
    border-color: var(--c-down);
}

/* ============ @mention autocomplete popup ============ */
.mention-popup {
    position: absolute;
    z-index: 500;
    background: var(--c-card);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-h);
    padding: 4px 0;
    min-width: 240px;
    max-width: 320px;
    max-height: 280px;
    overflow-y: auto;
}
.mention-popup-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
}
.mention-popup-item:hover,
.mention-popup-item.is-active { background: var(--c-bg); }
.mention-avatar {
    width: 28px; height: 28px; border-radius: 50%;
    object-fit: cover; flex-shrink: 0;
    background: var(--c-bg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
}
.mention-avatar-fallback { background: var(--c-primary); }
.mention-username { color: var(--c-heading); font-weight: 500; }

/* ============ @mention link inside comments ============ */
.comment-text .mention {
    color: var(--c-primary);
    font-weight: 500;
}
.comment-text .mention:hover { text-decoration: underline; }

/* ============ Comment sort tabs ============ */
.comments-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}
.comment-sort {
    display: flex;
    gap: 2px;
    background: var(--c-bg);
    border-radius: var(--radius-sm);
    padding: 3px;
}
.comment-sort a {
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    color: var(--c-muted);
}
.comment-sort a:hover { color: var(--c-heading); text-decoration: none; }
.comment-sort a.is-active {
    background: var(--c-card);
    color: var(--c-primary);
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
}

/* ============ Notifications ============ */
.notif-menu { position: relative; }
.notif-trigger {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--c-muted);
    background: transparent;
    cursor: pointer;
    position: relative;
    transition: background .12s, color .12s;
}
.notif-trigger:hover { background: var(--c-bg); color: var(--c-heading); }
.notif-trigger svg { display: block; pointer-events: none; }
.notif-trigger > * { pointer-events: none; }
.notif-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--c-down);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
}
.notif-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    width: 360px;
    max-width: calc(100vw - 24px);
    background: var(--c-card);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-h);
    z-index: 100;
    display: none;
    overflow: hidden;
}
.notif-menu.is-open .notif-dropdown { display: block; }
.notif-dropdown-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--c-border);
}
.btn-link-mini {
    background: transparent;
    border: 0;
    color: var(--c-primary);
    font-size: 12px;
    cursor: pointer;
    font-weight: 500;
}
.btn-link-mini:hover { text-decoration: underline; }
.notif-push-cta {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(18, 195, 244, .08);
    border-bottom: 1px solid var(--c-border);
    font-size: 12px;
    color: var(--c-text);
}
.notif-push-cta .btn-link-mini {
    margin-left: auto;
    background: var(--c-primary);
    color: #fff;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
}
.notif-push-cta .btn-link-mini:hover { filter: brightness(1.1); text-decoration: none; }

.notif-dropdown-list { max-height: 400px; overflow-y: auto; }
.notif-dropdown-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--c-border);
    color: var(--c-text);
    font-size: 13px;
    line-height: 1.45;
}
.notif-dropdown-item:hover { background: var(--c-bg); text-decoration: none; }
.notif-dropdown-item:last-child { border-bottom: 0; }
.notif-dropdown-item.is-unread { background: rgba(18,195,244,.06); }
.notif-dropdown-item.is-unread::before {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--c-primary);
    margin-right: 6px;
    vertical-align: middle;
}
.notif-dropdown-text strong { color: var(--c-heading); }
.notif-dropdown-foot {
    display: block;
    text-align: center;
    padding: 10px;
    font-size: 13px;
    color: var(--c-primary);
    border-top: 1px solid var(--c-border);
}
.notif-dropdown-foot:hover { background: var(--c-bg); text-decoration: none; }
.notif-loading { padding: 20px; text-align: center; margin: 0; }

/* /notifications page list */
.notif-page-head { display: flex; justify-content: space-between; align-items: center; }
.notif-page-head h1 { margin: 0; }
.notif-list { list-style: none; padding: 0; margin: 20px 0 0; }
.notif-item {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--c-border);
    align-items: flex-start;
}
.notif-item:last-child { border-bottom: 0; }
.notif-item.is-unread { background: rgba(18,195,244,.05); margin: 0 -16px; padding: 12px 16px; }
.notif-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    object-fit: cover; flex-shrink: 0;
    background: var(--c-bg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}
.notif-avatar-sys { background: var(--c-bg); display: inline-flex; align-items: center; justify-content: center; color: var(--c-primary); }
.notif-avatar-sys .icon { width: 22px; height: 22px; }
.notif-body { flex: 1; min-width: 0; }
.notif-text { color: var(--c-text); }
.notif-text strong { color: var(--c-heading); }
.notif-preview { margin-top: 4px; }
.notif-time { display: block; margin-top: 4px; }

@media (max-width: 720px) {
    /* Pin to viewport on mobile — avoids weird offset/clipping when bell sits
       at the right edge of a narrow header */
    .notif-dropdown {
        position: fixed;
        top: calc(var(--header-h, 56px) + 4px);
        left: 8px;
        right: 8px;
        width: auto;
        max-width: none;
    }
}

/* ============ Static pages (About / Terms / Privacy / Contact) ============ */
.page-wrap {
    max-width: 820px;
    margin: 24px auto;
    padding: 0 16px;
}
.page-content {
    padding: 32px 36px;
    line-height: 1.65;
    color: var(--c-text);
}
.page-content h1 {
    font-size: 28px;
    color: var(--c-heading);
    margin: 0 0 12px;
}
.page-content h2 {
    font-size: 20px;
    color: var(--c-heading);
    margin: 28px 0 10px;
    padding-top: 6px;
    border-top: 1px solid var(--c-border);
}
.page-content h2:first-of-type { border-top: 0; padding-top: 0; }
.page-content h3 {
    font-size: 16px;
    color: var(--c-heading);
    margin: 18px 0 8px;
}
.page-content p { margin: 0 0 12px; }
.page-content .page-lead {
    font-size: 16px;
    color: var(--c-text);
    margin-bottom: 20px;
    padding: 14px 16px;
    background: var(--c-bg);
    border-left: 3px solid var(--c-primary);
    border-radius: var(--radius-sm);
}
.page-content ul {
    margin: 0 0 14px;
    padding-left: 22px;
}
.page-content li { margin-bottom: 6px; }
.page-content a {
    color: var(--c-primary);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}
.page-content a:hover { text-decoration-thickness: 2px; }
.page-content code {
    background: var(--c-bg);
    border: 1px solid var(--c-border);
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 13px;
    font-family: ui-monospace, 'SF Mono', Consolas, monospace;
}
.page-content .muted.small { font-size: 12px; }

@media (max-width: 720px) {
    .page-wrap { margin: 16px auto; padding: 0 12px; }
    .page-content { padding: 22px 18px; }
    .page-content h1 { font-size: 22px; }
    .page-content h2 { font-size: 17px; margin-top: 22px; }
    .page-content .page-lead { font-size: 15px; padding: 12px 14px; }
}

/* ============ Theme toggle ============ */
.theme-toggle {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--c-muted);
    background: transparent;
    transition: background .12s, color .12s;
    cursor: pointer;
    flex-shrink: 0;
}
.theme-toggle:hover { background: var(--c-bg); color: var(--c-heading); }
.theme-toggle svg { width: 18px; height: 18px; display: block; }
.theme-toggle .icon-sun  { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun  { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle:hover { background: var(--c-card-2); color: var(--c-accent); }

/* ============ Dark mode overrides ============ */
[data-theme="dark"] body.admin { background: var(--c-bg); }

/* Admin header keeps a fixed dark navy */
[data-theme="dark"] .admin-header { background: #050a14; border-bottom-color: #1a2538; }

/* Alerts */
[data-theme="dark"] .alert-error   { background: #2a1419; color: #fca5a5; border-color: #5a1b22; }
[data-theme="dark"] .alert-success { background: #0f2722; color: #6ee7b7; border-color: #15453b; }

/* Status badges */
[data-theme="dark"] .status-pending   { background: #3a2a0a; color: #fbbf24; }
[data-theme="dark"] .status-resolved  { background: #0a3a2a; color: #34d399; }
[data-theme="dark"] .status-dismissed { background: #1f2937; color: #9ca3af; }
[data-theme="dark"] .status-active    { background: #0a3a2a; color: #34d399; }
[data-theme="dark"] .status-banned    { background: #3a0a0a; color: #fca5a5; }
[data-theme="dark"] .status-admin     { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .status-user      { background: #1f2937; color: #9ca3af; }
[data-theme="dark"] .status-published { background: #0a3a2a; color: #34d399; }
[data-theme="dark"] .status-hidden    { background: #3a2a0a; color: #fbbf24; }
[data-theme="dark"] .status-deleted   { background: #3a0a0a; color: #fca5a5; }

[data-theme="dark"] .stat-card.is-warn { border-color: #b45309; background: #2a1f0a; }

/* Buttons + form polish */
[data-theme="dark"] .btn-ghost { color: var(--c-text) !important; }
[data-theme="dark"] .btn-oauth { background: var(--c-card-2); color: var(--c-heading) !important; border-color: var(--c-border); }
[data-theme="dark"] .btn-oauth:hover { background: var(--c-card); }
[data-theme="dark"] .btn-oauth-facebook { background: #1877f2; color: #fff !important; border-color: #1877f2; }
[data-theme="dark"] .oauth-icon { background: var(--c-bg); color: var(--c-primary); }

/* Auth divider */
[data-theme="dark"] .auth-divider span { background: var(--c-card); }

/* Admin form code snippet */
[data-theme="dark"] .admin-form code { background: var(--c-bg); }

/* Btn mini in dark */
[data-theme="dark"] .btn-mini { background: var(--c-card-2); color: var(--c-text); border-color: var(--c-border); }
[data-theme="dark"] .btn-mini:hover { background: var(--c-bg); border-color: var(--c-accent); }
[data-theme="dark"] .btn-mini-danger  { background: var(--c-card-2); color: var(--c-down); border-color: #5a1b22; }
[data-theme="dark"] .btn-mini-danger:hover  { background: #2a1419; }
[data-theme="dark"] .btn-mini-success { background: var(--c-card-2); color: #34d399; border-color: #15453b; }
[data-theme="dark"] .btn-mini-success:hover { background: #0f2722; }

/* Page link */
[data-theme="dark"] .page-link { color: var(--c-text); }

/* Tag chip uses var-based bg now */
.tag-chip { background: var(--c-tag-bg); color: var(--c-primary); }
@media (hover: hover) and (pointer: fine) {
    .tag-chip:hover { background: var(--c-tag-bg-h); }
}
.tab.is-active { background: var(--c-tag-bg); color: var(--c-primary); }

/* Profile readonly username input */
[data-theme="dark"] .profile-edit-readonly { background: var(--c-card-2) !important; color: var(--c-muted) !important; }
