:root {
    color-scheme: dark;
    --night: #0c1627;
    --night-soft: #14253c;
    --panel: rgba(20, 37, 60, .88);
    --panel-solid: #162a43;
    --gold: #d8bc72;
    --gold-light: #f2dfa3;
    --teal: #79c7c0;
    --ink: #f6f1e5;
    --muted: #b8c2cf;
    --line: rgba(216, 188, 114, .28);
    --danger: #f1a6a6;
    --shadow: 0 20px 60px rgba(0, 0, 0, .28);
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--night); }
body { margin: 0; min-height: 100vh; color: var(--ink); line-height: 1.6; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--gold-light); }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { outline-offset: 4px; }
:focus-visible { outline: 2px solid var(--teal); }
img, video { display: block; max-width: 100%; }

.sky {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(circle at 12% 18%, rgba(121, 199, 192, .13), transparent 26%),
        radial-gradient(circle at 85% 8%, rgba(156, 174, 232, .12), transparent 30%),
        radial-gradient(circle at 70% 75%, rgba(216, 188, 114, .08), transparent 28%),
        linear-gradient(145deg, #091321 0%, #14253c 55%, #101b31 100%);
}
.sky::before {
    content: "";
    position: absolute;
    inset: 0;
    opacity: .38;
    background-image:
        radial-gradient(circle at 8% 28%, #fff 0 1px, transparent 1.5px),
        radial-gradient(circle at 22% 72%, #fff 0 1px, transparent 1.5px),
        radial-gradient(circle at 42% 18%, #fff 0 1px, transparent 1.5px),
        radial-gradient(circle at 64% 42%, #fff 0 1px, transparent 1.5px),
        radial-gradient(circle at 82% 64%, #fff 0 1px, transparent 1.5px),
        radial-gradient(circle at 94% 22%, #fff 0 1px, transparent 1.5px);
    background-size: 310px 290px;
}
.sky::after {
    content: "";
    position: absolute;
    width: 560px;
    height: 560px;
    right: -240px;
    top: 100px;
    border: 1px solid rgba(216, 188, 114, .12);
    border-radius: 50%;
    box-shadow: 0 0 0 55px rgba(216, 188, 114, .025), 0 0 0 110px rgba(216, 188, 114, .02);
}

.site-header {
    width: min(1240px, calc(100% - 40px));
    margin: 0 auto;
    padding: 26px 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 13px; }
.brand strong { display: block; letter-spacing: .16em; font-family: Georgia, serif; color: var(--gold-light); }
.brand small { display: block; color: var(--muted); font-size: .72rem; letter-spacing: .08em; }
.brand-emblem {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    color: var(--gold-light);
    font: 700 25px Georgia, serif;
    border: 1px solid var(--gold);
    transform: rotate(45deg);
    background: rgba(216, 188, 114, .08);
}
.brand-emblem::first-letter { transform: rotate(-45deg); }
.main-nav { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.main-nav a { padding: 8px 14px; color: var(--muted); border-bottom: 1px solid transparent; }
.main-nav a.active, .main-nav a:hover { color: var(--gold-light); border-bottom-color: var(--gold); }
.main-nav .admin-link { margin-left: 8px; border: 1px solid var(--line); border-radius: 6px; }

.page { width: min(1240px, calc(100% - 40px)); min-height: 65vh; margin: 0 auto; padding: 52px 0 72px; }
.site-footer {
    width: min(1240px, calc(100% - 40px));
    margin: 0 auto;
    padding: 22px 0 30px;
    border-top: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    gap: 16px;
    color: var(--muted);
    font-size: .85rem;
}

h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; line-height: 1.18; font-weight: 500; }
h1 { margin: 8px 0 18px; font-size: clamp(2.2rem, 5vw, 4.4rem); }
h2 { margin: 0 0 18px; font-size: clamp(1.45rem, 2.5vw, 2rem); }
h3 { margin: 14px 0 8px; }
p { margin: 8px 0 16px; }
.eyebrow { color: var(--gold); font-size: .76rem; font-weight: 700; letter-spacing: .2em; text-transform: uppercase; }
.muted { color: var(--muted); }
.preline { white-space: pre-line; }
.text-link { color: var(--teal); text-decoration: underline; text-underline-offset: 4px; }

.hero { max-width: 850px; padding: 70px 0 62px; position: relative; }
.hero::after { content: ""; width: 90px; height: 1px; display: block; margin-top: 35px; background: var(--gold); box-shadow: 105px 0 0 rgba(216,188,114,.3); }
.hero h1 em { color: var(--gold-light); font-weight: 400; }
.hero p { max-width: 620px; color: var(--muted); font-size: 1.14rem; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 28px; }
.page-heading { margin-bottom: 32px; }
.page-heading p { max-width: 700px; color: var(--muted); }

.button {
    appearance: none;
    border: 1px solid var(--gold);
    border-radius: 5px;
    background: linear-gradient(135deg, #d8bc72, #b99b55);
    color: #152237;
    padding: 11px 21px;
    font-weight: 700;
    cursor: pointer;
    transition: transform .16s ease, filter .16s ease;
}
.button:hover { color: #0c1627; filter: brightness(1.1); transform: translateY(-1px); }
.button-secondary { background: rgba(20, 37, 60, .6); color: var(--gold-light); }
.button-secondary:hover { color: var(--gold-light); }
.button-quiet { background: transparent; color: var(--muted); border-color: var(--line); }
.button-small { padding: 7px 13px; font-size: .86rem; }
.inline-form { display: inline; margin-top: 12px; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin: 8px 0 58px; }
.stats-grid-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat-card { position: relative; padding: 24px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); }
.stat-card::before, .panel::before { content: ""; position: absolute; width: 12px; height: 12px; top: 7px; left: 7px; border-top: 1px solid var(--gold); border-left: 1px solid var(--gold); }
.stat-card strong { display: block; color: var(--gold-light); font: 400 2.3rem Georgia, serif; }
.stat-card span { color: var(--muted); }

.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin: 36px 0 20px; }
.section-heading h2 { margin-bottom: 0; }
.section-heading > a { color: var(--gold); }
.media-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.media-card { overflow: hidden; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.media-preview { aspect-ratio: 16 / 10; background: #0a1321; display: grid; place-items: center; overflow: hidden; }
.media-preview img, .media-preview video { width: 100%; height: 100%; object-fit: cover; }
.media-preview video { object-fit: contain; }
.media-body { padding: 17px 19px 18px; }
.media-meta { display: flex; justify-content: space-between; align-items: start; gap: 10px; color: var(--muted); font-size: .85rem; }
.media-tags { display: flex; flex-wrap: wrap; gap: 5px 10px; }
.media-author { margin-top: 6px; color: var(--muted); font-size: .85rem; }
.media-author a { color: var(--teal); }
.tag { color: var(--teal); font-weight: 700; }
.media-body time { color: var(--muted); font-size: .8rem; }
.caption { color: var(--ink); white-space: pre-line; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.external-media { min-height: 210px; display: grid; place-content: center; justify-items: center; gap: 16px; color: var(--gold-light); background: radial-gradient(circle, rgba(216,188,114,.1), transparent 65%); }
.external-media-mark { width: 60px; height: 60px; display: grid; place-items: center; padding-left: 4px; border: 1px solid var(--gold); border-radius: 50%; }
.media-hidden { opacity: .55; }

.filters, .admin-form, .assign-form, .date-filter { display: flex; gap: 16px; align-items: end; flex-wrap: wrap; }
.filters { padding: 20px; margin-bottom: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.filters-toggle { display: none; }
.filter-actions { display: flex; align-items: center; gap: 16px; }
label { display: grid; gap: 6px; color: var(--muted); font-size: .87rem; }
input, select, textarea {
    min-width: 180px;
    border: 1px solid rgba(184, 194, 207, .28);
    border-radius: 5px;
    background: rgba(7, 17, 30, .75);
    color: var(--ink);
    padding: 10px 12px;
}
textarea { width: 100%; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); }
.checkbox { display: flex; align-items: center; gap: 8px; }
.checkbox input { min-width: auto; width: 17px; height: 17px; }
.results-count { margin: 16px 0; color: var(--muted); }
.empty-state { padding: 56px 28px; text-align: center; background: rgba(20, 37, 60, .55); border: 1px dashed var(--line); border-radius: 8px; }
.empty-state h1, .empty-state h3 { margin-top: 0; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 22px; margin-top: 32px; }
.pagination a { color: var(--gold); }

.lore-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-bottom: 32px; }
.lore-game-card { display: flex; flex-direction: column; padding: 24px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); transition: border-color .16s ease, transform .16s ease; }
.lore-game-card:hover { border-color: var(--gold); transform: translateY(-2px); }
.lore-game-card.is-active { border-color: var(--teal); box-shadow: 0 0 0 1px var(--teal); }
.lore-game-card strong { margin: 10px 0; color: var(--gold-light); font: 400 1.45rem Georgia, serif; }
.lore-game-card p { flex: 1; color: var(--muted); }
.lore-game-card small { color: var(--teal); }
.lore-chronology { scroll-margin-top: 24px; }
.lore-timeline { position: relative; display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.lore-event { position: relative; display: grid; grid-template-columns: 120px 1fr; gap: 24px; padding: 22px 0; border-bottom: 1px solid rgba(184,194,207,.13); }
.lore-event:last-child { border-bottom: 0; }
.lore-event > time { color: var(--gold); font-size: .9rem; }
.lore-event article { position: relative; padding-left: 22px; border-left: 1px solid var(--line); }
.lore-event article::before { content: ""; position: absolute; top: 9px; left: -5px; width: 9px; height: 9px; border-radius: 50%; background: var(--teal); }
.lore-event h3 { margin: 5px 0 8px; color: var(--gold-light); font-size: 1.35rem; }
.lore-event p { margin-bottom: 10px; }
.lore-source { font-size: .82rem; }

.card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.profile-card, .character-card { display: flex; align-items: center; flex-wrap: wrap; gap: 16px; min-width: 0; padding: 22px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.profile-card:hover, .character-card:hover { border-color: var(--gold); }
.profile-initial { flex: 0 0 auto; width: 54px; height: 54px; display: grid; place-items: center; border: 1px solid var(--gold); border-radius: 50%; color: var(--gold-light); background: rgba(216,188,114,.08); font: 400 25px Georgia, serif; }
.profile-content { display: grid; flex: 1 1 0; min-width: 0; gap: 3px; }
.profile-content strong { font: 400 1.3rem Georgia, serif; color: var(--gold-light); overflow-wrap: anywhere; }
.profile-content small, .profile-detail { color: var(--muted); }
.profile-detail { width: 100%; padding-left: 70px; font-size: .88rem; }
.profile-hero, .character-hero { display: flex; align-items: center; gap: 28px; margin-bottom: 36px; }
.profile-initial-large { width: 110px; height: 110px; font-size: 48px; }
.character-portrait { flex: 0 0 auto; width: 108px; height: 132px; display: grid; place-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: 54px 54px 8px 8px; background: rgba(216,188,114,.07); color: var(--gold-light); font: 400 44px Georgia, serif; }
.character-portrait img { width: 100%; height: 100%; object-fit: cover; }
.character-info { display: grid; flex: 1; min-width: 0; gap: 5px; }
.character-info strong { color: var(--gold-light); font: 400 1.45rem Georgia, serif; overflow-wrap: anywhere; }
.character-info small, .character-info span { color: var(--muted); overflow-wrap: anywhere; }
.character-portrait-large { width: 220px; height: 280px; font-size: 80px; }
.badge-list { display: flex; gap: 8px; flex-wrap: wrap; }
.badge { display: inline-flex; width: fit-content; padding: 4px 9px; border: 1px solid var(--line); border-radius: 20px; color: var(--gold-light); background: rgba(216,188,114,.07); font-size: .78rem; }
.alias-control { display: inline-flex; align-items: center; gap: 3px; }
.alias-delete { padding: 3px 6px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.alias-delete:hover { color: var(--danger); }
.filter-select { display: grid; gap: 6px; color: var(--muted); font-size: .87rem; }
.status-badge { display: inline-flex; width: fit-content; padding: 3px 9px; border: 1px solid; border-radius: 5px; font-size: .75rem; font-weight: 700; white-space: nowrap; }
.status-active { color: #9bd39c; border-color: rgba(155, 211, 156, .55); background: rgba(72, 130, 77, .18); }
.status-deleted { color: var(--muted); border-color: rgba(184, 194, 207, .4); background: rgba(184, 194, 207, .08); }
.status-blocked { color: var(--danger); border-color: rgba(241, 166, 166, .55); background: rgba(130, 40, 50, .2); }
.admin-photo-preview { width: min(220px, 100%); max-height: 280px; object-fit: cover; border: 1px solid var(--line); border-radius: 8px; }
.tag-forms { margin-bottom: 22px; }
.collapsible-panel > summary { display: flex; align-items: center; justify-content: space-between; gap: 16px; cursor: pointer; list-style: none; }
.collapsible-panel > summary::-webkit-details-marker { display: none; }
.collapsible-panel > summary h2 { margin: 4px 0 0; }
.collapsible-panel[open] > summary { margin-bottom: 20px; }
.character-tag-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; align-items: end; gap: 12px; }
.character-tag-form .filter-dropdown, .character-tag-form .filter-dropdown-toggle { width: 100%; min-width: 0; }
.collapse-label { flex: 0 0 auto; width: 10px; height: 10px; color: var(--gold); }
.collapse-label::after { content: ''; display: block; width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); }
.collapsible-panel[open] .collapse-label::after { transform: rotate(-135deg); }
@media (max-width: 620px) {
    .character-tag-form { grid-template-columns: 1fr; }
    .character-tag-form .button { width: 100%; }
}
.detail-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; }
.panel { position: relative; padding: 26px; margin-bottom: 22px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.details { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.details dt { color: var(--muted); }
.details dd { margin: 0; text-align: right; }

.admin-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding-bottom: 22px; margin-bottom: 32px; border-bottom: 1px solid var(--line); }
.admin-nav { display: flex; gap: 6px; flex-wrap: wrap; }
.admin-nav a { padding: 8px 13px; border-radius: 5px; color: var(--muted); }
.admin-nav a.active { color: var(--gold-light); background: rgba(216,188,114,.1); }
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.dashboard-grid .panel { margin: 0; }
.panel-wide { grid-column: 1 / -1; }
.chart-legend { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 12px; color: var(--muted); font-size: .85rem; }
.chart-legend span { display: flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 50%; background: var(--series-color); }
.line-chart { width: 100%; height: auto; overflow: visible; }
.line-chart text { fill: var(--muted); font-size: 10px; }
.chart-grid { stroke: rgba(184,194,207,.15); stroke-width: 1; }
.period-buttons { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.period-button.is-active { border-color: var(--teal); box-shadow: 0 0 0 1px var(--teal); color: var(--gold-light); }
.custom-period-form { display: flex; align-items: end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
[data-tag-usage-panel][aria-busy="true"] .line-chart { opacity: .6; }
.subscription-chart { display: grid; grid-template-columns: minmax(180px, 280px) 1fr; align-items: center; gap: 28px; }
.pie-chart { width: 100%; height: auto; transform: rotate(0deg); }
.pie-chart-base { fill: none; stroke: rgba(184,194,207,.1); stroke-width: 6; }
.pie-segment { fill: none; stroke-width: 6; }
.pie-chart-total { fill: var(--gold-light); font: 400 5px Georgia, serif; text-anchor: middle; }
.pie-chart-caption { fill: var(--muted); font-size: 1.8px; text-anchor: middle; }
.pie-legend { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.pie-legend li { display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 9px; }
.pie-legend i { width: 10px; height: 10px; border-radius: 50%; background: var(--series-color); }
.pie-legend strong { color: var(--gold-light); font-weight: 500; }
.pie-legend small { color: var(--muted); }
.date-filter { margin-bottom: 24px; }
.daily-bars { display: grid; gap: 15px; }
.bar-row { display: grid; grid-template-columns: 60px 1fr 35px; align-items: center; gap: 12px; }
.bar-track { height: 9px; background: rgba(184,194,207,.12); border-radius: 8px; overflow: hidden; }
.bar-track i { display: block; width: var(--bar-width); height: 100%; min-width: 2px; background: var(--bar-color); border-radius: 8px; }
.ranking { list-style: none; padding: 0; margin: 0; counter-reset: rank; }
.ranking li { counter-increment: rank; display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid rgba(184,194,207,.1); }
.ranking li::before { content: counter(rank); color: var(--gold); width: 20px; }
.ranking li a { flex: 1; }
.admin-form { align-items: end; }
.admin-form .form-wide { flex: 1 1 100%; }
.game-options { margin: 0; padding: 16px; border: 1px solid var(--line); border-radius: 5px; }
.game-options legend { padding: 0 8px; color: var(--muted); font-size: .87rem; }
.game-options-list { display: flex; flex-wrap: wrap; gap: 12px 22px; }
.game-options small, .admin-form label small { color: var(--muted); }
.assign-form { align-items: center; gap: 9px; }
.form-error { padding: 13px 17px; margin-bottom: 20px; border: 1px solid rgba(241,166,166,.5); border-radius: 5px; color: var(--danger); background: rgba(130,40,50,.15); }
.danger-zone { border-color: rgba(241,166,166,.35); }
.button-danger { border-color: rgba(241,166,166,.6); background: rgba(130,40,50,.35); color: var(--danger); }
.button-danger:hover { color: #ffd7d7; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; border-bottom: 1px solid rgba(184,194,207,.13); text-align: left; vertical-align: middle; }
th { color: var(--gold); font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; }
.login-card { max-width: 620px; margin: 70px auto; padding: 42px; text-align: center; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.login-card h1 { font-size: 2.6rem; }
.telegram-login { display: flex; justify-content: center; min-height: 45px; margin: 28px 0; }

@media (max-width: 900px) {
    .site-header { align-items: flex-start; flex-direction: column; }
    .main-nav .admin-link { margin-left: 0; }
    .media-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .lore-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-grid { grid-template-columns: 1fr; }
    .panel-wide { grid-column: auto; }
}

@media (max-width: 620px) {
    .site-header, .page, .site-footer { width: min(100% - 24px, 1240px); }
    .page { padding-top: 32px; }
    .hero { padding: 40px 0; }
    .media-grid, .card-grid, .detail-grid { grid-template-columns: 1fr; }
    .lore-event { grid-template-columns: 1fr; gap: 8px; }
    .profile-hero, .character-hero { align-items: flex-start; flex-direction: column; }
    .character-portrait-large { width: 170px; height: 215px; }
    .site-footer { flex-direction: column; }
    .filters, .admin-form { align-items: stretch; flex-direction: column; }
    .filters label, .filters button, .admin-form label, .admin-form button, input, select { width: 100%; }
    .filters-toggle { display: block; }
    .filters.is-mobile-collapsed > :not(.filters-toggle) { display: none; }
    .filter-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
    .subscription-chart { grid-template-columns: 1fr; }
    .custom-period-form { align-items: stretch; flex-direction: column; }
    .custom-period-form .date-range-picker, .custom-period-form .date-range-toggle { width: 100%; }
    .pie-chart { max-width: 260px; margin: 0 auto; }
    .admin-toolbar { align-items: flex-start; flex-direction: column; }
    .stats-grid { gap: 10px; }
    .stat-card { padding: 17px; }
    .section-heading { align-items: flex-start; flex-direction: column; }
}

.media-card, .media-preview { min-width: 0; }
.media-preview { position: relative; width: 100%; }
.media-preview video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    background: #050b14;
}
.media-preview img { cursor: zoom-in; }
.media-expand {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 34px;
    height: 34px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: rgba(12, 22, 39, .82);
    color: var(--gold-light);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}
.media-expand:hover { background: var(--panel-solid); }
.dialog-open { overflow: hidden; }
.media-dialog {
    width: 100vw;
    max-width: none;
    height: 100vh;
    max-height: none;
    margin: 0;
    padding: 48px 24px 24px;
    border: 0;
    background: rgba(5, 11, 20, .96);
    color: var(--ink);
}
.media-dialog::backdrop { background: rgba(5, 11, 20, .9); }
.media-dialog-content { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.media-dialog-content img, .media-dialog-content video {
    max-width: 95vw;
    max-height: 88vh;
    width: auto;
    height: auto;
    object-fit: contain;
}
.media-dialog-close {
    position: fixed;
    top: 14px;
    right: 20px;
    z-index: 2;
    width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--panel-solid);
    color: var(--gold-light);
    font-size: 28px;
    cursor: pointer;
}
.profile-initial { position: relative; overflow: hidden; }
.profile-initial img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.avatar-missing img { display: none; }
.profile-facts {
    display: grid;
    gap: 2px;
    width: 100%;
    padding-left: 70px;
    color: var(--muted);
    font-size: .86rem;
    line-height: 1.35;
}
.profile-facts-inline { width: auto; padding-left: 0; margin-top: 8px; }
.users-search { display: flex; align-items: end; gap: 12px; margin-bottom: 24px; }
.users-search label { flex: 1; max-width: 480px; }
@media (max-width: 620px) {
    .users-search { align-items: stretch; flex-direction: column; }
    .users-search label { max-width: none; }
    .users-search .button { width: 100%; }
}
.date-range-picker { position: relative; }
.date-range-toggle { min-width: 210px; }
.date-range-popup {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 20;
    width: 330px;
    padding: 16px;
    border: 1px solid var(--gold);
    border-radius: 8px;
    background: var(--panel-solid);
    box-shadow: var(--shadow);
}
.date-range-header, .date-range-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.date-range-header { margin-bottom: 14px; color: var(--gold-light); }
.date-range-header button, .date-range-actions button { border: 0; background: transparent; color: var(--gold); cursor: pointer; padding: 6px 10px; }
.date-range-header button { font-size: 24px; }
.date-weekdays, .date-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.date-weekdays { margin-bottom: 6px; color: var(--muted); font-size: .75rem; }
.date-grid button { padding: 7px 0; border: 0; border-radius: 4px; background: transparent; color: var(--ink); cursor: pointer; }
.date-grid button:hover { background: rgba(121, 199, 192, .18); }
.date-grid button.in-range { background: rgba(121, 199, 192, .13); }
.date-grid button.is-start, .date-grid button.is-end { background: var(--gold); color: var(--night); }
.date-range-actions { margin-top: 14px; }
.filter-dropdown { position: relative; }
.filter-dropdown-toggle { min-width: 210px; max-width: 310px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filter-popup {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 20;
    width: 280px;
    padding: 12px;
    border: 1px solid var(--gold);
    border-radius: 8px;
    background: var(--panel-solid);
    box-shadow: var(--shadow);
}
.filter-popup-tags { width: 330px; }
.filter-search-label { margin-bottom: 10px; }
.filter-search-label input { width: 100%; min-width: 0; }
.filter-options { display: grid; gap: 3px; max-height: 280px; overflow-y: auto; }
.filter-option { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 5px; color: var(--ink); cursor: pointer; }
.filter-option[hidden] { display: none; }
.filter-option:hover { background: rgba(121, 199, 192, .12); }
.filter-option input { min-width: auto; width: 17px; height: 17px; margin: 0; accent-color: var(--gold); }
.filter-popup-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 10px; }
.filter-popup-actions button { border: 0; background: transparent; color: var(--gold); cursor: pointer; padding: 6px 10px; }
.filter-empty { margin: 10px 8px; color: var(--muted); }
.filter-dropdown.has-value .filter-dropdown-toggle, .date-range-picker.has-value .date-range-toggle { border-color: var(--teal); }
@media (max-width: 620px) {
    .date-range-popup, .filter-popup { left: auto; right: 0; width: min(330px, calc(100vw - 30px)); }
    .filter-dropdown, .filter-dropdown-toggle { width: 100%; max-width: none; }
}
.scroll-sentinel { min-height: 54px; padding: 18px; text-align: center; color: var(--muted); cursor: pointer; }
.scroll-sentinel.is-complete { cursor: default; }
.media-expand, .media-dialog-close { display: grid; place-items: center; padding: 0; line-height: 1; }
[data-users-grid] { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
[data-users-grid] .profile-card { padding: 18px; gap: 12px; }
[data-users-grid] .profile-facts { padding-left: 0; margin-top: 4px; }
@media (min-width: 901px) and (max-width: 1100px) {
    [data-users-grid] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
    [data-users-grid] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
    [data-users-grid] { grid-template-columns: 1fr; }
}

.commands-search-panel { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 36px; }
.commands-search-label { flex: 1; max-width: 520px; }
.commands-search-label input { width: 100%; }
.commands-search-panel .results-count { margin: 0 0 10px; white-space: nowrap; }
.command-group { margin-bottom: 38px; }
.command-group .section-heading { margin-top: 0; }
.command-group-count { display: flex; align-items: center; gap: 12px; }
.command-group-description { margin: -8px 0 18px; color: var(--muted); }
.command-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.command-card { min-width: 0; padding: 20px 22px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.command-card code { display: inline-block; max-width: 100%; color: var(--gold-light); font-size: 1rem; font-weight: 700; overflow-wrap: anywhere; }
.command-card p { margin-bottom: 0; color: var(--muted); }
@media (max-width: 620px) {
    .commands-search-panel { align-items: stretch; flex-direction: column; }
    .commands-search-label { max-width: none; }
    .command-grid { grid-template-columns: 1fr; }
}

.insights-heading h1 em { color: var(--gold-light); font-weight: 400; }
.insight-periods { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 26px; }
.insight-periods .is-active { border-color: var(--teal); box-shadow: 0 0 0 1px var(--teal); color: var(--gold-light); }
.insight-stats { margin-bottom: 12px; }
.insight-date-range { margin: 0 0 30px; color: var(--muted); font-size: .9rem; }
.insight-panel { padding: 24px; overflow: hidden; }
.insight-panel .section-heading { align-items: flex-start; margin: 0 0 10px; }
.insight-panel .section-heading h2 { margin-top: 4px; }
.insight-panel .section-heading > span { font-size: .82rem; }
.word-cloud { display: block; width: 100%; height: auto; min-height: 300px; }
.cloud-word { cursor: pointer; transition: opacity .15s ease; }
.cloud-word text { fill: var(--muted); font-family: Georgia, "Times New Roman", serif; }
.cloud-word:hover text, .cloud-word.is-active text { fill: var(--gold-light); text-decoration: underline; }
.cloud-tone-0 text { fill: var(--gold-light); }
.cloud-tone-1 text { fill: var(--teal); }
.cloud-tone-2 text { fill: #b6c8ed; }
.cloud-tone-3 text { fill: #d6a8bb; }
.cloud-word.is-muted { opacity: .22; }
.insight-map-layout { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 18px; align-items: center; }
.semantic-map { display: block; width: 100%; height: auto; min-height: 430px; }
.semantic-edges line { stroke: rgba(184, 194, 207, .2); transition: opacity .15s ease, stroke .15s ease; }
.semantic-edges line.is-active { stroke: var(--gold); opacity: .85; }
.semantic-edges line.is-muted { opacity: .08; }
.semantic-node { cursor: pointer; transition: opacity .15s ease; }
.semantic-node circle { fill: rgba(121, 199, 192, .16); stroke: var(--teal); stroke-width: 1.4; }
.semantic-node text { fill: var(--ink); paint-order: stroke; stroke: rgba(12, 22, 39, .92); stroke-width: 4px; stroke-linejoin: round; }
.semantic-node:hover circle, .semantic-node.is-active circle { fill: rgba(216, 188, 114, .35); stroke: var(--gold-light); stroke-width: 2.5; }
.semantic-node.is-active text { fill: var(--gold-light); }
.semantic-node.is-related circle { stroke: var(--gold); }
.semantic-node.is-muted { opacity: .14; }
.community-1 circle, i.community-1 { stroke: #d8bc72; }
.community-2 circle, i.community-2 { stroke: #b6c8ed; }
.community-3 circle, i.community-3 { stroke: #d6a8bb; }
.community-4 circle, i.community-4 { stroke: #9bd39c; }
.community-5 circle, i.community-5 { stroke: #c4a4e8; }
.community-6 circle, i.community-6 { stroke: #e6a578; }
.community-7 circle, i.community-7 { stroke: #8ecbd8; }
.word-detail { align-self: stretch; padding: 20px; border-left: 1px solid var(--line); background: rgba(7, 17, 30, .3); }
.word-detail h3 { margin-top: 8px; color: var(--gold-light); font-size: 1.8rem; overflow-wrap: anywhere; }
.word-detail h4 { margin: 24px 0 8px; color: var(--muted); font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; }
.word-detail ul { display: grid; gap: 4px; margin: 0 0 22px; padding: 0; list-style: none; }
.word-detail li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid rgba(184, 194, 207, .1); cursor: pointer; }
.word-detail li:hover span { color: var(--gold-light); }
.word-detail li small { color: var(--teal); }
.word-detail .word-detail-empty { color: var(--muted); cursor: default; font-size: .85rem; }
.community-legend { display: flex; flex-wrap: wrap; gap: 8px 18px; padding-top: 18px; border-top: 1px solid rgba(184, 194, 207, .12); color: var(--muted); font-size: .8rem; }
.community-legend span { display: flex; align-items: center; gap: 7px; }
.community-legend i { width: 9px; height: 9px; border: 1px solid var(--teal); border-radius: 50%; }
.insight-method { color: var(--muted); font-size: .88rem; }
.insight-method summary { color: var(--gold); cursor: pointer; }
.insight-method p { max-width: 850px; }
@media (max-width: 900px) {
    .insight-map-layout { grid-template-columns: 1fr; }
    .word-detail { border-top: 1px solid var(--line); border-left: 0; }
    .word-detail ul { grid-template-columns: repeat(2, 1fr); column-gap: 18px; }
}
@media (max-width: 620px) {
    .insight-panel { padding: 16px 10px; }
    .insight-stats .stat-card strong { font-size: 1.75rem; white-space: nowrap; }
    .insight-panel .section-heading { padding: 0 8px; }
    .insight-panel .section-heading > span { display: none; }
    .insight-visual-scroll { max-width: 100%; min-width: 0; overflow-x: auto; overscroll-behavior-x: contain; }
    .word-cloud { min-width: 640px; min-height: 0; }
    .semantic-map { min-width: 700px; min-height: 0; }
    .word-detail { margin: 0 8px; }
    .community-legend { padding: 16px 8px 0; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
