/* ═══════════════════════════════════════════════════════════
   Hookah Threads — Global Styles
   Matched to stream.yamlgenerator.com color scheme
   ═══════════════════════════════════════════════════════════ */

@font-face { font-family: 'Inter'; font-weight: 400; font-style: normal; font-display: swap; src: url('/static/fonts/inter-400.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 500; font-style: normal; font-display: swap; src: url('/static/fonts/inter-500.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 600; font-style: normal; font-display: swap; src: url('/static/fonts/inter-600.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 700; font-style: normal; font-display: swap; src: url('/static/fonts/inter-700.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 800; font-style: normal; font-display: swap; src: url('/static/fonts/inter-800.woff2') format('woff2'); }

:root {
    --bg: #080808;
    --bg2: #0f0f0f;
    --surface: rgba(255,255,255,0.04);
    --surface-hover: rgba(255,255,255,0.07);
    --glass: rgba(255,255,255,0.05);
    --glass-border: rgba(255,255,255,0.1);
    --border: rgba(255,255,255,0.08);
    --border-hover: rgba(255,255,255,0.18);
    --text: #f0f0f0;
    --muted: rgba(255,255,255,0.35);
    --muted2: rgba(255,255,255,0.18);
    --online: #22c55e;
    --danger: #ef4444;
    --danger-dim: rgba(239,68,68,0.12);
    --danger-border: rgba(239,68,68,0.3);
    --accent: #f5a623;
    --accent-dim: rgba(245,166,35,0.12);
    --transition: 0.2s cubic-bezier(0.4,0,0.2,1);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

html {
    font-size: 15px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

a { color: rgba(255,255,255,0.7); text-decoration: none; transition: color var(--transition); }
a:hover { color: #fff; }

::selection { background: rgba(255,255,255,0.15); color: #fff; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

/* ═══════════════ TOP PROGRESS BAR ═══════════════ */

#progress-bar {
    position: fixed; top: 0; left: 0; z-index: 9999;
    width: 0; height: 2px;
    background: linear-gradient(90deg, rgba(255,255,255,0.6), #fff);
    transition: width 400ms ease;
    pointer-events: none;
}
#progress-bar.active { animation: progress-pulse 2s infinite; }
@keyframes progress-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ═══════════════ HEADER ═══════════════ */

.header {
    position: sticky; top: 0; z-index: 100;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 36px; height: 60px;
    background: rgba(8,8,8,0.85);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
}
.header-logo {
    display: flex; align-items: center; gap: 10px;
    font-weight: 800; font-size: 1.15rem; color: #fff;
    letter-spacing: -0.5px;
}
.header-logo .logo-icon {
    width: 24px; height: 24px; border-radius: 50%;
    animation: logo-pulse 2.5s ease-in-out infinite;
}
@keyframes logo-pulse {
    0%, 100% { opacity: 0.7; filter: drop-shadow(0 0 2px rgba(255,255,255,0.1)); }
    50% { opacity: 1; filter: drop-shadow(0 0 8px rgba(255,255,255,0.25)); }
}
.header-logo .dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--online);
    box-shadow: 0 0 6px var(--online);
    animation: livePulse 2s infinite;
}
@keyframes livePulse {
    0%,100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.75); }
}
.header-nav { display: flex; align-items: center; gap: 12px; }

.online-pill {
    display: flex; align-items: center; gap: 7px;
    padding: 6px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 100px;
    font-size: 0.75rem; font-weight: 600;
    color: var(--muted);
    transition: all var(--transition);
}
.online-pill .online-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--online);
    box-shadow: 0 0 6px var(--online);
    animation: livePulse 2s infinite;
}

.header-user {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 14px 6px 6px;
    border-radius: 100px; cursor: pointer;
    background: var(--surface);
    border: 1px solid var(--border);
    transition: all var(--transition);
    position: relative;
}
.header-user:hover { background: var(--surface-hover); border-color: var(--border-hover); }
.header-user img {
    width: 30px; height: 30px; border-radius: 50%;
    object-fit: cover;
}
.header-user .name { font-size: 0.8rem; font-weight: 500; color: rgba(255,255,255,0.7); }
.header-user .role-badge {
    font-size: 0.6rem; font-weight: 700; text-transform: uppercase;
    color: var(--online); letter-spacing: 0.06em;
}

