:root {
    --brand: #4f46e5;
    --brand-dark: #3730a3;
    --ink: #172033;
    --muted: #667085;
    --line: #e5e7eb;
    --surface: #ffffff;
    --soft: #f6f8fc;
}

* { box-sizing: border-box; }
body.public-body {
    min-height: 100vh;
    font-family: "Noto Sans Thai", sans-serif;
    color: var(--ink);
    background: var(--soft);
}
a { text-decoration: none; }
.public-navbar {
    background: rgba(255,255,255,.92);
    border-bottom: 1px solid rgba(229,231,235,.9);
    backdrop-filter: blur(16px);
    box-shadow: 0 8px 30px rgba(15,23,42,.035);
}
.navbar-brand { color: var(--ink); }
.navbar-brand:hover { color: var(--brand); }
.navbar-brand span:last-child { display:flex; flex-direction:column; line-height:1.08; }
.navbar-brand small { font-size:.68rem; color:var(--muted); font-weight:500; margin-top:.2rem; }
.brand-mark, .footer-mark {
    width:42px; height:42px; display:grid; place-items:center; border-radius:14px;
    color:#fff; background:linear-gradient(135deg,#4f46e5,#0891b2);
    box-shadow:0 10px 24px rgba(79,70,229,.24);
}
.public-navbar .nav-link { color:#475467; font-weight:600; border-radius:10px; padding:.6rem .8rem; }
.public-navbar .nav-link:hover { color:var(--brand); background:#eef2ff; }

.hero-section {
    position:relative; overflow:hidden; padding:5rem 0 4.5rem;
    background:
        radial-gradient(circle at 88% 18%, rgba(34,211,238,.2), transparent 28%),
        radial-gradient(circle at 10% 80%, rgba(129,140,248,.22), transparent 30%),
        linear-gradient(135deg,#eef2ff 0%,#f8fbff 52%,#ecfeff 100%);
    border-bottom:1px solid #e7ebf3;
}
.hero-section::after {
    content:""; position:absolute; inset:auto -7rem -11rem auto; width:26rem; height:26rem;
    border:68px solid rgba(255,255,255,.65); border-radius:50%;
}
.hero-eyebrow { display:inline-flex; gap:.5rem; align-items:center; padding:.45rem .8rem; border-radius:999px; background:#fff; color:var(--brand); font-weight:700; font-size:.85rem; box-shadow:0 8px 25px rgba(79,70,229,.08); }
.hero-title { font-size:clamp(2.1rem,5vw,4rem); line-height:1.13; letter-spacing:-.04em; font-weight:800; max-width:820px; }
.hero-title span { color:var(--brand); }
.hero-copy { max-width:690px; color:#536176; font-size:1.08rem; line-height:1.8; }
.hero-search { position:relative; z-index:2; max-width:900px; background:rgba(255,255,255,.9); padding:1rem; border-radius:22px; border:1px solid rgba(255,255,255,.9); box-shadow:0 22px 55px rgba(44,56,92,.13); }
.hero-search .form-control, .hero-search .form-select { min-height:52px; border-color:#e4e7ec; border-radius:13px; }
.hero-search .btn { min-height:52px; border-radius:13px; font-weight:700; }

.stats-strip { margin-top:-1.5rem; position:relative; z-index:3; }
.stats-card { background:#fff; border:1px solid var(--line); border-radius:18px; box-shadow:0 15px 42px rgba(15,23,42,.075); }
.stat-item { padding:1.2rem 1.3rem; display:flex; align-items:center; gap:.9rem; }
.stat-item + .stat-item { border-left:1px solid var(--line); }
.stat-icon { width:45px; height:45px; border-radius:14px; display:grid; place-items:center; background:#eef2ff; color:var(--brand); font-size:1.15rem; }
.stat-value { font-size:1.35rem; font-weight:800; line-height:1; }
.stat-label { font-size:.78rem; color:var(--muted); margin-top:.3rem; }

.section-heading h2 { font-weight:800; letter-spacing:-.02em; }
.filter-bar { background:#fff; border:1px solid var(--line); border-radius:16px; padding:.75rem; }
.filter-pills { display:flex; gap:.55rem; flex-wrap:wrap; }
.filter-pill { padding:.55rem .9rem; color:#475467; background:#f8fafc; border:1px solid #e4e7ec; border-radius:999px; font-weight:600; font-size:.88rem; }
.filter-pill:hover, .filter-pill.active { color:#fff; background:var(--brand); border-color:var(--brand); }

.event-card { height:100%; background:#fff; border:1px solid var(--line); border-radius:20px; overflow:hidden; transition:.22s ease; box-shadow:0 8px 24px rgba(15,23,42,.045); }
.event-card:hover { transform:translateY(-5px); border-color:#c7d2fe; box-shadow:0 22px 45px rgba(34,49,89,.12); }
.event-cover-wrap { position:relative; aspect-ratio:16/9; overflow:hidden; background:#eef2ff; }
.event-cover { width:100%; height:100%; object-fit:cover; transition:transform .35s ease; }
.event-card:hover .event-cover { transform:scale(1.035); }
.event-state { position:absolute; left:1rem; top:1rem; display:inline-flex; align-items:center; gap:.38rem; padding:.4rem .65rem; border-radius:999px; font-weight:700; font-size:.75rem; border:1px solid rgba(255,255,255,.7); box-shadow:0 8px 22px rgba(15,23,42,.13); backdrop-filter:blur(9px); }
.status-open { color:#067647; background:rgba(236,253,243,.94); }
.status-upcoming { color:#175cd3; background:rgba(239,248,255,.94); }
.status-full { color:#b42318; background:rgba(254,243,242,.94); }
.status-expired, .status-unavailable { color:#475467; background:rgba(242,244,247,.94); }
.event-category { color:var(--brand); font-size:.78rem; font-weight:700; text-transform:none; }
.event-card-title { color:var(--ink); font-size:1.14rem; font-weight:750; line-height:1.45; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; min-height:3.3rem; }
.event-card-text { color:var(--muted); font-size:.89rem; line-height:1.65; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; min-height:2.95rem; }
.event-meta { display:grid; gap:.6rem; color:#475467; font-size:.84rem; }
.event-meta div { display:flex; align-items:flex-start; gap:.55rem; }
.event-meta i { color:#818cf8; margin-top:.1rem; }
.quota-line { display:flex; justify-content:space-between; color:#475467; font-size:.8rem; }
.progress.slim { height:7px; background:#eef2f7; }
.progress.slim .progress-bar { background:linear-gradient(90deg,#4f46e5,#0891b2); border-radius:99px; }
.progress.slim .progress-bar.full { background:#ef4444; }

.empty-public { text-align:center; background:#fff; border:1px dashed #cfd6e4; border-radius:24px; padding:4.5rem 1rem; }
.empty-public .empty-icon { width:78px; height:78px; border-radius:24px; display:grid; place-items:center; background:#eef2ff; color:var(--brand); font-size:2rem; margin:0 auto 1.2rem; }

.detail-hero { padding:2.4rem 0 1rem; }
.detail-cover { width:100%; aspect-ratio:16/9; object-fit:cover; border-radius:24px; box-shadow:0 22px 55px rgba(15,23,42,.14); }
.detail-card { background:#fff; border:1px solid var(--line); border-radius:22px; box-shadow:0 12px 36px rgba(15,23,42,.055); }
.detail-title { font-size:clamp(1.75rem,4vw,3rem); line-height:1.28; font-weight:800; letter-spacing:-.03em; }
.detail-summary { color:#5e6b7d; line-height:1.8; }
.info-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:1rem; }
.info-box { padding:1rem; border:1px solid #e7eaf0; border-radius:16px; background:#fbfcfe; }
.info-box .label { color:var(--muted); font-size:.78rem; margin-bottom:.25rem; }
.info-box .value { font-weight:650; line-height:1.55; }
.content-prose { line-height:1.9; color:#344054; overflow-wrap:anywhere; }
.registration-box { position:sticky; top:96px; }
.registration-box .seat-number { font-size:2.4rem; line-height:1; font-weight:800; color:var(--brand); }
.phase-notice { border:1px solid #bfdbfe; background:#eff6ff; color:#1e40af; border-radius:14px; padding:.9rem; font-size:.88rem; }
.share-button { border-radius:12px; }
.related-card { display:flex; gap:1rem; padding:1rem; border:1px solid var(--line); border-radius:16px; color:var(--ink); transition:.2s; }
.related-card:hover { border-color:#c7d2fe; background:#fafaff; }
.related-card img { width:92px; height:72px; border-radius:12px; object-fit:cover; }

.pagination .page-link { border:0; margin:0 .16rem; border-radius:10px; color:#475467; font-weight:600; }
.pagination .page-item.active .page-link { background:var(--brand); }
.public-footer { margin-top:4rem; border-top:1px solid var(--line); background:#fff; }

@media (max-width: 767.98px) {
    .hero-section { padding:3.7rem 0 3.5rem; }
    .hero-search { padding:.8rem; border-radius:18px; }
    .stats-card { overflow:hidden; }
    .stat-item { padding:1rem; }
    .stat-item + .stat-item { border-left:0; border-top:1px solid var(--line); }
    .info-grid { grid-template-columns:1fr; }
    .registration-box { position:static; }
    .detail-cover { border-radius:18px; }
}

/* Phase 5: AJAX registration */
.registration-box .input-group-text {
    color: var(--brand);
    background: #f5f7ff;
    border-color: #dfe3ec;
}
.registration-box .form-control,
.registration-box .input-group-text,
.registration-box .input-group .btn {
    border-color: #dfe3ec;
}
.registration-box .form-control:focus {
    border-color: #818cf8;
    box-shadow: 0 0 0 .25rem rgba(79, 70, 229, .12);
}
.student-preview {
    display: flex;
    gap: .85rem;
    align-items: center;
    padding: .9rem;
    border: 1px solid #bbf7d0;
    border-radius: 15px;
    background: #f0fdf4;
}
.student-preview.d-none { display: none !important; }
.preview-icon {
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 13px;
    color: #067647;
    background: #dcfce7;
    font-size: 1.15rem;
}
.registration-alert { font-size: .9rem; }
.registration-result {
    padding: 1.25rem;
    text-align: center;
    border: 1px solid #a7f3d0;
    border-radius: 18px;
    background: linear-gradient(180deg, #f0fdf4, #ffffff);
}
.registration-result .result-icon {
    width: 58px;
    height: 58px;
    margin: 0 auto;
    display: grid;
    place-items: center;
    border-radius: 18px;
    color: #047857;
    background: #d1fae5;
    font-size: 1.8rem;
}
.registration-code {
    padding: .75rem .65rem;
    color: #3730a3;
    background: #eef2ff;
    border: 1px dashed #a5b4fc;
    border-radius: 12px;
    font-weight: 800;
    letter-spacing: .05em;
    overflow-wrap: anywhere;
}
.privacy-note {
    color: #667085;
    font-size: .78rem;
    text-align: center;
}
.min-w-0 { min-width: 0; }

.team-member-row .member-sequence {
    min-width: 7.5rem;
    justify-content: center;
    font-size: .82rem;
    font-weight: 700;
    color: var(--bs-primary);
    background: rgba(var(--bs-primary-rgb), .08);
}
.team-member-row .form-control {
    min-width: 0;
}
@media (max-width: 420px) {
    .team-member-row .member-sequence {
        min-width: 6.25rem;
        font-size: .75rem;
    }
}

/* Main event pages */
.main-event-card .event-cover-wrap::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 45%, rgba(15, 23, 42, .22));
    pointer-events: none;
}
.main-event-card .event-state { z-index: 2; }
.main-event-hero { background: linear-gradient(180deg, #eef2ff 0%, #f8fafc 100%); }


.content-prose h2,
.content-prose h3,
.content-prose h4 { margin:1.5rem 0 .75rem; font-weight:700; color:#172033; }
.content-prose p,
.content-prose ul,
.content-prose ol,
.content-prose blockquote,
.content-prose pre,
.content-prose table { margin-bottom:1rem; }
.content-prose ul,
.content-prose ol { padding-left:1.5rem; }
.content-prose blockquote { padding:.85rem 1rem; border-left:4px solid #6366f1; background:#f8fafc; border-radius:0 .75rem .75rem 0; }
.content-prose table { width:100%; border-collapse:collapse; display:block; overflow-x:auto; }
.content-prose th,
.content-prose td { padding:.7rem .8rem; border:1px solid #dbe2ea; min-width:110px; }
.content-prose th { background:#f8fafc; font-weight:700; }
.content-prose a { overflow-wrap:anywhere; }

/* Self-entry student registration */
.registration-box .form-select {
    border-color: #dfe3ec;
}
.registration-box .form-select:focus {
    border-color: #818cf8;
    box-shadow: 0 0 0 .25rem rgba(79, 70, 229, .12);
}
.team-member-card {
    padding: 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    background: #f8fafc;
}
.team-member-card:nth-child(odd) {
    background: #ffffff;
}
.team-member-card .form-label {
    margin-bottom: .35rem;
    color: #475467;
}
.registration-box .was-validated .form-control:invalid,
.registration-box .was-validated .form-select:invalid {
    border-color: #dc3545;
}
@media (max-width: 991.98px) {
    .team-member-card {
        padding: .9rem;
    }
}

/* Mobile-first registration form */
.mobile-form-intro {
    display: flex;
    align-items: flex-start;
    padding: .85rem 1rem;
    color: #344054;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    font-size: .9rem;
    line-height: 1.45;
}
.mobile-friendly-form .form-label {
    margin-bottom: .45rem;
    color: #344054;
}
.mobile-friendly-form .form-control,
.mobile-friendly-form .form-select {
    min-height: 52px;
    border-radius: 14px;
    font-size: 1rem;
}
.mobile-friendly-form .form-control-lg,
.mobile-friendly-form .form-select-lg {
    min-height: 56px;
    padding-top: .75rem;
    padding-bottom: .75rem;
    font-size: 1rem;
}
.registration-submit-button {
    min-height: 56px;
    border-radius: 15px;
    font-weight: 700;
    touch-action: manipulation;
}
.team-member-card {
    scroll-margin-top: 90px;
    transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
}
.team-member-card.is-complete {
    border-color: #86efac;
    background: #f0fdf4;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, .06);
}
.member-completion-badge {
    flex: 0 0 auto;
    font-size: .72rem;
}
.copy-leader-classroom {
    width: 100%;
    min-height: 44px;
    border-radius: 12px;
    white-space: normal;
    touch-action: manipulation;
}
.mobile-friendly-form input,
.mobile-friendly-form select,
.mobile-friendly-form button {
    touch-action: manipulation;
}

@media (max-width: 575.98px) {
    .registration-box {
        padding: 1rem !important;
        border-radius: 18px;
    }
    .registration-box .seat-number {
        font-size: 2rem;
    }
    .mobile-friendly-form .row {
        --bs-gutter-y: .85rem;
    }
    .team-member-card {
        padding: .9rem;
        border-radius: 15px;
    }
    .registration-alert {
        font-size: .88rem;
        line-height: 1.45;
    }
    .registration-submit-button {
        font-size: 1rem;
    }
}


/* Registration approval and public status */
.confirmed-applicant-card {
    border: 1px solid rgba(15, 23, 42, .09);
    border-radius: 1rem;
    padding: 1rem;
    background: #fff;
    box-shadow: 0 10px 24px rgba(15, 23, 42, .04);
}

.confirmed-number {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 999px;
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    background: rgba(25, 135, 84, .12);
    color: #146c43;
    font-weight: 800;
}

.confirmed-empty {
    border: 1px dashed rgba(100, 116, 139, .35);
    border-radius: 1rem;
    padding: 1.15rem;
    color: #64748b;
    background: rgba(248, 250, 252, .85);
}

.registration-status-checker {
    scroll-margin-top: 6rem;
}

.status-result-card {
    border: 1px solid rgba(37, 99, 235, .16);
    border-radius: 1rem;
    padding: 1rem;
    background: linear-gradient(180deg, rgba(239, 246, 255, .95), #fff);
}

.registration-count-breakdown {
    gap: .75rem;
}

@media (max-width: 575.98px) {
    .registration-count-breakdown {
        flex-direction: column;
        gap: .25rem;
    }

    .confirmed-applicant-card {
        padding: .9rem;
    }

    .registration-status-checker .btn,
    .registration-status-checker .form-control {
        min-height: 54px;
        font-size: 1rem;
    }
}


/* Activity scope and external applicant fields */
.scope-option {
    display: flex;
    align-items: flex-start;
    gap: .85rem;
    padding: 1rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 1rem;
    background: #fff;
    cursor: pointer;
    transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.scope-option:hover,
.scope-option.is-selected {
    border-color: var(--bs-primary);
    background: rgba(var(--bs-primary-rgb), .05);
    box-shadow: 0 0 0 .2rem rgba(var(--bs-primary-rgb), .08);
}
.scope-option .form-check-input { margin-top: .25rem; flex: 0 0 auto; }
.scope-option-icon { font-size: 1.4rem; color: var(--bs-primary); }
.scope-option strong,
.scope-option small { display: block; }
.scope-option small { color: var(--bs-secondary-color); margin-top: .2rem; line-height: 1.45; }
.external-contact-card {
    border: 1px solid rgba(var(--bs-info-rgb), .28);
    background: rgba(var(--bs-info-rgb), .06);
    border-radius: 1rem;
    padding: 1rem;
    margin-bottom: 1rem;
}
.recent-team-members { min-width: 260px; }
.recent-team-members .member-line { padding: .25rem 0; border-bottom: 1px dashed var(--bs-border-color); }
.recent-team-members .member-line:last-child { border-bottom: 0; }

.supervisor-entry-card {
    border: 1px solid rgba(var(--bs-primary-rgb), .18);
    background: #fff;
    border-radius: 1rem;
    padding: 1rem;
}

@media (max-width: 575.98px) {
    .supervisor-entry-card,
    .external-contact-card {
        padding: .9rem;
    }
    .supervisor-entry-card .form-control,
    .supervisor-entry-card .form-select {
        min-height: 52px;
        font-size: 1rem;
    }
}
