/* ============================================================
   MySQL Learning Lab — Components
   Terminal · Designer · Challenges · Achievements · Admin
   ============================================================ */

/* ---------- Syntax tokens (shared) ---------- */
.tok-kw { color: var(--kw); font-weight: 600; }
.tok-str { color: var(--str); }
.tok-num { color: var(--num); }
.tok-comment { color: var(--comment); font-style: italic; }
.tok-punct { color: var(--text-dim); }

/* ============================================================
   TERMINAL
   ============================================================ */
.term {
  background: var(--bg-3); border: 1px solid var(--border-2); border-radius: var(--radius);
  overflow: hidden; box-shadow: 0 8px 28px -14px rgba(0,0,0,.5);
}
.term-toolbar {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  background: var(--bg-2); border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.term-run {
  font-family: var(--sans); font-weight: 700; font-size: .85rem; padding: 7px 16px;
  background: linear-gradient(135deg, var(--accent), #ff8c42); color: #1a1206;
  border: none; border-radius: 8px; cursor: pointer; transition: .15s;
}
.term-run:hover { filter: brightness(1.08); transform: translateY(-1px); }
.term-clear, .term-save, .term-reset-data {
  font-family: var(--sans); font-size: .82rem; font-weight: 600; padding: 7px 13px;
  background: var(--panel-2); color: var(--text-dim); border: 1px solid var(--border-2);
  border-radius: 8px; cursor: pointer; transition: .15s;
}
.term-clear:hover, .term-save:hover, .term-reset-data:hover { color: var(--text); border-color: var(--accent-2); }
.term-dataset {
  font-family: var(--sans); font-size: .82rem; padding: 7px 10px; background: var(--panel-2);
  color: var(--text); border: 1px solid var(--border-2); border-radius: 8px; cursor: pointer;
}
.term-status { margin-left: auto; font-size: .82rem; font-weight: 600; color: var(--text-faint); }
.term-status.ok { color: var(--ok); } .term-status.err { color: var(--err); }

.term-editor-wrap { position: relative; min-height: 130px; }
.term-highlight, .term-input {
  margin: 0; padding: 16px 18px; font-family: var(--mono); font-size: .92rem; line-height: 1.65;
  white-space: pre-wrap; word-break: break-word; border: 0; tab-size: 2;
}
.term-highlight {
  position: absolute; inset: 0; pointer-events: none; overflow: auto; color: var(--text);
  background: transparent;
}
.term-highlight code { font-family: var(--mono); }
.term-input {
  position: relative; width: 100%; min-height: 130px; resize: vertical;
  background: transparent; color: transparent; caret-color: var(--accent);
  outline: none; display: block;
}
.term-input::selection { background: rgba(122,162,255,.3); }

.term-suggest {
  display: none; position: absolute; z-index: 30; min-width: 160px; max-height: 220px; overflow-y: auto;
  background: var(--panel-2); border: 1px solid var(--border-2); border-radius: 9px; box-shadow: var(--shadow);
  left: 18px; top: 46px;
}
.sg-item { padding: 7px 14px; font-family: var(--mono); font-size: .85rem; color: var(--text-dim); cursor: pointer; }
.sg-item.active, .sg-item:hover { background: rgba(255,180,84,.14); color: var(--accent); }

.term-result { border-top: 1px solid var(--border); max-height: 340px; overflow: auto; }
.res-meta { padding: 9px 16px; font-size: .8rem; color: var(--text-faint); background: var(--bg-2); }
.res-time { color: var(--accent-2); margin-left: 8px; }
.res-ok { padding: 14px 18px; color: var(--ok); font-size: .9rem; font-weight: 600; }
.res-err { padding: 14px 18px; color: var(--err); font-size: .9rem; font-weight: 600; background: rgba(248,113,113,.06); }
.res-note { padding: 14px 18px; color: var(--ok, #34d399); font-size: .9rem; font-weight: 600; background: rgba(52,211,153,.08); }
.res-scroll { overflow-x: auto; }
.res-tbl { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: .85rem; }
.res-tbl th {
  position: sticky; top: 0; text-align: left; padding: 9px 16px; background: var(--bg-2);
  color: var(--accent-2); font-weight: 700; border-bottom: 1px solid var(--border-2); white-space: nowrap;
}
.res-tbl td { padding: 8px 16px; border-bottom: 1px solid var(--border); color: var(--text); white-space: nowrap; }
.res-tbl tr:hover td { background: rgba(255,255,255,.02); }
.cell-null { color: var(--text-faint); font-style: italic; }

.term-compact .term-editor-wrap, .term-compact .term-input, .term-compact .term-highlight { min-height: 84px; }
.term-compact .term-result { max-height: 240px; }

.term-examples { margin-top: 18px; display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.term-examples span { color: var(--text-faint); font-size: .85rem; }
.ex-chip {
  font-family: var(--mono); font-size: .78rem; padding: 6px 12px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 20px; color: var(--text-dim); cursor: pointer; transition: .15s;
}
.ex-chip:hover { border-color: var(--accent-2); color: var(--accent-2); }

/* ============================================================
   DESIGNER
   ============================================================ */
.dz { background: var(--bg-3); border: 1px solid var(--border-2); border-radius: var(--radius); overflow: hidden; }
.dz-toolbar { display: flex; align-items: center; gap: 8px; padding: 11px 14px; background: var(--bg-2); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.dz-toolbar button {
  font-family: var(--sans); font-size: .82rem; font-weight: 600; padding: 7px 14px;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border-2); border-radius: 8px; cursor: pointer; transition: .15s;
}
.dz-toolbar button:hover { border-color: var(--accent-2); color: var(--accent-2); }
.dz-toolbar .dz-add { background: linear-gradient(135deg, var(--accent), #ff8c42); color: #1a1206; border: none; }
.dz-hint { color: var(--text-faint); font-size: .78rem; margin-left: auto; }
.dz-canvas { position: relative; height: 520px; overflow: auto; background:
  radial-gradient(circle, var(--border) 1px, transparent 1px); background-size: 22px 22px; }
.dz-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }
.dz-rel { fill: none; stroke: var(--accent-2); stroke-width: 2; stroke-dasharray: 5 4; opacity: .7; }

.dz-table {
  position: absolute; z-index: 2; width: 290px; background: var(--panel); border: 1px solid var(--border-2);
  border-radius: 11px; box-shadow: var(--shadow); overflow: hidden;
}
.dz-table-h { display: flex; align-items: center; gap: 6px; padding: 9px 10px; background: var(--bg-2); border-bottom: 1px solid var(--border); cursor: grab; }
.dz-table-h:active { cursor: grabbing; }
.dz-tname { flex: 1; background: none; border: none; color: var(--accent); font-family: var(--mono); font-weight: 700; font-size: .9rem; outline: none; min-width: 0; }
.dz-tdel { background: none; border: none; color: var(--text-faint); cursor: pointer; font-size: .8rem; }
.dz-tdel:hover { color: var(--err); }
.dz-cols { padding: 6px; }
.dz-col { display: flex; align-items: center; gap: 4px; margin-bottom: 4px; }
.dz-cname { flex: 1 1 70px; min-width: 0; background: var(--bg-3); border: 1px solid var(--border); border-radius: 5px; color: var(--text); font-family: var(--mono); font-size: .74rem; padding: 4px 6px; outline: none; }
.dz-ctype { flex: 1 1 90px; min-width: 0; background: var(--bg-3); border: 1px solid var(--border); border-radius: 5px; color: var(--text-dim); font-size: .72rem; padding: 4px 3px; }
.dz-pk, .dz-nn { flex: 0 0 auto; font-size: .62rem; font-weight: 700; padding: 3px 5px; background: var(--bg-3); border: 1px solid var(--border); border-radius: 5px; color: var(--text-faint); cursor: pointer; }
.dz-pk.on { background: var(--accent); color: #1a1206; border-color: var(--accent); }
.dz-nn.on { background: var(--accent-3); color: #0a0d14; border-color: var(--accent-3); }
.dz-cdel { flex: 0 0 auto; background: none; border: none; color: var(--text-faint); cursor: pointer; font-size: .72rem; }
.dz-cdel:hover { color: var(--err); }
.dz-addcol { width: calc(100% - 12px); margin: 0 6px 8px; padding: 6px; background: var(--bg-3); border: 1px dashed var(--border-2); border-radius: 6px; color: var(--text-dim); font-size: .75rem; cursor: pointer; }
.dz-addcol:hover { border-color: var(--accent-2); color: var(--accent-2); }
.dz-ddl-out { padding: 16px; border-top: 1px solid var(--border); background: var(--bg-2); }
.dz-ddl-out pre { font-family: var(--mono); font-size: .82rem; color: var(--str); white-space: pre-wrap; line-height: 1.6; }

/* ============================================================
   CHALLENGES
   ============================================================ */
.ch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.ch-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; transition: .2s; }
.ch-card:hover { transform: translateY(-3px); border-color: var(--accent-2); box-shadow: var(--shadow); }
.ch-card.solved { border-color: rgba(74,222,128,.35); }
.ch-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.ch-level { font-size: .72rem; font-weight: 700; padding: 3px 10px; border-radius: 20px; background: var(--bg-3); color: var(--accent-2); }
.ch-tick { color: var(--ok); }
.ch-card h3 { font-family: var(--display); font-size: 1.08rem; margin-bottom: 7px; }
.ch-card p { color: var(--text-dim); font-size: .88rem; margin-bottom: 12px; }
.ch-ds { font-size: .78rem; color: var(--text-faint); }

.ch-detail { max-width: 880px; }
.chd-head { margin: 16px 0; }
.chd-head h1 { font-family: var(--display); font-size: 1.7rem; margin-top: 8px; }
.chd-prompt { font-size: 1.05rem; background: var(--panel); border-left: 3px solid var(--accent); padding: 16px 20px; border-radius: 10px; margin-bottom: 14px; }
.chd-meta { color: var(--text-dim); font-size: .9rem; margin-bottom: 14px; }
.chd-hint-btn { background: none; border: 1px solid var(--border-2); color: var(--accent-2); padding: 4px 12px; border-radius: 7px; cursor: pointer; font-family: var(--sans); font-size: .82rem; }
.chd-hint { background: rgba(56,214,196,.08); border-radius: 9px; padding: 14px 18px; margin-bottom: 16px; color: var(--text-dim); font-size: .92rem; }
.chd-term { margin-bottom: 14px; }
.chd-status { min-height: 28px; margin-bottom: 16px; }
.chd-pass { color: var(--ok); font-weight: 700; padding: 12px 16px; background: rgba(74,222,128,.1); border-radius: 9px; }
.chd-fail { color: var(--err); font-weight: 600; padding: 12px 16px; background: rgba(248,113,113,.08); border-radius: 9px; }
.chd-sol { margin-top: 10px; }
.chd-sol summary { cursor: pointer; color: var(--text-dim); font-size: .9rem; font-weight: 600; padding: 8px 0; }
.chd-sol summary:hover { color: var(--accent); }
.chd-sol pre { background: var(--bg-3); border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-top: 8px; font-family: var(--mono); font-size: .84rem; color: var(--str); white-space: pre-wrap; line-height: 1.6; }

/* ============================================================
   ACHIEVEMENTS
   ============================================================ */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px 18px; text-align: center; }
.stat-card b { font-family: var(--display); font-size: 1.9rem; color: var(--accent); display: block; }
.stat-card span { color: var(--text-faint); font-size: .82rem; }
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.ach-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px 18px; text-align: center; transition: .2s; }
.ach-card.unlocked { border-color: rgba(255,180,84,.4); background: linear-gradient(160deg, rgba(255,180,84,.08), var(--panel)); }
.ach-card.locked { opacity: .5; }
.ach-ic { font-size: 2rem; margin-bottom: 10px; }
.ach-card h3 { font-family: var(--display); font-size: 1rem; margin-bottom: 5px; }
.ach-card p { color: var(--text-dim); font-size: .82rem; }

/* ============================================================
   ADMIN
   ============================================================ */
.admin-gate { max-width: 480px; }
.gate-box { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 26px; display: flex; flex-direction: column; gap: 14px; }
.gate-input { padding: 12px 16px; background: var(--bg-3); border: 1px solid var(--border-2); border-radius: 10px; color: var(--text); font-family: var(--sans); font-size: 1rem; outline: none; }
.gate-input:focus { border-color: var(--accent); }
.gate-err { color: var(--err); font-size: .88rem; font-weight: 600; min-height: 18px; }

.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.admin-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; display: flex; flex-direction: column; gap: 11px; }
.admin-card.danger { border-color: rgba(248,113,113,.3); }
.admin-card h3 { font-family: var(--display); font-size: 1.1rem; }
.admin-card input, .admin-card select, .admin-card textarea {
  padding: 10px 13px; background: var(--bg-3); border: 1px solid var(--border-2); border-radius: 9px;
  color: var(--text); font-family: var(--sans); font-size: .9rem; outline: none; width: 100%;
}
.admin-card textarea { font-family: var(--mono); font-size: .85rem; resize: vertical; }
.admin-card input:focus, .admin-card textarea:focus, .admin-card select:focus { border-color: var(--accent-2); }
.ad-item { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; background: var(--bg-3); border-radius: 8px; font-size: .88rem; margin-top: 6px; }
.ad-item button { background: none; border: none; color: var(--text-faint); cursor: pointer; }
.ad-item button:hover { color: var(--err); }

/* ---- CMS: list + editor ---- */
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.ad-section { margin: 28px 0; }
.ad-h2 { font-family: var(--display); font-size: 1.25rem; margin-bottom: 14px; }
.ad-lesson-list { display: flex; flex-direction: column; gap: 10px; }
.ad-lesson-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--panel); border: 1px solid var(--border); border-radius: 11px; padding: 14px 18px; }
.ad-lr-info { display: flex; flex-direction: column; gap: 3px; }
.ad-lr-info b { font-size: 1rem; }
.ad-lr-meta { font-size: .8rem; color: var(--text-faint); }
.ad-lr-btns { display: flex; gap: 8px; flex-shrink: 0; }

.admin-editor { max-width: 820px; }
.ed-field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 20px; }
.ed-field > label { font-size: .85rem; font-weight: 700; color: var(--accent-2); }
.ed-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.ed-field input, .ed-field select, .ed-field textarea {
  padding: 11px 14px; background: var(--bg-3); border: 1px solid var(--border-2); border-radius: 9px;
  color: var(--text); font-family: var(--sans); font-size: .92rem; outline: none; width: 100%;
}
.ed-field textarea { font-family: var(--mono); font-size: .86rem; line-height: 1.6; resize: vertical; }
.ed-field input:focus, .ed-field textarea:focus, .ed-field select:focus { border-color: var(--accent); }
.ed-hint-line { font-size: .8rem; color: var(--text-faint); }
.ed-ex-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }
.ed-ex-row { background: var(--panel); border: 1px solid var(--border); border-radius: 11px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.ed-ex-head { display: flex; align-items: center; justify-content: space-between; }
.ed-ex-head b { font-size: .9rem; color: var(--accent); }
.ed-ex-del { background: none; border: none; color: var(--text-faint); cursor: pointer; font-size: .95rem; }
.ed-ex-del:hover { color: var(--err); }
.ed-ex-row input, .ed-ex-row textarea {
  padding: 9px 12px; background: var(--bg-3); border: 1px solid var(--border-2); border-radius: 8px;
  color: var(--text); font-size: .88rem; outline: none; width: 100%; font-family: var(--sans);
}
.ed-ex-row textarea { font-family: var(--mono); font-size: .84rem; resize: vertical; }
.ed-ex-row input:focus, .ed-ex-row textarea:focus { border-color: var(--accent-2); }
.ed-actions { display: flex; gap: 12px; margin-top: 10px; }

@media (max-width: 720px) {
  .admin-grid { grid-template-columns: 1fr; }
  .ed-row { grid-template-columns: 1fr; }
}

/* ============================================================
   LOGIN
   ============================================================ */
.login-wrap { min-height: calc(100vh - 59px); display: grid; place-items: center; padding: 40px 20px; }
.login-card { width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--border-2); border-radius: 18px; padding: 38px 32px; box-shadow: var(--shadow); }
.login-logo { font-family: var(--display); font-weight: 800; font-size: 1.5rem; color: var(--accent); text-align: center; }
.login-title { font-family: var(--display); font-size: 1.6rem; text-align: center; margin: 14px 0 6px; }
.login-sub { color: var(--text-dim); font-size: .88rem; text-align: center; margin-bottom: 22px; }
.login-sub code { background: var(--bg-3); padding: 2px 7px; border-radius: 5px; color: var(--accent); }
.login-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.login-field label { font-size: .82rem; font-weight: 700; color: var(--accent-2); }
.login-field input { padding: 12px 15px; background: var(--bg-3); border: 1px solid var(--border-2); border-radius: 10px; color: var(--text); font-family: var(--sans); font-size: 1rem; outline: none; }
.login-field input:focus { border-color: var(--accent); }
.lg-btn { width: 100%; margin-top: 6px; }
.lg-err { color: var(--err); font-size: .9rem; font-weight: 600; min-height: 20px; margin-top: 12px; text-align: center; }
.lg-home { display: block; text-align: center; color: var(--text-faint); font-size: .85rem; margin-top: 14px; }
.lg-home:hover { color: var(--accent); }

