/* ==========================================================================
   Resume Forge — "workbench"
   Layered near-black surfaces, hairline rules, one ember accent reserved for
   the primary action, the live stage and the score dial. Dark is the primary
   design; the light palette below is a faithful inversion, not an afterthought.
   ========================================================================== */

/* --------------------------------------------------------------- 1. tokens */
:root {
  --bg:        #0a0a0b;
  --bg-2:      #0d0d0f;
  --surface:   #121215;
  --surface-2: #17171b;
  --surface-3: #1e1e23;
  --line:      #24242b;
  --line-soft: #1a1a20;
  --ink:       #ece9e4;
  --ink-2:     #a3a0a7;
  --ink-3:     #6d6a73;

  --ember:     #ff7d3b;
  --ember-2:   #ef5f1a;
  --ember-ink: #1b0c03;
  --ember-wash: rgba(255, 125, 59, .12);

  --ok:   #56d495;
  --warn: #f0bf5c;
  --bad:  #ff6f61;

  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "Liberation Mono", monospace;

  --r-lg: 16px; --r: 12px; --r-sm: 8px;
  --shadow: 0 1px 2px rgba(0,0,0,.5), 0 18px 44px -20px rgba(0,0,0,.85);
  --inset-hi: inset 0 1px 0 rgba(255,255,255,.045);
  --grain: .04;
  --ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--ember);
  --seg-on: var(--surface-3);      /* selected pill; must stay legible in both themes */
  --seg-on-shadow: none;
  --dur: .22s;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg:        #f5f3f0;
    --bg-2:      #efebe5;
    --surface:   #ffffff;
    --surface-2: #faf8f5;
    --surface-3: #f0ece6;
    --line:      #e2ddd4;
    --line-soft: #ebe6de;
    --ink:       #17161a;
    --ink-2:     #56535b;
    --ink-3:     #84808a;
    --ember:     #cf5410;
    --ember-2:   #b3450a;
    --ember-ink: #fff7f2;
    --ember-wash: rgba(207, 84, 16, .1);
    --ok:   #10875a;
    --warn: #9a6a08;
    --bad:  #c0392b;
    --shadow: 0 1px 2px rgba(45,35,25,.06), 0 16px 36px -22px rgba(45,35,25,.3);
    --inset-hi: inset 0 1px 0 rgba(255,255,255,.7);
    --grain: .018;
    --seg-on: #ffffff;
    --seg-on-shadow: 0 1px 2px rgba(60,45,30,.14);
  }
}

/* ----------------------------------------------------------- 2. base reset */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}
h1, h2, h3 { margin: 0; font-weight: 620; letter-spacing: -.018em; line-height: 1.2; }
p { margin: 0; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }
::selection { background: var(--ember); color: var(--ember-ink); }

