/* Celebration color is intentionally local to the completion cards. */
.passed, .unlock { --accent-glow: rgba(255, 212, 59, 0.28); }


body.page-editor { overflow-x: hidden; }

/* ===== TOP BAR ===== */
.topbar {
  height: 56px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-soft);
  display: flex;
  align-items: center;
}

.topbar .container { display: flex; align-items: center; justify-content: space-between; gap: 24px; max-width: 1360px; }

.crumb { display: flex; align-items: center; gap: 14px; font-family: var(--font-sans); font-size: 0.8rem; color: var(--soft); min-width: 0; }
.crumb a { color: var(--muted); white-space: nowrap; }
.crumb a:hover { color: var(--accent); }
.crumb b { color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb .sep { color: var(--soft); }

.strip { display: flex; gap: 6px; align-items: center; font-family: var(--font-sans); font-size: 0.72rem; color: var(--soft); }
.strip i { width: 22px; height: 6px; border-radius: 3px; background: var(--panel-2); }
.strip i.f { background: var(--blue); opacity: 0.85; }
.strip i.c { background: var(--accent-soft); border: 1px solid var(--accent-line);  }
.strip span { margin-left: 6px; }
.strip span:first-child { margin-left: 0; }

.topbar .right { display: flex; gap: 18px; align-items: center; font-family: var(--font-sans); font-size: 0.78rem; color: var(--soft); white-space: nowrap; }
.topbar .right b { color: var(--text); font-weight: 600; }

/* ===== LAYOUT ===== */
.work {
  display: grid;
  grid-template-columns: 400px 1fr;
  max-width: 1360px;
  margin: 0 auto;
  padding: 0 24px;
  height: calc(100vh - 56px);
  min-height: 520px;
}

.work > * { min-width: 0; }

/* ===== TASK PANEL ===== */
.task { padding: 36px 36px 36px 0; border-right: 1px solid var(--border-soft); overflow-y: auto; min-height: 0; }
.task .eyebrow { margin-bottom: 10px; }
.task h1 { font-family: var(--font-sans); font-size: 1.3rem; line-height: 1.4; font-weight: 600; color: var(--text-strong); margin-bottom: 16px; }
.task p { color: var(--muted); font-size: 0.95rem; line-height: 1.7; margin-bottom: 14px; }
.task code, .goal code { font-family: var(--font-sans); font-size: 0.85em; color: var(--text-strong); background: var(--panel-2); padding: 2px 6px; border-radius: 4px; }

.example { background: var(--panel); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 14px 16px; margin: 18px 0; font-family: var(--font-sans); font-size: 0.8rem; line-height: 1.7; color: var(--muted); }
.example b { display: block; color: var(--soft); font-size: 0.62rem; letter-spacing: .06em; text-transform: uppercase; margin-bottom: 6px; }
.example pre { margin: 0; white-space: pre-wrap; font-family: inherit; }
.example .o { color: var(--text); }

.goals { margin-top: 22px; border-top: 1px solid var(--border-soft); padding-top: 18px; }
.goals h4, .hint h4 { font-family: var(--font-sans); font-size: 0.62rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--soft); margin-bottom: 12px; }
.goal { display: flex; gap: 10px; align-items: flex-start; font-size: 0.88rem; color: var(--muted); padding: 6px 0; }
.goal i { width: 16px; height: 16px; border-radius: 4px; border: 1px solid var(--border); flex-shrink: 0; margin-top: 3px; display: grid; place-items: center; font-family: var(--font-sans); font-size: 10px; font-weight: 700; font-style: normal; }
.goal.ok { color: var(--text); }
.goal.ok i { background: var(--blue-soft); border-color: var(--blue-line); color: var(--blue); }
.goal.ok i::before { content: "✓"; }
.goal.bad i { border-color: var(--orange-line); color: var(--orange); }
.goal.bad i::before { content: "×"; }

.hint { margin-top: 22px; font-family: var(--font-sans); font-size: 0.8rem; color: var(--soft); }
.hint summary { cursor: pointer; color: var(--muted); list-style: none; }
.hint summary::before { content: "▸ "; }
.hint[open] summary::before { content: "▾ "; }
.hint summary:hover { color: var(--accent); }
.hint p { margin: 10px 0 0; font-family: var(--font-sans); font-size: 0.88rem; }

