/* ============================================================
   Foundry — Main Stylesheet
   Design: Dark gaming dashboard aesthetic
   Fonts: Rajdhani (display) + Nunito Sans (body)
   ============================================================ */

/* ── Google Font Import ──────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@400;500;600;700&family=Nunito+Sans:ital,opsz,wght@0,6..12,300;0,6..12,400;0,6..12,600;0,6..12,700;1,6..12,400&display=swap');

/* ── CSS Custom Properties ───────────────────────────────── */
:root {
    /* Palette — light theme */
    --bg-base:        #f0f2f5;
    --bg-surface:     #ffffff;
    --bg-sidebar:     #1a1d2e;
    --bg-sidebar-alt: #12141f;
    --bg-header:      #12141f;
    --bg-tile:        #1e2236;
    --bg-tile-hover:  #252a40;
    --bg-card:        #ffffff;
    --bg-input:       #ffffff;
    --bg-overlay:     rgba(10, 12, 22, 0.75);

    --text-primary:   #0d0f1a;
    --text-secondary: #4a5070;
    --text-muted:     #8890aa;
    --text-inverse:   #e8eaf6;
    --text-sidebar:   #c8cce8;
    --text-header:    #ffffff;

    --accent:         #00c8ff;
    --accent-dim:     rgba(0, 200, 255, 0.15);
    --accent-glow:    rgba(0, 200, 255, 0.4);
    --accent-hover:   #33d6ff;
    --danger:         #ff4757;
    --danger-dim:     rgba(255, 71, 87, 0.15);
    --success:        #2ed573;
    --success-dim:    rgba(46, 213, 115, 0.15);
    --warning:        #ffa502;

    --border:         rgba(0,0,0,0.08);
    --border-sidebar: rgba(255,255,255,0.07);
    --border-accent:  rgba(0, 200, 255, 0.3);

    /* Spacing */
    --sidebar-width:  240px;
    --header-height:  120px;
    --tile-height:    100px;
    --gap:            1rem;
    --radius:         10px;
    --radius-sm:      6px;
    --radius-lg:      16px;

    /* Typography */
    --font-display: 'Rajdhani', sans-serif;
    --font-body:    'Nunito Sans', sans-serif;
    --fs-xs:   0.75rem;
    --fs-sm:   0.875rem;
    --fs-base: 1rem;
    --fs-lg:   1.125rem;
    --fs-xl:   1.5rem;
    --fs-2xl:  2rem;
    --fs-3xl:  2.5rem;

    /* Transitions */
    --transition:      200ms ease;
    --transition-slow: 400ms ease;
}

[data-theme="dark"] {
    --bg-base:        #0d0f1a;
    --bg-surface:     #12141f;
    --bg-sidebar:     #0a0c16;
    --bg-sidebar-alt: #07090f;
    --bg-header:      #07090f;
    --bg-tile:        #151827;
    --bg-tile-hover:  #1c2030;
    --bg-card:        #151827;
    --bg-input:       #1a1d2e;
    --bg-overlay:     rgba(0, 0, 0, 0.85);

    --text-primary:   #e8eaf6;
    --text-secondary: #8890aa;
    --text-muted:     #555d7a;
    --text-inverse:   #0d0f1a;

    --border:         rgba(255,255,255,0.06);
    --border-sidebar: rgba(255,255,255,0.05);
}

/* ── Reset & Base ────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-size: var(--fs-base);
    color: var(--text-primary);
    background: var(--bg-base);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    transition: background var(--transition-slow), color var(--transition-slow);
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    color: var(--accent-hover);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

ul, ol {
    list-style: none;
}

button {
    cursor: pointer;
    font-family: var(--font-body);
}

/* ── Layout Shell ────────────────────────────────────────── */
.layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-rows: var(--header-height) 1fr;
    grid-template-areas:
        "sidebar header"
        "sidebar main";
    min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
    grid-area: sidebar;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-sidebar);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 100;
    transition: background var(--transition-slow);
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-sidebar); border-radius: 2px; }

/* Sidebar — Logo/Branding block */
.sidebar-brand {
    padding: 1.5rem 1.25rem 1rem;
    border-bottom: 1px solid var(--border-sidebar);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 80px;
}

.sidebar-brand-logo {
    width: 40px;
    height: 40px;
    background: var(--accent);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 0 16px var(--accent-glow);
}

.sidebar-brand-logo svg {
    width: 24px;
    height: 24px;
    color: #0d0f1a;
}

