/*!
 * STPM CGPA Calculator — theme layer
 * Visual language copied from WordPress Twenty Twenty-Five (theme.json tokens):
 *   base #FFFFFF · contrast #111111 · accent-1 #FFEE58 · accent-4 #686868
 *   accent-5 #FBFAF3 · Manrope · contentSize 645px · wideSize 1340px
 * Everything is scoped to .stpm-calc so the same file is safe inside a theme.
 */

.stpm-calc {
    /* Colour — follows iceclue.com: black on white, greys for support */
    --c-base: #ffffff;
    --c-contrast: #000000;
    --c-accent-1: #ffee58;
    --c-accent-2: #f6cff4;
    --c-accent-3: #503aa8;
    --c-accent-4: #666666;
    --c-accent-5: #f6f6f6;
    --c-mean: #dcf0e2;
    --c-line: #e5e6e9;
    --c-line-soft: #f0f0f0;

    /* Type — WordPress preset sizes, fluid like theme.json */
    --fs-small: 0.875rem;
    --fs-medium: clamp(1rem, 0.97rem + 0.16vw, 1.125rem);
    --fs-large: clamp(1.125rem, 1.08rem + 0.3vw, 1.375rem);
    --fs-x-large: clamp(1.4rem, 1.32rem + 0.4vw, 1.7rem);
    --fs-xx-large: clamp(1.9rem, 1.72rem + 0.9vw, 2.4rem);
    --font-sans: "Rubik", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, "Noto Sans", "PingFang SC", "Hiragino Sans GB",
        "Microsoft YaHei", sans-serif;
    --font-display: "Playfair Display", Georgia, "Times New Roman", serif;

    /* Spacing */
    --space-30: 20px;
    --space-40: 30px;
    --space-50: clamp(30px, 5vw, 50px);
    --space-60: clamp(40px, 7vw, 70px);
    --radius: 4px;
    --radius-lg: 6px;

    /* Layout */
    --wide: 960px;
    --content: 645px;
    --calc-width: 860px;
    --gutter: clamp(20px, 5vw, 50px);

    font-family: var(--font-sans);
    font-size: var(--fs-medium);
    font-weight: 400;
    line-height: 1.55;
    letter-spacing: 0;
    color: var(--c-contrast);
    background: transparent;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ------------------------------------------------------------------ *
 * Base
 * ------------------------------------------------------------------ */

.stpm-calc *,
.stpm-calc *::before,
.stpm-calc *::after {
    box-sizing: border-box;
}

.stpm-calc h1,
.stpm-calc h2,
.stpm-calc h3,
.stpm-calc h4 {
    margin: 0;
    font-family: inherit;
    font-weight: 400;
    line-height: 1.12;
    letter-spacing: -0.02em;
    color: inherit;
    text-wrap: balance;
}

.stpm-calc h1 { font-size: var(--fs-xx-large); }
.stpm-calc h2 { font-size: var(--fs-x-large); }
.stpm-calc h3 { font-size: var(--fs-large); }
.stpm-calc h4 { font-size: var(--fs-medium); }

.stpm-calc p {
    margin: 0 0 1rem;
    font-weight: 400;
    text-wrap: pretty;
}

.stpm-calc p:last-child,
.stpm-calc ul:last-child,
.stpm-calc ol:last-child {
    margin-bottom: 0;
}

.stpm-calc strong,
.stpm-calc b {
    font-weight: 700;
}

.stpm-calc a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 0.18em;
    text-decoration-thickness: 1px;
}

.stpm-calc a:hover {
    text-decoration: none;
}

.stpm-calc a:focus-visible,
.stpm-calc button:focus-visible,
.stpm-calc select:focus-visible {
    outline: 2px solid var(--c-accent-4);
    outline-offset: 2px;
}

.stpm-calc img {
    max-width: 100%;
    height: auto;
}

