:root {
  --paper: #fbfcfd;
  --panel: #f1f4f8;
  --ink: #1d2433;
  --muted: #5b6577;
  --line: #d9dee7;
  --jupyter: #f37726;
  --action: #c2560f;
  --action-hover: #a9480b;
  --run: #1f8a5b;
  --wait: #b7791f;
  --stop: #8a94a6;
  --fail: #c0392b;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #161b26;
    --panel: #1e2431;
    --ink: #e6e9ef;
    --muted: #9aa3b5;
    --line: #2c3445;
    --action: #e8742a;
    --action-hover: #f08a45;
    --run: #3fbf86;
    --fail: #e5675a;
    color-scheme: dark;
  }
  .button.primary { color: #161b26; }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

main { max-width: 56rem; margin: 0 auto; padding: 2rem 1rem 4rem; }

h1, h2 { line-height: 1.2; margin: 0 0 1rem; }
h1 { font-size: 1.6rem; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; font-weight: 650; margin-top: 2.5rem; }

a { color: inherit; }
:focus-visible { outline: 2px solid var(--jupyter); outline-offset: 2px; }

/* ---------- top bar ---------- */
.bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.75rem max(1rem, calc((100% - 54rem) / 2)); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; display: flex; align-items: center; gap: 0.5rem; }
.brand::before { content: ""; width: 0.8rem; height: 0.8rem; border-radius: 50%; background: var(--jupyter); }
.who { color: var(--muted); display: flex; gap: 1rem; }
.tabs { display: flex; gap: 0.25rem; margin-right: auto; margin-left: 2rem; }
.tabs a { text-decoration: none; padding: 0.35rem 0.75rem; border-radius: 6px; color: var(--muted); font-weight: 550; }
.tabs a[aria-current="page"] { color: var(--ink); background: var(--panel); }

/* ---------- landing ---------- */
.landing { min-height: 80vh; display: flex; flex-direction: column; justify-content: center; max-width: 36rem; }
.landing h1 { font-size: clamp(2rem, 5vw, 3rem); font-weight: 700; letter-spacing: -0.02em; }
.landing p { color: var(--muted); font-size: 1.1rem; margin: 0 0 2rem; }
.landing .button { align-self: flex-start; }

/* ---------- forms ---------- */
form { display: grid; gap: 1.25rem; }
.row { display: flex; gap: 1rem; flex-wrap: wrap; align-items: end; }
.grow { flex: 1 1 18rem; }
label { display: grid; gap: 0.35rem; font-weight: 550; font-size: 0.95rem; }
input[type="text"], input[type="password"] {
  font: inherit; font-weight: 400; padding: 0.6rem 0.75rem; width: 100%;
  border: 1px solid var(--line); border-radius: 6px; background: var(--paper); color: var(--ink);
}
input[name="repo"] { font-family: var(--mono); font-size: 0.95rem; }

.button {
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-block;
  padding: 0.55rem 1rem; border-radius: 6px; border: 1px solid var(--line); background: var(--paper); color: var(--ink);
}
.button:hover { border-color: var(--muted); }
.button.primary { background: var(--action); border-color: var(--action); color: #fff; }
.button.primary:hover { background: var(--action-hover); border-color: var(--action-hover); }
.button.quiet { border-color: transparent; color: var(--muted); }
.button.quiet:hover { color: var(--fail); }
button:disabled { opacity: 0.6; cursor: progress; }
form > .button { justify-self: start; }

/* ---------- cards: environments and sizes; the size picker is the one loud element ---------- */
.cards { border: 0; padding: 0; margin: 0; display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); }
.cards legend { font-weight: 550; font-size: 0.95rem; padding: 0; margin-bottom: 0.35rem; }
.card {
  position: relative; cursor: pointer; gap: 0.6rem; padding: 0.9rem 1rem;
  border: 1px solid var(--line); border-radius: 8px; background: var(--panel);
}
.card input { position: absolute; opacity: 0; pointer-events: none; }
.card:has(input:checked) { border-color: var(--jupyter); box-shadow: inset 0 0 0 1px var(--jupyter); background: var(--paper); }
.card:has(input:focus-visible) { outline: 2px solid var(--jupyter); outline-offset: 2px; }
.card-name { font-size: 1.4rem; font-weight: 700; line-height: 1; }
.env .card-name { font-size: 1.05rem; }
form:has(input[name="env"][data-clone="false"]:checked) .repo-fields { display: none; }
.cores { display: flex; gap: 3px; }
.core { width: 0.75rem; height: 0.75rem; border-radius: 2px; border: 1.5px solid var(--muted); }
.core.on { background: var(--ink); border-color: var(--ink); }
.core.half { background: linear-gradient(90deg, var(--ink) 50%, transparent 50%); border-color: var(--ink); }
.mem { height: 0.4rem; border-radius: 2px; background: var(--line); overflow: hidden; }
.mem .fill { display: block; height: 100%; background: var(--jupyter); }
.card-spec { color: var(--muted); font-weight: 400; font-size: 0.875rem; }
form .fine { color: var(--muted); margin: 0; }

/* ---------- notebook list ---------- */
.notebooks { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.nb {
  display: grid; grid-template-columns: auto 1fr auto; gap: 0.25rem 1rem; align-items: center;
  padding: 1rem 0; border-bottom: 1px solid var(--line);
}
.dot { width: 0.7rem; height: 0.7rem; border-radius: 50%; background: var(--stop); }
.running .dot, .done .dot { background: var(--run); }
.starting .dot { background: var(--wait); animation: pulse 1.6s ease-in-out infinite; }
.failed .dot { background: var(--fail); }
.what { display: grid; min-width: 0; }
.repo { font-family: var(--mono); font-weight: 600; overflow-wrap: anywhere; }
.meta, .detail { color: var(--muted); font-size: 0.9rem; }
.failed .detail { color: var(--fail); }
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: end; }
.empty { color: var(--muted); }
.log summary { cursor: pointer; color: var(--muted); font-size: 0.9rem; }
.log pre { max-height: 20rem; overflow: auto; }
code.pull { font-size: 0.85rem; color: var(--muted); overflow-wrap: anywhere; }

@keyframes pulse { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .starting .dot { animation: none; } }

@media (max-width: 40rem) {
  .nb { grid-template-columns: auto 1fr; }
  .actions { grid-column: 2; justify-content: start; }
}

/* ---------- help panels, messages ---------- */
.help { margin-top: 1.5rem; border: 1px solid var(--line); border-radius: 8px; padding: 0 1rem; }
.help summary { cursor: pointer; font-weight: 600; padding: 0.85rem 0; }
.help[open] { padding-bottom: 1rem; }
.help p { color: var(--muted); max-width: 65ch; }
pre { background: var(--panel); border-radius: 6px; padding: 0.85rem 1rem; overflow-x: auto; font-size: 0.85rem; }
code { font-family: var(--mono); }
.fine { font-size: 0.875rem; }

#toast:empty { display: none; }
#toast { max-width: 56rem; margin: 1rem auto 0; padding: 0 1rem; }
.error { margin: 0; padding: 0.75rem 1rem; border-radius: 6px; border-left: 4px solid var(--fail); background: var(--panel); }