/* sidebar user + logout */
.side-user { padding: 12px 20px; color: var(--text-faint); font-size: .82rem; border-top: 1px solid var(--border); }
.side-logout:hover { color: var(--err) !important; }

/* ============================================================
   EXERCISE RUNNER (single console, sequential)
   ============================================================ */
.ex-runner { background: var(--bg-3); border: 1px solid var(--border-2); border-radius: var(--radius); padding: 22px; }

/* numbered task list */
.ex-list { list-style: none; counter-reset: extask; margin: 0 0 20px; padding: 0; }
.ex-item {
  counter-increment: extask;
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--panel); border: 1px solid var(--border);
  border-left: 3px solid var(--accent); border-radius: 11px;
  padding: 13px 16px; margin-bottom: 10px;
}
.ex-item::before {
  content: counter(extask);
  flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: #1a1206; font-weight: 800; font-size: .85rem;
  display: inline-grid; place-items: center; font-family: var(--display);
}
.ex-item.is-solved { border-left-color: var(--ok); }
.ex-item.is-solved::before { background: var(--ok); }
.ex-item-task { font-size: 1rem; line-height: 1.5; padding-top: 2px; }
.ex-check {
  flex-shrink: 0; margin-left: auto; font-weight: 800; font-size: 1.1rem;
  color: var(--text-faint); padding-top: 1px;
}
.ex-item.is-solved .ex-check { color: var(--ok); }