.stpm-calc .visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ------------------------------------------------------------------ *
 * Language visibility — the markup carries all three languages, the
 * active one is chosen by [data-lang] on the wrapper.
 * ------------------------------------------------------------------ */

.stpm-calc[data-lang="en"] .lang-bm,
.stpm-calc[data-lang="en"] .lang-zh,
.stpm-calc[data-lang="bm"] .lang-en,
.stpm-calc[data-lang="bm"] .lang-zh,
.stpm-calc[data-lang="zh"] .lang-en,
.stpm-calc[data-lang="zh"] .lang-bm {
    display: none !important;
}

/* ------------------------------------------------------------------ *
 * Layout
 * ------------------------------------------------------------------ */

.stpm-calc .wrap {
    width: 100%;
    max-width: var(--wide);
    margin-inline: auto;
    padding-inline: var(--gutter);
}

.stpm-calc .wrap--calc {
    max-width: calc(var(--calc-width) + var(--gutter) * 2);
}

.stpm-calc .wrap--prose {
    max-width: var(--wide);
}

.stpm-calc .section {
    padding-block: var(--space-60);
}

.stpm-calc .section + .section {
    padding-top: 0;
}

/* ------------------------------------------------------------------ *
 * Site chrome (standalone page only)
 * ------------------------------------------------------------------ */

.stpm-calc .site-header {
    background: var(--c-base);
}

.stpm-calc .site-header__inner {
    width: 1180px;
    max-width: 90%;
    margin-inline: auto;
}

.stpm-calc .site-title {
    display: block;
    margin: 38px 0 34px;
    font-family: var(--font-display);
    font-size: 48px;
    font-weight: 500;
    line-height: 1.25;
    letter-spacing: 0;
    text-align: center;
    color: var(--c-contrast);
    text-decoration: none;
    white-space: nowrap;
}

.stpm-calc .site-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    border-top: 1px solid var(--c-contrast);
    border-bottom: 1px solid var(--c-contrast);
}

.stpm-calc .site-nav a {
    display: block;
    padding: 15px 16px;
    border: 0;
    font-size: 15px;
    font-weight: 400;
    line-height: 1.6;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--c-contrast);
    text-decoration: none;
}

.stpm-calc .site-nav a:hover {
    color: var(--c-contrast);
    opacity: 0.6;
    text-decoration: none;
}

.stpm-calc .site-nav a[aria-current="page"] {
    color: var(--c-contrast);
    text-decoration: none;
}

.stpm-calc .breadcrumb {
    margin: 0 0 var(--space-40);
    font-size: var(--fs-small);
    color: var(--c-accent-4);
}

.stpm-calc .site-footer {
    border-top: 1px solid var(--c-line-soft);
    padding-block: var(--space-40);
    font-size: var(--fs-small);
    color: var(--c-accent-4);
}

.stpm-calc .site-footer__inner {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.5rem;
    align-items: baseline;
    justify-content: space-between;
    max-width: var(--wide);
    margin-inline: auto;
    padding-inline: var(--gutter);
}

.stpm-calc .site-footer p {
    margin: 0;
    font-size: var(--fs-small);
}

.stpm-calc .skip-link {
    position: absolute;
    left: 1rem;
    top: -3rem;
    z-index: 20;
    padding: 0.6rem 1rem;
    background: var(--c-contrast);
    color: var(--c-base);
    text-decoration: none;
    border-radius: var(--radius);
    transition: top 0.15s ease;
}

.stpm-calc .skip-link:focus {
    top: 1rem;
}

/* ------------------------------------------------------------------ *
 * Hero
 * ------------------------------------------------------------------ */

.stpm-calc .hero {
    padding-block: 36px 28px;
    background: var(--c-base);
}

.stpm-calc .hero + .section {
    padding-top: 48px;
}

.stpm-calc .eyebrow {
    margin: 0 0 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--c-accent-4);
}

.stpm-calc .hero h1 {
    max-width: 18em;
    margin-bottom: 0.85rem;
}

