/* Kelcy HQ · shared skin
   Home = pastel purple. The Lab (science) = mint + teal, theme-lab on body.
   Subject accents: bio green, chem purple, phys amber. */

:root {
  --bg: #f6f1fa;
  --card: #ffffff;
  --ink: #3a3550;
  --navy: #4a3f78;
  --accent: #8a63d2;
  --accent-soft: #e9dff8;
  --rose: #c15b83;
  --amber: #e0973c;
  --teal: #2a8f88;
  --green: #4f9d72;
  --line: #e5dced;
  --shadow: 0 4px 14px rgba(74, 63, 120, 0.10);
  --radius: 18px;
}

body.theme-lab {
  --bg: #edf6f4;
  --accent: #2a8f88;
  --accent-soft: #d9efec;
  --navy: #2e5c66;
  --line: #d8e9e6;
  --shadow: 0 4px 14px rgba(46, 92, 102, 0.10);
}

.sub-bio  { --subject: #4f9d72; --subject-soft: #e2f2e8; }
.sub-chem { --subject: #8a63d2; --subject-soft: #ece2fa; }
.sub-phys { --subject: #e0973c; --subject-soft: #faecd9; }

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Nunito', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.5;
}

h1, h2, h3, .display { font-family: 'Baloo 2', 'Nunito', sans-serif; color: var(--navy); }

.wrap { max-width: 860px; margin: 0 auto; padding: 14px 14px 80px; }

/* Top bar */
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 2px; margin-bottom: 10px;
}
.topbar .back {
  text-decoration: none; font-weight: 800; color: var(--navy);
  background: var(--card); border: 2px solid var(--line);
  border-radius: 12px; padding: 8px 14px; min-height: 44px;
  display: inline-flex; align-items: center;
}
.topbar h1 { font-size: 1.35rem; flex: 1; line-height: 1.2; }
.chip {
  background: var(--card); border: 2px solid var(--line); border-radius: 999px;
  padding: 6px 12px; font-weight: 800; font-size: 0.85rem; color: var(--navy);
  white-space: nowrap;
}
.chip.hot { border-color: var(--amber); background: #fdf3e3; }

/* Cards and tiles */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 14px;
}
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tile {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 14px; text-decoration: none; color: var(--ink);
  display: flex; flex-direction: column; gap: 6px; min-height: 110px;
  border: 2px solid transparent; transition: transform 0.12s ease;
}
.tile:active { transform: scale(0.97); }
.tile .emoji { font-size: 1.9rem; }
.tile .t-name { font-family: 'Baloo 2', sans-serif; font-weight: 700; color: var(--navy); font-size: 1.05rem; line-height: 1.2; }
.tile .t-sub { font-size: 0.82rem; color: #7d7593; }
.tile.accent { background: linear-gradient(135deg, var(--accent-soft), var(--card)); border-color: var(--accent-soft); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: 'Baloo 2', sans-serif; font-weight: 700; font-size: 1.05rem;
  background: var(--accent); color: #fff; border: none; border-radius: 14px;
  padding: 12px 22px; min-height: 48px; cursor: pointer; text-decoration: none;
  box-shadow: var(--shadow);
}
.btn:active { transform: scale(0.97); }
.btn.ghost { background: var(--card); color: var(--navy); border: 2px solid var(--line); }
.btn.subject { background: var(--subject, var(--accent)); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: default; }

/* Answer options: big thumb targets */
.opts { display: grid; gap: 10px; margin-top: 14px; }
.opt {
  background: var(--card); border: 2px solid var(--line); border-radius: 14px;
  padding: 14px 16px; font-size: 1.02rem; font-weight: 700; color: var(--ink);
  text-align: left; cursor: pointer; min-height: 52px; width: 100%;
  transition: transform 0.1s ease;
}
.opt:active { transform: scale(0.98); }
.opt.right { border-color: var(--green); background: #e2f2e8; }
.opt.notyet { border-color: var(--rose); background: #f9e6ee; }
.opt.dim { opacity: 0.5; }

/* Feedback strip */
.feedback {
  border-radius: 14px; padding: 12px 16px; margin-top: 12px;
  font-weight: 700; display: none;
}
.feedback.show { display: block; animation: pop 0.25s ease; }
.feedback.good { background: #e2f2e8; color: #2d6647; }
.feedback.oops { background: #f9e6ee; color: #93446a; }
.feedback .why { display: block; font-weight: 600; font-size: 0.92rem; margin-top: 4px; opacity: 0.9; }

@keyframes pop { from { transform: scale(0.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.shake { animation: shake 0.3s ease; }

/* Progress bar */
.progress { height: 10px; background: var(--accent-soft); border-radius: 999px; overflow: hidden; margin: 8px 0 4px; }
.progress .fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.3s ease; width: 0; }

/* Status badges */
.status { font-size: 0.78rem; font-weight: 800; border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.status.new { background: #eeeaf2; color: #857c99; }
.status.cooking { background: #fdf3e3; color: #a96a15; }
.status.solid { background: #d9efec; color: #1e6e67; }
.status.mastered { background: #ece2fa; color: #6a3fb5; }

/* Topic rows */
.topic-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 0;
  border-bottom: 1px dashed var(--line); flex-wrap: wrap;
}
.topic-row:last-child { border-bottom: none; }
.topic-row .name { flex: 1; font-weight: 800; color: var(--navy); min-width: 140px; }
.topic-row .mini {
  font-size: 0.85rem; font-weight: 800; padding: 8px 14px; min-height: 40px;
  border-radius: 10px; text-decoration: none;
  background: var(--subject-soft, var(--accent-soft)); color: var(--navy);
  display: inline-flex; align-items: center;
}

.section-head {
  display: flex; align-items: center; gap: 10px; margin: 20px 0 10px;
}
.section-head h2 { font-size: 1.2rem; }
.section-head .rule { flex: 1; height: 3px; border-radius: 3px; background: var(--subject, var(--accent-soft)); opacity: 0.35; }

/* Flashcard */
.flash-stage { perspective: 1000px; margin: 14px 0; }
.flash-card {
  position: relative; width: 100%; min-height: 230px; cursor: pointer;
  transform-style: preserve-3d; transition: transform 0.45s ease;
}
.flash-card.flipped { transform: rotateY(180deg); }
.flash-face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px; text-align: center; gap: 8px;
}
.flash-face.back { transform: rotateY(180deg); background: linear-gradient(135deg, var(--accent-soft), var(--card)); }
.flash-face .big { font-size: 1.25rem; font-weight: 800; color: var(--navy); }
.flash-face .hint { font-size: 0.8rem; color: #9a90ad; font-weight: 700; }

.boxes { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin: 10px 0; }
.box {
  background: var(--card); border: 2px solid var(--line); border-radius: 12px;
  text-align: center; padding: 8px 4px;
}
.box .n { font-family: 'Baloo 2', sans-serif; font-size: 1.2rem; font-weight: 700; color: var(--navy); }
.box .l { font-size: 0.68rem; font-weight: 800; color: #9a90ad; }
.box.lit { border-color: var(--accent); background: var(--accent-soft); }

/* Sort buckets */
.buckets { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.buckets.three { grid-template-columns: 1fr 1fr 1fr; }
.bucket {
  min-height: 84px; border-radius: 14px; border: 3px dashed var(--line);
  background: var(--card); font-family: 'Baloo 2', sans-serif; font-weight: 700;
  font-size: 1rem; color: var(--navy); cursor: pointer; padding: 10px;
}
.bucket:active { transform: scale(0.97); }

.sort-item {
  background: var(--card); border-radius: 14px; box-shadow: var(--shadow);
  padding: 22px 16px; text-align: center; font-size: 1.15rem; font-weight: 800;
  color: var(--navy); margin-top: 6px; min-height: 76px;
  display: flex; align-items: center; justify-content: center;
}

/* Order chips */
.chips { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.chip-btn {
  background: var(--card); border: 2px solid var(--line); border-radius: 12px;
  padding: 12px 16px; font-weight: 800; font-size: 0.98rem; color: var(--ink);
  cursor: pointer; min-height: 48px;
}
.chip-btn.placed { opacity: 0.35; pointer-events: none; }
.chip-btn.selected { border-color: var(--accent); background: var(--accent-soft); }
.seq { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.seq .slot {
  border: 2px dashed var(--line); border-radius: 12px; padding: 12px 14px;
  min-height: 48px; font-weight: 800; color: #b9b0c9; background: rgba(255,255,255,0.5);
}
.seq .slot.filled { border-style: solid; border-color: var(--green); background: #e2f2e8; color: #2d6647; }

/* Label hotspots */
.label-stage { position: relative; margin-top: 10px; }
.label-stage svg { width: 100%; height: auto; display: block; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }
.hotspot { cursor: pointer; }
.hotspot circle { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 2.5; }
.hotspot text { font-family: 'Baloo 2', sans-serif; font-weight: 700; fill: var(--navy); font-size: 15px; }
.hotspot.done circle { fill: #e2f2e8; stroke: var(--green); }
.hotspot.wrong circle { stroke: var(--rose); fill: #f9e6ee; }

/* Balance */
.equation { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; margin: 16px 0; }
.species { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.species .formula { font-family: 'Baloo 2', sans-serif; font-size: 1.3rem; font-weight: 700; color: var(--navy); }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button {
  width: 40px; height: 40px; border-radius: 10px; border: 2px solid var(--line);
  background: var(--card); font-size: 1.2rem; font-weight: 800; color: var(--navy); cursor: pointer;
}
.stepper .co { font-family: 'Baloo 2', sans-serif; font-size: 1.4rem; font-weight: 700; width: 34px; text-align: center; color: var(--accent); }
.plus, .arrow { font-size: 1.3rem; font-weight: 800; color: #9a90ad; padding: 0 2px; }
.tally { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.tally .side { background: var(--card); border-radius: 12px; padding: 10px 14px; border: 2px solid var(--line); }
.tally h4 { font-size: 0.85rem; color: #9a90ad; margin-bottom: 4px; }
.tally .el { display: flex; justify-content: space-between; font-weight: 800; font-size: 0.95rem; }
.tally .el.ok { color: #2d6647; }
.tally .el.no { color: #93446a; }

/* Big score / timer */
.big-num { font-family: 'Baloo 2', sans-serif; font-size: 3rem; font-weight: 700; color: var(--navy); text-align: center; line-height: 1; }
.timer-bar { height: 14px; border-radius: 999px; background: var(--accent-soft); overflow: hidden; margin: 10px 0; }
.timer-bar .fill { height: 100%; background: var(--amber); width: 100%; border-radius: 999px; }

.center { text-align: center; }
.muted { color: #8d84a3; font-size: 0.9rem; }
.mt { margin-top: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row .grow { flex: 1; }

/* Round summary */
.summary-emoji { font-size: 3rem; text-align: center; }

input[type="text"], textarea, select {
  font-family: 'Nunito', sans-serif; font-size: 1rem; font-weight: 700; color: var(--ink);
  border: 2px solid var(--line); border-radius: 12px; padding: 12px 14px; width: 100%;
  background: var(--card);
}

@media (max-width: 420px) {
  .tile-grid { grid-template-columns: 1fr 1fr; }
  .topbar h1 { font-size: 1.15rem; }
}
