* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #1c2733; background: #f4f6f8;
}
.screen { height: 100%; }
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; }

/* ---------- login / done ---------- */
#login, #done { display: flex; align-items: center; justify-content: center; }
.logincard {
  background: #fff; border: 1px solid #dde3e9; border-radius: 10px;
  max-width: 560px; margin: 16px; padding: 28px 32px; box-shadow: 0 2px 12px rgba(0,0,0,.06);
}
.logincard h1 { font-size: 22px; margin: 0 0 14px; }
.logincard p { color: #3b4a59; }
.logincard label { display: block; margin: 18px 0 6px; font-weight: 600; }
.logincard input {
  width: 100%; padding: 10px 12px; font-size: 16px;
  border: 1px solid #b9c4cf; border-radius: 6px;
}
#codeError { color: #b02a1e; font-size: 13.5px; margin-top: 8px; }
.primary {
  background: #1769aa; color: #fff; border: none; border-radius: 6px;
  padding: 10px 18px; font-size: 16px; margin-top: 16px;
}
.primary:disabled { background: #a8b6c2; cursor: default; }
.primary:not(:disabled):hover { background: #125285; }

/* ---------- app layout ---------- */
#app { display: flex; flex-direction: column; }
header {
  display: flex; align-items: center; gap: 16px;
  background: #fff; border-bottom: 1px solid #dde3e9; padding: 8px 14px;
}
#caseLabel { font-weight: 700; font-size: 16px; white-space: nowrap; }
#progresswrap {
  flex: 1; height: 18px; background: #e4e9ee; border-radius: 9px;
  position: relative; overflow: hidden; max-width: 480px;
}
#progressfill { height: 100%; width: 0; background: #7fb3d5; transition: width .3s; }
#progresstext {
  position: absolute; inset: 0; text-align: center; font-size: 12px;
  line-height: 18px; color: #2c3e50;
}
#saveState { font-size: 13px; color: #1e7a3c; margin-left: auto; white-space: nowrap; }
#saveState.saving { color: #8a6d00; }
#saveState.error { color: #b02a1e; font-weight: 700; }
#exportBtn, #tutorialBtn { border: 1px solid #b9c4cf; background: #fff; border-radius: 6px; padding: 5px 12px; white-space: nowrap; }
#exportBtn:hover, #tutorialBtn:hover { border-color: #1769aa; color: #125285; }

main { flex: 1; display: flex; min-height: 0; }

/* ---------- left column: report being judged + viewer ---------- */
#leftcol { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#reportBar {
  background: #fffdf5; border-bottom: 2px solid #e6d9a8;
  padding: 8px 16px 10px; max-height: 32vh; overflow-y: auto;
}
#reportBarHead { font-weight: 700; font-size: 14px; color: #4a5a68; margin-bottom: 3px; }
#reportBarText { font-size: 15.5px; line-height: 1.55; color: #22313f; }

/* ---------- viewer ---------- */
#viewerwrap { flex: 1; position: relative; background: #2b2f33; min-width: 0; min-height: 0; }
#viewer { position: absolute; inset: 0; }
#viewerLoading {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  color: #cfd8e0; font-size: 15px; pointer-events: none;
}
#osdButtons { position: absolute; top: 12px; left: 12px; display: flex; flex-direction: column; gap: 6px; }
#osdButtons button {
  width: 40px; height: 40px; font-size: 20px; border: none; border-radius: 6px;
  background: rgba(255,255,255,.92); color: #1c2733; box-shadow: 0 1px 4px rgba(0,0,0,.35);
}
#osdButtons button:hover { background: #fff; }
#magLabel {
  position: absolute; bottom: 14px; right: 12px; background: rgba(0,0,0,.55);
  color: #fff; font-size: 13px; padding: 3px 9px; border-radius: 5px; pointer-events: none;
}
#scalebar {
  position: absolute; bottom: 14px; left: 12px; color: #fff; font-size: 12px;
  background: rgba(0,0,0,.45); padding: 4px 8px; border-radius: 5px; pointer-events: none;
}
#scalebarLine { height: 4px; background: #fff; border: 1px solid #333; margin-bottom: 2px; }