.sidebar-brand-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sidebar-brand-name {
    font-family: var(--font-display);
    font-size: var(--fs-xl);
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0.08em;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-brand-tagline {
    font-size: var(--fs-xs);
    color: var(--text-muted);
    letter-spacing: 0.04em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Sidebar — Full-width logo mode */
.sidebar-brand--full-logo {
    padding: 0.75rem;
    justify-content: center;
    align-items: center;
    min-height: auto;
}

.sidebar-brand--full-logo a {
    display: block;
    width: 100%;
    text-decoration: none;
}

.sidebar-brand--full-logo img {
    width: 100%;
    height: auto;
    max-height: 140px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    display: block;
}

/* Sidebar — Navigation */
.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    display: flex;
    flex-direction: column;
}

.sidebar-section-label {
    font-size: var(--fs-xs);
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 0.5rem 1.25rem 0.25rem;
    margin-top: 0.75rem;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1.25rem;
    color: var(--text-sidebar);
    font-size: var(--fs-sm);
    font-weight: 500;
    border-radius: 0;
    transition: color var(--transition), background var(--transition);
    position: relative;
}

.sidebar-nav-item:hover,
.sidebar-nav-item.active {
    color: #ffffff;
    background: rgba(255,255,255,0.05);
}

.sidebar-nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--accent);
    border-radius: 0 2px 2px 0;
    box-shadow: 0 0 8px var(--accent-glow);
}

.sidebar-nav-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.7;
    transition: opacity var(--transition);
}

.sidebar-nav-item:hover svg,
.sidebar-nav-item.active svg {
    opacity: 1;
}

/* Unread count badge in sidebar nav items */
.sidebar-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    margin-left: auto;
    background: var(--accent);
    color: var(--bg-sidebar);
    font-family: var(--font-display);
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    border-radius: 9px;
    line-height: 1;
    flex-shrink: 0;
}

.sidebar-spacer {
    flex: 1;
}

/* Sidebar — Login Box */
.sidebar-login {
    border-top: 1px solid var(--border-sidebar);
    padding: 1rem 1.25rem;
    background: var(--bg-sidebar-alt);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-sidebar);
    margin-bottom: 0.75rem;
}

.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-dim);
    border: 2px solid var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--accent);
    font-size: var(--fs-sm);
    letter-spacing: 0.05em;
    flex-shrink: 0;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-name {
    font-weight: 600;
    font-size: var(--fs-sm);
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: var(--fs-xs);
    color: var(--accent);
    text-transform: capitalize;
}

.sidebar-user-timer {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin-top: 0.25rem;
    font-family: var(--font-display);
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.04em;
    transition: color var(--transition);
}

.sidebar-user-timer svg {
    width: 10px;
    height: 10px;
    flex-shrink: 0;
    opacity: 0.65;
}

#session-timer-display {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.06em;
}

.sidebar-user-timer.timer-warning {
    color: var(--warning);
}

.sidebar-user-timer.timer-warning svg {
    opacity: 0.9;
}

.sidebar-user-timer.timer-danger {
    color: var(--danger);
}

.sidebar-user-timer.timer-danger svg {
    opacity: 1;
}

@keyframes timer-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.4; }
}

@media (prefers-reduced-motion: no-preference) {
    .sidebar-user-timer.timer-danger #session-timer-display {
        animation: timer-pulse 1s ease-in-out infinite;
    }
}

.login-form-label {
    font-size: var(--fs-xs);
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    display: block;
    margin-bottom: 0.625rem;
}

.login-form-group {
    margin-bottom: 0.625rem;
}

.login-form-input {
    width: 100%;
    padding: 0.5rem 0.625rem;
    background: var(--bg-input);
    border: 1px solid var(--border-sidebar);
    border-radius: var(--radius-sm);
    color: var(--text-sidebar);
    font-family: var(--font-body);
    font-size: var(--fs-sm);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.login-form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
    color: #ffffff;
}

.login-form-input::placeholder {
    color: var(--text-muted);
    font-size: var(--fs-xs);
}

.login-form-btn {
    width: 100%;
    padding: 0.5625rem;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-sm);
    color: #0d0f1a;
    font-family: var(--font-display);
    font-size: var(--fs-sm);
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
    margin-top: 0.25rem;
}

.login-form-btn:hover {
    background: var(--accent-hover);
    box-shadow: 0 0 16px var(--accent-glow);
    transform: translateY(-1px);
}

.login-form-btn:active {
    transform: translateY(0);
}

.login-error {
    font-size: var(--fs-xs);
    color: var(--danger);
    background: var(--danger-dim);
    border: 1px solid rgba(255,71,87,0.3);
    border-radius: var(--radius-sm);
    padding: 0.375rem 0.5rem;
    margin-bottom: 0.625rem;
    display: none;
}

.login-error.visible {
    display: block;
}

.login-divider {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.75rem 0;
    color: var(--text-muted);
    font-size: var(--fs-xs);
}
.login-divider::before,
.login-divider::after {
    content: '';
    flex: 1;
    border-top: 1px solid var(--border);
}

.login-discord-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5625rem;
    background: #5865F2;
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: var(--fs-sm);
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, box-shadow 0.15s;
}
.login-discord-btn:hover {
    background: #4752c4;
    box-shadow: 0 0 12px rgba(88, 101, 242, 0.4);
    color: #fff;
}