.stpm-calc .lede {
    max-width: 40em;
    margin-bottom: 1.75rem;
    font-size: var(--fs-large);
    line-height: 1.45;
    color: #262626;
}

.stpm-calc .lang-switch {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    border: 1px solid var(--c-line);
    border-radius: 999px;
    background: var(--c-base);
}

.stpm-calc .lang-btn {
    appearance: none;
    border: 0;
    border-radius: 999px;
    padding: 0.35rem 0.9rem;
    background: transparent;
    color: var(--c-accent-4);
    font-family: inherit;
    font-size: var(--fs-small);
    font-weight: 600;
    line-height: 1.4;
    cursor: pointer;
}

.stpm-calc .lang-btn:hover {
    color: var(--c-contrast);
}

.stpm-calc .lang-btn[aria-pressed="true"] {
    background: var(--c-contrast);
    color: var(--c-base);
}

/* ------------------------------------------------------------------ *
 * Prose
 * ------------------------------------------------------------------ */

.stpm-calc .section-title {
    margin-bottom: var(--space-40);
}

.stpm-calc .section-title + .lede {
    margin-top: -1.25rem;
}

.stpm-calc .prose {
    max-width: var(--content);
}

.stpm-calc .prose p,
.stpm-calc .prose li {
    font-weight: 400;
}

.stpm-calc .prose ol,
.stpm-calc .prose ul {
    margin: 0 0 1rem;
    padding-left: 1.35rem;
}

.stpm-calc .prose li {
    margin-top: 0.7rem;
    padding-left: 0.15rem;
}

.stpm-calc .prose li::marker {
    color: var(--c-accent-4);
    font-weight: 500;
}

.stpm-calc .note {
    max-width: var(--content);
    padding: 1.25rem 1.5rem;
    border-left: 2px solid var(--c-contrast);
    background: var(--c-accent-5);
    border-radius: 0 var(--radius) var(--radius) 0;
    font-size: var(--fs-small);
    color: #333333;
}

.stpm-calc .note p {
    font-size: var(--fs-small);
}

/* ------------------------------------------------------------------ *
 * Form panel
 * ------------------------------------------------------------------ */

.stpm-calc .panel {
    padding: clamp(20px, 4vw, 38px);
    border: 1px solid var(--c-line);
    border-radius: var(--radius-lg);
    background: var(--c-base);
}

.stpm-calc .field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    min-width: 0;
}

.stpm-calc .field-label {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    margin: 0;
    font-size: var(--fs-small);
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
    color: var(--c-contrast);
}

.stpm-calc .field-weight {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--c-accent-4);
    font-variant-numeric: tabular-nums;
}

.stpm-calc .term-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.1rem 1rem;
    margin-top: 1.4rem;
}

@media (min-width: 560px) {
    .stpm-calc .term-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }

    /* Five components (BM, BA): 3 + 2 reads better than 4 + 1. */
    .stpm-calc .term-grid--5 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 920px) {
    .stpm-calc .term-grid--5 {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}

.stpm-calc .form-empty {
    grid-column: 1 / -1;
    margin: 0;
    padding: 0.1rem 0;
    font-size: var(--fs-small);
    color: var(--c-accent-4);
}

.stpm-calc .actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-top: var(--space-40);
}

.stpm-calc .form-error {
    margin: 1rem 0 0;
    font-size: var(--fs-small);
    font-weight: 500;
    color: #b32d2e;
}

.stpm-calc .form-hint {
    margin: 1rem 0 0;
    font-size: var(--fs-small);
    color: var(--c-accent-4);
}

.stpm-calc .noscript-note {
    margin-top: 1rem;
    padding: 0.9rem 1.1rem;
    border: 1px dashed var(--c-line);
    border-radius: var(--radius);
    font-size: var(--fs-small);
}

/* ------------------------------------------------------------------ *
 * Controls (Bootstrap overrides)
 * ------------------------------------------------------------------ */

