:root {
    --primary: #660033;
    --secondary: #003366;
    --accent: #3399cc;
    --background: #121212;
    --text: #FFFFFF;
    --subtext: #D0D0D0;
    --nav-width-collapsed: 4.5rem;
    --nav-width-expanded: 14rem;
}

/* ── Base ── */
html {
    font-size: clamp(14px, 0.8333vw, 36px);
}

body {
    background-color: var(--background);
    margin: 0;
    padding: 0;
    font-family: 'Ubuntu', sans-serif;
    color: var(--text);
}

a { color: var(--accent); }
a:hover { color: #66ccff; }

/* ═══════════════════════════════════════════════
   Sidebar navigation — full-height drawer
   ═══════════════════════════════════════════════ */

.no-transition,
.no-transition * {
    transition: none !important;
}

.nav-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--nav-width-collapsed);
    background-color: var(--primary);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.3s ease;
    box-shadow: 0.25rem 0 1rem rgba(0, 0, 0, 0.5);
}

.nav-sidebar.expanded {
    width: var(--nav-width-expanded);
}

.nav-toggle {
    background: none;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    font: inherit;
}

.nav-toggle svg {
    transition: transform 0.3s ease;
}

.nav-sidebar.expanded .nav-toggle svg {
    transform: rotate(180deg);
}

.nav-links {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.5rem;
    flex: 1;
}

.nav-bottom {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-item-link {
    color: var(--text);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    opacity: 0.7;
    transition: opacity 0.2s ease, background-color 0.2s ease;
    white-space: nowrap;
    position: relative;
}

.nav-item-link:hover {
    opacity: 1;
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text);
}

.nav-item-link svg {
    flex-shrink: 0;
    width: 1.5rem;
    height: 1.5rem;
}

.nav-label {
    opacity: 0;
    transition: opacity 0.2s ease;
    font-size: 0.95rem;
    pointer-events: none;
}

.nav-sidebar.expanded .nav-label {
    opacity: 1;
    pointer-events: auto;
}

/* Tooltip on collapsed nav icons */
.nav-sidebar:not(.expanded) .nav-item-link::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 0.75rem);
    top: 50%;
    transform: translateY(-50%);
    background-color: #222;
    color: var(--text);
    padding: 0.4rem 0.75rem;
    border-radius: 0.4rem;
    font-size: 0.85rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.5);
}

.nav-sidebar:not(.expanded) .nav-item-link:hover::after {
    opacity: 1;
}

/* ── App shell — offset for fixed sidebar ── */
.app-shell {
    margin-left: var(--nav-width-collapsed);
    padding: 3.125rem;
}

body.nav-expanded .app-shell {
    margin-left: var(--nav-width-expanded);
}

.app-shell.no-nav {
    margin-left: 0;
}

.app-content {
    flex: 1;
    min-width: 0;
}

/* ── Shared panel style ── */
.panel {
    border-radius: 1.5625rem;
    box-shadow: -0.3125rem 0.3125rem 0.9375rem #000000;
    padding: 1.5625rem;
}

/* ═══════════════════════════════════════════════
   Dashboard layout (home page)
   ═══════════════════════════════════════════════ */

.layout-div {
    display: flex;
    min-height: 43rem;
    max-height: calc(100vh - 1.5rem);
    overflow: visible;
}

.column-layout-div {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 11rem);
    overflow: visible;
}

.content-div {
    flex: 2;
    min-width: 0;
    overflow: visible;
}

.side-content-div {
    flex: 1;
    min-width: 0;
    overflow: visible;
}

/* ── Section headers ── */
.section-header {
    font-size: 1.35rem;
    margin-left: 1.5625rem;
    margin-top: 0.5rem;
    margin-bottom: 0.25rem;
    flex-shrink: 0;
}

.article-header {
    font-size: 2.2rem;
    margin: 0;
    flex-shrink: 0;
}

.article-sub-header {
    color: var(--subtext);
    font-size: 1.6rem;
    font-style: italic;
    margin: 0.625rem 0;
    width: 100%;
    flex-shrink: 0;
}

/* ── Link wrappers inside flex columns — must not break flex ── */
.column-layout-div > a {
    display: contents;
}

/* ── Latest session card ── */
.latest-session-div {
    min-height: 12rem;
    margin: 0 0 0 1.5625rem;
    flex: 1;
    background-color: var(--primary);
    background-size: cover;
    background-repeat: no-repeat;
    overflow: hidden;
    cursor: pointer;
    border: 1px solid #2a2a4a;
    border-radius: 0.9375rem;
    transition: transform 0.15s ease, border-color 0.15s ease;
    position: relative;
    z-index: 0;
}

.latest-session-div::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    transition: background 0.3s ease;
    z-index: 1;
    border-radius: inherit;
    pointer-events: none;
}

.latest-session-div > * {
    position: relative;
    z-index: 2;
}

.latest-session-div:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
}

.latest-session-div:hover::after {
    background: rgba(0, 0, 0, 0.35);
}

/* ── Preview text (session recap scroll) ── */
.preview-text-wrapper {
    width: 60%;
    overflow: hidden;
    position: relative;
    -webkit-mask-image: linear-gradient(to bottom, black 20%, transparent 110%);
    mask-image: linear-gradient(to bottom, black 20%, transparent 110%);
}

.preview-text-wrapper:hover .preview-text {
    animation-name: scrollUp;
    animation-iteration-count: 1;
    animation-fill-mode: both;
}

.preview-text {
    will-change: top;
    margin: 0;
    line-height: 1.5em;
    position: relative;
    animation-name: none;
    animation-duration: 15s;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
    transition: top 1.5s;
}

.preview-text h1,
.preview-text h2,
.preview-text h3,
.preview-text h4,
.preview-text h5,
.preview-text h6 {
    font-size: 1rem;
    font-weight: 600;
    color: #999;
    margin: 0.5em 0 0.25em 0;
}

.preview-text p {
    margin: 0.25em 0;
}

/* ── Latest articles cards (animated banners) ── */
.pills-group {
    flex: 1;
    overflow: hidden;
    margin-left: 1.5625rem;
    display: flex;
    flex-direction: column;
}

.pill-wrapper {
    margin-top: 0.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.pill-wrapper > a {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.pill-wrapper .panel.latest-articles-div {
    flex: 1;
}

.pills-group .following-item {
    flex: 1;
    min-height: 3rem;
}

.panel.latest-articles-div {
    padding: 0.85rem 1.5625rem;
    background-color: var(--primary);
    background-size: cover;
    background-repeat: no-repeat;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    overflow: hidden;
    box-shadow: none;
    position: relative;
    z-index: 0;
    border: 1px solid #2a2a4a;
    border-radius: 0.9375rem;
    transition: transform 0.15s ease, border-color 0.15s ease;
    min-height: 3.3rem;
}

.panel.latest-articles-div::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    transition: background 0.3s ease;
    z-index: 1;
    border-radius: inherit;
    pointer-events: none;
}

.panel.latest-articles-div > * {
    position: relative;
    z-index: 2;
}

.panel.latest-articles-div:hover {
    border-color: var(--accent);
}

.panel.latest-articles-div:hover::after {
    background: rgba(0, 0, 0, 0.35);
}

.animated-header {
    font-size: 1.4rem;
    transition: font-size 0.3s ease;
    opacity: 1;
    margin: 0;
}

.panel.latest-articles-div:hover .animated-header {
    font-size: 1.1rem;
}

.animated-text {
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transition: opacity 0.3s ease, max-height 0.3s ease, margin 0.3s ease;
    margin: 0;
}

.panel.latest-articles-div:hover .animated-text {
    opacity: 0.7;
    max-height: 3rem;
    margin-top: 0.25rem;
}

/* ── Character portrait grid ── */
.grid-layout-div {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5625rem;
    padding-left: 1.5625rem;
}

.grid-layout-div > a {
    width: calc((100% - 3.125rem) / 3);
    text-decoration: none;
}

.portrait-div {
    width: 100%;
    position: relative;
    margin: 0;
    padding: 0;
    border: 1px solid #2a2a4a;
    border-radius: 0.9375rem;
    transition: transform 0.15s ease, border-color 0.15s ease;
    z-index: 0;
}

.portrait-div::before {
    content: "";
    display: block;
    padding-bottom: 100%;
}

.portrait-div::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    transition: background 0.3s ease;
    z-index: 1;
    border-radius: inherit;
}

