/* === Navigation === */
.nav {
    background: var(--bg-darker);
    border-bottom: 1px solid var(--current);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--purple);
    margin-right: 2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-brand svg {
    width: 22px;
    height: 22px;
}

.nav-links {
    display: flex;
    gap: 0.25rem;
    list-style: none;
}

.nav-links a {
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    color: var(--comment);
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.15s;
}

.nav-links a:hover {
    color: var(--fg);
    background: var(--current);
    text-decoration: none;
}

.nav-links a.active {
    color: var(--purple);
    background: rgba(189, 147, 249, 0.1);
}

.nav-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* === Stats Cards === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stats-card {
    background: var(--current);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow);
}

/* Stat cards double as links to their page/filter */
a.stats-card {
    display: block;
    text-decoration: none;
    color: inherit;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

a.stats-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.stats-card .label {
    font-size: 0.8rem;
    color: var(--comment);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.stats-card .value {
    font-size: 2rem;
    font-weight: 700;
    font-family: var(--font-mono);
    line-height: 1.2;
}

.stats-card.purple .value { color: var(--purple); }
.stats-card.green .value  { color: var(--green); }
.stats-card.cyan .value   { color: var(--cyan); }
.stats-card.pink .value   { color: var(--pink); }
.stats-card.yellow .value { color: var(--yellow); }
.stats-card.orange .value { color: var(--orange); }

/* === Data Tables === */
.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.9rem;
}

.data-table th {
    background: var(--bg-darker);
    color: var(--purple);
    font-weight: 600;
    text-align: left;
    padding: 0.85rem 0.75rem;
    border-bottom: 2px solid var(--purple);
    white-space: nowrap;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.data-table tbody tr:first-child td {
    padding-top: 0.85rem;
}

.data-table td {
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid rgba(68, 71, 90, 0.5);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background 0.1s;
}

.data-table tbody tr:hover {
    background: var(--current);
}

.data-table .clickable-row {
    cursor: pointer;
}

.data-table .sortable {
    cursor: pointer;
    user-select: none;
    padding-right: 1.5rem;
}

.data-table .sortable::after {
    content: '\2195';
    margin-left: 0.25rem;
    color: var(--comment);
    font-size: 0.75rem;
}

.data-table .sortable.sort-asc::after {
    content: '\2191';
    color: var(--purple);
}

.data-table .sortable.sort-desc::after {
    content: '\2193';
    color: var(--purple);
}

.data-table .empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--comment);
    font-style: italic;
}

/* === Count Badges === */
.count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: var(--font-mono);
}

.count-badge.green   { background: rgba(80, 250, 123, 0.15); color: var(--green); }
.count-badge.cyan    { background: rgba(139, 233, 253, 0.15); color: var(--cyan); }
.count-badge.pink    { background: rgba(255, 121, 198, 0.15); color: var(--pink); }
.count-badge.yellow  { background: rgba(241, 250, 140, 0.15); color: var(--yellow); }
.count-badge.purple  { background: rgba(189, 147, 249, 0.15); color: var(--purple); }
.count-badge.red     { background: rgba(255, 85, 85, 0.15); color: var(--red); }

/* === Avatars === */
.avatar-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--current);
}

.avatar-lg {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--purple);
}

.avatar-placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--current);
    color: var(--comment);
    font-size: 0.8rem;
    font-weight: 600;
}

.avatar-stack {
    display: flex;
    align-items: center;
}

.avatar-stack .avatar-sm,
.avatar-stack .avatar-placeholder {
    margin-left: -8px;
    border: 2px solid var(--bg);
}

.avatar-stack .avatar-sm:first-child,
.avatar-stack .avatar-placeholder:first-child {
    margin-left: 0;
}

/* === Chips / Filter Chips === */
.chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    border: 1px solid var(--current);
    background: transparent;
    color: var(--comment);
}

.chip:hover {
    border-color: var(--purple);
    color: var(--fg);
}