.task-meta { margin-top: 26px; font-family: var(--font-sans); font-size: 0.72rem; color: var(--soft); line-height: 1.8; }
.task-meta b { color: var(--accent); font-weight: 600; }

/* ===== EDITOR COLUMN ===== */
.editor-col { padding: 24px 0 24px 32px; display: flex; flex-direction: column; gap: 16px; min-height: 0; overflow-y: auto; }

.editor { background: var(--code-bg); border: 1px solid var(--border-soft); border-radius: var(--radius-lg); overflow: hidden; display: flex; flex-direction: column; flex: 1 1 auto; min-height: 260px; }
.editor.dim { flex: 0 1 260px; }
.ed-bar { display: flex; justify-content: space-between; align-items: center; background: var(--bg-soft); border-bottom: 1px solid var(--border-soft); padding: 0 14px 0 0; }
.ed-tab { padding: 11px 18px; font-family: var(--font-sans); font-size: 0.75rem; color: var(--text); border-bottom: 2px solid var(--accent); }
.ed-bar .st { font-family: var(--font-sans); font-size: 0.68rem; color: var(--soft); display: inline-flex; align-items: center; gap: 8px; }
.ed-bar .st i { width: 7px; height: 7px; border-radius: 50%; background: var(--soft); }
.ed-bar .st[data-state="ready"] i { background: var(--blue);  }
.ed-bar .st[data-state="running"] i { background: var(--blue); }
.ed-bar .st[data-state="error"] i { background: var(--orange); }

.ed-mount { flex: 1; display: flex; min-height: 0; }
.ed-mount .cm-editor { flex: 1; min-width: 0; }
.ed-mount textarea {
  flex: 1;
  background: transparent;
  color: var(--code-text);
  border: 0;
  outline: 0;
  resize: none;
  padding: 16px 20px;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  line-height: 1.85;
  tab-size: 4;
}

/* ===== RESULTS ===== */
.results { background: var(--panel); border: 1px solid var(--border-soft); border-radius: var(--radius-lg); overflow: hidden; flex: 0 0 auto; display: flex; flex-direction: column; max-height: 42%; min-height: 120px; }
.results .pane { overflow: auto; min-height: 0; }
.res-tabs { display: flex; border-bottom: 1px solid var(--border-soft); background: var(--bg-soft); }
.res-tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 16px; font-family: var(--font-sans); font-size: 0.72rem; color: var(--soft); cursor: pointer; }
.res-tabs button.on { color: var(--text); border-bottom-color: var(--muted); }
.res-tabs .ct { color: var(--soft); margin-left: 6px; }
.res-tabs .ct.ok { color: var(--blue); }
.res-tabs .ct.bad { color: var(--orange); }

.pane pre { margin: 0; padding: 16px 18px; font-family: var(--font-sans); font-size: 0.8rem; line-height: 1.7; color: var(--text); white-space: pre-wrap; word-break: break-word; max-height: 260px; overflow: auto; }
.pane pre.out-empty { color: var(--soft); }
.pane pre .err { color: var(--orange); }
.pane .out-meta { padding: 8px 18px; border-top: 1px solid var(--border-soft); font-family: var(--font-sans); font-size: 0.68rem; color: var(--soft); }

.test { display: grid; grid-template-columns: 22px 1fr auto; gap: 12px; align-items: center; padding: 11px 16px; border-bottom: 1px solid var(--border-soft); font-family: var(--font-sans); font-size: 0.8rem; color: var(--muted); }
.test:last-child { border-bottom: 0; }
.test i { width: 14px; height: 14px; border-radius: 50%; border: 1px solid var(--border); display: grid; place-items: center; font-size: 9px; font-weight: 700; font-style: normal; }
.test.ok i { background: var(--blue-soft); border-color: var(--blue-line); color: var(--blue); }
.test.ok i::before { content: "✓"; }
.test.bad i { background: var(--orange-soft); border-color: var(--orange-line); color: var(--orange); }
.test.bad i::before { content: "×"; }
.test.bad { color: var(--text); }
.test small { color: var(--soft); }
.test .diff { grid-column: 2 / 4; font-size: 0.75rem; color: var(--soft); white-space: pre-wrap; word-break: break-word; }
.test .diff b { color: var(--orange); font-weight: 500; }
.test .diff em { color: var(--blue); font-style: normal; }
.test.hid { opacity: 0.7; }
.test.hid i { border-style: dashed; }
.test .expr { white-space: pre-wrap; word-break: break-word; }
.test-note { padding: 14px 16px; font-family: var(--font-sans); font-size: 0.75rem; color: var(--soft); }