/* shared console */
.ex-console-label { font-size: .82rem; color: var(--text-faint); margin-bottom: 8px; }
.ex-status { min-height: 24px; margin-top: 12px; font-size: .92rem; font-weight: 600; }
.ex-pass { color: var(--ok); } .ex-fail { color: var(--err); }
.ex-hintmsg { color: var(--text-dim); }
.ex-progress-text { font-size: .85rem; color: var(--text-dim); font-weight: 700; margin-top: 14px; text-align: right; }


/* admin: user row actions + lesson order */
.ad-u-actions { display: flex; gap: 8px; }
.ad-u-actions button { background: none; border: none; color: var(--text-faint); cursor: pointer; font-size: .9rem; }
.ad-u-actions button:hover { color: var(--accent); }
.ad-lr-order { display: flex; flex-direction: column; gap: 2px; margin-right: 10px; }
.ad-lr-order button { background: var(--bg-3); border: 1px solid var(--border-2); color: var(--text-dim); cursor: pointer; border-radius: 5px; width: 26px; height: 20px; font-size: .65rem; line-height: 1; }
.ad-lr-order button:hover:not(:disabled) { color: var(--accent-2); border-color: var(--accent-2); }
.ad-lr-order button:disabled { opacity: .3; cursor: default; }
.ad-lesson-row { display: flex; align-items: center; }