.chip.active,
.chip input:checked + .chip-label {
    background: rgba(189, 147, 249, 0.2);
    border-color: var(--purple);
    color: var(--purple);
}

.chip input[type="checkbox"],
.chip input[type="radio"] {
    display: none;
}

.chip.chip-green.active  { background: rgba(80, 250, 123, 0.15); border-color: var(--green); color: var(--green); }
.chip.chip-cyan.active   { background: rgba(139, 233, 253, 0.15); border-color: var(--cyan); color: var(--cyan); }
.chip.chip-pink.active   { background: rgba(255, 121, 198, 0.15); border-color: var(--pink); color: var(--pink); }
.chip.chip-yellow.active { background: rgba(241, 250, 140, 0.15); border-color: var(--yellow); color: var(--yellow); }

/* === Search / Inputs === */
.search-input {
    width: 100%;
    max-width: 400px;
    padding: 0.6rem 1rem;
    background: var(--bg-darker);
    border: 1px solid var(--current);
    border-radius: var(--radius);
    color: var(--fg);
    font-size: 0.9rem;
    font-family: var(--font-sans);
    transition: border-color 0.15s;
    outline: none;
}

.search-input:focus {
    border-color: var(--purple);
    box-shadow: 0 0 0 2px rgba(189, 147, 249, 0.2);
}

.search-input::placeholder {
    color: var(--comment);
}

.form-input {
    padding: 0.5rem 0.75rem;
    background: var(--bg-darker);
    border: 1px solid var(--current);
    border-radius: var(--radius);
    color: var(--fg);
    font-size: 0.9rem;
    font-family: var(--font-sans);
    outline: none;
}

.form-input:focus {
    border-color: var(--purple);
}

select.form-input {
    cursor: pointer;
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 600;
    font-family: var(--font-sans);
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s;
    text-decoration: none;
}

.btn-purple {
    background: var(--purple);
    color: var(--bg);
}

.btn-purple:hover {
    background: #a77af8;
    color: var(--bg);
}

.btn-green {
    background: var(--green);
    color: var(--bg);
}

.btn-green:hover {
    background: #3de66c;
    color: var(--bg);
}

.btn-pink {
    background: var(--pink);
    color: var(--bg);
}

.btn-pink:hover {
    background: #e56cb0;
}

.btn-ghost {
    background: transparent;
    border-color: var(--current);
    color: var(--comment);
}

.btn-ghost:hover {
    border-color: var(--purple);
    color: var(--fg);
}

.btn-hidden-active {
    border-color: var(--red);
    color: var(--red);
}
.btn-hidden-active:hover {
    border-color: var(--red);
    color: var(--fg);
    background: rgba(255, 85, 85, 0.15);
}

.btn-sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
}

/* === Quote Cards === */
.quote-card {
    background: var(--bg-darker);
    border-left: 3px solid var(--purple);
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
}

.quote-card .quote-text {
    font-style: italic;
    color: var(--fg);
    line-height: 1.5;
    margin-bottom: 0.5rem;
}

.quote-card .quote-meta {
    font-size: 0.8rem;
    color: var(--comment);
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.quote-card .quote-meta a {
    color: var(--cyan);
}

/* === Thread Bar (mini visualization) === */
.thread-bar {
    display: flex;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    background: var(--current);
    min-width: 80px;
}

.thread-bar .bar-seg {
    min-width: 2px;
    transition: width 0.3s;
}

.bar-seg.green  { background: var(--green); }
.bar-seg.cyan   { background: var(--cyan); }
.bar-seg.pink   { background: var(--pink); }
.bar-seg.yellow { background: var(--yellow); }

/* === Power Grid === */
.powergrid-inline {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 300px;
}

.char-actions {
    margin-left: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-shrink: 0;
}

.approval-date-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.powergrid {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    width: 100%;
}

.powergrid-stat {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.powergrid-label {
    width: 2.5rem;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--pink);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
}

.powergrid-track {
    flex: 1;
    height: 18px;
    background: var(--current);
    border-radius: 9px;
    overflow: hidden;
}

.powergrid-fill {
    height: 100%;
    border-radius: 9px;
    background: linear-gradient(90deg, var(--pink), #bf8fce);
    transition: width 0.4s ease;
}

.powergrid-value {
    width: 1.5rem;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--fg);
    text-align: center;
    flex-shrink: 0;
}

/* === Activity Bar === */
.activity-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-darker);
    border-top: 1px solid var(--current);
    padding: 0.5rem 1.5rem;
    font-size: 0.85rem;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    height: 40px;
}

