/* Student portal — its own stylesheet (not the staff app's). Mobile-first; the accent colour is the
   school's brand colour, injected as --brand / --brand-ink by the layout. */

:root {
    --brand: #1f2a44;
    --brand-ink: #ffffff;
    --brand-soft: color-mix(in srgb, var(--brand) 10%, white);
    --brand-deep: color-mix(in srgb, var(--brand) 82%, black);
    --gold: #e0a800;
    --ink: #151a26;
    --ink-2: #4a5365;
    --ink-3: #8089a0;
    --bg: #f4f5f9;
    --card: #ffffff;
    --line: #e4e7ef;
    --ok: #1c8a4f;
    --ok-soft: #e4f5ec;
    --warn: #b7791f;
    --warn-soft: #fdf3d8;
    --bad: #c62839;
    --bad-soft: #fde8eb;
    --radius: 18px;
    --radius-sm: 12px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 6px 20px rgba(16, 24, 40, .06);
    --shadow-lg: 0 10px 40px rgba(16, 24, 40, .16);
    --tab-h: 68px;
    --side-w: 260px;
    --font: "Inter", "Instrument Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --ink: #eef0f6;
        --ink-2: #b4bacb;
        --ink-3: #7e869b;
        --bg: #0e1118;
        --card: #171b26;
        --line: #272d3c;
        --brand-soft: color-mix(in srgb, var(--brand) 28%, #171b26);
        --ok-soft: #12301f;
        --warn-soft: #3a2d0e;
        --bad-soft: #3b151b;
        --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body.portal {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--ink);
    line-height: 1.5;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}
:where(.portal) a { color: var(--brand); text-decoration: none; }
.portal h1, .portal h2, .portal h3 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
.portal p { margin: 0; }
.portal img { max-width: 100%; }
.portal svg.i { width: 1.25em; height: 1.25em; flex: 0 0 auto; }

/* ---------- Shell ---------- */
.p-top {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; gap: .75rem;
    padding: .65rem 1rem;
    background: var(--brand); color: var(--brand-ink);
    padding-top: calc(.65rem + env(safe-area-inset-top));
}
.p-top .p-brand { display: flex; align-items: center; gap: .6rem; color: inherit; font-weight: 700; min-width: 0; }
.p-top .p-brand img { width: 34px; height: 34px; object-fit: contain; border-radius: 8px; background: #fff; padding: 2px; }
.p-top .p-brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-top .p-spacer { flex: 1; }
.p-avatar {
    width: 38px; height: 38px; border-radius: 50%; border: 0; cursor: pointer;
    background: rgba(255, 255, 255, .18); color: inherit; font: inherit; font-weight: 700;
    display: grid; place-items: center;
}

.p-side { display: none; }
.p-main { padding: 1rem 1rem calc(var(--tab-h) + 1.5rem + env(safe-area-inset-bottom)); }
.p-wrap { max-width: 1240px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.25rem; }
.p-wrap > *, .p-grid > * { min-width: 0; }

.p-tabbar {
    position: fixed; inset: auto 0 0 0; z-index: 40;
    display: grid; grid-template-columns: repeat(5, 1fr);
    height: calc(var(--tab-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--card); border-top: 1px solid var(--line);
}
.p-tab {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    font-size: .7rem; font-weight: 600; color: var(--ink-3);
    background: none; border: 0; font-family: inherit; cursor: pointer; padding: 0;
}
.p-tab svg.i { width: 24px; height: 24px; }
.p-tab[aria-current="page"] { color: var(--brand); }
@media (prefers-color-scheme: dark) { .p-tab[aria-current="page"] { color: #fff; } }

@media (min-width: 900px) {
    .p-top { display: none; }
    .p-tabbar { display: none; }
    .p-side {
        display: flex; flex-direction: column;
        position: fixed; inset: 0 auto 0 0; width: var(--side-w);
        background: var(--brand); color: var(--brand-ink);
        padding: 1.25rem .9rem; overflow-y: auto;
    }
    .p-side .p-brand { display: flex; align-items: center; gap: .7rem; color: inherit; font-weight: 800; font-size: 1.05rem; padding: .25rem .5rem 1.25rem; }
    .p-side .p-brand img { width: 44px; height: 44px; object-fit: contain; border-radius: 10px; background: #fff; padding: 3px; }
    .p-side nav { display: grid; gap: 2px; }
    .p-side .p-nav-item {
        display: flex; align-items: center; gap: .75rem;
        padding: .7rem .85rem; border-radius: 12px;
        color: inherit; opacity: .8; font-weight: 600;
        background: none; border: 0; width: 100%; font-family: inherit; font-size: 1rem; cursor: pointer; text-align: left;
    }
    .p-side .p-nav-item:hover { opacity: 1; background: rgba(255, 255, 255, .1); }
    .p-side .p-nav-item[aria-current="page"] { opacity: 1; background: rgba(255, 255, 255, .18); }
    .p-side .p-side-foot { margin-top: auto; display: grid; gap: .5rem; padding-top: 1rem; }
    .p-side .p-who { display: flex; align-items: center; gap: .6rem; padding: .5rem; font-size: .9rem; }
    .p-side .p-who .p-avatar { flex: 0 0 auto; }
    .p-side .p-contact { font-size: .8rem; opacity: .75; padding: 0 .5rem; display: grid; gap: .15rem; }
    .p-side .p-contact a { color: inherit; }
    .p-main { margin-left: var(--side-w); padding: 2.25rem 2.5rem 3rem; }
}

/* "More" sheet (mobile) */
.p-sheet-back { position: fixed; inset: 0; z-index: 50; background: rgba(10, 14, 24, .5); opacity: 0; pointer-events: none; transition: opacity .2s; }
.p-sheet {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    background: var(--card); border-radius: 22px 22px 0 0;
    padding: .6rem 1rem calc(1rem + env(safe-area-inset-bottom));
    transform: translateY(105%); transition: transform .25s ease;
    box-shadow: var(--shadow-lg); max-height: 85vh; overflow-y: auto;
}
.p-sheet-open .p-sheet { transform: none; }
.p-sheet-open .p-sheet-back { opacity: 1; pointer-events: auto; }
.p-sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto .8rem; }
.p-sheet-who { display: flex; align-items: center; gap: .75rem; padding: .25rem .25rem 1rem; }
.p-sheet-who .p-avatar { background: var(--brand); color: var(--brand-ink); width: 44px; height: 44px; }
.p-sheet-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.p-sheet-grid a, .p-sheet-grid button {
    display: flex; flex-direction: column; align-items: center; gap: .35rem;
    padding: .9rem .4rem; border-radius: var(--radius-sm); border: 1px solid var(--line);
    background: var(--bg); color: var(--ink); font: inherit; font-size: .8rem; font-weight: 600; cursor: pointer; text-align: center;
}
.p-sheet-grid svg.i { width: 26px; height: 26px; color: var(--brand); }
@media (prefers-color-scheme: dark) { .p-sheet-grid svg.i { color: #fff; } }
.p-sheet-contact { display: flex; gap: .6rem; margin-top: .8rem; }
.p-sheet-contact a { flex: 1; text-align: center; padding: .7rem; border-radius: var(--radius-sm); background: var(--brand-soft); font-weight: 600; font-size: .9rem; }

/* Staff preview strip */
.p-preview {
    position: sticky; top: 0; z-index: 80; display: flex; align-items: center; justify-content: space-between; gap: .75rem;
    background: var(--gold); color: #1c1a1a; padding: .5rem 1rem; font-size: .88rem; flex-wrap: wrap;
}
.p-preview button { background: #1c1a1a; color: #fff; border: 0; border-radius: 8px; padding: .4rem .8rem; font: inherit; font-weight: 700; cursor: pointer; }
.p-preview form { margin: 0; }
:root:has(.p-preview) .p-top { top: 42px; }
@media (min-width: 900px) { :root:has(.p-preview) .p-side { top: 42px; } }

/* Home header chips */
.p-chips { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 1rem; position: relative; z-index: 1; }
.p-chip {
    display: inline-flex; align-items: center; gap: .4rem; padding: .35rem .75rem; border-radius: 999px;
    background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .22);
    color: inherit; font-size: .82rem; font-weight: 700;
}
.p-chip.gold { background: var(--gold); color: #1c1a1a; border-color: transparent; }
:where(.p-hero) a.p-chip { color: inherit; }
:where(.p-hero) a.p-chip.gold { color: #1c1a1a; }
.p-chip svg.i { width: 1.05em; height: 1.05em; }

/* Next test card */
.p-nexttest { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.p-nexttest .p-grow { flex: 1; min-width: 200px; }
.p-countdown { text-align: center; min-width: 84px; padding: .5rem .75rem; border-radius: 14px; background: var(--brand); color: var(--brand-ink); line-height: 1.1; }
.p-countdown b { display: block; font-size: 1.8rem; }
.p-countdown span { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }

/* ---------- Building blocks ---------- */
.p-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; }
.p-card > h2, .p-section-head h2 { font-size: 1.15rem; }
.p-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; }
.p-section-head a { font-size: .9rem; font-weight: 600; }
.p-page-head { display: grid; gap: .35rem; }
.p-page-head h1 { font-size: 1.75rem; }
.p-page-head p { color: var(--ink-2); }
.p-muted { color: var(--ink-2); }
.p-faint { color: var(--ink-3); font-size: .85rem; }
.p-grid { display: grid; gap: 1rem; }
@media (min-width: 640px) { .p-grid.cols-2 { grid-template-columns: repeat(2, 1fr); } .p-grid.cols-3 { grid-template-columns: repeat(3, 1fr); } .p-grid.cols-4 { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1000px) { .p-grid.cols-2-1 { grid-template-columns: 2fr 1fr; align-items: start; } }

.p-pill {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .2rem .65rem; border-radius: 999px; font-size: .78rem; font-weight: 700;
    background: var(--brand-soft); color: var(--brand);
}
@media (prefers-color-scheme: dark) { .p-pill { color: #fff; } }
.p-pill.ok { background: var(--ok-soft); color: var(--ok); }
.p-pill.warn { background: var(--warn-soft); color: var(--warn); }
.p-pill.bad { background: var(--bad-soft); color: var(--bad); }
.p-pill.gray { background: var(--bg); color: var(--ink-2); border: 1px solid var(--line); }

.p-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    padding: .75rem 1.15rem; border-radius: 12px; border: 0; cursor: pointer;
    background: var(--brand); color: var(--brand-ink); font: inherit; font-weight: 700; font-size: .95rem;
    min-height: 46px; transition: transform .1s, filter .15s;
}
.p-btn:hover { filter: brightness(1.1); }
.p-btn:active { transform: scale(.98); }
.p-btn.ghost { background: transparent; color: var(--brand); border: 1.5px solid var(--line); }
@media (prefers-color-scheme: dark) { .p-btn.ghost { color: #fff; } }
.p-btn.block { width: 100%; }

.p-alert { padding: .85rem 1rem; border-radius: var(--radius-sm); font-weight: 500; }
.p-alert.ok { background: var(--ok-soft); color: var(--ok); }
.p-alert.bad { background: var(--bad-soft); color: var(--bad); }
.p-alert ul { margin: 0; padding-left: 1.1rem; }

.p-empty { text-align: center; padding: 2.25rem 1rem; color: var(--ink-2); }
.p-empty svg.i { width: 40px; height: 40px; color: var(--ink-3); margin-bottom: .5rem; }
.p-empty strong { display: block; color: var(--ink); margin-bottom: .15rem; }

.p-stat { display: grid; gap: .1rem; }
.p-stat b { font-size: 1.6rem; letter-spacing: -.02em; }
.p-stat span { color: var(--ink-2); font-size: .85rem; }
.p-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .6rem; }
.p-stats .p-card { padding: .85rem; }
.p-stats .p-stat b { font-size: 1.35rem; }
.p-stats .p-stat b.p-stat-text { font-size: .95rem; line-height: 1.3; overflow-wrap: anywhere; }
.p-stats .p-stat span { font-size: .78rem; line-height: 1.3; }
@media (min-width: 640px) { .p-stats { gap: 1rem; } .p-stats .p-card { padding: 1.25rem; } .p-stats .p-stat b { font-size: 1.6rem; } .p-stats .p-stat b.p-stat-text { font-size: 1.1rem; } }

.p-list { list-style: none; margin: 0; padding: 0; }
.p-list > li { display: flex; gap: .85rem; align-items: center; padding: .85rem 0; border-top: 1px solid var(--line); }
.p-list > li:first-child { border-top: 0; padding-top: 0; }
.p-list .p-grow { flex: 1; min-width: 0; }
.p-list .p-title { font-weight: 600; overflow-wrap: anywhere; }
.p-iconbox { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); flex: 0 0 auto; }
@media (prefers-color-scheme: dark) { .p-iconbox { color: #fff; } }
.p-iconbox svg.i { width: 22px; height: 22px; }

/* ---------- Hero (dashboard) ---------- */
.p-hero {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 1rem 1.1rem;
}
.p-hero-id { display: flex; align-items: flex-start; gap: .9rem; }
.p-hero-body { flex: 1; min-width: 0; display: grid; gap: .6rem; }
.p-hero h1 { font-size: clamp(1.25rem, 4.5vw, 1.6rem); overflow-wrap: anywhere; }
.p-hero-photo {
    width: 56px; height: 56px; flex: 0 0 auto; border-radius: 50%; object-fit: cover;
    border: 2px solid var(--line); background: var(--bg);
}
.p-hero-initials { display: grid; place-items: center; font-weight: 800; color: var(--brand); background: var(--brand-soft); }
@media (prefers-color-scheme: dark) { .p-hero-initials { color: #fff; } }
@media (min-width: 700px) { .p-hero-photo { width: 64px; height: 64px; } }
.p-hero .p-chips { margin: 0; }
.p-hero .p-chip { background: var(--bg); border: 1px solid var(--line); color: var(--ink); font-weight: 600; padding: .25rem .7rem; }
.p-hero .p-chip.strong { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 700; }
.p-hero .p-chip.accent { background: var(--brand-soft); border-color: transparent; color: var(--brand); }
@media (prefers-color-scheme: dark) { .p-hero .p-chip.accent { color: #fff; } }
.p-hero-strip {
    display: flex; align-items: center; gap: .75rem; padding: .6rem .8rem; border-radius: var(--radius-sm);
    border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent);
    background: color-mix(in srgb, var(--gold) 10%, var(--card)); color: var(--ink);
}
.p-hero-strip .p-grow { min-width: 0; display: grid; line-height: 1.3; }
.p-hero-strip b { overflow-wrap: anywhere; }
.p-hero-strip small { color: var(--ink-3); font-size: .78rem; }
.p-strip-tag, .p-strip-go {
    font-size: .7rem; font-weight: 800; letter-spacing: .04em; border-radius: 8px; padding: .2rem .5rem; flex: 0 0 auto;
}
.p-strip-tag { background: var(--bg); border: 1px solid var(--line); color: var(--ink-2); }
.p-strip-go { background: color-mix(in srgb, var(--gold) 30%, var(--card)); color: var(--ink); }
.p-hero-ranks { display: grid; gap: .6rem; margin-top: .9rem; }
@media (min-width: 700px) { .p-hero-ranks { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); } }
.p-rank-tile {
    background: var(--bg); border: 1px solid var(--line);
    border-radius: var(--radius-sm); padding: .75rem .85rem; display: grid; gap: .6rem;
}
.p-rank-top { display: flex; align-items: center; gap: .75rem; }
.p-rank-name { font-weight: 800; font-size: 1.05rem; }
.p-rank-prog { font-size: .8rem; color: var(--ink-2); }
.p-hero .p-progress { background: var(--card); border: 1px solid var(--line); }
.p-belt { zoom: 2.6; line-height: 0; display: block; }
.p-belt .rank-graphic-bar { border-color: rgba(0, 0, 0, .25); }
.p-belt-sm { zoom: 1.5; line-height: 0; }

.p-progress { height: 10px; border-radius: 999px; background: rgba(255, 255, 255, .22); overflow: hidden; }
.p-progress > i { display: block; height: 100%; border-radius: 999px; background: var(--gold); transition: width .6s ease; }
.p-card .p-progress { background: var(--bg); border: 1px solid var(--line); }
.p-req { display: flex; justify-content: space-between; gap: .5rem; font-size: .82rem; margin-top: .3rem; }

/* rank-graphic (the same belt picture the staff side draws) */
.rank-graphic { display: inline-flex; align-items: center; }
.rank-graphic-bar {
    position: relative; display: flex; align-items: stretch; justify-content: flex-start; gap: 1px;
    width: 72px; height: 20px; border-radius: 3px; border: 1px solid rgba(28, 26, 26, .15);
    padding-left: 3px; overflow: hidden;
}
.rank-graphic-stripes {
    display: block; flex: 0 0 auto; align-self: stretch; width: calc(var(--n) * 6px);
    background-image: linear-gradient(90deg, var(--c) 0, var(--c) 4px, transparent 4px);
    background-size: 6px 100%; background-repeat: repeat-x; position: relative; z-index: 1;
}
.rank-graphic-band { position: absolute; left: 0; right: 0; bottom: 0; height: 30%; }
.rank-graphic-band-half { height: 50%; }
.rank-graphic-band-mid { position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%); height: 20%; }
.rank-graphic-insignia-group { position: relative; display: flex; align-items: stretch; gap: 1px; min-width: 0; z-index: 1; }
.rank-graphic-insignia-group-2 { margin-left: 3px; }
.rank-graphic-mark { display: flex; align-items: center; justify-content: center; font-size: .62rem; font-weight: 700; line-height: 1; }

/* ---------- Quick actions / tiles ---------- */
.p-tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; }
@media (min-width: 640px) { .p-tiles { grid-template-columns: repeat(4, 1fr); } }
.p-tile {
    display: flex; flex-direction: column; gap: .5rem; padding: 1rem;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
    color: var(--ink); transition: transform .12s, box-shadow .12s;
}
.p-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.p-tile b { font-size: 1rem; }
.p-tile span { color: var(--ink-2); font-size: .8rem; }

/* ---------- Media library ---------- */
.p-search { position: relative; }
.p-search svg.i { position: absolute; left: .9rem; top: 50%; transform: translateY(-50%); color: var(--ink-3); }
.p-search input {
    width: 100%; padding: .85rem 1rem .85rem 2.6rem; border-radius: 14px; border: 1.5px solid var(--line);
    background: var(--card); color: var(--ink); font: inherit; font-size: 1rem; min-height: 48px;
}
.p-search input:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }

.p-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem; font-size: .9rem; }
.p-crumbs a { padding: .3rem .6rem; border-radius: 999px; background: var(--card); border: 1px solid var(--line); color: var(--ink-2); font-weight: 600; }
.p-crumbs .sep { color: var(--ink-3); }
.p-crumbs .here { padding: .3rem .6rem; border-radius: 999px; background: var(--brand); color: var(--brand-ink); font-weight: 700; }

.p-folder-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .8rem; }
@media (min-width: 700px) { .p-folder-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1100px) { .p-folder-grid { grid-template-columns: repeat(4, 1fr); } }
.p-folder {
    display: flex; flex-direction: column; justify-content: space-between; gap: 1.1rem; min-height: 130px;
    padding: 1rem; border-radius: var(--radius); color: #fff;
    background: linear-gradient(145deg, var(--f1, var(--brand)), var(--f2, var(--brand-deep)));
    box-shadow: var(--shadow); position: relative; overflow: hidden;
    transition: transform .12s;
}
.p-folder:hover { transform: translateY(-3px); }
.p-folder svg.i { width: 34px; height: 34px; opacity: .95; }
.p-folder b { font-size: 1.02rem; line-height: 1.2; display: block; overflow-wrap: anywhere; }
.p-folder span { font-size: .8rem; opacity: .85; }
.p-folder::after { content: ""; position: absolute; right: -25px; bottom: -25px; width: 110px; height: 110px; border-radius: 50%; background: rgba(255, 255, 255, .1); }

.p-media-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; }
@media (min-width: 1000px) { .p-media-grid { grid-template-columns: repeat(3, 1fr); } }
.p-media {
    display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); overflow: hidden; color: var(--ink); box-shadow: var(--shadow);
    transition: transform .12s, box-shadow .12s;
}
.p-media:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.p-media-thumb {
    aspect-ratio: 16 / 9; display: grid; place-items: center; color: #fff; position: relative;
    background: linear-gradient(135deg, var(--m1), var(--m2));
}
.p-media-thumb svg.i { width: 46px; height: 46px; filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .25)); }
.p-media-thumb .p-play {
    width: 58px; height: 58px; border-radius: 50%; background: rgba(255, 255, 255, .92); color: var(--m1);
    display: grid; place-items: center; box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
}
.p-media-thumb .p-play svg.i { width: 26px; height: 26px; filter: none; margin-left: 3px; }
.p-media-body { padding: .65rem .8rem .8rem; display: grid; gap: .3rem; }
.p-media-body b { font-size: .92rem; line-height: 1.3; overflow-wrap: anywhere; }
.p-media.video { --m1: #2b4fd6; --m2: #7b3fe4; }
.p-media.pdf { --m1: #c62839; --m2: #f06a4a; }
.p-media.link { --m1: #0f8f77; --m2: #34c3a0; }
.p-media.new .p-media-body b::after { content: "NEW"; margin-left: .5rem; font-size: .65rem; padding: .1rem .4rem; border-radius: 6px; background: var(--gold); color: #1c1a1a; vertical-align: middle; }

.p-hscroll { display: grid; grid-auto-flow: column; grid-auto-columns: min(78%, 280px); gap: .8rem; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: .5rem; margin-right: -1rem; padding-right: 1rem; }
.p-hscroll > * { scroll-snap-align: start; }
@media (min-width: 900px) {
    .p-hscroll { grid-auto-flow: row; grid-auto-columns: auto; grid-template-columns: repeat(3, minmax(0, 1fr)); overflow: visible; margin-right: 0; padding-right: 0; }
}

.p-player { background: #000; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-lg); }
.p-player video { display: block; width: 100%; max-height: 72vh; background: #000; }
.p-player .p-ratio { position: relative; padding-top: 56.25%; }
.p-player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.p-pdf { width: 100%; height: 78vh; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.p-nextprev { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.p-nextprev a {
    display: grid; gap: .1rem; padding: .85rem 1rem; border-radius: var(--radius-sm);
    background: var(--card); border: 1px solid var(--line); color: var(--ink);
}
.p-nextprev a small { color: var(--ink-3); font-weight: 700; text-transform: uppercase; font-size: .68rem; letter-spacing: .05em; }
.p-nextprev a.next { text-align: right; }
.p-playlist a { display: flex; gap: .75rem; align-items: center; padding: .6rem; border-radius: 12px; color: var(--ink); }
.p-playlist a:hover { background: var(--bg); }
.p-playlist a[aria-current="true"] { background: var(--brand-soft); font-weight: 700; }
.p-playlist .p-iconbox { width: 36px; height: 36px; }

/* ---------- Schedule / timeline ---------- */
.p-day { display: grid; grid-template-columns: 64px 1fr; gap: 1rem; padding: .9rem 0; border-top: 1px solid var(--line); }
.p-day:first-child { border-top: 0; }
.p-day-label { font-weight: 800; color: var(--brand); text-transform: uppercase; font-size: .8rem; letter-spacing: .06em; padding-top: .2rem; }
@media (prefers-color-scheme: dark) { .p-day-label { color: #fff; } }
.p-slot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .2rem .75rem; padding: .35rem 0; }
.p-slot + .p-slot { border-top: 1px dashed var(--line); }

.p-timeline { position: relative; margin-left: .6rem; padding-left: 1.4rem; border-left: 3px solid var(--line); display: grid; gap: 1.1rem; }
.p-timeline .p-t-item { position: relative; }
.p-timeline .p-t-item::before {
    content: ""; position: absolute; left: calc(-1.4rem - 8px); top: .35rem; width: 13px; height: 13px; border-radius: 50%;
    background: var(--card); border: 3px solid var(--brand);
}
.p-timeline .p-t-item.current::before { background: var(--gold); border-color: var(--gold); box-shadow: 0 0 0 5px color-mix(in srgb, var(--gold) 28%, transparent); }
.p-t-item time { color: var(--ink-3); font-size: .8rem; font-weight: 600; }
.p-t-item .p-t-row { display: flex; align-items: center; gap: .9rem; margin-top: .3rem; flex-wrap: wrap; }
.p-t-item .p-belt-sm { flex: 0 0 auto; }

.p-datebadge { width: 54px; flex: 0 0 auto; text-align: center; border-radius: 14px; background: var(--brand-soft); color: var(--brand); padding: .4rem 0; line-height: 1.1; }
@media (prefers-color-scheme: dark) { .p-datebadge { color: #fff; } }
.p-datebadge b { display: block; font-size: 1.35rem; }
.p-datebadge span { font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }

/* ---------- Library toolbar, belt groups, list view ---------- */
.p-toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-bottom: 1rem; }
.p-toolbar .p-seg:last-child { margin-left: auto; }
.p-jump-select { flex: 1 1 200px; max-width: 320px; min-height: 42px; padding: .45rem .8rem; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-weight: 600; font-size: .88rem; }
.p-seg { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 2px; }
.p-seg button { border: 0; background: none; font: inherit; font-weight: 700; font-size: .85rem; color: var(--ink-2); padding: .45rem .75rem; border-radius: 9px; cursor: pointer; display: inline-flex; gap: .4rem; align-items: center; }
.p-seg button span { font-weight: 600; opacity: .6; }
.p-seg button.on { background: var(--brand); color: var(--brand-ink); }
.p-seg svg.i { width: 18px; height: 18px; }
.p-jump { display: flex; gap: .4rem; overflow-x: auto; padding: 0 0 .6rem; margin-bottom: .4rem; }
.p-jump a { white-space: nowrap; padding: .3rem .7rem; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-size: .8rem; font-weight: 700; color: var(--ink-2); }
.p-jump a.mine { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.p-group { margin-bottom: 1.4rem; scroll-margin-top: 4.5rem; }
.p-group[hidden], .p-media[hidden] { display: none; }
.p-group-head { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .6rem; padding-bottom: .4rem; border-bottom: 2px solid var(--line); }
.p-group-head h2 { font-size: 1.05rem; }
.p-group-head .p-pill:last-child { margin-left: auto; }

/* list view: one compact row per item */
.p-library[data-view="list"] .p-media-grid { grid-template-columns: 1fr; gap: .4rem; }
.p-library[data-view="list"] .p-media { flex-direction: row; align-items: center; border-radius: 12px; box-shadow: none; }
.p-library[data-view="list"] .p-media:hover { transform: none; background: var(--bg); }
.p-library[data-view="list"] .p-media-thumb { aspect-ratio: auto; width: 54px; height: 54px; flex: 0 0 54px; border-radius: 0; }
.p-library[data-view="list"] .p-media-thumb svg.i { width: 24px; height: 24px; }
.p-library[data-view="list"] .p-media-thumb .p-play { width: 34px; height: 34px; }
.p-library[data-view="list"] .p-media-thumb .p-play svg.i { width: 16px; height: 16px; }
.p-library[data-view="list"] .p-media-body { padding: .35rem .8rem; gap: .05rem; flex: 1; min-width: 0; }
.p-library[data-view="list"] .p-media-body b { font-size: .92rem; }

/* icon view: small tiles, many per row */
.p-library[data-view="grid"] .p-media-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; }
.p-library[data-view="grid"] .p-media-thumb { aspect-ratio: 4 / 3; }
.p-library[data-view="grid"] .p-media-thumb svg.i { width: 30px; height: 30px; }
.p-library[data-view="grid"] .p-media-thumb .p-play { width: 40px; height: 40px; }
.p-library[data-view="grid"] .p-media-thumb .p-play svg.i { width: 18px; height: 18px; }
.p-library[data-view="grid"] .p-media-body { padding: .5rem .6rem .6rem; }
.p-library[data-view="grid"] .p-media-body b { font-size: .82rem; }
.p-library[data-view="grid"] .p-media-body .p-faint { font-size: .72rem; }

/* ---------- Week grid & attendance months ---------- */
.p-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .6rem; }
.p-week-day { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .6rem; min-height: 96px; display: grid; gap: .45rem; align-content: start; }
.p-week-day.today { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.p-week-day h3 { font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); }
.p-week-day.today h3 { color: var(--brand); }
.p-class { background: var(--card); border-left: 4px solid var(--brand); border-radius: 8px; padding: .4rem .5rem; font-size: .8rem; line-height: 1.3; box-shadow: var(--shadow); }
.p-class b { display: block; font-size: .82rem; }
@media (max-width: 899px) { .p-week { grid-template-columns: 1fr; } .p-week-day { min-height: 0; grid-template-columns: 64px 1fr; align-items: start; } .p-week-day:empty { display: none; } }
.p-month { border-top: 1px solid var(--line); }
.p-month:first-of-type { border-top: 0; }
.p-month > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: .75rem; padding: .85rem 0; font-weight: 700; }
.p-month > summary::-webkit-details-marker { display: none; }
.p-month > summary .p-pill { margin-left: auto; }
.p-month > summary::before { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--ink-3); border-bottom: 2px solid var(--ink-3); transform: rotate(-45deg); transition: transform .15s; margin: 0 .3rem 0 .1rem; }
.p-month[open] > summary::before { transform: rotate(45deg); }
.p-att-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .5rem .9rem; padding-bottom: 1rem; }
.p-att { display: flex; gap: .65rem; align-items: center; padding: .5rem .65rem; border-radius: 12px; background: var(--bg); }
.p-att .d { width: 40px; text-align: center; line-height: 1.05; flex: 0 0 auto; }
.p-att .d b { display: block; font-size: 1.05rem; }
.p-att .d span { font-size: .65rem; font-weight: 800; text-transform: uppercase; color: var(--ink-3); }
.p-att .t { min-width: 0; font-size: .88rem; }
.p-att .t b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Challenge stripes ---------- */
.p-stripe-dot {
    width: 38px; height: 38px; border-radius: 50%; flex: 0 0 auto; display: grid; place-items: center;
    border: 3px solid var(--c); background: transparent; color: #fff;
}
.p-stripes .earned .p-stripe-dot { background: var(--c); }
.p-stripe-dot svg.i { width: 20px; height: 20px; filter: drop-shadow(0 0 1px rgba(0,0,0,.5)); }

/* ---------- Messages ---------- */
.p-msg { display: grid; gap: .25rem; padding: .85rem 1rem; border-radius: 16px; background: var(--card); border: 1px solid var(--line); max-width: 560px; }
.p-msg.you { margin-left: auto; background: var(--brand); color: var(--brand-ink); border-color: transparent; }
.p-msg small { opacity: .7; font-size: .75rem; }
.p-thread { display: grid; gap: .6rem; }
.p-email summary { cursor: pointer; list-style: none; display: flex; gap: .75rem; align-items: center; }
.p-email summary::-webkit-details-marker { display: none; }
.p-email[open] summary { margin-bottom: .75rem; }
.p-email-body { white-space: pre-wrap; color: var(--ink-2); border-top: 1px solid var(--line); padding-top: .75rem; overflow-wrap: anywhere; }

/* ---------- Money ---------- */
.p-cardvisual {
    border-radius: 20px; padding: 1.25rem; color: #fff; aspect-ratio: 1.7; max-width: 340px;
    background: linear-gradient(135deg, #20263a, #4b5578); display: flex; flex-direction: column; justify-content: space-between;
    box-shadow: var(--shadow-lg);
}
.p-cardvisual .num { font-size: 1.25rem; letter-spacing: .16em; font-weight: 600; }
.p-cardvisual .meta { display: flex; justify-content: space-between; font-size: .8rem; opacity: .85; }
.p-money { font-variant-numeric: tabular-nums; font-weight: 700; }

/* ---------- Forms ---------- */
.p-form { display: grid; gap: 1rem; }
.p-form .row { display: grid; gap: 1rem; }
@media (min-width: 640px) { .p-form .row.two { grid-template-columns: 1fr 1fr; } .p-form .row.three { grid-template-columns: 2fr 1fr 1fr; } }
.p-field { display: grid; gap: .35rem; font-weight: 600; font-size: .88rem; color: var(--ink-2); }
.p-field input[type="text"], .p-field input[type="email"], .p-field input[type="password"], .p-field input[type="date"],
.p-field input[type="datetime-local"], .p-field select, .p-field textarea {
    width: 100%; padding: .75rem .9rem; border-radius: 12px; border: 1.5px solid var(--line);
    background: var(--card); color: var(--ink); font: inherit; font-weight: 400; font-size: 1rem; min-height: 48px;
}
.p-field input:focus, .p-field select:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.p-check { display: flex; gap: .75rem; align-items: flex-start; font-weight: 500; color: var(--ink); }
.p-check input { width: 22px; height: 22px; margin-top: .1rem; accent-color: var(--brand); }
.p-savebar { position: sticky; bottom: calc(var(--tab-h) + 8px + env(safe-area-inset-bottom)); display: flex; justify-content: flex-end; }
@media (min-width: 900px) { .p-savebar { bottom: 1rem; } }

/* ---------- Signed-out pages ---------- */
body.portal-auth { min-height: 100vh; display: grid; }
.p-auth { display: grid; min-height: 100vh; }
.p-auth-hero {
    background: linear-gradient(150deg, var(--brand) 0%, var(--brand-deep) 100%); color: var(--brand-ink);
    padding: 2rem 1.5rem 3.5rem; display: flex; flex-direction: column; justify-content: center; gap: 1rem; text-align: center; align-items: center;
}
.p-auth-hero img { width: 84px; height: 84px; object-fit: contain; background: #fff; border-radius: 22px; padding: 6px; box-shadow: var(--shadow-lg); }
.p-auth-hero h1 { font-size: 1.6rem; }
.p-auth-hero p { opacity: .8; max-width: 34ch; }
.p-auth-panel { padding: 0 1rem 2rem; margin-top: -2rem; display: flex; justify-content: center; }
.p-auth-card { width: 100%; max-width: 440px; background: var(--card); border-radius: 24px; box-shadow: var(--shadow-lg); padding: 1.6rem 1.4rem; display: grid; gap: 1.1rem; align-self: flex-start; }
.p-auth-card h2 { font-size: 1.4rem; }
.p-auth-links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem; font-size: .9rem; font-weight: 600; }
.p-auth-links a { color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; }
.p-auth-links a:hover, .p-auth-links a:focus-visible { color: var(--ink); }
@media (min-width: 900px) {
    .p-auth { grid-template-columns: 1fr 1fr; }
    .p-auth-hero { padding: 3rem; }
    .p-auth-hero h1 { font-size: 2.4rem; }
    .p-auth-panel { margin: 0; align-items: center; padding: 2rem; }
    .p-auth-card { box-shadow: none; border: 1px solid var(--line); align-self: center; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.p-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
