/* Teachers' exercises.
   /custom/  - the studio: a toolbar, then edit (left) | live student view (right), each pane
               scrolling on its own like the exercise page; Edit / Student view tabs on phones.
   /custom/<runtime>/ - only the broken-link message is styled here (the rest is the exercise layout). */

/* ── Toolbar ── */
.studio-bar {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 10px 24px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.studio-heading { display: flex; flex-direction: column; gap: 1px; margin-right: auto; }
.studio-heading .eyebrow { font-size: 10.5px; }
.studio-heading h1 {
  font-family: var(--font-display); font-size: 1.3rem; font-weight: 600;
  letter-spacing: -0.01em; color: var(--text); line-height: 1.15;
}
.studio-actions { display: flex; align-items: center; gap: 10px; }
.studio-actions .btn { padding: 8px 14px; font-size: 14px; white-space: nowrap; }
.studio-actions .btn:disabled, .try-editor-foot .btn:disabled {
  opacity: .45; cursor: not-allowed; box-shadow: none; transform: none;
}

/* language switch: a compact segmented control */
.runtime-pick { display: inline-flex; border: 2px solid var(--ink); border-radius: var(--radius); overflow: hidden; }
.runtime-option { position: relative; }
.runtime-option input { position: absolute; opacity: 0; pointer-events: none; }
.runtime-option span {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px; cursor: pointer;
  font-size: 13.5px; font-weight: 600; color: var(--muted); background: var(--surface);
}
.runtime-option + .runtime-option span { border-left: 1.5px solid var(--border); }
.runtime-option input:checked + span { color: var(--on-ink); background: var(--ink); }
.runtime-option input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -4px; }

/* check status: a small chip that says where the exercise stands */
.studio-status {
  max-width: 340px; padding: 4px 10px; border-radius: 999px;
  font-family: var(--font-mono); font-size: 11.5px; line-height: 1.35; color: var(--muted);
  border: 1.5px dashed var(--border);
}
.studio-status:empty { display: none; }
.studio-status.is-busy { color: var(--accent); border-color: currentColor; }
.studio-status.is-ok { color: var(--done); border-style: solid; border-color: currentColor; background: var(--done-soft); }
.studio-status.is-stale { color: var(--warm); border-color: currentColor; }
.studio-status.is-error { color: var(--danger); border-style: solid; border-color: currentColor; background: var(--danger-soft); }

/* ── The two panes ── */
.studio {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: minmax(380px, 1fr) minmax(440px, 1.15fr);
}
.studio-edit, .studio-preview { min-height: 0; overflow-y: auto; }
.studio-edit { background: var(--surface); border-right: 2px solid var(--ink); }
.studio-preview { padding: 20px 26px 28px; background: var(--bg); }

/* edit tabs: Content · Tests · Solution */
.studio-tabs {
  position: sticky; top: 0; z-index: 2;
  display: flex; background: var(--surface); border-bottom: 1.5px solid var(--border);
}
.studio-tabs button {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 12px 8px 10px; margin-bottom: -1.5px;
  font-family: var(--font-mono); font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em; color: var(--faint);
  border-bottom: 3px solid transparent;
}
.studio-tabs button:hover { color: var(--text); }
.studio-tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--warm); }
.step-num { font-family: var(--font-mono); font-size: 11px; font-weight: 600; color: var(--accent); }
.tab-count {
  min-width: 20px; padding: 0 6px; border-radius: 999px; font-size: 10.5px; letter-spacing: 0;
  color: var(--on-ink); background: var(--accent);
}
.tab-count:empty { display: none; }
.studio-panel { padding: 20px 22px 4px; }
.studio-footnote { padding: 0 22px 22px; font-size: 12.5px; color: var(--muted); }

/* fields */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field-label { font-family: var(--font-mono); font-size: 12px; font-weight: 600; color: var(--text); }
.field-label em { font-style: normal; font-weight: 400; color: var(--muted); }
.field-hint { font-size: 13px; line-height: 1.5; color: var(--muted); }
.field input, .field textarea, #share-url {
  width: 100%; padding: 9px 11px; font: inherit; font-size: 15px; color: var(--text);
  background: var(--bg); border: 1.5px solid var(--border); border-radius: var(--radius);
  resize: vertical;
}
.field input:focus, .field textarea:focus, #share-url:focus {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent);
}
.code-input { font-family: var(--font-mono) !important; font-size: 13.5px !important; line-height: 1.55; tab-size: 4; }