.activity-bar-inner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}

/* Bug icon toggle replaces the old dot */
.debug-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--comment);
    flex-shrink: 0;
    border-radius: 4px;
    transition: color 0.2s, background 0.2s;
}

.debug-toggle:hover {
    color: var(--fg);
    background: var(--current);
}

.debug-toggle.active {
    color: var(--green);
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* === Debug Panel === */
.debug-panel {
    display: none;
    position: fixed;
    bottom: 40px;
    left: 0;
    right: 0;
    height: 320px;
    background: var(--bg-darker);
    border-top: 1px solid var(--purple);
    z-index: 99;
    flex-direction: column;
}

.debug-panel.open {
    display: flex;
}

.debug-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--current);
    flex-shrink: 0;
}

.debug-panel-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--purple);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.debug-panel-actions {
    display: flex;
    gap: 0.25rem;
}

.debug-log {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 1rem;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    line-height: 1.6;
}

.debug-entry {
    display: flex;
    gap: 0.75rem;
    padding: 1px 0;
}

.debug-time {
    color: var(--comment);
    flex-shrink: 0;
    min-width: 5.5em;
}

.debug-msg {
    color: var(--fg);
    word-break: break-word;
}

.debug-activity .debug-msg { color: var(--green); }
.debug-done .debug-msg { color: var(--cyan); }
.debug-error .debug-msg { color: var(--red); }
.debug-info .debug-msg { color: var(--fg); }

/* === Pagination === */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    margin: 1.5rem 0;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 0.5rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--comment);
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}

.page-link:hover {
    background: var(--current);
    color: var(--fg);
    text-decoration: none;
}

.page-link.active {
    background: var(--purple);
    color: var(--bg);
    font-weight: 700;
}

.page-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    color: var(--comment);
}

/* === Cards / Panels === */
.card {
    background: var(--bg-darker);
    border-radius: var(--radius-lg);
    border: 1px solid var(--current);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
}

/* === Character Detail Header === */
.char-header {
    display: flex;
    align-items: flex-start;
    gap: 1.5rem;
    position: relative;
}

.char-info {
    flex-shrink: 0;
}

.char-info h1 {
    font-size: 1.5rem;
    margin: 0 0 0.25rem 0;
    color: var(--fg);
}

.char-info .group-name {
    color: var(--comment);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.char-counts {
    display: flex;
    gap: 1.25rem;
    margin: 0.75rem 0;
}

.count-item {
    text-align: center;
}

.count-item .num {
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1.2;
}

.count-item .label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--comment);
    margin-top: 0.15rem;
}

/* === Profile Fields Table === */
.fields-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.fields-table td {
    padding: 0.4rem 0.75rem;
    border-bottom: 1px solid rgba(68, 71, 90, 0.3);
}

.fields-table .field-key {
    color: var(--comment);
    font-weight: 500;
    width: 30%;
    text-transform: capitalize;
}

.fields-table .field-value {
    color: var(--fg);
}

/* === Status Indicators === */
.status-replied {
    color: var(--green);
}

.status-awaiting {
    color: var(--yellow);
}

/* === Login Page === */
.login-container {
    max-width: 400px;
    margin: 15vh auto;
    padding: 0 1rem;
}

.login-card {
    background: var(--bg-darker);
    border: 1px solid var(--current);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    text-align: center;
}

.login-card h1 {
    color: var(--purple);
    margin-bottom: 0.5rem;
}

.login-card .subtitle {
    color: var(--comment);
    margin-bottom: 2rem;
    font-size: 0.9rem;
}