.discord-link-area {
    margin-top: 0.5rem;
}
.discord-linked-name {
    font-size: var(--fs-xs);
    color: var(--text-muted);
    margin-bottom: 0.3rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.discord-unlink-btn {
    width: 100%;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.12);
    color: var(--text-muted);
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: 0.04em;
    padding: 0.35rem 0.5rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    font-family: var(--font-body);
    transition: border-color var(--transition), color var(--transition);
}
.discord-unlink-btn:hover {
    border-color: var(--danger);
    color: var(--danger);
}
.discord-link-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    width: 100%;
    background: #5865F2;
    color: #fff;
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: 0.04em;
    padding: 0.4rem 0.5rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-family: var(--font-body);
    transition: background var(--transition), box-shadow var(--transition);
}
.discord-link-btn:hover {
    background: #4752c4;
    box-shadow: 0 0 10px rgba(88, 101, 242, 0.35);
    color: #fff;
}

.logout-btn {
    width: 100%;
    padding: 0.4375rem;
    background: transparent;
    border: 1px solid var(--border-sidebar);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    transition: color var(--transition), border-color var(--transition), background var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.logout-btn:hover {
    color: var(--danger);
    border-color: var(--danger);
    background: var(--danger-dim);
}

.logout-btn svg {
    width: 14px;
    height: 14px;
}

/* ── Header ──────────────────────────────────────────────── */
.header {
    grid-area: header;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-sidebar);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding-bottom: 0;
    position: sticky;
    top: 0;
    z-index: 90;
    overflow: hidden;
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0.5rem 1.5rem 0;
    gap: 0.75rem;
}

.theme-toggle-btn {
    background: rgba(255,255,255,0.07);
    border: 1px solid var(--border-sidebar);
    border-radius: var(--radius-sm);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: color var(--transition), background var(--transition), border-color var(--transition);
}

.theme-toggle-btn:hover {
    color: var(--accent);
    border-color: var(--border-accent);
    background: var(--accent-dim);
}

.theme-toggle-btn svg {
    width: 16px;
    height: 16px;
}

/* ── Tiles Track ─────────────────────────────────────────── */
.tiles-section {
    padding: 0 0 0;
    overflow: hidden;
    position: relative;
}

.tiles-track-wrapper {
    overflow-x: auto;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.tiles-track-wrapper::-webkit-scrollbar {
    display: none;
}

.tiles-track {
    display: flex;
    gap: 6px;
    padding: 8px 1.5rem;
    width: max-content;
    min-width: 100%;
}

/* Arrow scroll buttons */
.tiles-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    background: rgba(0,0,0,0.7);
    border: 1px solid var(--border-sidebar);
    border-radius: 50%;
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all var(--transition);
    backdrop-filter: blur(4px);
}

.tiles-arrow:hover {
    background: var(--accent);
    color: #0d0f1a;
    border-color: var(--accent);
}

.tiles-arrow svg { width: 14px; height: 14px; }
.tiles-arrow-prev { left: 6px; }
.tiles-arrow-next { right: 6px; }

/* ── Individual Tile ─────────────────────────────────────── */
.tile {
    position: relative;
    width: 160px;
    height: var(--tile-height);
    border-radius: var(--radius-sm);
    overflow: hidden;
    flex-shrink: 0;
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition);
    border: 1px solid rgba(255,255,255,0.08);
    background: var(--bg-tile);
}

.tile:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    border-color: var(--accent);
}

.tile-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    transition: transform var(--transition-slow), filter var(--transition-slow);
    filter: brightness(0.55) saturate(0.8);
}

.tile:hover .tile-bg {
    transform: scale(1.06);
    filter: brightness(0.7) saturate(1);
}

.tile-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to top,
        rgba(0,0,0,0.85) 0%,
        rgba(0,0,0,0.3) 50%,
        transparent 100%
    );
}

.tile-content {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 0.5rem 0.625rem;
}

.tile-title {
    font-family: var(--font-display);
    font-size: var(--fs-sm);
    font-weight: 600;
    color: #ffffff;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

/* Online/Offline indicator */
.tile-status {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid rgba(0,0,0,0.5);
    z-index: 5;
}

.tile-status.online {
    background: var(--success);
    box-shadow: 0 0 6px var(--success);
    animation: pulse-green 2s infinite;
}

.tile-status.offline {
    background: var(--danger);
    box-shadow: 0 0 6px var(--danger);
}

.tile-status.checking {
    background: var(--warning);
}

/* Locked state (not logged in) */
.tile-locked .tile-bg {
    filter: brightness(0.2) grayscale(0.8);
}

.tile-lock-icon {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: rgba(255,255,255,0.4);
    pointer-events: none;
}

.tile-lock-icon svg {
    width: 20px;
    height: 20px;
}

.tile-lock-icon span {
    font-size: var(--fs-xs);
    font-family: var(--font-display);
    letter-spacing: 0.05em;
}

/* Tile placeholder (no image) */
.tile-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e2236 0%, #2a2f4a 100%);
    color: rgba(255,255,255,0.2);
}

.tile-placeholder svg {
    width: 28px;
    height: 28px;
}

/* Empty tiles row message */
.tiles-empty {
    padding: 1.5rem 2rem;
    color: var(--text-muted);
    font-size: var(--fs-sm);
    font-style: italic;
}

/* ── Main Content ─────────────────────────────────────────── */
.main-content {
    grid-area: main;
    padding: 1.5rem;
    background: var(--bg-base);
    transition: background var(--transition-slow);
    min-width: 0;
    overflow-x: hidden;
}