/* ------------------------------------------------------- 3. atmosphere bed */
.field { position: fixed; inset: 0; z-index: -1; pointer-events: none; background: var(--bg); }
.field::before {           /* hairline machinist grid, faded from the top-left */
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(900px 420px at 12% -8%, var(--ember-wash), transparent 70%),
    repeating-linear-gradient(90deg, var(--line-soft) 0 1px, transparent 1px 72px),
    repeating-linear-gradient(0deg,  var(--line-soft) 0 1px, transparent 1px 72px);
  -webkit-mask-image: radial-gradient(1300px 900px at 18% -5%, #000 0%, transparent 72%);
          mask-image: radial-gradient(1300px 900px at 18% -5%, #000 0%, transparent 72%);
  opacity: .4;   /* texture, not a visible grid */
}
.field::after {            /* fine grain so flat panels do not read as plastic */
  content: ""; position: absolute; inset: 0; opacity: var(--grain);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* -------------------------------------------------- 4. typographic helpers */
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.dim  { color: var(--ink-3); }
.micro {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--mono); font-size: 10.5px; font-weight: 500;
  letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3);
}
.micro .tick { width: 5px; height: 5px; border-radius: 50%; background: var(--ember); opacity: .85; }
/* file paths and free text stay in their own case — uppercasing a path is a lie */
.path { font-family: var(--mono); font-size: 11px; letter-spacing: .01em; color: var(--ink-3); }
.lede { display: block; font-size: 19px; font-weight: 600; letter-spacing: -.02em; margin-bottom: 6px; }
.hint { color: var(--ink-3); font-size: 13.5px; line-height: 1.5; max-width: 62ch; }

/* ------------------------------------------------------------- 5. controls */
.btn {
  --btn-bg: var(--surface-3);
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--btn-bg); color: var(--ink);
  font-size: 14px; font-weight: 560; letter-spacing: -.01em; white-space: nowrap;
  transition: background var(--dur), border-color var(--dur), transform .1s, opacity var(--dur);
}
.btn:hover:not(:disabled) { background: color-mix(in srgb, var(--btn-bg) 84%, var(--ink) 16%); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary:disabled { opacity: .7; }
.btn-primary {
  border-color: transparent; color: var(--ember-ink);
  background: linear-gradient(180deg, var(--ember), var(--ember-2));
  box-shadow: 0 1px 0 rgba(255,255,255,.18) inset, 0 8px 22px -12px var(--ember);
  font-weight: 640;
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.07); background: linear-gradient(180deg, var(--ember), var(--ember-2)); }
.btn-ghost { --btn-bg: transparent; color: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { color: var(--ink); background: var(--surface-2); }
/* Stop. Quiet until hovered — it sits next to a live run and should not compete
   with the progress for attention, but must be unmistakable once reached for. */
.btn-danger {
  --btn-bg: transparent;
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 38%, transparent);
}
.btn-danger:hover:not(:disabled) {
  background: color-mix(in srgb, var(--bad) 14%, transparent);
  border-color: color-mix(in srgb, var(--bad) 60%, transparent);
}
.btn-block { width: 100%; }
.btn-sm { padding: 8px 13px; font-size: 13px; border-radius: 9px; }
.btn-xs { padding: 4px 9px; font-size: 11px; font-family: var(--mono); letter-spacing: .04em; border-radius: 7px; }
.btn-icon { padding: 8px; }
.btn-icon svg { width: 17px; height: 17px; display: block; }
.btn-danger:hover:not(:disabled) { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }

.spinner {
  display: none; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, currentColor 30%, transparent);
  border-top-color: currentColor; animation: spin .7s linear infinite;
}
.btn.busy .spinner { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

.input, .textarea {
  width: 100%; background: var(--bg-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px;
  transition: border-color var(--dur), background var(--dur);
}
.input::placeholder, .textarea::placeholder { color: var(--ink-3); opacity: .75; }
.input:focus, .textarea:focus {
  outline: none; border-color: color-mix(in srgb, var(--ember) 60%, var(--line));
  box-shadow: 0 0 0 3px var(--ember-wash);
}
.textarea { resize: vertical; line-height: 1.6; min-height: 108px; }
.textarea-sm { min-height: 84px; font-size: 14px; }

/* segmented control */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; }
.seg button {
  padding: 7px 13px; border-radius: 7px; font-size: 13px; font-weight: 520; color: var(--ink-3);
  transition: color var(--dur), background var(--dur);
}
.seg button:hover { color: var(--ink-2); }
.seg button.on { background: var(--seg-on); color: var(--ink); box-shadow: var(--inset-hi), var(--seg-on-shadow); }

/* switch */
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 3px 0; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  position: relative; flex: none; width: 38px; height: 22px; border-radius: 999px;
  background: var(--surface-3); border: 1px solid var(--line); transition: background var(--dur), border-color var(--dur);
}
.switch .knob {
  position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--ink-3); transition: transform var(--dur) cubic-bezier(.3,1.4,.5,1), background var(--dur);
}
.switch input:checked + .track { background: color-mix(in srgb, var(--ember) 30%, var(--surface-3)); border-color: color-mix(in srgb, var(--ember) 45%, var(--line)); }
.switch input:checked + .track .knob { transform: translateX(16px); background: var(--ember); }
.switch input:focus-visible + .track { box-shadow: var(--ring); }
.switch-label { font-size: 13.5px; color: var(--ink-2); }
.switch:hover .switch-label { color: var(--ink); }

