:root {
    --red: #b3282d;
    --red-dark: #8f1f23;
    --navy: #1d2d44;
    --bg: #f7f7f5;
    --text: #24292f;
    --muted: #6a737d;
    --border: #d8dbe0;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
}

.wrap {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 1.25rem;
}

/* Header */
.site-header {
    background: var(--navy);
    color: #fff;
    padding: 0.75rem 0;
}
.site-header .wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    position: relative;
}
.brand {
    color: #fff;
    text-decoration: none;
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: 0.03em;
}
.brand .star { color: var(--red); }

/* Mobile hamburger */
.nav-toggle {
    display: none;
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: #fff;
    font-size: 1.2rem;
    line-height: 1;
    border-radius: 6px;
    padding: 0.3rem 0.65rem;
    cursor: pointer;
}

/* Grouped nav */
.mainnav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.25rem;
}
.mainnav .nav-link,
.navgroup-btn,
.nav-logout .linklike {
    color: #dbe2ee;
    text-decoration: none;
    font-size: 0.95rem;
    background: none;
    border: none;
    font-family: inherit;
    cursor: pointer;
    padding: 0.35rem 0.6rem;
    border-radius: 6px;
}
.mainnav .nav-link:hover,
.navgroup-btn:hover,
.nav-logout .linklike:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}
.navgroup { position: relative; }
.navgroup-btn::after { content: " ▾"; font-size: 0.7em; opacity: 0.85; }
.navgroup-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 12rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
    padding: 0.35rem;
    z-index: 50;
    margin-top: 0.25rem;
}
.navgroup.open .navgroup-menu { display: block; }
.navgroup-menu a {
    display: block;
    color: var(--text);
    text-decoration: none;
    padding: 0.45rem 0.7rem;
    border-radius: 6px;
    font-size: 0.95rem;
}
.navgroup-menu a:hover { background: #f1f3f5; color: var(--red-dark); }

/* Demo-mode banner */
.demo-banner {
    background: #f6c700;
    color: #1d2d44;
    text-align: center;
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: 0.01em;
    padding: 0.5rem 1rem;
    border-bottom: 3px solid #1d2d44;
}
.demo-banner strong { color: #7a1f00; }

/* Nav search box */
.nav-search { display: flex; align-items: center; margin-left: 0.25rem; }
.nav-search input {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    font: inherit;
    font-size: 0.9rem;
    padding: 0.3rem 0.6rem;
    border-radius: 6px 0 0 6px;
    width: 9rem;
    outline: none;
}
.nav-search input::placeholder { color: #c3ccdb; }
.nav-search input:focus { background: rgba(255, 255, 255, 0.2); border-color: rgba(255, 255, 255, 0.5); }
.nav-search button {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-left: none;
    border-radius: 0 6px 6px 0;
    color: #fff;
    padding: 0.3rem 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
}
.nav-search button:hover { background: rgba(255, 255, 255, 0.22); }

.inline-form { display: inline; }
.linklike {
    background: none;
    border: none;
    padding: 0;
    color: #dbe2ee;
    font-size: 0.95rem;
    font-family: inherit;
    cursor: pointer;
}
.linklike:hover { color: #fff; }

@media (max-width: 820px) {
    .nav-toggle { display: block; }
    .mainnav {
        display: none;
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 0.1rem;
        margin-top: 0.5rem;
    }
    .site-header.nav-open .mainnav { display: flex; }
    .navgroup { width: 100%; }
    .navgroup-btn,
    .mainnav .nav-link,
    .nav-logout .linklike { width: 100%; text-align: left; }
    .navgroup-menu {
        position: static;
        box-shadow: none;
        border: none;
        background: rgba(255, 255, 255, 0.06);
        margin: 0.1rem 0 0.2rem 0.9rem;
        padding: 0.15rem;
    }
    .navgroup-menu a { color: #dbe2ee; }
    .navgroup-menu a:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
    .nav-search { width: 100%; margin: 0.3rem 0; }
    .nav-search input { flex: 1; width: auto; }
}

/* Search results page */
.search-page-form { display: flex; gap: 0.5rem; margin: 1rem 0 1.5rem; max-width: 34rem; }
.search-page-form input {
    flex: 1;
    font: inherit;
    padding: 0.55rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 8px;
}
.search-page-form input:focus { outline: 2px solid var(--red); border-color: var(--red); }
.search-page-form button {
    background: var(--red);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0.55rem 1.1rem;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.search-page-form button:hover { background: var(--red-dark); }
.search-summary { margin-bottom: 0.5rem; }
.search-group { margin-bottom: 1.5rem; }
.search-group h2 {
    font-size: 1.05rem;
    border-bottom: 2px solid var(--red);
    display: inline-block;
    padding-bottom: 0.2rem;
    margin-bottom: 0.6rem;
}
.search-results { list-style: none; padding: 0; margin: 0; }
.search-results li { padding: 0.5rem 0; border-bottom: 1px solid var(--border); }
.search-results li:last-child { border-bottom: none; }
.search-results li a { font-weight: 600; }
.search-snippet { display: block; color: var(--muted); font-size: 0.9rem; margin-top: 0.15rem; }
.search-empty { background: #fbf6e6; border-left: 4px solid #e0b000; padding: 0.8rem 1rem; border-radius: 6px; }

/* Technical handbook */
.handbook-layout { display: flex; gap: 2rem; align-items: flex-start; }
.handbook-nav {
    flex: 0 0 15rem; position: sticky; top: 1rem;
    background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 1rem 1.1rem;
}
.handbook-nav h2 { margin: 0 0 0.6rem; font-size: 1rem; }
.handbook-nav ul { list-style: none; padding: 0; margin: 0; }
.handbook-nav li { margin: 0; }
.handbook-nav li a { display: block; padding: 0.4rem 0.6rem; border-radius: 6px; color: var(--text); font-size: 0.92rem; }
.handbook-nav li a:hover { background: #f1f3f5; color: var(--red-dark); text-decoration: none; }
.handbook-nav li.active a { background: var(--navy); color: #fff; }
.handbook-note { margin: 0.9rem 0 0; font-size: 0.78rem; color: var(--muted); line-height: 1.4; }

.handbook-body { flex: 1 1 auto; min-width: 0; max-width: 52rem; }
.handbook-body h1 { margin-top: 0; }
.handbook-body h2 { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.handbook-body h3 { margin-top: 1.4rem; color: var(--navy); }
.handbook-body p, .handbook-body li { line-height: 1.65; }
.handbook-body ul, .handbook-body ol { padding-left: 1.4rem; }
.handbook-body li { margin-bottom: 0.3rem; }
.handbook-body a { word-break: break-word; }
.handbook-body code {
    background: #eef0ee; padding: 0.12em 0.4em; border-radius: 4px;
    font-size: 0.88em; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.handbook-body pre {
    background: #1d2333; color: #e7ebf3; padding: 1rem 1.1rem; border-radius: 8px;
    overflow-x: auto; font-size: 0.85rem; line-height: 1.5;
}
.handbook-body pre code { background: none; padding: 0; color: inherit; font-size: inherit; }
.handbook-body table { border-collapse: collapse; width: 100%; margin: 1rem 0; font-size: 0.9rem; display: block; overflow-x: auto; }
.handbook-body th, .handbook-body td { border: 1px solid var(--border); padding: 0.5rem 0.7rem; text-align: left; vertical-align: top; }
.handbook-body th { background: #eef0ee; }
.handbook-body blockquote {
    margin: 1rem 0; padding: 0.6rem 1rem; background: #eef4fb;
    border-left: 4px solid var(--navy); border-radius: 0 6px 6px 0;
}
.handbook-body blockquote p { margin: 0.3rem 0; }
.handbook-body hr { border: none; border-top: 1px solid var(--border); margin: 1.6rem 0; }

@media (max-width: 820px) {
    .handbook-layout { flex-direction: column; }
    .handbook-nav { position: static; flex-basis: auto; width: 100%; }
}

/* Main */
main { padding: 2rem 1.25rem 3rem; }
h1 { color: var(--navy); margin-top: 0.5rem; }
h2 { color: var(--navy); }
a { color: var(--red-dark); }

.hero {
    text-align: center;
    padding: 2rem 0 1rem;
}
.hero .lead {
    font-size: 1.15rem;
    color: var(--muted);
    max-width: 40rem;
    margin: 0.5rem auto 1.5rem;
}

.btn {
    display: inline-block;
    background: var(--red);
    color: #fff;
    padding: 0.55rem 1.2rem;
    border: 2px solid var(--red);
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    font-size: 1rem;
    font-family: inherit;
    cursor: pointer;
    margin: 0.25rem;
}
.btn:hover { background: var(--red-dark); border-color: var(--red-dark); }
.btn-outline {
    background: transparent;
    color: var(--red-dark);
}
.btn-outline:hover { background: var(--red); color: #fff; }

/* Cards */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.25rem;
    margin-top: 2rem;
}
.card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem 1.25rem;
}
.card h2 { font-size: 1.1rem; margin-top: 0.25rem; }

/* Tables */
.table-scroll { overflow-x: auto; }
table {
    border-collapse: collapse;
    width: 100%;
    background: #fff;
    border: 1px solid var(--border);
}
th, td {
    text-align: left;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
}
th { background: var(--navy); color: #fff; font-weight: 600; }
tbody tr:nth-child(even) { background: #fbfbfa; }

/* Lists & forms */
.file-list { padding-left: 1.25rem; }
.file-list li { margin: 0.35rem 0; }

.login-form {
    max-width: 22rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.login-form label { font-weight: 600; margin-top: 0.5rem; }
.login-form input,
.login-form select,
.login-form textarea {
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
    background: #fff;
}
.login-form .btn { margin: 1rem 0 0; align-self: flex-start; }

.edit-banner {
    text-align: right;
    margin: 0;
}
.edit-banner a {
    display: inline-block;
    font-size: 0.85rem;
    text-decoration: none;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.2rem 0.6rem;
}
.page-content img { max-width: 100%; height: auto; }
.page-content table { margin: 1rem 0; }

.apply-form { max-width: 30rem; }
.apply-form h3 {
    color: var(--navy);
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.25rem;
    margin: 1.25rem 0 0.25rem;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: normal !important;
    margin-top: 0.75rem;
}
.checkbox-row input { width: auto; }

.error { color: var(--red-dark); font-weight: 600; }
.muted { color: var(--muted); font-size: 0.9rem; }

/* Member avatars */
.avatar, .avatar-blank {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
}
.avatar-lg {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.avatar-blank {
    background: var(--navy);
    color: #fff;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
}
.avatar-lg.avatar-blank { font-size: 2rem; }
.card-person { text-align: center; }
.card-person h2 { margin-bottom: 0.25rem; }

/* Member profile */
.profile { text-align: center; max-width: 30rem; }
.profile-facts {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.4rem 1rem;
    text-align: left;
    max-width: 24rem;
    margin: 1rem auto;
}
.profile-facts dt { font-weight: 600; color: var(--navy); }
.profile-facts dd { margin: 0; }

/* Messages */
.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.msg { padding: 0.6rem 0.9rem; border-radius: 6px; margin-bottom: 0.5rem; }
.msg-success { background: #e5f4e8; border: 1px solid #b7e0c1; }
.msg-error { background: #fbe6e6; border: 1px solid #f0b8b8; }
.msg-info { background: #e8eef7; border: 1px solid #bcd0ea; }

/* Awards ballot */
.ballot-option {
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin: 0.5rem 0;
    cursor: pointer;
}
.ballot-option:hover { border-color: var(--red); }
.ballot-option input { margin-top: 0.25rem; }

/* Minutes */
.badge-draft { background: #6a737d; }
.motion-carried { color: #1c6b34; }
.motion-defeated { color: var(--red-dark); }
.motion-tabled, .motion-withdrawn { color: var(--muted); }
.motion-list li { margin-bottom: 0.75rem; }
.motion-list p { margin: 0.15rem 0; }
.minutes-filter { color: var(--muted); }

/* Bylaws */
.bylaws-meta { color: var(--muted); }
.bylaws-review {
    background: #eef4fb;
    border: 1px solid #cfe0f2;
    border-radius: 6px;
    padding: 0.5rem 0.8rem;
    display: inline-block;
}
.bylaws-overdue { background: #fbe6e6; border-color: #f0b8b8; }
.bylaw-diff {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.85rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}
.bylaw-diff > div { padding: 0.15rem 0.7rem; white-space: pre-wrap; }
.diff-add { background: #e5f4e8; color: #1c6b34; }
.diff-del { background: #fbe6e6; color: #8f1f23; text-decoration: line-through; }
.diff-same { color: var(--muted); }

/* AGM topic voting */
.agm-suggest { max-width: 34rem; margin-bottom: 1.5rem; }
.topic-list { list-style: none; padding: 0; }
.topic {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.6rem 0.9rem;
    margin: 0.4rem 0;
}
.topic-vote {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 2.4rem;
}
.vote-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    color: var(--muted);
    padding: 0.1rem;
}
.vote-btn:hover { color: var(--navy); }
.vote-on-up { color: #2e8b4f; }
.vote-on-down { color: var(--red); }
.topic-score { font-weight: 700; font-size: 0.95rem; color: var(--navy); }
.score-pos { color: #2e8b4f; }
.score-neg { color: var(--red); }
.topic-text { flex: 1; }
.agm-when { color: var(--muted); }

/* Events calendar */
.cal-header { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; }
.cal-nav { display: flex; gap: 1rem; align-items: baseline; }
.cal { table-layout: fixed; min-width: 640px; }
.cal td {
    vertical-align: top;
    height: 5.5rem;
    padding: 0.25rem 0.35rem;
    border: 1px solid var(--border);
}
.cal-daynum { font-size: 0.85rem; color: var(--muted); }
.cal-dim { background: #f1f1ef; }
.cal-dim .cal-daynum { color: #c0c4c9; }
.cal-today { outline: 2px solid var(--red); outline-offset: -2px; }
.cal-event {
    display: block;
    font-size: 0.75rem;
    line-height: 1.3;
    background: var(--navy);
    color: #fff;
    border-radius: 4px;
    padding: 0.1rem 0.3rem;
    margin-top: 0.2rem;
    text-decoration: none;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.cal-event.cal-members { background: var(--red-dark); }
.badge {
    display: inline-block;
    font-size: 0.7rem;
    background: var(--red-dark);
    color: #fff;
    border-radius: 4px;
    padding: 0.05rem 0.4rem;
    vertical-align: middle;
}

/* Footer */
.site-footer {
    border-top: 1px solid var(--border);
    padding: 1rem 0 2rem;
    color: var(--muted);
    font-size: 0.9rem;
}

/* Demo page: video tour + brochure */
.demo-lead { font-size: 1.1rem; color: var(--muted); max-width: 42rem; }
.demo-section { margin-top: 2.5rem; }
.demo-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 0.5rem 1.5rem; margin-bottom: 1rem; }
.demo-head h2 { margin: 0; }
.demo-head p { margin: 0.25rem 0 0; max-width: 34rem; }
.demo-dl { display: flex; align-items: center; gap: 0.5rem; }
.demo-dl .btn { margin: 0; }
.demo-player { background: var(--navy); border-radius: 8px; overflow: hidden; }
.demo-player video { display: block; width: 100%; aspect-ratio: 16 / 9; background: var(--navy); }
.demo-chapters { list-style: none; margin: 0.75rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.5rem; }
.demo-chapters button {
    width: 100%;
    text-align: left;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    font: inherit;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
    cursor: pointer;
}
.demo-chapters button span { display: block; font-weight: 400; font-size: 0.85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.demo-chapters button:hover { border-color: var(--muted); }
.demo-chapters button[aria-current="true"] { border-color: var(--red); box-shadow: inset 0 3px 0 var(--red); }
.demo-pages { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.1rem; }
.demo-pages a { display: grid; gap: 0.4rem; color: var(--muted); text-decoration: none; font-size: 0.9rem; cursor: zoom-in; }
.demo-pages img {
    display: block;
    width: 100%;
    aspect-ratio: 8.5 / 11;
    object-fit: cover;
    border-radius: 3px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(29, 45, 68, 0.15), 0 8px 22px rgba(29, 45, 68, 0.12);
}
.demo-pages a:hover img { outline: 2px solid var(--red); }
.demo-pages strong { color: var(--text); }
.demo-viewer {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    grid-template-rows: auto 1fr;
    padding: 0.75rem 1rem 1rem;
    background: rgba(12, 18, 29, 0.88);
}
.demo-viewer[hidden] { display: none; }
.demo-viewer-bar { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; color: #fff; font-weight: 600; padding-bottom: 0.6rem; }
.demo-viewer-bar button {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    padding: 0.4rem 0.8rem;
    font: inherit;
    cursor: pointer;
}
.demo-viewer-bar button:hover { background: rgba(255, 255, 255, 0.22); }
.demo-viewer-stage { min-height: 0; display: grid; place-items: center; }
.demo-viewer-stage img { max-width: 100%; max-height: 100%; object-fit: contain; background: #fff; border-radius: 3px; }
@media (max-width: 820px) {
    .demo-chapters { grid-template-columns: repeat(2, 1fr); }
    .demo-chapters li:last-child { grid-column: span 2; }
    .demo-pages { grid-template-columns: repeat(2, 1fr); }
}
