/* IBM Plex, Latin subset, served from the binary (see NOTICE). */
@font-face {
  font-family: "IBM Plex Sans";
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/ibm-plex-sans-400.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Sans";
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/ibm-plex-sans-500.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Sans";
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/ibm-plex-sans-600.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/ibm-plex-mono-400.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/ibm-plex-mono-600.woff2") format("woff2");
}

:root {
  --bg: #11140f;
  --panel: #1a1e17;
  --line: #2c3326;
  --fg: #dfe3d6;
  --muted: #8b937f;
  --accent: #b5e655;
  --bad: #ff7a6b;
  --warn: #ffd479;
  --ink: #0d0f0c;
  --deep: #0f120d;
  --inset: #171c13;
  --dim: #5f6a55;
  --seg: #252b22;
  --radius: 6px;
  font-family: "IBM Plex Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  color: var(--fg);
}

body {
  display: grid;
  grid-template-columns: var(--sidebar-width, 260px) 1fr;
  grid-template-rows: minmax(0, 1fr);
}

aside#sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--panel);
  min-height: 0;
  min-width: 0;
  position: relative;
}

/* Drag handle on the sidebar's right edge (see workspace-layout.js). */
#sidebar-resize {
  position: absolute;
  top: 0;
  right: -5px;
  bottom: 0;
  width: 9px;
  z-index: 5;
  cursor: col-resize;
  touch-action: none;
}
#sidebar-resize::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 4px;
  width: 1px;
  background: transparent;
  transition: background 0.1s;
}
#sidebar-resize:hover::after,
#sidebar-resize.dragging::after,
#sidebar-resize:focus-visible::after {
  left: 3px;
  width: 3px;
  background: var(--accent);
}
#sidebar-resize:focus { outline: none; }
body.sidebar-resizing { cursor: col-resize; user-select: none; }
body.sidebar-resizing iframe,
body.sidebar-resizing #workspace { pointer-events: none; }

/* —— Chrome header —— */
.chrome-header {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding: 13px 12px 12px;
}

.chrome-brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
}

.brand {
  display: flex;
  align-items: center;
  gap: 1px;
  min-width: 0;
  text-decoration: none;
  color: inherit;
}
a.brand:hover h1 { color: var(--accent); }

h1 {
  margin: 0;
  font: 600 17px/1 "IBM Plex Sans", system-ui, sans-serif;
  letter-spacing: -0.3px;
  color: var(--fg);
}

.brand-caret {
  display: block;
  width: 7px;
  height: 2px;
  background: var(--accent);
}

.chrome-status-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

/* —— VM status row: [dot] state boot … note —— */
.vm-status {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 8px;
  border-radius: 4px;
  background: #ffffff06;
  font: normal 10.5px/1 "IBM Plex Mono", ui-monospace, monospace;
  color: var(--muted);
  white-space: nowrap;
  min-width: 0;
}

.vm-state {
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.vm-boot { flex: 0 0 auto; }

.vm-note {
  margin-left: auto;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.vm-note.unsaved, .vm-note.busy { color: var(--warn); }
.vm-note.error { color: var(--bad); }
.vm-note.ok { color: var(--accent); }

.status-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--muted);
  flex: 0 0 auto;
}

.vm-status[data-state="busy"] .status-dot {
  background: var(--warn);
  animation: vm-pulse 1.2s ease-in-out infinite;
}
.vm-status[data-state="ready"] .vm-state { color: var(--accent); }
.vm-status[data-state="ready"] .status-dot { background: var(--accent); }
.vm-status[data-state="error"] { background: #ff7a6b14; }
.vm-status[data-state="error"] .vm-state { color: var(--bad); }
.vm-status[data-state="error"] .status-dot { background: var(--bad); }

@keyframes vm-pulse {
  50% { opacity: 0.3; }
}

@media (prefers-reduced-motion: reduce) {
  .vm-status[data-state="busy"] .status-dot { animation: none; }
}

.mode-segment {
  display: flex;
  align-items: stretch;
  gap: 2px;
  padding: 2px;
  height: 28px;
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--deep);
}

.mode-seg {
  display: inline-flex;
  flex: 1 1 0;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  border-radius: 4px;
  color: var(--muted);
  text-decoration: none;
  font: normal 9.5px/1 "IBM Plex Mono", ui-monospace, monospace;
  letter-spacing: 0.4px;
}

