:root {
  --brand-pink-light: #fae1e9;
  --brand-pink: #f096b8;
  --brand-green: #c9dcb9;
  --brand-teal: #0091aa;
  --brand-blue: #2d60a5;
  --ink: #18324a;
  --muted: #607385;
  --line: #dce7e9;
  --surface: #ffffff;
  --soft: #f4f8f8;
  --app-background: linear-gradient(135deg, #dff3ef, #e6edff);
}

body { background: var(--app-background); color: var(--ink); font-family: system-ui, sans-serif; font-size: 1.05rem; }
/* The page already shows a loading message and kitten. Keep it readable while
   Shiny replaces root_ui; Bootstrap 5 also applies the fade to its children. */
#root_ui.recalculating,
#root_ui.recalculating > * { opacity: 1; }
h1, h2, h3, h4, h5, h6, .btn, .nav-link, .card-header, .metric-title, .feedback-title { font-family: system-ui, sans-serif; }
.navbar { position: relative; background: #fff !important; box-shadow: 0 2px 14px rgba(45, 96, 165, .1); }
.navbar::before { content: ""; position: absolute; inset: 0 0 auto; height: 5px; background: linear-gradient(90deg, var(--brand-pink) 0 24%, var(--brand-green) 24% 48%, var(--brand-teal) 48% 72%, var(--brand-blue) 72%); }
/* Reserve the full brand width and align its two-line content with the menu. */
.navbar .navbar-brand { display: inline-flex; align-items: center; vertical-align: middle; }
@media (min-width: 768px) {
  .navbar .navbar-header { flex-shrink: 0; }
  .navbar .navbar-brand { margin-right: 1.5rem; }
}
.navbar .nav-link { color: var(--brand-blue) !important; font-size: .86rem; font-weight: 600; border-bottom: 3px solid transparent; }
.navbar .nav-link.active { color: var(--brand-teal) !important; border-bottom-color: var(--brand-pink); }
#main_nav > li > a > i { display: none; }
.navbar-toggler { border-color: rgba(45, 96, 165, .35); }
.navbar-toggler-icon { filter: invert(34%) sepia(24%) saturate(1750%) hue-rotate(174deg); }
.navbar-toggle { border: 1px solid rgba(45, 96, 165, .3) !important; border-radius: .5rem; background: rgba(201, 220, 185, .18) !important; }
.navbar-toggle .icon-bar { display: block !important; width: 23px !important; height: 2px !important; margin: 4px auto !important; padding: 0 !important; border-radius: 2px; background: var(--brand-blue) !important; }
.brand { display: flex; align-items: center; gap: .65rem; color: var(--brand-blue); }
.brand-faculty-logo { width: 70px; height: 46px; object-fit: contain; }
.brand-copy { display: flex; flex-direction: column; line-height: 1.05; font-family: system-ui, sans-serif; }
.brand-copy strong { font-size: .94rem; letter-spacing: .035em; }
.brand-copy small { color: var(--brand-teal); font-family: system-ui, sans-serif; font-size: .78rem; letter-spacing: 0; }
.university-logo { width: 92px; height: 39px; object-fit: contain; background: #fff; border-radius: .25rem; }
.page-wrap { width: min(1400px, 100%); margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.page-wrap > h2 { margin: .25rem 0 1.25rem; color: var(--brand-blue); font-weight: 700; letter-spacing: .015em; text-transform: uppercase; }
.card { border: 1px solid var(--line); border-radius: .85rem; box-shadow: 0 5px 18px rgba(0, 145, 170, .06); overflow: hidden; }
.card-header { color: var(--brand-blue); font-weight: 700; background: linear-gradient(90deg, rgba(250,225,233,.52), rgba(201,220,185,.3)); border-bottom-color: var(--line); }
.btn-primary { background-color: var(--brand-blue); border-color: var(--brand-blue); }
.btn-primary:hover { background-color: #244f8a; border-color: #244f8a; }
.btn-success { background-color: var(--brand-teal); border-color: var(--brand-teal); }
.form-control:focus, .form-select:focus, .selectize-input.focus { border-color: var(--brand-teal); box-shadow: 0 0 0 .2rem rgba(0,145,170,.14); }
#session_class[hidden] { display: none !important; }
.session-choice-card, .session-choice-card > .card-body { overflow: visible; }
.class-picker { position: relative; }
.class-picker-trigger { display: flex; align-items: center; justify-content: space-between; gap: .75rem; width: 100%; min-height: 64px; padding: .65rem .85rem; text-align: left; color: var(--bs-body-color, #212529); background: #fff; border: 1px solid var(--bs-border-color, #ced4da); border-radius: .375rem; }
.class-picker-trigger::after { content: ""; flex: 0 0 auto; width: .55rem; height: .55rem; margin-right: .15rem; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translateY(-2px); }
.class-picker-trigger[aria-expanded="true"]::after { transform: rotate(225deg) translate(-2px, -2px); }
.class-picker-label { display: block; min-width: 0; overflow-wrap: anywhere; }
.class-picker-name { display: block; font-size: 1rem; font-weight: 600; line-height: 1.4; }
.class-picker-detail { display: block; margin-top: .2rem; font-size: .78rem; font-weight: 400; line-height: 1.4; color: var(--muted); }
.class-picker-options { position: absolute; z-index: 1050; top: calc(100% + 4px); left: 0; right: 0; max-height: min(320px, 45vh); overflow-y: auto; overscroll-behavior: contain; background: #fff; border: 1px solid var(--bs-border-color, #ced4da); border-radius: .375rem; box-shadow: 0 6px 18px rgba(0,0,0,.15); }
.class-picker-options[hidden] { display: none; }
.class-picker-option { padding: .7rem .85rem; cursor: pointer; border-bottom: 1px solid var(--line); }
.class-picker-option:last-child { border-bottom: 0; }
.class-picker-option[aria-selected="true"] { background: #eaf2fc; }
.class-picker-option:hover, .class-picker-option:focus { background: var(--brand-blue); color: #fff; outline: none; }
.class-picker-option:hover .class-picker-detail, .class-picker-option:focus .class-picker-detail { color: #fff; }
.class-picker-trigger:focus-visible { outline: 2px solid var(--brand-teal); outline-offset: 2px; }
.class-picker-trigger:disabled { opacity: .65; cursor: default; }
.metric-card .card-body { min-height: 142px; display: flex; flex-direction: column; justify-content: center; }
.metric-card { border-top: 5px solid var(--brand-teal); }
.metric-card:nth-child(2) { border-top-color: var(--brand-pink); }
.metric-card:nth-child(3) { border-top-color: var(--brand-green); }
.metric-card:nth-child(4) { border-top-color: var(--brand-blue); }
.metric-title { color: var(--brand-teal); font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.metric-value { color: var(--brand-blue); font-family: system-ui, sans-serif; font-size: 2.35rem; line-height: 1.15; font-weight: 700; margin: .35rem 0; }
.metric-subtitle { color: var(--muted); font-size: 1.02rem; }
.overview-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1.5rem; margin-bottom: 1rem; }
.session-class { font-size: 1.2rem; font-weight: 700; }
.session-week { font-family: system-ui, sans-serif; font-size: 2rem; font-weight: 700; color: var(--brand-teal); margin: .35rem 0; }
.session-times { color: var(--muted); margin-bottom: .65rem; }
.session-pill { border-radius: .65rem; margin-top: 1rem; padding: .8rem 1rem; font-size: .9rem; }
.session-pill.inactive { background: var(--soft); color: var(--muted); }
.session-pill.active { background: #ecfdf3; color: #126b33; border: 1px solid #abefc6; }
.qr-reader { width: 100%; min-height: 280px; overflow: hidden; border: 2px dashed #b9c0cb; border-radius: .8rem; background: #f9fafb; }
.qr-reader video { border-radius: .55rem; }
.scanner-actions { display: flex; gap: .6rem; margin-top: .8rem; }
.scanner-actions .btn { flex: 1; }
.scan-feedback-settings { margin-top: .8rem; padding: .7rem .8rem; background: var(--soft); border-radius: .65rem; }
.scan-feedback-settings .form-check { margin: 0; }
.scan-feedback-settings small { display: block; margin: .2rem 0 0 1.5rem; color: var(--muted); }
.scan-feedback { min-height: 170px; border-radius: .8rem; padding: 1.25rem; display: flex; flex-direction: column; justify-content: center; text-align: center; }
.feedback-title { font-size: 1.45rem; font-weight: 700; }
.feedback-detail { margin-top: .45rem; }
.feedback-muted { background: var(--soft); color: #475467; }
.feedback-success { background: #ecfdf3; color: #126b33; border: 1px solid #abefc6; }
.feedback-warning { background: #fffaeb; color: #93370d; border: 1px solid #fedf89; }
.feedback-danger { background: #fef3f2; color: #b42318; border: 1px solid #fecdca; }
.persistence-banner { display: flex; align-items: center; gap: .85rem; margin: 0 0 1rem; padding: .85rem 1rem; color: #24536a; background: linear-gradient(90deg, rgba(201,220,185,.52), rgba(0,145,170,.08)); border: 1px solid #b9d5cf; border-radius: .75rem; }
.persistence-banner small { display: block; color: var(--muted); font-size: .95rem; }
.persistence-icon { display: grid; place-items: center; flex: 0 0 2.2rem; height: 2.2rem; border-radius: 50%; color: #fff; background: var(--brand-teal); font-family: system-ui, sans-serif; font-weight: 700; }
.import-confirmation { margin-top: 1rem; border-top: 5px solid var(--brand-pink); }
.import-confirmation .card-header > div { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; }
.detected-badge { padding: .3rem .65rem; color: #7a3d5a; background: var(--brand-pink-light); border: 1px solid var(--brand-pink); border-radius: 999px; font-family: system-ui, sans-serif; font-size: .9rem; }
.preview-count { margin: .7rem 0; padding: .55rem .8rem; color: var(--brand-blue); background: rgba(201,220,185,.38); border-radius: .55rem; font-weight: 700; }
.confirmation-actions { display: flex; justify-content: flex-end; gap: .65rem; }
.empty-state { color: var(--muted); padding: 2rem 1rem; text-align: center; }
.qr-toolbar, .attendance-toolbar { display: flex; align-items: end; gap: .75rem; justify-content: space-between; flex-wrap: wrap; }
.qr-toolbar .form-group { min-width: 0; width: min(100%, 260px); margin-bottom: 0; }
.qr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr)); gap: 1rem; margin-top: 1rem; }
.student-qr-card { min-width: 0; break-inside: avoid; background: #fff; border: 1px solid var(--line); border-radius: .8rem; overflow: hidden; text-align: center; display: flex; flex-direction: column; }
.student-qr-header { display: flex; align-items: center; gap: .6rem; padding: .9rem .8rem; text-align: left; background: var(--app-background); border-bottom: 1px solid var(--line); }
.student-qr-header > img { width: 42px; height: 38px; object-fit: contain; flex-shrink: 0; }
.student-qr-header > div { min-width: 0; }
.student-qr-header strong { display: block; color: var(--brand-blue); font-size: .8rem; letter-spacing: .035em; }
.student-qr-header small { display: block; color: #007f94; font-size: .64rem; line-height: 1.3; margin-top: .2rem; }
/* A generous white margin surrounds the code at every screen/print size. */
.student-qr-image { box-sizing: border-box; width: 252px; max-width: 100%; padding: 36px; margin: .3rem auto 0; background: #fff; }
.student-qr-image img, .student-qr-image canvas { max-width: 100%; height: auto; margin: auto; }
.student-qr-details { padding: 0 .9rem 1rem; overflow-wrap: anywhere; }
.student-qr-name { color: var(--brand-blue); font-weight: 700; font-size: 1.05rem; line-height: 1.4; }
.student-qr-id { font-family: inherit; font-size: .88rem; color: #344054; margin-top: .35rem; }
.student-qr-class { color: var(--muted); font-size: .8rem; margin-top: .5rem; line-height: 1.4; }
.student-qr-footer { display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap; margin-top: auto; padding: .7rem .9rem; border-top: 1px solid var(--line); color: #007f94; font-size: .7rem; }
.student-qr-footer > span:last-child { color: var(--muted); letter-spacing: .04em; }

.timezone-label { color: var(--muted); font-size: .95rem; padding: .5rem; }
.user-label { display: inline-flex; align-items: center; white-space: nowrap; color: var(--ink); font-size: .88rem; padding: .5rem; }
.user-label .shiny-action-link { color: var(--brand-blue); font-weight: 700; text-decoration: none; }

.auth-page { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: 2rem 1rem; background: var(--app-background); }
.auth-shell { width: min(460px, 100%); min-width: 0; }
.login-introduction { margin: 1.25rem 0 1.5rem; padding: 0 .35rem; }
.login-introduction h2 { margin: 0 0 .65rem; color: var(--brand-blue); font-size: 1.35rem; font-weight: 700; line-height: 1.3; }
.login-introduction p { margin: 0; color: var(--muted); font-size: .95rem; line-height: 1.6; }
.auth-brand { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; padding: 0 .35rem; }
.auth-brand .brand-faculty-logo { width: 76px; height: 52px; }
.auth-university-logo { width: 118px; height: 51px; object-fit: contain; mix-blend-mode: multiply; }
.auth-card { border-top: 6px solid var(--brand-teal); box-shadow: 0 22px 55px rgba(28, 69, 91, .16); }
.auth-card .card-body { padding: 2rem; }
.auth-card h1 { margin: 0 0 .45rem; color: var(--brand-blue); font-size: 2rem; font-weight: 700; }
.auth-subtitle { margin-bottom: 1.5rem; color: var(--muted); }
.auth-submit { margin-top: .4rem; min-height: 46px; font-weight: 700; }
.task-submit.is-busy, .import-submit.is-busy, .auth-submit.is-busy { cursor: wait; opacity: .8; }
.task-submit.is-busy::before, .import-submit.is-busy::before, .auth-submit.is-busy::before, .scan-success-toast.is-pending .scan-success-icon::before { content: ""; display: inline-block; width: 1.15rem; height: 1.15rem; border: 3px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: feedback-spin .8s linear infinite; }
.task-submit.is-busy::before, .import-submit.is-busy::before, .auth-submit.is-busy::before { margin-right: .6rem; vertical-align: -.2rem; }
#login-status:not(:empty) { margin-top: .75rem; }
@keyframes feedback-spin { to { transform: rotate(360deg); } }
.app-credit { width: 100%; padding: 1.15rem 1rem 1.35rem; color: var(--muted); background: rgba(244,248,248,.92); border-top: 1px solid var(--line); font-size: .82rem; line-height: 1.45; text-align: center; }
.app-credit-compact { margin: .8rem 0 0; padding: .35rem .5rem; background: transparent; border: 0; }
.app-version { margin-top: .2rem; color: var(--brand-blue); font-weight: 700; }
.loading-kitten { display: flex; justify-content: center; }
.kitten-stage { width: 200px; height: 200px; max-width: 100%; }
.kitten-stage > svg { display: block; width: 100%; height: 100%; }
.about-page { max-width: 820px; }
.about-page .card-body { padding: 1.5rem; }
.about-brand { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.about-page .app-credit { margin: 1.25rem -1.5rem -1.5rem; width: calc(100% + 3rem); }
.drive-explainer { margin: 0 0 1.25rem; padding: 1rem; border: 1px solid #b9d5cf; border-radius: .7rem; background: rgba(201,220,185,.28); }
.drive-explainer p { margin: .3rem 0 0; color: var(--muted); }
.admin-actions { display: flex; gap: .6rem; flex-wrap: wrap; }

.scan-success-toast { position: fixed; z-index: 3000; top: 50%; left: 50%; width: min(520px, calc(100% - 2rem)); box-sizing: border-box; display: flex; flex-direction: column; align-items: center; gap: 1rem; padding: 1.75rem; text-align: center; color: #0d5f31; background: rgba(236, 253, 243, .98); border: 2px solid #75d69b; border-top: 7px solid #12a150; border-radius: 1.1rem; box-shadow: 0 18px 60px rgba(16, 40, 46, .28); opacity: 0; visibility: hidden; pointer-events: none; transform: translate(-50%, -50%) scale(.96); transition: opacity .18s ease, transform .18s ease, visibility .18s ease; }
.scan-success-toast.is-visible { opacity: 1; visibility: visible; transform: translate(-50%, -50%) scale(1); }
.scan-success-toast.is-late { color: #854a0e; background: rgba(255, 250, 235, .98); border-color: #f7c65e; border-top-color: #f79009; }
.scan-success-toast.is-duplicate { color: #184e83; background: rgba(239, 247, 255, .98); border-color: #8cbce8; border-top-color: #2d60a5; }
.scan-success-toast.is-wrong-class { color: #8c2020; background: rgba(255, 241, 241, .98); border-color: #efa0a0; border-top-color: #c93838; }
.scan-success-icon { display: grid; place-items: center; width: 3.5rem; height: 3.5rem; color: #fff; background: #12a150; border-radius: 50%; font-size: 2rem; font-weight: 700; }
.scan-success-toast.is-late .scan-success-icon { background: #f79009; }
.scan-success-toast.is-duplicate .scan-success-icon { background: #2d60a5; }
.scan-success-toast.is-wrong-class .scan-success-icon { background: #c93838; }
.scan-success-toast.is-pending { color: #854a0e; background: rgba(255, 250, 235, .98); border-color: #f7c65e; border-top-color: #f79009; }
.scan-success-toast.is-pending .scan-success-icon { background: #a85b00; }
.scan-success-toast.is-error { color: #8c2020; background: rgba(255, 241, 241, .98); border-color: #efa0a0; border-top-color: #c93838; }
.scan-success-toast.is-error .scan-success-icon { background: #c93838; }
#scan-reload { pointer-events: auto; }
/* The decoder's green corners mean detection only. App state owns their color. */
#reader #qr-shaded-region > div { background-color: #fff !important; }
#reader[data-scan-state="pending"] #qr-shaded-region > div { background-color: #f79009 !important; }
#reader[data-scan-state="saved"] #qr-shaded-region > div { background-color: #12a150 !important; }
#reader[data-scan-state="error"] #qr-shaded-region > div { background-color: #c93838 !important; }
#reader[data-scan-state="duplicate"] #qr-shaded-region > div { background-color: #2d60a5 !important; }
.scan-success-copy { min-width: 0; width: 100%; overflow-wrap: anywhere; }
.scan-success-toast strong, .scan-success-toast span { display: block; }
.scan-success-toast strong { font-size: 1.1rem; }
#scan-success-name { margin-top: .55rem; font-size: clamp(1.5rem, 5vw, 2rem); font-weight: 700; line-height: 1.25; }
#scan-success-detail { margin-top: .65rem; font-size: 1.15rem; }

@media (max-width: 767px) {
  .page-wrap { padding: 1rem .65rem 5rem; }
  .page-wrap > h2 { font-size: 1.45rem; }
  .checkin-page .bslib-grid { gap: .75rem; }
  .qr-reader { min-height: 245px; }
  .metric-card .card-body { min-height: 105px; }
  .metric-value { font-size: 1.9rem; }
  .overview-metrics { gap: 0; padding: .85rem 0; background: #fff; border: 1px solid var(--line); border-top: 4px solid var(--brand-teal); border-radius: .85rem; box-shadow: 0 5px 18px rgba(0, 145, 170, .06); }
  .overview-metrics > .metric-card { min-width: 0; margin: 0; border: 0; border-radius: 0; box-shadow: none; background: transparent; }
  .overview-metrics > .metric-card + .metric-card { border-left: 1px solid var(--line); }
  .overview-metrics .card-body { min-height: 0; padding: 0 .25rem; gap: 0; text-align: center; justify-content: flex-start; overflow: visible; }
  .overview-metrics .metric-value { order: 0; margin: 0 0 .45rem; font-size: clamp(1.2rem, 6vw, 1.65rem); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
  .overview-metrics .metric-title { order: 1; min-height: 2.6em; font-size: .7rem; line-height: 1.3; font-weight: 500; letter-spacing: 0; text-transform: none; }
  .overview-metrics .metric-subtitle { display: none; }
  .navbar .navbar-collapse {
    position: absolute; top: 100%; left: .65rem; right: .65rem; z-index: 1040;
    padding: .65rem; margin-top: .25rem; background: #fff;
    border: 1px solid var(--line); border-radius: .9rem;
    box-shadow: 0 12px 30px rgba(24, 50, 74, .18);
    max-height: calc(100vh - 6rem); max-height: calc(100dvh - 6rem);
    overflow-y: auto; overscroll-behavior: contain;
  }
  .navbar .navbar-collapse.collapsing { overflow: hidden; }
  #main_nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .4rem; width: 100%; margin: 0; padding: 0; }
  #main_nav > li { min-width: 0; margin: 0; }
  #main_nav > li > .nav-link {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .35rem;
    min-height: 64px; padding: .5rem; font-size: .92rem; line-height: 1.2; text-align: center;
    border: 1px solid var(--line); border-radius: .6rem; white-space: normal;
  }
  #main_nav > li > .nav-link.active { background: #e7f4f4; border-color: var(--brand-teal); box-shadow: inset 3px 0 var(--brand-pink); }
  #main_nav > li > a > i { display: inline-block; margin: 0; font-size: 1.15rem; }
  #main_nav > .bslib-nav-spacer,
  #main_nav > li:has(> .university-logo),
  #main_nav > li:has(> .timezone-label) { display: none; }
  #main_nav > li:has(> .user-label) { grid-column: 1 / -1; margin-top: .25rem; padding-top: .4rem; border-top: 1px solid var(--line); }
  #main_nav .user-label { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .25rem; width: 100%; padding: 0 .25rem; white-space: normal; }
  #main_nav .user-label :is(.shiny-action-link, .action-link) { display: inline-flex; align-items: center; min-height: 44px; padding: .4rem .3rem; }
  .university-logo { margin: .5rem 0; }
  .brand-copy small { display: none; }
  .brand-faculty-logo { width: 62px; height: 40px; }
  .persistence-banner { align-items: flex-start; }
  .confirmation-actions .btn { flex: 1; }
  .scan-success-toast { width: calc(100% - 1.5rem); padding: 1.5rem 1rem; }
  .auth-page { align-items: start; padding-top: 1rem; }
  .auth-card .card-body { padding: 1.35rem; }
  .auth-card h1 { font-size: 1.7rem; }
  .auth-brand .brand-copy small { display: block; }
  .user-label { padding-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .scan-success-toast { transition: none; }
  .task-submit.is-busy::before, .import-submit.is-busy::before, .auth-submit.is-busy::before, .scan-success-toast.is-pending .scan-success-icon::before { animation: none; }
}

@media (max-width: 380px) {
  .auth-brand { gap: .5rem; padding: 0; }
  .auth-brand .brand { gap: .4rem; }
  .auth-brand .brand-faculty-logo { width: 52px; height: 40px; }
  .auth-brand .brand-copy strong { font-size: .8rem; }
  .auth-brand .brand-copy small { font-size: .65rem; }
  .auth-university-logo { width: 84px; height: 40px; }
}

@media print {
  body { background: white; }
  .navbar, .no-print, .qr-toolbar, .card-header, .card-footer, .page-wrap > h2 { display: none !important; }
  .page-wrap, .card-body { padding: 0 !important; margin: 0 !important; }
  .card { border: 0; box-shadow: none; }
  .qr-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6mm; }
  .student-qr-card { border: 1px solid #aaa; padding: 0; box-shadow: none; break-inside: avoid; page-break-inside: avoid; }
  .student-qr-header { padding: 3mm 2mm; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .student-qr-header > img { width: 9mm; height: 9mm; }
  .student-qr-header strong { font-size: 8pt; }
  .student-qr-header small { font-size: 6.5pt; }
  .student-qr-name { font-size: 10pt; }
  .student-qr-id { font-size: 8pt; }
  .student-qr-class { font-size: 8pt; }
  .student-qr-details { padding: 0 2mm 3mm; }
  .student-qr-footer { padding: 2mm; font-size: 7pt; }
}

/* Public Windows edition app mark. */
.brand .kitten-logo { width: 52px; height: 52px; object-fit: contain; }
@media (max-width: 767px) { .brand .kitten-logo { width: 42px; height: 42px; } }

/* Record browsers adapt to their card width, including narrow desktop cards. */
.record-browser { container-type: inline-size; min-width: 0; }
.rb-controls { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr); gap: .7rem; }
.record-browser .shiny-input-container { width: 100%; min-width: 0; }
.rb-filters { margin-bottom: 1rem; }
.rb-filters > summary { color: #3165a9; cursor: pointer; padding: .6rem 0; font-weight: 600; }
.rb-filter-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 .7rem; padding-top: .8rem; }
.rb-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.rb-master, .rb-detail { min-width: 0; }
.rb-list { display: grid; gap: .55rem; }
.rb-row { display: block; width: 100%; min-width: 0; text-align: left; padding: .9rem; border: 1px solid #dce5eb; border-radius: .8rem; background: #fff; color: #24435c; overflow-wrap: anywhere; }
.rb-row:hover { background: #f6fafb; border-color: #9acbd4; }
.rb-row.is-selected { border-color: #0094ad; background: #eef9fa; box-shadow: inset 3px 0 #0094ad; }
.rb-row:focus-visible, .rb-back:focus-visible { outline: 3px solid #3064a7; outline-offset: 2px; }
.rb-row-heading { display: flex; align-items: start; flex-wrap: wrap; gap: .4rem; justify-content: space-between; }
.rb-row-heading strong { flex: 1 1 120px; color: #3064a7; }
.rb-row-subtitle, .rb-row-meta, .rb-row-link { display: block; margin-top: .35rem; }
.rb-row-subtitle { font-size: .93rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rb-row-meta { color: #617589; font-size: .8rem; }
.rb-row-link { color: #007e94; font-size: .8rem; font-weight: 600; }
.rb-detail { background: #f8fbfc; border: 1px solid #dce5eb; border-top: 3px solid #0094ad; border-radius: .8rem; padding: 1rem; overflow-wrap: anywhere; }
.rb-detail-title { color: #3064a7; font-size: 1.15rem; margin: 0 0 .75rem; }
.rb-fields { margin: 1rem 0 0; }
.rb-fields dt { color: #617589; font-size: .8rem; font-weight: 500; }
.rb-fields dd { padding: .15rem 0 .65rem; margin: 0 0 .65rem; border-bottom: 1px solid #e3eaf0; white-space: pre-wrap; }
.rb-fields dd:last-child { margin-bottom: 0; border-bottom: 0; padding-bottom: 0; }
.rb-edit-note { font-size: .85rem; margin: .7rem 0; }
.rb-back { display: none; margin-bottom: 1rem; min-height: 44px; }
.rb-pagination { display: flex; gap: .5rem; justify-content: space-between; align-items: center; margin-top: .8rem; font-size: .8rem; }
.rb-pagination .btn { min-height: 44px; padding-inline: .6rem; }
@container (max-width: 620px) {
  .rb-controls { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .rb-controls > :first-child { grid-column: 1 / -1; }
  .rb-filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rb-layout { grid-template-columns: minmax(0, 1fr); }
  .rb-detail { display: none; }
  .rb-open .rb-detail { display: block; }
  .rb-open .rb-master, .rb-open .rb-controls, .rb-open .rb-filters { display: none; }
  .rb-back { display: inline-block; }
}
@container (min-width: 621px) {
  .rb-list { max-height: 36rem; overflow-y: auto; padding: .2rem; }
  .rb-detail { max-height: 36rem; overflow-y: auto; }
}

/* Attendance submenus remain touch-friendly and wrap on narrow screens. */
#attendance_views { flex-wrap: wrap; }
#attendance_views .nav-link { min-height: 44px; padding: .7rem .85rem; }

/* The language buttons are available before sign-in and inside the mobile menu. */
.language-switch { display: inline-flex; gap: .2rem; padding: .2rem; border: 1px solid var(--line); border-radius: .65rem; background: #fff; align-self: flex-end; }
.language-switch button { border: 0; border-radius: .45rem; background: transparent; color: var(--brand-blue); padding: .4rem .65rem; min-height: 36px; font: inherit; font-size: .85rem; cursor: pointer; }
.language-switch button.is-selected { background: var(--brand-blue); color: #fff; }
.language-switch button:focus-visible { outline: 3px solid var(--brand-teal); outline-offset: 2px; }
.auth-shell > .language-switch { margin: .75rem 0; }
.navbar .language-switch { margin: .25rem .5rem; white-space: nowrap; }
html[lang="th"] .brand-copy { line-height: 1.5; }
html[lang="th"] .brand-copy small { font-size: .75rem; }
html[lang="th"] .btn, html[lang="th"] .nav-link { line-height: 1.6; }
html[lang="th"] .page-wrap > h2 { letter-spacing: 0; }
@media print { .language-switch { display: none !important; } }

/* Explain a lost server connection without dimming an otherwise clickable page.
   Modal backdrops and reconnect dialogs keep their own behavior. */
body.has-connection-warning #shiny-disconnected-overlay { display: none; }
#connection-banner { position: fixed; z-index: 99999; bottom: 1rem; left: 50%; transform: translateX(-50%); width: min(720px, calc(100% - 2rem)); padding: .85rem 1rem; display: flex; align-items: center; justify-content: space-between; gap: .75rem; border: 1px solid #e4b453; border-radius: .7rem; background: #fff3cd; color: #664d03; box-shadow: 0 5px 20px rgba(0,0,0,.15); }
#connection-banner button { flex-shrink: 0; }
@media (max-width: 480px) { #connection-banner { flex-direction: column; align-items: stretch; } }

/* Login password visibility control. */
.login-password-control { display: flex; gap: 8px; margin: -9px 0 15px; align-items: stretch; }
.login-password-control input { flex: 1; min-width: 0; }
.login-password-control button { flex: 0 0 auto; padding: 8px; font-size: 13px; }

/* Keep copy counts comparable in three columns, including on narrow phones. */
#storage-copy-panel table { width: 100%; table-layout: fixed; }
#storage-copy-panel th, #storage-copy-panel td { min-width: 0; padding: 9px 6px; white-space: normal; overflow-wrap: anywhere; }
#storage-copy-panel th:first-child { width: 50%; }
#storage-copy-panel td:not(:first-child), #storage-copy-panel th:not(:first-child) { text-align: center; }
#storage-copy-progress:not(:empty) { margin-top: 16px; }