.stpm-calc .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 2.25rem;
    border: 1px solid transparent;
    border-radius: 0;
    background: transparent;
    font-family: inherit;
    font-size: var(--fs-medium);
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: 0.01em;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.stpm-calc .btn-primary {
    background-color: var(--c-contrast);
    border-color: var(--c-contrast);
    color: var(--c-base);
}

.stpm-calc .btn-primary:hover {
    background-color: color-mix(in srgb, var(--c-contrast) 85%, transparent);
    border-color: transparent;
    color: var(--c-base);
}

.stpm-calc .btn-primary:active {
    background-color: #000000;
}

.stpm-calc .btn-quiet {
    background-color: transparent;
    border-color: var(--c-line);
    color: var(--c-contrast);
}

.stpm-calc .btn-quiet:hover {
    background-color: color-mix(in srgb, var(--c-contrast) 5%, transparent);
    border-color: var(--c-contrast);
}

.stpm-calc .btn-primary:focus-visible,
.stpm-calc .btn-quiet:focus-visible {
    outline: 2px solid var(--c-accent-4);
    outline-offset: 2px;
}

.stpm-calc .form-select {
    --bs-form-select-bg-img: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23111111' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.4' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    display: block;
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: var(--bs-form-select-bg-img);
    background-repeat: no-repeat;
    background-position: right 0.9rem center;
    background-size: 16px 12px;
    padding: 0.7rem 2.35rem 0.7rem 0.9rem;
    border: 1px solid rgba(0, 0, 0, 0.22);
    border-radius: var(--radius);
    background-color: var(--c-base);
    font-family: var(--font-sans);
    font-size: var(--fs-medium);
    font-weight: 400;
    line-height: 1.4;
    color: var(--c-contrast);
    cursor: pointer;
}

.stpm-calc .form-select:hover {
    border-color: rgba(0, 0, 0, 0.45);
}

.stpm-calc .form-select:focus {
    border-color: var(--c-contrast);
    outline: 2px solid var(--c-accent-4);
    outline-offset: 2px;
    box-shadow: none;
}

.stpm-calc .form-select-lg {
    padding: 0.9rem 2.8rem 0.9rem 1rem;
    font-size: var(--fs-large);
    font-weight: 400;
}

.stpm-calc .form-select option {
    font-weight: 400;
}

/* ------------------------------------------------------------------ *
 * Results
 * ------------------------------------------------------------------ */

.stpm-calc .results {
    margin-top: var(--space-50);
    scroll-margin-top: 1.5rem;
}

.stpm-calc .results[hidden] {
    display: none;
}

.stpm-calc .results-title {
    margin-bottom: 1.25rem;
    font-size: var(--fs-large);
}

.stpm-calc .results-title:focus {
    outline: none;
}

.stpm-calc .result-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(8px, 1.6vw, 16px);
    margin-bottom: var(--space-30);
}

.stpm-calc .result-card {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding: clamp(14px, 2.4vw, 24px);
    border: 1px solid var(--c-line);
    border-radius: var(--radius-lg);
    background: var(--c-base);
}

.stpm-calc .result-card__label {
    margin: 0;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--c-accent-4);
}

.stpm-calc .result-card__mark {
    margin: 0.2rem 0 0.45rem;
    font-size: clamp(1.7rem, 4.6vw, 2.6rem);
    font-weight: 400;
    line-height: 1;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
}

.stpm-calc .result-card__mark small {
    margin-left: 0.15em;
    font-size: 0.35em;
    font-weight: 400;
    letter-spacing: 0;
    color: var(--c-accent-4);
}

.stpm-calc .result-card__grade {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 0.5rem;
    margin: 0;
}

.stpm-calc .result-card__cgpa {
    font-size: var(--fs-small);
    font-weight: 500;
    color: var(--c-accent-4);
    font-variant-numeric: tabular-nums;
}

.stpm-calc .result-card--mean {
    background: var(--c-mean);
    border-color: var(--c-mean);
}