.mode-seg .tb-icon { width: 11px; height: 11px; }
.mode-seg:hover { color: var(--fg); }
.mode-seg.active {
  background: var(--seg);
  color: var(--accent);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover { border-color: var(--muted); color: var(--fg); }
.icon-btn.danger { width: 24px; padding: 0; color: var(--muted); border-color: var(--line); }
.icon-btn.danger:hover { color: var(--bad); border-color: var(--bad); }

/* —— Problem picker —— */
.problem-picker {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 12px 10px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.picker-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.picker-label {
  font: 600 9px/1 "IBM Plex Sans", system-ui, sans-serif;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.picker-count {
  margin-left: auto;
  font: normal 9px/1 "IBM Plex Mono", ui-monospace, monospace;
  color: #6f7867;
}

#problem-select {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--inset);
  color: var(--fg);
  cursor: pointer;
  font: inherit;
  text-align: left;
}
#problem-select:hover { border-color: var(--muted); }
#problem-select[aria-expanded="true"] { border-color: #b5e65555; }

.problem-num {
  font: normal 11px/1 "IBM Plex Mono", ui-monospace, monospace;
  color: var(--accent);
}

.problem-select-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
}

.problem-menu {
  position: absolute;
  z-index: 40;
  left: 8px;
  right: 8px;
  top: calc(100% - 4px);
  display: flex;
  flex-direction: column;
  max-height: min(420px, 70vh);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 12px 32px #0008;
  overflow: hidden;
}
.problem-menu[hidden],
#layout-menu[hidden] {
  display: none !important;
}

.problem-search {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 10px;
  border-bottom: 1px solid var(--line);
  background: var(--deep);
  color: var(--accent);
}
.problem-search input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 12px;
  outline: none;
}
.problem-search input::placeholder { color: #6f7867; }
.problem-search kbd {
  font: normal 8.5px/1 "IBM Plex Mono", ui-monospace, monospace;
  color: #6f7867;
}

.problem-results {
  flex: 1;
  overflow: auto;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  border: none;
}

.problem-results button {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 38px;
  padding: 0 8px;
  border: none;
  border-radius: 5px;
  background: none;
  color: var(--fg);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  text-align: left;
}
.problem-results button:hover { background: #ffffff08; }
.problem-results button[aria-selected="true"] {
  background: #b5e65514;
}
.problem-results button[aria-selected="true"]::after {
  content: "";
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 18px;
  border-radius: 1px;
  background: var(--accent);
}
.problem-results .problem-num { flex: 0 0 auto; }
.problem-results .problem-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.problem-results .solved-mark {
  color: var(--accent);
  margin-right: 10px;
  font-size: 12px;
}
.problem-results button.solved .problem-num { color: var(--accent); }

.problem-menu-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border-top: 1px solid var(--line);
  font: normal 9px/1 "IBM Plex Mono", ui-monospace, monospace;
  color: #6f7867;
}

article#problem {
  flex: 1;
  overflow: auto;
  padding: 14px;
  font-size: 12px;
  line-height: 1.55;
  color: #a7ad9a;
}

article#problem h2 {
  margin: 0 0 12px;
  font: 600 22px/1.2 "IBM Plex Sans", system-ui, sans-serif;
  color: var(--fg);
}

article#problem p { margin: 0 0 10px; }

/* —— Learn —— */
article.lesson { font-size: 13px; }
article.lesson ul { margin: 0 0 10px; padding-left: 18px; }
article.lesson li { margin-bottom: 4px; }
article.lesson b { color: var(--fg); font-weight: 600; }
article.lesson kbd {
  font: 11px "IBM Plex Mono", ui-monospace, monospace;
  padding: 1px 4px;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--fg);
}
article.lesson .lesson-file {
  margin-top: 16px;
  font: 11px "IBM Plex Mono", ui-monospace, monospace;
  color: var(--muted);
}
article.lesson h3 {
  margin: 0 0 6px;
  font: 400 10px/1 "IBM Plex Mono", ui-monospace, monospace;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
}
article.lesson .lesson-output { margin: 0; white-space: pre; }
article.lesson .lesson-solved { color: var(--accent); }
article.lesson .lesson-hint { margin-top: 16px; }
article.lesson .lesson-hint summary { font: 11px "IBM Plex Mono", ui-monospace, monospace; }
article.lesson .lesson-hint p { margin: 8px 0; }
article.lesson .lesson-example { margin: 0; white-space: pre; overflow-x: auto; color: var(--fg); }
button#check.checking { background: none; color: var(--accent); border: 1px solid var(--accent); }