/* Content Cards */
.content-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    transition: background var(--transition-slow), border-color var(--transition-slow);
}

.content-card-header {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.content-card-title {
    font-family: var(--font-display);
    font-size: var(--fs-xl);
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.04em;
}

.content-card-meta {
    font-size: var(--fs-xs);
    color: var(--text-muted);
}

.content-card-body {
    color: var(--text-secondary);
    font-size: var(--fs-sm);
    line-height: 1.75;
}

.content-card-body p + p {
    margin-top: 0.75rem;
}

/* Welcome banner */
.welcome-banner {
    background: linear-gradient(135deg, #12141f 0%, #1a1d2e 100%);
    border: 1px solid var(--border-accent);
    border-radius: var(--radius);
    padding: 2rem 1.5rem;
    margin-bottom: 1.25rem;
    position: relative;
    overflow: hidden;
}

.welcome-banner::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, var(--accent-dim) 0%, transparent 70%);
    pointer-events: none;
}

.welcome-banner-title {
    font-family: var(--font-display);
    font-size: var(--fs-2xl);
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0.05em;
    line-height: 1.1;
    margin-bottom: 0.5rem;
    position: relative;
}

.welcome-banner-sub {
    font-size: var(--fs-sm);
    color: rgba(255,255,255,0.5);
    position: relative;
}

.welcome-banner-accent {
    color: var(--accent);
}

/* News Feed Placeholder */
.news-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 3rem 2rem;
    text-align: center;
    color: var(--text-muted);
}

.news-placeholder svg {
    width: 48px;
    height: 48px;
    opacity: 0.3;
}

.news-placeholder p {
    font-size: var(--fs-sm);
}

/* ── Animations ──────────────────────────────────────────── */
@keyframes pulse-green {
    0%, 100% { box-shadow: 0 0 6px var(--success); opacity: 1; }
    50%       { box-shadow: 0 0 12px var(--success); opacity: 0.7; }
}

@keyframes fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fade-in 0.3s ease forwards;
}

/* ── Utility / Badges ─────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.badge-admin   { background: var(--accent-dim);   color: var(--accent); }
.badge-viewer  { background: rgba(255,255,255,0.07); color: var(--text-muted); }
.badge-online  { background: var(--success-dim);  color: var(--success); }
.badge-offline { background: var(--danger-dim);   color: var(--danger); }

/* ── Toast Notifications ─────────────────────────────────── */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 9999;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    font-size: var(--fs-sm);
    color: var(--text-primary);
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    animation: toast-in 0.3s ease;
    max-width: 320px;
}

.toast.error   { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }

@keyframes toast-in {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* Hamburger button — injected by JS on mobile; hidden by default at desktop */
.mobile-menu-btn { display: none; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 1024px) {
    :root { --sidebar-width: 200px; }
}

@media (max-width: 768px) {
    :root {
        --sidebar-width: 100%;
        --header-height: auto;
    }

    .layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto 1fr;
        grid-template-areas:
            "header"
            "sidebar"
            "main";
    }

    /* Sidebar becomes a top bar with flex-wrap so nav can drop below */
    .sidebar {
        position: relative;
        height: auto;
        overflow: visible;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: stretch;
    }

    /* Brand occupies most of the top bar, leaves room for hamburger */
    .sidebar-brand {
        flex: 1;
        min-height: 56px;
        border-bottom: 1px solid var(--border-sidebar);
        border-right: none;
        padding: 0.875rem 1rem;
        align-items: center;
    }

    /* Hamburger toggle button */
    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        width: 56px;
        min-height: 56px;
        background: transparent;
        border: none;
        border-left: 1px solid var(--border-sidebar);
        border-bottom: 1px solid var(--border-sidebar);
        color: var(--text-sidebar);
        cursor: pointer;
        transition: color var(--transition), background var(--transition);
    }

    .mobile-menu-btn:hover,
    .mobile-menu-btn[aria-expanded="true"] {
        color: var(--accent);
        background: rgba(255,255,255,0.04);
    }

    /* Nav — hidden by default, shown via .mobile-open added by JS */
    .sidebar-nav {
        display: none;
        flex: 0 0 100%;
        flex-direction: column;
        padding: 0.5rem 0;
        border-bottom: 1px solid var(--border-sidebar);
        background: var(--bg-sidebar-alt);
    }

    .sidebar-nav.mobile-open {
        display: flex;
    }

    /* Login / user block — full-width row below the nav */
    .sidebar-login {
        flex: 0 0 100%;
        border-top: 1px solid var(--border-sidebar);
        border-left: none;
    }

    /* Theme toggle — larger touch target */
    .theme-toggle-btn {
        width: 44px;
        height: 44px;
    }

    /* Tile scroll arrows — hidden on mobile; rely on native touch scroll */
    .tiles-arrow {
        display: none;
    }

    /* Calendar nav buttons — larger touch target */
    .cal-nav-btn {
        width: 44px;
        height: 44px;
    }

    /* Calendar view toggle — larger touch target */
    .cal-view-toggle {
        width: 44px;
        height: 44px;
    }
}