/* admin: built-in lessons list */
.ad-builtin-list { display: flex; flex-direction: column; gap: 14px; }
.ad-bi-group { background: var(--panel); border: 1px solid var(--border); border-radius: 11px; padding: 14px 16px; }
.ad-bi-level { font-family: var(--display); font-size: .95rem; color: var(--accent-2); font-weight: 700; margin-bottom: 10px; }
.ad-bi-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.ad-bi-row:last-child { border-bottom: none; }
.ad-bi-row.is-hidden .ad-bi-title { color: var(--text-faint); text-decoration: line-through; }
.ad-bi-title { font-size: .9rem; }
.ad-bi-btns { display: flex; gap: 6px; flex-shrink: 0; }


/* ============================================================
   RICH TEXT EDITOR (Notion-like)
   ============================================================ */
.rte { border: 1px solid var(--border-2); border-radius: 11px; overflow: hidden; background: var(--bg-3); }
.rte-toolbar { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px 10px; background: var(--bg-2); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.rte-btn {
  font-family: var(--sans); font-size: .8rem; font-weight: 600; padding: 6px 10px;
  background: var(--panel-2); color: var(--text-dim); border: 1px solid var(--border-2);
  border-radius: 7px; cursor: pointer; transition: .12s;
}
.rte-btn:hover { color: var(--accent); border-color: var(--accent-2); }
.rte-area {
  min-height: 280px; max-height: 520px; overflow-y: auto; padding: 18px 20px;
  color: var(--text); font-size: 1rem; line-height: 1.7; outline: none;
}
.rte-area:focus { background: rgba(255,255,255,.01); }
.rte-area p { margin: 10px 0; }
.rte-area h3 { font-family: var(--display); font-size: 1.3rem; margin: 18px 0 8px; color: var(--text); }
.rte-area h4 { font-family: var(--display); font-size: 1.05rem; margin: 16px 0 6px; color: var(--accent-2); }
.rte-area ul, .rte-area ol { margin: 10px 0 10px 24px; }
.rte-area li { margin: 5px 0; }
.rte-area b, .rte-area strong { color: var(--text); }
.rte-area pre { background: var(--bg); border: 1px solid var(--border); border-radius: 9px; padding: 14px 16px; overflow-x: auto; margin: 12px 0; font-family: var(--mono); font-size: .9rem; color: var(--str); white-space: pre-wrap; }
.rte-area pre code { font-family: var(--mono); background: none; }
.rte-area .note { background: rgba(56,214,196,.08); border-left: 3px solid var(--accent-2); padding: 12px 16px; border-radius: 8px; color: var(--text-dim); }
.rte-area .warn { background: rgba(248,113,113,.08); border-left: 3px solid var(--err); padding: 12px 16px; border-radius: 8px; color: #fca5a5; }

/* ============================================================
   INLINE ADMIN EDITING
   ============================================================ */
.admin-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  background: linear-gradient(90deg, rgba(255,180,84,.12), rgba(56,214,196,.08));
  border: 1px solid rgba(255,180,84,.35); border-radius: 12px;
  padding: 12px 16px; margin-bottom: 22px; font-size: .9rem;
}
.admin-bar.editing { background: rgba(56,214,196,.1); border-color: rgba(56,214,196,.4); }
.admin-bar.bottom { margin-top: 24px; margin-bottom: 0; justify-content: flex-end; }
.admin-bar-label { font-weight: 700; color: var(--accent); white-space: nowrap; }
.admin-bar.editing .admin-bar-label { color: var(--accent-2); }
.admin-bar-actions { display: flex; gap: 8px; }
.admin-bar a { color: var(--accent-2); text-decoration: underline; }
.dash-admin { font-size: .85rem; color: var(--text-dim); }

/* editable title input matches the h1 look */
.ile-title {
  width: 100%; background: var(--bg-3); border: 1px dashed var(--accent-2);
  border-radius: 10px; padding: 8px 14px; color: var(--text);
  font-family: var(--display); font-size: 1.9rem; font-weight: 800; outline: none;
}
.ile-title:focus { border-style: solid; }

.lesson-editing .ile-theory-host { margin-top: 8px; }

.ile-ex {
  background: var(--bg-3); border: 1px solid var(--border-2); border-radius: 12px;
  padding: 14px 16px; margin-bottom: 12px;
}
.ile-ex-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.ile-ex-num {
  width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #1a1206;
  font-weight: 800; font-size: .85rem; display: inline-grid; place-items: center; font-family: var(--display);
}
.ile-ex-del { background: none; border: none; color: var(--text-faint); cursor: pointer; font-size: 1rem; }
.ile-ex-del:hover { color: var(--err); }
.ile-ex textarea {
  width: 100%; background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 11px; color: var(--text); font-family: var(--mono); font-size: .85rem;
  outline: none; margin-bottom: 8px; resize: vertical;
}
.ile-ex textarea:focus { border-color: var(--accent-2); }
.ile-ex-ord { display: flex; align-items: center; gap: 7px; font-size: .82rem; color: var(--text-dim); cursor: pointer; }
.ch-editing .ed-field { margin-bottom: 14px; }
.ch-editing .ed-field label { display: block; font-size: .82rem; font-weight: 700; color: var(--accent-2); margin-bottom: 5px; }
.ch-editing .ed-field input, .ch-editing .ed-field textarea, .ch-editing .ed-field select {
  width: 100%; background: var(--bg-3); border: 1px solid var(--border-2); border-radius: 9px;
  padding: 9px 13px; color: var(--text); font-family: var(--sans); font-size: .95rem; outline: none; resize: vertical;
}
.ch-editing .ed-field textarea { font-family: var(--mono); font-size: .85rem; }
.ch-editing .ed-row { display: flex; gap: 14px; }
.ch-editing .ed-row .ed-field { flex: 1; }

/* ============================================================
   ADMIN PANEL — side menu layout
   ============================================================ */
.admin-layout { display: flex; gap: 24px; align-items: flex-start; }
.admin-menu {
  flex: 0 0 220px; position: sticky; top: 20px;
  background: var(--bg-3); border: 1px solid var(--border-2); border-radius: 14px; padding: 16px;
}
.admin-menu-title { font-family: var(--display); font-weight: 800; font-size: 1.05rem; color: var(--accent); margin-bottom: 14px; padding: 0 6px; }
.admin-menu-nav { display: flex; flex-direction: column; gap: 4px; }
.admin-menu-link {
  text-align: left; background: none; border: none; cursor: pointer;
  padding: 10px 12px; border-radius: 9px; color: var(--text-dim);
  font-family: var(--sans); font-size: .92rem; font-weight: 600; transition: .12s;
}
.admin-menu-link:hover { background: var(--bg-2); color: var(--text); }
.admin-menu-link.active { background: var(--accent); color: #1a1206; }
.admin-menu-cta { width: 100%; margin-top: 16px; }
.admin-content { flex: 1; min-width: 0; }
.admin-content .admin-head { margin-bottom: 6px; }
.admin-content .page-title { margin: 0; }

@media (max-width: 760px) {
  .admin-layout { flex-direction: column; }
  .admin-menu { position: static; width: 100%; flex-basis: auto; }
  .admin-menu-nav { flex-direction: row; flex-wrap: wrap; }
  .admin-menu-link { flex: 1 1 auto; text-align: center; }
}

/* ============================================================
   SQL Playground (stateful, visual) — lesson exercise area
   ============================================================ */
.pg-wrap { display: flex; flex-direction: column; gap: 16px; }

.pg-tasks-box {
  background: var(--bg-2); border: 1px solid var(--border);
  border-left: 3px solid var(--accent); border-radius: 12px; padding: 14px 18px;
}
.pg-tasks { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; }
.pg-tasks li { color: var(--text); line-height: 1.5; }

.pg-console { background: var(--bg-3); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.pg-toolbar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: var(--panel); border-bottom: 1px solid var(--border); }
.pg-run {
  background: var(--accent); color: #1a1205; font-weight: 700; border: none;
  padding: 8px 18px; border-radius: 8px; cursor: pointer; font-size: .92rem;
}
.pg-run:hover { filter: brightness(1.07); }
.pg-clear, .pg-reset {
  background: var(--panel-2); color: var(--text-dim); border: 1px solid var(--border-2);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: .88rem;
}
.pg-clear:hover, .pg-reset:hover { color: var(--text); border-color: var(--text-faint); }
.pg-reset { margin-left: auto; }
.pg-status { color: var(--text-dim); font-size: .85rem; min-width: 40px; }

.pg-input {
  width: 100%; box-sizing: border-box; min-height: 130px; resize: vertical;
  background: var(--bg); color: var(--text); border: none; outline: none;
  font-family: var(--mono); font-size: .95rem; line-height: 1.55; padding: 16px 18px;
}
.pg-input::placeholder { color: var(--text-faint); }

.pg-msg { padding: 0 18px; font-size: .9rem; font-weight: 600; }
.pg-msg:not(:empty) { padding: 12px 18px; }
.pg-msg.pg-ok { color: var(--ok); background: rgba(74,222,128,.07); }
.pg-msg.pg-err { color: var(--err); background: rgba(248,113,113,.07); }

.pg-result:not(:empty) { padding: 12px 14px 16px; border-top: 1px solid var(--border); }
.pg-res-meta { color: var(--text-dim); font-size: .82rem; margin-bottom: 8px; }

/* visual state */
.pg-visual { background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; }
.pg-visual-head { font-weight: 700; color: var(--text); margin-bottom: 14px; font-size: 1rem; }
.pg-empty { color: var(--text-faint); font-size: .9rem; margin: 6px 0; }

.pg-dbs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.pg-db {
  display: inline-flex; align-items: center; gap: 4px; padding: 6px 14px; border-radius: 20px;
  background: var(--panel); border: 1px solid var(--border-2); color: var(--text-dim); font-size: .88rem; font-weight: 600;
}
.pg-db.is-current { background: rgba(255,180,84,.12); border-color: var(--accent); color: var(--accent); }

.pg-table { margin-top: 14px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.pg-table-head {
  display: flex; align-items: center; gap: 8px; padding: 9px 14px; background: var(--panel-2);
  font-weight: 700; color: var(--text); border-bottom: 1px solid var(--border); font-size: .92rem;
}
.pg-table-meta { color: var(--text-faint); font-weight: 500; font-size: .8rem; }

.pg-res-scroll { overflow-x: auto; }
.pg-tbl { border-collapse: collapse; width: 100%; font-size: .88rem; }
.pg-tbl th, .pg-tbl td { padding: 8px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.pg-tbl thead th { background: var(--panel); color: var(--text-dim); font-weight: 700; position: sticky; top: 0; }
.pg-tbl tbody tr:last-child td { border-bottom: none; }
.pg-tbl tbody tr:hover td { background: rgba(255,255,255,.02); }
.pg-coltype { display: block; font-weight: 400; font-size: .72rem; color: var(--text-faint); text-transform: lowercase; }
.pg-null { color: var(--text-faint); font-style: italic; }