.login-card .form-input {
    width: 100%;
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
}

.login-card .btn {
    width: 100%;
    justify-content: center;
    padding: 0.75rem;
}

.login-error {
    color: var(--red);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

/* === HTMX Loading Indicator === */
.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator {
    display: inline-block;
}

.htmx-request.htmx-indicator {
    display: inline-block;
}

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--current);
    border-top: 2px solid var(--purple);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* === Section Headers === */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

/* === Dashboard Charts === */
.chart-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}

.chart-card {
    background: var(--bg-darker);
    border: 1px solid var(--current);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

.chart-card-wide {
    min-width: 0;
}

.chart-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--comment);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 1rem;
}

.chart-container {
    position: relative;
    height: 280px;
}

.chart-container-sm {
    height: 240px;
}

/* Recent activity feed */
.recent-activity {
    display: flex;
    flex-direction: column;
    gap: 0;
    max-height: 280px;
    overflow-y: auto;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid rgba(68, 71, 90, 0.4);
    text-decoration: none;
    transition: background 0.1s;
    color: var(--fg);
}

.activity-item:hover {
    background: var(--current);
    color: var(--fg);
    text-decoration: none;
}

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

.activity-name {
    font-weight: 500;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.activity-aff {
    font-size: 0.75rem;
    color: var(--comment);
}

.activity-time {
    font-size: 0.8rem;
    color: var(--comment);
    font-family: var(--font-mono);
    white-space: nowrap;
}

.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--comment);
    font-style: italic;
}

/* === Activity Badges === */
.activity-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.badge-very-active {
    background: rgba(189, 147, 249, 0.15);
    color: var(--purple);
    border: 1px solid rgba(189, 147, 249, 0.4);
}

.badge-active {
    background: rgba(80, 250, 123, 0.15);
    color: var(--green);
    border: 1px solid rgba(80, 250, 123, 0.4);
}

.badge-low-activity {
    background: rgba(241, 250, 140, 0.15);
    color: var(--yellow);
    border: 1px solid rgba(241, 250, 140, 0.4);
}

.badge-inactive {
    background: rgba(255, 85, 85, 0.15);
    color: var(--red);
    border: 1px solid rgba(255, 85, 85, 0.4);
}

.badge-new {
    background: rgba(139, 233, 253, 0.15);
    color: var(--cyan);
    border: 1px solid rgba(139, 233, 253, 0.4);
}

/* Activity bar visualization */
.activity-bar-track {
    width: 100%;
    height: 6px;
    background: var(--current);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 0.35rem;
}

.activity-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease;
}

.activity-bar-fill.purple { background: var(--purple); }
.activity-bar-fill.green  { background: var(--green); }
.activity-bar-fill.yellow { background: var(--yellow); }
.activity-bar-fill.red    { background: var(--red); }

/* Activity summary in player/character detail */
.activity-summary {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.activity-metric {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 60px;
}

.activity-metric .metric-value {
    font-size: 1.1rem;
    font-weight: 700;
    font-family: var(--font-mono);
    line-height: 1.2;
}

.activity-metric .metric-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--comment);
}

/* === Activity Check Badges === */
.ac-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
}

.ac-safe {
    background: rgba(80, 250, 123, 0.2);
    color: var(--green);
    border: 1px solid rgba(80, 250, 123, 0.5);
}

.ac-pending {
    background: rgba(98, 114, 164, 0.2);
    color: var(--comment);
    border: 1px solid rgba(98, 114, 164, 0.5);
}

.ac-warning {
    background: rgba(255, 183, 77, 0.2);
    color: var(--orange);
    border: 1px solid rgba(255, 183, 77, 0.5);
}

.ac-unsafe {
    background: rgba(255, 85, 85, 0.2);
    color: var(--red);
    border: 1px solid rgba(255, 85, 85, 0.5);
}

/* === Activity Check Overview Page === */
.ac-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