.portrait-div:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
    cursor: pointer;
}

.portrait-div:hover::after {
    background: rgba(0, 0, 0, 0.35);
}

.portrait-img {
    background-size: cover;
    background-position: center;
    overflow: hidden;
}

.portrait-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    padding: 0.375rem 0.5rem;
    font-size: 0.85rem;
    font-weight: bold;
    color: var(--text);
    background: linear-gradient(to top, rgba(0, 0, 0, 0.85), transparent);
    border-radius: 0 0 0.9375rem 0.9375rem;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.portrait-div:hover .portrait-label {
    opacity: 1;
}

.grid-layout-div > .portrait-div {
    width: calc((100% - 3.125rem) / 3);
}

/* ── Upcoming session card ── */
.upcoming-session-div {
    flex: 1;
    min-width: 18.75rem;
    min-height: 13.75rem;
    margin-left: 1.5625rem;
    overflow: hidden;
    flex-direction: column-reverse;
    display: flex;
    background-color: var(--primary);
    background-size: cover;
    background-repeat: no-repeat;
    cursor: pointer;
    border: 1px solid #2a2a4a;
    border-radius: 0.9375rem;
    transition: transform 0.15s ease, border-color 0.15s ease;
    position: relative;
    z-index: 0;
}

.upcoming-session-div::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    transition: background 0.3s ease;
    z-index: 1;
    border-radius: inherit;
    pointer-events: none;
}

.upcoming-session-div > * {
    position: relative;
    z-index: 2;
}

.upcoming-session-div:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
}

.upcoming-session-div:hover::after {
    background: rgba(0, 0, 0, 0.35);
}

/* ── Animations ── */
@keyframes scrollUp {
    0% { transform: translateY(0); }
    100% { transform: translateY(calc(-55%)); }
}

.date-text {
    margin-left: auto;
}

/* ═══════════════════════════════════════════════
   Article detail — hero banner
   ═══════════════════════════════════════════════ */

.article-hero {
    position: relative;
    height: 33.33vh;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    margin: -3.125rem -3.125rem 0 -3.125rem;
}

.article-hero-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to bottom,
        transparent 0%,
        transparent 40%,
        var(--background) 100%
    );
}

.page-container.has-hero {
    position: relative;
    margin-top: -4rem;
    z-index: 1;
}

/* ═══════════════════════════════════════════════
   CRUD / inner pages
   ═══════════════════════════════════════════════ */

.page-container {
    max-width: 56.25rem;
    margin: 0 auto;
    padding: 1.5625rem;
}

.page-container.page-container--wide {
    max-width: 100%;
}

.page-container h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.page-container .form-label {
    color: var(--subtext);
}

.page-container .form-control {
    background-color: #1e1e2e;
    border: 1px solid #333;
    color: var(--text);
    border-radius: 0.5rem;
}

.page-container .form-control:focus {
    background-color: #252540;
    border-color: var(--accent);
    color: var(--text);
    box-shadow: 0 0 0 0.2rem rgba(51, 153, 204, 0.25);
}

.page-container .btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
}

.page-container .btn-primary:hover {
    background-color: #880044;
    border-color: #880044;
}

.page-container .btn-outline-secondary {
    color: var(--subtext);
    border-color: #555;
}

.page-container .btn-outline-secondary:hover {
    background-color: #333;
    color: var(--text);
}

.page-container .btn-outline-primary {
    color: var(--accent);
    border-color: var(--accent);
}

.page-container .btn-outline-primary:hover {
    background-color: var(--accent);
    color: var(--background);
}

.page-container .btn-outline-danger {
    color: #ff6666;
    border-color: #ff6666;
}

.page-container .btn-outline-danger:hover {
    background-color: #ff6666;
    color: var(--background);
}

/* ── Archive grid ── */
.archive-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(max(18rem, calc((100% - 4.5rem) / 4)), 1fr));
    gap: 1.5rem;
}

/* ── Archive list cards ── */
.lore-card {
    background-color: #1e1e2e;
    border: 1px solid #2a2a4a;
    border-radius: 0.9375rem;
    transition: transform 0.15s ease, border-color 0.15s ease;
    position: relative;
    z-index: 0;
}

.lore-card::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    transition: background 0.3s ease;
    z-index: -1;
    border-radius: inherit;
}

.lore-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
}

.lore-card:hover::after {
    background: rgba(0, 0, 0, 0.35);
}

.lore-card .card-title a {
    color: var(--accent);
}

.lore-card .card-title a:hover {
    color: #66ccff;
}

.lore-card .card-footer {
    background-color: rgba(0, 0, 0, 0.15);
    border-top: 1px solid #2a2a4a;
    border-radius: 0 0 0.9375rem 0.9375rem;
}

.lore-card-wrapper {
    position: relative;
    transition: transform 0.15s ease;
}

.lore-card-wrapper:hover {
    transform: translateY(-2px);
}

.lore-card-wrapper:hover .lore-card {
    border-color: var(--accent);
    transform: none;
}

.lore-card-wrapper:hover .lore-card::after {
    background: rgba(0, 0, 0, 0.35);
}

.lore-card-wrapper > .follow-btn-inline {
    position: absolute;
    bottom: 0.45rem;
    right: 0.75rem;
    z-index: 3;
}

.lore-card .badge {
    background-color: var(--primary) !important;
}

.lore-card .badge.tag-badge--filtered {
    background-color: var(--accent) !important;
}

.tag-badge {
    background-color: var(--secondary) !important;
    font-weight: normal;
}

.tag-badge--filtered {
    background-color: var(--accent) !important;
    color: #fff !important;
}

.tag-badge--user {
    background-color: #2a5a3a !important;
    border: 1px solid #3a7a4a;
}

/* ── Tag add/toggle (article topbar) ── */
.tag-add-toggle {
    cursor: pointer;
    background-color: rgba(255, 255, 255, 0.1) !important;
    border: 1px dashed rgba(255, 255, 255, 0.3);
    font-size: 0.75em;
    line-height: 1;
    padding: 0;
    height: calc(1em + 0.7em);
    aspect-ratio: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s ease;
}

.tag-add-toggle:hover {
    background-color: rgba(255, 255, 255, 0.2) !important;
}

.tag-save-btn {
    background-color: rgba(42, 90, 58, 0.3) !important;
    border: 1px dashed #3a7a4a;
    color: #5cb85c !important;
}

