/* compile.nitaimaarek.com — the only CSS this site owns.
 *
 * Everything visual (colour, type, buttons, cards, inputs) comes from
 * framework.nitaimaarek.com/ui.css. What is here is the two things the shared
 * framework has no opinion about: the three-column workbench layout, and the
 * internals of a code editor — gutter, overlay highlighting, syntax colours.
 * Every value below is derived from a --ui-* token so a theme or hue change on
 * the framework still repaints this page correctly. */

:root {
  --cs-gap: var(--ui-3);
  --cs-side: 320px;
  --cs-code-fs: 13px;
  --cs-code-lh: 1.55;

  /* Syntax palette, dark (the framework's default mode). Hues are fixed so
     code stays readable, saturation follows --ui-sat so a monochrome site
     stays monochrome here too. */
  --cs-kw:   hsl(265 calc(var(--ui-sat) * .95) 76%);
  --cs-type: hsl(190 calc(var(--ui-sat) * .8) 66%);
  --cs-str:  hsl(95  calc(var(--ui-sat) * .7) 66%);
  --cs-num:  hsl(30  calc(var(--ui-sat) * .9) 68%);
  --cs-com:  hsl(var(--ui-tint) calc(var(--ui-tint-sat) + 6%) 48%);
  --cs-pre:  hsl(340 calc(var(--ui-sat) * .8) 72%);
  --cs-fn:   hsl(45  calc(var(--ui-sat) * .75) 72%);
  --cs-punc: var(--ui-muted);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --cs-kw:   hsl(265 calc(var(--ui-sat) * .9) 44%);
    --cs-type: hsl(196 calc(var(--ui-sat) * .9) 34%);
    --cs-str:  hsl(120 calc(var(--ui-sat) * .8) 30%);
    --cs-num:  hsl(22  calc(var(--ui-sat) * .95) 42%);
    --cs-com:  hsl(var(--ui-tint) calc(var(--ui-tint-sat) + 4%) 52%);
    --cs-pre:  hsl(335 calc(var(--ui-sat) * .85) 44%);
    --cs-fn:   hsl(38  calc(var(--ui-sat) * .95) 36%);
  }
}
:root[data-theme="light"] {
  --cs-kw:   hsl(265 calc(var(--ui-sat) * .9) 44%);
  --cs-type: hsl(196 calc(var(--ui-sat) * .9) 34%);
  --cs-str:  hsl(120 calc(var(--ui-sat) * .8) 30%);
  --cs-num:  hsl(22  calc(var(--ui-sat) * .95) 42%);
  --cs-com:  hsl(var(--ui-tint) calc(var(--ui-tint-sat) + 4%) 52%);
  --cs-pre:  hsl(335 calc(var(--ui-sat) * .85) 44%);
  --cs-fn:   hsl(38  calc(var(--ui-sat) * .95) 36%);
}

/* ── shell ─────────────────────────────────────────────────────────── */

body { padding-inline: var(--ui-3); }

/* Several layout classes here set display:flex, which beats the UA rule for
   the hidden attribute. Panels toggled from JS must actually disappear. */
[hidden] { display: none !important; }

.cs-top {
  display: flex; align-items: center; gap: var(--ui-2);
  padding: var(--ui-2) 0; margin-bottom: var(--ui-2);
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in oklab, var(--ui-bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--ui-line-soft);
}
.cs-top__brand { display: flex; align-items: center; gap: var(--ui-2); min-width: 0; }
.cs-top__brand > div { display: flex; align-items: baseline; gap: var(--ui-2); min-width: 0; }
.cs-top__brand strong { font-size: 1.15rem; letter-spacing: -.02em; }
.cs-top__right { margin-left: auto; display: flex; align-items: center; gap: var(--ui-1); }
.cs-mark {
  font-family: var(--ui-mono); font-weight: 700; font-size: .95rem;
  color: var(--ui-accent);
  border: 1px solid var(--ui-line); border-radius: var(--ui-radius-sm);
  padding: 2px 7px;
}

.cs-app {
  display: grid; gap: var(--cs-gap);
  grid-template-columns: var(--cs-side) minmax(0, 1.05fr) minmax(0, 1fr);
  align-items: start;
  /* Fill the viewport under the sticky header so the editor and the output
     panel each scroll inside themselves rather than moving the page. */
  height: calc(100dvh - 84px);
}
.cs-side { overflow-y: auto; height: 100%; padding-right: 4px; scrollbar-width: thin; }
.cs-main, .cs-out { height: 100%; min-width: 0; display: flex; flex-direction: column; }

.cs-card { padding: var(--ui-3); }
.cs-card .ui-field + .ui-field { margin-top: var(--ui-2); }
.cs-card .ui-card__sub { margin-bottom: var(--ui-2); }
.cs-grow { flex: 1 1 auto; min-width: 0; }