@media (max-width: 480px) {
    .tile { width: 130px; height: 80px; }
    .welcome-banner-title { font-size: var(--fs-xl); }
    /* Reduce welcome banner padding on very small screens */
    .welcome-banner { padding: 1.25rem 1rem; }
}

/* ── Reduced Motion ──────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================================
   News Post Cards (index.php main feed)
   ============================================================ */

.news-post-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.news-post-card + .news-post-card {
    margin-top: 1.25rem;
}

.news-post-card:hover {
    border-left-color: var(--accent-hover);
    box-shadow: 0 4px 20px rgba(0, 200, 255, 0.08);
}

.news-post-header {
    padding: 1rem 1.25rem 0.75rem;
    border-bottom: 1px solid var(--border);
}

.news-post-meta-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.4rem;
}

.news-post-title {
    margin: 0;
    font-family: var(--font-display);
    font-size: var(--fs-lg);
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    letter-spacing: 0.02em;
}

.news-post-badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border-radius: 100px;
}

.news-post-badge--public {
    background: rgba(0, 200, 100, 0.12);
    color: #00c864;
    border: 1px solid rgba(0, 200, 100, 0.25);
}

.news-post-meta {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: var(--fs-xs);
    color: var(--text-muted);
}

.news-post-meta svg {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    opacity: 0.6;
}

.news-post-meta-dot {
    opacity: 0.4;
}

.news-post-body {
    padding: 1rem 1.25rem 1.25rem;
    font-size: var(--fs-sm);
    line-height: 1.75;
    color: var(--text-secondary);
}

/* Rich content typography inside post cards */
.news-post-body h2 { font-family: var(--font-display); font-size: 1.35rem; font-weight: 700; margin: 1.1rem 0 0.5rem; color: var(--text-primary); border-bottom: 1px solid var(--border); padding-bottom: 0.3rem; }
.news-post-body h3 { font-family: var(--font-display); font-size: 1.1rem; font-weight: 700; margin: 0.9rem 0 0.4rem; color: var(--text-primary); }
.news-post-body h4 { font-family: var(--font-display); font-size: 0.95rem; font-weight: 700; margin: 0.8rem 0 0.35rem; color: var(--text-primary); }
.news-post-body p  { margin: 0 0 0.75rem; }
.news-post-body p:last-child { margin-bottom: 0; }
.news-post-body ul, .news-post-body ol { padding-left: 1.5rem; margin: 0 0 0.75rem; }
.news-post-body li { margin-bottom: 0.25rem; }
.news-post-body blockquote { border-left: 3px solid var(--accent); padding: 0.5rem 0.875rem; margin: 0.75rem 0; color: var(--text-secondary); font-style: italic; background: var(--accent-dim); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.news-post-body a { color: var(--accent); text-decoration: underline; }
.news-post-body a:hover { color: var(--accent-hover); }
.news-post-body code { font-family: monospace; font-size: 0.85em; background: rgba(255,255,255,0.07); padding: 0.15em 0.4em; border-radius: 3px; color: var(--accent); }
.news-post-body pre { background: rgba(0,0,0,0.25); padding: 1rem; border-radius: var(--radius-sm); overflow-x: auto; border: 1px solid var(--border); margin: 0.75rem 0; }
.news-post-body pre code { background: none; padding: 0; color: var(--text-primary); font-size: 0.875rem; }
.news-post-body hr { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0; }
.news-post-body mark { background: rgba(255,200,0,0.25); color: var(--text-primary); padding: 0.1em 0.25em; border-radius: 2px; }
.news-post-body table { border-collapse: collapse; width: 100%; margin: 0.75rem 0; font-size: var(--fs-xs); }
.news-post-body th, .news-post-body td { padding: 0.5rem 0.75rem; border: 1px solid var(--border); text-align: left; }
.news-post-body th { background: var(--bg-tile); font-weight: 700; color: var(--text-primary); }
.news-post-body img, .news-post-body .news-img { max-width: 100%; height: auto; border-radius: var(--radius-sm); display: block; margin: 0.75rem 0; }
.news-post-body figure.news-figure { margin: 0.75rem 0; }
.news-post-body figcaption { font-size: var(--fs-xs); color: var(--text-muted); text-align: center; margin-top: 0.4rem; }
.news-post-body details { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.5rem 0.875rem; margin: 0.75rem 0; }
.news-post-body summary { cursor: pointer; font-weight: 600; color: var(--text-primary); }
.news-post-body .news-embed { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; border-radius: var(--radius-sm); margin: 0.75rem 0; background: var(--bg-tile); }
.news-post-body .news-embed iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: none; }