.ac-summary-card {
    display: block;
    background: var(--bg-dark);
    border: 1px solid var(--current);
    border-radius: 8px;
    padding: 1.25rem;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, transform 0.1s;
}

.ac-summary-card:hover {
    transform: translateY(-1px);
}

.ac-summary-num {
    font-size: 2rem;
    font-weight: 700;
    font-family: var(--font-mono);
    line-height: 1.2;
}

.ac-summary-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 0.25rem;
}

.ac-summary-safe { border-color: rgba(80, 250, 123, 0.4); }
.ac-summary-safe .ac-summary-num { color: var(--green); }
.ac-summary-safe .ac-summary-label { color: var(--green); }
.ac-summary-safe:hover { border-color: var(--green); background: rgba(80, 250, 123, 0.08); }
.ac-summary-safe.ac-summary-active { border-color: var(--green); background: rgba(80, 250, 123, 0.15); box-shadow: 0 0 12px rgba(80, 250, 123, 0.2); }

.ac-summary-warning { border-color: rgba(255, 183, 77, 0.4); }
.ac-summary-warning .ac-summary-num { color: var(--orange); }
.ac-summary-warning .ac-summary-label { color: var(--orange); }
.ac-summary-warning:hover { border-color: var(--orange); background: rgba(255, 183, 77, 0.08); }
.ac-summary-warning.ac-summary-active { border-color: var(--orange); background: rgba(255, 183, 77, 0.15); box-shadow: 0 0 12px rgba(255, 183, 77, 0.2); }

.ac-summary-danger { border-color: rgba(255, 85, 85, 0.4); }
.ac-summary-danger .ac-summary-num { color: var(--red); }
.ac-summary-danger .ac-summary-label { color: var(--red); }
.ac-summary-danger:hover { border-color: var(--red); background: rgba(255, 85, 85, 0.08); }
.ac-summary-danger.ac-summary-active { border-color: var(--red); background: rgba(255, 85, 85, 0.15); box-shadow: 0 0 12px rgba(255, 85, 85, 0.2); }

.ac-summary-pending { border-color: rgba(98, 114, 164, 0.4); }
.ac-summary-pending .ac-summary-num { color: var(--comment); }
.ac-summary-pending .ac-summary-label { color: var(--comment); }
.ac-summary-pending:hover { border-color: var(--comment); background: rgba(98, 114, 164, 0.08); }
.ac-summary-pending.ac-summary-active { border-color: var(--comment); background: rgba(98, 114, 164, 0.15); box-shadow: 0 0 12px rgba(98, 114, 164, 0.2); }

.ac-progress-bar {
    display: flex;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    background: var(--bg-darker);
}

.ac-progress-segment {
    height: 100%;
    transition: width 0.3s ease;
}

.ac-seg-safe { background: var(--green); }
.ac-seg-warning { background: var(--orange); }
.ac-seg-danger { background: var(--red); }
.ac-seg-pending { background: var(--comment); }

.ac-player-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

@media (max-width: 1024px) {
    .ac-player-grid {
        grid-template-columns: 1fr;
    }
}

.ac-player-card {
    border-left: 3px solid var(--current);
    margin-bottom: 0;
}

.ac-player-card.ac-player-safe { border-left-color: var(--green); }
.ac-player-card.ac-player-warning { border-left-color: var(--orange); }
.ac-player-card.ac-player-danger { border-left-color: var(--red); }
.ac-player-card.ac-player-pending { border-left-color: var(--comment); }

.ac-player-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.ac-player-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.ac-player-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--purple);
    text-decoration: none;
}

.ac-player-name:hover {
    color: var(--pink);
    text-decoration: underline;
}

.ac-player-counts {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.ac-char-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.75rem;
}

.ac-char-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border-radius: 6px;
    background: var(--bg-darker);
    border: 1px solid var(--current);
    text-decoration: none;
    color: var(--fg);
    transition: border-color 0.2s, background 0.2s;
}

.ac-char-card:hover {
    background: var(--bg-dark);
    border-color: var(--purple);
}

