/*
 * Indonesia Bertauhid Academy
 * Tokens and components follow DESIGN.md. Red is reserved for the primary action,
 * progress, active state and one "red moment" per page. Links and focus use ink.
 */

:root {
  --paper: #FAF8F7;
  --surface: #FFFFFF;
  --ink: #1C1617;
  --ink-muted: #6B6163;
  --line: #E9E4E4;
  --line-strong: #8F8587;
  --red: #B3122B;
  --red-strong: #9E1024;
  --red-soft: #FBEAEC;
  --on-red: #FFFFFF;
  --on-red-soft: #B3122B;
  --ok: #1B7A4B;
  --ok-soft: #E7F3EC;
  --warn: #8A5A00;
  --warn-soft: #FBF0DA;
  --neutral-soft: #F1EEEE;
  --on-ok: #FFFFFF;
  --on-warn: #FFFFFF;
  --ok-hover: #15613B;
  --warn-hover: #6E4800;
  --ink-hover: #3A3132;
  --shadow: 0 8px 24px rgba(28, 22, 23, .12), 0 1px 3px rgba(28, 22, 23, .08);

  --r-control: 6px;
  --r-card: 12px;
  --r-chip: 4px;

  /* System fonts for Latin text; Amiri only picks up Arabic glyphs the system font lacks. */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Amiri", sans-serif;
  --font-ar: "Amiri", "Traditional Arabic", serif;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #121212;
    --surface: #1C1C1C;
    --ink: #F2F2F2;
    --ink-muted: #A3A3A3;
    --line: #2E2E2E;
    --line-strong: #858585;
    --red: #F04452;
    --red-strong: #FF5A67;
    --red-soft: #2A1416;
    --on-red: #121212;
    --on-red-soft: #FF8A93;
    --ok: #5BD69A;
    --ok-soft: #12261B;
    --warn: #F2B640;
    --warn-soft: #2A2110;
    --neutral-soft: #2A2A2A;
    --on-ok: #121212;
    --on-warn: #121212;
    --ok-hover: #7BE0AE;
    --warn-hover: #F6C766;
    --ink-hover: #FFFFFF;
    --shadow: 0 8px 24px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #121212;
  --surface: #1C1C1C;
  --ink: #F2F2F2;
  --ink-muted: #A3A3A3;
  --line: #2E2E2E;
  --line-strong: #858585;
  --red: #F04452;
  --red-strong: #FF5A67;
  --red-soft: #2A1416;
  --on-red: #121212;
  --on-red-soft: #FF8A93;
  --ok: #5BD69A;
  --ok-soft: #12261B;
  --warn: #F2B640;
  --warn-soft: #2A2110;
  --neutral-soft: #2A2A2A;
  --shadow: 0 8px 24px rgba(0, 0, 0, .5);
  color-scheme: dark;
  --on-ok: #121212;
  --on-warn: #121212;
  --ok-hover: #7BE0AE;
  --warn-hover: #F6C766;
  --ink-hover: #FFFFFF;
}

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

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.2; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 24px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
p { margin: 0 0 1em; }
small, .small { font-size: 13px; }
.muted { color: var(--ink-muted); }
.num { font-variant-numeric: tabular-nums; }
.display { font-size: 30px; line-height: 1.08; letter-spacing: -.02em; }
@media (min-width: 1024px) { .display { font-size: 44px; } h1 { font-size: 30px; letter-spacing: -.02em; } }

a { color: var(--ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

img { max-width: 100%; display: block; }

.ar { font-family: var(--font-ar); font-size: 1.5em; line-height: 2; direction: rtl; text-align: right; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.skip-link { position: absolute; left: 16px; top: -48px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: var(--r-control); }
.skip-link:focus { top: 8px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

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

.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 720px; }
@media (min-width: 640px) { .wrap { padding: 0 24px; } }

.page { padding: 24px 0 48px; }
@media (min-width: 1024px) { .page { padding: 40px 0 72px; } }

.stack > * + * { margin-top: 16px; }
.stack-lg > * + * { margin-top: 32px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.grid-cards { display: grid; gap: 24px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.split { display: grid; gap: 32px; }
@media (min-width: 1024px) { .split { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; } }

.page-head { margin-bottom: 24px; }
.page-head h1 { margin-bottom: 4px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-muted); text-decoration: none; margin-bottom: 8px; min-height: 36px; }
.back-link:hover { color: var(--ink); }

.section-title { font-size: 16px; margin-bottom: 12px; }

/* ---- Header: public ---------------------------------------------------------------------- */

.site-header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.site-header .wrap { display: flex; align-items: center; gap: 16px; min-height: 64px; }
.brand { white-space: nowrap; font-weight: 800; font-size: 15px; line-height: 1.15; text-decoration: none; letter-spacing: -.01em; }
.brand span { display: block; font-weight: 600; font-size: 11px; color: var(--ink-muted); letter-spacing: 0; }
.brand-logo { display: inline-flex; align-items: center; gap: 10px; }
.brand-logo img { height: 44px; width: auto; display: block; }
.brand-logo .brand-label { display: inline-block; padding-left: 10px; border-left: 1px solid var(--line); font-size: 11px; line-height: 1.25; }
.topbar .brand-logo img { height: 36px; }
/* In the sidebar the area label sits under the logo so it never meets the collapse button. */
.sidebar .brand-logo { flex-direction: column; align-items: flex-start; gap: 2px; }
.sidebar .brand-logo img { height: 36px; }
.sidebar .brand-logo .brand-label { padding-left: 0; border-left: 0; color: var(--ink-muted); }
.site-nav { display: none; margin-left: auto; gap: 4px; align-items: center; }
.site-nav a { text-decoration: none; padding: 10px 12px; border-radius: var(--r-control); font-weight: 600; font-size: 14px; }
.site-nav a:hover { background: var(--neutral-soft); }
.site-nav a[aria-current="page"] { color: var(--red); }
.header-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
@media (min-width: 1024px) {
  .site-nav { display: flex; }
  .header-actions { margin-left: 8px; }
  .menu-toggle, .mobile-only { display: none !important; }
}

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: var(--r-control);
  background: transparent; border: 1px solid transparent; color: var(--ink); cursor: pointer;
}
.icon-btn:hover { background: var(--neutral-soft); }
.icon-btn .badge-count { position: absolute; }

.mobile-menu { display: none; border-top: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); }
.mobile-menu.is-open { display: block; }
.mobile-menu a { display: block; padding: 14px 16px; text-decoration: none; font-weight: 600; border-bottom: 1px solid var(--line); }
@media (min-width: 1024px) { .mobile-menu { display: none !important; } }

.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: inline; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: inline; }
}

