:root {
    --lm-primary: #5fb425;
    --lm-primary-dark: #4ca020;
    --lm-primary-light: #75c834;
    --lm-accent: #58ae24;
    --lm-accent-dark: #4ca020;
    --lm-surface: #f8fafc;
    --lm-card: #ffffff;
    --lm-text: #1a1a1a;
    --lm-muted: #707070;
    --lm-border: #dfe2e6;
    --lm-nav-bg: #ffffff;
    --lm-body-bg: #f1f5f9;
    --lm-shadow: 0 4px 24px rgba(95, 180, 37, 0.08);
    --lm-cal-select: #d4edbc;
    --lm-cal-weekend: #ec4445;

    --bs-primary: #5fb425;
    --bs-primary-rgb: 95, 180, 37;
    --bs-link-color: #5fb425;
    --bs-link-hover-color: #4ca020;
    --bs-body-font-family: 'Poppins', 'Segoe UI', system-ui, sans-serif;
    --bs-body-bg: #f1f5f9;
    --bs-body-color: #1a1a1a;
    --bs-border-color: #dfe2e6;
    --bs-border-radius: 0.5rem;
    --bs-border-radius-lg: 0.75rem;
}

[data-bs-theme="dark"] {
    --lm-surface: #1e293b;
    --lm-card: #0f172a;
    --lm-text: #f1f5f9;
    --lm-muted: #94a3b8;
    --lm-border: #334155;
    --lm-nav-bg: #0f172a;
    --lm-body-bg: #020617;
    --lm-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
    --lm-cal-select: #4ca020;
    --lm-cal-weekend: #fb7185;
    --bs-body-bg: #020617;
    --bs-body-color: #f1f5f9;
}

body.site-shell {
    background: var(--lm-body-bg);
    color: var(--lm-text);
    font-family: 'Poppins', 'Segoe UI', system-ui, sans-serif;
}

.lm-site-header,
#mainNavBar {
    background: var(--lm-nav-bg) !important;
    border-bottom: 1px solid var(--lm-border);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
    z-index: 1030;
}

.lm-brand-link {
    display: inline-flex;
    align-items: center;
    line-height: 0;
}

.lm-logo-img {
    display: block;
    height: auto;
    max-height: 42px;
    width: auto;
}

.lm-logo-footer {
    max-height: 36px;
}

.lm-brand-text {
    color: var(--lm-primary);
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: -0.02em;
}

.lm-brand {
    color: var(--lm-primary) !important;
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.02em;
}

.lm-brand span {
    color: var(--lm-accent);
}

.lm-nav-link {
    color: var(--lm-muted) !important;
    font-weight: 600;
    font-size: 0.88rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    border-radius: 0.35rem;
    transition: background .15s, color .15s;
}

.lm-nav-link:hover,
.lm-nav-link:focus {
    color: var(--lm-primary) !important;
    background: rgba(95, 180, 37, 0.08);
}

.lm-nav-link.active {
    color: #fff !important;
    background: var(--lm-primary);
}

#mainBody {
    background: var(--lm-body-bg);
}

.lm-card {
    background: var(--lm-card);
    border: 1px solid var(--lm-border);
    border-radius: 1rem;
    box-shadow: var(--lm-shadow);
}

.btn-lm-primary {
    background: var(--lm-primary);
    border-color: var(--lm-primary);
    color: #fff;
    font-weight: 600;
    border-radius: 0.35rem;
    transition: transform .15s, box-shadow .15s, background .15s;
}

.btn-lm-primary:hover {
    background: var(--lm-primary-dark);
    border-color: var(--lm-primary-dark);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(95, 180, 37, 0.35);
}

.btn-pe-add {
    background: #e85d4c;
    border: none;
    color: #fff;
    font-weight: 600;
    border-radius: 0.5rem;
    text-decoration: none;
}

.btn-pe-add:hover {
    background: #d44a3a;
    color: #fff;
}

.btn-lm-accent {
    background: var(--lm-accent);
    border-color: var(--lm-accent);
    color: #fff;
    font-weight: 600;
}

.btn-lm-accent:hover {
    background: var(--lm-accent-dark);
    border-color: var(--lm-accent-dark);
    color: #fff;
}

.btn-lm-outline {
    border-color: var(--lm-primary);
    color: var(--lm-primary);
    font-weight: 600;
}

.btn-lm-outline:hover {
    background: var(--lm-primary);
    color: #fff;
}

#Calendar {
    max-width: 360px;
    user-select: none;
}

.cal-weekdays,
.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

.cal-grid {
    gap: 3px;
}

.cal-widget {
    background: var(--lm-card);
    border: 1px solid var(--lm-border);
    border-radius: 1rem;
    box-shadow: var(--lm-shadow);
}

.cal-title,
.cal-nav {
    color: var(--lm-primary);
}

.cal-nav:hover {
    background: rgba(95, 180, 37, 0.08);
    color: var(--lm-primary-dark);
}

.cal-weekday {
    font-size: .72rem;
    color: var(--lm-muted);
    font-weight: 600;
}