.lesson-nav { display: flex; gap: 8px; }
.lesson-nav button {
  flex: 1;
  min-width: 0;
  height: 34px;
  padding: 0 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: inherit;
  font-size: 12px;
  color: var(--fg);
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}
.lesson-nav button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.lesson-nav button:disabled { opacity: 0.35; cursor: default; }
#lesson-prev { text-align: left; }
#lesson-next { text-align: right; }
article#problem .hint {
  color: var(--muted);
  font-size: 12px;
}
code, pre { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 12px; }
code { color: var(--accent); }
pre {
  background: var(--ink);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
  overflow-x: auto;
  color: var(--fg);
}

footer {
  padding: 12px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

button#check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font: inherit;
  cursor: pointer;
  border: none;
  background: var(--accent);
  color: var(--ink);
  font-weight: 600;
  font-size: 12px;
  padding: 0 14px;
  height: 38px;
  width: 100%;
  border-radius: var(--radius);
}

button:disabled { opacity: 0.4; cursor: wait; }

/* Toolbar / tree actions stay readable when disabled (opacity washes icons out). */
#toolbar button:disabled,
#tree-toolbar button:disabled {
  opacity: 1;
  color: var(--dim);
  border-color: var(--line);
  cursor: not-allowed;
}
#toolbar button:disabled .tb-icon { color: var(--dim); }

button.danger {
  font: inherit;
  cursor: pointer;
  background: none;
  color: var(--bad);
  border: 1px solid var(--bad);
  font-weight: 400;
  padding: 6px 10px;
  width: auto;
  border-radius: var(--radius);
}

#result { min-height: 1.5em; font-size: 13px; }
#result.ok { color: var(--accent); }
#result.fail { color: var(--bad); }

details { font-size: 13px; color: var(--muted); }
summary { cursor: pointer; }

.credits {
  margin: 0;
  padding: 0 0 4px;
  font-size: 9.5px;
  color: var(--muted);
}
aside#sidebar > .credits {
  padding: 0 12px 8px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}
.credits a { color: var(--muted); text-decoration: none; }
.credits a:hover { color: var(--accent); }

/* —— Workspace —— */
#workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
}
#workspace.layout-shell .editor-only,
#workspace.layout-shell section#editor,
#workspace.layout-shell #split,
#workspace.layout-shell #editor-tabs { display: none; }
#workspace.layout-editor #terminal,
#workspace.layout-editor #split { display: none; }

#toolbar {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 12px;
  height: 44px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  font-size: 13px;
  min-width: 0;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.toolbar-left { flex: 1 1 auto; overflow: hidden; }
.toolbar-right { flex: 0 0 auto; }

.tb-icon {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  display: block;
  overflow: visible;
}

#toolbar button[hidden] { display: none; }

#toolbar button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font: inherit;
  cursor: pointer;
  background: none;
  color: var(--fg);
  border: 1px solid var(--line);
  padding: 0 10px;
  height: 28px;
  border-radius: var(--radius);
  font-size: 12px;
  white-space: nowrap;
}
#toolbar button .tb-icon { color: var(--muted); }
#toolbar button:hover:not(:disabled) { border-color: var(--muted); }
#toolbar button[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
}
#toolbar button[aria-pressed="true"] .tb-icon { color: var(--accent); }
#toolbar button[aria-pressed="true"] .toggle-track { background: var(--accent); }
#toolbar button[aria-pressed="true"] .toggle-knob { background: var(--ink); margin-left: auto; margin-right: 0; }

#toolbar button.btn-primary,
#editor-run {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  color: var(--ink) !important;
  font-weight: 600;
}
#toolbar button.btn-primary .tb-icon,
#editor-run .tb-icon { color: var(--ink) !important; }

.lang-select {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 9px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--inset);
  color: var(--muted);
  font-size: 12px;
}
.lang-select .tb-icon { color: var(--accent); width: 12px; height: 12px; }
.lang-select select {
  border: none;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 11.5px;
  cursor: pointer;
  outline: none;
  max-width: 8rem;
}

.toolbar-rule {
  width: 1px;
  height: 18px;
  background: var(--line);
  flex: 0 0 auto;
}

#editor-status {
  flex: 1;
  min-width: 0;
  color: var(--dim);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10.5px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