.tag-save-btn:hover {
    background-color: rgba(42, 90, 58, 0.5) !important;
}

.tag-badge--user-toggle {
    background-color: transparent !important;
    border: 1px dashed #3a7a4a;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.tag-badge--user-toggle.tag-badge--user-active {
    background-color: #2a5a3a !important;
    border-style: solid;
}

.tag-editing .tag-badge--user {
    cursor: pointer;
}

.tag-editing .tag-badge--user:not(.tag-badge--user-active) {
    background-color: transparent !important;
    border: 1px dashed #3a7a4a;
}

.tag-add-new-form {
    display: flex;
    gap: 0.5rem;
    max-width: 20rem;
    margin-bottom: 0.5rem;
}

.user-tag-input {
    background-color: var(--primary) !important;
    border-color: #444 !important;
    color: var(--text) !important;
}

/* ── Settings tag management ── */
.settings-tags-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.settings-tag-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.settings-tag-rename-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
}

.settings-tag-action-btn {
    padding: 0.5rem 0.75rem;
    border: 1px solid #444;
    border-radius: 0.375rem;
    background-color: transparent;
    color: var(--text);
    font-size: 0.9rem;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease;
    white-space: nowrap;
    height: 2.375rem;
    display: flex;
    align-items: center;
}

.settings-tag-save {
    border-color: var(--accent);
    color: var(--accent);
}

.settings-tag-save:hover {
    background-color: rgba(51, 153, 204, 0.1);
}

.settings-tag-delete {
    border-color: #dc3545;
    color: #dc3545;
    font-size: 1.1rem;
    padding: 0.5rem 0.6rem;
}

.settings-tag-delete:hover {
    background-color: rgba(220, 53, 69, 0.1);
}