/* disclosure */
.disclosure { border-top: 1px solid var(--line-soft); padding-top: 14px; margin-top: 4px; }
.disclosure > summary {
  display: flex; align-items: center; gap: 9px; cursor: pointer; list-style: none;
  font-size: 13.5px; font-weight: 540; color: var(--ink-2); user-select: none; padding: 4px 0;
}
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary:hover { color: var(--ink); }
.disclosure > summary em { font-style: normal; font-size: 12px; }
.disclosure > * + * { margin-top: 12px; }
.chev { flex: none; width: 7px; height: 7px; border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor;
        transform: rotate(-45deg); transition: transform var(--dur); margin-left: 2px; }
details[open] > summary .chev { transform: rotate(45deg); }

/* ------------------------------------------------------------ 6. the gate */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.gate-card {
  width: min(400px, 100%); padding: 34px 30px 26px; text-align: left;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow), var(--inset-hi);
  animation: rise .5s cubic-bezier(.2,.8,.3,1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
.mark { width: 26px; height: 26px; flex: none; }
.mark-lg { width: 34px; height: 34px; margin-bottom: 18px; }
.mark-lines rect { fill: var(--ink); opacity: .32; }
.mark-bolt { fill: var(--ember); }
.gate-title { font-size: 27px; letter-spacing: -.03em; }
.gate-sub { color: var(--ink-3); font-size: 13.5px; margin: 8px 0 26px; line-height: 1.55; }
.gate-card .micro { margin-bottom: 8px; }
.gate-card .input { margin-bottom: 14px; letter-spacing: .1em; }
.gate-error { color: var(--bad); font-size: 13px; margin: -6px 0 12px; }
.gate-foot { margin-top: 18px; text-align: center; font-size: 10.5px; letter-spacing: .1em; color: var(--ink-3); opacity: .7; }

/* ---------------------------------------------------------- 7. top chrome */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px max(20px, env(safe-area-inset-left)) 14px max(20px, env(safe-area-inset-right));
  border-bottom: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(150%) blur(14px);
  -webkit-backdrop-filter: saturate(150%) blur(14px);
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.wordmark { display: flex; flex-direction: column; font-weight: 620; letter-spacing: -.02em; font-size: 15px; line-height: 1.1; }
.wordmark em { font-style: normal; font-size: 9.5px; letter-spacing: .2em; text-transform: uppercase; color: var(--ink-3); margin-top: 3px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px 7px 10px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  font-size: 12.5px; color: var(--ink-2); transition: border-color var(--dur), color var(--dur);
}
.chip:hover { color: var(--ink); border-color: var(--ink-3); }
.chip-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); flex: none; }
.chip-dot.ok   { background: var(--ok);   box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 18%, transparent); }
.chip-dot.warn { background: var(--warn); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 18%, transparent); }
.chip-dot.bad  { background: var(--bad);  box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 18%, transparent); }