@media (max-width: 1400px) {
  .cs-app { grid-template-columns: 300px minmax(0, 1fr); grid-template-rows: minmax(280px, 1fr) minmax(300px, 1fr); }
  .cs-side { grid-row: 1 / span 2; }
}
@media (max-width: 900px) {
  .cs-app { grid-template-columns: minmax(0, 1fr); height: auto; grid-template-rows: none; }
  .cs-side { grid-row: auto; order: 3; height: auto; overflow: visible; }
  .cs-main { order: 1; height: 70vh; }
  .cs-out { order: 2; height: 70vh; }
  .cs-hide-sm { display: none; }
}

/* ── editor ────────────────────────────────────────────────────────── */

.cs-filebar { display: flex; align-items: center; gap: var(--ui-1); margin-bottom: var(--ui-1); }
.cs-tabs { display: flex; gap: 4px; overflow-x: auto; flex: 1 1 auto; scrollbar-width: none; }
.cs-tabs::-webkit-scrollbar { display: none; }
.cs-tab {
  display: inline-flex; align-items: center; gap: 6px;
  font: 500 12.5px/1 var(--ui-mono); white-space: nowrap;
  padding: 7px 10px; border-radius: var(--ui-radius-sm) var(--ui-radius-sm) 0 0;
  border: 1px solid transparent; border-bottom: none;
  background: transparent; color: var(--ui-muted); cursor: pointer;
}
.cs-tab:hover { color: var(--ui-text); background: var(--ui-surface); }
.cs-tab[aria-selected="true"] {
  color: var(--ui-text); background: var(--ui-surface-2);
  border-color: var(--ui-line-soft);
}
.cs-tab__x { border: 0; background: none; color: var(--ui-faint); cursor: pointer; padding: 0 2px; line-height: 1; }
.cs-tab__x:hover { color: var(--ui-bad); }

.cs-editor { flex: 1 1 auto; min-height: 220px; display: flex; }

.cs-ed {
  flex: 1 1 auto; display: flex; min-width: 0;
  border: 1px solid var(--ui-line-soft); border-radius: var(--ui-radius-sm);
  background: var(--ui-surface); overflow: hidden; position: relative;
}
.cs-ed__gutter {
  flex: 0 0 auto; overflow: hidden; user-select: none;
  padding: 10px 8px 10px 12px; text-align: right;
  font: 400 var(--cs-code-fs)/var(--cs-code-lh) var(--ui-mono);
  color: var(--ui-faint); background: var(--ui-bg-alt);
  border-right: 1px solid var(--ui-line-soft);
}
.cs-ed__gutter span { display: block; position: relative; }
.cs-ed__gutter span.is-error { color: var(--ui-bad); font-weight: 700; }
.cs-ed__gutter span.is-warning { color: var(--ui-warn); font-weight: 700; }
.cs-ed__gutter span.is-cursor { color: var(--ui-text); }

.cs-ed__wrap { position: relative; flex: 1 1 auto; min-width: 0; }
.cs-ed__hl, .cs-ed__ta {
  margin: 0; padding: 10px 14px; border: 0;
  font: 400 var(--cs-code-fs)/var(--cs-code-lh) var(--ui-mono);
  tab-size: 4; white-space: pre; overflow-wrap: normal;
  position: absolute; inset: 0; width: 100%; height: 100%;
}
.cs-ed__hl {
  overflow: auto; pointer-events: none; color: var(--ui-text);
  background: none; box-shadow: none;
}
.cs-ed__hl::-webkit-scrollbar { display: none; }
.cs-ed__hl { scrollbar-width: none; }
.cs-ed__ta {
  overflow: auto; resize: none; background: transparent;
  color: transparent; caret-color: var(--ui-accent);
  outline: none; box-shadow: none; border-radius: 0;
  /* ui.css frosts every input with a backdrop-filter. On a transparent
     textarea sitting over the highlight layer, that blurs the code it is
     meant to be invisible in front of. */
  backdrop-filter: none; -webkit-backdrop-filter: none;
}
.cs-ed__ta::selection { background: color-mix(in oklab, var(--ui-accent) 35%, transparent); }
.cs-ed__hl mark.cs-err {
  background: none; color: inherit;
  border-bottom: 2px wavy var(--ui-bad); text-decoration: underline wavy var(--ui-bad);
}

.tk-kw { color: var(--cs-kw); font-weight: 600; }
.tk-ty { color: var(--cs-type); }
.tk-st { color: var(--cs-str); }
.tk-nu { color: var(--cs-num); }
.tk-cm { color: var(--cs-com); font-style: italic; }
.tk-pp { color: var(--cs-pre); }
.tk-fn { color: var(--cs-fn); }
.tk-pu { color: var(--cs-punc); }

.cs-runbar { display: flex; align-items: center; gap: var(--ui-2); margin-top: var(--ui-2); flex-wrap: wrap; }
.cs-runbar kbd { margin-left: 6px; opacity: .65; font-size: .8em; }

/* ── output side ───────────────────────────────────────────────────── */

