:root {
    --bg: #f3eee4;
    --bg-2: #fffcf6;
    --forest: #3e5348;
    --forest-dark: #2f4038;
    --gold: #a6843d;
    --gold-soft: #c4a45c;
    --ink: #2c281f;
    --muted: #6d6558;
    --line: rgba(70, 55, 30, 0.12);
    --danger: #b04a4a;
    --ok: #3f7a52;
    --serif: "Cormorant Garamond", Georgia, serif;
    --sans: "Outfit", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--sans);
    background:
        radial-gradient(circle at top right, rgba(166, 132, 61, .12), transparent 32%),
        var(--bg);
    color: var(--ink);
    overflow-x: hidden;
}
a { color: #6b5424; text-decoration: none; }
a:hover { color: var(--gold); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; margin: 0; }
h1 { font-size: clamp(1.8rem, 3vw, 2.6rem); line-height: 1.05; }
h2 { font-size: 1.4rem; }
p { margin: 0; }
.muted { color: var(--muted); }
.eyebrow {
    text-transform: uppercase;
    letter-spacing: .24em;
    font-size: .68rem;
    color: var(--gold);
    margin-bottom: .4rem;
}

.shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
    background: var(--forest);
    color: #f4efe4;
    padding: 28px 20px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand, .login-brand {
    display: flex;
    gap: 12px;
    align-items: center;
    color: inherit;
    min-width: 0;
}
.brand strong, .login-brand strong {
    display: block;
    font-family: var(--serif);
    font-size: 1.3rem;
}
.brand small, .login-brand small {
    display: block;
    color: rgba(244, 239, 228, .7);
    font-size: .78rem;
}
.sidebar nav { margin-top: 32px; display: grid; gap: 4px; }
.sidebar nav a {
    display: grid;
    gap: 2px;
    padding: 11px 12px;
    border-radius: 12px;
    color: #f4efe4;
    border: 1px solid transparent;
    min-height: 44px;
}
.sidebar nav a em { font-style: normal; color: rgba(244, 239, 228, .65); font-size: .76rem; }
.sidebar nav a.is-active,
.sidebar nav a:hover {
    background: rgba(255, 255, 255, .08);
    border-color: rgba(196, 164, 92, .35);
    color: #fff;
}
.sidebar-foot { margin-top: auto; color: rgba(244, 239, 228, .7); font-size: .85rem; }
.sidebar-foot .linkish { color: rgba(244, 239, 228, .7); }
.sidebar-foot .linkish:hover { color: #fff; }
.main { padding: 32px 40px 56px; min-width: 0; }
.mobile-bar, .nav-scrim { display: none; }
.menu-toggle {
    border: 1px solid rgba(196, 164, 92, .45);
    background: rgba(255,255,255,.08);
    color: #f4efe4;
    border-radius: 999px;
    min-height: 44px;
    padding: 0 16px;
    font: 500 0.92rem var(--sans);
    cursor: pointer;
}
.topbar {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: end;
    margin-bottom: 24px;
}
.day-nav, .search { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.btn {
    border: 0;
    cursor: pointer;
    border-radius: 999px;
    padding: 10px 18px;
    font: 500 0.92rem var(--sans);
}
.btn-gold { background: var(--gold); color: #fff; }
.btn-gold:hover { background: #8f7030; }
.btn-ghost {
    background: var(--bg-2);
    color: var(--ink);
    border: 1px solid var(--line);
}
.btn-ghost:hover { border-color: var(--gold); color: #6b5424; }
.linkish {
    background: none;
    border: 0;
    color: var(--muted);
    cursor: pointer;
    padding: 0;
    font: inherit;
}
.linkish:hover { color: var(--danger); }

.stats {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}
.stats div {
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 16px 18px;
    box-shadow: 0 8px 24px rgba(80, 60, 20, .04);
}
.stats b { display: block; font-family: var(--serif); font-size: 1.7rem; color: var(--forest); }
.stats span { color: var(--muted); font-size: .82rem; }

.bulletin {
    background: linear-gradient(180deg, #fffdf7, #f4ead0);
    color: #1c1710;
    border-radius: 24px;
    padding: 32px 36px 24px;
    box-shadow: 0 16px 40px rgba(80, 60, 20, .08);
    border: 1px solid rgba(166, 132, 61, .25);
    position: relative;
    min-width: 0;
}
.bulletin::before {
    content: "";
    position: absolute;
    inset: 10px;
    border: 1px solid rgba(140, 110, 48, .28);
    border-radius: 16px;
    pointer-events: none;
}
.bulletin header { margin-bottom: 16px; }
.bulletin header p {
    text-transform: uppercase;
    letter-spacing: .18em;
    font-size: .72rem;
    color: #7a6230;
}
.bulletin h2 { font-size: 2.1rem; }
.bulletin h3 {
    margin: 18px 0 8px;
    font-size: 1rem;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: #7a6230;
}
.bulletin ul { margin: 0; padding-left: 1.1rem; }
.bulletin li { margin: .3rem 0; font-family: var(--serif); font-size: 1.18rem; overflow-wrap: anywhere; }
.bulletin-empty { font-family: var(--serif); font-size: 1.3rem; font-style: italic; }
.bulletin footer { margin-top: 24px; display: flex; gap: 10px; }
.bulletin.compact { padding: 22px; }
.bulletin.compact h2 { font-size: 1.6rem; }

.upcoming { margin-top: 32px; }
.upcoming h2 { margin-bottom: 12px; }
.upcoming-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.upcoming-grid a {
    display: grid;
    gap: 6px;
    padding: 16px;
    border-radius: 16px;
    background: var(--bg-2);
    border: 1px solid var(--line);
    color: inherit;
    min-width: 0;
    box-shadow: 0 8px 24px rgba(80, 60, 20, .04);
}
.upcoming-grid em {
    color: var(--muted);
    font-style: normal;
    font-size: .9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.calendar-layout { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, .8fr); gap: 24px; align-items: start; }
.month {
    list-style: none;
    margin: 0;
    padding: 16px;
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 8px;
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-radius: 20px;
}
.month .wd { color: var(--gold); font-size: .75rem; letter-spacing: .12em; text-align: center; }
.month a, .month .pad {
    min-height: 60px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 8px;
    color: inherit;
    border: 1px solid transparent;
}
.month a:hover, .month a.is-selected { border-color: var(--gold); background: rgba(166, 132, 61, .08); }
.month a.is-today span { color: var(--gold); font-weight: 600; }
.month i { display: flex; gap: 4px; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: block; background: var(--gold); }
.dot-spouse { background: #b36d96; }
.dot-family { background: #4e8a62; }
.dot-wedding { background: #c4a45c; }
.dot-degree, .dot-masonic { background: #5d7fa8; }
.dot-paramasonic { background: #8a6aa8; }
.dot-civil { background: #8a7a58; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 16px; max-width: 100%; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; background: var(--bg-2); }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--gold); font-weight: 500; font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; }
td { overflow-wrap: break-word; }
.nowrap { white-space: nowrap; }

.cards, .split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; margin-bottom: 18px; }
.card {
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 22px;
    min-width: 0;
    box-shadow: 0 8px 24px rgba(80, 60, 20, .04);
}
.card h2 { margin-bottom: 14px; }
.card h3 { margin: 18px 0 10px; color: var(--gold); font-size: 1rem; letter-spacing: .08em; text-transform: uppercase; }
.stack { display: grid; gap: 14px; }
.row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
label { display: grid; gap: 6px; color: var(--muted); font-size: .88rem; min-width: 0; }
input, select, textarea {
    width: 100%;
    max-width: 100%;
    background: #fff;
    border: 1px solid var(--line);
    color: var(--ink);
    border-radius: 10px;
    padding: 12px;
    font: inherit;
    font-size: 16px;
}
.dates-browser { overflow: hidden; }
.dates-toolbar { display: grid; gap: 14px; margin-bottom: 16px; }
.month-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.month-pills a {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    padding: 7px 11px;
    border-radius: 999px;
    background: #fff;
    border: 1px solid var(--line);
    color: var(--ink);
    font-size: .85rem;
}
.month-pills a small { color: var(--muted); font-size: .72rem; }
.month-pills a.is-active {
    background: var(--forest);
    border-color: var(--forest);
    color: #fff;
}
.month-pills a.is-active small { color: rgba(255,255,255,.75); }
.dates-filter { justify-content: flex-start; }
.dates-filter input[type="search"] { width: min(240px, 100%); }
.dates-table td:nth-child(2) { width: 70%; }
.dates-filter-card { margin-bottom: 20px; display: grid; gap: 16px; }
.half-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.half-pick {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    cursor: pointer;
}
.half-pick input { width: auto; }
.half-pick.is-active {
    background: var(--forest);
    border-color: var(--forest);
    color: #fff;
}
.type-picks {
    border: 0;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
    align-items: center;
}
.type-picks legend {
    padding: 0;
    margin-right: 8px;
    color: var(--muted);
    font-size: .88rem;
}
.check {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--ink);
    font-size: .95rem;
}
.check input { width: auto; }
.dates-filter-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.dates-count { margin-bottom: 16px; }
.session-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 26px; }
.session-day h2 { font-size: 1.35rem; margin-bottom: 8px; }
.session-day h3 {
    margin: 14px 0 6px;
    font-size: .92rem;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--gold);
}
.session-day ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.session-day li { overflow-wrap: anywhere; }
.session-title { overflow-wrap: anywhere; }
.report { background: var(--bg-2); border: 1px solid var(--line); border-radius: 20px; padding: 28px 32px 40px; box-shadow: 0 8px 24px rgba(80, 60, 20, .04); }
.report-head { margin-bottom: 28px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.report-head p { text-transform: uppercase; letter-spacing: .16em; font-size: .72rem; color: var(--gold); }
.report-head h1 { font-size: 2.2rem; }
.report-month { margin-top: 36px; }
.report-month:first-of-type { margin-top: 0; }
.report-month > h2 {
    font-size: 1.8rem;
    margin-bottom: 14px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--line);
    color: var(--forest);
}
.report .session-day h3 {
    font-size: 1.35rem;
    margin: 0 0 8px;
    letter-spacing: 0;
    text-transform: none;
    color: var(--ink);
}

.modal {
    border: 0;
    border-radius: 20px;
    padding: 0;
    width: min(520px, calc(100vw - 32px));
    background: var(--bg-2);
    color: var(--ink);
    box-shadow: 0 24px 60px rgba(40, 30, 10, .18);
}
.modal::backdrop { background: rgba(40, 32, 20, .45); }
.modal form { padding: 24px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.pill {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: .75rem;
    background: #eee8dc;
}
.pill-masonic { background: #e4edd8; color: #35553d; }
.pill-paramasonic { background: #ebe4f3; color: #5a3f72; }
.pill-civil { background: #f0ead8; color: #6b5424; }

.drop {
    border: 1px dashed var(--line);
    border-radius: 14px;
    padding: 16px;
    background: #faf7f0;
}
.hint { font-size: .86rem; color: var(--muted); line-height: 1.5; }
.plain, .history { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.history li {
    display: grid;
    gap: 4px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
    min-width: 0;
}
.history span, .history em { color: var(--muted); font-size: .86rem; font-style: normal; overflow-wrap: anywhere; }
dl { display: grid; gap: 10px; margin: 0; }
dt { color: var(--muted); font-size: .8rem; }
dd { margin: 0; font-family: var(--serif); font-size: 1.25rem; overflow-wrap: anywhere; }

.flash {
    margin-bottom: 18px;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: #fff;
}
.flash-ok { background: #eaf4ec; }
.flash-err { background: #f8eaea; color: #7a2e2e; }
.empty-cta {
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 32px;
    max-width: 640px;
}
.empty-cta h2 { margin-bottom: 10px; }
.empty-cta p { color: var(--muted); margin-bottom: 18px; }

.login-wrap {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at 20% 10%, rgba(166, 132, 61, .18), transparent 36%),
        #eae3d4;
}
.login-card {
    width: min(460px, 100%);
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-radius: 24px;
    padding: 36px;
    box-shadow: 0 20px 50px rgba(80, 60, 20, .08);
}
.login-card h1 { margin: 24px 0 8px; }
.login-brand { color: var(--ink); }
.login-brand small { color: var(--muted) !important; }
.lede { color: var(--muted); margin-bottom: 22px; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    border: 0;
}

@media (max-width: 980px) {
    .shell { grid-template-columns: 1fr; }
    .mobile-bar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        position: sticky;
        top: 0;
        z-index: 60;
        padding: 12px 16px;
        padding-top: max(12px, env(safe-area-inset-top));
        background: var(--forest);
        color: #f4efe4;
    }
    .mobile-bar .brand { min-width: 0; }
    .mobile-bar .brand strong { font-size: 1.15rem; }
    .sidebar-brand { display: none; }
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 50;
        width: min(300px, 88vw);
        height: 100%;
        height: 100dvh;
        transform: translateX(-105%);
        transition: transform .2s ease;
        padding-top: 72px;
        padding-bottom: max(20px, env(safe-area-inset-bottom));
        box-shadow: none;
    }
    body.nav-open { overflow: hidden; }
    body.nav-open .sidebar { transform: none; box-shadow: 16px 0 40px rgba(20, 24, 18, .28); }
    .nav-scrim {
        display: none;
        position: fixed;
        inset: 0;
        z-index: 45;
        border: 0;
        padding: 0;
        background: rgba(28, 24, 18, .45);
        cursor: pointer;
    }
    body.nav-open .nav-scrim { display: block; }
    .main {
        padding: 18px 16px 40px;
        padding-bottom: max(40px, env(safe-area-inset-bottom));
    }
    .topbar {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
        margin-bottom: 18px;
    }
    .day-nav, .search { width: 100%; }
    .day-nav .btn, .search .btn { flex: 1 1 7.2rem; text-align: center; min-height: 44px; }
    .btn { min-height: 44px; }
    .search { align-items: stretch; }
    .search input { min-height: 44px; }
    .calendar-layout, .cards, .split, .row { grid-template-columns: 1fr; }
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stats div { padding: 14px; }
    .bulletin { padding: 22px 18px 18px; }
    .bulletin h2 { font-size: 1.55rem; }
    .bulletin li { font-size: 1.05rem; }
    .bulletin footer { flex-wrap: wrap; }
    .bulletin footer .btn { flex: 1; }
    .month { padding: 10px; gap: 4px; }
    .month a, .month .pad { min-height: 44px; padding: 6px 4px; }
    .dates-filter { flex-direction: column; align-items: stretch; }
    .dates-filter input[type="search"] { width: 100%; }
    .month-pills { gap: 8px; }
    .month-pills a, .half-pick { min-height: 40px; }
    .report { padding: 18px 16px 28px; }
    .report-head h1 { font-size: 1.7rem; }
    .login-wrap { padding: 20px 16px; padding-bottom: max(20px, env(safe-area-inset-bottom)); }
    .login-card { padding: 24px 20px; }
    .login-card h1 { font-size: 1.8rem; }
    .modal { width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow: auto; }
    .check { min-height: 40px; }
    .table-wrap table { min-width: 640px; }
}

@media (max-width: 640px) {
    h1 { font-size: 1.7rem; }
    .upcoming-grid { grid-template-columns: 1fr; }
    .type-picks { gap: 8px 12px; }
}
@media print {
    @page { margin: 14mm 16mm; }
    body { background: #fff; color: #111; }
    .no-print, .sidebar, .mobile-bar, .nav-scrim, .flash, .stats, .upcoming, .bulletin footer { display: none !important; }
    .shell { display: block; }
    .main { padding: 0; }
    .bulletin, .report { box-shadow: none; background: #fff; border: 0; border-radius: 0; padding: 0; }
    .report-month { break-inside: auto; }
    .report-month > h2 { break-after: avoid; page-break-after: avoid; }
    .session-day { break-inside: avoid; page-break-inside: avoid; }
}