.pop {
  position: fixed; top: 62px; right: 18px; z-index: 60; width: min(340px, calc(100vw - 28px));
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow); overflow: hidden; animation: rise .18s ease both;
}
.pop-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line-soft); }
.pop-body { padding: 6px 14px 14px; font-size: 13px; }
.pop-row { display: flex; gap: 10px; justify-content: space-between; padding: 9px 0; border-bottom: 1px dashed var(--line-soft); }
.pop-row:last-child { border-bottom: 0; }
.pop-row b { font-weight: 560; color: var(--ink-2); font-size: 12.5px; }
.pop-row span { text-align: right; font-family: var(--mono); font-size: 12px; }
.pop-note { margin-top: 10px; padding: 10px 11px; border-radius: var(--r-sm); font-size: 12.5px; line-height: 1.5; }
.pop-note.warn { background: color-mix(in srgb, var(--warn) 12%, transparent); color: var(--warn); }
.pop-note.bad  { background: color-mix(in srgb, var(--bad) 12%, transparent);  color: var(--bad); }
.x { font-size: 20px; line-height: 1; color: var(--ink-3); padding: 2px 6px; border-radius: 6px; }
.x:hover { color: var(--ink); background: var(--surface-2); }

/* -------------------------------------------------------------- 8. layout */
.shell {
  display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 20px;
  max-width: 1240px; margin: 0 auto; padding: 26px max(20px, env(safe-area-inset-left)) 96px;
}
.col-main { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.col-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.card {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 22px; box-shadow: var(--shadow), var(--inset-hi);
  animation: rise .34s cubic-bezier(.2,.8,.3,1) both;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }

/* ------------------------------------------------------------ 9. composer */
.composer .textarea { margin-top: 14px; font-size: 15.5px; max-height: 380px; }
.options {
  display: flex; flex-wrap: wrap; gap: 22px 30px; align-items: flex-start;
  margin: 18px 0 16px; padding: 16px 0; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft);
}
.opt { display: flex; flex-direction: column; gap: 9px; }
.opt-switches { gap: 6px; }
.composer-foot { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 18px; }
.composer-foot .btn-primary { padding: 12px 24px; font-size: 15px; }
.foot-actions { display: flex; align-items: center; gap: 10px; }

/* ---------------------------------------------------------------- 10. run */
.run-meta { display: flex; align-items: center; gap: 10px; }
.badge {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase;
  padding: 4px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-3);
}
.badge.running { color: var(--ember); border-color: color-mix(in srgb, var(--ember) 45%, transparent); background: var(--ember-wash); }
.badge.done    { color: var(--ok);   border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.badge.error, .badge.cancelled { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.run-title { font-size: 20px; }
.run-sub { font-size: 12px; margin-top: 5px; word-break: break-all; }
.run-grid { display: grid; grid-template-columns: 252px minmax(0, 1fr); gap: 22px; margin-top: 20px; }

.stages { list-style: none; margin: 0; padding: 0; }
.stage { position: relative; display: grid; grid-template-columns: 20px 1fr; gap: 12px; padding-bottom: 16px; }
.stage:last-child { padding-bottom: 0; }
.stage::before {                      /* the spine — doubles as a progress track */
  content: ""; position: absolute; left: 9.5px; top: 18px; bottom: -2px; width: 1.5px;
  border-radius: 2px; background: color-mix(in srgb, var(--ink-3) 30%, transparent);
  transition: background var(--dur);
}
.stage:last-child::before { display: none; }
.stage.done::before   { background: color-mix(in srgb, var(--ok) 45%, transparent); }
.stage.active::before { background: linear-gradient(color-mix(in srgb, var(--ember) 55%, transparent),
                                                    color-mix(in srgb, var(--ink-3) 25%, transparent)); }
.node {
  position: relative; z-index: 1; width: 20px; height: 20px; border-radius: 50%;
  border: 1.5px solid var(--line); background: var(--bg-2);
  display: grid; place-items: center; font-size: 10px; color: var(--bg);
  transition: background var(--dur), border-color var(--dur);
}
.stage-label { font-size: 13.5px; color: var(--ink-3); padding-top: 1px; transition: color var(--dur); }
.stage-id { display: block; font-family: var(--mono); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); opacity: .55; margin-top: 3px; }

.stage.done .node { background: color-mix(in srgb, var(--ok) 22%, var(--bg-2)); border-color: color-mix(in srgb, var(--ok) 55%, transparent); }
.stage.done .node::after { content: "✓"; color: var(--ok); font-size: 11px; line-height: 1; }
.stage.done .stage-label { color: var(--ink-2); }
.stage.failed .node { background: color-mix(in srgb, var(--bad) 22%, var(--bg-2)); border-color: color-mix(in srgb, var(--bad) 60%, transparent); }
.stage.failed .node::after { content: "✕"; color: var(--bad); font-size: 10px; line-height: 1; }
.stage.failed .stage-label { color: var(--bad); }
.stage.active .node { background: var(--ember); border-color: var(--ember); animation: pulse 1.9s ease-out infinite; }
.stage.active .stage-label { color: var(--ink); font-weight: 560; }
.stage.active .stage-id { color: var(--ember); opacity: 1; }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ember) 55%, transparent); }
  70%  { box-shadow: 0 0 0 9px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.stage.active .bar { display: block; }
.bar { display: none; position: relative; height: 2px; margin-top: 8px; border-radius: 2px; background: var(--line); overflow: hidden; }
.bar::after {
  content: ""; position: absolute; inset: 0; width: 40%; border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--ember), transparent);
  animation: sweep 1.5s ease-in-out infinite;
}
@keyframes sweep { 0% { transform: translateX(-110%); } 100% { transform: translateX(260%); } }