/* ===== ACTIONS ===== */
.actions { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; flex: 0 0 auto; }
.actions .keys { font-family: var(--font-sans); font-size: 0.7rem; color: var(--soft); }
.actions .keys kbd { border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; color: var(--muted); font-family: inherit; }
.actions .btns { display: flex; gap: 10px; }

/* ===== PASSED (exercise) ===== */
.passed {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, var(--accent-soft), transparent 60%), var(--panel);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-lg);
  padding: 26px 28px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: center;
  animation: rise 0.45s ease both;
  box-shadow: 0 8px 32px var(--accent-glow);
}

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.passed .eyebrow { margin-bottom: 6px; }
.passed h2 { font-family: var(--font-sans); font-size: 1.25rem; font-weight: 700; color: var(--text-strong); margin-bottom: 6px; }
.passed p { color: var(--muted); font-size: 0.9rem; }
.passed .meta { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-top: 12px; font-family: var(--font-sans); font-size: 0.75rem; color: var(--soft); }
.passed .meta b { color: var(--accent); font-weight: 700; }
.passed .side { text-align: right; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }
.xpbig { font-family: var(--font-sans); font-size: 2rem; font-weight: 700; color: var(--accent);  line-height: 1.1; }
.xpbig small { display: block; font-size: 0.6rem; letter-spacing: .06em; text-transform: uppercase; color: var(--soft);  margin-bottom: 4px; }
.pix { position: absolute; width: 6px; height: 6px; background: var(--accent-fill); opacity: 0; animation: spark 1.4s ease-out both; }
.pix:nth-child(2) { width: 4px; height: 4px; animation-delay: 0.15s; }
.pix:nth-child(3) { width: 4px; height: 4px; animation-delay: 0.3s; }
.pix:nth-child(4) { animation-delay: 0.1s; }
.pix:nth-child(5) { width: 3px; height: 3px; animation-delay: 0.25s; }
@keyframes spark { 0% { opacity: 0; transform: translateY(6px) scale(0.6); } 30% { opacity: 0.8; } 100% { opacity: 0.35; transform: translateY(-6px) scale(1); } }

.nextbar { display: flex; align-items: center; gap: 14px; font-family: var(--font-sans); font-size: 0.72rem; color: var(--soft); }
.nextbar .bar { flex: 1; height: 4px; border-radius: 2px; background: var(--panel-2); overflow: hidden; }
.nextbar .bar i { display: block; height: 100%; width: 0; background: var(--accent-fill); transition: width 6s linear; }
.nextbar .bar i.go { width: 100%; }

