:root {
    --bg: #f5f6fa;
    --bg-soft: #eef1f7;
    --panel: #ffffff;
    --panel-2: #f8f9fc;
    --text: #232a35;
    --muted: #6f7b8c;
    --border: #e5e9f2;
    --shadow: 0 10px 30px rgba(20, 31, 56, 0.08);
    --accent: #44c2ee;
    --accent-2: #6c7cff;
    --danger-soft: #fff1f1;
}

body[data-theme="dark"] {
    --bg: #111827;
    --bg-soft: #182132;
    --panel: #1b2433;
    --panel-2: #212c3d;
    --text: #edf2f7;
    --muted: #97a3b6;
    --border: #2a374c;
    --shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
    --accent: #44c2ee;
    --accent-2: #7d88ff;
    --danger-soft: #2d1f27;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    transition: background 0.2s ease, color 0.2s ease;
    overflow-x: hidden;
}

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 280px;
    background: var(--panel);
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 30;
}

.sidebar-inner {
    padding: 24px 18px;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.brand-box {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 28px;
}

.brand-logo {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: white;
    display: grid;
    place-items: center;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.brand-title {
    font-size: 1.25rem;
    margin: 0;
    font-weight: 800;
}

.brand-subtitle {
    color: var(--muted);
    font-size: 0.9rem;
}

.nav-links .nav-link {
    color: var(--text);
    border-radius: 14px;
    padding: 12px 14px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
}

.nav-links .nav-link:hover,
.nav-links .nav-link.active {
    background: var(--panel-2);
}

.sidebar-footer {
    margin-top: auto;
}

.btn-theme,
.btn-icon,
.btn-close-panel {
    border: 0;
    background: var(--panel-2);
    color: var(--text);
    border-radius: 14px;
    padding: 12px 14px;
}

.btn-theme:hover,
.btn-icon:hover,
.btn-close-panel:hover {
    opacity: 0.92;
}

.main-area {
    flex: 1;
    padding: 24px;
    min-width: 0;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    margin-bottom: 22px;
}

.station-scope-top {
    min-width: 210px;
    max-width: 280px;
}

.topbar-right {
    align-items: flex-start !important;
}

.station-scope-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 220px;
}

.station-scope-hint {
    font-size: 0.78rem;
    color: var(--muted);
    line-height: 1.25;
    max-width: 320px;
}

.scope-debug {
    font-size: 0.82rem;
    margin-top: 0.35rem;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 800;
}

.page-subtitle,
.last-updated,
.muted {
    color: var(--muted);
}

.content-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.8fr) 320px;
    gap: 22px;
    align-items: start;
    min-width: 0;
}

.stats-row {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 20px;
}

.main-column,
.right-column {
    display: flex;
    flex-direction: column;
    gap: 22px;
    min-width: 0;
}

.panel,
.stat-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: var(--shadow);
}

.panel {
    padding: 22px;
    min-width: 0;
}

.stat-card {
    padding: 24px;
    color: white;
    min-height: 155px;
    position: relative;
    overflow: hidden;
}