.card-tags {
    display: flex;
    gap: 0.35rem;
    overflow: hidden;
    white-space: nowrap;
    -webkit-mask-image: linear-gradient(to right, #000 80%, transparent 100%);
    mask-image: linear-gradient(to right, #000 80%, transparent 100%);
    margin-bottom: 0.5rem;
}

.card-tags .tag-badge {
    flex-shrink: 0;
}

/* ── Wiki links ── */
.wiki-link {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px dotted var(--accent);
}

.wiki-link:hover {
    color: #66ccff;
    border-bottom-color: #66ccff;
}

/* ── Article references section ── */
.article-references {
    background-color: #1a1a2e;
    border: 1px solid #2a2a4a;
    border-radius: 0.75rem;
    padding: 1rem 1.5rem;
    margin-top: 2rem;
}

.article-references h2:first-child {
    margin-top: 0;
}

.article-references h2 {
    font-size: 1.1rem;
    color: var(--subtext);
    margin: 1.5rem 0 0.75rem 0;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid #333;
}

.article-references ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.article-references li {
    padding: 0.35rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.article-references li a {
    color: var(--accent);
    text-decoration: none;
}

.article-references li a:hover {
    color: #66ccff;
}

.article-references .ref-date {
    color: #666;
    font-size: 0.85rem;
}

/* ── Accent button (for tag toggles) ── */
.btn-accent {
    background-color: var(--accent);
    border-color: var(--accent);
    color: var(--background);
}

.btn-accent:hover {
    background-color: #2288bb;
    border-color: #2288bb;
    color: var(--background);
}

.btn-outline-accent {
    color: var(--accent);
    border-color: var(--accent);
    background: transparent;
}

.btn-outline-accent:hover {
    background-color: var(--accent);
    color: var(--background);
}

.btn-user-tag {
    background-color: #2a5a3a;
    border-color: #3a7a4a;
    color: #fff;
}

.btn-user-tag:hover {
    background-color: #1e4a2e;
    border-color: #3a7a4a;
    color: #fff;
}

.btn-outline-user-tag {
    color: #5cb85c;
    border-color: #3a7a4a;
    background: transparent;
}

.btn-outline-user-tag:hover {
    background-color: #2a5a3a;
    color: #fff;
}

.archive-tag-divider {
    width: 1px;
    height: 1.5rem;
    background-color: #444;
    align-self: center;
    margin: 0 0.25rem;
}

.tag-badge--user-filtered {
    background-color: #3a7a4a !important;
    color: #fff !important;
}

.lore-card .badge.tag-badge--user-filtered {
    background-color: #3a7a4a !important;
}

/* ── Article detail page ── */
.lore-content {
    line-height: 1.8;
    font-size: 1.05rem;
}

.lore-content h1,
.lore-content h2,
.lore-content h3,
.lore-content h4,
.lore-content h5,
.lore-content h6 {
    color: #999;
}

.lore-content h2 {
    padding-bottom: 0.4rem;
    border-bottom: 1px solid #333;
    margin-bottom: 0.75rem;
}

.character-portrait {
    float: left;
    width: 16rem;
    height: 16rem;
    object-fit: cover;
    border-radius: 1rem;
    margin: 0 1.5rem 1rem 0;
    box-shadow: 0 0.25rem 1rem rgba(0, 0, 0, 0.5);
}

/* ── Article topbar (tags + buttons) ── */
.article-topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.article-topbar-tags {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
    min-width: 0;
}

.article-topbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.article-topbar-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* ── Follow / Bookmark button ── */
.follow-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    color: var(--subtext);
    opacity: 0.5;
    transition: opacity 0.2s ease, color 0.2s ease, transform 0.2s ease;
    position: relative;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.follow-btn:hover {
    opacity: 1;
}

.follow-btn--active {
    color: #f0c040;
    opacity: 1;
}

.follow-btn--active:hover {
    opacity: 0.8;
}

.follow-btn--burst {
    animation: follow-burst 0.4s ease-out;
}

@keyframes follow-burst {
    0% { transform: scale(1) rotate(0deg); }
    30% { transform: scale(1.4) rotate(30deg); }
    50% { transform: scale(0.9) rotate(15deg); }
    70% { transform: scale(1.1) rotate(5deg); }
    100% { transform: scale(1) rotate(0deg); }
}

.follow-btn--burst::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: #f0c040;
    opacity: 0;
    animation: follow-ring 0.4s ease-out;
    pointer-events: none;
}

@keyframes follow-ring {
    0% { opacity: 0.5; transform: scale(0.5); }
    100% { opacity: 0; transform: scale(1.08); }
}

/* ── Inline TOC (visible on small screens) ── */
.article-toc-inline {
    display: none;
    background-color: #1e1e2e;
    border: 1px solid #2a2a4a;
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}

@media (max-width: 60rem) {
    .article-toc-inline {
        display: block;
    }
    .article-toc {
        display: none;
    }
}

/* ── Article layout with TOC sidebar ── */
.article-layout {
    display: flex;
    gap: 2rem;
    max-width: 75rem;
    margin: 0 auto;
    padding: 1.5625rem;
}

.article-layout .page-container {
    flex: 1;
    min-width: 0;
    margin: 0;
    padding: 0;
}

.article-layout.has-hero {
    position: relative;
    margin-top: -4rem;
    z-index: 1;
}

/* ── Article table of contents ── */
.article-toc {
    position: sticky;
    top: 1.5rem;
    align-self: flex-start;
    max-height: calc(100vh - 3rem);
    overflow-y: auto;
    background-color: #1e1e2e;
    border: 1px solid #2a2a4a;
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
    flex-shrink: 0;
    width: fit-content;
    white-space: nowrap;
}

.article-toc-title {
    font-size: 1.1rem;
    margin: 0 0 0.75rem 0;
    color: var(--subtext);
}

.article-toc-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.article-toc-item {
    margin: 0.25rem 0;
}

.article-toc-parent {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.article-toc-toggle {
    font-size: 0.65rem;
    color: var(--subtext);
    transition: transform 0.2s ease;
    display: inline-block;
    flex-shrink: 0;
}

.article-toc-parent.collapsed .article-toc-toggle {
    transform: rotate(0deg);
}

.article-toc-parent:not(.collapsed) .article-toc-toggle {
    transform: rotate(90deg);
}

.article-toc-child {
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    padding-left: 4rem;
}

.article-toc-link {
    color: var(--accent);
    text-decoration: none;
    font-size: 0.95rem;
    transition: color 0.15s ease;
}

.article-toc-link:hover {
    color: #66ccff;
}

/* ── Delete confirmation ── */
.page-container .card {
    background-color: #1e1e2e;
    border-radius: 0.9375rem;
}

.page-container .card-footer {
    background-color: rgba(0, 0, 0, 0.15);
    border-radius: 0 0 0.9375rem 0.9375rem;
}

/* ═══════════════════════════════════════════════
   Search page
   ═══════════════════════════════════════════════ */

.search-page {
    max-width: 60rem;
}

.search-bar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.search-input {
    flex: 1;
}

.search-btn {
    flex-shrink: 0;
}

.search-options {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.search-option-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.search-option-group .form-label {
    margin: 0;
    color: var(--subtext);
    white-space: nowrap;
    font-size: 0.9rem;
}

.search-select {
    background-color: #1e1e2e;
    border: 1px solid #333;
    color: var(--text);
    border-radius: 0.5rem;
    padding: 0.35rem 0.75rem;
    font-size: 0.9rem;
}

.search-select:focus {
    background-color: #252540;
    border-color: var(--accent);
    color: var(--text);
    box-shadow: 0 0 0 0.2rem rgba(51, 153, 204, 0.25);
}

.search-results .pill-wrapper {
    margin-top: 0.75rem;
}

.search-results .pill-wrapper > .following-item {
    min-height: 3rem;
}

.search-preview {
    -webkit-mask-image: linear-gradient(to bottom, black 30%, transparent 100%);
    mask-image: linear-gradient(to bottom, black 30%, transparent 100%);
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--subtext);
}

/* ── Infinite scroll ── */
.scroll-sentinel {
    height: 1px;
}

.scroll-loading {
    display: flex;
    justify-content: center;
    padding: 2rem 0;
}

.spinner {
    width: 2rem;
    height: 2rem;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════════
   Login / Account pages
   ═══════════════════════════════════════════════ */

.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

.login-card {
    width: 100%;
    max-width: 24rem;
    background-color: var(--primary);
    padding: 2rem;
}

.login-card h1 {
    margin: 0 0 1.5rem 0;
    font-size: 1.5rem;
    color: var(--text);
}

.login-field {
    margin-bottom: 1rem;
}

.login-field label {
    display: block;
    margin-bottom: 0.25rem;
    color: var(--subtext);
    font-size: 0.85rem;
}

.login-field input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #444;
    border-radius: 0.375rem;
    background-color: var(--background);
    color: var(--text);
    font-size: 0.9rem;
}

.login-field input:focus {
    outline: none;
    border-color: var(--accent);
}

.login-btn {
    width: 100%;
    padding: 0.6rem;
    margin-top: 0.5rem;
    border: none;
    border-radius: 0.375rem;
    background-color: var(--accent);
    color: #fff;
    font-size: 0.95rem;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.login-btn:hover {
    opacity: 0.85;
}

.login-error {
    background-color: rgba(220, 53, 69, 0.15);
    color: #ff6b7a;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
}

.login-success {
    background-color: rgba(40, 167, 69, 0.15);
    color: #5fda83;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
}

.login-back-link {
    display: block;
    text-align: center;
    margin-top: 1rem;
    color: var(--subtext);
    font-size: 0.85rem;
}

/* ── Nav logout button ── */

.nav-logout-btn {
    background: none;
    border: none;
    font: inherit;
    cursor: pointer;
}

/* ── Default password toast ── */

.default-password-toast {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    background-color: #cc6600;
    color: #fff;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    z-index: 2000;
    box-shadow: 0 0.25rem 1rem rgba(0, 0, 0, 0.5);
    font-size: 0.9rem;
}

.default-password-toast a {
    color: #fff;
    font-weight: bold;
    text-decoration: underline;
}

/* ── Nav avatar (circular profile image) ── */

.nav-avatar {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    transform: scale(1.8);
}

.nav-avatar-fallback {
    flex-shrink: 0;
    width: 1.5rem;
    height: 1.5rem;
    transform: scale(1.8);
}

/* ═══════════════════════════════════════════════
   Settings page
   ═══════════════════════════════════════════════ */

.settings-container {
    max-width: 40rem;
    margin: 0 auto;
}

.settings-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.settings-section {
    background-color: var(--primary);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.settings-section h2 {
    font-size: 1.2rem;
    margin: 0 0 0.75rem 0;
    color: var(--text);
}

.settings-profile-row {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.settings-avatar-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.settings-avatar {
    width: 6rem;
    height: 6rem;
    border-radius: 50%;
    object-fit: cover;
}

.settings-avatar-placeholder {
    width: 6rem;
    height: 6rem;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--subtext);
}

.settings-upload-label {
    font-size: 0.8rem;
    color: var(--accent);
    cursor: pointer;
    text-decoration: underline;
}

.settings-upload-input {
    display: none;
}

.settings-fields {
    flex: 1;
}

.settings-readonly {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: none;
    border-radius: 0.375rem;
    background-color: transparent;
    color: var(--subtext);
    font-size: 0.9rem;
    cursor: default;
    opacity: 0.6;
}

/* ═══════════════════════════════════════════════
   Admin Console
   ═══════════════════════════════════════════════ */

.admin-add-btn {
    background-color: var(--accent);
    color: #fff;
    border: none;
    padding: 0.5rem 1.25rem;
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 0.9rem;
    transition: opacity 0.2s ease;
}

.admin-add-btn:hover {
    opacity: 0.85;
}

.admin-alert {
    background-color: rgba(40, 167, 69, 0.15);
    color: #5fda83;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.admin-code {
    font-family: monospace;
    background-color: rgba(255, 255, 255, 0.1);
    padding: 0.15rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.95rem;
    letter-spacing: 0.05em;
    user-select: all;
}

.admin-table-wrapper {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.admin-table th {
    text-align: left;
    padding: 0.75rem 1rem;
    border-bottom: 2px solid #333;
    color: var(--subtext);
    font-weight: 600;
    white-space: nowrap;
}

.admin-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #222;
    vertical-align: middle;
}

.admin-table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.03);
}

.status-badge {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    border-radius: 1rem;
    font-size: 0.8rem;
    font-weight: 600;
}

.status-active {
    background-color: rgba(40, 167, 69, 0.2);
    color: #5fda83;
}

.status-inactive {
    background-color: rgba(220, 53, 69, 0.2);
    color: #ff6b7a;
}

.status-pending {
    background-color: rgba(255, 193, 7, 0.2);
    color: #ffc107;
}

.admin-actions-cell {
    position: relative;
    width: 2rem;
    text-align: center;
}

.admin-actions-btn {
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    opacity: 0.6;
    transition: opacity 0.2s ease;
    line-height: 1;
}

.admin-actions-btn:hover {
    opacity: 1;
    background-color: rgba(255, 255, 255, 0.1);
}

.admin-dropdown {
    display: none;
    position: fixed;
    background-color: #1a1a2e;
    border: 1px solid #333;
    border-radius: 0.5rem;
    min-width: 14rem;
    z-index: 9999;
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.admin-dropdown.open {
    display: block;
}

.admin-dropdown form {
    display: block;
}

.admin-dropdown button {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    color: var(--text);
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.admin-dropdown button:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

/* ── Admin site settings bar ── */
.admin-site-settings {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    background: #1e1e2e;
    border: 1px solid #2a2a4a;
    border-radius: 0.75rem;
    padding: 0.75rem 1.25rem;
    margin-bottom: 1rem;
}

.admin-site-settings .admin-section-title {
    margin: 0;
    white-space: nowrap;
}

.admin-site-settings-form {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.admin-site-settings-form label {
    font-size: 0.85rem;
    opacity: 0.7;
    white-space: nowrap;
}

.admin-text-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 0.4rem;
    color: inherit;
    font-size: 0.9rem;
    padding: 0.3rem 0.6rem;
}

.admin-text-input:focus {
    outline: none;
    border-color: var(--accent);
}

/* ── Home page campaign title ── */
.campaign-title {
    font-size: 2rem;
    font-weight: 700;
    padding: 1.5625rem 0 0.75rem 1.5625rem;
    margin: 0;
    opacity: 0.92;
}

/* ── Admin page columns layout ── */
.admin-columns {
    display: flex;
    gap: 1.5rem;
    min-height: 0;
}

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

.admin-section-title {
    font-size: 1.25rem;
    margin: 0 0 1rem 0;
}

/* ── Database query section ── */
.query-tables {
    font-size: 0.8rem;
    color: var(--subtext);
    margin-bottom: 0.5rem;
}

.query-tables-label {
    opacity: 0.6;
}

.query-tables-list {
    font-family: monospace;
}

.query-table-name {
    cursor: pointer;
    color: var(--accent);
    opacity: 0.8;
    transition: opacity 0.15s;
}

.query-table-name:hover {
    opacity: 1;
    text-decoration: underline;
}

.query-input-group {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
    margin-bottom: 0.75rem;
}

.query-textarea {
    flex: 1;
    background-color: #1e1e2e;
    border: 1px solid #333;
    color: var(--text);
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-family: monospace;
    font-size: 0.85rem;
    resize: vertical;
    field-sizing: content;
    min-height: 0;
}

.query-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 0.15rem rgba(51, 153, 204, 0.25);
}

.query-textarea::placeholder {
    color: #555;
}

.query-error {
    background-color: rgba(255, 80, 80, 0.12);
    color: #ff6b7a;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
    font-family: monospace;
}

.query-result-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.query-result-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--subtext);
    margin-bottom: 0.5rem;
}

.query-pager {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.query-page-btn {
    background: none;
    border: 1px solid #444;
    color: var(--text);
    padding: 0.2rem 0.6rem;
    border-radius: 0.25rem;
    cursor: pointer;
    font-size: 0.8rem;
}

.query-page-btn:hover:not(:disabled) {
    background-color: rgba(255, 255, 255, 0.08);
}

.query-page-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

.query-table-scroll {
    flex: 1;
    overflow: auto;
    min-height: 0;
}

.query-table-scroll .admin-table td {
    max-width: 20rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    height: 2.5rem;
    padding-top: 0;
    padding-bottom: 0;
    line-height: 2.5rem;
}

.query-table-scroll .admin-table th {
    white-space: nowrap;
}

.query-null {
    opacity: 0.35;
    font-style: italic;
}

@media (max-width: 64rem) {
    .admin-columns {
        flex-direction: column;
    }
}

/* ── Home page element size reductions ── */
.layout-div .article-header { font-size: 1.75rem; }
.layout-div .article-sub-header { font-size: 1.15rem; }
.layout-div .panel { padding: 1rem; }
.layout-div .grid-layout-div { gap: 1rem; }
.latest-session-div { min-height: 9rem !important; }
.upcoming-session-div { min-height: 9rem !important; }
.panel.latest-articles-div { min-height: 2.5rem; padding: 0.6rem 1rem; }

/* ── Home page section wrappers ── */
.home-section {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.home-section > a {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.home-latest-session {
    flex: 0 1 44%;
}

.home-recently-created,
.home-recently-updated {
    flex: 1 1 0;
    overflow: hidden;
}

.home-characters {
    flex: 0 0 auto;
}

.home-upcoming {
    flex: 1 1 0;
}

/* ── Home page responsive — tablet / 4:3 ── */
@media (max-width: 64rem) {
    .app-shell { padding: 2rem; }
    .section-header { font-size: 1.5rem; margin-left: 1rem; }
    .article-header { font-size: 1.8rem; }
    .article-sub-header { font-size: 1.3rem; }
    .grid-layout-div { gap: 1rem; padding-left: 1rem; }
    .latest-session-div { margin-left: 1rem; }
    .pills-group { margin-left: 1rem; }
    .upcoming-session-div { margin-left: 1rem; min-width: 12rem; }
    .panel { padding: 1.25rem; }
}

/* ── Home page responsive — phone / portrait ── */
@media (max-width: 48rem) {
    .app-shell { padding: 1rem; }

    .layout-div {
        flex-direction: column;
        max-height: none;
        min-height: auto;
    }

    .column-layout-div {
        height: auto;
    }

    .layout-div > .content-div,
    .layout-div > .side-content-div {
        display: contents;
    }

    .home-section { width: 100%; flex: none; }

    .home-upcoming       { order: 1; }
    .home-latest-session { order: 2; }
    .home-characters     { order: 3; }
    .home-recently-created { order: 4; }
    .home-recently-updated { order: 5; }

    .section-header { font-size: 1.3rem; margin-left: 0.75rem; margin-top: 0.5rem; }
    .article-header { font-size: 1.6rem; }
    .article-sub-header { font-size: 1.1rem; }

    .latest-session-div {
        max-height: none;
        min-height: 12rem;
        margin-left: 0;
    }

    .upcoming-session-div {
        height: auto;
        min-height: 12rem;
        margin-left: 0;
        min-width: auto;
    }

    .pills-group {
        margin-left: 0;
        mask-image: none;
        -webkit-mask-image: none;
        overflow: visible;
    }

    .grid-layout-div {
        padding-left: 0;
        gap: 0.75rem;
    }

    .panel { padding: 1rem; border-radius: 1rem; }
    .preview-text-wrapper { width: 100%; }

    .home-recently-created,
    .home-recently-updated { overflow: visible; }
}

/* ═══════════════════════════════════════════════
   Followed Articles page
   ═══════════════════════════════════════════════ */

.following-page {
    height: calc(100vh - 6.25rem);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 1.5625rem 1.5625rem 0;
}

.following-page-title {
    font-size: 2rem;
    margin: 0;
    flex-shrink: 0;
}

.following-layout {
    display: flex;
    gap: 1rem;
    flex: 1;
    min-height: 0;
    padding: 0 0 1.5625rem 0;
}

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

.following-main-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    padding: 0 0 0.5rem 0;
    flex-shrink: 0;
}

.following-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
    margin-bottom: 0.75rem;
    flex-shrink: 0;
}

.following-entry {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.following-expand-btn {
    background: none;
    border: none;
    color: inherit;
    opacity: 0.5;
    padding: 0 0.75rem;
    cursor: pointer;
    align-self: center;
    transition: opacity 0.2s, transform 0.2s;
    position: relative;
    z-index: 2;
}

.following-expand-btn:hover {
    opacity: 0.9;
}

.following-entry.expanded .following-expand-btn {
    transform: rotate(180deg);
}

.following-detail {
    background: #1a0a12;
    border: 1px solid #2a2a4a;
    border-top: none;
    border-radius: 0 0 0.9375rem 0.9375rem;
    padding: 0.75rem 1rem;
    margin-top: -0.5rem;
    padding-top: 1rem;
    max-height: 21rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.following-detail-cols {
    display: flex;
    gap: 1rem;
    flex: 1;
    min-height: 0;
}

.following-detail-section {
    flex: 1;
    min-width: 0;
    border: 1px solid #2a2a4a;
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.following-detail-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 0.5rem 0;
}

.following-detail-section h3 {
    font-size: 1.1rem;
    opacity: 0.85;
    margin: 0;
}

.following-help {
    color: var(--subtext);
    opacity: 0.4;
    cursor: help;
    display: flex;
    align-items: center;
    transition: opacity 0.2s;
}

.following-help:hover {
    opacity: 0.8;
}

.following-detail-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding-top: 0.2rem;
}

.following-entry.expanded > .following-item {
    border-radius: 0.9375rem 0.9375rem 0 0;
}

.following-item--detail {
    min-height: 2.75rem;
}

.following-item--detail .following-item-title {
    font-size: 0.85rem;
}

.following-item--detail .following-item-summary {
    font-size: 0.75rem;
}

.following-item--detail .following-item-date {
    font-size: 0.65rem;
}

.following-item--detail .following-item-content {
    padding: 0.35rem 0.75rem 0.35rem 0.25rem;
}

.following-item--detail > .follow-btn-inline {
    margin-left: 0.5rem;
}

.following-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.2rem 0.5rem 0 0;
}

.following-list--main {
    flex: 1;
}

.following-item {
    display: flex;
    align-items: stretch;
    border: 1px solid #2a2a4a;
    border-radius: 0.9375rem;
    text-decoration: none;
    color: inherit;
    background-size: cover;
    background-repeat: no-repeat;
    background-color: var(--primary);
    position: relative;
    z-index: 0;
    min-height: 3.5rem;
    flex-shrink: 0;
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease;
}

.following-item::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    transition: background 0.3s ease;
    z-index: 1;
    border-radius: inherit;
    pointer-events: none;
}

.following-item > * {
    position: relative;
    z-index: 2;
}

.following-item:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
}

.following-item:hover::after {
    background: rgba(0, 0, 0, 0.35);
}

.following-item-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.following-item-link {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0.5rem 0.75rem;
    text-decoration: none;
    color: inherit;
    min-width: 0;
    flex: 1;
}

.following-item-link:hover {
    text-decoration: none;
    color: inherit;
}

.following-item > .follow-btn-inline {
    align-self: flex-start;
    margin-left: 0.5rem;
    margin-top: 0.5rem;
    flex-shrink: 0;
}

.following-item-title {
    font-size: 1rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.following-item-summary {
    font-size: 0.8rem;
    opacity: 0.6;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 0.1rem;
}

.following-item-date {
    font-size: 0.7rem;
    opacity: 0.5;
    white-space: nowrap;
    padding: 0.15rem 0.75rem 0.4rem;
}

.following-item-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-top: 0.15rem;
}

.following-item-tags .badge {
    font-size: 0.65rem;
    padding: 0.15em 0.4em;
}

.following-item-title-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
}