#editor-status.dirty { color: var(--warn); }
#workspace.layout-shell #editor-status { visibility: hidden; }

.editor-lang {
  color: var(--muted);
  font: normal 10.5px/1 "IBM Plex Mono", ui-monospace, monospace;
  white-space: nowrap;
}

.toggle-track {
  display: inline-flex;
  align-items: center;
  width: 24px;
  height: 13px;
  padding: 0 2px;
  border-radius: 999px;
  background: var(--line);
}
.toggle-knob {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--muted);
}

.layout-picker { position: relative; }
#layout-toggle {
  width: 28px;
  height: 28px;
  padding: 0 !important;
  display: inline-grid;
  place-items: center;
  place-content: center;
  line-height: 0;
  border-color: #b5e65566 !important;
  background: #b5e65514 !important;
  color: var(--accent) !important;
}
#layout-toggle .tb-icon {
  color: var(--accent) !important;
  width: 15px;
  height: 15px;
  margin: 0;
}
#layout-toggle[aria-expanded="true"] {
  border-color: var(--accent) !important;
}

#layout-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 30;
  min-width: 11rem;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px #0008;
}
#layout-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: auto;
  background: none;
  border: none !important;
  color: var(--fg);
  padding: 6px 8px;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  border-radius: 4px;
}
#layout-menu button:hover { background: #ffffff0a; }
#layout-menu button[aria-checked="true"] {
  color: var(--accent);
  background: #ffffff0a;
}
#layout-menu button .tb-icon { color: inherit; }

.build-cmd-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 9px;
  border-radius: var(--radius);
  background: var(--inset);
  min-width: 0;
  flex: 0 1 180px;
}
.build-cmd-prompt {
  color: var(--accent);
  font: normal 11px/1 "IBM Plex Mono", ui-monospace, monospace;
}
#build-cmd {
  flex: 1;
  min-width: 60px;
  border: none;
  background: transparent;
  color: var(--muted);
  font: normal 11px/1 "IBM Plex Mono", ui-monospace, monospace;
  outline: none;
  padding: 0;
}
#build-cmd:disabled {
  opacity: 1;
  color: var(--dim);
}

section#editor {
  flex: var(--editor-share, 0.6) 1 0;
  min-height: 0;
  overflow: hidden;
}
#workspace.layout-editor section#editor { flex: 1 1 0; }

#split {
  flex: 0 0 8px;
  cursor: row-resize;
  background: var(--line);
  touch-action: none;
  position: relative;
}
#split::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 27px;
  height: 2px;
  transform: translate(-50%, -50%);
  border-radius: 1px;
  background: repeating-linear-gradient(
    90deg,
    var(--muted) 0 3px,
    transparent 3px 5px
  );
  opacity: 0.85;
  pointer-events: none;
}
#split:hover,
#split:focus-visible,
#split.dragging {
  background: #3a4334;
}
#split:hover::after,
#split:focus-visible::after,
#split.dragging::after {
  opacity: 1;
  background: repeating-linear-gradient(
    90deg,
    var(--accent) 0 3px,
    transparent 3px 5px
  );
}
#split:focus { outline: none; }
#split:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; }

main#terminal {
  flex: calc(1 - var(--editor-share, 0.6)) 1 0;
  min-width: 0;
  min-height: 0;
  padding: 8px;
  background: #000;
  position: relative;
  overflow: hidden;
}
#workspace.layout-shell main#terminal { flex: 1 1 0; }
#workspace.layout-editor main#terminal { flex: 0 0 0; }
main#terminal canvas { display: block; }

#workspace.layout-horizontal {
  flex-direction: row;
  flex-wrap: wrap;
  align-content: stretch;
}
#workspace.layout-horizontal #toolbar,
#workspace.layout-horizontal #editor-tabs {
  flex: 0 0 100%;
}
#workspace.layout-horizontal section#editor {
  flex: var(--editor-share, 0.6) 1 0;
  min-width: 0;
  height: auto;
}
#workspace.layout-horizontal #split {
  flex: 0 0 8px;
  cursor: col-resize;
  align-self: stretch;
  height: auto;
}
#workspace.layout-horizontal #split::after {
  width: 2px;
  height: 27px;
  background: repeating-linear-gradient(
    180deg,
    var(--muted) 0 3px,
    transparent 3px 5px
  );
}
#workspace.layout-horizontal #split:hover::after,
#workspace.layout-horizontal #split:focus-visible::after,
#workspace.layout-horizontal #split.dragging::after {
  background: repeating-linear-gradient(
    180deg,
    var(--accent) 0 3px,
    transparent 3px 5px
  );
}
#workspace.layout-horizontal main#terminal {
  flex: calc(1 - var(--editor-share, 0.6)) 1 0;
  min-width: 0;
}