/* ---------- side panel ---------- */
#panel {
  width: 470px; max-width: 48%; background: #fff; border-left: 1px solid #dde3e9;
  overflow-y: auto; padding: 0 16px 20px; display: flex; flex-direction: column; gap: 10px;
}
details { border: 1px solid #dde3e9; border-radius: 8px; padding: 8px 12px; background: #fafbfc; }
details summary { cursor: pointer; font-weight: 600; color: #2c3e50; }
details .hint { font-weight: 400; color: #7a8894; font-size: 13px; }
.guidebody h4 { margin: 10px 0 4px; font-size: 14px; }
.guidebody ul { margin: 2px 0 8px; padding-left: 18px; }
.guidebody li { margin: 3px 0; font-size: 13.5px; color: #3b4a59; }
#refbox { border: 1px solid #74b784; background: #f0f8f2; }
#refbox summary { color: #1e7a3c; }
#refbox .hint { color: #5a8a68; }
#refbox pre {
  white-space: pre-wrap; font-family: inherit; font-size: 13.5px; line-height: 1.45;
  margin: 8px 0 2px; color: #24422e;
}

/* ---------- stepper (stays pinned while the questions scroll) ---------- */
#stepper {
  display: flex; flex-wrap: wrap; gap: 6px;
  position: sticky; top: 0; z-index: 5; background: #fff;
  padding: 12px 0 8px; border-bottom: 1px solid #eef2f6;
}
.step {
  border: 1px solid #ccd6df; background: #fff; border-radius: 15px;
  padding: 4px 12px; font-size: 13px; color: #4a5a68;
}
.step.done { border-color: #74b784; color: #1e7a3c; background: #f0f8f2; }
.step.cur { background: #1769aa; border-color: #1769aa; color: #fff; font-weight: 600; }

/* ---------- slide-first stage ---------- */
.slidestage { border: 1px solid #dde3e9; border-radius: 10px; padding: 14px 16px; background: #fafbfc; }
.slidestage h3 { margin: 0 0 8px; font-size: 17px; }
.slidestage p { margin: 6px 0; color: #3b4a59; }
.muted { color: #7a8894 !important; font-size: 13.5px; }
.notewrap { font-size: 13px; color: #4a5a68; display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.notewrap input { flex: 1; padding: 6px 8px; font-size: 13.5px; border: 1px solid #ccd6df; border-radius: 6px; }

/* ---------- report card ---------- */
.card { border: 1px solid #ccd6df; border-radius: 10px; overflow: hidden; }
.card.complete { border-color: #74b784; }
.cardhead {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  background: #eef2f6; font-weight: 700;
}
.card.complete .cardhead { background: #e4f2e7; }
.counthint { font-weight: 400; color: #7a8894; font-size: 13px; }
.cardhead .tick { margin-left: auto; color: #1e7a3c; visibility: hidden; font-size: 13.5px; }
.card.complete .tick { visibility: visible; }
.reporttext {
  padding: 12px 14px; font-size: 15px; line-height: 1.55; color: #22313f;
  border-bottom: 1px dashed #dde3e9; background: #fffdf5;
}
.claimintro { display: block; font-size: 12.5px; color: #7a8894; margin-bottom: 3px; }
.claimquote { font-size: 16px; font-weight: 600; color: #22313f; }
.q { padding: 10px 12px 4px; }
.qlabel { font-size: 14px; font-weight: 600; color: #2c3e50; margin-bottom: 7px; }
.qhint { font-weight: 400; color: #7a8894; font-size: 12.5px; }
.q.pulse .qlabel { color: #b02a1e; }

.opt {
  display: block; width: 100%; text-align: left; margin-bottom: 6px;
  border: 1px solid #ccd6df; background: #fff; border-radius: 8px; padding: 7px 10px;
}
.opt:hover { border-color: #1769aa; }
.opt.sel { border-color: #1769aa; background: #eaf3fa; box-shadow: inset 3px 0 0 #1769aa; }
.optanchor { display: block; font-weight: 600; font-size: 14px; color: #1c2733; }
.optdesc { display: block; font-size: 12.5px; color: #5d6d7b; margin-top: 1px; }
.opt.sel .optanchor { color: #125285; }
.optex { display: block; font-size: 12.5px; color: #7a8894; font-style: italic; margin-top: 1px; }

.comment input {
  width: 100%; padding: 6px 8px; font-size: 13.5px;
  border: 1px solid #ccd6df; border-radius: 6px; margin-bottom: 8px;
}

#navbtns { display: flex; justify-content: space-between; gap: 10px; margin-top: 2px; }
#navbtns button { border-radius: 6px; padding: 9px 16px; font-size: 15px; border: 1px solid #b9c4cf; background: #fff; }
#navbtns .primary { background: #1769aa; color: #fff; border: none; margin-top: 0; }
#navbtns .primary:hover { background: #125285; }

/* ---------- part 1 -> part 2 interlude ---------- */
#interlude { display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; }
#interlude[hidden] { display: none !important; }
.interludecard { position: relative; z-index: 2; text-align: center; max-width: 640px; }
.bigparty { font-size: 56px; margin-bottom: 4px; }
.bigq { font-size: 19px; font-weight: 700; color: #125285; margin: 18px 0; line-height: 1.5; }
.contenders { display: block; font-size: 14px; font-weight: 600; color: #4a5a68; margin-top: 8px; }
#confetti { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
#confetti span {
  position: absolute; top: -14px; width: 9px; height: 14px; opacity: .9;
  animation: confetti-fall linear infinite;
}
@keyframes confetti-fall {
  0%   { transform: translateY(-5vh) rotate(0deg); }
  100% { transform: translateY(105vh) rotate(720deg); }
}

/* ---------- first-time guided tour ---------- */
#tourOverlay { position: fixed; inset: 0; z-index: 100; }
#tourHi {
  position: fixed; border-radius: 10px; pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(15, 25, 35, .55); outline: 2px solid #7fb3d5;
  transition: left .25s, top .25s, width .25s, height .25s;
}
#tourCard {
  position: fixed; background: #fff; border-radius: 10px; padding: 14px 16px;
  max-width: 340px; box-shadow: 0 4px 20px rgba(0,0,0,.35);
}
#tourCard h4 { margin: 0 0 6px; font-size: 15px; }
#tourCard p { margin: 0 0 12px; font-size: 13.5px; color: #3b4a59; line-height: 1.5; }
#tourBtns { display: flex; align-items: center; gap: 10px; }
#tourCount { color: #7a8894; font-size: 12px; margin-right: auto; }
#tourSkip { border: none; background: none; color: #7a8894; text-decoration: underline; padding: 0; }
#tourBtns .primary { margin-top: 0; padding: 7px 14px; font-size: 14px; }

@media (max-width: 900px) {
  main { flex-direction: column; }
  #panel { width: 100%; max-width: none; border-left: none; border-top: 1px solid #dde3e9; }
  #leftcol { min-height: 60vh; }
  #viewerwrap { min-height: 40vh; }
}