.ac-char-card.ac-char-safe { border-left: 3px solid var(--green); }
.ac-char-card.ac-char-warning { border-left: 3px solid var(--orange); }
.ac-char-card.ac-char-danger { border-left: 3px solid var(--red); }
.ac-char-card.ac-char-pending { border-left: 3px solid var(--comment); }

.ac-char-avatar {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
}

.ac-char-avatar img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.ac-char-info {
    flex: 1;
    min-width: 0;
}

.ac-char-name {
    font-weight: 600;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ac-char-detail {
    font-size: 0.7rem;
}

.ac-char-posts {
    font-size: 0.7rem;
    font-family: var(--font-mono);
    display: flex;
    gap: 0.3rem;
}

.ac-char-status {
    flex-shrink: 0;
}

.ac-toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.ac-search-wrap {
    position: relative;
    flex-shrink: 0;
    width: 220px;
}

.ac-search-icon {
    position: absolute;
    left: 0.6rem;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    color: var(--comment);
    pointer-events: none;
}

.ac-subtabs {
    display: flex;
    gap: 0;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--selection);
}

.ac-subtab {
    padding: 0.5rem 1.25rem;
    font-size: 0.85rem;
    color: var(--comment);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}

.ac-subtab:hover {
    color: var(--foreground);
}

.ac-subtab-active {
    color: var(--purple);
    border-bottom-color: var(--purple);
}

.ac-results-toggles {
    display: flex;
    gap: 0.5rem;
}

.ac-search-input {
    padding-left: 2rem !important;
    width: 100% !important;
}

.ac-month-toggles {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    flex: 1;
}

.ac-month-pill {
    padding: 0.3rem 0.65rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--comment);
    background: transparent;
    border: 1px solid var(--current);
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.15s;
}

.ac-month-pill:hover {
    color: var(--fg);
    border-color: var(--purple);
}

.ac-month-pill.ac-month-active {
    background: var(--purple);
    color: var(--bg);
    border-color: var(--purple);
}

/* Leaderboard grid */
.ac-lb-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 768px) {
    .ac-lb-grid { grid-template-columns: 1fr; }
}

/* Leaderboard */
.ac-leaderboard {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.ac-lb-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.35rem 0.5rem;
    border-radius: 4px;
    transition: background 0.15s;
}

.ac-lb-row:hover {
    background: var(--current);
}

.ac-lb-rank {
    width: 1.4rem;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--comment);
}

.ac-lb-rank.ac-lb-top3 {
    color: var(--orange);
}

.ac-lb-avatar {
    width: 24px;
    height: 24px;
    border-radius: 3px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--current);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ac-lb-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ac-lb-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--foreground);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ac-lb-count {
    font-size: 0.85rem;
    font-weight: 700;
    font-family: var(--font-mono);
    margin-left: auto;
}

/* Sort pills */
.ac-sort-wrap {
    display: flex;
    gap: 0.3rem;
}

.ac-sort-pill {
    padding: 0.25rem 0.55rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--comment);
    background: transparent;
    border: 1px solid var(--current);
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.15s;
}

.ac-sort-pill:hover {
    color: var(--fg);
    border-color: var(--cyan);
}

.ac-sort-pill.ac-sort-active {
    background: var(--cyan);
    color: var(--bg);
    border-color: var(--cyan);
}

@media (max-width: 768px) {
    .ac-summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .ac-char-grid {
        grid-template-columns: 1fr;
    }
}

/* === Profile Two-Column Layout === */
.profile-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    align-items: stretch;
}

@media (max-width: 768px) {
    .profile-columns {
        grid-template-columns: 1fr;
    }
}

/* === Hero Image Gallery === */
.hero-gallery-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 1rem;
    container-type: inline-size;
}

.hero-gallery-rect {
    position: relative;
    grid-column: 1 / 3;
    grid-row: 1;
    cursor: pointer;
}

.hero-gallery-img.hero-img-rect {
    width: 100%;
    height: calc((100cqi - 2rem) / 3);
    object-fit: cover;
    border-radius: var(--radius);
    border: 2px solid var(--current);
    transition: border-color 0.2s;
}