/* —— Play —— */
body.play {
  grid-template-columns: 260px 1fr;
}

#tree-toolbar {
  display: flex;
  flex-wrap: nowrap;
  gap: 3px;
  align-items: center;
  height: 34px;
  padding: 0 6px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

#tree-toolbar .icon-btn {
  flex: 0 0 auto;
  border-radius: 5px;
}
#tree-toolbar .icon-btn .tb-icon {
  width: 12px;
  height: 12px;
}
#tree-toolbar .icon-btn:not(:disabled) {
  color: var(--muted);
  border-color: var(--line);
}
#tree-toolbar .icon-btn:hover:not(:disabled) {
  border-color: var(--muted);
  color: var(--fg);
}
#tree-toolbar button:disabled .tb-icon {
  color: var(--dim);
}

#tree {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 6px 8px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12px;
}

.tree-name-edit {
  flex: 1;
  min-width: 0;
  height: 22px;
  margin: 0;
  padding: 0 4px;
  border: 1px solid var(--accent);
  border-radius: 3px;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  outline: none;
}

.tree-root, .tree-root ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tree-root ul { padding-left: 13px; }

.tree-row {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  height: 24px;
  border-radius: 4px;
  padding: 0 4px 0 2px;
}

.tree-toggle, .tree-toggle-spacer {
  flex: 0 0 14px;
  width: 14px;
  text-align: center;
  line-height: 0;
}

.tree-toggle {
  display: inline-grid;
  place-items: center;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  font: inherit;
  font-size: 10px;
  line-height: 1;
}

.tree-icon {
  flex: 0 0 12px;
  width: 12px;
  height: 12px;
  display: grid;
  place-items: center;
  color: var(--muted);
  line-height: 0;
}
.tree-icon svg {
  width: 12px;
  height: 12px;
  display: block;
  overflow: visible;
}
.tree-item[data-type="file"] .tree-icon { color: var(--muted); }

.tree-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: none;
  border: none;
  color: var(--fg);
  cursor: pointer;
  padding: 2px 2px;
  text-align: left;
  font: inherit;
  border-radius: 4px;
}

.tree-item.selected > .tree-row {
  background: #b5e65516;
}
.tree-item.selected > .tree-row .tree-label { color: var(--accent); }
.tree-item.selected > .tree-row .tree-icon { color: var(--accent); }

#editor-tabs {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0;
  padding: 0;
  height: 34px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  overflow-x: auto;
  min-height: 34px;
}

.editor-conflict {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  background: #2a2210;
  border-bottom: 1px solid var(--warn);
  color: var(--warn);
  font-size: 12px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
}

.editor-conflict[hidden] { display: none; }

.editor-conflict button {
  font: inherit;
  font-size: 12px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
  color: var(--fg);
  cursor: pointer;
}

.editor-conflict button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.editor-tab {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 100%;
  border: none;
  border-right: 1px solid transparent;
  background: transparent;
}

.editor-tab.active {
  background: var(--bg);
}

.editor-tab-label {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  padding: 0 13px;
  height: 100%;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
}

.editor-tab.active .editor-tab-label { color: var(--fg); }

.tab-dirty {
  color: var(--warn);
  font-size: 14px;
  line-height: 1;
  padding-left: 4px;
}

.editor-tab-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 8px 2px 0;
  line-height: 1;
}

.editor-tab-close:hover { color: var(--fg); }

#sidebar-toggle { display: none; }
#sidebar-backdrop { display: none; }

@media (max-width: 720px) {
  body,
  body.play {
    grid-template-columns: 1fr;
  }

  aside#sidebar {
    position: fixed;
    z-index: 20;
    inset: 0 auto 0 0;
    width: min(320px, 88vw);
    transform: translateX(-105%);
    transition: transform 0.15s ease;
    box-shadow: none;
  }

  body.sidebar-open aside#sidebar {
    transform: translateX(0);
    box-shadow: 8px 0 24px #0008;
  }

  #sidebar-backdrop { display: none; }
  body.sidebar-open #sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 15;
    background: #0008;
  }

  #sidebar-toggle { display: inline-flex; }
  #sidebar-resize { display: none; }

  #split { flex-basis: 12px; }

  #toolbar {
    height: auto;
    min-height: 44px;
    flex-wrap: wrap;
    padding: 6px 10px;
  }
}