/* ---- App shell: sidebar (fixed on desktop, drawer on phones and tablets) ---------------- */

.sidebar {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 50; width: 264px;
  display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--line);
  transform: translateX(-100%); visibility: hidden;
  transition: transform .2s ease, visibility 0s linear .2s;
}
body.nav-open .sidebar { transform: none; visibility: visible; box-shadow: var(--shadow); transition: transform .2s ease; }
.sidebar-backdrop { display: none; position: fixed; inset: 0; z-index: 45; background: rgba(0, 0, 0, .5); }
body.nav-open .sidebar-backdrop { display: block; }
body.nav-open { overflow: hidden; }

.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 64px; padding: 0 12px 0 20px; border-bottom: 1px solid var(--line); }
.side-nav { flex: 1; overflow-y: auto; padding: 8px 12px 16px; }
.side-nav ul { list-style: none; margin: 0; padding: 0; }
.side-group-label { margin: 16px 12px 6px; font-size: 11px; font-weight: 700; color: var(--ink-muted); }
.side-link {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 8px 12px;
  border-radius: var(--r-control); text-decoration: none; font-weight: 600; font-size: 14px; color: var(--ink-muted);
}
.side-link:hover { background: var(--neutral-soft); color: var(--ink); }
.side-link[aria-current="page"] { background: var(--red-soft); color: var(--on-red-soft); }
.side-link .dot-count, .side-link .side-ext { margin-left: auto; }

.sidebar-foot { border-top: 1px solid var(--line); padding: 12px; }
.side-user { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--r-control); text-decoration: none; min-width: 0; }
a.side-user:hover { background: var(--neutral-soft); }
.side-user[aria-current="page"] { background: var(--red-soft); }
.side-user-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.side-user-text strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-user-text span { font-size: 12px; color: var(--ink-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }

.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; min-height: 60px; padding: 0 8px; background: var(--surface); border-bottom: 1px solid var(--line); }

.sidebar-collapse { display: none; }

@media (min-width: 1024px) {
  .sidebar { transform: none; visibility: visible; transition: width .15s ease; }
  .shell-main { transition: margin-left .15s ease; }
  .sidebar-collapse { display: inline-flex; }

  /* Mini sidebar: icons only. Labels stay in the accessibility tree and show as tooltips. */
  :root[data-sidebar="mini"] .sidebar { width: 72px; }
  :root[data-sidebar="mini"] .shell-main { margin-left: 72px !important; }
  :root[data-sidebar="mini"] .sidebar .brand { display: none; }
  :root[data-sidebar="mini"] .sidebar-head { justify-content: center; padding: 0; }
  :root[data-sidebar="mini"] .side-nav { padding: 8px 12px 16px; }
  :root[data-sidebar="mini"] .side-group-label { height: 1px; margin: 12px 8px; overflow: hidden; color: transparent; background: var(--line); }
  :root[data-sidebar="mini"] .side-label, :root[data-sidebar="mini"] .side-ext, :root[data-sidebar="mini"] .side-user-text {
    position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
  :root[data-sidebar="mini"] .side-link { justify-content: center; padding: 8px 0; position: relative; }
  :root[data-sidebar="mini"] .side-link .dot-count { position: absolute; top: 2px; right: 2px; min-width: 18px; height: 18px; padding: 0 4px; font-size: 11px; margin: 0; }
  :root[data-sidebar="mini"] .sidebar-foot { padding: 12px 8px; }
  :root[data-sidebar="mini"] .side-user { justify-content: center; padding: 4px; }
  :root[data-sidebar="mini"] .side-actions { flex-direction: column; gap: 4px; }
  :root[data-sidebar="mini"] .side-logout { width: 40px; height: 40px; padding: 0; }

  .sidebar-close, .sidebar-backdrop, .topbar { display: none !important; }
  .shell-main { margin-left: 264px; }
  body.nav-open { overflow: auto; }
}

/* ---- Participant: bottom tab bar on phones -------------------------------------------- */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 56px; font-size: 11px; font-weight: 600; text-decoration: none; color: var(--ink-muted);
}
.tabbar a[aria-current="page"] { color: var(--red); }
.has-tabbar { padding-bottom: 72px; }
@media (min-width: 1024px) { .tabbar { display: none; } .has-tabbar { padding-bottom: 0; } }

.dot-count {
  display: inline-flex; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  align-items: center; justify-content: center; font-size: 12px; font-weight: 700;
  background: var(--red); color: var(--on-red);
}

/* ---- Footer -------------------------------------------------------------------------------- */

.site-footer { border-top: 1px solid var(--line); padding: 32px 0; font-size: 13px; color: var(--ink-muted); }
.site-footer .row-between { align-items: flex-start; }
.site-footer nav { display: flex; gap: 4px 16px; flex-wrap: wrap; }
.site-footer a { color: var(--ink-muted); display: inline-block; padding: 10px 0; }

/* ---- Buttons ------------------------------------------------------------------------------- */

.btn {
  --btn-bg: transparent; --btn-color: var(--ink); --btn-border: transparent;
  --btn-hover-bg: var(--neutral-soft); --btn-hover-color: var(--ink); --btn-hover-border: transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 7px 14px; border-radius: var(--r-control);
  font: inherit; font-weight: 700; font-size: 14px; line-height: 1.2; text-decoration: none; text-align: center; white-space: nowrap;
  border: 1px solid var(--btn-border); background: var(--btn-bg); color: var(--btn-color); cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--btn-hover-bg); color: var(--btn-hover-color); border-color: var(--btn-hover-border); }

/*
 * Variants follow Bootstrap 5 names, mapped to DESIGN.md tokens:
 * primary = brand red, success/warning = status colours, danger/dark = ink (red is never used for
 * destructive actions, so "Hapus" cannot be mistaken for "Daftar"). There is no info variant:
 * the palette has no info colour.
 */
.btn-primary   { --btn-bg: var(--red); --btn-color: var(--on-red); --btn-border: var(--red); --btn-hover-bg: var(--red-strong); --btn-hover-color: var(--on-red); --btn-hover-border: var(--red-strong); }
.btn-secondary { --btn-bg: var(--neutral-soft); --btn-border: var(--neutral-soft); --btn-hover-bg: var(--line); --btn-hover-border: var(--line); }
.btn-success   { --btn-bg: var(--ok); --btn-color: var(--on-ok); --btn-border: var(--ok); --btn-hover-bg: var(--ok-hover); --btn-hover-color: var(--on-ok); --btn-hover-border: var(--ok-hover); }
.btn-warning   { --btn-bg: var(--warn); --btn-color: var(--on-warn); --btn-border: var(--warn); --btn-hover-bg: var(--warn-hover); --btn-hover-color: var(--on-warn); --btn-hover-border: var(--warn-hover); }
.btn-danger, .btn-dark { --btn-bg: var(--ink); --btn-color: var(--paper); --btn-border: var(--ink); --btn-hover-bg: var(--ink-hover); --btn-hover-color: var(--paper); --btn-hover-border: var(--ink-hover); }
.btn-light     { --btn-bg: var(--surface); --btn-border: var(--line); --btn-hover-bg: var(--neutral-soft); --btn-hover-border: var(--line-strong); }