/* Light mode adjustments */
[data-theme="light"] .news-post-card {
    border-color: rgba(0,0,0,0.08);
    border-left-color: var(--accent);
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

[data-theme="light"] .news-post-card:hover {
    box-shadow: 0 4px 16px rgba(0,200,255,0.12);
}

[data-theme="light"] .news-post-header {
    border-bottom-color: rgba(0,0,0,0.06);
}

[data-theme="light"] .news-post-body code {
    background: rgba(0,0,0,0.06);
}

[data-theme="light"] .news-post-body pre {
    background: rgba(0,0,0,0.04);
    border-color: rgba(0,0,0,0.1);
}

/* ── Calendar ─────────────────────────────────────────────── */

/* Calendar card variant: edge-to-edge grid, clean contained look */
.content-card--cal {
    padding: 0;
    overflow: hidden;
}
.content-card--cal .content-card-header {
    padding: 1.25rem 1.5rem 0.75rem;
    margin-bottom: 0;
}

.cal-body {
    padding: 0;
    overflow: hidden;
}

.cal-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    padding: 0.875rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.cal-nav-title {
    font-family: var(--font-display);
    font-size: var(--fs-xl);
    font-weight: 700;
    color: var(--text-primary);
    min-width: 220px;
    text-align: center;
    letter-spacing: 0.04em;
}

.cal-nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    background: var(--bg-input);
    border: 1px solid var(--border);
    transition: color var(--transition), background var(--transition), border-color var(--transition);
    text-decoration: none;
    flex-shrink: 0;
}

.cal-nav-btn:hover {
    color: var(--accent);
    background: var(--accent-dim);
    border-color: var(--accent);
}

/* 7-column grid with complete border box */
.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    border-top: 1px solid var(--border);
    border-left: 1px solid var(--border);
    width: 100%;
    box-sizing: border-box;
}

.cal-day-header {
    padding: 0.5rem 0.25rem;
    text-align: center;
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: var(--bg-surface);
}

/* Weekend column headers subtle tint */
.cal-day-header:first-child,
.cal-day-header:last-child {
    color: var(--accent);
    opacity: 0.75;
}

.cal-cell {
    min-height: 90px;
    padding: 0.4rem 0.5rem;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
    transition: background var(--transition-slow);
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
}

.cal-cell:not(.cal-cell--empty):hover {
    background: var(--bg-input);
}

.cal-cell--empty {
    background: var(--bg-surface);
}

/* Weekend cells (columns 1 and 7) */
.cal-cell:nth-child(7n+1),
.cal-cell:nth-child(7n) {
    background: color-mix(in srgb, var(--bg-surface) 60%, var(--bg-card) 40%);
}

.cal-cell:nth-child(7n+1):not(.cal-cell--empty):hover,
.cal-cell:nth-child(7n):not(.cal-cell--empty):hover {
    background: var(--bg-input);
}

.cal-cell--today {
    background: color-mix(in srgb, var(--accent) 6%, var(--bg-card) 94%);
}

.cal-cell--today:hover {
    background: color-mix(in srgb, var(--accent) 10%, var(--bg-card) 90%);
}

.cal-cell--today .cal-day-num {
    background: var(--accent);
    color: #000;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    box-shadow: 0 0 8px var(--accent-glow);
}

.cal-day-num {
    display: inline-block;
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
    width: 26px;
    height: 26px;
    line-height: 26px;
    text-align: center;
    border-radius: 50%;
    transition: background var(--transition), color var(--transition);
}

.cal-events { display: flex; flex-direction: column; gap: 2px; }

.cal-event-chip {
    display: block;
    width: 100%;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.68rem;
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    border: none;
    border-left-width: 3px;
    border-left-style: solid;
    transition: opacity var(--transition), transform var(--transition);
    font-family: var(--font-body);
    line-height: 1.6;
}

.cal-event-chip:hover { opacity: 0.82; transform: translateX(1px); }

.cal-event-more {
    font-size: 0.62rem;
    color: var(--text-muted);
    padding-left: 4px;
    font-style: italic;
    line-height: 1.8;
}

.cal-empty-msg {
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: var(--fs-sm);
    font-style: italic;
}

/* Calendar modal */
.cal-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.cal-modal[hidden] { display: none; }

.cal-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
}

.cal-modal-box {
    position: relative;
    z-index: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    width: 100%;
    max-width: 520px;
    max-height: 80vh;
    overflow-y: auto;
}

.cal-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 1.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
}

.cal-modal-title {
    font-family: var(--font-display);
    font-size: var(--fs-xl);
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.cal-modal-close {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition), background var(--transition);
    cursor: pointer;
}

.cal-modal-close:hover { color: var(--text-primary); background: var(--bg-input); }

.cal-modal-meta {
    padding: 0.75rem 1.5rem;
    font-size: var(--fs-sm);
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
    align-items: center;
}

.cal-modal-body {
    padding: 1.25rem 1.5rem 1.5rem;
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    line-height: 1.7;
}

.cal-modal-body p { margin-bottom: 0.6rem; }

@media (max-width: 768px) {
    .cal-cell { min-height: 52px; padding: 0.2rem 0.25rem; }
    .cal-event-chip { font-size: 0.58rem; padding: 1px 3px; }
    .cal-nav-title { font-size: var(--fs-lg); min-width: 140px; }
    .cal-day-header { font-size: 0.6rem; padding: 0.35rem 0.1rem; letter-spacing: 0; }
}

/* ── AI Chat ───────────────────────────────────────────────── */

/* Page-level layout: fill viewport so the chat can expand to fill it */
.page-chat html,
html.page-chat,
body.page-chat { height: 100%; overflow: hidden; }