.stpm-calc .result-card--mean .result-card__label,
.stpm-calc .result-card--mean .result-card__cgpa,
.stpm-calc .result-card--mean .result-card__mark small {
    color: rgba(0, 0, 0, 0.62);
}

.stpm-calc .grade-badge {
    display: inline-block;
    min-width: 2.6rem;
    padding: 0.1rem 0.6rem;
    border: 1px solid rgba(0, 0, 0, 0.28);
    border-radius: 999px;
    font-size: var(--fs-small);
    font-weight: 600;
    line-height: 1.6;
    text-align: center;
}

.stpm-calc .result-summary {
    max-width: 62ch;
    margin-bottom: var(--space-30);
    font-size: var(--fs-medium);
    color: #242424;
}


/* ------------------------------------------------------------------ *
 * Estimate range — min → max with the grade boundaries it crosses
 * ------------------------------------------------------------------ */

.stpm-calc .grade-band {
    margin: 1.2rem 0 1.4rem;
}

.stpm-calc .gr__title {
    margin: 0 0 0.1rem;
    font-size: var(--fs-small);
    color: var(--c-accent-4);
}

.stpm-calc .gr__plot {
    position: relative;
}

.stpm-calc .gr__meanrow {
    position: relative;
    height: 24px;
}

.stpm-calc .gr__quartile {
    position: absolute;
    bottom: 0;
    display: inline-flex;
    align-items: baseline;
    gap: 0.25rem;
    transform: translateX(-50%);
    line-height: 1.2;
    white-space: nowrap;
}

.stpm-calc .gr__quartile b {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--c-contrast);
    font-variant-numeric: tabular-nums;
}

.stpm-calc .gr__quartile em {
    font-style: normal;
    font-size: 0.65rem;
    color: var(--c-accent-4);
}

.stpm-calc .gr__meanlabel {
    position: absolute;
    bottom: 0;
    display: inline-flex;
    align-items: baseline;
    gap: 0.35rem;
    transform: translateX(-50%);
    white-space: nowrap;
    line-height: 1.2;
}

.stpm-calc .gr__meanlabel b {
    font-size: 0.95rem;
    font-weight: 600;
}

.stpm-calc .gr__meanlabel em {
    font-style: normal;
    font-size: 0.7rem;
    color: var(--c-accent-4);
}

.stpm-calc .gr__bar {
    position: relative;
    height: 12px;
    border: 1px solid var(--c-line);
    border-radius: 3px;
    background: #f4f4f4;
    overflow: hidden;
}

.stpm-calc .gr__seg {
    position: absolute;
    top: 0;
    bottom: 0;
    background: #e9e9e9;
}

.stpm-calc .gr__seg--you {
    box-shadow: none;
}

.stpm-calc .gr__tick {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 0;
    border-left: 1px dashed rgba(0, 0, 0, 0.6);
}

.stpm-calc .gr__qtick {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 0;
    border-left: 1px solid rgba(0, 0, 0, 0.22);
}

.stpm-calc .gr__marker {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    margin-left: -1px;
    background: var(--c-contrast);
}

.stpm-calc .gr__ends {
    display: flex;
    justify-content: space-between;
    margin-top: 0.3rem;
    font-size: 0.7rem;
    color: var(--c-accent-4);
}

.stpm-calc .gr__end {
    display: inline-flex;
    align-items: baseline;
    gap: 0.3rem;
}

.stpm-calc .gr__end b {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--c-contrast);
    font-variant-numeric: tabular-nums;
}

.stpm-calc .gr__end--max {
    text-align: right;
}

.stpm-calc .gr__boundaries {
    position: relative;
    height: 20px;
    margin-top: 0.1rem;
    font-size: 0.7rem;
    color: var(--c-accent-4);
}

.stpm-calc .gr__boundary {
    position: absolute;
    top: 0;
    display: inline-flex;
    align-items: baseline;
    gap: 0.2rem;
    transform: translateX(-50%);
    white-space: nowrap;
}