@media (min-width: 721px) {
  #sidebar-toggle,
  #sidebar-backdrop {
    display: none !important;
  }
}

/* —— Landing / home —— */
body.home {
  display: block;
  overflow: auto;
  background: var(--bg);
}

.home-shell {
  max-width: 1248px;
  margin: 0 auto;
  padding: 0 96px 96px;
}

.home-top {
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.home-brand {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font: 600 18px/1 "IBM Plex Mono", ui-monospace, monospace;
  color: var(--fg);
  text-decoration: none;
}

.home-cursor {
  display: inline-block;
  width: 9px;
  height: 18px;
  background: var(--accent);
  vertical-align: text-bottom;
  animation: home-blink 1.1s steps(1) infinite;
}

@keyframes home-blink {
  50% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .home-cursor { animation: none; }
}

.home-nav {
  display: flex;
  align-items: center;
  gap: 32px;
  font: 400 13px/1 "IBM Plex Mono", ui-monospace, monospace;
}

.home [hidden] {
  display: none !important;
}

.home-nav a,
.home-nav button:not(.home-cta) {
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
}

.home-nav a:hover,
.home-nav button:not(.home-cta):hover,
.home-nav button.home-nav-strong {
  color: var(--fg);
}

.home-account {
  position: relative;
}

.home-signed-in {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--muted);
}

.home-auth-popover {
  position: absolute;
  top: calc(100% + 16px);
  right: 0;
  z-index: 10;
  width: 340px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.home-auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.home-auth-form label {
  font: 400 13px/1.4 "IBM Plex Sans", system-ui, sans-serif;
  color: var(--muted);
}

.home-auth-row {
  display: flex;
  gap: 8px;
}

.home-auth-row input {
  flex: 1;
  min-width: 0;
  padding: 0 10px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--inset);
  color: var(--fg);
  font: 400 13px/1 "IBM Plex Mono", ui-monospace, monospace;
}

.home-auth-row .home-cta {
  height: 36px;
  padding: 0 14px;
  font-size: 13px;
}

.home-auth-status {
  margin: 0;
  font: 400 13px/1.4 "IBM Plex Sans", system-ui, sans-serif;
  color: var(--muted);
}

.home-auth-status.is-error {
  color: var(--bad);
}

.home-auth-status a {
  color: var(--accent);
}

.home-hero {
  display: grid;
  grid-template-columns: minmax(0, 548fr) minmax(0, 620fr);
  gap: 80px;
  align-items: center;
  padding: 56px 0;
}

.home-headline {
  margin: 0;
  font: 500 56px/1.05 "IBM Plex Sans", system-ui, sans-serif;
  letter-spacing: -0.5px;
  color: var(--fg);
}

.home-points {
  list-style: none;
  margin: 28px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 17px;
  line-height: 22px;
  color: var(--muted);
}

.home-points li {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.home-points li::before {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  background: var(--accent);
  transform: translateY(-2px);
}

.home-points b {
  font-weight: 400;
  color: var(--fg);
}

.home-actions {
  margin-top: 40px;
  display: flex;
  align-items: center;
  gap: 28px;
  flex-wrap: wrap;
}

.home-cta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 0 20px;
  border: none;
  border-radius: 4px;
  background: var(--accent);
  color: var(--bg);
  font: 600 14px/1 "IBM Plex Mono", ui-monospace, monospace;
  white-space: nowrap;
  cursor: pointer;
}

.home-cta:hover {
  filter: brightness(1.08);
}

.home-cta:disabled {
  opacity: 0.6;
  cursor: progress;
}

.home-cta svg,
.home-link-accent svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.home-link-muted {
  font: 400 13px/1 "IBM Plex Mono", ui-monospace, monospace;
  color: var(--muted);
  text-decoration: none;
}

.home-link-muted:hover {
  color: var(--fg);
}

.home-link-accent {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: none;
  background: none;
  font: 400 12px/1 "IBM Plex Mono", ui-monospace, monospace;
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
}

.home-link-accent:hover {
  text-decoration: underline;
}

.home-preview {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  font: 400 13px/18px "IBM Plex Mono", ui-monospace, monospace;
  color: var(--fg);
}

.home-preview-tabs {
  height: 40px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}

