/*
 * Reusable components: buttons, chips, cards, fields, phone input, switches, modals / sheets / drawers,
 * toasts, menus, tabs, accordions, progress, avatars, certificate preview, learner pass.
 */

/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
  --btn-bg: var(--surface); --btn-fg: var(--text); --btn-bd: var(--line-2);
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 48px; padding: 0 22px; border-radius: var(--r-pill);
  background: var(--btn-bg); color: var(--btn-fg); border: 1px solid var(--btn-bd);
  font-weight: 600; font-size: var(--fs-15); letter-spacing: 0.005em; line-height: 1; white-space: nowrap;
  cursor: pointer; user-select: none; isolation: isolate; overflow: hidden;
  transition: transform var(--t-2) var(--ease-out), box-shadow var(--t-2), background-color var(--t-2), border-color var(--t-2), color var(--t-2);
}
.btn .i { width: 18px; height: 18px; transition: transform var(--t-3) var(--ease-out); }
.btn:hover { border-color: var(--accent); }
.btn:hover .i-arrow-right, .btn:hover .i-arrow-up-right { transform: translateX(3px); }
.btn:active { transform: scale(0.975); }
.btn:disabled, .btn[aria-disabled='true'] { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn--primary { --btn-bg: var(--inverse); --btn-fg: var(--on-inverse); --btn-bd: var(--inverse); }
.btn--primary:hover { box-shadow: var(--shadow-2); border-color: var(--inverse); }
/* Gold leaf: the single loud action on a screen. A sheen crosses it on hover. */
.btn--gold { --btn-fg: var(--on-accent); --btn-bd: transparent; background: linear-gradient(180deg, #E2BC5C, #C9982F 55%, #B98724); box-shadow: inset 0 1px 0 rgba(255, 244, 204, 0.75), inset 0 -1px 0 rgba(116, 91, 14, 0.35), 0 8px 22px -10px rgba(166, 123, 36, 0.8); }
.btn--gold::after { content: ''; position: absolute; inset: 0; z-index: -1; background: linear-gradient(105deg, transparent 35%, rgba(255, 248, 220, 0.75) 50%, transparent 65%); transform: translateX(-120%); transition: transform 0.9s var(--ease-out); }
.btn--gold:hover::after { transform: translateX(120%); }
.btn--gold:hover { box-shadow: inset 0 1px 0 rgba(255, 244, 204, 0.75), inset 0 -1px 0 rgba(116, 91, 14, 0.35), 0 14px 30px -10px rgba(166, 123, 36, 0.9); transform: translateY(-1px); }
.btn--gold:active { transform: scale(0.975); }
.btn--secondary { --btn-bg: transparent; }
.btn--secondary:hover { background: var(--accent-soft); }
.btn--ghost { --btn-bg: transparent; --btn-bd: transparent; }
.btn--ghost:hover { background: var(--accent-soft); border-color: transparent; }
.btn--danger { --btn-bg: var(--bad); --btn-fg: #fff; --btn-bd: var(--bad); }
.btn--danger:hover { border-color: var(--bad); box-shadow: var(--shadow-2); }
.btn--danger-soft { --btn-bg: transparent; --btn-fg: var(--bad-text); --btn-bd: color-mix(in srgb, var(--bad) 40%, transparent); }
.btn--danger-soft:hover { background: var(--bad-bg); border-color: var(--bad); }
.btn--sm { min-height: 38px; padding: 0 16px; font-size: var(--fs-14); gap: 8px; }
.btn--sm .i { width: 16px; height: 16px; }
.btn--lg { min-height: 56px; padding: 0 30px; font-size: var(--fs-16); }
.btn--block { width: 100%; }
.btn--icon { padding: 0; width: 48px; }
.btn--icon.btn--sm { width: 38px; }
.btn--square { border-radius: var(--r-2); }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Chips & badges ─────────────────────────────────────────────── */
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 26px; padding: 0 10px; border-radius: var(--r-pill); font-size: var(--fs-12); font-weight: 650; letter-spacing: 0.03em; background: var(--sunken); color: var(--text-2); border: 1px solid var(--line); white-space: nowrap; }
.chip .i { width: 13px; height: 13px; }
.chip--gold { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent-line); }
.chip--ok { background: var(--ok-bg); color: var(--ok-text); border-color: transparent; }
.chip--bad { background: var(--bad-bg); color: var(--bad-text); border-color: transparent; }
.chip--warn { background: var(--warn-bg); color: var(--warn-text); border-color: transparent; }
.chip--solid { background: var(--inverse); color: var(--on-inverse); border-color: transparent; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }

/* ── Cards ──────────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-4); box-shadow: var(--shadow-1); }
.card--pad { padding: clamp(18px, 3vw, 28px); }
.card--tint { background: var(--surface-2); }
.card--lift { transition: transform var(--t-3) var(--ease-out), box-shadow var(--t-3), border-color var(--t-3); }
.card--lift:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); border-color: var(--accent-line); }
/* Manuscript frame: a double gold rule with corner diamonds. */
.frame { position: relative; border: 1px solid var(--accent-line); border-radius: var(--r-3); background: var(--surface); }
.frame::before { content: ''; position: absolute; inset: 6px; border: 1px solid var(--accent-line); border-radius: calc(var(--r-3) - 5px); opacity: 0.55; pointer-events: none; }

/* ── Fields ─────────────────────────────────────────────────────── */
.field { display: grid; gap: 8px; }
.field__label { font-size: var(--fs-14); font-weight: 600; color: var(--text); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.field__label .opt { font-weight: 500; font-size: var(--fs-12); color: var(--text-3); letter-spacing: 0.04em; text-transform: uppercase; }
.field__hint { font-size: var(--fs-13); color: var(--text-3); }
.field__error { font-size: var(--fs-13); color: var(--bad-text); font-weight: 550; display: flex; gap: 6px; }
.input, .select, .textarea {
  width: 100%; min-height: 52px; padding: 12px 16px; border-radius: var(--r-3);
  background: var(--surface); border: 1px solid var(--line-2); color: var(--text);
  font-size: 1rem; /* 16px: phones never zoom on focus */ line-height: 1.35;
  transition: border-color var(--t-2), box-shadow var(--t-2), background-color var(--t-2);
  appearance: none; -webkit-appearance: none;
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); opacity: 1; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--accent-line); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); outline: none; }
.textarea { min-height: 132px; resize: vertical; }
.select { padding-right: 44px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23A67B24' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; background-size: 18px; cursor: pointer; }
.input--lg { min-height: 64px; font-size: 1.25rem; padding-inline: 20px; border-radius: var(--r-4); }
.input--upper { text-transform: uppercase; }
.input--upper::placeholder { text-transform: none; }
.field.has-error .input, .field.has-error .select, .field.has-error .textarea, .field.has-error .phone { border-color: var(--bad); box-shadow: 0 0 0 4px color-mix(in srgb, var(--bad) 16%, transparent); }
input[type='number']::-webkit-outer-spin-button, input[type='number']::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type='number'] { -moz-appearance: textfield; appearance: textfield; }
input:-webkit-autofill { -webkit-text-fill-color: var(--text); box-shadow: 0 0 0 100px var(--surface) inset; caret-color: var(--text); }