.stpm-calc .gr__swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border: 1px solid rgba(0, 0, 0, 0.16);
    border-radius: 2px;
}

.stpm-calc .gr__boundary b {
    font-weight: 600;
    color: var(--c-contrast);
    font-variant-numeric: tabular-nums;
}

.stpm-calc .gr__boundary i,
.stpm-calc .gr__boundary em {
    font-style: normal;
}

.stpm-calc .gr__boundary em {
    font-weight: 500;
}

.stpm-calc .gr__none {
    margin: 0.35rem 0 0;
    font-size: 0.7rem;
    color: var(--c-accent-4);
}

.stpm-calc .results-note {
    max-width: 62ch;
    margin: var(--space-30) 0 0;
    font-size: var(--fs-small);
    color: var(--c-accent-4);
}

/* ------------------------------------------------------------------ *
 * Accordion + tables
 * ------------------------------------------------------------------ */

.stpm-calc .accordion {
    --bs-accordion-border-color: var(--c-line);
    --bs-accordion-border-radius: var(--radius-lg);
    --bs-accordion-inner-border-radius: calc(var(--radius-lg) - 1px);
    --bs-accordion-btn-focus-box-shadow: none;
    --bs-accordion-btn-focus-border-color: var(--c-line);
    --bs-accordion-active-bg: transparent;
    --bs-accordion-active-color: var(--c-contrast);
    --bs-accordion-btn-color: var(--c-contrast);
    --bs-accordion-btn-bg: transparent;
    --bs-accordion-btn-padding-y: 1.05rem;
    --bs-accordion-btn-padding-x: 1.25rem;
    --bs-accordion-body-padding-x: 1.25rem;
    --bs-accordion-body-padding-y: 0.5rem;
}

.stpm-calc .accordion-button {
    font-family: var(--font-sans);
    font-size: var(--fs-medium);
    font-weight: 600;
    letter-spacing: 0;
    line-height: 1.35;
}

.stpm-calc .accordion-button:not(.collapsed) {
    box-shadow: none;
}

.stpm-calc .accordion-button:focus-visible {
    outline: 2px solid var(--c-accent-4);
    outline-offset: -2px;
    box-shadow: none;
}

.stpm-calc .stpm-table {
    --bs-table-border-color: var(--c-line-soft);
    --bs-table-bg: transparent;
    --bs-table-color: var(--c-contrast);
    width: 100%;
    margin: 0;
    border-collapse: collapse;
    font-size: var(--fs-small);
    font-variant-numeric: tabular-nums;
}

.stpm-calc .stpm-table th,
.stpm-calc .stpm-table td {
    padding: 0.7rem 0.5rem;
    border-width: 0 0 1px;
    border-style: solid;
    border-color: var(--c-line-soft);
    vertical-align: baseline;
}

.stpm-calc .stpm-table thead th {
    padding-top: 0.4rem;
    border-bottom-color: var(--c-line);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--c-accent-4);
    white-space: nowrap;
}

.stpm-calc .stpm-table tbody th {
    font-weight: 500;
    text-align: left;
}

.stpm-calc .stpm-table .num {
    text-align: right;
    white-space: nowrap;
}

.stpm-calc .stpm-table tbody tr:last-child th,
.stpm-calc .stpm-table tbody tr:last-child td {
    border-bottom: 0;
}

.stpm-calc .stpm-table__total th,
.stpm-calc .stpm-table__total td {
    border-top: 1px solid var(--c-line);
    font-weight: 600;
}

.stpm-calc .stpm-table__weight {
    font-weight: 400;
    color: var(--c-accent-4);
    font-variant-numeric: tabular-nums;
}

.stpm-calc .stpm-table__note {
    margin: 0.55rem 0 0;
    font-size: 0.72rem;
    line-height: 1.5;
    color: var(--c-accent-4);
}

.stpm-calc .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}