.gradient-petrol {
    background: linear-gradient(135deg, #27c6a8, #58d8d0);
}

.gradient-diesel {
    background: linear-gradient(135deg, #6a7cff, #58a7f8);
}

.gradient-premium-petrol {
    background: linear-gradient(135deg, #f59e0b, #f7c948);
    color: #1f2937;
}

.gradient-premium-diesel {
    background: linear-gradient(135deg, #a855f7, #ec4899);
    color: #ffffff;
}

.gradient-premium-petrol .stat-meta {
    color: rgba(17, 24, 39, 0.85);
}

.stat-label {
    font-size: 1rem;
    font-weight: 700;
    opacity: 0.96;
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    margin-top: 14px;
}

.stat-meta {
    margin-top: 10px;
    opacity: 0.92;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    gap: 12px;
}

.panel-header h3,
.welcome-panel h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 800;
}

.custom-table {
    color: var(--text);
    margin: 0;
}

.custom-table th {
    color: var(--muted);
    font-weight: 700;
    border-bottom-color: var(--border);
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--panel);
}

.custom-table td {
    border-bottom-color: var(--border);
    background: transparent !important;
    color: var(--text);
}

.custom-table tbody tr.station-row {
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.15s ease;
}

.custom-table tbody tr.station-row:hover {
    background: rgba(68, 194, 238, 0.10) !important;
}

.station-name {
    font-weight: 700;
    line-height: 1.2;
}

.station-town {
    font-size: 0.82rem;
    color: var(--muted);
    margin-top: 2px;
}

.postcode-pill,
.fuel-pill {
    display: inline-block;
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 0.8rem;
    font-weight: 600;
}

.postcode-pill {
    background: rgba(108, 124, 255, 0.14);
    color: var(--text);
}

.fuel-pill {
    background: rgba(68, 194, 238, 0.14);
    color: var(--text);
}

.price-cell {
    font-weight: 700;
}

.stack-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.stack-item {
    background: var(--panel-2);
    border-radius: 18px;
    padding: 14px 16px;
}

.stack-item h4 {
    margin: 0 0 6px;
    font-size: 1rem;
    font-weight: 700;
}

.stack-item p {
    margin: 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.expensive-item {
    border: 1px solid rgba(239, 68, 68, 0.18);
    background: linear-gradient(180deg, rgba(239, 68, 68, 0.06), var(--panel-2));
}

.expensive-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.expensive-fuel {
    background: rgba(239, 68, 68, 0.14);
}

.expensive-price {
    font-size: 1.08rem;
    font-weight: 800;
    color: var(--text);
}

.expensive-location {
    margin-top: 2px;
    font-weight: 600;
}

.expensive-above {
    margin-top: 8px !important;
    color: #ef4444 !important;
    font-weight: 700;
}

.ad-box,
.chat-preview {
    background: var(--panel-2);
    border-radius: 18px;
    padding: 18px;
}

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

.local-business-card {
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--panel-2);
    overflow: hidden;
}

.local-business-card.is-sponsor {
    border-color: rgba(245, 158, 11, 0.45);
    box-shadow: 0 6px 18px rgba(245, 158, 11, 0.16);
}

.local-business-image {
    width: 100%;
    height: 120px;
    object-fit: cover;
    display: block;
}

.local-business-body {
    padding: 10px 12px 12px;
}

.local-business-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
}

.local-business-head h4 {
    margin: 0;
    font-size: 0.98rem;
    font-weight: 700;
}

.local-business-badge {
    display: inline-flex;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    color: #78350f;
    background: rgba(245, 158, 11, 0.22);
}

.local-business-summary {
    margin: 8px 0 10px;
    color: var(--muted);
    font-size: 0.88rem;
}

.local-business-link {
    font-weight: 600;
    text-decoration: none;
}

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

.home-blog-item {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--panel-2);
    padding: 10px;
}

.home-blog-item-image {
    width: 100%;
    height: 100px;
    object-fit: cover;
    border-radius: 10px;
    margin-bottom: 8px;
}

.home-blog-item-title {
    margin: 0 0 6px;
    font-size: 0.95rem;
    font-weight: 700;
}

.home-blog-item-excerpt {
    margin: 0 0 6px;
    color: var(--muted);
    font-size: 0.86rem;
}

.blog-card {
    padding: 18px;
}

.blog-card-image {
    width: 100%;
    height: 220px;
    object-fit: cover;
    border-radius: 14px;
    margin-bottom: 12px;
    display: block;
    max-width: 100%;
}

/* Safety fallback for older blog markup/classes to prevent giant images. */
.blog-list-item img,
.blog-post img,
.blog-card img {
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: 420px;
    object-fit: cover;
    display: block;
}

.blog-card-title {
    margin: 0 0 8px;
    font-size: 1.26rem;
    font-weight: 800;
    line-height: 1.25;
}

.blog-card-subtitle {
    margin: 0 0 10px;
    color: var(--muted);
    font-size: 1rem;
}

.sidebar-backdrop {
    display: none;
}

.chart-panel {
    overflow: hidden;
}

.chart-wrap {
    position: relative;
    height: 360px;
    width: 100%;
}

.station-map {
    height: 340px;
    width: 100%;
    border-radius: 16px;
    border: 1px solid var(--border);
    overflow: hidden;
    margin-bottom: 16px;
    background: var(--panel-2);
}

.station-controls {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) 220px auto;
    gap: 10px 12px;
    margin-bottom: 12px;
}