.home-preview-tabs > span:first-child {
  display: flex;
  gap: 20px;
}

.home-preview-tabs .is-active {
  color: var(--fg);
}

.home-preview-run {
  color: var(--accent);
}

.home-preview pre {
  margin: 0;
  border: none;
  border-radius: 0;
  background: none;
  font: inherit;
  white-space: pre;
  overflow: hidden;
}

.home-preview-code {
  padding: 18px 20px;
  line-height: 24px;
}

.home-preview-code i {
  display: inline-block;
  width: 30px;
  font-style: normal;
  font-size: 12px;
  color: #6f7a64;
}

.home-preview-term {
  padding: 16px 20px 20px;
  line-height: 23px;
  background: #000 !important;
  border-top: 1px solid var(--line);
}

.home-preview-term .home-cursor {
  width: 8px;
  height: 15px;
  vertical-align: -2px;
}

.t-y { color: #e7d3a4; }
.t-g { color: #a9c29b; }
.t-a { color: var(--accent); }
.t-o { color: #d7a97c; }
.t-m { color: var(--muted); }

.home-languages {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 28px 0;
  border-top: 1px solid var(--line);
}

.home-languages h2 {
  margin: 0;
  font: 400 11px/1 "IBM Plex Mono", ui-monospace, monospace;
  letter-spacing: 1.2px;
  color: var(--muted);
}

.home-languages ul {
  max-width: 100%;
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 16px 32px;
}

.home-languages li {
  display: flex;
  align-items: center;
  gap: 12px;
  font: 500 18px/1 "IBM Plex Sans", system-ui, sans-serif;
  color: var(--fg);
}

.home-workspace {
  display: grid;
  grid-template-columns: minmax(0, 772fr) minmax(0, 380fr);
  gap: 96px;
  align-items: start;
  padding-top: 36px;
  border-top: 1px solid var(--line);
}

.home-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.home-section-head h2 {
  margin: 0;
  font: 400 11px/1 "IBM Plex Mono", ui-monospace, monospace;
  letter-spacing: 1.5px;
  color: var(--muted);
}

.home-score {
  font: 400 12px/1 "IBM Plex Mono", ui-monospace, monospace;
  color: var(--fg);
}

.session-list {
  list-style: none;
  margin: 20px 0 0;
  padding: 0;
}

.session-row {
  display: flex;
  align-items: center;
  border-bottom: 1px solid #232a1d;
}

.session-open {
  flex: 1;
  min-width: 0;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0;
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.session-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: 400 13px/1 "IBM Plex Mono", ui-monospace, monospace;
  color: var(--fg);
}

.session-open:hover .session-name {
  color: var(--accent);
}

.session-file {
  width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: 400 12px/1 "IBM Plex Mono", ui-monospace, monospace;
  color: var(--muted);
}

.session-when {
  width: 80px;
  text-align: right;
  white-space: nowrap;
  font-size: 12px;
  color: var(--muted);
}

.session-delete {
  margin-left: 12px;
  padding: 0;
  border: none;
  background: none;
  color: var(--bad);
  font: 400 12px/1 "IBM Plex Mono", ui-monospace, monospace;
  cursor: pointer;
  opacity: 0;
}

.session-row:hover .session-delete,
.session-delete:focus-visible {
  opacity: 1;
}

@media (hover: none) {
  .session-delete { opacity: 1; }
}

.home-empty {
  margin: 20px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.home-next {
  margin-top: 20px;
  padding-top: 4px;
}

.home-next p {
  margin: 0;
}

.home-next-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font: 400 15px/20px "IBM Plex Mono", ui-monospace, monospace;
  color: var(--fg);
}

.home-next-title span:first-child {
  font-size: 13px;
  color: var(--muted);
}

.home-next-blurb {
  margin-top: 8px !important;
  font-size: 13px;
  line-height: 20px;
  color: var(--muted);
}

.home-exercises .home-link-accent {
  margin-top: 20px;
  font-size: 13px;
}

.home-exercises .home-link-accent[aria-disabled="true"] {
  opacity: 0.5;
  pointer-events: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Share-link dialog (play) and the read-only shared view (/s/<id>). */
.share-dialog {
  padding: 0;
  border: none;
  background: transparent;
  max-width: calc(100vw - 32px);
  color: inherit;
}

.share-dialog::backdrop {
  background: #000000a6;
}

.share-modal {
  width: min(480px, calc(100vw - 32px));
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
}

.share-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.share-head h2 {
  margin: 0;
  font: 600 15px/1.2 "IBM Plex Mono", ui-monospace, monospace;
  color: var(--fg);
}

.share-blurb {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.share-link-row {
  display: flex;
  gap: 8px;
}

#share-link,
#signin-email {
  flex: 1;
  min-width: 0;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--fg);
  font: 12px "IBM Plex Mono", ui-monospace, monospace;
  outline: none;
}

#share-link:focus,
#signin-email:focus { border-color: var(--muted); }

.share-copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--ink);
  font: 600 13px "IBM Plex Sans", system-ui, sans-serif;
  cursor: pointer;
}

.share-note {
  margin: 0;
  min-height: 1.4em;
  font-size: 12px;
  color: var(--muted);
}

.share-note.ok { color: var(--accent); }
.share-note.error { color: var(--bad); }
.share-note a { color: inherit; }

.readonly-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 8px;
  border: 1px solid var(--warn);
  border-radius: var(--radius);
  color: var(--warn);
  font: 600 11px/1 "IBM Plex Mono", ui-monospace, monospace;
  white-space: nowrap;
}

