/* ===== StandSure Live Portal ===== */
:root {
  --leaf: #6fb23c;
  --deep: #4f8a2a;
  --soft: #eaf4e0;
  --oak: #5c3a21;
  --ink: #232a21;
  --body: #4a5244;
  --muted: #6f7768;
  --line: #e4e8df;
  --cream: #fbfaf6;
  --bad: #b3401f;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Inter", system-ui, sans-serif;
  background: var(--cream);
  color: var(--body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: "Poppins", "Inter", sans-serif; color: var(--ink); letter-spacing: -.01em; margin: 0; }
button { font: inherit; cursor: pointer; }
input, textarea { font: inherit; }

.wrap { max-width: 680px; margin: 0 auto; padding: 0 20px; }
.wrap--wide { max-width: 980px; }

html { scroll-behavior: smooth; }

/* Header (sticky, with section nav) */
.p-header { background: #fff; border-bottom: 1px solid var(--line); padding: 14px 0; position: sticky; top: 0; z-index: 40; }
.p-nav { display: flex; gap: 18px; flex: 1; min-width: 0; margin: 0 18px; overflow-x: auto; scrollbar-width: none; }
.p-nav::-webkit-scrollbar { display: none; }
.p-nav a { color: var(--muted); text-decoration: none; font-size: .85rem; font-weight: 600; white-space: nowrap; }
.p-nav a:hover { color: var(--deep); }
.p-header .wrap, .p-header .wrap--wide { display: flex; align-items: center; gap: 12px; }
.p-brand { font-family: "Poppins", sans-serif; font-weight: 600; color: var(--ink); font-size: 1.05rem; text-decoration: none; }
.p-brand strong { color: var(--deep); font-weight: 700; }
.p-live { margin-left: auto; display: inline-flex; align-items: center; gap: 7px; font-size: .8rem; font-weight: 600; color: var(--deep); }
.p-live .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--leaf); animation: pulse 1.6s infinite; }
.p-live.is-off { color: var(--muted); }
.p-live.is-off .dot { background: #c2c8bc; animation: none; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

main { padding: 36px 0 64px; }

/* Cards */
.card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 28px; box-shadow: 0 6px 22px rgba(35,42,33,.05); }
.card + .card { margin-top: 18px; }
.eyebrow { font-size: .72rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--deep); margin: 0 0 8px; }
.sub { color: var(--muted); font-size: .95rem; margin: 6px 0 0; }

/* Join screen */
.join { text-align: center; padding: 44px 28px; }
.join h1 { font-size: 1.7rem; margin-bottom: 8px; }
.join p { color: var(--muted); margin: 0 0 24px; }
.join-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.code-input {
  width: 210px; text-align: center; font-family: "Poppins", sans-serif; font-weight: 600;
  font-size: 1.25rem; letter-spacing: .14em; text-transform: uppercase;
  padding: 12px 14px; border: 2px solid var(--line); border-radius: 10px; outline: none;
}
.code-input:focus { border-color: var(--leaf); }