.btn-outline-primary   { --btn-color: var(--red); --btn-border: var(--red); --btn-hover-bg: var(--red); --btn-hover-color: var(--on-red); --btn-hover-border: var(--red); }
.btn-outline-secondary { --btn-border: var(--line-strong); --btn-hover-border: var(--line-strong); }
.btn-outline-success   { --btn-color: var(--ok); --btn-border: var(--ok); --btn-hover-bg: var(--ok); --btn-hover-color: var(--on-ok); --btn-hover-border: var(--ok); }
.btn-outline-warning   { --btn-color: var(--warn); --btn-border: var(--warn); --btn-hover-bg: var(--warn); --btn-hover-color: var(--on-warn); --btn-hover-border: var(--warn); }
.btn-outline-danger, .btn-outline-dark { --btn-border: var(--ink); --btn-hover-bg: var(--ink); --btn-hover-color: var(--paper); --btn-hover-border: var(--ink); }

/* Ghost: no border until hovered (sidebar, toolbars). Link: looks like a text link. */
.btn-ghost { --btn-bg: transparent; --btn-border: transparent; }
.btn-link  { --btn-hover-bg: transparent; text-decoration: underline; text-underline-offset: 3px; font-weight: 600; }
.btn-link:hover { text-decoration-thickness: 2px; }

.btn .icon { width: 16px; height: 16px; flex: none; }
.btn-sm { min-height: 30px; padding: 4px 10px; font-size: 13px; }
.btn-sm .icon { width: 14px; height: 14px; }
.btn-lg { min-height: 42px; padding: 9px 18px; font-size: 15px; }
.btn-lg .icon { width: 18px; height: 18px; }

/* Compact on screen, but a touch still gets a 44px target: an invisible hit area around the control. */
@media (pointer: coarse) {
  .btn, .icon-btn, .filters a { position: relative; }
  .btn::after, .filters a::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 44px; transform: translateY(-50%); }
  .icon-btn::after { content: ""; position: absolute; inset: -2px; }
}
.btn-block { width: 100%; white-space: normal; text-align: center; }  /* long labels (batch name + price) wrap instead of spilling out */
.btn:disabled, .btn.disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; pointer-events: none; }
.inline-form { display: inline; }

/* ---- Forms ---------------------------------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: 6px; }
.field + .field { margin-top: 16px; }
.field label, .label { font-weight: 600; font-size: 14px; }
.field .hint { font-size: 13px; color: var(--ink-muted); }
.input, .field input[type="text"], .field input[type="email"], .field input[type="password"], .field input[type="tel"],
.field input[type="number"], .field input[type="date"], .field input[type="url"], .field input[type="search"], .field select, .field textarea, .input-plain {
  width: 100%; min-height: 40px; padding: 8px 12px; line-height: 1.4; border-radius: var(--r-control);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font: inherit; font-size: 14px;
}
@media (pointer: coarse) {
  .input, .field input, .field select, .field textarea, .input-plain, .chat-form textarea, .option-row input[type="text"] { font-size: 16px; }
}
/* Password with a show / hide button inside the field. */
.password-field { position: relative; display: block; }
.password-field input { width: 100%; padding-right: 48px !important; }
.password-toggle { position: absolute; top: 50%; right: 4px; transform: translateY(-50%); width: 40px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: var(--r-control); background: transparent; color: var(--ink-muted); cursor: pointer; }
.password-toggle:hover { color: var(--ink); background: var(--neutral-soft); }
.password-toggle[aria-pressed="true"] { color: var(--ink); }
.field textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
.field input[type="file"] { font: inherit; font-size: 14px; padding: 8px 0; }
.field-error { color: var(--ink); font-weight: 700; font-size: 13px; display: flex; gap: 6px; align-items: flex-start; }
.field-error svg { flex: none; margin-top: 2px; }
.is-invalid { border-width: 2px !important; border-color: var(--ink) !important; }
.check { display: flex; gap: 10px; align-items: flex-start; min-height: 44px; padding-top: 10px; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--red); flex: none; }
.choice-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; }
.choice span {
  display: flex; align-items: center; justify-content: center; min-height: 40px; padding: 8px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--r-control); font-weight: 600; cursor: pointer;
}
.choice input:checked + span { border: 2px solid var(--red); color: var(--on-red-soft); background: var(--red-soft); }
.choice input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 2px; }
.form-grid { display: grid; gap: 16px; }
.form-grid .field + .field { margin-top: 0; }
@media (min-width: 640px) { .form-grid-2 { grid-template-columns: 1fr 1fr; } }
.form-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 24px; }

.search-form { display: flex; gap: 8px; align-items: center; }
.search-form input { flex: 1; min-width: 0; }

/* ---- Surfaces ------------------------------------------------------------------------------ */

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 20px; }
.card-tight { padding: 16px; }
@media (min-width: 640px) { .card { padding: 24px; } }
.card h2, .card h3 { margin-bottom: 8px; }
.divider { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }

/* The one red block per page, placed at the main decision. */
.moment { background: var(--red); color: var(--on-red); border-radius: var(--r-card); padding: 24px; }
.moment a:not(.btn), .moment .muted { color: var(--on-red); }
.moment .btn { --btn-bg: var(--on-red); --btn-color: var(--red); --btn-border: var(--on-red); --btn-hover-bg: var(--paper); --btn-hover-color: var(--red); --btn-hover-border: var(--paper); }
.moment-label { font-size: 13px; font-weight: 600; opacity: .9; margin-bottom: 6px; }
@media (min-width: 1024px) { .moment { padding: 32px; } }
/* Next-batch block with the course cover: cover on top on phones, on the left from tablet up. */
.moment-with-cover { display: grid; gap: 20px; }
.moment-cover { display: block; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; background: var(--red-strong); }
.moment-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
@media (min-width: 768px) {
  .moment-with-cover { grid-template-columns: minmax(220px, 320px) minmax(0, 1fr); align-items: center; gap: 28px; }
  .moment-with-cover .moment-body { align-self: stretch; }
}

/* ---- Chips --------------------------------------------------------------------------------- */