.logwrap { display: flex; flex-direction: column; min-width: 0; }
.log-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.logpane {
  height: 290px; overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r);
  padding: 12px 13px; font-size: 12px; line-height: 1.65; color: var(--ink-2);
  scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent;
}
.logpane::-webkit-scrollbar { width: 9px; }
.logpane::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 9px; border: 3px solid var(--bg-2); }
.logline { display: grid; grid-template-columns: 58px 1fr; gap: 10px; padding: 1.5px 0; }
.logline .t { color: var(--ink-3); opacity: .65; }
.logline .m { white-space: pre-wrap; word-break: break-word; }
.logline .s { color: var(--ink-3); opacity: .8; }
.logline.warn .m    { color: var(--warn); }
.logline.error .m   { color: var(--bad); }
.logline.success .m { color: var(--ok); }
.logline.empty { color: var(--ink-3); opacity: .6; }
.run-error {
  margin-top: 16px; padding: 12px 14px; border-radius: var(--r-sm); font-size: 13px;
  background: color-mix(in srgb, var(--bad) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--bad) 32%, transparent); color: var(--bad);
}

/* ------------------------------------------------------------- 11. result */
.result-top { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.result-id { min-width: 0; }
.result-title { font-size: 23px; letter-spacing: -.025em; }
.result-sub { color: var(--ink-3); font-size: 14px; margin-top: 6px; }
#result-dir { word-break: break-all; text-align: right; }

.dial { position: relative; width: 116px; height: 116px; flex: none; }
.dial svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.dial circle { fill: none; stroke-width: 8; stroke-linecap: round; }
.dial-track { stroke: var(--line); }
.dial-arc {
  stroke: var(--ember); stroke-dasharray: 326.7; stroke-dashoffset: 326.7;
  transition: stroke-dashoffset 1.1s cubic-bezier(.2,.8,.25,1), stroke .6s ease;
  filter: drop-shadow(0 0 6px color-mix(in srgb, currentColor 0%, transparent));
}
.dial-center { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 1px; }
.dial-num { font-size: 30px; font-weight: 600; letter-spacing: -.04em; line-height: 1; }
.dial-center .micro { font-size: 9px; letter-spacing: .2em; }

.artifacts { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; margin: 22px 0 4px; }
.art {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 56px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r);
  transition: border-color var(--dur), background var(--dur), transform .12s;
}
.art:hover { border-color: var(--ink-3); background: var(--surface-2); }
.art:active { transform: translateY(1px); }
.art .ext {
  flex: none; font-family: var(--mono); font-size: 9.5px; font-weight: 600; letter-spacing: .08em;
  padding: 5px 7px; border-radius: 6px; background: var(--surface-3); color: var(--ink-2);
}
.art .nm { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 520; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.art .dl { flex: none; width: 15px; height: 15px; color: var(--ink-3); }
.art:hover .dl { color: var(--ember); }
.art.primary { border-color: color-mix(in srgb, var(--ember) 38%, transparent); background: var(--ember-wash); }
.art.primary .ext { background: var(--ember); color: var(--ember-ink); }
.art.primary .dl { color: var(--ember); }

.report { margin-top: 18px; }
.report-body {
  margin: 0; max-height: 460px; overflow: auto; white-space: pre-wrap; word-break: break-word;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px; font-size: 12.5px; line-height: 1.7; color: var(--ink-2);
}

/* --------------------------------------------------------- 12. side rail */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.panel > summary {
  display: flex; align-items: center; gap: 10px; padding: 13px 15px; cursor: pointer; list-style: none; user-select: none;
}
.panel > summary::-webkit-details-marker { display: none; }
.panel > summary:hover .micro { color: var(--ink-2); }
.panel > summary .chev { color: var(--ink-3); }
.panel .count { margin-left: auto; font-size: 11px; color: var(--ink-3); }
.panel-body { padding: 0 12px 12px; }
.panel-actions { display: flex; justify-content: flex-end; margin-bottom: 6px; }

.hist { display: flex; flex-direction: column; gap: 4px; }
.hrow {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px;
  padding: 10px 11px; border-radius: var(--r-sm); border: 1px solid transparent; text-align: left; width: 100%;
  transition: background var(--dur), border-color var(--dur);
}
.hrow:hover { background: var(--bg-2); border-color: var(--line); }
.hrow.on { background: var(--ember-wash); border-color: color-mix(in srgb, var(--ember) 32%, transparent); }
.hmain { display: block; width: 100%; min-width: 0; text-align: left; padding: 0; }
.hrow .co { display: block; font-size: 13.5px; font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hrow .ro { display: block; font-size: 12px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.hrow .meta { display: flex; align-items: center; gap: 7px; margin-top: 5px; font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); }
.hrow .sc { padding: 1px 6px; border-radius: 5px; background: var(--surface-3); color: var(--ink-2); }
.hrow .st { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); flex: none; }
.hrow .st.running { background: var(--ember); animation: pulse 1.9s ease-out infinite; }
.hrow .st.done { background: var(--ok); }
.hrow .st.error, .hrow .st.cancelled { background: var(--bad); }
.hrow .kill { opacity: 0; color: var(--ink-3); padding: 6px; border-radius: 6px; line-height: 1; font-size: 15px; }
.hrow:hover .kill, .hrow .kill:focus-visible { opacity: 1; }
.hrow .kill:hover { color: var(--bad); background: var(--surface-2); }

.browse { display: flex; flex-direction: column; gap: 2px; }
.bco > summary, .brun > summary { display: flex; align-items: center; gap: 8px; padding: 8px 10px; cursor: pointer; list-style: none; border-radius: var(--r-sm); font-size: 13px; }
.bco > summary::-webkit-details-marker, .brun > summary::-webkit-details-marker { display: none; }
.bco > summary:hover, .brun > summary:hover { background: var(--bg-2); }
.bco > summary { font-weight: 560; }
.bco .n, .brun .n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bco .c { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); }
.brun { margin-left: 14px; border-left: 1px solid var(--line-soft); }
.brun > summary { font-size: 12px; color: var(--ink-2); font-family: var(--mono); }
.bfile {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px 7px 22px; border-radius: var(--r-sm);
  font-size: 12px; font-family: var(--mono); color: var(--ink-3); min-height: 34px;
}
.bfile:hover { background: var(--bg-2); color: var(--ember); }
.empty-note { padding: 14px 11px; font-size: 12.5px; color: var(--ink-3); text-align: center; }
.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; }
@media (hover: none) { .hrow .kill { opacity: 1; } }