/* ===== UNLOCK (challenge) ===== */
.unlock {
  background: linear-gradient(135deg, var(--accent-soft), var(--blue-soft) 55%, transparent), var(--panel);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-lg);
  padding: 32px 34px;
  position: relative;
  overflow: hidden;
  animation: rise 0.5s ease both;
  box-shadow: 0 8px 32px var(--accent-glow);
}
.unlock > * { position: relative; }
.unlock h2 { font-family: var(--font-sans); font-size: 1.5rem; line-height: 1.3; color: var(--text-strong); margin: 6px 0 10px; }
.unlock h2 .c-accent {  }
.unlock p { color: var(--muted); font-size: 0.92rem; max-width: 52ch; }
.unlock .row2 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 22px 0; }
.unlock .cell { background: var(--panel-alpha); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 14px 16px; }
.unlock .cell small { font-family: var(--font-sans); font-size: 0.6rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--soft); display: block; margin-bottom: 4px; }
.unlock .cell b { font-family: var(--font-sans); font-size: 1.2rem; font-weight: 700; color: var(--text-strong); }
.unlock .cell span { font-family: var(--font-sans); font-size: 0.72rem; color: var(--accent); display: block; }
.unlock .badge { display: inline-flex; align-items: center; gap: 10px; background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: 999px; padding: 6px 14px 6px 8px; font-family: var(--font-sans); font-size: 0.72rem; color: var(--accent); }
.unlock .badge i { width: 22px; height: 22px; border-radius: 50%; background: var(--accent-fill); color: var(--on-accent); display: grid; place-items: center; font-size: 12px; font-style: normal; }
.unlock .nextmod { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; background: var(--panel-alpha); border: 1px dashed var(--accent-line); border-radius: var(--radius); padding: 16px 18px; margin-top: 6px; }
.unlock .nextmod h3 { font-family: var(--font-sans); font-size: 0.95rem; font-weight: 700; color: var(--text-strong); }
.unlock .nextmod p { font-size: 0.82rem; margin-top: 2px; }
.unlock .nextmod .btns { display: flex; gap: 10px; }

.editor.dim { opacity: 0.55; }

/* ===== GATE / NOTICE ===== */
.notice-wrap { max-width: 720px; margin: 0 auto; padding: 72px 24px; }
.notice-wrap h1 { font-family: var(--font-sans);  line-height: 1.15; color: var(--text-strong); margin-bottom: 14px; }
.notice-wrap h1 .c-accent {  }
.notice-wrap .btn-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 24px; }
.notice-card { padding: 28px 30px; }
.notice-card p { color: var(--muted); font-size: 0.95rem; }

/* ===== TOAST ===== */
.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); background: var(--panel); border: 1px solid var(--accent-line); color: var(--text); font-family: var(--font-sans); font-size: 0.78rem; padding: 10px 16px; border-radius: 6px; opacity: 0; pointer-events: none; transition: color .15s, background .15s, border-color .15s; z-index: 200; max-width: calc(100vw - 48px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ===== RESPONSIVE ===== */
@media (max-width: 1100px) {
  .work { grid-template-columns: 340px 1fr; }
}

@media (max-width: 900px) {
  .work { grid-template-columns: 1fr; }
  .task { padding: 28px 0 8px; border-right: 0; border-bottom: 1px solid var(--border-soft); }
  .editor-col { padding: 20px 0 24px; }
  .strip { display: none; }
  .crumb .sep:nth-of-type(1), .crumb > span:not(.sep) { display: none; }
  .passed { grid-template-columns: 1fr;
  box-shadow: 0 8px 32px var(--accent-glow);
}
  .passed .side { align-items: flex-start; text-align: left; }
  .unlock .row2 { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .topbar .right { display: none; }
  .actions .keys { display: none; }
  .actions .btns { width: 100%; }
  .actions .btns .btn { flex: 1; }
  .editor { min-height: 300px; }
}

@media (prefers-reduced-motion: reduce) {
  .passed, .unlock, .pix { animation: none; }
  .pix { opacity: 0.4; }
  .nextbar .bar i { transition: width 6s linear; }
}

.task code, .goal code, .example pre, .ed-tab, .ed-mount textarea, .pane pre, .test .expr, .test .diff, .actions .keys, .actions kbd, .xpbig, .strip, .task-meta b, .unlock .cell b { font-family: var(--font-mono); }
.task p { max-width: 56ch; }
.ed-mount textarea { min-width: 0; }
.test > *, .topbar .container > * { min-width: 0; }
@media (max-width: 1000px) { .work { grid-template-columns: minmax(0, 1fr); height: auto; min-height: calc(100vh - 56px); } .task { padding: 28px 0 8px; border-right: 0; border-bottom: 1px solid var(--border-soft); overflow: visible; } .editor-col { padding: 20px 0 24px; overflow: visible; } .editor, .editor.dim { flex: none; min-height: 380px; } .results { max-height: none; } }
@media (max-width: 640px) { .task h1, .notice-wrap h1 { font-size: 2rem; line-height: 1.15; } .actions .btns { flex-wrap: wrap; } .actions .btns .btn { padding: 0 12px; } }