.user-dropdown {
    position: absolute; top: calc(100% + 8px); right: 0;
    min-width: 180px; padding: 6px;
    background: var(--bg2);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    box-shadow: 0 16px 40px rgba(0,0,0,0.5);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    opacity: 0; visibility: hidden;
    transform: translateY(-8px);
    transition: opacity var(--transition), transform var(--transition), visibility var(--transition);
}
.user-dropdown.open { opacity: 1; visibility: visible; transform: translateY(0); }
.user-dropdown a, .user-dropdown button {
    display: block; width: 100%; padding: 9px 14px;
    font: inherit; font-size: 0.8rem; font-weight: 500;
    color: rgba(255,255,255,0.7); background: none; border: none;
    border-radius: 10px; cursor: pointer;
    text-align: left;
    transition: all var(--transition);
}
.user-dropdown a:hover, .user-dropdown button:hover { background: var(--surface-hover); color: #fff; }
.user-dropdown .danger { color: var(--danger); }
.user-dropdown .danger:hover { background: var(--danger-dim); }

/* ═══════════════ LAYOUT ═══════════════ */

.page-layout {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 24px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 36px;
}
@media (max-width: 900px) {
    .page-layout { grid-template-columns: 1fr; padding: 16px; }
    .sidebar { order: -1; }
}

.main-content { min-width: 0; }

/* ═══════════════ SIDEBAR ═══════════════ */

.sidebar { display: flex; flex-direction: column; gap: 16px; }

.sidebar-card {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 16px;
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    transition: border-color var(--transition);
}
.sidebar-card:hover { border-color: var(--border-hover); }
.sidebar-card h3 {
    font-size: 0.7rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 1.2px;
    color: var(--muted); margin-bottom: 12px;
}

.cat-list { list-style: none; }
.cat-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: 10px;
    cursor: pointer; transition: all var(--transition);
    font-size: 0.85rem; font-weight: 500; line-height: 1;
    color: rgba(255,255,255,0.7);
}
.cat-item:hover { background: var(--surface-hover); color: #fff; }
.cat-item.active { background: rgba(255,255,255,0.1); color: #fff; }
.cat-dot {
    width: 10px; height: 10px; border-radius: 50%;
    flex-shrink: 0;
}
.cat-count {
    margin-left: auto; font-size: 0.7rem;
    color: var(--muted2); font-weight: 600;
}

/* ═══════════════ CARDS / THREADS ═══════════════ */

.thread-list { display: flex; flex-direction: column; gap: 10px; }

.thread-card {
    background: #161616;
    border: 1px solid var(--glass-border);
    border-radius: 18px;
    padding: 18px 22px;
    cursor: pointer;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    isolation: isolate;
    animation: cardIn 0.4s cubic-bezier(0.4,0,0.2,1) both;
}
.thread-card:hover {
    box-shadow: 0 16px 40px rgba(0,0,0,0.5);
    border-color: rgba(255,255,255,0.2);
}
.thread-card:active { transform: translateY(0) scale(0.995); }
.thread-card.pinned-global { border-left: 3px solid rgba(255,255,255,0.4); }
.thread-card.pinned-user { border-left: 3px solid rgba(255,255,255,0.15); }

@keyframes cardIn {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

.thread-card-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.thread-card-category {
    font-size: 0.65rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.06em;
    padding: 3px 10px; border-radius: 100px;
}
.thread-card-pin {
    font-size: 0.7rem; color: rgba(255,255,255,0.5); font-weight: 600;
    display: flex; align-items: center; gap: 4px;
}
.thread-card-title {
    font-size: 1.05rem; font-weight: 600;
    color: #fff; line-height: 1.4;
    margin-bottom: 4px;
    overflow-wrap: anywhere;
}
.thread-card-excerpt {
    font-size: 0.85rem; color: var(--muted);
    line-height: 1.5; white-space: pre-line;
    display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical;
    overflow: hidden;
}
.thread-card-footer {
    display: flex; align-items: center; gap: 10px;
    margin-top: 10px; font-size: 0.75rem; color: var(--muted2);
}
.thread-card-footer img {
    width: 20px; height: 20px; border-radius: 50%; object-fit: cover;
}
.thread-card-actions {
    margin-left: auto; display: flex; gap: 4px;
}

.thread-card-image {
    position: relative;
    margin: 10px -22px 0;
    height: 380px;
    overflow: hidden;
    border-top: 1px solid var(--border);
}
.thread-card-image-blur {
    position: absolute; inset: -24px;
    background-size: cover;
    background-position: center;
    filter: blur(24px);
    opacity: 0.4;
    transform: scale(1.1);
}
.thread-card-image img {
    position: relative;
    width: 100%; height: 100%;
    object-fit: contain;
}
@media (max-width: 600px) {
    .thread-card-image { margin: 8px -18px 0; height: 260px; }
}

/* ═══════════════ CUSTOM VIDEO PLAYER ═══════════════ */

.vp {
    position: relative; background: #000; overflow: hidden;
    border-radius: 0; /* inherits from parent */
}
.vp video { width: 100%; height: 100%; display: block; object-fit: contain; }

.vp-overlay {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,0.25);
    opacity: 1; transition: opacity 0.3s ease;
    cursor: pointer;
}
.vp.playing .vp-overlay { opacity: 0; }
.vp.playing:hover .vp-overlay { opacity: 1; }

.vp-play-big {
    width: 56px; height: 56px; border-radius: 50%;
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border: 2px solid rgba(255,255,255,0.25);
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.2s ease, background 0.2s ease;
}
.vp-play-big:hover { transform: scale(1.1); background: rgba(255,255,255,0.25); }
.vp-play-big svg { margin-left: 3px; }

.vp-controls {
    position: absolute; bottom: 0; left: 0; right: 0;
    padding: 8px 12px;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    display: flex; align-items: center; gap: 10px;
    opacity: 0; transition: opacity 0.3s ease;
}
.vp:hover .vp-controls { opacity: 1; }

.vp-progress {
    position: absolute; bottom: 0; left: 0; right: 0;
    height: 3px; background: rgba(255,255,255,0.15);
    cursor: pointer; z-index: 2;
    transition: height 0.15s ease;
}
.vp:hover .vp-progress { height: 5px; }
.vp-progress-fill {
    height: 100%; background: #fff; width: 0%;
    transition: none;
}
.vp-progress-buffer {
    position: absolute; top: 0; left: 0; height: 100%;
    background: rgba(255,255,255,0.2); width: 0%;
}

.vp-time {
    font-size: 0.7rem; color: rgba(255,255,255,0.7);
    font-variant-numeric: tabular-nums; white-space: nowrap;
    min-width: 70px;
}

.vp-btn {
    background: none; border: none; color: #fff;
    cursor: pointer; padding: 4px;
    display: flex; align-items: center; justify-content: center;
    opacity: 0.8; transition: opacity 0.2s;
}
.vp-btn:hover { opacity: 1; }

.vp-volume {
    display: flex; align-items: center; gap: 4px;
}
.vp-volume-bar {
    width: 60px; height: 4px;
    -webkit-appearance: none; appearance: none;
    background: rgba(255,255,255,0.2); border-radius: 2px;
    outline: none; cursor: pointer;
}
.vp-volume-bar::-webkit-slider-thumb {
    -webkit-appearance: none; width: 12px; height: 12px;
    border-radius: 50%; background: #fff; cursor: pointer;
}

/* Card-mode player — compact controls */
.thread-card-image .vp { height: 100%; }
.thread-card-image .vp-play-big { width: 48px; height: 48px; }
.thread-card-image .vp-controls { padding: 6px 10px; gap: 8px; }
.thread-card-image .vp-controls .vp-fs { display: none; }
.thread-card-image .vp-time { font-size: 0.65rem; min-width: 55px; }

/* ═══════════════ BUTTONS ═══════════════ */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 22px;
    font: inherit; font-size: 0.8rem; font-weight: 600;
    border: none; border-radius: 10px;
    cursor: pointer; white-space: nowrap;
    transition: all var(--transition);
}
.btn:active { transform: scale(0.97); }

.btn-primary {
    background: rgba(255,255,255,0.1);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
}
.btn-primary:hover {
    background: rgba(255,255,255,0.16);
    border-color: rgba(255,255,255,0.25);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.btn-secondary {
    background: var(--surface);
    color: rgba(255,255,255,0.7);
    border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--border-hover); background: var(--surface-hover); color: #fff; }

.btn-ghost {
    background: transparent; color: var(--muted);
    padding: 6px 14px; font-size: 0.8rem;
    border-radius: 8px;
}
.btn-ghost:hover { color: #fff; background: var(--surface-hover); }

.btn-danger {
    background: var(--danger-dim); color: var(--danger);
    border: 1px solid var(--danger-border);
}
.btn-danger:hover { background: rgba(239,68,68,0.2); }

.btn-icon {
    width: 30px; height: 30px; padding: 0;
    border-radius: 8px;
    background: transparent; border: none; color: var(--muted2);
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
}
.btn-icon:hover { color: #fff; background: var(--surface-hover); }
.btn-icon.active { color: #fff; }
.btn-icon.liked { color: #ef4444; }
.btn-icon.liked:hover { color: #f87171; }
.btn-icon:active { transform: scale(0.9); }

.like-btn {
    display: inline-flex; align-items: center; gap: 2px;
    width: auto; padding: 0 6px;
    transition: all 0.2s cubic-bezier(0.34,1.56,0.64,1);
}
.like-btn:active { transform: scale(1.15); }
.like-count { font-size: 0.7rem; font-weight: 600; min-width: 12px; }

/* ═══════════════ INPUTS ═══════════════ */

.input, .textarea, .select {
    width: 100%; padding: 11px 18px;
    font: inherit; font-size: 0.9rem;
    background: var(--glass); color: var(--text);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    outline: none;
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    transition: all var(--transition);
}
.input:focus, .textarea:focus, .select:focus {
    border-color: rgba(255,255,255,0.25);
    background: rgba(255,255,255,0.07);
    box-shadow: 0 0 0 3px rgba(255,255,255,0.04);
}
.input::placeholder, .textarea::placeholder {
    color: var(--muted2);
}
.textarea {
    resize: vertical; min-height: 120px; line-height: 1.6;
    font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', monospace;
    font-size: 0.85rem;
}
.select {
    appearance: none; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 14px center;
    padding-right: 36px;
}

label {
    display: block; font-size: 0.7rem; font-weight: 700;
    color: var(--muted); margin-bottom: 6px;
    text-transform: uppercase; letter-spacing: 1.2px;
}

/* ═══════════════ MODALS ═══════════════ */

.modal-overlay {
    position: fixed; inset: 0; z-index: 500;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    display: flex; align-items: center; justify-content: center;
    opacity: 0; visibility: hidden;
    transition: opacity 250ms ease, visibility 250ms ease;
}
.modal-overlay.open { opacity: 1; visibility: visible; }

.modal {
    background: var(--bg2);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 32px;
    max-width: 560px; width: 90%;
    box-shadow: 0 24px 80px rgba(0,0,0,0.8), inset 0 1px 0 rgba(255,255,255,0.06);
    transform: scale(0.94);
    opacity: 0;
    transition: transform 250ms cubic-bezier(0.4,0,0.2,1), opacity 250ms ease;
}
.modal-overlay.open .modal { transform: scale(1); opacity: 1; }

.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px;
}
.modal-header h2 { font-size: 1.1rem; font-weight: 700; }
.modal-body { margin-bottom: 20px; }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; }

/* ═══════════════ PROFILE MODAL ═══════════════ */

.profile-modal {
    width: 340px; max-width: 92vw;
    border-radius: 20px;
    overflow: hidden;
    background: var(--bg2);
    border: 1px solid var(--glass-border);
    box-shadow: 0 24px 80px rgba(0,0,0,0.8);
    transform: scale(0.94); opacity: 0;
    transition: transform 250ms cubic-bezier(0.4,0,0.2,1), opacity 250ms ease;
}
.modal-overlay.open .profile-modal { transform: scale(1); opacity: 1; }

.profile-modal-bg {
    position: relative;
    min-height: 180px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    display: flex; align-items: flex-end; justify-content: center;
    padding: 24px 20px 20px;
    overflow: hidden;
}
.profile-modal-bg-img {
    position: absolute; inset: 0;
    background-size: cover; background-position: center;
    transition: filter 0.4s ease, transform 0.4s ease;
}
.profile-modal-bg-overlay {
    position: absolute; inset: 0;
    background: linear-gradient(to bottom, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0.6) 100%);
}
.profile-modal-close {
    position: absolute; top: 12px; right: 12px; z-index: 2;
    background: rgba(0,0,0,0.4); border: none; color: #fff;
    width: 28px; height: 28px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 1.1rem;
    transition: background 0.2s;
}
.profile-modal-close:hover { background: rgba(0,0,0,0.7); }

.profile-modal-header {
    position: relative; z-index: 1;
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    text-align: center;
}
.profile-modal-avatar {
    width: 72px; height: 72px; border-radius: 50%;
    object-fit: cover; border: 3px solid rgba(255,255,255,0.2);
}
.profile-modal-name {
    font-size: 1.15rem; font-weight: 700; color: #fff;
}
.profile-modal-username {
    font-size: 0.8rem; color: rgba(255,255,255,0.5);
}
.profile-role-badge {
    display: inline-block; padding: 2px 10px;
    border-radius: 10px; font-size: 0.65rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.5px;
    background: rgba(245,166,35,0.2); color: #f5a623;
}

.profile-modal-stats {
    display: flex; justify-content: space-around;
    padding: 16px 12px;
    border-bottom: 1px solid var(--border);
}
.profile-stat { text-align: center; }
.profile-stat-val { font-size: 1.2rem; font-weight: 700; color: #fff; }
.profile-stat-label { font-size: 0.7rem; color: var(--text-muted); margin-top: 2px; }

.profile-modal-footer {
    padding: 12px 16px;
    font-size: 0.75rem; color: var(--text-muted);
    text-align: center;
}

/* ═══════════════ CUSTOM SELECT ═══════════════ */

.csel {
    position: relative; width: 100%;
}
.csel-trigger {
    display: flex; align-items: center; justify-content: space-between;
    padding: 11px 18px;
    background: var(--glass); color: var(--text);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    font-size: 0.9rem; cursor: pointer;
    transition: all var(--transition);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.csel-trigger:hover { border-color: var(--border-hover); }
.csel.open .csel-trigger { border-color: rgba(255,255,255,0.25); background: rgba(255,255,255,0.07); }
.csel-trigger svg { flex-shrink: 0; color: var(--muted); transition: transform var(--transition); }
.csel.open .csel-trigger svg { transform: rotate(180deg); }
.csel-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.csel-dropdown {
    position: absolute; top: calc(100% + 6px); left: 0; right: 0;
    background: var(--bg2);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 6px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.6);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    z-index: 60;
    max-height: 220px; overflow-y: auto;
    opacity: 0; visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 150ms ease, transform 150ms ease, visibility 150ms ease;
}
.csel.open .csel-dropdown { opacity: 1; visibility: visible; transform: translateY(0); }

.csel-option {
    padding: 9px 14px;
    font-size: 0.85rem; color: rgba(255,255,255,0.7);
    border-radius: 8px; cursor: pointer;
    transition: all var(--transition);
}
.csel-option:hover { background: var(--surface-hover); color: #fff; }
.csel-option.active { background: rgba(255,255,255,0.1); color: #fff; }

/* ═══════════════ SKELETON LOADING ═══════════════ */

.skeleton {
    background: linear-gradient(90deg, var(--glass) 25%, rgba(255,255,255,0.08) 50%, var(--glass) 75%);
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease infinite;
    border-radius: 14px;
}
@keyframes skeleton-pulse {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}
.skeleton-card {
    height: 120px; border-radius: 18px;
    margin-bottom: 10px;
}

/* ═══════════════ THREAD VIEW ═══════════════ */

.thread-view {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 18px;
    padding: 36px;
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    animation: cardIn 0.4s cubic-bezier(0.4,0,0.2,1);
}
.thread-view-title { font-size: 1.6rem; font-weight: 800; line-height: 1.3; margin-bottom: 12px; color: #fff; overflow-wrap: anywhere; }
.thread-view-meta {
    display: flex; align-items: center; gap: 12px;
    font-size: 0.8rem; color: var(--muted);
    margin-bottom: 24px; padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.thread-view-meta img { width: 24px; height: 24px; border-radius: 50%; }
.thread-view-body {
    font-size: 0.95rem; line-height: 1.8; color: rgba(255,255,255,0.85);
}
.thread-view-body h1, .thread-view-body h2, .thread-view-body h3 {
    margin: 1.2em 0 0.4em; font-weight: 700; color: #fff;
}
.thread-view-body h1 { font-size: 1.3rem; }
.thread-view-body h2 { font-size: 1.15rem; }
.thread-view-body h3 { font-size: 1rem; }
.thread-view-body p { margin: 0.6em 0; }
.thread-view-body img {
    max-width: 100%; max-height: 480px;
    border-radius: 14px;
    margin: 12px 0;
    object-fit: contain;
}
.thread-view-body blockquote {
    border-left: 3px solid rgba(255,255,255,0.2);
    padding: 8px 16px; margin: 12px 0;
    background: rgba(255,255,255,0.03);
    border-radius: 0 10px 10px 0;
}
.thread-view-body code {
    background: rgba(255,255,255,0.08);
    padding: 2px 6px; border-radius: 4px;
    font-size: 0.85em;
}
.thread-view-body pre {
    background: rgba(255,255,255,0.04);
    padding: 16px; border-radius: 10px;
    overflow-x: auto; margin: 12px 0;
    border: 1px solid var(--border);
}
.thread-view-body pre code { background: none; padding: 0; }
.thread-view-body a {
    color: rgba(255,255,255,0.7); text-decoration: underline; text-underline-offset: 2px;
    max-width: 40ch; display: inline-block; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom;
}
.thread-view-body a:hover { color: #fff; }
.thread-view-body ul, .thread-view-body ol { padding-left: 1.5em; margin: 0.6em 0; }
.thread-view-body li { margin: 0.3em 0; }
.thread-view-body table {
    width: 100%; border-collapse: collapse; margin: 12px 0;
}
.thread-view-body th, .thread-view-body td {
    padding: 8px 12px; border: 1px solid var(--border);
    text-align: left; font-size: 0.85rem;
}
.thread-view-body th { background: var(--surface-hover); font-weight: 600; }
.thread-view-body hr { border: none; border-top: 1px solid var(--border); margin: 24px 0; }

.thread-view-actions {
    display: flex; gap: 8px; margin-top: 24px;
    padding-top: 16px; border-top: 1px solid var(--border);
}

/* ═══════════════ LIKES POPOVER ═══════════════ */

.like-wrap { position: relative; display: inline-flex; }
.likes-popover {
    position: absolute; bottom: calc(100% + 8px); left: 50%;
    transform: translateX(-50%) translateY(4px);
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: 12px; padding: 8px;
    min-width: 200px; max-width: 280px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.6);
    opacity: 0; visibility: hidden;
    transition: opacity 0.15s, transform 0.15s, visibility 0.15s;
    z-index: 100; pointer-events: none;
}
.like-wrap:hover .likes-popover.has-data {
    opacity: 1; visibility: visible;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}
.likes-popover::after {
    content: ''; position: absolute; top: 100%; left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent; border-top-color: var(--bg2);
    margin-top: -1px;
}
.likes-popover-row {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 4px; border-radius: 8px;
    cursor: pointer; transition: background 0.15s;
}
.likes-popover-row:hover { background: var(--surface-hover); }
.likes-popover-avatar {
    width: 28px; height: 28px; border-radius: 50%;
    flex-shrink: 0; object-fit: cover;
}
.likes-popover-name {
    font-size: 0.85rem; font-weight: 500; color: #fff;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.likes-popover-more {
    padding: 6px 4px; text-align: center;
    color: var(--muted); font-size: 0.75rem;
}

/* ═══════════════ COMMENTS ═══════════════ */

.comments-section {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}
.comments-header {
    display: flex; align-items: center; gap: 8px;
    font-size: 0.95rem; font-weight: 700; color: #fff;
    margin-bottom: 16px;
}
.comments-count-badge {
    font-size: 0.75rem; font-weight: 600;
    background: rgba(255,255,255,0.08);
    padding: 2px 8px; border-radius: 100px;
    color: var(--muted);
}
.comment-item {
    display: flex; gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.comment-item:last-child { border-bottom: none; }
.comment-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    flex-shrink: 0; object-fit: cover;
}
.comment-content { flex: 1; min-width: 0; }
.comment-meta {
    display: flex; align-items: center; gap: 8px;
    font-size: 0.78rem; margin-bottom: 4px;
}
.comment-author { font-weight: 600; color: #fff; }
.comment-time { color: var(--muted); }
.comment-body {
    font-size: 0.88rem; line-height: 1.6;
    color: rgba(255,255,255,0.8);
}
.comment-body p { margin: 0.3em 0; }
.comment-body p:first-child { margin-top: 0; }
.comment-body p:last-child { margin-bottom: 0; }
.comment-body a { color: rgba(255,255,255,0.7); text-decoration: underline; }
.comment-body code {
    background: rgba(255,255,255,0.08);
    padding: 1px 4px; border-radius: 3px; font-size: 0.82em;
}
.comment-delete {
    background: none; border: none; color: var(--muted);
    cursor: pointer; padding: 2px; margin-left: auto;
    opacity: 0; transition: opacity 0.15s, color 0.15s;
}
.comment-item:hover .comment-delete { opacity: 1; }
.comment-delete:hover { color: var(--danger); }
.comment-form {
    display: flex; gap: 12px; margin-top: 16px; align-items: flex-start;
}
.comment-form > .comment-avatar { margin-top: 6px; }
.comment-form > .comment-send-btn { margin-top: 2px; }
.comment-form textarea {
    flex: 1; background: var(--surface);
    border: 1px solid var(--border); border-radius: 12px;
    color: var(--text); font: inherit; font-size: 0.88rem;
    padding: 10px 14px; resize: vertical; min-height: 44px; max-height: 200px;
    outline: none; transition: border-color 0.15s;
}
.comment-form textarea:focus { border-color: rgba(255,255,255,0.25); }
.comment-form textarea::placeholder { color: var(--muted2); }
.comment-send-btn {
    display: flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: 50%;
    background: var(--surface); border: 1px solid var(--border);
    color: var(--muted); cursor: pointer;
    transition: all 0.15s; flex-shrink: 0;
}
.comment-send-btn:hover { background: var(--surface-hover); color: #fff; border-color: var(--border-hover); }
.comment-send-btn:disabled { opacity: 0.4; cursor: default; }
.comments-empty {
    text-align: center; padding: 24px 0;
    color: var(--muted2); font-size: 0.85rem;
}

/* ═══════════════ EDITOR ═══════════════ */

.modal-fullish {
    max-width: 95vw !important; width: 100%;
    height: 88vh;
    display: flex; flex-direction: column;
}
.modal-fullish .modal-body {
    flex: 1; overflow: hidden;
    display: flex; flex-direction: column;
}
.modal-fullish .editor-wrap {
    flex: 1; min-height: 0;
}
.modal-fullish .textarea {
    height: 100%; resize: none;
}
.modal-fullish .editor-preview {
    max-height: none; height: 100%;
}
@media (max-width: 768px) {
    .modal-fullish { height: 95vh; }
}

.editor-wrap {
    display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
    min-height: 300px;
}
@media (max-width: 768px) { .editor-wrap { grid-template-columns: 1fr; } }

.editor-preview {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 16px;
    overflow-y: auto; max-height: 500px;
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.editor-preview-empty {
    color: var(--muted2); font-style: italic;
    display: flex; align-items: center; justify-content: center;
    height: 100%; font-size: 0.85rem;
}
.editor-toolbar {
    display: flex; gap: 4px; margin-bottom: 8px;
    flex-wrap: wrap;
}

.drop-zone {
    border: 2px dashed var(--border);
    border-radius: 14px;
    padding: 24px; text-align: center;
    color: var(--muted); font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition);
}
.drop-zone:hover, .drop-zone.dragover {
    border-color: rgba(255,255,255,0.3); background: rgba(255,255,255,0.03);
}
.drop-zone.uploading { pointer-events: none; opacity: 0.5; }

/* ═══════════════ LOGIN ═══════════════ */

.login-page {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg);
}
.login-card {
    background: rgba(255,255,255,0.03);
    backdrop-filter: blur(40px); -webkit-backdrop-filter: blur(40px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 48px 40px;
    text-align: center; max-width: 420px; width: 90%;
    box-shadow: 0 0 80px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.08);
    animation: loginReveal 0.6s cubic-bezier(0.4,0,0.2,1);
}
@keyframes loginReveal {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.login-card h1 {
    font-size: 1.6rem; font-weight: 800; margin-bottom: 4px;
    color: #fff;
}
.login-card .subtitle {
    color: var(--muted); font-size: 0.85rem; margin-bottom: 32px;
}
.login-tg-wrap { display: flex; justify-content: center; }
.login-methods {
    display: flex; gap: 4px; margin-bottom: 28px;
    background: rgba(255,255,255,0.04); border-radius: 10px; padding: 4px;
}
.login-method-tab {
    flex: 1; padding: 10px 12px; font-size: 0.8rem; font-weight: 600;
    color: var(--muted); background: transparent; border: none; cursor: pointer;
    border-radius: 8px; transition: all var(--transition); font-family: var(--font);
}
.login-method-tab:hover { color: var(--text); }
.login-method-tab.active {
    background: rgba(255,255,255,0.08); color: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.login-method-content { display: none; min-height: 60px; }
.login-method-content.active { display: block; }
.bot-login-link {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 12px 28px; border-radius: 10px;
    background: rgba(255,255,255,0.06); border: 1px solid var(--glass-border);
    color: #fff; font-weight: 600; font-size: 0.9rem; cursor: pointer;
    transition: all var(--transition); text-decoration: none;
    font-family: var(--font);
}
.bot-login-link:hover { background: rgba(255,255,255,0.1); border-color: var(--border-hover); color: #fff; }
.bot-login-status {
    margin-top: 20px; font-size: 0.8rem; color: var(--muted);
    display: flex; align-items: center; justify-content: center; gap: 8px;
}
.bot-login-status .dot {
    width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
    animation: pulse-dot 1.5s ease-in-out infinite;
}
@keyframes pulse-dot {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}
.bot-login-ok { color: var(--online); }
.bot-login-denied { color: var(--danger); }
.login-powered {
    margin-top: 32px; font-size: 0.65rem; color: var(--muted2);
    letter-spacing: 1.5px; text-transform: uppercase;
}

/* ═══════════════ NO-ACCESS ═══════════════ */

.no-access-page {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    flex-direction: column; gap: 16px;
    text-align: center; padding: 24px;
}
.no-access-page h1 { font-size: 1.4rem; font-weight: 700; }
.no-access-page p { color: var(--muted); max-width: 400px; font-size: 0.9rem; }

/* ═══════════════ ADMIN TABLES ═══════════════ */

.admin-table {
    width: 100%; border-collapse: collapse;
    font-size: 0.85rem;
}
.admin-table th {
    text-align: left; padding: 10px 12px;
    font-size: 0.65rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 1.2px;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
}
.admin-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}
.admin-table tr { transition: background var(--transition); }
.admin-table tr:hover { background: var(--surface-hover); }

.role-pill {
    display: inline-block; padding: 3px 10px;
    border-radius: 100px; font-size: 0.65rem;
    font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.5px;
}
.role-pill.admin { background: rgba(34,197,94,0.08); color: var(--online); border: 1px solid rgba(34,197,94,0.25); }
.role-pill.user { background: var(--surface); color: var(--muted); border: 1px solid var(--border); }
.role-pill.banned { background: var(--danger-dim); color: var(--danger); border: 1px solid var(--danger-border); }

/* ═══════════════ TOASTS ═══════════════ */

.toast-container {
    position: fixed; bottom: 28px; right: 28px; z-index: 1000;
    display: flex; flex-direction: column; gap: 8px;
}
.toast {
    padding: 14px 22px;
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    font-size: 0.85rem; max-width: 360px; color: #fff;
    animation: toast-in 0.35s cubic-bezier(0.34,1.56,0.64,1);
}
.toast.success { border-left: 3px solid var(--online); }
.toast.error { border-left: 3px solid var(--danger); }
@keyframes toast-in {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ═══════════════ SCROLL TO TOP ═══════════════ */

.scroll-top {
    position: fixed; bottom: 24px; left: 24px; z-index: 200;
    width: 40px; height: 40px; border-radius: 50%;
    background: var(--surface); border: 1px solid var(--border);
    color: var(--muted);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; opacity: 0; visibility: hidden;
    transition: all var(--transition);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.scroll-top.visible { opacity: 1; visibility: visible; }
.scroll-top:hover { transform: translateY(-2px); border-color: var(--border-hover); color: #fff; }

/* ═══════════════ SITE BACKGROUND ═══════════════ */

#site-bg-layer {
    position: fixed; inset: 0; z-index: -1;
    background-size: cover; background-position: center;
    pointer-events: none;
}
#site-bg-dim {
    position: fixed; inset: 0; z-index: -1;
    background: #000; pointer-events: none;
}

.sitebg-modal {
    width: 420px; max-width: 94vw;
    border-radius: 20px; overflow: hidden;
    background: var(--bg2);
    border: 1px solid var(--glass-border);
    box-shadow: 0 24px 80px rgba(0,0,0,0.8);
    transform: scale(0.94); opacity: 0;
    transition: transform 250ms cubic-bezier(0.4,0,0.2,1), opacity 250ms ease;
}
.modal-overlay.open .sitebg-modal { transform: scale(1); opacity: 1; }

.sitebg-preview {
    width: 100%; height: 180px;
    background: var(--surface); background-size: cover; background-position: center;
    position: relative; overflow: hidden;
}
.sitebg-preview-dim {
    position: absolute; inset: 0; background: #000;
}
.sitebg-preview-blur {
    position: absolute; inset: -20px;
    background-size: cover; background-position: center;
}
.sitebg-controls {
    padding: 20px;
    display: flex; flex-direction: column; gap: 14px;
}
.sitebg-label {
    display: flex; align-items: center; justify-content: space-between;
    font-size: 0.8rem; color: var(--text-muted);
}
.sitebg-label span:last-child { font-weight: 600; color: #fff; }
.sitebg-controls input[type="range"] {
    width: 100%; accent-color: var(--accent, #f5a623);
}
.sitebg-actions {
    display: flex; gap: 8px; padding: 0 20px 20px;
    justify-content: flex-end;
}

/* ═══════════════ FAB (floating action button) ═══════════════ */

.fab-new-thread {
    position: fixed; bottom: 28px; right: 28px; z-index: 100;
    width: 52px; height: 52px; border-radius: 50%;
    background: #fff; border: none;
    color: #000; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 0 20px rgba(255,255,255,0.3), 0 4px 16px rgba(0,0,0,0.3);
    transition: transform 0.2s, box-shadow 0.2s;
}
.fab-new-thread:hover { transform: scale(1.1); box-shadow: 0 0 30px rgba(255,255,255,0.5), 0 6px 24px rgba(0,0,0,0.4); }
.fab-new-thread:active { transform: scale(0.95); }
.fab-new-thread.hidden { display: none; }

/* ═══════════════ PERF MODE ═══════════════ */

body.perf-mode *,
body.perf-mode *::before,
body.perf-mode *::after {
    animation: none !important;
    transition: none !important;
}
body.perf-mode .sakura-container { display: none !important; }
body.perf-mode .modal-overlay { backdrop-filter: none !important; -webkit-backdrop-filter: none !important; }
body.perf-mode .profile-modal-bg-overlay { backdrop-filter: none !important; }
body.perf-mode .thread-card { box-shadow: none !important; }
body.perf-mode .sidebar-card { box-shadow: none !important; }
body.perf-mode .online-dot { box-shadow: none !important; }

/* ═══════════════ UTILITY ═══════════════ */

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.text-muted { color: var(--muted); }
.text-sm { font-size: 0.8rem; }
.text-center { text-align: center; }
.hidden { display: none !important; }

/* ═══════════════ GLOSSARY TOOLTIP ═══════════════ */
.glossary-term {
    border-bottom: 1px dotted rgba(255,255,255,0.35);
    cursor: help;
    position: relative;
}
.glossary-tip {
    position: fixed;
    max-width: 320px;
    padding: 10px 14px;
    background: #1a1a1a;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.6);
    color: #e0e0e0;
    font-size: 0.82rem;
    line-height: 1.5;
    z-index: 9000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 150ms ease;
}
.glossary-tip.visible { opacity: 1; }
.glossary-tip-term {
    font-weight: 700;
    color: #fff;
    margin-bottom: 4px;
    font-size: 0.85rem;
}
@media (max-width: 768px) {
    .glossary-tip { max-width: 280px; font-size: 0.78rem; }
}