.hero-gallery-rect:hover .hero-img-rect {
    border-color: var(--purple);
}

.hero-gallery-rect:hover .hero-gallery-tooltip {
    display: block;
}

.hero-placeholder-rect {
    width: 100%;
    height: calc((100cqi - 2rem) / 3);
    border-radius: var(--radius);
    border: 2px dashed var(--current);
}

.hero-gallery-portrait {
    grid-column: 3;
    grid-row: 1 / 3;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.hero-gallery-img.hero-img-portrait {
    width: 100%;
    flex: 1 1 0;
    min-height: 0;
    object-fit: cover;
    border-radius: var(--radius);
    border: 2px solid var(--current);
    transition: border-color 0.2s;
}

.hero-placeholder-portrait {
    width: 100%;
    flex: 1 1 0;
    min-height: 0;
    border-radius: var(--radius);
    border: 2px dashed var(--current);
}

.hero-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.hero-gallery-item {
    position: relative;
    flex: 0 0 auto;
    cursor: pointer;
}

.hero-gallery-img {
    display: block;
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: var(--radius);
    border: 2px solid var(--current);
    transition: border-color 0.2s;
}

.hero-gallery-item:hover .hero-gallery-img {
    border-color: var(--purple);
}

.hero-gallery-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 1;
    border-radius: var(--radius);
    border: 2px dashed var(--current);
    color: var(--comment);
    font-size: 0.75rem;
    text-align: center;
}

.hero-gallery-label {
    margin-top: 0.35rem;
    font-size: 0.75rem;
    color: var(--comment);
    text-align: center;
    font-weight: 500;
}

.hero-gallery-tooltip {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg);
    border: 1px solid var(--purple);
    border-radius: var(--radius);
    padding: 0.6rem 0.75rem;
    white-space: nowrap;
    z-index: 50;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.hero-gallery-tooltip code {
    display: block;
    font-size: 0.78rem;
    color: var(--green);
    font-family: var(--font-mono);
}

.hero-gallery-tip-sub {
    display: block;
    margin-top: 0.3rem;
    font-size: 0.7rem;
    color: var(--comment);
}

.hero-gallery-tip-sub code {
    display: inline;
    color: var(--cyan);
    font-size: 0.7rem;
}

.hero-gallery-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--purple);
}

.hero-gallery-item:hover .hero-gallery-tooltip {
    display: block;
}

/* === Affiliations === */
.affiliation-group {
    background: var(--bg-light);
    border: 1px solid var(--current);
    border-left: 4px solid var(--purple);
    border-radius: 10px;
    padding: 1.25rem;
    margin-bottom: 1rem;
}
.affiliation-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.affiliation-header h2 {
    font-size: 1.1rem;
    margin: 0;
    color: var(--fg);
}
.affiliation-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 140px));
    gap: 0.5rem;
}
.char-mini-card {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: 8px;
    text-decoration: none;
    color: var(--fg);
    transition: background 0.15s;
}
.char-mini-card:hover {
    background: var(--current);
}
.char-mini-card-vertical {
    flex-direction: column;
    text-align: center;
    padding: 0.75rem 0.5rem;
    overflow: hidden;
    max-width: 140px;
}
.char-mini-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.char-mini-name {
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.char-mini-group {
    font-size: 0.7rem;
}
img.avatar-aff {
    width: 56px;
    height: 56px;
    max-width: 56px;
    max-height: 56px;
    border-radius: 50%;
    border: 2px solid var(--current);
    object-fit: cover;
    flex-shrink: 0;
}
span.avatar-aff {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--current);
    font-size: 1.2rem;
    color: var(--comment);
}

/* === Connections page === */
.connections-page {
    display: flex;
    gap: 1rem;
    min-height: calc(100vh - 160px);
}
/* Full-bleed Connections: the flex column in layout.css hands this
   page the remaining viewport; children fill it exactly. */