.cs-outtabs { flex: 0 0 auto; flex-wrap: wrap; row-gap: 2px; }
.cs-outtabs .ui-tab { padding-inline: var(--ui-2); }
.cs-panel {
  flex: 1 1 auto; min-height: 0; overflow: auto;
  display: flex; flex-direction: column; gap: var(--ui-2);
  padding-top: var(--ui-2);
}
.cs-panel[hidden] { display: none; }

.cs-console, .cs-code {
  flex: 1 1 auto; min-height: 120px; margin: 0; overflow: auto;
  font: 400 var(--cs-code-fs)/var(--cs-code-lh) var(--ui-mono);
  white-space: pre; tab-size: 8;
}
.cs-console { white-space: pre-wrap; word-break: break-word; }
.cs-console .cs-stderr { color: var(--ui-bad); }
.cs-console .cs-sys { color: var(--ui-muted); font-style: italic; }
.cs-code .as-lbl { color: var(--cs-fn); }
.cs-code .as-dir { color: var(--ui-faint); }
.cs-code .as-ins { color: var(--cs-kw); }
.cs-code .as-cm { color: var(--cs-com); }
.cs-cmd { white-space: pre-wrap; word-break: break-all; }

.cs-meta { display: flex; flex-wrap: wrap; gap: var(--ui-1) var(--ui-2); align-items: center; font-size: .82rem; }
.cs-artifact {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--ui-2);
  padding: var(--ui-2); border: 1px solid var(--ui-line-soft);
  border-radius: var(--ui-radius-sm); background: var(--ui-surface);
}
.cs-viewbar { display: flex; align-items: center; gap: var(--ui-2); flex-wrap: wrap; }

.cs-problems { display: flex; flex-direction: column; gap: 6px; }
.cs-prob {
  display: grid; grid-template-columns: auto auto 1fr; gap: 8px; align-items: baseline;
  width: 100%; text-align: left; cursor: pointer;
  padding: 8px 10px; border-radius: var(--ui-radius-sm);
  border: 1px solid var(--ui-line-soft); background: var(--ui-surface);
  font-size: .85rem;
}
.cs-prob:hover { border-color: var(--ui-line); background: var(--ui-surface-2); }
.cs-prob__loc { font-family: var(--ui-mono); color: var(--ui-muted); font-size: .78rem; white-space: nowrap; }
.cs-prob__msg { min-width: 0; overflow-wrap: anywhere; }
.cs-prob--error .cs-prob__kind { color: var(--ui-bad); }
.cs-prob--warning .cs-prob__kind { color: var(--ui-warn); }
.cs-prob--note .cs-prob__kind { color: var(--ui-info); }
.cs-prob__kind { font-weight: 700; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; }

/* ── sidebar bits ──────────────────────────────────────────────────── */

.cs-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.cs-preset {
  cursor: pointer; font-size: .78rem; padding: 6px 10px;
  border-radius: var(--ui-radius-lg); border: 1px solid var(--ui-line);
  background: var(--ui-surface); color: var(--ui-text);
}
.cs-preset:hover { border-color: var(--ui-accent); transform: translateY(var(--ui-lift)); }
.cs-preset[aria-pressed="true"] { background: var(--ui-solid); color: var(--ui-solid-ink); border-color: transparent; }

.cs-switches { display: grid; grid-template-columns: 1fr; gap: 7px; }
.cs-switches label { font-size: .84rem; }
.cs-switches .is-off { opacity: .42; }

.cs-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: var(--ui-2); }
.cs-chips:empty { display: none; }
.cs-liblist { display: flex; flex-direction: column; gap: 3px; max-height: 220px; overflow: auto; margin-top: var(--ui-1); }
.cs-liblist--common { max-height: 200px; }
.cs-lib {
  display: grid; grid-template-columns: auto 1fr; gap: 8px; align-items: baseline;
  padding: 4px 6px; border-radius: var(--ui-radius-xs); cursor: pointer; font-size: .82rem;
}
.cs-lib:hover { background: var(--ui-surface-2); }
.cs-lib code { font-size: .8rem; }
.cs-lib small { color: var(--ui-faint); }

.cs-wslist { display: flex; flex-direction: column; gap: 4px; margin-top: var(--ui-2); }
.cs-ws {
  display: grid; grid-template-columns: auto 1fr auto auto; gap: 8px; align-items: center;
  font-size: .8rem; padding: 5px 7px; border-radius: var(--ui-radius-xs);
  background: var(--ui-surface); border: 1px solid var(--ui-line-soft);
}
.cs-ws code { font-size: .78rem; overflow-wrap: anywhere; }
.cs-ws small { color: var(--ui-faint); white-space: nowrap; }
.cs-drop { padding: var(--ui-3); }

/* ── compare ───────────────────────────────────────────────────────── */

.cs-cmpsetup { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px; }
.cs-cmpsetup + .ui-row .ui-slider { max-width: 260px; }
.cs-bar { height: 7px; border-radius: 4px; background: var(--ui-accent); min-width: 2px; }
.cs-cmp-table td, .cs-cmp-table th { font-size: .82rem; }
.cs-help p { margin-block: var(--ui-2); }
.cs-help h4 { margin-bottom: var(--ui-1); }