.readonly-note {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.share-view #tree { padding-top: 6px; }

.home-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 18px;
  border: none;
  border-radius: 0;
  font: 600 14px/1 "IBM Plex Mono", ui-monospace, monospace;
  text-decoration: none;
  cursor: pointer;
  width: 100%;
  box-sizing: border-box;
}

.home-btn-primary {
  background: var(--accent);
  color: var(--bg);
}

.home-btn-secondary {
  background: var(--seg);
  color: var(--fg);
  border: 1px solid var(--line);
}

@media (max-width: 1080px) {
  .home-shell { padding: 0 40px 64px; }
  .home-hero,
  .home-workspace {
    grid-template-columns: minmax(0, 1fr);
    gap: 48px;
  }
}

@media (max-width: 720px) {
  .home-shell { padding: 0 20px 48px; }
  .home-top { height: 64px; }
  .home-nav { gap: 20px; }
  .home-nav > a[href^="https://github.com"] { display: none; }
  .home-auth-popover { width: min(340px, calc(100vw - 40px)); }
  .home-hero { padding: 32px 0 48px; }
  .home-headline { font-size: 38px; }
  .home-points { font-size: 15px; }
  .home-points li { display: block; }
  .home-points li::before { display: inline-block; margin-right: 12px; }
  .home-preview-code,
  .home-preview-term { overflow-x: auto; }
  .session-file { display: none; }
}

.session-template-dialog {
  padding: 0;
  border: none;
  background: transparent;
  max-width: calc(100vw - 32px);
  color: inherit;
}

.session-template-dialog::backdrop {
  background: #11140fcc;
}

.session-template-modal {
  width: min(560px, 100%);
  margin: 0 auto;
  background: var(--panel);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

.session-template-header {
  padding: 24px 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.session-template-header h2 {
  margin: 0;
  font: 600 18px/1.2 "IBM Plex Mono", ui-monospace, monospace;
  color: var(--fg);
}

.session-template-sub {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}

.session-template-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 20px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.session-template-lang-label {
  margin: 8px 0 0;
  font: 400 11px/1 "IBM Plex Mono", ui-monospace, monospace;
  letter-spacing: 1.2px;
  color: var(--muted);
}

.session-template-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.session-template-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--inset);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.session-template-card.is-selected {
  background: #b5e65514;
  border-color: var(--accent);
}

.session-template-name {
  font: 600 14px/1.2 "IBM Plex Sans", system-ui, sans-serif;
  color: var(--fg);
}

.session-template-detail {
  font: 400 11px/1.3 "IBM Plex Mono", ui-monospace, monospace;
  color: var(--muted);
}

.session-template-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 20px;
}

.session-template-footer .home-btn {
  width: auto;
  min-width: 7rem;
  padding: 10px 16px;
  font-size: 13px;
}

@media (max-width: 720px) {
  .session-template-dialog {
    max-width: 100vw;
    width: 100%;
    margin: 0;
    align-self: end;
  }

  .session-template-modal {
    width: 100%;
    border-left: none;
    border-right: none;
    border-bottom: none;
  }

  .session-template-grid {
    grid-template-columns: 1fr;
  }

  .session-template-footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .session-template-footer .home-btn {
    width: 100%;
  }
}