.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: var(--r-chip);
  font-size: 12px; font-weight: 700; line-height: 1.6; background: var(--neutral-soft); color: var(--ink-muted); white-space: nowrap;
}
.chip-run { background: var(--red-soft); color: var(--on-red-soft); }
.chip-ok { background: var(--ok-soft); color: var(--ok); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }
.chip-strong { background: var(--neutral-soft); color: var(--ink); }

/* ---- Flash messages ------------------------------------------------------------------------ */

.flash { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: var(--r-control); margin-bottom: 20px; border: 1px solid var(--line); background: var(--surface); }
.flash svg { flex: none; margin-top: 3px; }
.flash-success { background: var(--ok-soft); border-color: transparent; color: var(--ok); font-weight: 600; }
.flash-error { border: 2px solid var(--ink); font-weight: 700; }
.flash-info { background: var(--warn-soft); border-color: transparent; color: var(--warn); font-weight: 600; }

/* Toasts for AJAX results: fixed above the phone tab bar, no animation (MOTION 1). */
.toast-region { position: fixed; z-index: 60; right: 16px; bottom: 16px; left: 16px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; pointer-events: none; }
.has-tabbar .toast-region { bottom: 80px; }
@media (min-width: 1024px) { .toast-region { left: auto; width: 380px; } .has-tabbar .toast-region { bottom: 16px; } }
.toast { margin: 0; box-shadow: var(--shadow); pointer-events: auto; max-width: 100%; }
.flash-success.toast { background: var(--surface); color: var(--ok); border: 1px solid var(--line); }
.flash-error.toast { background: var(--surface); }

/* Modal: one shared <dialog>; header and footer stay put, the body scrolls. */
.modal { border: 0; padding: 0; width: min(680px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); border-radius: var(--r-card); background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(0, 0, 0, .5); }
.modal[open] { display: flex; }
.modal-panel { display: flex; flex-direction: column; width: 100%; max-height: calc(100dvh - 48px); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 16px 12px 20px; border-bottom: 1px solid var(--line); }
.modal-title { font-size: 17px; margin: 0 0 2px; }
.modal-form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.modal-body { padding: 16px 20px; overflow-y: auto; flex: 1; align-content: start; }
.modal-confirm { width: min(440px, calc(100vw - 32px)); }
.modal-confirm .modal-body { padding: 20px 20px 16px; }
.modal-confirm .modal-title { margin-bottom: 8px; }
.confirm-text { margin: 0; font-size: 14px; color: var(--ink-muted); }
.confirm-note { margin: 12px 0 0; padding: 8px 12px; border-radius: var(--r-control); font-size: 13px; font-weight: 600; background: var(--ok-soft); color: var(--ok); }
.confirm-note.is-warn { background: var(--warn-soft); color: var(--warn); }
.modal-loading { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 180px; padding: 24px; font-size: 14px; color: var(--ink-muted); }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--red); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }
.modal-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); }
@media (max-width: 639px) {
  .modal { width: 100vw; max-width: 100vw; max-height: 92dvh; margin: auto 0 0; border-radius: var(--r-card) var(--r-card) 0 0; }
  .modal-panel { max-height: 92dvh; }
  .modal-foot .btn { flex: 1; }
}

/* Bank accounts on the payment page and in Pengaturan. */
.bank-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.bank-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-control); background: var(--paper); }
.bank-item > div { display: flex; flex-direction: column; min-width: 0; }
.bank-number { font-size: 18px; font-weight: 800; letter-spacing: .02em; overflow-wrap: anywhere; }

/* Payment proof review (admin modal). */
.review-grid { display: grid; gap: 16px; }
@media (min-width: 640px) { .review-grid { grid-template-columns: 240px minmax(0, 1fr); } }
.proof-preview { display: block; border: 1px solid var(--line); border-radius: var(--r-control); overflow: hidden; background: var(--neutral-soft); }
.proof-preview img { width: 100%; max-height: 360px; object-fit: contain; display: block; }

/* ---- Empty, locked, loading states ---------------------------------------------------------- */

.empty { border: 1px dashed var(--line-strong); border-radius: var(--r-card); padding: 32px 20px; text-align: center; }
.empty h2, .empty h3 { margin-bottom: 6px; }
.empty p { color: var(--ink-muted); max-width: 46ch; margin: 0 auto 16px; }
.loading-text { color: var(--ink-muted); font-size: 13px; }

/* ---- Course card ---------------------------------------------------------------------------- */

.course-card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; text-decoration: none; }
.course-card:hover { border-color: var(--line-strong); }
.course-card:hover h3 { text-decoration: underline; text-underline-offset: 3px; }
.poster { aspect-ratio: 16 / 9; background: var(--neutral-soft); display: flex; align-items: flex-end; padding: 16px; position: relative; }
.poster img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.poster-fallback { font-weight: 800; font-size: 19px; line-height: 1.15; letter-spacing: -.01em; position: relative; }
.course-card.no-poster .body { padding-top: 20px; }
.course-card .body { padding: 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.course-card h3 { font-size: 16px; margin: 0; }
.course-card .price { font-weight: 800; }
.course-card .extra { display: none; font-size: 13px; color: var(--ink-muted); }
@media (min-width: 640px) { .course-card .extra { display: block; } }

/* Admin index pages: filter row (search + selects) and results that swap in place. */
.index-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.index-search { position: relative; flex: 1 1 260px; min-width: 0; }
.index-search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-muted); pointer-events: none; }
.index-search input, .index-select select { width: 100%; min-height: 38px; padding: 7px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-control); background: var(--surface); color: var(--ink); font: inherit; font-size: 14px; }
.index-search input { padding-left: 34px; }
.index-select { flex: 0 1 200px; min-width: 150px; }
@media (max-width: 639px) { .index-select { flex: 1 1 calc(50% - 4px); min-width: 0; } }
@media (pointer: coarse) { .index-search input, .index-select select { font-size: 16px; } }
.index-count { margin: 0 0 10px; }
[data-index-results][aria-busy="true"] { opacity: .55; transition: opacity .15s; }

/* ---- Compact course tile (landing) ---------------------------------------------------------- */