/* Phone: [+][code] | [number] in one frame. */
.phone { display: flex; align-items: stretch; min-height: 52px; border-radius: var(--r-3); background: var(--surface); border: 1px solid var(--line-2); transition: border-color var(--t-2), box-shadow var(--t-2); overflow: hidden; }
.phone:hover { border-color: var(--accent-line); }
.phone:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }
.phone__code { display: flex; align-items: center; padding-left: 16px; border-right: 1px solid var(--line); background: var(--surface-2); color: var(--text-2); font-weight: 600; flex: none; }
.phone__code input { width: 3.4em; border: 0; background: transparent; padding: 0 10px 0 2px; font-size: 1rem; font-weight: 600; color: var(--text); min-height: 50px; }
.phone__num { flex: 1; min-width: 0; border: 0; background: transparent; padding: 0 16px; font-size: 1rem; letter-spacing: 0.04em; min-height: 50px; }
.phone--lg { min-height: 64px; border-radius: var(--r-4); }
.phone--lg .phone__code input, .phone--lg .phone__num { font-size: 1.25rem; min-height: 62px; }
.phone--lg .phone__code { font-size: 1.25rem; padding-left: 18px; }

/* Segmented choice (gender, filters). */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: var(--r-3); background: var(--sunken); border: 1px solid var(--line); }
.seg label { position: relative; display: grid; place-items: center; min-height: 44px; padding: 0 14px; border-radius: calc(var(--r-3) - 4px); font-weight: 600; font-size: var(--fs-15); color: var(--text-2); cursor: pointer; transition: background-color var(--t-2), color var(--t-2), box-shadow var(--t-2); }
.seg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg label:has(input:checked) { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1), inset 0 0 0 1px var(--accent-line); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.seg--lg label { min-height: 60px; font-size: var(--fs-18); }

/* Stepper (age). */
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper input { text-align: center; font-family: var(--font-display); font-size: 2rem; font-weight: 500; width: 4.2em; min-height: 64px; }
.stepper button { width: 52px; height: 52px; border-radius: 50%; border: 1px solid var(--line-2); display: grid; place-items: center; background: var(--surface); transition: border-color var(--t-2), background-color var(--t-2), transform var(--t-1); }
.stepper button:hover { border-color: var(--accent); background: var(--accent-soft); }
.stepper button:active { transform: scale(0.94); }

/* Switch. */
.switch { position: relative; display: inline-flex; align-items: center; cursor: pointer; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch i { width: 46px; height: 28px; border-radius: 99px; background: var(--line-2); transition: background-color var(--t-2); position: relative; display: block; }
.switch i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: transform var(--t-3) var(--ease-out); }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(18px); }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 3px; }

.check { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; font-size: var(--fs-15); }
.check input { appearance: none; -webkit-appearance: none; width: 22px; height: 22px; border-radius: 6px; border: 1.5px solid var(--line-2); background: var(--surface); flex: none; margin: 1px 0 0; display: grid; place-items: center; transition: background-color var(--t-2), border-color var(--t-2); cursor: pointer; }
.check input::after { content: ''; width: 11px; height: 6px; border-left: 2px solid var(--on-accent); border-bottom: 2px solid var(--on-accent); transform: rotate(-45deg) translate(1px, -1px) scale(0); transition: transform var(--t-2) var(--ease-out); }
.check input:checked { background: var(--accent); border-color: var(--accent); }
.check input:checked::after { transform: rotate(-45deg) translate(1px, -1px) scale(1); }