.full-bleed .connections-page {
    flex: 1;
    min-height: 0;
}
.full-bleed .connections-graph-wrap { min-height: 0; }
.full-bleed .connections-graph { height: 100%; }
.full-bleed .connections-sidebar { max-height: 100%; }
/* The affiliations tab is a long list — it scrolls inside the locked
   viewport instead of growing the page */
.full-bleed #view-affiliations {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}
.connections-graph-wrap {
    flex: 1;
    position: relative;
    min-width: 0;
}
.connections-graph {
    width: 100%;
    height: calc(100vh - 160px);
    background: var(--bg-darker);
    border: 1px solid var(--current);
    border-radius: 10px;
    overflow: hidden;
}
.graph-layout-btn.active {
    background: var(--purple);
    color: var(--bg);
    border-color: var(--purple);
}
/* Fullscreen graph viewer */
.connections-graph-wrap:fullscreen {
    background: var(--bg-darker);
}
.connections-graph-wrap:fullscreen .connections-graph {
    height: 100vh;
    border: none;
    border-radius: 0;
}
.connections-sidebar {
    width: 340px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: calc(100vh - 160px);
    overflow-y: auto;
}
.graph-legend {
    position: absolute;
    bottom: 12px;
    left: 12px;
    background: rgba(40, 42, 54, 0.9);
    border: 1px solid var(--current);
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    font-size: 0.7rem;
    max-width: 350px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 10;
}
.legend-section { line-height: 1.8; }
.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    margin-right: 0.5rem;
    color: var(--fg);
    white-space: nowrap;
}
.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.legend-line {
    width: 14px;
    height: 3px;
    border-radius: 2px;
    flex-shrink: 0;
}
.rel-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.rel-form select, .rel-form input {
    background: var(--bg);
    border: 1px solid var(--current);
    border-radius: 6px;
    padding: 0.4rem 0.6rem;
    color: var(--fg);
    font-size: 0.85rem;
}
.rel-form select:focus, .rel-form input:focus {
    border-color: var(--purple);
    outline: none;
}
.relationship-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.relationship-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: 6px;
    font-size: 0.85rem;
    background: var(--bg);
    border: 1px solid var(--current);
}
.relationship-item:hover {
    border-color: var(--comment);
}
.rel-names {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.rel-names span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* Right-hand side of a relationship row: two aligned label columns
   (their side, your side) + action buttons, so rows line up instead of
   ragged badges floating in whitespace. */
.rel-side-group {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}
.rel-side-group .rel-badge {
    min-width: 8rem;
    text-align: center;
}
.rel-you-chip {
    display: inline-block;
    min-width: 9.5rem;
    text-align: center;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--comment);
    background: transparent;
    border: 1px dashed var(--current);
    flex-shrink: 0;
}
.rel-you-chip.filled {
    color: var(--fg);
    border-style: solid;
    border-color: var(--comment);
}

.rel-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    flex-shrink: 0;
}
.rel-badge-platonic { background: var(--green); color: var(--bg); }
.rel-badge-familial { background: var(--cyan); color: var(--bg); }
.rel-badge-romantic { background: var(--pink); color: var(--bg); }
.rel-badge-antagonistic { background: var(--red); color: var(--bg); }
.rel-badge-teammate { background: var(--orange); color: var(--bg); }
.rel-badge-other { background: var(--comment); color: var(--fg); }

/* === Responsive helpers === */
@media (max-width: 768px) {
    .hide-mobile { display: none !important; }
    .char-header { flex-direction: column; align-items: center; text-align: center; }
    .char-counts { justify-content: center; }
    .chart-row { grid-template-columns: 1fr; }
    .powergrid-inline { position: static; transform: none; width: 100%; max-width: 280px; }
    .char-actions { flex-direction: row; flex-wrap: wrap; justify-content: center; }
    .connections-page { flex-direction: column; }
    .connections-sidebar { width: 100%; max-height: none; }
    .connections-graph { height: 400px; }
    .affiliation-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
}

@media (min-width: 769px) {
    .hide-desktop { display: none !important; }
}