.tile-grid { display: grid; gap: 16px; }
@media (min-width: 640px) { .tile-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 28px 20px; } }
.tile { display: grid; grid-template-columns: 128px minmax(0, 1fr); gap: 12px; align-items: start; text-decoration: none; color: var(--ink); }
@media (min-width: 640px) { .tile { display: flex; flex-direction: column; gap: 10px; } }
.tile-cover { width: 100%; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; background: var(--neutral-soft); border: 1px solid var(--line); position: relative; }
.tile-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile:hover .tile-cover img { opacity: .92; }
.tile:hover .tile-title { text-decoration: underline; text-underline-offset: 3px; }
.tile-fallback { position: absolute; inset: 0; display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; gap: 8px; }
.tile-weeks { display: flex; flex-direction: column; gap: 3px; }
.tile-row { display: flex; gap: 3px; }
.tile-row i { width: 10px; height: 10px; border: 1.5px solid var(--line-strong); border-radius: 1px; }
.tile-row:first-child i { background: var(--red); border-color: var(--red); }
.tile-fallback-label { align-self: flex-end; font-size: 12px; font-weight: 700; color: var(--ink-muted); }
@media (max-width: 639px) { .tile-row i { width: 7px; height: 7px; } .tile-fallback { padding: 6px 8px; } .tile-fallback-label { font-size: 11px; } }
.tile-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tile-body p { margin: 0; }
.tile-title { font-size: 15px; line-height: 1.3; margin: 0 0 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile-instructor { font-size: 12px; color: var(--ink-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-meta { font-size: 12px; color: var(--ink-muted); }
.tile-price { display: flex; align-items: center; gap: 8px; margin-top: 2px !important; font-size: 15px; }
.tile-seats { font-size: 12px; color: var(--ink-muted); }

/* ---- Tabs and filters ---------------------------------------------------------------------- */

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs a { padding: 12px 14px; min-height: 44px; text-decoration: none; font-weight: 600; color: var(--ink-muted); border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--red); }
.filters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.filters a { display: inline-flex; align-items: center; min-height: 34px; padding: 4px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-control); text-decoration: none; font-weight: 600; font-size: 13px; white-space: nowrap; }
.filters a[aria-current="page"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* ---- Progress ------------------------------------------------------------------------------- */

.bar { height: 8px; background: var(--neutral-soft); border-radius: 4px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--red); }
.progress-line { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.progress-line .bar { flex: 1; }

/* ---- Identity motif: the week strip --------------------------------------------------------- */

.strip { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.strip-label { font-size: 12px; font-weight: 700; color: var(--ink-muted); min-width: 64px; }
.strip-days { display: flex; gap: 6px; }
.strip-day {
  width: 28px; height: 28px; border-radius: 2px; display: inline-flex; align-items: center; justify-content: center;
  border: 1.5px dashed var(--line-strong); background: transparent; color: var(--on-red); text-decoration: none;
}
.strip-day.is-open { border: 1.5px solid var(--ink); }
.strip-day.is-done { border: 1.5px solid var(--red); background: var(--red); }
.strip-day.is-today { outline: 2px solid var(--ink); outline-offset: 2px; }
a.strip-day:hover { border-style: solid; border-color: var(--ink); }
.strip-sep { width: 1px; height: 20px; background: var(--line-strong); margin: 0 4px; }
.strip-eval { width: 28px; height: 28px; border-radius: 50%; border: 1.5px dashed var(--line-strong); display: inline-flex; align-items: center; justify-content: center; color: var(--surface); text-decoration: none; }
.strip-eval.is-open { border: 1.5px solid var(--ink); }
.strip-eval.is-done { background: var(--ok); border: 1.5px solid var(--ok); color: var(--surface); }
.strip-eval.is-missed { border: 1.5px solid var(--line-strong); color: var(--ink-muted); }
.strip-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 12px; color: var(--ink-muted); }
.strip-legend span { display: inline-flex; align-items: center; gap: 6px; }
.strip-legend .strip-day, .strip-legend .strip-eval { width: 16px; height: 16px; }
.strip-sm .strip-day, .strip-sm .strip-eval { width: 18px; height: 18px; }
.strip-sm .strip-day svg, .strip-sm .strip-eval svg { width: 12px; height: 12px; }

/* ---- Lists: materials, evaluations, schedule ----------------------------------------------- */

.list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); overflow: hidden; }
.list > li + li { border-top: 1px solid var(--line); }
.list-item { display: flex; gap: 12px; align-items: center; padding: 14px 16px; min-height: 56px; text-decoration: none; }
a.list-item:hover { background: var(--neutral-soft); }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; display: block; }
.list-item .meta { font-size: 13px; color: var(--ink-muted); display: block; }
.list-num { width: 28px; flex: none; font-weight: 700; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.state-icon { flex: none; width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; border-radius: 2px; }
.state-icon.is-done { background: var(--red); color: var(--on-red); }
.state-icon.is-open { border: 1.5px solid var(--ink); }
.state-icon.is-locked { color: var(--ink-muted); }

.thumb { flex: none; position: relative; width: 112px; aspect-ratio: 16 / 9; border-radius: 6px; overflow: hidden; background: var(--neutral-soft); display: flex; align-items: center; justify-content: center; color: var(--ink-muted); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.is-locked img { opacity: .45; filter: grayscale(1); }
.thumb-play { position: absolute; width: 28px; height: 28px; border-radius: 50%; background: rgba(0, 0, 0, .65); color: #FFFFFF; display: flex; align-items: center; justify-content: center; }
.thumb-play .icon { fill: currentColor; }
@media (max-width: 639px) { .thumb { width: 88px; } }

.week-block + .week-block { margin-top: 28px; }
.week-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.week-head h3 { margin: 0; }

.day-group + .day-group { margin-top: 24px; }
.day-title { font-size: 14px; font-weight: 700; margin-bottom: 8px; }
.day-title .chip { margin-left: 6px; }

/* Course page: on phones the batch choice comes right after the course facts. */
.course-layout { display: grid; gap: 32px; }
@media (min-width: 1024px) {
  .course-layout { grid-template-columns: minmax(0, 1fr) 340px; grid-template-areas: "head aside" "body aside"; align-items: start; }
  .course-layout > .course-head { grid-area: head; }
  .course-layout > .course-aside { grid-area: aside; }
  .course-layout > .course-body { grid-area: body; }
}

/* Page header with the course cover: cover on top on phones, at the left from tablet up. */
.cover-head { display: grid; gap: 16px; margin-bottom: 24px; }
.cover-head .page-head { margin-bottom: 0; }
.cover-img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--r-card); border: 1px solid var(--line); background: var(--neutral-soft); }
@media (min-width: 768px) {
  .cover-head:has(.cover-img) { grid-template-columns: 240px minmax(0, 1fr); gap: 24px; align-items: center; }
}

/* Material page: content + playlist (right column on wide screens, below the content on phones). */
.lesson-layout { display: grid; gap: 32px; max-width: 1120px; }
@media (min-width: 1100px) { .lesson-layout { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; } }
.lesson-main { min-width: 0; max-width: 760px; }
.lesson-pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 24px; }
.lesson-step { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: var(--r-card); text-decoration: none; color: var(--ink); min-width: 0; }
a.lesson-step:hover { background: var(--neutral-soft); }
.lesson-step.is-next { text-align: right; align-items: flex-end; }
.lesson-step.is-locked { border-style: dashed; color: var(--ink-muted); }
.lesson-step-dir { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--ink-muted); }
.lesson-step-title { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.lesson-aside { min-width: 0; }
@media (min-width: 1100px) { .lesson-aside { position: sticky; top: 24px; } }
.playlist { border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); overflow: hidden; }
.playlist-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.playlist-list { position: relative; list-style: none; margin: 0; padding: 6px; max-height: 70vh; overflow-y: auto; }
@media (max-width: 1099px) { .playlist-list { max-height: none; } }
.playlist-week { font-size: 11px; font-weight: 700; color: var(--ink-muted); padding: 10px 10px 4px; }
.playlist-item { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: var(--r-control); text-decoration: none; color: var(--ink); min-height: 44px; }
a.playlist-item:hover { background: var(--neutral-soft); }
.playlist-item[aria-current="page"] { background: var(--red-soft); }
.playlist-item[aria-current="page"] .playlist-title { color: var(--on-red-soft); }
.playlist-item.is-locked { color: var(--ink-muted); }
.playlist-item .state-icon { width: 22px; height: 22px; margin-top: 1px; }
.playlist-text { display: flex; flex-direction: column; min-width: 0; }
.playlist-title { font-size: 13px; font-weight: 600; line-height: 1.35; }
.playlist-meta { font-size: 12px; color: var(--ink-muted); }