/* tests */
.custom-tests { list-style: none; counter-reset: test; display: flex; flex-direction: column; gap: 12px; margin: 12px 0 14px; }
.custom-test {
  position: relative; counter-increment: test; padding: 14px 52px 4px 14px;
  background: var(--bg); border: 1.5px dashed var(--border); border-radius: var(--radius);
}
.custom-test::before {
  content: counter(test, decimal-leading-zero); position: absolute; top: 14px; right: 16px;
  font-family: var(--font-mono); font-size: 12px; color: var(--faint);
}
.test-remove { position: absolute; bottom: 12px; right: 10px; width: 30px; height: 30px; font-size: 12px; }
.test-expected { margin: -4px 0 12px; font-size: 13px; color: var(--muted); }
.test-expected code { font-family: var(--font-mono); color: var(--done); overflow-wrap: anywhere; }
.custom-log {
  margin-bottom: 18px; max-height: 220px; overflow: auto; padding: 10px 12px;
  font-family: var(--font-mono); font-size: 12.5px; white-space: pre-wrap;
  color: var(--body-text); background: var(--sunken); border-radius: var(--radius);
}

/* ── Student view ── */
.preview-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.preview-live { display: inline-flex; align-items: center; gap: 7px; font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--done); box-shadow: 0 0 0 3px var(--done-soft); }
.try-card {
  margin-bottom: 18px; padding: 20px 22px; font-size: 15px;
  background: var(--surface); border: 2px solid var(--ink); border-radius: var(--radius); box-shadow: var(--shadow);
}
.try-card h2 { font-family: var(--font-display); font-size: 1.45rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.try-desc { color: var(--muted); margin-bottom: 12px; }
.try-desc:empty { display: none; }
.try-task-label { margin-top: 18px; }

/* the try box looks like the exercise page's editor panel (dark ink) */
.try-editor { border: 2px solid var(--ink); border-radius: var(--radius); overflow: hidden; background: #232931; }
.try-editor-bar, .try-editor-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 12px; background: #2b323b;
}
.try-editor-bar { border-bottom: 1px solid #3b434e; }
.try-editor-foot { border-top: 1px solid #3b434e; }
.try-editor .editor-fname { display: flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 12px; color: #b6bec9; }
.try-editor .editor-fname i { color: #f6d67f; }
.try-shortcuts { display: flex; gap: 12px; }
.try-editor .text-btn { font-family: var(--font-mono); font-size: 11.5px; color: #8f99a6; }
.try-editor .text-btn:hover { color: #e59c84; }
.try-editor .editor-hint { font-family: var(--font-mono); font-size: 11px; color: #8f99a6; }
.try-editor .kbd { background: #2f3640; color: #e3e8ee; border-color: #66707d; }
#try-code {
  display: block; width: 100%; min-height: 190px; padding: 12px 14px; resize: vertical;
  color: #e3e8ee; background: #232931; border: 0; caret-color: #f6d67f;
}
#try-code:focus { outline: none; box-shadow: inset 0 0 0 2px var(--accent); }
.try-editor-foot .btn { padding: 7px 14px; font-size: 13.5px; }
.try-summary { margin-left: auto; font-family: var(--font-mono); font-size: 12.5px; font-weight: 600; color: #b6bec9; }
.try-summary.all-passed { color: #8fcaa1; }
.try-summary.some-failed { color: #f0a08f; }
.try-results { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }

/* ── Share dialog ── */
.share-dialog {
  width: min(560px, calc(100% - 32px)); margin: auto; padding: 22px 22px 18px;
  color: var(--text); background: var(--surface);
  border: 2px solid var(--ink); border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.share-dialog::backdrop { background: rgb(20 24 30 / .45); }
.share-dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.share-dialog-head h2 { font-family: var(--font-display); font-size: 1.3rem; font-weight: 600; }
.share-dialog-head h2 i { color: var(--accent); margin-right: 6px; font-size: .9em; }
#share-url { font-family: var(--font-mono); font-size: 13px; }
.share-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 14px 0 16px; }
.share-size { margin-left: auto; font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.share-notes { display: flex; flex-direction: column; gap: 8px; padding-top: 14px; border-top: 1px dashed var(--border); }
.share-notes li { display: flex; gap: 9px; font-size: 13px; line-height: 1.5; color: var(--muted); }
.share-notes i { margin-top: 3px; color: var(--accent); }

/* ── Code fields: CodeMirror (dark, like the exercise page), growing with their content ── */
.studio .CodeMirror {
  height: auto !important; min-height: 130px; font-size: 13.5px !important;
  border: 1.5px solid var(--ink); border-radius: var(--radius);
}
.studio .CodeMirror-scroll { min-height: 130px; max-height: 420px; }
.studio .field .CodeMirror-focused { outline: 2px solid var(--accent); outline-offset: 1px; }
.try-editor .CodeMirror { border: 0; border-radius: 0; min-height: 210px; }
.try-editor .CodeMirror-scroll { min-height: 210px; max-height: 480px; }

/* ── First-visit welcome strip ── */
.studio-welcome {
  flex-shrink: 0; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 24px; background: color-mix(in srgb, var(--marker) 32%, var(--bg));
  border-bottom: 1px solid var(--border);
}
.studio-welcome[hidden] { display: none; }
.welcome-steps { display: flex; flex-wrap: wrap; gap: 6px 22px; margin-right: auto; font-size: 14px; color: var(--body-text); }
.welcome-steps strong { color: var(--text); }
.studio-welcome .btn { padding: 6px 12px; font-size: 13.5px; }
.studio-welcome .icon-btn { width: 30px; height: 30px; }

/* ── Template gallery ── */
.templates-dialog { width: min(760px, calc(100% - 32px)); }
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin-top: 16px; }
.template-card {
  display: flex; flex-direction: column; gap: 6px; padding: 14px 14px 16px; text-align: left;
  background: var(--bg); border: 1.5px solid var(--border); border-radius: var(--radius);
  transition: transform .12s, box-shadow .12s, border-color .12s;
}
.template-card:hover, .template-card:focus-visible {
  border-color: var(--ink); box-shadow: var(--shadow); transform: translate(-1px, -1px); outline: none;
}
.template-tag { font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--accent); }
.template-card strong { font-family: var(--font-display); font-size: 17px; font-weight: 600; color: var(--text); }
.template-card span:last-child { font-size: 13px; line-height: 1.45; color: var(--muted); }
.template-card.blank { border-style: dashed; }

/* ── Phones and small tablets: one pane at a time ── */
.studio-panes { display: none; }
@media (max-width: 960px) {
  .studio-bar { gap: 10px 14px; padding: 10px 14px; }
  .studio-welcome { padding: 10px 14px; }
  .studio-actions #new-btn span { display: none; }
  .studio-heading .eyebrow { display: none; }
  .studio-heading h1 { font-size: 1.15rem; }
  .runtime-option span { padding: 6px 10px; font-size: 13px; }
  .studio-actions { width: 100%; }
  .studio-actions .studio-status { flex: 1; min-width: 0; margin-right: auto; max-width: none; }
  .studio-panes { display: flex; flex-shrink: 0; background: var(--surface); border-bottom: 2px solid var(--ink); }
  .studio { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
  .studio > section { display: none; grid-area: 1 / 1; border-right: 0; }
  .studio[data-pane="edit"] > .studio-edit,
  .studio[data-pane="preview"] > .studio-preview { display: block; }
  .studio-preview { padding: 16px 14px 24px; }
  .studio-panel { padding: 16px 14px 4px; }
  .studio-footnote { padding: 0 14px 18px; }
}

/* play page: a damaged link */
.custom-error { max-width: 640px; margin: 48px auto; padding: 0 24px; }
.custom-error h2 { font-family: var(--font-display); font-size: 1.7rem; margin: 6px 0 12px; color: var(--text); }
.custom-error p { line-height: 1.6; color: var(--body-text); margin-bottom: 18px; }