/* ------------------------------------------------------------------ *
 * STPM 2024 reference module
 * ------------------------------------------------------------------ */

.stpm-calc .cohort {
    margin-top: var(--space-40);
    padding: clamp(16px, 3vw, 26px);
    border: 1px solid var(--c-line);
    border-radius: var(--radius-lg);
    background: var(--c-accent-5);
}

.stpm-calc .cohort[hidden] {
    display: none;
}

.stpm-calc .cohort__title {
    margin: 0 0 0.3rem;
    font-size: var(--fs-large);
}

.stpm-calc .accordion-body .cohort {
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
}

.stpm-calc .cohort__meta {
    margin: 0 0 0.9rem;
    font-size: var(--fs-small);
    color: var(--c-accent-4);
}

.stpm-calc .cohort__table {
    margin: 0;
    background: transparent;
}

.stpm-calc .cohort__table th,
.stpm-calc .cohort__table td {
    padding-block: 0.55rem;
    background: transparent;
}

.stpm-calc .cohort__rowmeta {
    display: block;
    font-size: 0.72rem;
    font-weight: 400;
    color: var(--c-accent-4);
}

.stpm-calc .cohort__table thead th {
    padding-top: 0.2rem;
    white-space: normal;
    letter-spacing: 0.06em;
}

.stpm-calc .cohort__note {
    margin: 0.35rem 0 0;
    font-size: 0.75rem;
    line-height: 1.55;
    color: #595959;
}

.stpm-calc .cohort__source {
    margin: 0.9rem 0 0;
    padding-top: 0.75rem;
    border-top: 1px solid var(--c-line);
    font-size: 0.75rem;
    line-height: 1.6;
    color: #4f4f4f;
    overflow-wrap: anywhere;
}

.stpm-calc .cohort__source a {
    color: var(--c-accent-4);
    text-decoration: underline;
}

.stpm-calc .cohort__source a:hover {
    color: var(--c-contrast);
}

.stpm-calc .cohort-details {
    margin-top: var(--space-40);
    padding: 0 clamp(14px, 2.5vw, 22px);
    border: 1px solid var(--c-line);
    border-radius: var(--radius-lg);
}

.stpm-calc .cohort-details > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 0;
    font-size: var(--fs-medium);
    font-weight: 600;
    cursor: pointer;
    list-style: none;
}

.stpm-calc .cohort-details > summary::-webkit-details-marker {
    display: none;
}

.stpm-calc .cohort-details > summary::after {
    content: "+";
    font-size: 1.15rem;
    font-weight: 400;
    line-height: 1;
}

.stpm-calc .cohort-details[open] > summary::after {
    content: "−";
}

.stpm-calc .cohort-details[open] > summary {
    border-bottom: 1px solid var(--c-line-soft);
}

.stpm-calc .cohort-details > summary:focus-visible {
    outline: 2px solid var(--c-accent-4);
    outline-offset: 2px;
}

.stpm-calc .cohort__overview {
    padding-bottom: 1rem;
}

.stpm-calc .method-body {
    padding: 0.2rem 0 1.2rem;
    font-size: var(--fs-small);
    color: #333;
}

.stpm-calc .method-body p {
    margin: 0 0 0.7rem;
    max-width: 68ch;
    font-weight: 400;
}

.stpm-calc .method-body p:last-child {
    margin-bottom: 0;
}

.stpm-calc .method-body a {
    color: var(--c-contrast);
}

.stpm-calc .cohort__overview table {
    font-size: 0.8rem;
}

.stpm-calc .dist-table {
    font-size: 0.72rem;
}

.stpm-calc .dist-table thead th {
    padding: 0.45rem 0.35rem;
    font-size: 0.62rem;
    letter-spacing: 0.04em;
}

.stpm-calc .dist-table tbody td,
.stpm-calc .dist-table tbody th {
    padding: 0.38rem 0.35rem;
}