/* ------------------------------------------------- 13. drawer & feedback */
.scrim { position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.55); backdrop-filter: blur(2px); animation: fade .2s ease both; }
@keyframes fade { from { opacity: 0; } }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 80; width: min(620px, 100%);
  display: flex; flex-direction: column; gap: 14px; padding: 22px;
  background: var(--surface); border-left: 1px solid var(--line);
  box-shadow: -30px 0 60px -30px rgba(0,0,0,.7);
  animation: slide .26s cubic-bezier(.2,.8,.3,1) both;
}
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.drawer-title { font-size: 20px; margin-top: 6px; }
.warn-banner {
  padding: 12px 14px; border-radius: var(--r-sm); font-size: 12.5px; line-height: 1.55;
  background: color-mix(in srgb, var(--warn) 11%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 28%, transparent); color: var(--warn);
}
.warn-banner strong { font-weight: 640; }
.profile-text { flex: 1; min-height: 0; resize: none; font-size: 12.5px; line-height: 1.6; }
.drawer-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.drawer-btns { display: flex; gap: 8px; }
#profile-status.ok  { color: var(--ok); }
#profile-status.bad { color: var(--bad); }

.toasts { position: fixed; z-index: 90; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast {
  pointer-events: auto; max-width: min(380px, calc(100vw - 36px));
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 15px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow); font-size: 13.5px; animation: toast-in .24s cubic-bezier(.2,.8,.3,1) both;
}
.toast::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; margin-top: 7px; background: var(--ink-3); }
.toast.ok::before  { background: var(--ok); }
.toast.bad::before { background: var(--bad); }
.toast.out { animation: toast-out .2s ease both; }
@keyframes toast-in  { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(4px) scale(.98); } }

