/* Controlled C++ exam IDE — clean single-file editor, no toolbar/menus.
   Calm, exam-focused; not a public playground. */
:root {
  --ink: #1c2733; --muted: #5b6675; --line: #d9dee7; --surface: #fff;
  --bg: #f4f6f8; --primary: #0c3b4a; --accent: #11506a;
  --kw: #0b5fa5; --str: #0a7a3d; --com: #8a93a0; --num: #b4530a; --pre: #6d28d9;
  --err: #b42318; --ok: #0a7a3d;
}
* { box-sizing: border-box; }
/* The join gate / app shell toggle via the [hidden] attribute; without this the
   class display rules (grid/flex) would override [hidden] and the join overlay
   would never disappear (incl. in demo mode). */
[hidden] { display: none !important; }
.ide-body { margin: 0; font-family: "IBM Plex Sans", system-ui, "Segoe UI", Roboto, sans-serif;
  color: var(--ink); background: var(--bg); height: 100vh; overflow: hidden; }

/* Join gate */
.ide-join { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 20; }
.ide-join-card { width: min(420px, 92vw); background: var(--surface); border: 1px solid var(--line);
  border-top: 5px solid var(--primary); border-radius: 12px; padding: 28px; box-shadow: 0 10px 30px rgba(0,0,0,.08);
  display: flex; flex-direction: column; gap: 10px; }
.ide-join-logo { height: 40px; align-self: flex-start; }
.ide-join-card h1 { margin: 6px 0 0; font-size: 1.4rem; color: var(--primary); }
.ide-join-sub { margin: 0 0 8px; color: var(--muted); font-size: .9rem; }
.ide-join-card label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; font-weight: 600; }
.ide-join-card input { font: inherit; font-weight: 400; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; }
.ide-join-status { font-size: .85rem; color: var(--err); min-height: 1em; margin: 0; }

/* App shell */
.ide-app { display: flex; flex-direction: column; height: 100vh; }
.ide-header { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 16px; background: var(--primary); color: #fff; flex: 0 0 auto; }
.ide-head-left { display: flex; align-items: center; gap: 10px; }
.ide-logo { height: 30px; }
.ide-exam-title { font-weight: 700; }
.ide-exam-meta { font-size: .8rem; color: #cfe0e7; }
.ide-head-right { display: flex; align-items: center; gap: 14px; font-size: .82rem; }
.ide-badge { background: #11506a; border: 1px solid #2b6c86; padding: 3px 9px; border-radius: 999px; font-weight: 700; }
.ide-time, .ide-save { color: #e7eef1; font-variant-numeric: tabular-nums; }
.ide-btn-ghost { background: transparent; color: #fff; border: 1px solid #36738a; border-radius: 8px; padding: 5px 10px; cursor: pointer; font: inherit; font-size: .8rem; }
.ide-btn-ghost:hover { background: #11506a; }

.ide-main { flex: 1 1 auto; display: grid; grid-template-columns: 260px 1fr 240px; gap: 1px; background: var(--line); min-height: 0; }
.ide-side { background: var(--surface); padding: 14px 16px; overflow: auto; }
.ide-side h2 { font-size: .95rem; margin: 0 0 8px; }
.ide-side h3 { font-size: .82rem; margin: 14px 0 4px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.ide-side p { font-size: .86rem; color: var(--ink); margin: 0 0 8px; }
.ide-muted { color: var(--muted) !important; font-size: .82rem !important; }
.ide-note { background: #fff7e6; border: 1px solid #f3d89a; color: #6b4e12; padding: 8px 10px; border-radius: 8px; font-size: .82rem !important; }
.ide-statuslist { list-style: none; padding: 0; margin: 0 0 10px; }
.ide-statuslist li { position: relative; padding-left: 18px; margin-bottom: 6px; font-size: .85rem; }
.ide-statuslist li::before { content: "✓"; position: absolute; left: 0; color: var(--ok); font-weight: 800; }

/* Editor */
.ide-editor-wrap { background: var(--surface); display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.ide-filetab { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px; align-self: flex-start;
  margin: 8px 0 0 10px; padding: 6px 14px; background: #eef3f5; border: 1px solid var(--line); border-bottom: none;
  border-radius: 8px 8px 0 0; font-size: .82rem; font-weight: 600; }
.ide-filedot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.ide-editor { flex: 1 1 auto; display: grid; grid-template-columns: 48px 1fr; border: 1px solid var(--line);
  margin: 0 10px; overflow: auto; background: #fbfcfd; min-height: 0; }
.ide-gutter { padding: 10px 6px; text-align: right; color: var(--com); background: #f1f4f6; border-right: 1px solid var(--line);
  font-family: "JetBrains Mono", "Consolas", monospace; font-size: 13px; line-height: 1.5; user-select: none; white-space: pre; }
.ide-code { position: relative; min-width: 0; }
.ide-highlight, .ide-code textarea {
  margin: 0; padding: 10px 12px; font-family: "JetBrains Mono", "Consolas", monospace; font-size: 13px; line-height: 1.5;
  white-space: pre; tab-size: 4; border: 0; }
.ide-highlight { position: absolute; inset: 0; overflow: hidden; pointer-events: none; color: var(--ink); }
.ide-code textarea { position: relative; width: 100%; height: 100%; background: transparent; color: transparent;
  caret-color: var(--ink); resize: none; outline: none; overflow: auto; }
.tok-kw { color: var(--kw); font-weight: 600; } .tok-str { color: var(--str); }
.tok-com { color: var(--com); font-style: italic; } .tok-num { color: var(--num); } .tok-pre { color: var(--pre); }

.ide-runbar { flex: 0 0 auto; display: flex; align-items: center; gap: 14px; padding: 10px; }
.ide-btn-primary { background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; border: 0;
  border-radius: 9px; padding: 9px 18px; font: inherit; font-weight: 700; cursor: pointer; }
.ide-btn-primary:disabled { opacity: .55; cursor: default; }
.ide-run-status { font-size: .84rem; color: var(--muted); }
.ide-run-status.ok { color: var(--ok); } .ide-run-status.err { color: var(--err); }

/* Bottom panels */
.ide-panels { flex: 0 0 38vh; display: flex; flex-direction: column; border-top: 1px solid var(--line); background: var(--surface); min-height: 0; }
.ide-tabs { display: flex; gap: 2px; background: #eef3f5; flex: 0 0 auto; }
.ide-tab { background: transparent; border: 0; border-bottom: 2px solid transparent; padding: 8px 14px; cursor: pointer; font: inherit; font-size: .84rem; color: var(--muted); }
.ide-tab.is-active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 700; background: var(--surface); }
.ide-panel { display: none; flex: 1 1 auto; margin: 0; padding: 10px 12px; overflow: auto;
  font-family: "JetBrains Mono", "Consolas", monospace; font-size: 13px; line-height: 1.5; white-space: pre-wrap; }
.ide-panel.is-active { display: block; }
.ide-panel textarea { width: 100%; height: 100%; border: 0; outline: none; resize: none; font: inherit; }
#out-build.err, #out-program.err { color: var(--err); }
.ide-history { list-style: none; margin: 0; padding: 0; font-family: inherit; }
.ide-history li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 4px; border-bottom: 1px solid var(--line); font-size: .82rem; }
.ide-history .h-status { font-weight: 700; }
.ide-history .h-ok { color: var(--ok); } .ide-history .h-err { color: var(--err); }

@media (max-width: 900px) {
  .ide-main { grid-template-columns: 1fr; grid-auto-rows: min-content; overflow: auto; }
  .ide-instructions, .ide-status { max-height: none; }
  .ide-editor { min-height: 320px; }
}
