/* Certificates: the Trophy Room (/certificates), the public verification page
   (/c/{code}), the tutor's issue dialog (cx-) and the organisation studio
   (cs-). Certificates are objects: they tilt under the pointer, shimmer like
   foil and arrive sealed. Palette per certificate comes in as --cp-* vars
   set inline from the preset snapshot. */

:root {
  --tr-bg: var(--tt-bg, #f6f4ff);
  --tr-surface: var(--tt-surface, #ffffff);
  --tr-surface-2: var(--tt-surface-2, #f1effa);
  --tr-line: var(--tt-line, #e6e2f5);
  --tr-ink: var(--tt-ink, #1c1535);
  --tr-muted: var(--tt-muted, #6f6a8a);
  --tr-accent: #6d4df6;
  --tr-accent-2: #ff7ad9;
  --tr-gold: #f5c04a;
  --tr-radius: 22px;
  --tr-shadow: 0 18px 50px rgba(40, 20, 90, 0.14);
}

.tr-page-bg { background: var(--tr-bg); min-height: 100vh; }
.tr-root { position: relative; isolation: isolate; padding: 1.25rem 0 5rem; color: var(--tr-ink); }
.tr-container { max-width: 1120px; }

/* Soft drifting orbs behind everything. */
.tr-sky { position: absolute; inset: 0; overflow: hidden; z-index: -1; pointer-events: none; }
.tr-sky span { position: absolute; width: 42vmax; height: 42vmax; border-radius: 50%; filter: blur(70px); opacity: .35; animation: trDrift 26s ease-in-out infinite alternate; }
.tr-sky span:nth-child(1) { background: #c4b5fd; top: -18vmax; left: -10vmax; }
.tr-sky span:nth-child(2) { background: #fbcfe8; top: 30%; right: -16vmax; animation-delay: -8s; }
.tr-sky span:nth-child(3) { background: #fde68a; bottom: -20vmax; left: 30%; animation-delay: -16s; }
@keyframes trDrift { from { transform: translate3d(0, 0, 0) scale(1); } to { transform: translate3d(6vmax, 4vmax, 0) scale(1.12); } }

/* Hero */
.tr-hero { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1.25rem; margin-bottom: 2rem; }
.tr-eyebrow { display: inline-flex; align-items: center; gap: .45rem; font-size: .78rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--tr-accent); }
.tr-eyebrow i { color: var(--tr-gold); filter: drop-shadow(0 2px 6px rgba(245, 192, 74, .5)); }
.tr-title { font-size: clamp(1.8rem, 4vw, 2.6rem); font-weight: 800; letter-spacing: -.02em; margin: .35rem 0 .35rem; line-height: 1.05; }
.tr-sub { margin: 0; color: var(--tr-muted); font-size: 1rem; max-width: 46ch; }
.tr-stats { display: grid; grid-template-columns: repeat(4, minmax(70px, 1fr)); gap: .5rem; }
.tr-stat { background: var(--tr-surface); border: 1px solid var(--tr-line); border-radius: 16px; padding: .7rem .6rem; text-align: center; box-shadow: 0 6px 18px rgba(40, 20, 90, .06); }
.tr-stat i { display: block; color: var(--tr-accent); font-size: .95rem; margin-bottom: .2rem; }
.tr-stat b { display: block; font-size: 1.3rem; line-height: 1; font-weight: 800; }
.tr-stat span { display: block; font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; color: var(--tr-muted); margin-top: .25rem; }

/* Sections */
.tr-section { margin-bottom: 2.25rem; }
.tr-section-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tr-section-head h2 { font-size: 1.15rem; font-weight: 800; margin: 0; display: flex; align-items: center; gap: .5rem; }
.tr-section-head h2 i { color: var(--tr-accent); }
.tr-pill { font-size: .72rem; font-weight: 700; padding: .3rem .65rem; border-radius: 999px; background: var(--tr-surface-2); color: var(--tr-muted); }
.tr-pill-hot { background: linear-gradient(90deg, var(--tr-accent), var(--tr-accent-2)); color: #fff; animation: trPulse 2.4s ease-in-out infinite; }
@keyframes trPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(109, 77, 246, .5); } 50% { box-shadow: 0 0 0 8px rgba(109, 77, 246, 0); } }
.tr-filters { display: flex; gap: .35rem; flex-wrap: wrap; }
.tr-filter { border: 1px solid var(--tr-line); background: var(--tr-surface); color: var(--tr-muted); font-weight: 700; font-size: .8rem; padding: .35rem .8rem; border-radius: 999px; transition: all .18s ease; }
.tr-filter.active, .tr-filter:hover { background: var(--tr-ink); color: #fff; border-color: var(--tr-ink); }

/* The grid of certificates */
.tr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1.25rem 1rem; perspective: 1400px; }
.tr-grid-locked { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }

.tr-cert { position: relative; cursor: pointer; outline: none; transform-style: preserve-3d; transition: transform .35s cubic-bezier(.2, .8, .2, 1); will-change: transform; animation: trIn .6s cubic-bezier(.2, .8, .2, 1) both; }
.tr-cert:nth-child(2) { animation-delay: .05s; } .tr-cert:nth-child(3) { animation-delay: .1s; } .tr-cert:nth-child(4) { animation-delay: .15s; } .tr-cert:nth-child(5) { animation-delay: .2s; } .tr-cert:nth-child(n+6) { animation-delay: .25s; }
@keyframes trIn { from { opacity: 0; transform: translateY(18px) rotateX(8deg); } to { opacity: 1; transform: none; } }
.tr-cert.tr-hidden { display: none; }
.tr-cert:focus-visible .tr-cert-paper { box-shadow: 0 0 0 3px var(--tr-accent), var(--tr-shadow); }

.tr-cert-paper { position: relative; aspect-ratio: 297 / 210; border-radius: 10px; padding: 10% 9% 8%; color: var(--cp-ink); background: radial-gradient(120% 90% at 50% 0%, var(--cp-paper) 0%, var(--cp-paper2) 100%); box-shadow: var(--tr-shadow); overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; transform: translateZ(0); transition: box-shadow .3s ease; }
.tr-cert:hover .tr-cert-paper { box-shadow: 0 28px 70px rgba(40, 20, 90, .25); }
.tr-cert-frame { position: absolute; inset: 5%; border: 2px solid var(--cp-foil); border-radius: 6px; box-shadow: inset 0 0 0 1px var(--cp-paper), inset 0 0 0 2px var(--cp-accent); pointer-events: none; }
.tr-border-foil .tr-cert-frame { border-image: linear-gradient(115deg, var(--cp-foil), #fff 30%, var(--cp-accent) 50%, var(--cp-foil) 70%, #fff) 1; border-width: 3px; box-shadow: none; border-radius: 0; }
.tr-border-minimal .tr-cert-frame { border: 1.5px solid var(--cp-ink); box-shadow: none; }
.tr-border-confetti .tr-cert-frame { border-radius: 14px; border-style: dashed; box-shadow: none; }
.tr-border-ribbon .tr-cert-paper::before { content: ""; position: absolute; top: -2px; right: 12%; width: 9%; height: 26%; background: linear-gradient(180deg, var(--cp-accent), var(--cp-foil)); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 82%, 0 100%); }
.tr-cert-top { display: flex; justify-content: flex-start; }
.tr-cert-kind { font-size: .55rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--cp-accent); display: inline-flex; gap: .3rem; align-items: center; opacity: .95; }
.tr-cert-title { font-size: clamp(.95rem, 1.5vw, 1.15rem); font-weight: 800; line-height: 1.1; letter-spacing: -.01em; color: var(--cp-accent); text-align: center; margin-top: 2%; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tr-font-serif .tr-cert-title, .tr-font-serif .tr-cert-name { font-family: 'Instrument Serif', Georgia, serif; font-weight: 400; }
.tr-font-serif .tr-cert-title { font-style: italic; font-size: clamp(1.05rem, 1.7vw, 1.3rem); }
.tr-font-mono .tr-cert-title, .tr-font-mono .tr-cert-name { font-family: ui-monospace, 'JetBrains Mono', monospace; letter-spacing: -.03em; }
.tr-cert-name { text-align: center; font-weight: 800; font-size: clamp(.8rem, 1.3vw, 1rem); position: relative; padding-bottom: 4%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tr-cert-name::after { content: ""; position: absolute; left: 25%; right: 25%; bottom: 0; height: 2px; border-radius: 2px; background: linear-gradient(90deg, transparent, var(--cp-foil), var(--cp-accent), var(--cp-foil), transparent); }
.tr-cert-foot { display: flex; align-items: center; justify-content: space-between; }
.tr-cert-seal { width: 20%; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; color: var(--cp-paper); font-size: .7rem; background: conic-gradient(from 20deg, var(--cp-foil), var(--cp-accent), var(--cp-foil), var(--cp-accent), var(--cp-foil)); box-shadow: 0 4px 10px rgba(0, 0, 0, .18), inset 0 0 0 2px var(--cp-accent), inset 0 0 0 3px var(--cp-paper); }
.tr-cert-date { font-size: .55rem; letter-spacing: .1em; text-transform: uppercase; opacity: .7; }

/* Holographic sheen that follows the pointer (certificates.js sets --mx/--my). */
.tr-cert-shine { position: absolute; inset: 0; border-radius: 10px; pointer-events: none; z-index: 2; opacity: 0; transition: opacity .3s ease; background: radial-gradient(circle at calc(var(--mx, .5) * 100%) calc(var(--my, .5) * 100%), rgba(255, 255, 255, .55), rgba(255, 255, 255, .08) 30%, transparent 60%), linear-gradient(calc(var(--mx, .5) * 360deg), rgba(255, 180, 230, .25), rgba(170, 220, 255, .25), rgba(255, 240, 160, .25)); mix-blend-mode: screen; }
.tr-cert:hover .tr-cert-shine, .tr-cert.tr-tilting .tr-cert-shine { opacity: 1; }

.tr-cert-caption { margin-top: .6rem; text-align: center; display: flex; flex-direction: column; gap: .1rem; }
.tr-cert-caption-title { font-weight: 800; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tr-cert-caption-sub { font-size: .75rem; color: var(--tr-muted); }

/* Sealed (unseen) awards are wrapped in an envelope. */
.tr-unseen .tr-cert-paper { filter: blur(1.5px) saturate(.8); }
.tr-seal-wrap { position: absolute; inset: 0; bottom: 2.6rem; display: grid; place-items: center; z-index: 3; }
.tr-envelope { position: relative; width: 78%; aspect-ratio: 1.55; }
.tr-envelope-body { position: absolute; inset: 0; border-radius: 10px; background: linear-gradient(160deg, #fff, #ece8ff); box-shadow: 0 14px 34px rgba(40, 20, 90, .25); border: 1px solid #ddd6ff; }
.tr-envelope-flap { position: absolute; left: 0; right: 0; top: 0; height: 55%; background: linear-gradient(180deg, #f6f3ff, #e3dcff); clip-path: polygon(0 0, 100% 0, 50% 100%); border-radius: 10px 10px 0 0; transform-origin: top; z-index: 1; }
.tr-wax { position: absolute; left: 50%; top: 50%; width: 30%; aspect-ratio: 1; transform: translate(-50%, -40%); border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 1.1rem; background: radial-gradient(circle at 35% 30%, #ff9ad4, #b4257a 70%); box-shadow: 0 6px 14px rgba(180, 37, 122, .45), inset 0 -3px 6px rgba(0, 0, 0, .25); z-index: 2; animation: trWax 2.2s ease-in-out infinite; }
@keyframes trWax { 0%, 100% { transform: translate(-50%, -40%) scale(1); } 50% { transform: translate(-50%, -40%) scale(1.06); } }
.tr-envelope-label { position: absolute; left: 0; right: 0; bottom: 8%; text-align: center; font-size: .68rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: #6d4df6; }
.tr-cert.tr-opening .tr-envelope-flap { animation: trFlap .7s ease forwards; }
.tr-cert.tr-opening .tr-wax { animation: trWaxPop .5s ease forwards; }
.tr-cert.tr-opening .tr-envelope-body, .tr-cert.tr-opening .tr-envelope-label { animation: trFade .6s ease .45s forwards; }
.tr-cert.tr-opening .tr-cert-paper { animation: trUnblur .8s ease .3s forwards; }
@keyframes trFlap { to { transform: rotateX(180deg); opacity: 0; } }
@keyframes trWaxPop { 40% { transform: translate(-50%, -40%) scale(1.3); } to { transform: translate(-50%, -40%) scale(0); opacity: 0; } }
@keyframes trFade { to { opacity: 0; transform: translateY(30px) scale(.9); } }
@keyframes trUnblur { to { filter: none; } }

/* Locked silhouettes */
.tr-locked { cursor: default; }
.tr-locked .tr-cert-paper { background: var(--tr-surface); color: var(--tr-muted); box-shadow: 0 8px 22px rgba(40, 20, 90, .07); justify-content: center; align-items: center; text-align: center; gap: .35rem; }
.tr-locked .tr-cert-frame { border: 2px dashed var(--tr-line); box-shadow: none; }
.tr-locked-glyph { width: 2.2rem; height: 2.2rem; border-radius: 50%; display: grid; place-items: center; background: var(--tr-surface-2); color: var(--tr-muted); }
.tr-locked-title { font-weight: 800; font-size: .9rem; color: var(--tr-ink); }
.tr-locked-meter { width: 70%; height: 6px; border-radius: 999px; background: var(--tr-surface-2); overflow: hidden; }
.tr-locked-meter span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--cp-accent), var(--cp-foil)); animation: trMeter 1.2s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes trMeter { from { width: 0 !important; } }
.tr-locked-sub { font-size: .72rem; }

/* Empty state */
.tr-empty { text-align: center; padding: 3rem 1.5rem; background: var(--tr-surface); border: 1px solid var(--tr-line); border-radius: var(--tr-radius); box-shadow: var(--tr-shadow); }
.tr-empty-art { width: 84px; height: 84px; margin: 0 auto 1rem; border-radius: 50%; display: grid; place-items: center; font-size: 2rem; color: #fff; background: linear-gradient(135deg, var(--tr-gold), #ff9f43); box-shadow: 0 14px 30px rgba(245, 160, 60, .4); animation: trWax 3s ease-in-out infinite; }
.tr-empty-title { font-weight: 800; font-size: 1.25rem; }
.tr-empty-sub { color: var(--tr-muted); max-width: 44ch; margin: .4rem auto 1.25rem; }
.tr-cta { display: inline-flex; align-items: center; gap: .5rem; padding: .75rem 1.3rem; border-radius: 999px; font-weight: 800; color: #fff; background: linear-gradient(90deg, var(--tr-accent), var(--tr-accent-2)); box-shadow: 0 10px 24px rgba(109, 77, 246, .35); text-decoration: none; }
.tr-cta:hover { color: #fff; transform: translateY(-1px); }

/* Viewer */
.tr-viewer { position: fixed; inset: 0; z-index: 1080; display: grid; place-items: center; padding: 1rem; }
.tr-viewer[hidden] { display: none; }
.tr-viewer-backdrop { position: absolute; inset: 0; background: rgba(20, 12, 45, .72); backdrop-filter: blur(10px); animation: trFadeIn .25s ease; }
@keyframes trFadeIn { from { opacity: 0; } }
.tr-viewer-panel { position: relative; width: min(1100px, 100%, calc(72vh * 297 / 210)); background: var(--tr-surface); border-radius: 20px; overflow: hidden; box-shadow: 0 40px 100px rgba(0, 0, 0, .5); animation: trZoom .4s cubic-bezier(.2, .8, .2, 1); }
@keyframes trZoom { from { opacity: 0; transform: scale(.92) translateY(20px); } }
.tr-viewer-close { position: absolute; top: .6rem; right: .6rem; z-index: 2; width: 38px; height: 38px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .45); color: #fff; display: grid; place-items: center; }
.tr-viewer-doc { background: #e9e9ee; aspect-ratio: 297 / 210; }
.tr-viewer-doc iframe { width: 100%; height: 100%; border: 0; display: block; }
.tr-viewer-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: .85rem 1rem; border-top: 1px solid var(--tr-line); }
.tr-viewer-meta { display: flex; flex-direction: column; min-width: 0; }
.tr-viewer-meta b { font-weight: 800; }
.tr-viewer-meta span { font-family: ui-monospace, monospace; font-size: .75rem; color: var(--tr-muted); letter-spacing: .12em; }
.tr-viewer-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.tr-act { display: inline-flex; align-items: center; gap: .45rem; padding: .6rem 1rem; border-radius: 999px; border: 0; font-weight: 800; font-size: .85rem; color: #fff; background: linear-gradient(90deg, var(--tr-accent), var(--tr-accent-2)); text-decoration: none; box-shadow: 0 8px 20px rgba(109, 77, 246, .3); transition: transform .15s ease; }
.tr-act:hover { color: #fff; transform: translateY(-1px); }
.tr-act-ghost { background: var(--tr-surface-2); color: var(--tr-ink); box-shadow: none; }
.tr-act-ghost:hover { color: var(--tr-ink); }

/* Reveal takeover (first open) */
.tr-reveal { position: fixed; inset: 0; z-index: 1079; display: grid; place-items: center; pointer-events: none; }
.tr-reveal[hidden] { display: none; }
.tr-reveal-glow { position: absolute; inset: 0; background: radial-gradient(circle at 50% 50%, rgba(255, 230, 150, .55), rgba(109, 77, 246, .25) 40%, transparent 70%); animation: trGlow .9s ease both; }
@keyframes trGlow { from { opacity: 0; transform: scale(.4); } 60% { opacity: 1; } to { opacity: 0; transform: scale(1.6); } }
.tr-reveal-text { position: relative; font-weight: 800; font-size: 1.6rem; color: #fff; text-shadow: 0 4px 20px rgba(0, 0, 0, .4); animation: trTextPop .9s ease both; }
@keyframes trTextPop { from { opacity: 0; transform: scale(.6); } 40% { opacity: 1; transform: scale(1.05); } to { opacity: 0; transform: scale(1); } }

/* Public verification page */
.cv-body { margin: 0; min-height: 100vh; background: var(--tr-bg); color: var(--tr-ink); font-family: 'Poppins', -apple-system, 'Segoe UI', Roboto, sans-serif; position: relative; isolation: isolate; }
.cv-main { max-width: 1000px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }
.cv-brand { display: inline-flex; align-items: center; gap: .5rem; font-weight: 800; color: var(--tr-ink); text-decoration: none; margin-bottom: 1rem; }
.cv-brand i { color: var(--tr-gold); }
.cv-verified { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; background: var(--tr-surface); border: 1px solid var(--tr-line); border-radius: 18px; padding: .9rem 1.1rem; margin-bottom: 1rem; box-shadow: 0 8px 24px rgba(40, 20, 90, .08); }
.cv-verified-badge { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 1.2rem; background: linear-gradient(135deg, #22c55e, #0ea5e9); box-shadow: 0 8px 20px rgba(34, 197, 94, .35); }
.cv-verified-title { font-weight: 800; }
.cv-verified-sub { font-size: .85rem; color: var(--tr-muted); }
.cv-code { margin-left: auto; font-size: .85rem; letter-spacing: .14em; font-weight: 700; background: var(--tr-surface-2); padding: .4rem .7rem; border-radius: 10px; color: var(--tr-ink); }
.cv-doc { aspect-ratio: 297 / 210; background: #e9e9ee; border-radius: 16px; overflow: hidden; box-shadow: var(--tr-shadow); }
.cv-doc iframe { width: 100%; height: 100%; border: 0; display: block; }
.cv-actions { display: flex; gap: .6rem; flex-wrap: wrap; justify-content: center; margin: 1.25rem 0; }
.cv-foot { text-align: center; font-size: .8rem; color: var(--tr-muted); }
.cv-foot a { color: var(--tr-accent); font-weight: 700; }

/* ---------- Issue dialog (cx-) ---------- */
.cx-modal .modal-content.cx-content { border: 0; border-radius: 24px; overflow: hidden; background: var(--tr-surface); color: var(--tr-ink); }
.cx-head { position: relative; display: flex; align-items: center; gap: 1rem; padding: 1.25rem 1.5rem; background: linear-gradient(120deg, #1c1535, #3b2a8a 60%, #6d4df6); color: #fff; overflow: hidden; }
.cx-head-glow { position: absolute; right: -60px; top: -80px; width: 260px; height: 260px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 200, 90, .6), transparent 65%); }
.cx-close { position: absolute; top: .8rem; right: .8rem; width: 36px; height: 36px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .15); color: #fff; }
.cx-head-badge { width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; font-size: 1.5rem; background: linear-gradient(135deg, var(--tr-gold), #ff9f43); box-shadow: 0 10px 24px rgba(245, 192, 74, .4); flex: none; }
.cx-eyebrow { font-size: .72rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; opacity: .8; }
.cx-title { margin: .1rem 0; font-weight: 800; font-size: 1.35rem; }
.cx-sub { font-size: .88rem; opacity: .85; }
.cx-body { padding: 1.25rem 1.5rem 1.5rem; }
.cx-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 1.5rem; }
.cx-label { font-size: .72rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--tr-muted); margin: 1rem 0 .5rem; }
.cx-label:first-child { margin-top: 0; }
.cx-who { display: inline-flex; background: var(--tr-surface-2); border-radius: 999px; padding: .25rem; gap: .25rem; margin-bottom: .6rem; }
.cx-who-tab { border: 0; background: transparent; color: var(--tr-muted); font-weight: 700; font-size: .82rem; padding: .4rem .9rem; border-radius: 999px; }
.cx-who-tab.active { background: var(--tr-surface); color: var(--tr-ink); box-shadow: 0 2px 8px rgba(0, 0, 0, .08); }
.cx-search { display: flex; align-items: center; gap: .5rem; border: 1px solid var(--tr-line); border-radius: 12px; padding: .5rem .75rem; margin-bottom: .5rem; color: var(--tr-muted); }
.cx-search input { border: 0; outline: 0; background: transparent; flex: 1; color: var(--tr-ink); }
.cx-roster { max-height: 190px; overflow: auto; display: flex; flex-direction: column; gap: .25rem; padding-right: .25rem; }
.cx-student, .cx-class { display: flex; align-items: center; gap: .6rem; padding: .45rem .6rem; border-radius: 12px; border: 1px solid transparent; cursor: pointer; position: relative; }
.cx-student:hover, .cx-class:hover { background: var(--tr-surface-2); }
.cx-student input, .cx-class input { position: absolute; opacity: 0; pointer-events: none; }
.cx-student-avatar, .cx-class-icon { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: .72rem; font-weight: 800; color: #fff; background: linear-gradient(135deg, var(--tr-accent), var(--tr-accent-2)); flex: none; }
.cx-student-name, .cx-class-name { font-weight: 600; font-size: .9rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cx-student i { opacity: 0; color: var(--tr-accent); transition: opacity .15s; }
.cx-student:has(input:checked) { background: rgba(109, 77, 246, .1); border-color: rgba(109, 77, 246, .35); }
.cx-student:has(input:checked) i { opacity: 1; }
.cx-class:has(input:checked) { background: rgba(109, 77, 246, .1); border-color: rgba(109, 77, 246, .35); }
.cx-class-count { font-size: .72rem; font-weight: 800; color: var(--tr-muted); background: var(--tr-surface-2); padding: .15rem .5rem; border-radius: 999px; }
.cx-classes { display: flex; flex-direction: column; gap: .25rem; max-height: 190px; overflow: auto; }
.cx-empty { font-size: .85rem; color: var(--tr-muted); padding: .5rem; }
.cx-presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: .5rem; }
.cx-preset { position: relative; border: 2px solid var(--tr-line); background: var(--tr-surface); border-radius: 14px; padding: .4rem; display: flex; flex-direction: column; gap: .35rem; align-items: stretch; transition: all .18s; }
.cx-preset.active { border-color: var(--tr-accent); box-shadow: 0 0 0 3px rgba(109, 77, 246, .18); }
.cx-preset-swatch, .cs-item-swatch { display: grid; place-items: center; aspect-ratio: 297 / 210; border-radius: 6px; background: radial-gradient(120% 90% at 50% 0%, var(--cp-paper), var(--cp-paper2)); box-shadow: inset 0 0 0 2px var(--cp-foil), inset 0 0 0 3px var(--cp-paper), inset 0 0 0 4px var(--cp-accent); }
.cx-preset-seal, .cs-item-swatch span { width: 28%; aspect-ratio: 1; border-radius: 50%; background: conic-gradient(from 20deg, var(--cp-foil), var(--cp-accent), var(--cp-foil)); box-shadow: inset 0 0 0 2px var(--cp-paper); }
.cx-preset-name { font-size: .72rem; font-weight: 700; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cx-preset-org { position: absolute; top: .3rem; right: .3rem; width: 18px; height: 18px; border-radius: 50%; background: var(--tr-ink); color: #fff; font-size: .55rem; display: grid; place-items: center; }
.cx-field { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .6rem; }
.cx-field > span { font-size: .78rem; font-weight: 700; color: var(--tr-muted); }
.cx-field em { font-style: normal; font-weight: 500; opacity: .7; }
.cx-field input, .cx-field textarea, .cs-field input, .cs-field textarea { border: 1px solid var(--tr-line); border-radius: 12px; padding: .55rem .75rem; font: inherit; font-size: .92rem; color: var(--tr-ink); background: var(--tr-surface); outline: 0; resize: vertical; }
.cx-field input:focus, .cx-field textarea:focus, .cs-field input:focus, .cs-field textarea:focus { border-color: var(--tr-accent); box-shadow: 0 0 0 3px rgba(109, 77, 246, .15); }
.cx-hint { font-size: .75rem; color: var(--tr-muted); margin: .25rem 0 0; }
.cx-hint code, .cs-label code { background: var(--tr-surface-2); padding: .1rem .35rem; border-radius: 6px; color: var(--tr-accent); font-size: .72rem; }
.cx-col-preview { display: flex; flex-direction: column; gap: .75rem; position: sticky; top: 0; align-self: start; }
.cx-preview-label, .cs-preview-label { font-size: .72rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--tr-muted); display: flex; align-items: center; gap: .4rem; }
.cx-preview-frame, .cs-preview { position: relative; aspect-ratio: 297 / 210; border-radius: 14px; overflow: hidden; background: #e9e9ee; box-shadow: var(--tr-shadow); }
.cx-preview-frame iframe, .cs-preview iframe { width: 100%; height: 100%; border: 0; display: block; }
.cx-preview-loading, .cs-preview-loading { position: absolute; inset: 0; display: grid; place-items: center; font-size: 1.6rem; color: var(--tr-accent); background: rgba(255, 255, 255, .5); opacity: 0; transition: opacity .2s; pointer-events: none; }
.cx-preview-loading.on, .cs-preview-loading.on { opacity: 1; }
.cx-preview-loading i, .cs-preview-loading i { animation: trWax 1s ease-in-out infinite; }
.cx-error, .cs-error { background: #fff1f2; color: #b91c1c; border-radius: 12px; padding: .6rem .8rem; font-size: .85rem; font-weight: 600; }
.cx-go, .cs-save { border: 0; border-radius: 999px; padding: .9rem 1.4rem; font-weight: 800; font-size: 1rem; color: #fff; background: linear-gradient(90deg, var(--tr-accent), var(--tr-accent-2)); box-shadow: 0 12px 28px rgba(109, 77, 246, .35); display: inline-flex; align-items: center; justify-content: center; gap: .6rem; transition: transform .15s; }
.cx-go:hover, .cs-save:hover { transform: translateY(-1px); }
.cx-go:disabled { opacity: .6; transform: none; }
.cx-done { text-align: center; padding: 1rem; animation: trZoom .4s ease; }
.cx-done-burst { width: 72px; height: 72px; margin: 0 auto .6rem; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 1.8rem; background: linear-gradient(135deg, var(--tr-gold), #ff9f43); box-shadow: 0 14px 30px rgba(245, 160, 60, .45); }
.cx-done-title { font-weight: 800; font-size: 1.3rem; }
.cx-done-sub { color: var(--tr-muted); font-size: .9rem; }
.cx-done-actions { display: flex; gap: .5rem; justify-content: center; margin-top: .9rem; }
.cx-ghost, .cs-ghost { border: 1px solid var(--tr-line); background: var(--tr-surface); color: var(--tr-ink); font-weight: 700; padding: .55rem 1rem; border-radius: 999px; font-size: .88rem; display: inline-flex; align-items: center; gap: .45rem; }
.cx-ghost:hover, .cs-ghost:hover { background: var(--tr-surface-2); }
@media (max-width: 900px) { .cx-form { grid-template-columns: 1fr; } .cx-col-preview { position: static; } }

/* ---------- Organisation studio (cs-) ---------- */
.cs-page { color: var(--org-ink, var(--tr-ink)); padding-bottom: 3rem; }
.cs-hero { position: relative; overflow: hidden; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 1rem; border-radius: 24px; padding: 1.75rem 2rem; margin-bottom: 1.5rem; color: #fff; background: linear-gradient(120deg, #1c1535, #3b2a8a 55%, #6d4df6); box-shadow: 0 20px 50px rgba(40, 20, 90, .25); }
.cs-hero-glow { position: absolute; right: -80px; top: -120px; width: 360px; height: 360px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 200, 90, .55), transparent 65%); pointer-events: none; }
.cs-eyebrow { font-size: .72rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; opacity: .85; display: inline-flex; gap: .4rem; align-items: center; }
.cs-eyebrow i { color: var(--tr-gold); }
.cs-title { font-size: clamp(1.5rem, 3vw, 2.2rem); font-weight: 800; margin: .3rem 0; letter-spacing: -.02em; }
.cs-sub { margin: 0; max-width: 62ch; opacity: .85; font-size: .95rem; }
.cs-hero-stats { display: flex; gap: .6rem; position: relative; }
.cs-stat { background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .2); border-radius: 14px; padding: .6rem .9rem; text-align: center; min-width: 90px; backdrop-filter: blur(6px); }
.cs-stat b { display: block; font-size: 1.4rem; line-height: 1; }
.cs-stat span { font-size: .65rem; text-transform: uppercase; letter-spacing: .1em; opacity: .8; }
.cs-layout { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.cs-side { background: var(--tr-surface); border: 1px solid var(--tr-line); border-radius: 20px; padding: 1rem; box-shadow: 0 8px 24px rgba(40, 20, 90, .06); position: sticky; top: 1rem; }
.cs-side-head { display: flex; align-items: center; justify-content: space-between; font-size: .72rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--tr-muted); margin-bottom: .6rem; }
.cs-side-head-sub { margin-top: 1rem; }
.cs-new { border: 0; background: var(--tr-ink); color: #fff; font-size: .72rem; font-weight: 800; padding: .35rem .7rem; border-radius: 999px; letter-spacing: 0; text-transform: none; }
.cs-list { display: flex; flex-direction: column; gap: .35rem; }
.cs-item, .cs-recent-item { display: flex; align-items: center; gap: .65rem; border: 2px solid transparent; background: transparent; padding: .4rem .5rem; border-radius: 14px; text-align: left; width: 100%; text-decoration: none; color: inherit; transition: all .15s; }
.cs-item:hover, .cs-recent-item:hover { background: var(--tr-surface-2); color: inherit; }
.cs-item.active { border-color: var(--tr-accent); background: rgba(109, 77, 246, .08); }
.cs-item .cs-item-swatch, .cs-recent-item .cs-item-swatch { width: 54px; flex: none; }
.cs-item-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.cs-item-text b { font-size: .88rem; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-item-text small { font-size: .7rem; color: var(--tr-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-item-default { color: var(--tr-gold); }
.cs-empty { font-size: .82rem; color: var(--tr-muted); padding: .4rem .2rem .6rem; }
.cs-editor { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 1.25rem; background: var(--tr-surface); border: 1px solid var(--tr-line); border-radius: 20px; padding: 1.25rem; box-shadow: 0 8px 24px rgba(40, 20, 90, .06); }
.cs-preview-wrap { position: sticky; top: 1rem; display: flex; flex-direction: column; gap: .6rem; }
.cs-preview-label span { color: var(--tr-ink); text-transform: none; letter-spacing: 0; font-weight: 700; }
.cs-form { display: flex; flex-direction: column; gap: .2rem; }
.cs-row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-end; }
.cs-row-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; }
.cs-grow { flex: 1; min-width: 160px; }
.cs-field { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .6rem; }
.cs-field > span { font-size: .78rem; font-weight: 700; color: var(--tr-muted); }
.cs-field em { font-style: normal; font-weight: 500; opacity: .7; }
.cs-toggle { flex-direction: row; align-items: center; gap: .5rem; padding: .55rem .75rem; border: 1px solid var(--tr-line); border-radius: 12px; cursor: pointer; }
.cs-toggle > span { color: var(--tr-ink); }
.cs-toggle input { accent-color: var(--tr-accent); width: 16px; height: 16px; }
.cs-label { font-size: .72rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--tr-muted); margin: .6rem 0 .45rem; display: flex; gap: .6rem; align-items: baseline; flex-wrap: wrap; }
.cs-label small { font-weight: 500; letter-spacing: 0; text-transform: none; font-size: .72rem; }
.cs-palette { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .5rem; margin-bottom: .6rem; }
.cs-palette label { display: flex; flex-direction: column; align-items: center; gap: .3rem; font-size: .7rem; font-weight: 700; color: var(--tr-muted); cursor: pointer; }
.cs-palette input[type="color"] { width: 100%; height: 42px; border: 1px solid var(--tr-line); border-radius: 12px; padding: 3px; background: var(--tr-surface); cursor: pointer; }
.cs-chips { display: flex; flex-wrap: wrap; gap: .3rem; }
.cs-chips button { border: 1px solid var(--tr-line); background: var(--tr-surface); color: var(--tr-muted); font-size: .74rem; font-weight: 700; padding: .3rem .6rem; border-radius: 999px; text-transform: capitalize; transition: all .15s; }
.cs-chips button.active { background: var(--tr-ink); color: #fff; border-color: var(--tr-ink); }
.cs-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-top: .6rem; }
.cs-danger { color: #b91c1c; border-color: #fecaca; }
.cs-award { margin-left: auto; }
.cs-readonly { font-size: .82rem; color: var(--tr-muted); display: inline-flex; gap: .5rem; align-items: center; }
.cs-recent { margin-top: 1.5rem; background: var(--tr-surface); border: 1px solid var(--tr-line); border-radius: 20px; padding: 1rem 1.25rem; }
.cs-recent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .35rem; }
@media (max-width: 1100px) { .cs-layout { grid-template-columns: 1fr; } .cs-side { position: static; } .cs-editor { grid-template-columns: 1fr; } .cs-preview-wrap { position: static; } }
@media (max-width: 700px) { .cs-row-3 { grid-template-columns: 1fr; } .cs-palette { grid-template-columns: repeat(3, 1fr); } .cs-hero { padding: 1.25rem; } }

/* Dark themes: the surfaces already follow --tt-*; soften the sky. */
:root[data-theme="dark"] .tr-sky span, .dark-mode .tr-sky span { opacity: .18; }
@media (prefers-reduced-motion: reduce) { .tr-cert, .tr-sky span, .tr-pill-hot, .tr-wax, .tr-empty-art { animation: none !important; transition: none !important; } }
@media (max-width: 640px) {
  .tr-grid, .tr-grid-locked { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem .6rem; }
  .tr-cert-paper { border-radius: 7px; }
  .tr-cert-kind { font-size: .48rem; }
  .tr-cert-caption-title { font-size: .8rem; }
  .tr-envelope-label { font-size: .55rem; }
  .tr-locked-title { font-size: .78rem; }
  .tr-stats { width: 100%; }
}