.station-search,
.station-sort {
    border-radius: 12px;
    border-color: var(--border);
    background: var(--panel);
    color: var(--text);
}

.station-reset-btn {
    height: 38px;
    white-space: nowrap;
}

.station-filters {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    font-size: 0.86rem;
    color: var(--muted);
}

.source-legend {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    align-items: center;
}

.source-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 0.82rem;
}

.station-filters label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--panel-2);
    border-radius: 999px;
    padding: 4px 10px;
    border: 1px solid var(--border);
}

.nearby-panel {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 10px 12px;
    margin-bottom: 12px;
    background: var(--panel-2);
}

.nearby-controls {
    display: grid;
    grid-template-columns: auto minmax(240px, 1fr) minmax(170px, 230px);
    gap: 10px;
    align-items: center;
}

.nearby-btn {
    white-space: nowrap;
    height: 38px;
    padding: 7px 12px;
}

.nearby-manual {
    display: flex;
    gap: 8px;
    min-width: 0;
    width: 100%;
}

.nearby-postcode {
    border-radius: 12px;
    height: 38px;
    flex: 1 1 auto;
    min-width: 0;
}

.nearby-fuel {
    width: 100%;
    max-width: 230px;
    border-radius: 12px;
    height: 38px;
}

.nearby-results {
    margin-top: 8px;
    font-size: 0.9rem;
}

.freshness-badge {
    display: inline-block;
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 0.75rem;
    font-weight: 700;
    margin-right: 6px;
}

.freshness-fresh {
    background: rgba(34, 197, 94, 0.16);
    color: #15803d;
}

.freshness-warn {
    background: rgba(245, 158, 11, 0.18);
    color: #b45309;
}

.freshness-stale {
    background: rgba(239, 68, 68, 0.16);
    color: #dc2626;
}

.trend-up {
    color: #dc2626;
    font-weight: 700;
}

.trend-down {
    color: #16a34a;
    font-weight: 700;
}

.trend-flat {
    color: var(--muted);
    font-weight: 700;
}

.watchlist-builder {
    display: grid;
    gap: 8px;
    margin-bottom: 10px;
}

.watchlist-select,
.watchlist-target {
    border-radius: 12px;
}

.watchlist-target-wrap {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
}

.watchlist-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.watchlist-item {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px 10px;
    background: var(--panel-2);
}

.watchlist-item.met {
    border-color: rgba(34, 197, 94, 0.45);
    background: rgba(34, 197, 94, 0.10);
}

.watchlist-item .top {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.86rem;
}

.watchlist-item button {
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 0.8rem;
    text-decoration: underline;
}

.watchlist-notice {
    margin-top: 8px;
    font-size: 0.84rem;
}

.station-map .leaflet-popup-content {
    margin: 10px 12px;
}

.station-map .leaflet-popup-content strong {
    display: block;
    margin-bottom: 4px;
}

.station-map .leaflet-container {
    background: #dbe5f0;
}

.station-map .leaflet-tile {
    outline: 1px solid transparent;
    backface-visibility: hidden;
    width: 257px !important;
    height: 257px !important;
    margin-left: -0.5px;
    margin-top: -0.5px;
}

.map-panel .table-responsive {
    max-height: 420px;
    overflow-y: auto;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--panel);
    width: 100%;
    min-width: 0;
    -webkit-overflow-scrolling: touch;
}

.map-panel .custom-table th,
.map-panel .custom-table td {
    white-space: nowrap;
}

.sortable-header {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 18px !important;
}

.sortable-header::after {
    content: "↕";
    font-size: 0.72rem;
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
}

.sortable-header.sort-asc::after {
    content: "▲";
    color: var(--text);
}