/* ---- Batch detail (admin) --------------------------------------------------------------------- */
.batch-head { display: grid; gap: 16px; align-items: center; margin-bottom: 20px; }
@media (min-width: 900px) { .batch-head { grid-template-columns: auto minmax(0, 1fr) auto; gap: 20px; } }
.batch-head-cover { width: 100%; max-width: 200px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--r-card); border: 1px solid var(--line); }
@media (max-width: 899px) { .batch-head-cover { max-width: none; } }
.batch-head-course { margin: 0 0 2px; font-size: 13px; }
.batch-head-course a { color: var(--ink-muted); text-decoration: none; }
.batch-head-course a:hover { color: var(--ink); text-decoration: underline; }
.batch-head h1 { margin: 0 0 8px; }
.batch-head-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.overview-grid { display: grid; gap: 16px; }
@media (min-width: 1100px) { .overview-grid { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; } }

/* Batch lifecycle (Draft -> Arsip): done steps checked, the current one in red. */
.stepper { list-style: none; margin: 0 0 20px; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.stepper li { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.stepper li::before { content: ""; position: absolute; top: 10px; left: -50%; width: 100%; height: 2px; background: var(--line); z-index: 0; }
.stepper li:first-child::before { display: none; }
.stepper li.is-done::before, .stepper li.is-current::before { background: var(--red); }
.stepper-dot { position: relative; z-index: 1; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line-strong); background: var(--surface); display: inline-flex; align-items: center; justify-content: center; color: var(--on-red); }
.stepper .is-done .stepper-dot { background: var(--red); border-color: var(--red); }
.stepper .is-current .stepper-dot { border-color: var(--red); box-shadow: inset 0 0 0 4px var(--surface), inset 0 0 0 11px var(--red); }
.stepper-label { font-size: 12px; color: var(--ink-muted); font-weight: 600; }
.stepper .is-current .stepper-label { color: var(--ink); font-weight: 800; }

.fact-grid { display: grid; gap: 16px 20px; margin: 0; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.fact { display: flex; gap: 12px; align-items: flex-start; min-width: 0; }
.fact-icon { flex: none; width: 36px; height: 36px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; background: var(--tone-bg); color: var(--tone-fg); }
.fact dt { font-size: 12px; font-weight: 600; color: var(--ink-muted); }
.fact dd { margin: 0; font-size: 15px; font-weight: 700; }
.fact dd.fact-sub, .fact-sub { display: block; font-size: 12px; font-weight: 400; color: var(--ink-muted); }

.seat-grid { display: grid; gap: 16px; }
@media (min-width: 640px) { .seat-grid { grid-template-columns: 1fr 1fr; gap: 24px; } }
.seat { display: flex; flex-direction: column; gap: 6px; }
.seat-label { font-size: 13px; font-weight: 700; }
.seat-value { font-size: 18px; font-weight: 800; }
.seat-value .muted { font-size: 13px; font-weight: 600; }

.danger-zone { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 24px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r-card); }
.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; font-size: 13px; }
.checklist li { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r-control); }
.checklist li .icon { flex: none; margin-top: 2px; }
.checklist .is-ok { background: var(--ok-soft); color: var(--ok); }
.checklist .is-warn { background: var(--warn-soft); color: var(--warn); }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; margin-bottom: 4px; }
.toolbar .index-filters { flex: 1 1 520px; margin-bottom: 8px; }

.schedule-weeks { display: grid; gap: 12px; }
@media (min-width: 1100px) { .schedule-weeks { grid-template-columns: 1fr 1fr; } }
.schedule-list { list-style: none; margin: 0; padding: 0; }
.schedule-list li { display: grid; grid-template-columns: 116px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 7px 0; border-top: 1px solid var(--line); font-size: 13px; }
.schedule-list li:first-child { border-top: 0; }
.schedule-when { color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.schedule-list .is-past .schedule-what { color: var(--ink-muted); }
.schedule-list .is-today { font-weight: 700; }
.schedule-list .is-eval .schedule-what { font-weight: 700; }
@media (max-width: 639px) { .schedule-list li { grid-template-columns: 1fr auto; } .schedule-when { grid-column: 1 / -1; } }

/* Segmented control (tabs inside a modal). */
.segmented { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--r-control); background: var(--neutral-soft); }
.segmented [role="tab"] { padding: 6px 14px; border-radius: 4px; font-size: 13px; font-weight: 700; text-decoration: none; color: var(--ink-muted); }
.segmented [role="tab"][aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }

.candidate-results { min-height: 48px; }
.candidate-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 260px; overflow-y: auto; }
.candidate { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-control); cursor: pointer; }
.candidate:hover { border-color: var(--line-strong); }
.candidate:has(input:checked) { border: 2px solid var(--red); background: var(--red-soft); }
.candidate input { width: 18px; height: 18px; accent-color: var(--red); flex: none; }
.candidate .avatar { width: 32px; height: 32px; font-size: 13px; }
.candidate-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.candidate-text strong { font-size: 14px; }
.candidate.is-disabled { opacity: .55; cursor: not-allowed; }
.enroll-options { border: 0; padding: 12px 0 0; margin: 12px 0 0; border-top: 1px solid var(--line); }

/* ---- Material and evaluation pages --------------------------------------------------------- */