.following-item-title-row .following-item-title {
    flex-shrink: 1;
}

.following-item-title-row .following-item-tags {
    flex-shrink: 0;
    margin-top: 0;
}

.follow-btn-inline {
    padding: 0;
    flex-shrink: 0;
}

/* Darker stroke for outline bookmark so it reads on lighter backgrounds */
.follow-btn-inline:not(.follow-btn--active) {
    color: rgba(255, 255, 255, 0.85);
    opacity: 0.7;
    filter: drop-shadow(0 0 1px rgba(0, 0, 0, 0.6));
}

.following-empty {
    opacity: 0.4;
    font-size: 0.9rem;
    text-align: center;
    padding: 1.5rem 0;
    margin: 0;
}

@media (max-width: 48rem) {
    .following-page {
        height: auto;
        overflow: visible;
    }

    .following-main-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .following-detail-cols {
        flex-direction: column;
    }
}

/* ===== Navbar Active State ===== */
.nav-item-link--active {
    background-color: rgba(255, 255, 255, 0.12);
}

.nav-item-link--active svg {
    color: var(--accent);
    opacity: 1;
}

/* ===== Navbar Notification Badge ===== */
.notif-nav-badge {
    position: absolute;
    top: -0.3rem;
    right: -0.3rem;
    background: #e03030;
    color: #fff;
    border-radius: 9999px;
    font-size: 0.55rem;
    font-weight: 700;
    min-width: 1rem;
    height: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.18rem;
    line-height: 1;
    pointer-events: none;
    z-index: 2;
}