.sortable-header.sort-desc::after {
    content: "▼";
    color: var(--text);
}

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

    .right-column {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 22px;
    }

    .stats-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 991px) {
    .sidebar {
        position: fixed;
        left: -300px;
        transition: left 0.25s ease;
    }

    .sidebar.open {
        left: 0;
    }

    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.35);
        opacity: 0;
        visibility: hidden;
        transition: all 0.2s ease;
        z-index: 20;
    }

    .sidebar-backdrop.show {
        opacity: 1;
        visibility: visible;
    }

    .main-area {
        padding: 18px;
    }

    .stats-row,
    .right-column {
        grid-template-columns: 1fr;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar-right {
        width: 100%;
        justify-content: flex-start !important;
        gap: 0.75rem !important;
    }

    .topbar-right .kf-user-chrome {
        order: 1;
    }

    .topbar-right .station-scope-wrap {
        order: 2;
        width: 100%;
        max-width: 100%;
    }

    .topbar-right .station-scope-top {
        min-width: 0;
        max-width: 100%;
        width: 100%;
    }

    .topbar-right .last-updated {
        order: 3;
    }

    .chart-wrap {
        height: 280px;
    }

    .station-controls {
        grid-template-columns: 1fr;
    }

    .nearby-controls {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .nearby-fuel {
        max-width: 100%;
    }

    .nearby-manual {
        display: grid;
        grid-template-columns: 1fr auto;
        min-width: 0;
        width: 100%;
    }
}

/* Inner pages + community chat */
.brand-box-link {
    display: block;
    color: inherit;
}

.brand-box-link:hover {
    color: inherit;
    opacity: 0.92;
}

.content-grid--page {
    display: block;
    max-width: 980px;
    margin: 0 auto;
    width: 100%;
    padding: 0 4px 48px;
}

.content-grid.content-grid--page.content-grid--community {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 360px);
    gap: 22px;
    align-items: start;
    max-width: 1440px;
}

@media (max-width: 991px) {
    .content-grid.content-grid--page.content-grid--community {
        grid-template-columns: 1fr;
    }
}

.community-main-col,
.community-side-col {
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-width: 0;
}

.community-featured-title {
    font-weight: 700;
}

.community-featured-title:hover {
    text-decoration: underline;
}

.community-featured-excerpt {
    color: var(--muted);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.community-news-list {
    padding: 0;
}

.community-news-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.community-news-item:last-child {
    border-bottom: 0;
}

.community-news-link {
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    display: block;
}

.community-news-link:hover {
    color: var(--text);
    text-decoration: underline;
}

.community-news-date {
    display: block;
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 4px;
}

.community-content-panel .panel-header {
    margin-bottom: 12px;
}

.community-content-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

@media (min-width: 992px) {
    .community-content-cards--blog {
        grid-template-columns: 1fr;
    }
    .community-content-cards--news {
        grid-template-columns: 1fr;
    }
}

.community-content-card {
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--panel-2);
    padding: 12px 12px;
}

.community-content-card:hover {
    border-color: rgba(68, 194, 238, 0.6);
}

.community-content-card-title {
    font-weight: 800;
    margin-bottom: 2px;
}

.community-content-card-excerpt {
    color: var(--muted);
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.community-content-card-date {
    margin-bottom: 6px;
}

.community-stats-dl {
    margin: 0;
}

.community-stat-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
}

.community-stat-row:last-child {
    border-bottom: 0;
}

.community-stat-row dt {
    margin: 0;
    color: var(--muted);
    font-weight: 500;
}

.community-stat-row dd {
    margin: 0;
    font-weight: 700;
    text-align: right;
}

.community-stat-row--block {
    flex-direction: column;
    align-items: flex-start;
}

.community-stat-row--block dd {
    text-align: left;
    width: 100%;
}

.community-chat-lead {
    max-width: 62ch;
}

.community-chat-body::placeholder {
    opacity: 0.7;
}

.community-chat-form--full .community-chat-body {
    border-radius: 10px;
    padding: 14px 20px;
    min-height: 56px;
    resize: vertical;
    max-height: 320px;
    font-size: 1rem;
    background: var(--panel);
}

.community-chat-form--full .community-chat-actions {
    justify-content: flex-end;
}

.community-chat-controls {
    margin-bottom: 10px;
}

.community-chat-pinned {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--panel-2);
    padding: 10px 12px;
    margin-bottom: 10px;
}

.community-chat-pinned-title {
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 8px;
}