.cal-cell {
    min-height: 40px;
    font-weight: 600;
    border-radius: .5rem;
    transition: background-color .12s, transform .1s;
    color: var(--lm-text);
}

.cal-cell.weekend:not(.other-month):not(.selected) {
    color: var(--lm-cal-weekend);
}

.cal-cell.other-month {
    color: var(--lm-muted);
    opacity: .5;
}

.cal-cell.today:not(.selected) {
    box-shadow: inset 0 0 0 2px var(--lm-accent);
}

.cal-cell:hover:not(.selected) {
    background: rgba(95, 180, 37, 0.08);
}

.cal-cell.selected {
    background: var(--lm-cal-select) !important;
    color: var(--lm-primary-dark);
}

.cal-cell.selected:hover {
    background: var(--lm-primary-light) !important;
    color: #fff;
}

.cal-dow-cell.selected {
    background: var(--lm-cal-select);
    border-color: var(--lm-primary) !important;
}

/* Availability input grid */
.avail-scroll {
    max-height: 420px;
    overflow: auto;
    border: 1px solid var(--lm-border);
    border-radius: .75rem;
    background: var(--lm-card);
}

.avail-scroll table {
    border-collapse: separate;
    border-spacing: 0;
}

.avail-scroll thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--lm-card);
    box-shadow: 0 1px 0 var(--lm-border);
}

.avail-scroll tbody th {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--lm-card);
    box-shadow: 1px 0 0 var(--lm-border);
}

.avail-scroll thead th:first-child {
    left: 0;
    z-index: 3;
}

.time-grid td,
.time-grid th {
    border: 1px solid var(--lm-border);
    min-width: 36px;
    height: 32px;
    padding: 0;
    font-size: .72rem;
    font-weight: 600;
    text-align: center;
    vertical-align: middle;
}

.time-grid th {
    color: var(--lm-muted);
    cursor: default;
}

.time-grid td {
    cursor: pointer;
    transition: transform .08s, box-shadow .08s;
}

.time-grid td:hover {
    transform: scale(1.05);
    z-index: 1;
    position: relative;
}

/* Input grid: user's own selection */
.slot-available {
    background: var(--lm-primary) !important;
    color: #fff;
}

.slot-empty {
    background: var(--lm-surface);
}

