/* =========================================================
   COPA MCQ – Live Practice Lab
   ========================================================= */
.lab-content { padding-top: 20px; }
.lab-wrap { max-width: 1560px; }
.lab-hero { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-bottom: 16px; }
.lab-hero .lh-ic { width: 58px; height: 58px; border-radius: 16px; background: linear-gradient(135deg, #7b3fe4, #1554e0); color: #fff; display: grid; place-items: center; font-size: 26px; flex: none; box-shadow: 0 10px 22px rgba(91,61,245,.35); }
.lab-hero h1 { margin: 0; font-size: 26px; }
.lab-hero p { margin: 2px 0 0; color: var(--ink-2); font-size: 14.5px; }
.lab-hero .lang-badges { margin-left: auto; display: flex; gap: 8px; }
.lang-badges span { display: inline-flex; gap: 6px; align-items: center; padding: 6px 12px; border-radius: 999px; font: 600 12.5px var(--font-head); background: #fff; border: 1px solid var(--line); }

.lab { display: grid; grid-template-columns: 270px minmax(0, 1fr) minmax(0, 1fr); gap: 14px; align-items: stretch; }
.lab.full-out { grid-template-columns: 270px minmax(0, .8fr) minmax(0, 1.2fr); }

/* library */
.lib { background: #fff; border: 1px solid var(--line); border-radius: 16px; display: flex; flex-direction: column; min-height: 0; max-height: 720px; overflow: hidden; }
.lib-tabs { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--line); }
.lib-tabs button { white-space: nowrap; border: 0; background: #f7f9fd; padding: 12px 8px; font: 600 13px var(--font-head); color: var(--ink-2); cursor: pointer; display: flex; gap: 6px; align-items: center; justify-content: center; }
.lib-tabs button.on { background: #fff; color: var(--blue-600); box-shadow: inset 0 -3px 0 var(--blue-600); }
.lib-search { padding: 10px; border-bottom: 1px solid var(--line); }
.lib-search .input { padding: 8px 12px; font-size: 13.5px; }
.lib-list { overflow-y: auto; flex: 1; padding: 6px; }
.lib-group { font: 700 11px var(--font-head); letter-spacing: .6px; text-transform: uppercase; color: var(--ink-3); padding: 10px 10px 4px; display: flex; align-items: center; gap: 6px; }
.lib-item { display: flex; gap: 10px; align-items: center; width: 100%; text-align: left; border: 0; background: transparent; padding: 9px 10px; border-radius: 10px; cursor: pointer; font: 500 13.5px var(--font); color: var(--ink); }
.lib-item:hover { background: var(--blue-100); }
.lib-item.on { background: var(--navy-800); color: #fff; }
.lib-item .li-ic { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font-size: 13px; flex: none; color: #fff; }
.lib-item .li-t { flex: 1; min-width: 0; line-height: 1.3; }
.lib-item small { display: block; font-size: 11px; opacity: .7; }
.lib-item .li-del { opacity: .55; padding: 4px 6px; border-radius: 6px; }
.lib-item .li-del:hover { opacity: 1; background: var(--red-100); color: var(--red); }
.lib-empty { padding: 22px 14px; text-align: center; color: var(--ink-3); font-size: 13.5px; }

/* panes */
.pane { background: #1e1f29; border-radius: 16px; overflow: hidden; display: flex; flex-direction: column; min-height: 0; border: 1px solid #2c2e3e; box-shadow: var(--shadow); }
.pane-out { background: #fff; border-color: var(--line); }
.pane-bar { display: flex; align-items: center; gap: 6px; padding: 8px 10px; background: #15161e; border-bottom: 1px solid #2c2e3e; min-height: 48px; flex-wrap: wrap; }
.pane-out .pane-bar { background: #f3f5fa; border-color: var(--line); }
.pane-out .ftab.on { background: #fff; color: var(--navy-800); border: 1px solid var(--line); }
.ftab { border: 0; background: transparent; color: #a9adc8; font: 600 13px var(--font-head); padding: 7px 12px; border-radius: 8px; cursor: pointer; display: inline-flex; gap: 7px; align-items: center; }
.ftab:hover { color: #fff; background: rgba(255,255,255,.06); }
.ftab.on { background: #2b2d3d; color: #fff; }
.ftab .dot { width: 8px; height: 8px; border-radius: 50%; }
.pane-bar .sp { flex: 1; }
.mini { border: 0; background: rgba(255,255,255,.08); color: #d6d9ee; width: 32px; height: 32px; border-radius: 8px; cursor: pointer; display: grid; place-items: center; font-size: 13px; }
.mini:hover { background: rgba(255,255,255,.16); color: #fff; }
.pane-out .mini { background: #fff; border: 1px solid var(--line); color: var(--ink-2); }
.pane-out .mini:hover { color: var(--blue-600); border-color: var(--blue-500); }
.editor-host { flex: 1; min-height: 0; position: relative; }
.editor-host .CodeMirror { height: 100%; min-height: 520px; font: 14.5px/1.6 "JetBrains Mono", Consolas, "Courier New", monospace; }
.editor-host textarea.fallback { width: 100%; height: 100%; min-height: 520px; background: #282a36; color: #f8f8f2; border: 0; padding: 14px; font: 14.5px/1.6 Consolas, monospace; resize: none; }
.CodeMirror-gutters { border-right: 1px solid #2c2e3e !important; }

/* toolbar */
.lab-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 10px 12px; margin-bottom: 14px; box-shadow: var(--shadow); }
.mode-switch { display: inline-flex; background: var(--bg); border-radius: 12px; padding: 4px; }
.mode-switch button { border: 0; background: transparent; padding: 9px 14px; border-radius: 9px; font: 600 13.5px var(--font-head); color: var(--ink-2); cursor: pointer; display: inline-flex; gap: 8px; align-items: center; }
.mode-switch button.on { background: #fff; color: var(--navy-800); box-shadow: 0 2px 8px rgba(16,41,106,.12); }
.title-in { flex: 1; min-width: 200px; display: flex; align-items: center; gap: 8px; border: 1.5px solid var(--line); border-radius: 12px; padding: 0 12px; }
.title-in i { color: var(--ink-3); }
.title-in input { border: 0; outline: 0; flex: 1; padding: 10px 0; font: 500 14.5px var(--font); color: var(--ink); background: transparent; min-width: 0; }
.title-in:focus-within { border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(42,109,244,.12); }
.btn-run { background: linear-gradient(135deg, #18a957, #0f8a4b); color: #fff; box-shadow: 0 8px 18px rgba(24,169,87,.35); }
.btn-run:hover { filter: brightness(1.05); }
.btn-run kbd { font: 600 11px var(--font); background: rgba(255,255,255,.2); padding: 2px 6px; border-radius: 5px; }
.auto-tg { font-size: 13px; color: var(--ink-2); display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }
.auto-tg input { width: 36px; height: 20px; appearance: none; -webkit-appearance: none; background: #cfd5e3; border-radius: 999px; position: relative; cursor: pointer; transition: background .2s; }
.auto-tg input::after { content: ""; position: absolute; width: 14px; height: 14px; top: 3px; left: 3px; border-radius: 50%; background: #fff; transition: left .2s; }
.auto-tg input:checked { background: var(--green); }
.auto-tg input:checked::after { left: 19px; }

/* web preview */
.browser { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.browser .dots i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; }
.browser .url { flex: 1; min-width: 0; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 12.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.browser .url i { color: var(--green); margin-right: 6px; }
.preview-host { flex: 1; min-height: 300px; background: #fff; position: relative; }
.preview-host iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #fff; }
.live-dot { display: inline-flex; gap: 6px; align-items: center; font: 600 11.5px var(--font-head); color: var(--green); background: var(--green-100); padding: 4px 10px; border-radius: 999px; }
.live-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--green); animation: lpulse 1.4s infinite; }
@keyframes lpulse { 0% { box-shadow: 0 0 0 0 rgba(24,169,87,.6); } 100% { box-shadow: 0 0 0 8px rgba(24,169,87,0); } }

/* console */
.console { background: #0d1326; color: #d7e1ff; font: 13.5px/1.6 "JetBrains Mono", Consolas, monospace; display: flex; flex-direction: column; min-height: 0; }
.console-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: #0a0f1f; color: #8fa0d0; font: 600 12px var(--font-head); letter-spacing: .5px; text-transform: uppercase; border-top: 1px solid #1d2747; }
.console-head .sp { flex: 1; }
.console-head button { border: 0; background: transparent; color: #8fa0d0; cursor: pointer; font: 600 12px var(--font-head); }
.console-head button:hover { color: #fff; }
.console-body { overflow-y: auto; padding: 10px 14px; white-space: pre-wrap; word-break: break-word; flex: 1; }
.web-console { height: 170px; flex: none; }
.web-console.min { height: 36px; }
.web-console.min .console-body { display: none; }
.py-console { flex: 1; min-height: 360px; }
.cl { padding: 1px 0; }
.cl.out { color: #e6edff; }
.cl.info { color: #7fa8ff; }
.cl.ok { color: #3ddc84; }
.cl.warn { color: #ffd166; }
.cl.err { color: #ff7b7b; }
.cl.in { color: #c3a6ff; }
.cl .tm { color: #4f5f8f; margin-right: 8px; font-size: 11.5px; }
.console-empty { color: #4f5f8f; font-style: italic; }
.stdin-box { border-top: 1px solid var(--line); padding: 10px 12px; background: #f7f9fd; }
.stdin-box label { font: 600 12px var(--font-head); color: var(--ink-2); display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.stdin-box label small { color: var(--ink-3); font-weight: 400; font-family: var(--font); }
.stdin-box textarea { width: 100%; min-height: 56px; border: 1.5px solid var(--line); border-radius: 10px; padding: 8px 10px; font: 13.5px Consolas, monospace; resize: vertical; }
.py-status { display: inline-flex; gap: 7px; align-items: center; font: 600 12px var(--font-head); padding: 4px 10px; border-radius: 999px; background: var(--orange-100); color: #9a5300; }
.py-status.ready { background: var(--green-100); color: var(--green); }
.py-status.run { background: var(--blue-100); color: var(--blue-600); }

.lab-tips { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin-top: 16px; }
.lab-tip { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; display: flex; gap: 12px; font-size: 13.5px; color: var(--ink-2); }
.lab-tip i { font-size: 20px; color: var(--blue-600); margin-top: 2px; }
.lab-tip b { color: var(--ink); display: block; font-family: var(--font-head); }

.mob-switch { display: none; }
.lab.fs .pane-out { position: fixed; inset: 10px; z-index: 90; }

@media (max-width: 1280px) {
  .lab, .lab.full-out { grid-template-columns: 230px minmax(0, 1fr) minmax(0, 1fr); }
}
@media (max-width: 1100px) {
  .lab, .lab.full-out { grid-template-columns: 1fr 1fr; }
  .lib { grid-column: 1 / -1; max-height: none; }
  .lib-list { display: flex; overflow-x: auto; gap: 6px; padding: 8px; }
  .lib-group { display: none; }
  .lib-item { flex: none; width: auto; max-width: 240px; border: 1px solid var(--line); }
  .lib-item small { display: none; }
}
@media (max-width: 760px) {
  .lab, .lab.full-out { grid-template-columns: 1fr; }
  .mob-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--bg); padding: 4px; border-radius: 12px; }
  .mob-switch button { border: 0; padding: 10px; border-radius: 9px; font: 600 14px var(--font-head); background: transparent; color: var(--ink-2); }
  .mob-switch button.on { background: #fff; color: var(--navy-800); box-shadow: 0 2px 8px rgba(16,41,106,.12); }
  .lab[data-show="code"] .pane-out, .lab[data-show="out"] .pane-ed { display: none; }
  .editor-host .CodeMirror, .editor-host textarea.fallback { min-height: 420px; }
  .preview-host { min-height: 420px; }
  .lab-hero .lang-badges { display: none; }
  .lab-hero { flex-wrap: nowrap; gap: 12px; align-items: flex-start; }
  .lab-hero .lh-ic { width: 44px; height: 44px; font-size: 19px; border-radius: 12px; }
  .lab-hero p { font-size: 13.5px; }
  .mode-switch { width: 100%; }
  .mode-switch button { flex: 1; justify-content: center; }
  .lab-toolbar { gap: 8px; }
  .lab-toolbar .btn-run { flex: 1; }
  .lib { order: 3; }
  .lab-hero h1 { font-size: 22px; }
  .title-in { order: 5; flex-basis: 100%; }
  .lab-toolbar .btn { padding: 10px 14px; font-size: 13.5px; }
  .lab-toolbar .btn .lbl { display: none; }
  .btn-run .lbl { display: inline !important; }
  .btn-run kbd { display: none; }
}

/* ---------- VS Code-style suggestion list ---------- */
.CodeMirror-hints { background: #252526; border: 1px solid #454545; border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.45); padding: 3px; max-height: 260px; min-width: 260px; font: 13.5px/1.4 "JetBrains Mono", Consolas, monospace; z-index: 200; }
.CodeMirror-hint { color: #d4d4d4; padding: 4px 8px; border-radius: 4px; display: flex; align-items: center; gap: 9px; white-space: nowrap; max-width: 460px; }
.CodeMirror-hint .hk { width: 20px; text-align: center; font: 700 11px var(--font-head); flex: none; }
.CodeMirror-hint .ht { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.CodeMirror-hint .hd { color: #8b8b8b; font: 12px var(--font); overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
li.CodeMirror-hint-active { background: #04395e; color: #fff; }
li.CodeMirror-hint-active .hd { color: #c8c8c8; }
/* show >= != == exactly as typed (no font ligatures) */
.editor-host .CodeMirror, .CodeMirror-hints, .console-body, .pc-out pre { font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }

/* ---------- Python error explained (selected language) ---------- */
.py-explain { margin: 10px 0 4px; padding: 12px 14px; border-radius: 12px; background: linear-gradient(135deg, #2a1d10, #1e2236); border: 1px solid #ffb347; border-left: 5px solid #ffb347; color: #e6edff; font-family: "Poppins", "Roboto", sans-serif; font-size: 13.5px; line-height: 1.6; white-space: normal; box-shadow: 0 6px 18px rgba(0,0,0,.25); }
.py-explain .pe-hd { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.py-explain .pe-hd i { color: #ffd166; font-size: 16px; }
.py-explain .pe-hd b { color: #ffd166; font-size: 14.5px; flex: 1; min-width: 160px; }
.py-explain .pe-line { background: #ff7b7b; color: #1a1020; border: 0; border-radius: 999px; padding: 2px 10px; font: 600 12px "Poppins", sans-serif; cursor: pointer; }
.py-explain .pe-line:hover { background: #ffa0a0; }
.py-explain .pe-code { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; margin: 4px 0 8px; }
.py-explain .pe-code span { font-size: 12px; color: #9fb0d8; }
.py-explain .pe-code code { background: #0d1224; border: 1px dashed #ff7b7b; border-radius: 6px; padding: 2px 8px; color: #ffb4b4; font-family: "JetBrains Mono", Consolas, monospace; font-size: 12.5px; white-space: pre-wrap; word-break: break-word; }
.py-explain p { margin: 4px 0; }
.py-explain p i { color: #7fa8ff; width: 16px; }
.py-explain .pe-fix { color: #c9f7dc; }
.py-explain .pe-fix i { color: #3ddc84; }
.CodeMirror .cm-err-line { background: rgba(255, 90, 90, .22) !important; box-shadow: inset 3px 0 0 #ff5a5a; }