.community-chat-pinned-item + .community-chat-pinned-item {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.community-chat-pinned-body {
    margin-top: 2px;
}

.community-msg--rich {
    display: grid;
    grid-template-columns: minmax(110px, 170px) minmax(0, 1fr);
    gap: 14px 18px;
    align-items: start;
    padding: 0;
    border: 0;
    background: transparent;
    margin-bottom: 14px;
}

.community-chat-list--full .community-msg--rich {
    border-bottom: 1px solid var(--border);
    padding-bottom: 14px;
    margin-bottom: 0;
}

.community-chat-list--full .community-msg--rich:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.community-msg--pinned .community-msg-body--bubble {
    border-color: rgba(238, 181, 26, 0.45);
    box-shadow: 0 0 0 1px rgba(238, 181, 26, 0.15) inset;
}

.community-msg-aside {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 10px 10px;
    background: var(--panel);
    text-align: center;
}

body[data-theme="dark"] .community-msg-aside {
    background: var(--panel);
}

.community-msg-avatar-wrap {
    flex-shrink: 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.community-msg-avatar-img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.community-msg-avatar-ph {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 0.95rem;
    color: white;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.community-msg-who {
    min-width: 0;
}

.community-msg-name-link {
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.community-msg-name-link:hover {
    text-decoration: underline;
}

.community-msg-name-link--guest {
    color: var(--text);
}

.community-msg-tag {
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    margin-top: 6px;
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--panel);
}

.community-msg-tag--guest {
    color: var(--muted);
}

.community-msg-tag--member {
    color: var(--text);
    border-color: rgba(68, 194, 238, 0.35);
    background: rgba(68, 194, 238, 0.07);
}

.community-msg-tag--staff {
    color: #fff;
    border-color: rgba(225, 29, 72, 0.55);
    background: rgba(225, 29, 72, 0.85);
}

.community-msg-main {
    min-width: 0;
    padding: 0;
}

.community-msg-body--bubble {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    background: var(--panel);
}

.community-msg-below {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-left: 2px;
    padding-right: 2px;
}

.community-msg-time {
    font-size: 0.85rem;
}

.community-msg-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-start;
}

.community-msg-reactions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
    margin-top: 8px;
}

.community-msg-admin {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.community-msg-admin-btn {
    border-radius: 999px;
}

.community-msg-admin-menu {
    position: absolute;
    left: auto;
    right: 0;
    top: calc(100% + 6px);
    z-index: 20;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 8px;
    min-width: 170px;
    box-shadow: var(--shadow);
    max-width: 220px;
}

.community-msg-admin-menu button {
    width: 100%;
    white-space: nowrap;
    margin-bottom: 6px;
}

.community-msg-admin-menu button:last-child {
    margin-bottom: 0;
}

@media (max-width: 520px) {
    .community-msg-admin-menu {
        left: 0;
        right: auto;
    }
}

.community-msg-like {
    border-radius: 999px;
    padding: 4px 10px;
    line-height: 1.2;
}

.community-msg-like--on {
    color: #e11d48;
    border-color: rgba(225, 29, 72, 0.45);
    background: var(--danger-soft);
}

.community-msg-like-count {
    font-size: 0.8rem;
    margin-left: 2px;
}

@media (max-width: 620px) {
    .community-msg--rich {
        grid-template-columns: 1fr;
    }

    .community-msg-side {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        text-align: left;
    }

    .community-msg-reactions {
        justify-content: flex-start;
    }
}

.page-stack {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.announcement-toasts {
    display: grid;
    gap: 10px;
    margin-bottom: 4px;
}

.announcement-toast {
    border: 1px solid rgba(56, 189, 248, 0.35);
    background: linear-gradient(180deg, rgba(56, 189, 248, 0.08), rgba(56, 189, 248, 0.04));
    border-radius: 12px;
    padding: 10px 12px;
}

.announcement-toast-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.announcement-toast-body {
    font-size: 0.92rem;
    line-height: 1.45;
}

.page-stack--auth {
    max-width: 460px;
    margin: 0 auto;
    width: 100%;
}

.auth-panel {
    padding: 28px 26px;
}

.auth-panel-head {
    text-align: center;
}

.auth-panel-icon {
    font-size: 2rem;
    color: var(--accent);
}

body[data-theme="dark"] .auth-panel-icon {
    color: var(--accent-2);
}

.auth-panel-form .btn-link {
    text-decoration: none;
}

.sidebar-account {
    margin: 10px 0 18px;
    padding-top: 4px;
    border-top: 1px solid var(--border);
}

.sidebar-account-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.sidebar-account-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1 1 120px;
    padding: 6px 10px;
    border-radius: 14px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    color: var(--text);
    font-weight: 600;
    font-size: 0.9rem;
}

.sidebar-account-chip:hover {
    color: var(--text);
    opacity: 0.95;
}

.sidebar-account-name {
    min-width: 0;
}

.sidebar-account-out {
    flex: 0 0 auto;
}

.kf-user-chrome .btn-sm {
    border-radius: 12px;
}

.kf-auth-signin,
.kf-auth-signup {
    font-weight: 600;
    border-radius: 12px;
    border-width: 1px;
}

.kf-auth-signin {
    background: #e8f2ff;
    border-color: #8fb8ff;
    color: #184b9b;
}

.kf-auth-signin:hover {
    background: #dbeaff;
    border-color: #7aa9fb;
    color: #123e83;
}

.kf-auth-signup {
    background: linear-gradient(135deg, #26c6a7, #44c2ee);
    border-color: transparent;
    color: #ffffff;
}

.kf-auth-signup:hover {
    background: linear-gradient(135deg, #20b597, #3bb2dc);
    color: #ffffff;
}

.kf-user-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px 4px 4px;
    border-radius: 999px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    color: var(--text);
    max-width: min(260px, 56vw);
}

.kf-user-chip:hover {
    color: var(--text);
    opacity: 0.96;
}

.kf-user-avatar-img {
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.kf-user-avatar-img--sm {
    width: 32px;
    height: 32px;
}

.kf-user-avatar-ph {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: white;
    font-weight: 700;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.kf-user-avatar-ph--sm {
    width: 32px;
    height: 32px;
    font-size: 0.85rem;
}

.kf-user-label {
    font-weight: 600;
    font-size: 0.95rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.community-chat-root {
    min-height: 0;
}

.community-chat-widget {
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--panel-2);
    padding: 12px;
}

/* Ensure the scrollable message list itself is pure white (not grey). */
.community-chat-list--full,
.community-chat-list--compact {
    background: var(--panel);
}

body[data-theme="dark"] .community-chat-list--full,
body[data-theme="dark"] .community-chat-list--compact {
    background: var(--panel);
}

.community-soft-panel {
    box-shadow: none !important;
    background: var(--panel) !important;
    border-radius: 20px !important;
    padding: 18px !important;
}

.community-soft-panel .panel-header {
    margin-bottom: 12px;
}

.community-chat-header a {
    font-weight: 600;
}

.community-chat-card-title {
    font-weight: 800;
    letter-spacing: 0.2px;
}

.community-chat-footer {
    padding: 12px 4px 2px;
    border-top: 1px solid var(--border);
}

.community-chat-footer .community-chat-signin {
    background: var(--panel-2);
    border-color: var(--border);
}

.community-chat-footer .community-chat-signout {
    background: var(--panel-2);
    border-color: var(--border);
}

.community-chat-posting {
    font-weight: 600;
}

.community-chat-footer .btn {
    border-radius: 10px;
    padding-left: 16px;
    padding-right: 16px;
}

.community-chat-list {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--panel);
    padding: 12px;
    margin-bottom: 12px;
}

.community-chat-list--compact {
    max-height: 240px;
    overflow-y: auto;
}

.community-chat-list--full {
    max-height: min(72vh, 720px);
    overflow-y: auto;
}

.community-msg {
    padding: 8px 10px;
    border-radius: 10px;
    margin-bottom: 6px;
    background: var(--panel);
    border: 1px solid var(--border);
}

/* Rich rows are styled with their own internal boxes (identity + message bubble).
   Override the generic `.community-msg` “card” so timestamp/actions sit in the list background. */
.community-chat-list--full .community-msg.community-msg--rich {
    background: transparent !important;
    border: 0 !important;
    padding: 0 !important;
    border-radius: 0 !important;
    margin-bottom: 14px;
}

.community-msg-meta {
    font-size: 0.93rem;
    margin-bottom: 4px;
}

.community-msg-body {
    font-size: 1rem;
    line-height: 1.45;
    word-break: break-word;
}

.community-chat-form .community-chat-fields {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 8px;
}

/* Profile page: replace inline styles so CSP can be tightened. */
.profile-avatar-placeholder--96 {
    width: 96px;
    height: 96px;
}

.profile-user-head-minwidth {
    min-width: 200px;
}

.community-chat-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.chart-wrap--trends {
    height: 420px;
}