/* Buttons */
.btn {
  display: inline-block; border: 0; border-radius: 10px; padding: 12px 24px;
  font-weight: 600; font-size: .95rem; text-decoration: none;
  background: var(--deep); color: #fff; transition: background .15s ease;
}
.btn:hover { background: #3f7020; }
.btn-ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.btn-ghost:hover { border-color: var(--ink); background: transparent; }
.btn-sm { padding: 8px 14px; font-size: .85rem; border-radius: 8px; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-danger { background: var(--bad); }
.btn-danger:hover { background: #93351a; }

/* Message banner */
.banner {
  background: var(--soft); border: 1px solid #d3e6c2; border-radius: 12px;
  padding: 16px 20px; color: var(--ink); font-weight: 500; margin-bottom: 18px;
}

/* Poll */
.q-status { display: inline-block; font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; border-radius: 999px; padding: 4px 12px; margin-bottom: 14px; }
.q-status.open { background: var(--soft); color: var(--deep); }
.q-status.closed { background: #f3ece2; color: var(--oak); }
.q-status.revealed { background: var(--deep); color: #fff; }
.q-text { font-size: 1.35rem; line-height: 1.35; margin-bottom: 22px; }

.opt {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: var(--cream); border: 2px solid var(--line); border-radius: 12px;
  padding: 14px 18px; margin-bottom: 10px; color: var(--ink); font-weight: 500;
  position: relative; overflow: hidden; transition: border-color .15s ease;
}
.opt:hover:not(:disabled) { border-color: var(--leaf); }
.opt.sel { border-color: var(--deep); background: var(--soft); }
.opt:disabled { cursor: default; }
.opt .mark { flex: none; width: 22px; height: 22px; border-radius: 50%; border: 2px solid #c9cfc2; display: grid; place-items: center; font-size: .8rem; color: #fff; background: transparent; }
.opt.sel .mark { background: var(--deep); border-color: var(--deep); }
.opt .bar { position: absolute; inset: 0 auto 0 0; width: 0; background: rgba(111,178,60,.16); transition: width .6s ease; }
.opt .pc { margin-left: auto; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.opt.correct { border-color: var(--deep); }
.opt.correct .pc { color: var(--deep); }
.opt.correct .mark { background: var(--deep); border-color: var(--deep); }
.opt > span { position: relative; }

.submit-row { display: flex; align-items: center; gap: 14px; margin-top: 18px; }
.note { font-size: .9rem; color: var(--deep); font-weight: 600; }
.note.err { color: var(--bad); }

/* Poll modal — a new poll pops over the page */
.poll-modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 18px; }
.poll-modal[hidden] { display: none; }
.poll-modal-backdrop { position: absolute; inset: 0; background: rgba(21,32,33,.55); }
.poll-modal-card {
  position: relative; width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto;
  background: #fff; border-radius: 16px; padding: 30px 28px 28px;
  box-shadow: 0 24px 60px rgba(0,0,0,.32); animation: pollpop .18s ease-out;
}
@keyframes pollpop { from { transform: translateY(12px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.poll-modal-x {
  position: absolute; top: 12px; right: 14px; width: 34px; height: 34px; border: 0; border-radius: 8px;
  background: var(--cream); color: var(--muted); font-size: 1.4rem; line-height: 1; cursor: pointer;
}
.poll-modal-x:hover { background: var(--line); color: var(--ink); }
.poll-modal-tag { font-size: .72rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--deep); margin: 0 0 10px; }
.poll-modal-body .q-text { margin-bottom: 18px; }

.linkish { background: none; border: 0; color: var(--deep); font: inherit; font-weight: 600; cursor: pointer; padding: 0; text-decoration: underline; }

/* Waiting */
.waiting { text-align: center; padding: 54px 20px; color: var(--muted); }
.waiting .pulse { width: 14px; height: 14px; border-radius: 50%; background: var(--leaf); margin: 0 auto 18px; animation: pulse 1.6s infinite; }

/* ===== Control page ===== */
.kv { display: flex; gap: 28px; flex-wrap: wrap; align-items: center; }
.kv-qr { flex: none; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.kv .code-big { font-family: "Poppins", sans-serif; font-weight: 700; font-size: 2rem; letter-spacing: .1em; color: var(--ink); }
.kv .lbl { font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); display: block; }
.kv code { background: var(--cream); border: 1px solid var(--line); border-radius: 6px; padding: 3px 8px; font-size: .8rem; word-break: break-all; }

.poll-row { border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; margin-top: 14px; }
.poll-row.active { border-color: var(--leaf); box-shadow: 0 0 0 3px rgba(111,178,60,.15); }
.poll-row h3 { font-size: 1.02rem; margin-bottom: 4px; }
.poll-meta { font-size: .82rem; color: var(--muted); margin-bottom: 12px; }
.poll-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.t-bar { display: flex; align-items: center; gap: 10px; font-size: .88rem; margin: 5px 0; }
.t-bar .t-track { flex: 1; height: 8px; background: var(--cream); border-radius: 99px; overflow: hidden; }
.t-bar .t-fill { height: 100%; background: var(--leaf); border-radius: 99px; transition: width .4s ease; }
.t-bar.correct .t-fill { background: var(--deep); }
.t-bar .t-n { width: 30px; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.t-bar .t-opt { width: 38%; min-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-bar.correct .t-opt::after { content: " ✓"; color: var(--deep); font-weight: 700; }

textarea.polls-src { width: 100%; min-height: 170px; border: 1.5px solid var(--line); border-radius: 10px; padding: 14px; resize: vertical; }
.chk-row { display: flex; align-items: center; gap: 9px; margin-top: 12px; font-size: .92rem; color: var(--body); cursor: pointer; }
.chk-row input { width: 17px; height: 17px; accent-color: var(--deep); }
.id-card { border-left: 3px solid var(--leaf); }
textarea.polls-src:focus { outline: none; border-color: var(--leaf); }
input.text { width: 100%; padding: 11px 14px; border: 1.5px solid var(--line); border-radius: 10px; }
input.text:focus { outline: none; border-color: var(--leaf); }
.form-row { display: flex; gap: 10px; margin-top: 10px; }
.form-row .text { flex: 1; }
.hint { font-size: .82rem; color: var(--muted); }

footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 24px 0 40px; }

/* ===== Course portal (learner) ===== */
.course-head { margin-bottom: 20px; }
.course-head h1 { font-size: clamp(1.5rem, 4vw, 2rem); }

.live-hint {
  display: flex; align-items: center; gap: 10px;
  background: #fff; border: 1px dashed #cdd5c4; border-radius: 12px;
  padding: 13px 18px; margin-bottom: 8px; color: var(--muted); font-size: .92rem;
}
.live-hint .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--leaf); animation: pulse 1.6s infinite; flex: none; }

.p-section { margin-top: 34px; scroll-margin-top: 76px; }
.p-section > .eyebrow { margin-bottom: 12px; }
#live { scroll-margin-top: 76px; }
.locked-note { color: var(--muted); font-size: .9rem; margin: 0 0 12px; }

/* Resource list */
.res-list { display: grid; gap: 10px; }
.res-item {
  display: flex; align-items: center; gap: 16px; text-decoration: none;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 15px 18px;
  color: var(--ink); transition: border-color .15s ease;
}
a.res-item:hover { border-color: var(--leaf); }
.res-item .res-icon { flex: none; width: 40px; height: 40px; border-radius: 9px; background: var(--soft); display: grid; place-items: center; font-size: 1.05rem; }
.res-item .res-lock { flex: none; width: 40px; height: 40px; border-radius: 9px; background: #f1f0ec; display: grid; place-items: center; font-size: 1rem; }
.res-item .res-body { flex: 1; min-width: 0; }
.res-item .res-body strong { display: block; font-family: "Poppins", sans-serif; font-weight: 600; font-size: .98rem; }
.res-item .res-body small { color: var(--muted); font-size: .85rem; line-height: 1.4; display: block; }
.res-item .res-action { flex: none; color: var(--deep); font-weight: 600; font-size: .88rem; }
.res-item.locked { background: #faf9f5; }
.res-item.locked .res-body strong, .res-item.locked .res-body small { color: #a8aca1; }
.res-item .res-tag { flex: none; font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #a8aca1; border: 1px solid var(--line); border-radius: 999px; padding: 4px 11px; }

/* Video grid */
.vid-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.vid-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.vid-frame { aspect-ratio: 16 / 9; position: relative; background: #1d241a; }
.vid-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.vid-frame .vid-inner { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 8px; text-align: center; }
.vid-frame .vid-inner p { margin: 0; font-size: .8rem; color: #9aa593; }
.vid-frame .play { width: 46px; height: 46px; border-radius: 50%; background: var(--deep); color: #fff; display: grid; place-items: center; padding-left: 3px; }
.vid-frame.locked { background: #eceae4; }
.vid-frame.locked .lock { font-size: 1.5rem; opacity: .7; }
.vid-frame.locked .vid-inner p { color: #97948b; }
.vid-card .vid-title { font-family: "Poppins", sans-serif; font-weight: 600; color: var(--ink); font-size: .95rem; margin: 12px 14px 2px; }
.vid-card .vid-desc { color: var(--muted); font-size: .82rem; line-height: 1.45; margin: 0 14px 14px; }
.vid-card.is-locked .vid-title, .vid-card.is-locked .vid-desc { color: #a8aca1; }

/* Poll history */
.hist-item { background: #fff; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; }
.hist-item summary {
  list-style: none; cursor: pointer; padding: 15px 18px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.hist-item summary::-webkit-details-marker { display: none; }
.hist-item summary::before { content: "▸"; color: var(--muted); transition: transform .15s ease; }
.hist-item[open] summary::before { transform: rotate(90deg); }
.hist-q { font-family: "Poppins", sans-serif; font-weight: 600; color: var(--ink); font-size: .95rem; flex: 1; min-width: 200px; }
.verdict { font-size: .8rem; font-weight: 600; color: var(--muted); }
.verdict.ok { color: var(--deep); }
.verdict.no { color: var(--bad); }
.hist-body { padding: 4px 18px 16px; }
.hist-body .opt { cursor: default; }

/* Justification (revealed polls) */
.just { margin-top: 12px; }
.just-toggle {
  background: none; border: 1.5px solid var(--line); border-radius: 8px;
  padding: 8px 14px; font-size: .85rem; font-weight: 600; color: var(--deep);
}
.just-toggle:hover { border-color: var(--deep); }
.just-panel { margin-top: 12px; background: var(--soft); border: 1px solid #d3e6c2; border-radius: 10px; padding: 16px 18px; }
.just-panel p { margin: 0 0 12px; color: var(--ink); line-height: 1.6; }
.just-panel p:last-child { margin-bottom: 0; }
.just-panel img { max-width: 100%; border-radius: 8px; border: 1px solid var(--line); display: block; margin-top: 10px; background: #fff; }

/* FAQ */
.faq-search { width: 100%; padding: 11px 16px; border: 1.5px solid var(--line); border-radius: 10px; font: inherit; background: #fff; margin-bottom: 18px; }
.faq-search:focus { outline: none; border-color: var(--leaf); }
.faq-group { margin-bottom: 20px; }
.faq-group-title { font-size: .76rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--oak); margin: 0 0 8px; }
.faq-item { background: #fff; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; }
.faq-item summary { list-style: none; cursor: pointer; padding: 14px 18px; font-weight: 600; color: var(--ink); display: flex; align-items: center; gap: 12px; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::before { content: "▸"; color: var(--muted); transition: transform .15s ease; }
.faq-item[open] summary::before { transform: rotate(90deg); }
.faq-item p { margin: 0; padding: 0 18px 16px 44px; color: var(--body); line-height: 1.6; }

/* Knowledge Base link card (deep technical content lives off-portal) */
.kb-card {
  display: flex; align-items: center; gap: 18px; margin-top: 22px;
  background: linear-gradient(135deg, #fff, var(--soft)); border: 1px solid #d3e6c2;
  border-radius: 12px; padding: 18px 20px;
}
.kb-card .kb-text { flex: 1; min-width: 0; }
.kb-card strong { font-family: "Poppins", sans-serif; color: var(--ink); display: block; margin-bottom: 4px; }
.kb-card p { margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.5; }
.kb-soon { flex: none; font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; background: #fff; }

/* Admin pages — session/course rows */
.sess-row {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px; margin-top: 12px;
}
.sess-row.is-ended { opacity: .65; }
.sess-code { font-family: "Poppins", sans-serif; font-weight: 700; font-size: 1.15rem; letter-spacing: .08em; color: var(--ink); flex: none; }
.sess-main { flex: 1; min-width: 220px; }
.sess-main strong { color: var(--ink); font-family: "Poppins", sans-serif; font-weight: 600; }
.sess-main small { display: block; color: var(--muted); margin-top: 2px; }
.sess-active { color: var(--deep); font-weight: 700; }
.sess-stats { display: flex; gap: 16px; flex: none; font-size: .85rem; color: var(--muted); }
.sess-stats strong { color: var(--ink); }
.q-status.is-dev { background: #eef1f0; color: var(--muted); }
.q-status.is-beta { background: #fbf0dd; color: #9a6516; }
.q-status.is-live { background: var(--soft); color: var(--deep); }

/* Course editor (admin) */
.ed-h { font-size: 1.02rem; color: var(--ink); margin: 26px 0 8px; padding-top: 18px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.ed-h:first-of-type { border-top: 0; padding-top: 4px; }
.ed-count { font-size: .72rem; font-weight: 700; background: var(--soft); color: var(--deep); border-radius: 999px; padding: 3px 10px; }
.ed-row { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.ed-row .text { flex: 1; min-width: 140px; }
.ed-select { flex: none !important; width: auto; min-width: 150px; }
.ed-item { border: 1px solid var(--line); border-radius: 12px; padding: 4px 16px 12px; margin-top: 12px; background: var(--cream); }
.ed-item .text { background: #fff; }
.ed-answer { min-height: 64px; resize: vertical; font: inherit; }
.ed-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.ed-id { font-size: .76rem; color: var(--muted); }
.ed-btns { display: flex; gap: 6px; }
.ed-mini {
  width: 30px; height: 28px; border: 1px solid var(--line); border-radius: 7px;
  background: #fff; color: var(--body); font-size: .85rem; line-height: 1;
}
.ed-mini:hover:not(:disabled) { border-color: var(--deep); color: var(--deep); }
.ed-mini:disabled { opacity: .35; cursor: default; }
.ed-mini.ed-del:hover { border-color: var(--bad); color: var(--bad); }

/* Control page — course content rows */
.content-row {
  display: flex; align-items: center; gap: 14px;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin-top: 8px;
  background: #faf9f5;
}
.content-row.is-open { background: #fff; border-color: #d3e6c2; }
.content-kind { flex: none; width: 70px; font-size: .68rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.content-title { flex: 1; min-width: 0; font-weight: 500; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.content-state { flex: none; font-size: .8rem; font-weight: 600; color: var(--muted); }
.content-row.is-open .content-state { color: var(--deep); }
select.text { background: #fff; }