body.page-chat .layout {
    height: 100vh;        /* fallback for browsers without dvh support */
    height: 100dvh;       /* accounts for mobile browser chrome (address bar) */
}

body.page-chat .main-content {
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding-bottom: 0;
}

/* Chat card: expand to fill remaining main-content height */
.content-card--chat {
    flex: 1;
    min-height: 0;
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
}

.content-card--chat .content-card-header {
    padding: 1rem 1.5rem 0.75rem;
    margin-bottom: 0;
    flex-shrink: 0;
}

.content-card--chat .content-card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    min-height: 0;
}

/* ── Chat layout wrapper ──────────────────────────────────── */
.chat-wrap {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

/* ── Messages scroll area ─────────────────────────────────── */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: .875rem;
    scroll-behavior: smooth;
    min-height: 0;
}

.chat-messages::-webkit-scrollbar { width: 5px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border-sidebar); border-radius: 99px; }

/* ── Message bubbles ──────────────────────────────────────── */
.chat-msg {
    display: flex;
    gap: .625rem;
    max-width: 82%;
}
.chat-msg--user {
    align-self: flex-end;
    flex-direction: row-reverse;
}
.chat-msg--assistant {
    align-self: flex-start;
}

.chat-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .04em;
    flex-shrink: 0;
    margin-top: 2px;
}
.chat-msg--user     .chat-msg-avatar { background: var(--accent); color: #000; }
.chat-msg--assistant .chat-msg-avatar { background: var(--bg-input); color: var(--text-muted); }

.chat-msg-bubble {
    padding: .625rem .875rem;
    border-radius: var(--radius);
    font-size: var(--fs-sm);
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}
.chat-msg--user      .chat-msg-bubble { background: var(--accent); color: #000; border-bottom-right-radius: 4px; }
.chat-msg--assistant .chat-msg-bubble { background: var(--bg-input); color: var(--text-primary); border-bottom-left-radius: 4px; }

/* ── Typing indicator ─────────────────────────────────────── */
.chat-typing {
    display: none;
    align-self: flex-start;
    align-items: center;
    gap: .625rem;
}
.chat-typing.visible { display: flex; }

.chat-typing-dots {
    display: flex;
    gap: 4px;
    padding: .625rem .875rem;
    background: var(--bg-input);
    border-radius: var(--radius);
    border-bottom-left-radius: 4px;
}
.chat-typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: chat-dot-bounce 1.2s ease-in-out infinite;
}
.chat-typing-dots span:nth-child(2) { animation-delay: .2s; }
.chat-typing-dots span:nth-child(3) { animation-delay: .4s; }

@keyframes chat-dot-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: .5; }
    40%            { transform: translateY(-5px); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .chat-typing-dots span { animation: none; opacity: .8; }
}

/* ── Empty state ──────────────────────────────────────────── */
.chat-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .75rem;
    color: var(--text-muted);
    text-align: center;
    padding: 2rem;
}
.chat-empty svg { opacity: .3; }
.chat-empty-title { font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 600; }
.chat-empty-sub   { font-size: var(--fs-sm); }

/* ── Input bar ────────────────────────────────────────────── */
.chat-input-bar {
    border-top: 1px solid var(--border);
    padding: .875rem 1.25rem;
    display: flex;
    gap: .625rem;
    align-items: flex-end;
    background: var(--bg-card);
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    resize: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: var(--fs-sm);
    line-height: 1.5;
    padding: .5rem .75rem;
    min-height: 38px;
    max-height: 160px;
    overflow-y: hidden;
    transition: border-color .15s;
}
.chat-input:focus { outline: none; border-color: var(--accent); }
.chat-input::placeholder { color: var(--text-muted); }

.chat-send-btn {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: var(--radius);
    border: none;
    background: var(--accent);
    color: #000;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity .15s, transform .1s;
}
.chat-send-btn:hover:not(:disabled) { opacity: .85; }
.chat-send-btn:active:not(:disabled) { transform: scale(.95); }
.chat-send-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Disabled state ───────────────────────────────────────── */
.chat-disabled {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .75rem;
    color: var(--text-muted);
    text-align: center;
    padding: 2rem;
}
.chat-disabled svg { opacity: .3; }

/* ── Calendar Agenda / List View (mobile-first) ───────────── */

.cal-agenda {
    padding: 0.75rem 1.25rem 1.25rem;
}

.cal-agenda-date {
    font-family: var(--font-display);
    font-size: var(--fs-xs);
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 0.75rem 0 0.4rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.4rem;
}

.cal-agenda-date:first-child {
    padding-top: 0.25rem;
}

.cal-agenda-item {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0.625rem 0.75rem;
    margin-bottom: 0.375rem;
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--accent);
    border-top: 1px solid var(--border);
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: var(--bg-input);
    cursor: pointer;
    text-align: left;
    transition: background var(--transition), transform var(--transition);
    font-family: var(--font-body);
    color: var(--text-primary);
    min-height: 44px;
}

.cal-agenda-item:hover {
    background: var(--bg-tile-hover);
    transform: translateX(2px);
}