/* ===== Notification Center Page ===== */
.notif-layout {
    display: flex;
    gap: 1.25rem;
    align-items: flex-start;
}

.notif-main {
    flex: 2;
    min-width: 0;
}

.notif-sidebar {
    flex: 0 0 20rem;
    min-width: 0;
    position: sticky;
    top: 1.5rem;
    align-self: flex-start;
    max-height: calc(100vh - 3rem);
    overflow-y: auto;
}

.notif-feed-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.6rem;
}

.notif-count {
    font-size: 0.85rem;
    opacity: 0.6;
}

.notif-feed {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Lore-card–style notification rows */
.notif-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    border: 1px solid var(--primary);
    border-radius: 0.9375rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    position: relative;
    z-index: 0;
    background-color: #1e1e2e;
    transition: transform 0.15s ease, border-color 0.15s ease;
    overflow: hidden;
}

.notif-item--followed .notif-item-icon {
    color: #f0c040;
}

.notif-item::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    transition: background 0.3s ease;
    z-index: -1;
    border-radius: inherit;
    pointer-events: none;
}

.notif-item:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
}

.notif-item:hover::after {
    background: rgba(0, 0, 0, 0.32);
}

.notif-item-icon {
    flex-shrink: 0;
    width: 2.25rem;
    height: 2.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.92;
}

.notif-item-icon svg {
    width: 1.5rem;
    height: 1.5rem;
}

.notif-item-body {
    flex: 1;
    min-width: 0;
}

.notif-item-titles {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.3rem;
    min-width: 0;
    margin-bottom: 0.15rem;
}

.notif-item-title {
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 18rem;
    color: inherit;
}

a.notif-item-title:hover,
a.notif-item-linked-title:hover {
    color: var(--accent);
    text-decoration: none;
}

.notif-linked-sep {
    font-size: 0.75rem;
    opacity: 0.5;
    flex-shrink: 0;
}