/* --------------------------------------------------------- 14. responsive */
@media (max-width: 1180px) { .run-grid { grid-template-columns: 1fr; gap: 18px; } .logpane { height: 240px; } }
@media (max-width: 980px) {
  .shell { grid-template-columns: minmax(0, 1fr); padding-bottom: 60px; }
  .col-side { order: 2; }
}
@media (max-width: 900px) {
  body { font-size: 15px; }
  .card { padding: 18px 16px; border-radius: 14px; }
  .shell { padding: 18px 14px 48px; gap: 16px; }
  .topbar { padding: 11px 14px; }
  .wordmark em { display: none; }
  /* single column: a flex row cannot shrink a segmented control below its
     label width, which pushed the whole page sideways on a phone */
  .options { display: grid; grid-template-columns: 1fr; gap: 18px; }
  .opt { min-width: 0; width: 100%; }
  .opt .seg { width: 100%; }
  .opt .seg button { flex: 1 1 0; min-width: 0; min-height: 42px; }
  .composer-foot { flex-direction: column-reverse; align-items: stretch; }
  .composer-foot .btn-primary { width: 100%; min-height: 50px; }
  .composer-foot .path { text-align: center; }
  .btn { min-height: 44px; }
  .btn-xs, .btn-icon, .x, .hrow .kill { min-height: 36px; }
  .switch { min-height: 44px; }
  .result-top { flex-direction: column-reverse; align-items: flex-start; gap: 18px; }
  #result-dir { display: none; }
  .artifacts { grid-template-columns: 1fr; }
  .art { min-height: 52px; }
  .toasts { left: 14px; right: 14px; bottom: 14px; align-items: stretch; }
  .toast { max-width: none; }
  .drawer { padding: 18px 14px; }
  .pop { right: 10px; left: 10px; width: auto; }
  .stage { padding-bottom: 14px; }
}
@media (max-width: 420px) { .gate-card { padding: 26px 20px 20px; } .btn-sm { padding: 9px 11px; } }

/* --------------------------------------------------- 15. reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
  .dial-arc { transition: none; }
}