.stpm-calc .dist-table thead th:first-child,
.stpm-calc .dist-table tbody td:first-child {
    width: 1px;
    padding-inline: 0;
}

.stpm-calc .dist-group th {
    padding: 1rem 0.35rem 0.45rem;
    border-bottom: 1px solid var(--c-line);
    background: var(--c-base);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    text-align: left;
    color: var(--c-contrast);
    white-space: nowrap;
}

.stpm-calc .dist-paper {
    display: block;
    white-space: nowrap;
    font-weight: 500;
    color: var(--c-contrast);
}

.stpm-calc .dist-cand {
    display: block;
    font-style: normal;
    font-size: 0.66rem;
    color: var(--c-accent-4);
    font-variant-numeric: tabular-nums;
}

.stpm-calc .dist-flag {
    color: var(--c-accent-4);
}

.stpm-calc .cohort__overview thead th {
    position: sticky;
    top: 0;
    background: var(--c-base);
}

.stpm-calc .cohort__overview td a {
    text-decoration: none;
}

.stpm-calc .cohort__overview td a:hover {
    text-decoration: underline;
}

@media (max-width: 575.98px) {
    .stpm-calc .cohort__table {
        font-size: 0.75rem;
    }

    .stpm-calc .cohort__table th,
    .stpm-calc .cohort__table td {
        padding: 0.5rem 0.25rem;
    }

    .stpm-calc .cohort__rowmeta {
    display: block;
    font-size: 0.72rem;
    font-weight: 400;
    color: var(--c-accent-4);
}

.stpm-calc .cohort__table thead th {
        font-size: 0.6rem;
        letter-spacing: 0.02em;
    }

    .stpm-calc .cohort__overview table {
        font-size: 0.72rem;
    }

    .stpm-calc .dist-table {
        font-size: 0.66rem;
    }

    .stpm-calc .dist-table thead th,
    .stpm-calc .dist-table tbody td,
    .stpm-calc .dist-table tbody th {
        padding: 0.35rem 0.28rem;
    }
}

/* ------------------------------------------------------------------ *
 * Responsive
 * ------------------------------------------------------------------ */

@media (max-width: 575.98px) {
    .stpm-calc .result-card {
        padding: 12px 10px;
    }

    .stpm-calc .result-card__label {
        font-size: 0.62rem;
        letter-spacing: 0.08em;
    }

    .stpm-calc .result-card__mark {
        font-size: 1.65rem;
        margin-bottom: 0.35rem;
    }

    .stpm-calc .result-card__mark small {
        display: none;
    }

    .stpm-calc .result-card__cgpa {
        font-size: 0.72rem;
    }

    .stpm-calc .grade-badge {
        min-width: 2rem;
        padding-inline: 0.4rem;
    }

    .stpm-calc .actions {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: stretch;
        gap: 0.6rem;
    }

    .stpm-calc .actions .btn {
        width: 100%;
        --bs-btn-padding-x: 1rem;
    }

    .stpm-calc .site-title {
        margin: 26px 0 22px;
        font-size: 32px;
    }

    .stpm-calc .gr__quartile b {
        font-size: 0.72rem;
    }

    .stpm-calc .gr__quartile em,
    .stpm-calc .gr__meanlabel em {
        font-size: 0.6rem;
    }

    .stpm-calc .site-nav a {
        padding: 11px 9px;
        font-size: 12px;
        letter-spacing: 0.4px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .stpm-calc *,
    .stpm-calc *::before,
    .stpm-calc *::after {
        transition: none !important;
        animation: none !important;
    }
}

@media print {
    .stpm-calc .site-header,
    .stpm-calc .site-footer,
    .stpm-calc .lang-switch,
    .stpm-calc .form-empty,
    .stpm-calc .actions {
        display: none;
    }

    .stpm-calc .panel,
    .stpm-calc .accordion-collapse {
        border-color: #999;
    }

    .stpm-calc .accordion-collapse {
        display: block !important;
        height: auto !important;
    }
}