.notif-item-linked-title {
    font-size: 0.82rem;
    font-weight: 500;
    opacity: 0.8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 14rem;
    color: inherit;
}

.notif-item-message {
    font-size: 0.78rem;
    opacity: 0.62;
    margin: 0;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.notif-item-meta {
    position: absolute;
    top: 0.5rem;
    right: 0.75rem;
    bottom: 0.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-end;
}

.notif-item-body {
    padding-right: 4rem;
}

.notif-item-date {
    font-size: 0.7rem;
    opacity: 0.45;
    white-space: nowrap;
}

.notif-dismiss-btn {
    background: none;
    border: none;
    padding: 0.2rem;
    cursor: pointer;
    color: inherit;
    opacity: 0.35;
    border-radius: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.15s ease;
    z-index: 1;
}

.notif-dismiss-btn:hover {
    opacity: 0.85;
}

/* ===== Notification color variants — dark, site-tone matched (~15-22% HSL lightness) ===== */
.notif--session   { --nc: #0d3d5a; }   /* deep navy-blue      */
.notif--character { --nc: #4a1535; }   /* deep plum           */
.notif--npc       { --nc: #4a2d00; }   /* deep amber-brown    */
.notif--location  { --nc: #003d2e; }   /* deep forest-teal    */
.notif--lore      { --nc: #0a2e50; }   /* deep ink-blue       */
.notif--history   { --nc: #3d3500; }   /* deep antique-gold   */
.notif--factions  { --nc: #4a1e00; }   /* deep burnt-orange   */
.notif--combat    { --nc: #4a0d0d; }   /* deep crimson        */
.notif--upcoming  { --nc: #0a3d35; }   /* deep dark-teal      */
.notif--default   { --nc: #252a38; }   /* deep slate          */

.notif-item .notif-item-icon { color: #fff; }

/* ===== Notification Sidebar Panels ===== */
.notif-panel {
    border: 1px solid #2a2a4a;
    border-radius: 0.9375rem;
    padding: 0.85rem 1rem;
    margin-bottom: 1rem;
}

.notif-panel-title {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    opacity: 0.6;
    margin-bottom: 0.85rem;
}

.notif-setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.6rem;
    transition: opacity 0.2s ease;
}

.notif-setting-row--disabled {
    opacity: 0.35;
    pointer-events: none;
}

.notif-setting-row--indented {
    padding-left: 0.75rem;
}

.notif-setting-group-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.45;
    margin: 0 0 0.4rem;
}

.notif-setting-label {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.notif-setting-label span {
    font-size: 0.88rem;
}

.notif-setting-label small {
    font-size: 0.72rem;
    opacity: 0.5;
}

.notif-setting-divider {
    border-top: 1px solid #2a2a4a;
    margin: 0.5rem 0 0.65rem;
}

.notif-poll-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding-top: 0.65rem;
    border-top: 1px solid #2a2a4a;
    margin-top: 0.25rem;
}

.notif-poll-label {
    font-size: 0.74rem;
    opacity: 0.48;
}

.notif-empty {
    font-size: 0.82rem;
    opacity: 0.42;
    margin: 0;
    padding: 0.2rem 0;
}

/* ===== Toggle Switch ===== */
.toggle-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    flex-shrink: 0;
    user-select: none;
}

.toggle-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.toggle-track {
    width: 2.75rem;
    height: 1.5rem;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 1rem;
    position: relative;
    transition: background 0.2s ease, border-color 0.2s ease;
}

/* ~ instead of + because hidden input sits between checkbox and track in DOM */
.toggle-input:checked ~ .toggle-track {
    background: rgba(51, 153, 204, 0.55);
    border-color: var(--accent);
}

.toggle-thumb {
    position: absolute;
    top: 50%;
    left: 0.125rem;
    width: 1.25rem;
    height: 1.25rem;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.92);
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
    transition: transform 0.2s ease, background 0.2s ease;
    z-index: 1;
}

.toggle-input:checked ~ .toggle-track .toggle-thumb {
    transform: translateY(-50%) translateX(1.375rem);
}

/* ===== Recently Dismissed ===== */
.notif-dismissed-list {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    max-height: 16rem;
    overflow-y: auto;
}

.notif-dismissed-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.25rem;
    border-radius: 0.4rem;
    opacity: 0.5;
    transition: opacity 0.15s ease;
}

.notif-dismissed-item:hover {
    opacity: 0.85;
}

.notif-dismissed-icon {
    flex-shrink: 0;
    width: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--nc, #8D99AE);
}

.notif-dismissed-icon svg {
    width: 0.9rem;
    height: 0.9rem;
}

.notif-dismissed-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.05rem;
}

.notif-dismissed-title {
    font-size: 0.78rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.notif-dismissed-date {
    font-size: 0.65rem;
    opacity: 0.5;
}

.notif-restore-btn {
    background: none;
    border: none;
    padding: 0.15rem;
    cursor: pointer;
    color: inherit;
    opacity: 0.38;
    border-radius: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.15s ease;
}

.notif-restore-btn:hover {
    opacity: 0.9;
}

@media (max-width: 56rem) {
    .notif-layout {
        flex-direction: column;
    }

    .notif-sidebar {
        flex: unset;
        width: 100%;
    }
}

/* ── Map page ── */
#map-container {
    position: fixed;
    top: 0;
    left: var(--nav-width-collapsed);
    right: 0;
    bottom: 0;
    overflow: hidden;
    z-index: 1;
}

body.nav-expanded #map-container {
    left: var(--nav-width-expanded);
}

#map {
    width: 100%;
    height: 100%;
    background: var(--background);
}

.leaflet-container { background: var(--background) !important; }

#map-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--subtext);
    font-style: italic;
}

/* ── Map pins ── */
.map-pin-bubble {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    box-shadow: 0 2px 6px rgba(0,0,0,0.5);
}
.map-pin-bubble > svg {
    transform: rotate(45deg);
    flex-shrink: 0;
}

/* ── Leaflet control row (zoom + Add Pin side by side) ── */
.leaflet-top.leaflet-left {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 0.5rem;
}
.leaflet-top.leaflet-left .leaflet-control-zoom {
    display: flex;
    flex-direction: column;
    margin: 0;
}

/* ── Add Pin button (Leaflet control) ── */
.map-tool-btn {
    background: var(--primary);
    color: white;
    border: 1px solid var(--accent);
    border-radius: 0.5rem;
    padding: 0.4rem 0.9rem;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.15s;
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
    margin: 0;
    height: fit-content;
    white-space: nowrap;
}
.map-tool-btn:hover { background: #2a2a4a; }
.map-tool-btn.active { background: var(--accent); }

/* ── Leaflet popup — transparent shell, .map-popup owns all styling ── */
.leaflet-popup-content-wrapper {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    border-radius: 0 !important;
}
.leaflet-popup-content {
    margin: 0 !important;
    padding: 0 !important;
}
.leaflet-popup-tip-container { display: none !important; }
.leaflet-popup-close-button  { display: none !important; }

/* ── Map popup pill ── */
.map-popup {
    background-color: var(--primary);
    background-size: cover;
    background-position: right center;
    background-repeat: no-repeat;
    border: 1px solid #2a2a4a;
    border-radius: 0.9375rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.6);
    min-width: 14rem;
    max-width: 20rem;
    position: relative;
    overflow: hidden;
}
.map-popup-inner {
    padding: 0.65rem 0.9rem;
}
.map-popup-header {
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
    margin-bottom: 0.2rem;
}
.map-popup-title { font-size: 0.95rem; font-weight: 600; color: white; }
.map-popup-desc  { font-size: 0.8rem; color: rgba(255,255,255,0.7); margin: 0 0 0.4rem; }
.map-popup-edit-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.65rem;
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    background: rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.7);
    border-radius: 0.3rem;
    cursor: pointer;
}
.map-popup-edit-btn:hover { background: rgba(0,0,0,0.6); color: white; }

/* ── Map pin panel ── */
.map-pin-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 22rem;
    z-index: 1000;
    background: #12121e;
    border-left: 1px solid var(--primary);
    display: flex;
    flex-direction: column;
    padding: 1.25rem;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    overflow-y: auto;
}
.map-pin-panel.open { transform: translateX(0); }
.map-pin-panel h3 { font-size: 1rem; margin-bottom: 0.75rem; color: white; }
.map-pin-panel label { font-size: 0.8rem; opacity: 0.7; margin-bottom: 0.2rem; display: block; }
.map-pin-panel input,
.map-pin-panel textarea,
.map-pin-panel select {
    width: 100%;
    background: var(--primary);
    border: 1px solid #2a2a4a;
    color: white;
    border-radius: 0.4rem;
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}
.map-pin-panel textarea { resize: vertical; min-height: 3.5rem; }
.map-pin-panel select option { background: #1e1e2e; }

/* ── Article combobox ── */
.article-combobox {
    position: relative;
    margin-bottom: 0.75rem;
}
.article-combobox input {
    margin-bottom: 0;
}
.article-combobox-list {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #1e1e2e;
    border: 1px solid #2a2a4a;
    border-top: none;
    border-radius: 0 0 0.4rem 0.4rem;
    max-height: 11rem;
    overflow-y: auto;
    list-style: none;
    margin: 0;
    padding: 0;
    z-index: 10;
}
.article-combobox-list li {
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
    cursor: pointer;
    color: white;
}
.article-combobox-list li:hover,
.article-combobox-list li.selected {
    background: rgba(255, 255, 255, 0.08);
}

/* ── Icon picker ── */
.icon-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
}
.icon-picker-btn {
    background: var(--primary);
    border: 1.5px solid #2a2a4a;
    border-radius: 0.4rem;
    padding: 0.4rem 0.5rem;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    transition: border-color 0.15s;
    color: white;
}
.icon-picker-btn span { font-size: 0.6rem; opacity: 0.6; }
.icon-picker-btn.selected { border-color: var(--accent); background: #1e1e2e; }

/* ── Color pickers ── */
.color-pickers {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}
.color-picker-row {
    display: flex;
    flex-direction: column;
    flex: 1;
}
.color-picker-row label {
    font-size: 0.8rem;
    opacity: 0.7;
    margin-bottom: 0.2rem;
}
.map-pin-panel input[type="color"] {
    width: 100%;
    height: 2rem;
    padding: 0.1rem 0.2rem;
    background: var(--primary);
    border: 1px solid #2a2a4a;
    border-radius: 0.4rem;
    cursor: pointer;
    margin-bottom: 0;
}

/* ── Panel action buttons ── */
.map-panel-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: auto;
    padding-top: 0.75rem;
    flex-shrink: 0;
}
.map-panel-actions .btn-save {
    flex: 1;
    background: var(--accent);
    border: none;
    color: white;
    border-radius: 0.4rem;
    padding: 0.45rem;
    cursor: pointer;
    font-size: 0.85rem;
}
.map-panel-actions .btn-cancel {
    background: none;
    border: 1px solid #2a2a4a;
    color: white;
    border-radius: 0.4rem;
    padding: 0.45rem 0.9rem;
    cursor: pointer;
    font-size: 0.85rem;
}
.map-panel-actions .btn-delete {
    background: #5a1a1a;
    border: 1px solid #8a2a2a;
    color: white;
    border-radius: 0.4rem;
    padding: 0.45rem 0.9rem;
    cursor: pointer;
    font-size: 0.85rem;
}