.player { background: #000; border-radius: var(--r-card); overflow: hidden; aspect-ratio: 16 / 9; }
.player iframe, .player video { width: 100%; height: 100%; border: 0; display: block; }
.audio-player { width: 100%; }
.prose { font-size: 16px; line-height: 1.75; }
.prose h2 { font-size: 19px; margin-top: 1.5em; }
.prose h3 { font-size: 16px; margin-top: 1.4em; }
.prose blockquote { margin: 1em 0; padding: 4px 0 4px 16px; border-left: 3px solid var(--line-strong); color: var(--ink-muted); }
.pager { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.question { border: 1px solid var(--line); border-radius: var(--r-card); padding: 20px; background: var(--surface); }
.question + .question { margin-top: 16px; }
.question legend { font-weight: 700; padding: 0; margin-bottom: 12px; float: left; width: 100%; }
.question fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.question .options { clear: both; display: flex; flex-direction: column; gap: 8px; }
.option { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border: 1px solid var(--line-strong); border-radius: var(--r-control); cursor: pointer; min-height: 48px; }
.option input { margin: 3px 0 0; width: 20px; height: 20px; accent-color: var(--red); flex: none; }
.option:has(input:checked) { border: 2px solid var(--red); background: var(--red-soft); }
.option.is-correct { border: 2px solid var(--ok); background: var(--ok-soft); }
.option.is-wrong { border: 2px solid var(--ink); }
.option .verdict { margin-left: auto; font-size: 13px; font-weight: 700; flex: none; }

/* ---- Score summary -------------------------------------------------------------------------- */

.scores { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; }
.scores > div { background: var(--surface); padding: 14px 16px; }
.scores dt { font-size: 13px; color: var(--ink-muted); }
.scores dd { margin: 0; font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; }
@media (min-width: 640px) { .scores { grid-template-columns: repeat(4, 1fr); } }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; font-size: 14px; }
.facts dt { color: var(--ink-muted); }
.facts dd { margin: 0; font-weight: 600; }

/* ---- Tables (stack into rows on phones) ----------------------------------------------------- */

.table-wrap { border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); overflow: hidden; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-weight: 700; color: var(--ink-muted); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; height: 44px; }
.table tr:last-child td { border-bottom: 0; }
.table .actions { text-align: right; white-space: nowrap; }
@media (max-width: 767px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .table tr:last-child { border-bottom: 0; }
  .table td { border: 0; padding: 3px 0; height: auto; display: flex; gap: 12px; }
  .table td::before { content: attr(data-label); flex: 0 0 38%; color: var(--ink-muted); font-weight: 600; }
  .table td.lead { font-size: 14px; font-weight: 700; }
  .table td.lead::before { display: none; }
  .table .actions { text-align: left; }
  .table .actions::before { display: none; }
}

.pagination { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

/* ---- Chat ------------------------------------------------------------------------------------ */

.chat { display: flex; flex-direction: column; height: calc(100vh - 260px); min-height: 360px; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); }
@media (max-width: 1023px) { .chat { height: calc(100dvh - 330px); } }
.chat-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.bubble { max-width: 80%; padding: 10px 14px; border-radius: var(--r-card); background: var(--neutral-soft); white-space: pre-wrap; word-wrap: break-word; }
.bubble.is-mine { align-self: flex-end; background: var(--ink); color: var(--paper); }
.bubble .meta { display: block; font-size: 11px; opacity: .75; margin-top: 4px; }
.chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.chat-form textarea { flex: 1; min-height: 40px; max-height: 160px; resize: none; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-control); font: inherit; background: var(--surface); color: var(--ink); }

/* ---- Landing -------------------------------------------------------------------------------- */