/* ── Modal / sheet / drawer ─────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: var(--z-modal); display: grid; place-items: center; padding: 20px; }
.modal__backdrop { position: absolute; inset: 0; background: var(--scrim); opacity: 0; transition: opacity var(--t-3) var(--ease-soft); }
.modal__panel { position: relative; width: min(100%, 520px); max-height: min(100%, 860px); display: flex; flex-direction: column; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: var(--r-5); box-shadow: var(--shadow-3); opacity: 0; transform: translate3d(0, 18px, 0) scale(0.98); transition: opacity var(--t-3) var(--ease-out), transform var(--t-3) var(--ease-out); overflow: hidden; }
.modal--sm .modal__panel { width: min(100%, 420px); }
.modal--lg .modal__panel { width: min(100%, 760px); }
.modal--xl .modal__panel { width: min(100%, 1040px); }
.modal.is-open .modal__backdrop { opacity: 1; }
.modal.is-open .modal__panel { opacity: 1; transform: none; }
.modal.is-closing .modal__panel { opacity: 0; transform: translate3d(0, 10px, 0) scale(0.985); transition-duration: var(--t-2); }
.modal.is-closing .modal__backdrop { opacity: 0; }
.modal__head { display: flex; align-items: flex-start; gap: 14px; padding: 22px 22px 0 26px; }
.modal__head--bare { position: absolute; top: 0; right: 0; z-index: 2; padding: 12px; }
.modal__titles { flex: 1; min-width: 0; padding-top: 4px; }
.modal__title { font-size: var(--fs-24); }
.modal__sub { color: var(--text-2); font-size: var(--fs-14); margin-top: 4px; }
.modal__icon { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); flex: none; }
.modal__x { flex: none; margin-left: auto; }
.modal__body { padding: 20px 26px 26px; overflow-y: auto; overscroll-behavior: contain; }
.modal__foot { padding: 16px 26px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; background: var(--surface-2); }
.modal--sheet { align-items: end; padding: 0; }
.modal--sheet .modal__panel { width: min(100%, 560px); border-radius: var(--r-5) var(--r-5) 0 0; transform: translate3d(0, 100%, 0); opacity: 1; max-height: 92dvh; }
.modal--sheet.is-closing .modal__panel { transform: translate3d(0, 100%, 0); opacity: 1; }
.modal--drawer { justify-items: end; padding: 0; }
.modal--drawer .modal__panel { height: 100%; max-height: none; width: min(100%, 560px); border-radius: 0; border-width: 0 0 0 1px; transform: translate3d(100%, 0, 0); opacity: 1; }
.modal--drawer.modal--lg .modal__panel { width: min(100%, 760px); }
.modal--drawer.is-closing .modal__panel { transform: translate3d(100%, 0, 0); opacity: 1; }
@media (max-width: 640px) {
  .modal--dialog:not(.modal--confirm) { align-items: end; padding: 0; }
  .modal--dialog:not(.modal--confirm) .modal__panel { width: 100%; border-radius: var(--r-5) var(--r-5) 0 0; transform: translate3d(0, 100%, 0); opacity: 1; max-height: 94dvh; }
  .modal--dialog:not(.modal--confirm).is-open .modal__panel { transform: none; }
  .modal--dialog:not(.modal--confirm).is-closing .modal__panel { transform: translate3d(0, 100%, 0); opacity: 1; }
  .modal__body { padding: 18px 20px 24px; }
  .modal__head { padding: 18px 16px 0 20px; }
  .modal__foot { padding: 14px 20px calc(14px + env(safe-area-inset-bottom)); }
}
.confirm { text-align: center; display: grid; justify-items: center; gap: 10px; padding-top: 8px; }
.confirm__icon { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); margin-bottom: 4px; }
.confirm__icon .i { width: 26px; height: 26px; }
.confirm__icon--danger { background: var(--bad-bg); color: var(--bad-text); }
.confirm__title { font-size: var(--fs-24); }
.confirm__msg { color: var(--text-2); font-size: var(--fs-15); max-width: 36ch; }
.confirm__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; margin-top: 14px; }
.confirm__actions--stack { grid-template-columns: 1fr; }

/* ── Toasts ─────────────────────────────────────────────────────── */
.toast-stack { position: fixed; z-index: var(--z-toast); left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: grid; gap: 10px; width: min(calc(100% - 32px), 420px); pointer-events: none; }
.has-dock .toast-stack { bottom: calc(92px + env(safe-area-inset-bottom)); }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 12px; padding: 14px 14px 14px 16px; background: var(--inverse); color: var(--on-inverse); border-radius: var(--r-3); box-shadow: var(--shadow-3); opacity: 0; transform: translate3d(0, 16px, 0) scale(0.97); transition: opacity var(--t-3) var(--ease-out), transform var(--t-3) var(--ease-out); }
.toast.is-in { opacity: 1; transform: none; }
.toast.is-leaving { opacity: 0; transform: translate3d(0, 8px, 0) scale(0.98); }
.toast__icon { color: var(--brand-gold-border); flex: none; margin-top: 1px; }
[data-theme='dark'] .toast__icon { color: var(--brand-gold-deep); }
.toast--error .toast__icon { color: #F0A08D; }
[data-theme='dark'] .toast--error .toast__icon { color: var(--bad); }
.toast__body { flex: 1; font-size: var(--fs-14); line-height: 1.45; display: grid; }
.toast__title { font-weight: 650; font-size: var(--fs-15); }
.toast__x { opacity: 0.6; padding: 2px; border-radius: 6px; flex: none; }
.toast__x:hover { opacity: 1; }
.toast__x .i { width: 16px; height: 16px; }

/* ── Menu ───────────────────────────────────────────────────────── */
.menu { position: fixed; z-index: calc(var(--z-modal) + 10); min-width: 210px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-3); box-shadow: var(--shadow-3); opacity: 0; transform: translate3d(0, -6px, 0) scale(0.98); transform-origin: top right; transition: opacity var(--t-2) var(--ease-out), transform var(--t-2) var(--ease-out); }
.menu.is-open { opacity: 1; transform: none; }
.menu__item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--r-2); font-size: var(--fs-14); font-weight: 550; text-align: left; color: var(--text); }
.menu__item .i { width: 17px; height: 17px; color: var(--text-3); }
.menu__item:hover, .menu__item:focus-visible { background: var(--accent-soft); outline: none; }
.menu__item--danger, .menu__item--danger .i { color: var(--bad-text); }
.menu__item:disabled { opacity: 0.45; cursor: not-allowed; }
.menu__item kbd { margin-left: auto; font: inherit; font-size: var(--fs-12); color: var(--text-3); }
.menu__sep { height: 1px; background: var(--line); margin: 6px; }
.menu__head { padding: 8px 12px 4px; font-size: var(--fs-12); letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-3); font-weight: 650; }

