/* Dev Toolbox — instrument, not brochure.
   Ink-navy bench, phosphor-amber action color, mono voice for data. */

:root {
  --bg: #12151d;
  --bg-well: #0c0f15;
  --surface: #191e29;
  --surface-2: #212836;
  --border: #2a3242;
  --text: #e9e7e0;
  --muted: #8d95a5;
  --accent: #ffb454;
  --key-top: #f6a832;
  --key-bottom: #dd8d1d;
  --key-ink: #1c1305;
  --ok: #85d8a8;
  --err: #ff8b98;
  --shadow: 0 16px 48px rgba(0, 0, 0, 0.35);

  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

body.light {
  --bg: #eef0f3;
  --bg-well: #ffffff;
  --surface: #f7f8fa;
  --surface-2: #e7eaef;
  --border: #d3d8e0;
  --text: #1d222c;
  --muted: #5f6878;
  --accent: #9a6700;
  --ok: #1a7f4e;
  --err: #c4314b;
  --shadow: 0 16px 40px rgba(29, 34, 44, 0.10);
}

* { box-sizing: border-box; scrollbar-color: var(--border) transparent; scrollbar-width: thin; }

::selection { background: var(--accent); color: var(--bg); }

body {
  margin: 0;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
}

button, input, textarea { font: inherit; color: inherit; }
h1, p { margin: 0; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

kbd {
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10.5px;
}

/* ---------- shell ---------- */

.app {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  height: 100dvh;
}

/* Mobile-only backdrop; fixed so it never participates in the grid. */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 20;
  border: 0;
  padding: 0;
  background: rgba(8, 10, 14, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

/* ---------- rail (navigation) ---------- */

.rail {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(180deg, var(--key-top), var(--key-bottom));
  color: var(--key-ink);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.25);
}

.brand-name {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand-name em { font-style: normal; color: var(--accent); }

.key-button {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
}

.key-button:hover { color: var(--text); }
.key-button:active { transform: translateY(1px); border-bottom-width: 1px; }

.search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  margin: 2px 14px 10px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg-well);
}

.search-row input {
  min-width: 0;
  padding: 8px 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 13px;
}

.search-row input::placeholder { color: var(--muted); }
.search-row:focus-within { border-color: var(--accent); }

.tool-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 8px 10px;
}

.group-label {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: 0;
  padding: 10px 8px 4px;
  background: var(--surface);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.tool-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 6px 8px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.tool-row:hover { background: var(--surface-2); color: var(--text); }

.tool-row.active {
  background: var(--surface-2);
  color: var(--text);
}

.tool-row.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 2px;
  border-radius: 2px;
  background: var(--accent);
}

.tool-glyph {
  flex: none;
  width: 30px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  opacity: 0.85;
}

.tool-row .pin {
  margin-left: auto;
  color: var(--accent);
  font-size: 11px;
}

.list-empty {
  padding: 18px 10px;
  color: var(--muted);
  font-size: 13px;
}

.rail-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 18%, transparent);
}

.coffee-link {
  margin-left: auto;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}

.coffee-link:hover {
  text-decoration: underline;
}

/* ---------- bench ---------- */

.bench {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.bench-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 24px 14px;
  border-bottom: 1px solid var(--border);
}

.nav-toggle { display: none; }

.bench-title { min-width: 0; }

.bench-title h1 {
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.015em;
  line-height: 1.25;
}

.bench-title p {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bench-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.badge {
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.bench-meta .key-button.pinned { color: var(--accent); }

/* ---------- pipeline ---------- */

.pipeline {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 68px minmax(0, 1fr);
  padding: 16px 24px;
}

.pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.pane-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
}

.pane-label {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.pane-tools { display: flex; gap: 14px; }

.text-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  cursor: pointer;
}

.text-button:hover { text-decoration: underline; }
.text-button:disabled { color: var(--muted); cursor: default; text-decoration: none; }

textarea, .output {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-well);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  overflow: auto;
  resize: none;
}

.output { white-space: pre; }

textarea:focus { outline: none; border-color: var(--accent); }

.output.error { color: var(--err); white-space: pre-wrap; }
.output.idle { color: var(--muted); white-space: pre-wrap; }

/* Half-block QR modules must touch to form a solid, scannable grid. */
.output.qr { line-height: 1; font-size: 12px; letter-spacing: 0; }

/* ---------- the seam ---------- */

.seam {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 30px 8px 6px;
}

.pipe {
  flex: 1;
  width: 2px;
  background: repeating-linear-gradient(180deg, var(--border) 0 6px, transparent 6px 12px);
}

body.running .pipe {
  background: repeating-linear-gradient(180deg, var(--accent) 0 6px, transparent 6px 12px);
  animation: pipe-flow 0.45s linear infinite;
}

@keyframes pipe-flow {
  to { background-position: 0 12px; }
}

.run-key {
  display: grid;
  place-items: center;
  gap: 0;
  width: 54px;
  height: 54px;
  margin: 10px 0 6px;
  padding: 0;
  border: 0;
  border-radius: 13px;
  background: linear-gradient(180deg, var(--key-top), var(--key-bottom));
  color: var(--key-ink);
  cursor: pointer;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.28), 0 6px 16px color-mix(in srgb, var(--key-bottom) 35%, transparent);
}

.run-key:hover { filter: brightness(1.06); }

.run-key:active, body.running .run-key {
  transform: translateY(2px);
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.28), 0 2px 8px color-mix(in srgb, var(--key-bottom) 30%, transparent);
}

.run-glyph { font-size: 15px; line-height: 1; }

.run-word {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.live-badge {
  margin-bottom: 10px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.seam.manual .live-badge { visibility: hidden; }

/* ---------- footer ---------- */

.bench-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 24px;
  border-top: 1px solid var(--border);
}

.status {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12px;
}

.status.success { color: var(--ok); }
.status.error { color: var(--err); }

.hint { flex: none; color: var(--muted); font-size: 11px; }

/* ---------- responsive ---------- */

@media (max-width: 960px) {
  body { overflow: auto; }

  .app { display: block; height: auto; }

  .rail {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    width: min(320px, 86vw);
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow);
  }

  body.nav-open .rail { transform: translateX(0); }

  body.nav-open .scrim { opacity: 1; pointer-events: auto; }

  .bench { height: auto; min-height: 100dvh; }

  .nav-toggle { display: inline-grid; flex: none; }

  .bench-head { padding: 12px 16px; }
  .bench-title h1 { font-size: 17px; }

  .pipeline {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    padding: 12px 16px;
  }

  textarea, .output { min-height: 34dvh; }

  .seam { flex-direction: row; padding: 12px 4px; }

  .pipe {
    width: auto;
    height: 2px;
    background: repeating-linear-gradient(90deg, var(--border) 0 6px, transparent 6px 12px);
  }

  body.running .pipe {
    background: repeating-linear-gradient(90deg, var(--accent) 0 6px, transparent 6px 12px);
    animation-name: pipe-flow-x;
  }

  @keyframes pipe-flow-x {
    to { background-position: 12px 0; }
  }

  .run-key { width: 48px; height: 48px; margin: 0 12px; }
  .live-badge { margin: 0 12px 0 0; }

  .bench-foot { padding: 9px 16px; }
  .hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