.hero { padding: 48px 0 40px; }
.hero .lead { font-size: 16px; color: var(--ink-muted); max-width: 52ch; margin-top: 16px; }
@media (min-width: 1024px) { .hero { padding: 80px 0 64px; } .hero .lead { font-size: 18px; } }
.landing-section { padding: 48px 0; }
@media (min-width: 1024px) { .landing-section { padding: 72px 0; } }
.rhythm { display: grid; gap: 24px; }
@media (min-width: 1024px) { .rhythm { grid-template-columns: 5fr 7fr; gap: 64px; align-items: center; } }
.rhythm-week { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.rhythm-week .cell { border: 1px solid var(--line); border-radius: var(--r-control); background: var(--surface); padding: 12px 10px; min-height: 108px; display: flex; flex-direction: column; gap: 8px; }
.rhythm-week .cell b { font-size: 13px; }
.rhythm-week .cell span { font-size: 12px; color: var(--ink-muted); line-height: 1.4; }
.rhythm-week .box { width: 22px; height: 22px; border-radius: 2px; background: var(--red); }
.rhythm-week .ring { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--ink); }
@media (max-width: 639px) { .rhythm-week { grid-template-columns: repeat(3, 1fr); } }
.weights { display: grid; gap: 12px; }
.weight-row { display: grid; grid-template-columns: 72px 1fr; gap: 16px; align-items: baseline; padding: 14px 0; border-bottom: 1px solid var(--line); }
.weight-row b { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.faq-item { border-bottom: 1px solid var(--line); }
.faq-item summary { cursor: pointer; padding: 16px 0; font-weight: 700; min-height: 44px; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; font-weight: 400; font-size: 22px; line-height: 1; }
.faq-item[open] summary::after { content: "\2212"; }
.faq-item .answer { padding-bottom: 16px; color: var(--ink-muted); white-space: pre-line; }

/* ---- Auth ---------------------------------------------------------------------------------- */

.auth-page { min-height: 100vh; display: flex; flex-direction: column; }
.auth-main { flex: 1; display: flex; align-items: flex-start; justify-content: center; padding: 32px 16px 48px; }
.auth-card { width: 100%; max-width: 440px; }
@media (min-width: 640px) { .auth-main { align-items: center; } }

/* ---- Admin ---------------------------------------------------------------------------------- */

.admin-body { font-size: 14px; }
.admin-summary { display: flex; flex-wrap: wrap; gap: 4px 24px; font-size: 13px; color: var(--ink-muted); margin-bottom: 24px; }
.admin-summary b { color: var(--ink); font-variant-numeric: tabular-nums; }
/* Dashboard: stat tiles, column charts, quota meters (see the dataviz notes in DESIGN.md). */
/* Always one row of four, at every width. */
.stat-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-tile { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); text-decoration: none; color: var(--ink); min-width: 0; }
a.stat-tile:hover { border-color: var(--line-strong); }
.stat-icon { flex: none; width: 38px; height: 38px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; background: var(--tone-bg); color: var(--tone-fg); }
.tone-red { --tone-bg: var(--red-soft); --tone-fg: var(--on-red-soft); }
.tone-ok { --tone-bg: var(--ok-soft); --tone-fg: var(--ok); }
.tone-warn { --tone-bg: var(--warn-soft); --tone-fg: var(--warn); }
.tone-neutral { --tone-bg: var(--neutral-soft); --tone-fg: var(--ink); }
.stat-body { display: flex; flex-direction: column; min-width: 0; }
.stat-label { font-size: 12px; font-weight: 600; color: var(--ink-muted); line-height: 1.3; }
.stat-value { font-size: 19px; font-weight: 800; letter-spacing: -.01em; line-height: 1.2; overflow-wrap: anywhere; }
.stat-sub { font-size: 11px; color: var(--ink-muted); line-height: 1.35; }
.stat-value-short { display: none; }
.stat-delta { display: inline-flex; align-items: center; gap: 1px; font-weight: 700; margin-right: 2px; }
.stat-delta.is-up { color: var(--ok); }
.stat-delta.is-down { color: var(--ink); }
@media (max-width: 1279px) {
  .stat-tile { flex-direction: column; align-items: flex-start; gap: 8px; }
}
/* Phones: four narrow tiles, so the icon shrinks and the explanation is kept for screen readers only. */
@media (max-width: 639px) {
  .stat-row { gap: 6px; }
  .stat-tile { padding: 8px; gap: 6px; }
  .stat-icon { width: 26px; height: 26px; border-radius: 6px; }
  .stat-icon .icon { width: 14px; height: 14px; }
  .stat-label { font-size: 10.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .stat-value { font-size: 14px; white-space: nowrap; overflow-wrap: normal; }
  .stat-value-short { display: inline; }
  .stat-value-full { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .stat-sub { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

.chart-row { display: grid; gap: 16px; margin-bottom: 32px; }
@media (min-width: 1100px) { .chart-row { grid-template-columns: 1fr 1fr; } }
.chart-card { margin: 0; }
.chart-title { font-size: 15px; margin: 0 0 2px; }
.chart-sub { font-size: 12px; color: var(--ink-muted); margin: 0 0 16px; }
.chart-empty { font-size: 13px; color: var(--ink-muted); margin: 8px 0 0; padding: 32px 12px; text-align: center; border: 1px dashed var(--line-strong); border-radius: var(--r-control); }

.colchart { position: relative; padding-left: 52px; }
.colchart-grid { position: absolute; left: 0; right: 0; top: 0; height: 168px; display: flex; flex-direction: column; justify-content: space-between; }
.colchart-gridline { position: relative; border-top: 1px solid var(--line); height: 0; }
.colchart-gridline span { position: absolute; left: 0; top: -6px; width: 44px; text-align: right; white-space: nowrap; font-size: 11px; color: var(--ink-muted); font-variant-numeric: tabular-nums; line-height: 1; }
.colchart-cols { position: relative; display: flex; gap: 2px; }
.colchart-col { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; outline-offset: 2px; border-radius: 4px; }
.colchart-plot { position: relative; width: 100%; height: 168px; display: flex; align-items: flex-end; justify-content: center; }
.colchart-bar { display: block; width: min(24px, 60%); min-height: 2px; border-radius: 4px 4px 0 0; background: var(--line-strong); }
.colchart-col.is-current .colchart-bar { background: var(--red); }
.colchart-col:hover .colchart-bar, .colchart-col:focus-visible .colchart-bar { filter: brightness(1.12); }
.colchart-cap { position: absolute; left: 0; right: 0; text-align: center; font-size: 11px; font-weight: 700; color: var(--ink); white-space: nowrap; }
.colchart-label { margin-top: 6px; font-size: 11px; color: var(--ink-muted); }
.colchart-tip { display: none; position: absolute; z-index: 5; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); padding: 6px 8px; border-radius: 6px; background: var(--ink); color: var(--paper); font-size: 12px; white-space: nowrap; box-shadow: var(--shadow); pointer-events: none; }
.colchart-tip strong { font-weight: 800; }
.colchart-col:hover .colchart-tip, .colchart-col:focus-visible .colchart-tip { display: block; bottom: auto; top: -30px; }
.chart-table { margin-top: 14px; font-size: 13px; }
.chart-table summary { cursor: pointer; color: var(--ink-muted); font-weight: 600; min-height: 32px; display: inline-flex; align-items: center; }
.chart-table .table { margin-top: 8px; border: 1px solid var(--line); border-radius: var(--r-control); }

.quota-list { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 16px; }
@media (min-width: 900px) { .quota-list { grid-template-columns: 1fr 1fr; gap: 20px 32px; } }
.quota-name { display: block; text-decoration: none; margin-bottom: 8px; font-size: 13px; }
.quota-name:hover strong { text-decoration: underline; }
.meter-row { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; align-items: center; gap: 10px; font-size: 12px; margin-top: 6px; }
.meter-label { color: var(--ink-muted); font-weight: 600; }
.meter { display: block; height: 8px; border-radius: 4px; background: var(--red-soft); overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: 4px; background: var(--red); }
.meter-value { font-variant-numeric: tabular-nums; white-space: nowrap; }
.meter-none { grid-column: span 2; color: var(--ink-muted); }

.batch-row { display: grid; gap: 8px; padding: 14px 16px; text-decoration: none; }
a.batch-row:hover { background: var(--neutral-soft); }
.batch-row .issues { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.batch-row .issues .chip { white-space: normal; }
@media (min-width: 768px) { .batch-row { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr); align-items: center; } }
.question-editor { border: 1px solid var(--line); border-radius: var(--r-card); padding: 16px; background: var(--surface); }
.question-editor + .question-editor { margin-top: 12px; }
.option-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.option-row input[type="text"] { flex: 1; min-width: 0; min-height: 40px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: var(--r-control); background: var(--surface); color: var(--ink); font: inherit; }
.option-row input[type="radio"] { width: 20px; height: 20px; accent-color: var(--red); flex: none; }

/* ---- Avatar --------------------------------------------------------------------------------- */

.avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center; background: var(--neutral-soft); color: var(--ink); font-weight: 700; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 64px; height: 64px; font-size: 22px; }
.header-actions .avatar { width: 44px; height: 44px; text-decoration: none; }
.break { overflow-wrap: anywhere; min-width: 0; }
@media (max-width: 639px) { .hide-sm { display: none !important; } }

/* ---- QR -------------------------------------------------------------------------------------- */

.qr-box { background: #FFFFFF; padding: 16px; border-radius: var(--r-card); border: 1px solid var(--line); width: fit-content; margin: 0 auto; }
.qr-box canvas, .qr-box img { width: 232px; height: 232px; }