/* ── Mobile nav hamburger button ── */
.mobile-nav-btn {
    display: none;
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 1100;
    background: var(--primary);
    border: none;
    border-radius: 0.4rem;
    color: white;
    padding: 0.4rem;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

/* ── Mobile nav overlay ── */
.mobile-nav-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.mobile-nav-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* ── Admin-unavailable page banner ── */
.mobile-unavailable {
    display: none;
    padding: 2rem;
    text-align: center;
    font-size: 1.1rem;
}

/* ════════════════════════════════════════════════
   Mobile layout overrides — max-width: 48rem
   ════════════════════════════════════════════════ */
@media (max-width: 48rem) {

    /* Nav as slide-out drawer */
    .nav-sidebar {
        transform: translateX(-100%);
        height: 100dvh;
        width: var(--nav-width-expanded);
        overflow: hidden;
        transition: transform 0.3s ease;
    }
    .nav-sidebar.mobile-open {
        transform: translateX(0);
    }
    /* Show nav labels inside the open drawer */
    .nav-sidebar .nav-label {
        opacity: 1;
        pointer-events: auto;
    }
    /* Suppress tooltip popups inside the drawer */
    .nav-sidebar .nav-item-link::after {
        display: none;
    }
    /* Hide the desktop collapse/expand arrow */
    .nav-toggle {
        display: none;
    }
    /* Push nav links below the floating hamburger button */
    .nav-sidebar .nav-links {
        padding-top: 3.5rem;
    }

    /* Full-width content — no sidebar offset */
    .app-shell {
        margin-left: 0;
        padding-top: 3.5rem;
    }
    body.nav-expanded .app-shell {
        margin-left: 0;
    }

    /* Map container full-width on mobile */
    #map-container {
        left: 0;
    }
    body.nav-expanded #map-container {
        left: 0;
    }

    /* Show hamburger button */
    .mobile-nav-btn {
        display: flex;
    }
    /* Overlay shown structure-ready; visible when .active */
    .mobile-nav-overlay {
        display: block;
    }

    /* Hide admin-only nav links and page buttons */
    .mobile-admin-hidden {
        display: none !important;
    }

    /* Admin-unavailable page pattern */
    .mobile-unavailable {
        display: block;
    }
    .mobile-hide-content {
        display: none;
    }

    /* Notification settings before feed on mobile, not sticky */
    .notif-sidebar {
        order: -1;
        position: static;
    }

    /* Notification feed header: allow dismiss button to wrap */
    .notif-feed-header {
        flex-wrap: wrap;
        gap: 0.4rem;
    }

    /* Notification items: allow message to wrap instead of clipping */
    .notif-item-message {
        white-space: normal;
    }
    .notif-item-title {
        max-width: 100%;
    }

    /* Article topbar: stack tags above date/actions on mobile */
    .article-topbar {
        flex-direction: column;
        align-items: flex-start;
    }
    .article-topbar-right {
        width: 100%;
        justify-content: space-between;
    }

    /* Search bar: text input wraps to its own full-width line */
    .search-bar {
        flex-wrap: wrap;
    }
    .search-input {
        flex: 1 1 100%;
        order: 3;
    }
    .search-btn {
        order: 4;
    }
}