.cal-agenda-item-content {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}

.cal-agenda-title {
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cal-agenda-time {
    font-size: var(--fs-xs);
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* View toggle button in calendar nav */
.cal-view-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    transition: color var(--transition), background var(--transition), border-color var(--transition);
    flex-shrink: 0;
}

.cal-view-toggle:hover {
    color: var(--accent);
    background: var(--accent-dim);
    border-color: var(--accent);
}

/* ============================================================
   Paizo Feed (paizo-feed.php — login-gated live feed)
   Reuses the same theme tokens as news-post-card so dark / light
   modes work without any per-component overrides.
   ============================================================ */

.paizo-feed-blurb {
    margin: 0 0 1rem;
    font-size: var(--fs-sm);
    color: var(--text-muted);
    line-height: 1.6;
}

.paizo-feed-blurb-meta {
    display: inline-block;
    margin-left: 0.4rem;
    font-size: var(--fs-xs);
    color: var(--text-muted);
}

.paizo-feed-status {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 3px 8px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 100px;
}

.paizo-feed-status .paizo-feed-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 6px var(--accent-glow);
    animation: paizo-feed-pulse 2.4s ease-in-out infinite;
}

.paizo-feed-status[data-state="error"] .paizo-feed-dot {
    background: #ff6680;
    box-shadow: 0 0 6px rgba(255, 102, 128, 0.5);
    animation: none;
}

.paizo-feed-status[data-state="updating"] .paizo-feed-dot {
    animation-duration: 0.9s;
}

@keyframes paizo-feed-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.55; transform: scale(0.85); }
}

@media (prefers-reduced-motion: reduce) {
    .paizo-feed-status .paizo-feed-dot { animation: none; }
}

.paizo-feed-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.paizo-feed-empty {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-muted);
    font-size: var(--fs-sm);
}

.paizo-feed-empty svg {
    width: 36px;
    height: 36px;
    margin-bottom: 0.6rem;
    opacity: 0.5;
}

.paizo-feed-item {
    display: grid;
    grid-template-columns: 96px 1fr;
    gap: 1rem;
    padding: 0.9rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.paizo-feed-item:hover {
    border-left-color: var(--accent-hover);
    box-shadow: 0 4px 20px rgba(0, 200, 255, 0.08);
}

.paizo-feed-item.paizo-feed-item--new {
    animation: paizo-feed-flash 1.6s ease-out;
}

@keyframes paizo-feed-flash {
    0%   { background: var(--accent-dim); }
    100% { background: var(--bg-card); }
}

@media (prefers-reduced-motion: reduce) {
    .paizo-feed-item.paizo-feed-item--new { animation: none; }
}

.paizo-feed-cover {
    width: 96px;
    height: 96px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--accent-dim);
    display: block;
    flex-shrink: 0;
}

.paizo-feed-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.paizo-feed-cover--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
}

.paizo-feed-cover--placeholder svg {
    width: 36px;
    height: 36px;
    opacity: 0.6;
}

.paizo-feed-body {
    min-width: 0;
}

.paizo-feed-meta {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.4rem;
    flex-wrap: wrap;
}

.paizo-feed-cat {
    display: inline-block;
    padding: 2px 8px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border-radius: 100px;
    background: var(--accent-dim);
    color: var(--accent);
    border: 1px solid var(--border-accent);
}

.paizo-feed-cat--book      { background: rgba(120, 90, 220, 0.15); color: #b39bff; border-color: rgba(120, 90, 220, 0.3); }
.paizo-feed-cat--adventure { background: rgba(255, 140, 0, 0.15);  color: #ffb060; border-color: rgba(255, 140, 0, 0.3); }
.paizo-feed-cat--accessory { background: rgba(0, 180, 110, 0.15); color: #4cd6a3; border-color: rgba(0, 180, 110, 0.3); }
.paizo-feed-cat--news      { background: rgba(180, 180, 200, 0.15); color: var(--text-muted); border-color: var(--border); }

.paizo-feed-time {
    font-size: var(--fs-xs);
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.paizo-feed-title {
    margin: 0 0 0.3rem;
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
    letter-spacing: 0.01em;
    word-break: break-word;
}

.paizo-feed-title a {
    color: inherit;
    text-decoration: none;
}

.paizo-feed-title a:hover {
    color: var(--accent);
}

.paizo-feed-summary {
    margin: 0;
    font-size: var(--fs-sm);
    line-height: 1.55;
    color: var(--text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

@media (max-width: 540px) {
    .paizo-feed-item {
        grid-template-columns: 64px 1fr;
        gap: 0.75rem;
        padding: 0.75rem;
    }
    .paizo-feed-cover {
        width: 64px;
        height: 64px;
    }
    .paizo-feed-title {
        font-size: 0.95rem;
    }
}

/* Light-mode tweaks — match the news-post-card light pattern. */
[data-theme="light"] .paizo-feed-item {
    border-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .paizo-feed-item:hover {
    box-shadow: 0 4px 20px rgba(0, 200, 255, 0.12);
}

[data-theme="light"] .paizo-feed-cat--news {
    color: var(--text-muted);
}