/* Results heatmap: indigo scale — darker = more people */
.hm-0 { background: var(--lm-surface); color: var(--lm-muted); }
.hm-1 { background: #E0E7FF; color: var(--lm-text); }
.hm-2 { background: #A5B4FC; color: var(--lm-text); }
.hm-3 { background: #6366F1; color: #fff; }
.hm-4 { background: #4338CA; color: #fff; }
.hm-best {
    outline: 2px solid var(--lm-primary);
    outline-offset: -2px;
    box-shadow: 0 0 0 2px rgba(95, 180, 37, 0.35);
}

[data-bs-theme="dark"] .hm-0 { background: #334155; }
[data-bs-theme="dark"] .hm-1 { background: #312E81; }
[data-bs-theme="dark"] .hm-2 { background: #4338CA; }
[data-bs-theme="dark"] .hm-3 { background: #6366F1; }
[data-bs-theme="dark"] .hm-4 { background: #818CF8; color: #0F172A; }

.reveal {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity .5s, transform .5s;
}

.reveal.visible {
    opacity: 1;
    transform: none;
}

.lm-footer {
    background: var(--lm-card);
    border-top: 1px solid var(--lm-border);
    color: var(--lm-muted);
}

.lm-best-slot {
    border-left: 4px solid var(--lm-primary);
    background: rgba(95, 180, 37, 0.08);
}

.theme-toggle {
    border: 1px solid var(--lm-border);
    color: var(--lm-muted);
    background: transparent;
}

.theme-toggle:hover {
    border-color: var(--lm-primary);
    color: var(--lm-primary);
}

.copy-toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 1080;
    background: var(--lm-primary);
    color: #fff;
    padding: .75rem 1.25rem;
    border-radius: .5rem;
    box-shadow: var(--lm-shadow);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity .25s, transform .25s;
    pointer-events: none;
}

.copy-toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* Honeypot — invisible to users */
.hp-field {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

/* ── Event page ── */
.event-page {
    background: var(--lm-body-bg);
}

.event-sticky-top {
    z-index: 1030;
    background: var(--lm-body-bg);
}

.event-header {
    background: var(--lm-card);
    border-bottom: 1px solid var(--lm-border);
    box-shadow: var(--lm-shadow);
}

.event-tz-banner {
    background: rgba(95, 180, 37, 0.08);
    border-bottom: 1px solid var(--lm-border);
}

.event-logo {
    font-size: 1.1rem;
    white-space: nowrap;
}

.event-title {
    color: var(--lm-text);
}

.event-participant-badge {
    background: rgba(95, 180, 37, 0.12);
    color: var(--lm-primary);
    font-weight: 600;
    padding: .5rem .85rem;
}

.event-sidebar.sticky-lg-top {
    top: var(--lm-event-sticky-offset, 8rem);
    z-index: 1010;
    max-height: calc(100vh - var(--lm-event-sticky-offset, 8rem) - 1rem);
    overflow-y: auto;
}

.event-sidebar-inner .lm-card {
    border-radius: .75rem;
}

.event-participant-list {
    max-height: 220px;
    overflow-y: auto;
}

.event-participant-item {
    margin-bottom: .25rem;
}

.participant-btn {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem .65rem;
    border: 1px solid transparent;
    border-radius: .5rem;
    background: transparent;
    color: var(--lm-text);
    transition: background .15s, border-color .15s;
}

.participant-btn:hover,
.event-participant-item.active .participant-btn {
    background: rgba(95, 180, 37, 0.08);
    border-color: rgba(95, 180, 37, 0.2);
}

.participant-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.participant-name {
    flex: 1;
    min-width: 0;
    font-weight: 500;
    font-size: .875rem;
}

.participant-slots {
    font-size: .75rem;
    color: var(--lm-muted);
    font-weight: 600;
}

.event-legend li {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: .35rem;
}

.legend-swatch {
    width: 18px;
    height: 18px;
    border-radius: .25rem;
    flex-shrink: 0;
    border: 1px solid var(--lm-border);
}

.legend-mine { background: var(--lm-primary); }
.legend-hm-low { background: rgba(95, 180, 37, 0.12); }
.legend-hm-high { background: rgba(95, 180, 37, 0.88); }
.legend-best { background: var(--lm-surface); outline: 2px solid var(--lm-primary); }

[data-bs-theme="dark"] .legend-hm-low { background: rgba(95, 180, 37, 0.15); }
[data-bs-theme="dark"] .legend-hm-high { background: rgba(95, 180, 37, 0.85); }

.event-best-item {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .45rem 0;
    border-bottom: 1px solid var(--lm-border);
    font-size: .875rem;
}

.event-best-item:last-child { border-bottom: none; }

.best-rank {
    font-weight: 700;
    color: var(--lm-primary);
    min-width: 1.25rem;
}

.best-label { flex: 1; }

.event-stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .35rem 0;
    border-bottom: 1px solid var(--lm-border);
    font-size: .875rem;
}

.event-stat-row:last-child { border-bottom: none; }

.event-stat-row dt {
    color: var(--lm-muted);
    font-weight: 500;
}

.event-stat-row dd {
    margin: 0;
    font-weight: 700;
    color: var(--lm-text);
}

.event-grid-card {
    min-height: 400px;
}

.event-grid-scroll {
    max-height: min(70vh, 640px);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

.event-grid-table .grid-corner {
    min-width: 72px;
    position: sticky;
    left: 0;
    z-index: 4;
    background: var(--lm-card);
}

.event-grid-table .grid-date-header {
    min-width: 52px;
    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--lm-card);
    white-space: nowrap;
    padding: .5rem .35rem;
}

.event-grid-table .grid-time-label {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--lm-card);
    min-width: 72px;
    white-space: nowrap;
    padding: 0 .5rem;
    font-size: .68rem;
}

.event-grid-table td.grid-cell {
    min-width: 44px;
    height: 28px;
    padding: 0;
    cursor: pointer;
    position: relative;
    transition: background-color .15s, color .15s, box-shadow .1s;
    user-select: none;
    touch-action: none;
    background: var(--lm-surface);
}

.event-grid-table td.grid-cell:focus-visible {
    outline: 2px solid var(--lm-primary);
    outline-offset: -2px;
    z-index: 5;
}

.event-grid-table-mine td.grid-cell-mine.cell-selected {
    background: var(--lm-primary) !important;
    color: #fff;
}

.event-grid-table-heat td.grid-cell-heat {
    cursor: default;
}

.event-grid-table-heat td.grid-cell-heat.cell-highlight {
    box-shadow: inset 0 0 0 2px var(--lm-primary);
}

.cell-highlight {
    box-shadow: inset 0 0 0 2px var(--lm-primary);
}

.cell-best {
    outline: 2px solid var(--lm-primary);
    outline-offset: -2px;
}

.cell-dimmed {
    opacity: 0.25;
}

/* Legacy stepped heat classes — grid now uses inline rgba in event-grid.js */

.cell-count {
    font-size: .65rem;
    font-weight: 700;
    color: inherit;
    opacity: .85;
}

.event-offcanvas {
    --bs-offcanvas-width: min(340px, 90vw);
}

@media (max-width: 991.98px) {
    .event-grid-scroll { max-height: 55vh; }
    .event-grid-table .grid-date-header { min-width: 40px; font-size: .65rem; }
    .event-grid-table td.grid-cell { min-width: 36px; height: 32px; }
}

@media (max-width: 767.98px) {
    .lm-nav-link {
        text-transform: none;
    }
    .lm-nav-link.active {
        background: var(--lm-primary);
        color: #fff !important;
    }
    .cal-cell { min-height: 34px; font-size: .8rem; }
}