/* ── Tabs ───────────────────────────────────────────────────────── */
.tabs [role='tablist'] { position: relative; display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs [role='tablist']::-webkit-scrollbar { display: none; }
.tabs [role='tab'] { padding: 12px 14px; font-weight: 600; font-size: var(--fs-14); color: var(--text-2); white-space: nowrap; border-radius: var(--r-2) var(--r-2) 0 0; transition: color var(--t-2); display: inline-flex; gap: 8px; align-items: center; }
.tabs [role='tab'][aria-selected='true'] { color: var(--text); }
.tabs [role='tab']:hover { color: var(--text); }
.tabs__ink { position: absolute; left: 0; bottom: 0; height: 2px; background: var(--accent); border-radius: 2px; transition: transform var(--t-3) var(--ease-out), width var(--t-3) var(--ease-out); }

/* ── Accordion ──────────────────────────────────────────────────── */
details.acc { border-bottom: 1px solid var(--line); }
details.acc summary { list-style: none; display: flex; align-items: center; gap: 16px; padding: 22px 4px; cursor: pointer; font-family: var(--font-display); font-size: var(--fs-20); font-weight: 500; line-height: 1.3; transition: color var(--t-2); }
details.acc summary::-webkit-details-marker { display: none; }
details.acc summary:hover { color: var(--accent-text); }
details.acc summary::after { content: ''; margin-left: auto; width: 34px; height: 34px; flex: none; border-radius: 50%; border: 1px solid var(--line-2); background: no-repeat center / 14px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23A67B24' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E"); transition: transform var(--t-3) var(--ease-out), background-color var(--t-2); }
details.acc[open]:not(.is-closing) summary::after { transform: rotate(135deg); background-color: var(--accent-soft); }
.acc__content { overflow: hidden; }
.acc__content > div { padding: 0 56px 24px 4px; color: var(--text-2); max-width: 70ch; }
.acc__content p + p { margin-top: 10px; }

/* ── Progress ───────────────────────────────────────────────────── */
.bar { height: 6px; border-radius: 6px; background: var(--sunken); overflow: hidden; border: 1px solid var(--line); }
.bar > i { display: block; height: 100%; width: 100%; border-radius: inherit; background: var(--leaf-flat); transform-origin: left; transform: scaleX(var(--v, 0)); transition: transform 0.9s var(--ease-out); }

/* ── Avatar (initials on an ornament seal) ───────────────────────── */
.avatar { --size: 40px; width: var(--size); height: var(--size); border-radius: 50%; display: inline-grid; place-items: center; flex: none; font-weight: 700; font-size: calc(var(--size) * 0.36); letter-spacing: 0.02em; color: var(--on-accent); background: var(--av, linear-gradient(140deg, #E5C568, #B98724)); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35), 0 0 0 1px var(--accent-line); user-select: none; }
.avatar[data-tone='ink'] { --av: linear-gradient(140deg, #3A352A, #15130F); color: #E5C568; }
.avatar[data-tone='sand'] { --av: linear-gradient(140deg, #F4EAD0, #DCC9A0); color: #5A4308; }
.avatar[data-tone='olive'] { --av: linear-gradient(140deg, #A9B28A, #6C7750); color: #1C2110; }
.avatar[data-tone='clay'] { --av: linear-gradient(140deg, #D9A98C, #A8694A); color: #2B1408; }
.avatar[data-tone='dusk'] { --av: linear-gradient(140deg, #9AA7C4, #55607F); color: #0F1424; }

/* ── Loader / empty ─────────────────────────────────────────────── */
.loader { display: grid; justify-items: center; gap: 14px; padding: 56px 20px; color: var(--text-3); font-size: var(--fs-14); }
.empty { display: grid; justify-items: center; text-align: center; gap: 10px; padding: 48px 20px; color: var(--text-2); }
.empty .ayah-mark { --size: 64px; opacity: 0.7; margin-bottom: 6px; }
.empty h3 { font-size: var(--fs-20); }
.view-error { padding: 80px 20px; text-align: center; display: grid; gap: 16px; justify-items: center; }

/* ── Notes / callouts ───────────────────────────────────────────── */
.note { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--r-3); background: var(--accent-soft); border: 1px solid var(--accent-line); font-size: var(--fs-14); color: var(--text); }
.note .i { color: var(--accent-text); margin-top: 2px; }
.note--bad { background: var(--bad-bg); border-color: transparent; color: var(--bad-text); }
.note--bad .i { color: currentColor; }
.note--ok { background: var(--ok-bg); border-color: transparent; color: var(--ok-text); }
.note--ok .i { color: currentColor; }
.kbd { font: inherit; font-size: var(--fs-12); padding: 2px 7px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text-2); font-weight: 600; }

/* ── Certificate preview (container-query units match the PDF at any size) ───────── */
.cert-preview { position: relative; container-type: inline-size; border-radius: var(--r-2); overflow: hidden; background: #fff; box-shadow: var(--shadow-3); border: 1px solid var(--line); }
.cert-preview img { width: 100%; display: block; }
.cert-preview__name { position: absolute; left: var(--nx); top: var(--ny); transform: translate(-50%, -100%); width: 86%; text-align: center; font-family: Helvetica, Arial, sans-serif; font-weight: 700; font-size: var(--ns); line-height: 1; color: var(--nc); text-transform: uppercase; white-space: nowrap; }
.cert-preview__number { position: absolute; left: var(--cx); top: var(--cy); transform: translate(-50%, -50%); font-family: Helvetica, Arial, sans-serif; font-weight: 700; font-size: var(--cs); line-height: 1; color: var(--cc); white-space: nowrap; }
.cert-preview.is-blurred img { filter: saturate(0.5) opacity(0.55); }
.cert-preview.is-blurred .cert-preview__name { opacity: 0.35; }

/* ── Learner pass: barcode (one segment per level), stamps and the boarding pass ── */
.barcode { position: relative; width: 100%; display: grid; gap: 6px; --bc-ink: var(--pass-ink); --bc-off: var(--pass-off); --bc-now: var(--accent); }
.barcode[data-tone='night'] { --bc-ink: #E5C568; --bc-off: rgba(242, 236, 221, 0.13); --bc-now: #FFF1BF; }
.barcode[data-tone='gold'] { --bc-ink: #E5C568; --bc-off: rgba(229, 197, 104, 0.18); --bc-now: #FFF1BF; }
.bc-svg { width: 100%; height: auto; display: block; overflow: visible; }
.bc-hit { fill: transparent; }
.bc-b { fill: var(--bc-off); transition: fill 0.45s var(--ease-out); }
.bc-s.is-on .bc-b { fill: var(--bc-ink); }
.bc-s.is-now .bc-b { fill: var(--bc-now); animation: bc-blink 1.5s var(--ease-in-out) infinite; }
@keyframes bc-blink { 50% { opacity: 0.3; } }
.bc-s.is-hit { cursor: pointer; }
.bc-s.is-hover .bc-b { fill: var(--accent); }
.bc-s.is-printing .bc-b { transform-box: fill-box; transform-origin: 50% 0; animation: bc-print 0.7s steps(7, end) both; }
@keyframes bc-print { from { transform: scaleY(0); } }
.bc-laser { fill: #F0643C; opacity: 0; pointer-events: none; filter: drop-shadow(0 0 3px rgba(240, 100, 60, 0.9)); }
.bc-laser.is-on { animation: bc-laser 0.9s var(--ease-in-out) both; }
@keyframes bc-laser { 0% { opacity: 0; transform: translateY(-2px); } 12% { opacity: 1; } 80% { opacity: 1; transform: translateY(62px); } 100% { opacity: 0; transform: translateY(62px); } }
.barcode.is-flash .bc-svg { animation: bc-flash 1.1s var(--ease-out); }
@keyframes bc-flash { 30% { filter: brightness(1.35) drop-shadow(0 0 10px rgba(229, 180, 80, 0.45)); } }
.bc-l { font-family: var(--font-mono); font-size: 8px; font-weight: 600; fill: var(--text-3); text-anchor: middle; }
.bc-cap { display: flex; justify-content: space-between; gap: 12px; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--pass-muted); white-space: nowrap; }
.bc-cap b { font-weight: 700; color: inherit; }
.bc-cap__s b { color: var(--pass-strong); }
.barcode[data-tone='night'] .bc-cap, .barcode[data-tone='gold'] .bc-cap { color: rgba(242, 236, 221, 0.55); }
.barcode[data-tone='night'] .bc-cap__s b, .barcode[data-tone='gold'] .bc-cap__s b { color: #F2ECDD; }

/* Stamps: rotated rubber-stamp marks with a double rule. */
.stamp { display: inline-grid; justify-items: center; gap: 0; padding: 3px 7px 4px; border: 2px solid currentColor; border-radius: 6px; box-shadow: inset 0 0 0 2px var(--pass-bg), inset 0 0 0 3px currentColor; color: var(--stamp, #B0451F); font-family: var(--font-mono); line-height: 1.05; text-transform: uppercase; transform: rotate(var(--r, -4deg)); mix-blend-mode: multiply; }
[data-theme='dark'] .stamp, .pass--night .stamp { mix-blend-mode: normal; }
.stamp small { font-size: 7px; font-weight: 700; letter-spacing: 0.22em; }
.stamp b { font-size: 13px; font-weight: 700; letter-spacing: 0.04em; }
.stamp i { font-style: normal; font-size: 6.5px; font-weight: 600; letter-spacing: 0.08em; opacity: 0.85; max-width: 9ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stamp.is-new { animation: stamp-in 0.55s cubic-bezier(0.3, 1.5, 0.5, 1) both; }
@keyframes stamp-in { 0% { transform: rotate(var(--r)) scale(2.6); opacity: 0; } 60% { opacity: 1; } }

/* The pass. The sheet is cut with two notches at the perforation; the shadow sits on the outer box. */
.pass-host { container-type: inline-size; width: 100%; }
.pass { --stub: clamp(96px, 21cqw, 150px); --notch: 11px; position: relative; color: var(--pass-strong); filter: drop-shadow(0 22px 26px var(--pass-shadow)) drop-shadow(0 1px 1px rgba(0, 0, 0, 0.06)); }
.pass__sheet { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) var(--stub); border-radius: 18px; background: var(--pass-bg);
  -webkit-mask: radial-gradient(circle var(--notch) at calc(100% - var(--stub)) 0, #0000 98%, #000) top / 100% 51% no-repeat, radial-gradient(circle var(--notch) at calc(100% - var(--stub)) 100%, #0000 98%, #000) bottom / 100% 51% no-repeat;
          mask: radial-gradient(circle var(--notch) at calc(100% - var(--stub)) 0, #0000 98%, #000) top / 100% 51% no-repeat, radial-gradient(circle var(--notch) at calc(100% - var(--stub)) 100%, #0000 98%, #000) bottom / 100% 51% no-repeat; }
.pass__sheet::after { content: ''; position: absolute; top: calc(var(--notch) + 6px); bottom: calc(var(--notch) + 6px); right: var(--stub); border-left: 2px dashed var(--pass-line); pointer-events: none; }
.pass__main { display: grid; grid-template-columns: minmax(0, 1fr); gap: clamp(10px, 3cqw, 18px); padding: clamp(14px, 4.2cqw, 26px); min-width: 0; }
.pass__hd { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-family: var(--font-mono); font-size: 10.5px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--pass-muted); }
.pass__issuer { display: inline-flex; align-items: center; gap: 8px; color: var(--pass-strong); min-width: 0; }
.pass__logo { width: 22px; height: 22px; flex: none; border-radius: 6px; overflow: hidden; }
.pass__logo .logo__mark { width: 100%; height: 100%; display: block; }
.pass__kind { color: var(--accent-text); white-space: nowrap; }
.pass--night .pass__kind { color: #E5C568; }
.pass__route { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: clamp(8px, 2.6cqw, 18px); }
.pass__code b { display: block; font-family: var(--font-display); font-weight: 700; font-size: clamp(1.9rem, 10cqw, 3.3rem); line-height: 0.88; letter-spacing: -0.035em; }
.pass__code small { display: block; margin-top: 6px; font-size: 12px; color: var(--pass-muted); white-space: nowrap; }
.pass__code--to { text-align: right; }
.pass__track { position: relative; height: 2px; background: repeating-linear-gradient(90deg, var(--pass-line) 0 5px, transparent 5px 9px); }
.pass__fill { position: absolute; left: 0; top: -1px; height: 4px; width: 0; border-radius: 4px; background: var(--leaf-flat); transition: width 0.9s var(--ease-out); }
.pass__pos { position: absolute; top: 50%; left: 9%; width: 0; height: 0; transition: left 0.9s var(--ease-out); }
.pass__tag { position: absolute; top: 0; left: 0; transform: translate(-50%, -50%); padding: 3px 8px; border-radius: 7px; background: var(--pass-strong); color: var(--pass-bg); font-family: var(--font-mono); font-size: 11px; font-weight: 700; font-style: normal; white-space: nowrap; }
/* The flight mark rides just above the marker, heading for Al-Ikhlas. */
.pass__plane { position: absolute; left: 0; bottom: 13px; width: clamp(18px, 5.2cqw, 24px); transform: translateX(-50%); }
.pass__plane .plane { display: block; width: 100%; height: auto; filter: drop-shadow(0 1px 1.5px rgba(80, 55, 8, 0.35)); animation: plane-cruise 3.6s ease-in-out infinite; }
.pass.is-boarded .pass__plane .plane { animation: none; }
.pass__fields { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 0; }
.pass__fields div { display: grid; gap: 3px; min-width: 0; }
.pass__fields dt { font-family: var(--font-mono); font-size: 9.5px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--pass-muted); }
.pass__fields dd { margin: 0; font-family: var(--font-display); font-weight: 600; font-size: clamp(13px, 3.4cqw, 16px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pass__bc { min-width: 0; }
.pass__stub { display: grid; align-content: start; gap: 8px; padding: clamp(14px, 3.6cqw, 22px) clamp(10px, 2.6cqw, 16px); min-width: 0; }
.pass__stub-k { font-family: var(--font-mono); font-size: 10px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--pass-muted); }
.pass__stamps { display: grid; gap: 6px; }
.pass__slot { height: clamp(30px, 8.4cqw, 40px); display: grid; place-items: center; border: 1px dashed var(--pass-line); border-radius: 8px; font-family: var(--font-mono); font-size: 11px; font-weight: 600; color: var(--pass-muted); }
.pass__slot .stamp { transform: rotate(var(--r)) scale(0.92); }
.pass__boarded { position: absolute; left: calc((100% - var(--stub)) / 2); top: 50%; z-index: 2; display: grid; justify-items: center; padding: 8px 18px 9px; border: 3px solid #B0451F; border-radius: 10px; box-shadow: inset 0 0 0 3px var(--pass-bg), inset 0 0 0 4.5px #B0451F; background: color-mix(in srgb, var(--pass-bg) 78%, transparent); color: #B0451F; transform: translate(-50%, -50%) rotate(-8deg); pointer-events: none; }
.pass__boarded b { font-family: var(--font-display); font-weight: 800; font-size: clamp(1.3rem, 7cqw, 2.2rem); letter-spacing: 0.06em; line-height: 1; text-transform: uppercase; }
.pass__boarded small { font-family: var(--font-mono); font-size: 10px; font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase; }
.pass__boarded.is-new { animation: board-in 0.7s cubic-bezier(0.3, 1.5, 0.5, 1) both; }
@keyframes board-in { 0% { transform: translate(-50%, -50%) rotate(-8deg) scale(2.4); opacity: 0; } }
.pass--night { --pass-bg: #16130D; --pass-strong: #F2ECDD; --pass-muted: #9C927C; --pass-line: rgba(229, 197, 104, 0.28); --pass-ink: #E5C568; --pass-off: rgba(242, 236, 221, 0.12); --pass-shadow: rgba(0, 0, 0, 0.55); --stamp: #E8A257; }
.pass--night .pass__sheet { background: radial-gradient(120% 140% at 0% 0%, #241E13, #16130D 55%, #0F0D09); box-shadow: inset 0 0 0 1px rgba(229, 197, 104, 0.16); }
.pass--night .pass__boarded { border-color: #E8A257; color: #E8A257; box-shadow: inset 0 0 0 3px #16130D, inset 0 0 0 4.5px #E8A257; }
/* Ivory stock that stays light on any theme (the hero shot and printed moments). */
.pass--ivory { --pass-bg: #FFFDF6; --pass-strong: #1C1810; --pass-muted: #8A8270; --pass-line: #DCD2BB; --pass-ink: #1C1810; --pass-off: rgba(28, 24, 16, 0.12); --pass-shadow: rgba(0, 0, 0, 0.4); --accent-text: #745B0E; }
.pass--compact .pass__route { margin-top: 2px; }
.pass.is-boarded .pass__fill { background: linear-gradient(90deg, #C6952F, #FFE4A0); }
/* Narrow: the stub moves below and the perforation turns horizontal. */
@container (max-width: 470px) {
  .pass { --stub-h: 70px; }
  .pass__sheet { grid-template-columns: minmax(0, 1fr);
    -webkit-mask: radial-gradient(circle var(--notch) at 0 calc(100% - var(--stub-h)), #0000 98%, #000) left / 51% 100% no-repeat, radial-gradient(circle var(--notch) at 100% calc(100% - var(--stub-h)), #0000 98%, #000) right / 51% 100% no-repeat;
            mask: radial-gradient(circle var(--notch) at 0 calc(100% - var(--stub-h)), #0000 98%, #000) left / 51% 100% no-repeat, radial-gradient(circle var(--notch) at 100% calc(100% - var(--stub-h)), #0000 98%, #000) right / 51% 100% no-repeat; }
  .pass__sheet::after { top: auto; bottom: var(--stub-h); left: calc(var(--notch) + 6px); right: calc(var(--notch) + 6px); border-left: 0; border-top: 2px dashed var(--pass-line); }
  .pass__stub { height: var(--stub-h); grid-template-columns: auto minmax(0, 1fr); align-items: center; padding-block: 10px; }
  .pass__stamps { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; }
  .pass__slot { height: 44px; }
  .pass__fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pass__boarded { left: 50%; top: 40%; }
}

/* A level ticket: main part + stub, notched at the perforation. The outline is a drop-shadow so it follows the cut. */
.tk { --cut: 78px; --tk-bg: var(--bg); --tk-edge: var(--line-2); display: block; width: 100%; padding: 0; border: 0; background: none; text-align: left; color: var(--text); filter: drop-shadow(0 0 0.5px var(--tk-edge)) drop-shadow(0 0 0.5px var(--tk-edge)); transition: transform var(--t-2) var(--ease-out); }
.tk:hover { transform: translateY(-2px); --tk-edge: var(--accent); }
.tk__sheet { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) var(--cut); min-height: 74px; border-radius: 12px; background: var(--tk-bg);
  -webkit-mask: radial-gradient(circle 7px at calc(100% - var(--cut)) 0, #0000 98%, #000) top / 100% 51% no-repeat, radial-gradient(circle 7px at calc(100% - var(--cut)) 100%, #0000 98%, #000) bottom / 100% 51% no-repeat;
          mask: radial-gradient(circle 7px at calc(100% - var(--cut)) 0, #0000 98%, #000) top / 100% 51% no-repeat, radial-gradient(circle 7px at calc(100% - var(--cut)) 100%, #0000 98%, #000) bottom / 100% 51% no-repeat; }
.tk__sheet::after { content: ''; position: absolute; top: 11px; bottom: 11px; right: var(--cut); border-left: 1.5px dashed var(--line-2); }
.tk__main { display: grid; align-content: center; gap: 2px; padding: 11px 14px 11px 16px; min-width: 0; }
.tk__k { font-family: var(--font-mono); font-size: 10px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3); }
.tk__t { font-weight: 650; font-size: var(--fs-15); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk__s { font-size: var(--fs-13); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk__stub { position: relative; display: grid; place-content: center; justify-items: center; gap: 3px; padding: 8px 6px; border-radius: 0 12px 12px 0; text-align: center; }
.tk__n { font-family: var(--font-display); font-weight: 700; font-size: 1.45rem; line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.tk__st { font-family: var(--font-mono); font-size: 8.5px; font-weight: 700; letter-spacing: 0.14em; line-height: 1.25; text-transform: uppercase; color: var(--text-3); }
.tk__st .i { width: 15px; height: 15px; }
/* Punched: ink stub, gold number and a punched hole. */
.tk--done .tk__stub { background: var(--inverse); color: var(--on-inverse); }
.tk--done .tk__n { color: var(--accent); }
[data-theme='dark'] .tk--done .tk__n { color: #8A6416; }
.tk--done .tk__st { color: color-mix(in srgb, var(--on-inverse) 70%, transparent); }
.tk--done .tk__stub::before { content: ''; position: absolute; top: 7px; right: 8px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35); }
/* Now boarding: gold stub that breathes. */
.tk--current { --tk-edge: var(--accent); --tk-bg: var(--accent-soft); }
.tk--current .tk__stub { background: var(--leaf-flat); color: var(--on-accent); }
.tk--current .tk__st { color: var(--on-accent); animation: bc-blink 1.8s var(--ease-in-out) infinite; }
.lvl--current .tk { filter: drop-shadow(0 0 0.6px var(--accent)) drop-shadow(0 8px 20px rgba(204, 153, 51, 0.28)); }
.tk--open .tk__stub { color: var(--accent-text); }
/* Locked: faded, waiting its turn. */
.tk--locked { opacity: 0.6; }
.tk--locked:hover { transform: none; --tk-edge: var(--line-2); }
.tk--locked .tk__n { color: var(--text-3); }
/* A short decorative barcode strip (loaders, chips, rows). */
.strip { display: inline-flex; align-items: stretch; gap: 3px; height: 22px; color: var(--accent); }
.strip__s { display: flex; gap: 1px; }
.strip__s i { display: block; background: currentColor; border-radius: 0.5px; }
.strip--load { height: 30px; }
.strip--load .strip__s { animation: strip-print 1.6s var(--ease-in-out) infinite; animation-delay: calc(var(--k) * 90ms); transform-origin: 50% 0; }
@keyframes strip-print { 0%, 12% { transform: scaleY(0); opacity: 0.2; } 40%, 70% { transform: none; opacity: 1; } 100% { transform: none; opacity: 0.15; } }

/* Gold flecks used by the quiet celebration. */
.flecks { position: fixed; inset: 0; pointer-events: none; z-index: calc(var(--z-modal) + 5); overflow: hidden; }
.flecks i { position: absolute; width: var(--s, 8px); height: calc(var(--s, 8px) * 0.62); background: var(--c, #E5C568); border-radius: 1px; opacity: 0; animation: fleck var(--d, 2.6s) var(--ease-soft) var(--dl, 0s) both; will-change: transform, opacity; }
@keyframes fleck { 0% { opacity: 0; transform: translate3d(0, 0, 0) rotate(0) scale(0.4); } 12% { opacity: 1; } 100% { opacity: 0; transform: translate3d(var(--x, 0), var(--y, 60vh), 0) rotate(var(--r, 540deg)) scale(1); } }

/* ── Table (shared bones; the admin adds density and tools) ──────── */
.table th { text-align: left; font-size: var(--fs-12); letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); font-weight: 650; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: var(--fs-14); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }

/* ── Theme + sound toggles ──────────────────────────────────────── */
.icon-btn { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; color: var(--text-2); border: 1px solid transparent; transition: background-color var(--t-2), color var(--t-2), border-color var(--t-2), transform var(--t-1); flex: none; position: relative; }
.icon-btn:hover { background: var(--accent-soft); color: var(--text); border-color: var(--accent-line); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn .i { width: 19px; height: 19px; }
.icon-btn__badge { position: absolute; top: 6px; right: 6px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 99px; background: var(--bad); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; line-height: 1; }
.theme-toggle .i-sun { display: none; }
[data-theme='dark'] .theme-toggle .i-sun { display: block; }
[data-theme='dark'] .theme-toggle .i-moon { display: none; }

/* ── The flight mark (AQ.planeSVG / <i data-plane>) ───────────────────── */
.plane { display: inline-block; width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em; overflow: visible; }
.plane .plane__body { fill: var(--plane-body, #E2B552); }
.plane .plane__wing { fill: var(--plane-wing, #B98A2A); }
.plane .plane__glint { stroke: var(--plane-glint, #FFF1C4); }
[data-theme='dark'] .plane { --plane-body: #EAC567; --plane-wing: #C79631; }
@keyframes plane-cruise { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2px); } }
.reduce-motion .plane { animation: none !important; }
@media (prefers-reduced-motion: reduce) { .plane { animation: none !important; } }
.eyebrow .plane { width: 1.5em; height: 1.5em; margin-right: -4px; }
/* On the gold "now boarding" stub the mark is inked in the stub's own text colour. */
.tk--current .tk__st .plane { display: block; width: 18px; height: 18px; margin: 0 auto 3px; --plane-body: currentColor; --plane-wing: currentColor; --plane-glint: transparent; opacity: 0.9; }
/* Level complete: the mark takes off beside the title. */
.takeoff { display: inline-block; margin-left: 0.25em; vertical-align: 0.05em; }
.takeoff .plane { width: 0.8em; height: 0.8em; animation: takeoff 1.1s cubic-bezier(0.3, 0.7, 0.3, 1) 0.5s both; }
@keyframes takeoff { 0% { opacity: 0; transform: translate(-0.6em, 0.3em) rotate(0deg); } 100% { opacity: 1; transform: translate(0, -0.1em) rotate(-14deg); } }
