/* PipeID visual code: tokens, typography and signature details. Loaded after every page stylesheet (only brand.css
   follows; it also holds the @font-face rules). Every colour in the other stylesheets is a var() of these tokens, so the dark theme is a token swap:
   theme.js sets html[data-dark="1"] ("dark", or "auto" on a dark system).

   Rules: 1px borders and 1–2px shadows instead of soft glows; radii 6 / 8 / 12px, no pills; Geist Mono for data
   (pipe ids, formats, sizes, step numbers, credits). Zinc neutrals cover the screen, petrol teal only marks the main
   action, the selected step, pipeline connectors and ids. */

/* ------------------------------------------------------------ tokens */
html[data-dark="1"], .dark {
  color-scheme: dark;
  --bg-page: #09090B;
  --bg-surface: #121215;
  --bg-subtle: #18181B;
  --bg-muted: #1F1F23;
  --bg-inverse: #E4E4E7;
  --fg-inverse: #09090B;
  --border-default: #27272A;
  --border-strong: #3F3F46;

  --text-primary: #FAFAFA;
  --text-secondary: #A1A1AA;
  --text-muted: #71717A;

  --brand-primary: #14B8A6;
  --brand-primary-hover: #2DD4BF;
  --brand-primary-fg: #042F2E;
  --brand-accent: #5EEAD4;
  --brand-tint: rgba(20, 184, 166, 0.12);
  --brand-tint-fg: #5EEAD4;
  --brand-tint-border: rgba(94, 234, 212, 0.35);

  --danger: #F87171;  --danger-tint: rgba(248, 113, 113, 0.12); --danger-border: rgba(248, 113, 113, 0.35);
  --warning: #FBBF24; --warning-tint: rgba(251, 191, 36, 0.12); --warning-border: rgba(251, 191, 36, 0.35);
  --info: #60A5FA;    --info-tint: rgba(96, 165, 250, 0.12);    --info-border: rgba(96, 165, 250, 0.35);

  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-pop: 0 1px 2px rgba(0, 0, 0, 0.5), 0 8px 20px rgba(0, 0, 0, 0.45);
  --canvas-dot: rgba(250, 250, 250, 0.07);
}
/* A dark plate (Pro card, tooltip) keeps light text in both themes: on the primary button the text follows the button. */

/* ------------------------------------------------------------ base and typography */
html, body { background: var(--bg-page); color: var(--text-primary); }
body, button, input, select, textarea { font-family: var(--font-sans); }
h2, h3 { font-weight: 600; letter-spacing: -0.015em; }
button, .button, .text-button { font-weight: 500; }
body .topbar { background: color-mix(in srgb, var(--bg-page) 92%, transparent) !important; backdrop-filter: blur(8px); border-bottom: 1px solid var(--border-default); }
::selection { background: color-mix(in srgb, var(--brand-accent) 30%, transparent); }

/* Data in monospace: ids, formats, sizes, counts, step numbers, credits, code. */
code,
kbd,
pre,
samp,
.pipe-number,
.pipe-type,
.pipe-param,
.pbar-badge,
.pg-badge-text,
.counter,
.file-format,
.file-icon-ext,
.row-size,
.job-size-badge,
.pipeline-format-chip,
.batch-type-chip,
.batch-ext-keep,
.request-file-chip,
.key-countdown,
.compact-credit-example,
.prompt-counter,
.pipeline-chips button,
.account-quota,
.key-hint,
.api-content code {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.pipe-type, .pipe-param, .file-format, .file-icon-ext, .pipeline-format-chip, .batch-type-chip, .request-file-chip,
.job-size-badge, .pbar-badge { font-weight: 500; letter-spacing: 0; }

/* ------------------------------------------------------------ surfaces, controls */
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]), select, textarea {
  border-radius: var(--radius-md);
  border-color: var(--border-default);
  background-color: var(--bg-surface);
  color: var(--text-primary);
}
input:not([type=checkbox]):not([type=radio]):not([type=range]):focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none; border-color: var(--brand-accent); box-shadow: var(--focus-ring);
}
button:focus-visible, a:focus-visible { outline: 2px solid var(--brand-accent); outline-offset: 2px; }
input[type=checkbox], input[type=radio], input[type=range], progress { accent-color: var(--brand-primary); }

/* Primary call to action: petrol, white text; in the dark theme a bright teal with dark text. */
body .primary, body .pipeline-run, body .pro-cta, body .pbar-save:not(.is-clean), body .pbar-api.is-highlight {
  background: var(--brand-primary); border-color: var(--brand-primary); color: var(--brand-primary-fg);
  border-radius: var(--radius-md); box-shadow: var(--shadow-card); font-weight: 500;
}
body .primary:hover:not(:disabled), body .pipeline-run:hover:not(:disabled), body .pro-cta:hover,
body .pbar-save:not(.is-clean):hover:not(:disabled), body .pbar-api.is-highlight:hover:not(:disabled) {
  background: var(--brand-primary-hover); border-color: var(--brand-primary-hover); color: var(--brand-primary-fg);
}
/* Buttons that sit on dark plates and were white-on-dark keep a readable foreground in both themes. */
body .pbar-save:not(.is-clean) *, body .primary * { color: inherit; }

dialog, [role=dialog], .help-dialog { border-radius: var(--radius-lg); }

/* ------------------------------------------------------------ pipeline canvas (signature detail) */
body .pipeline-editor {
  background-color: var(--bg-surface);
  background-image: radial-gradient(circle at 1px 1px, var(--canvas-dot) 1px, transparent 1.2px);
  background-size: 16px 16px;
  background-position: -1px -1px;
}
.pipeline-side { border-radius: var(--radius-lg); box-shadow: var(--shadow-card); }

/* Node: 8px card, mono step number on the left, operation name, settings as chips. */
.pipe-step { border-radius: var(--radius-md); }
.pipe-step:hover { border-color: var(--border-strong); }
.pipe-step.is-open { border-color: var(--brand-accent); box-shadow: 0 0 0 1px var(--brand-accent), var(--shadow-card); }
.pipe-step.is-open .pipe-step-head { background: var(--brand-tint); border-radius: calc(var(--radius-md) - 1px) calc(var(--radius-md) - 1px) 0 0; }
.pipe-step-head { grid-template-columns: 30px minmax(0, 1fr) auto; }
.pipe-number {
  width: 30px; height: 24px; border-radius: var(--radius-sm);
  background: var(--bg-subtle); color: var(--text-muted);
  font-size: 12px; font-weight: 600; letter-spacing: 0;
}
.pipe-step.is-open .pipe-number { background: var(--bg-surface); color: var(--brand-tint-fg); box-shadow: inset 0 0 0 1px var(--brand-tint-border); }
.pipe-number.is-completed { background: var(--brand-tint); color: var(--brand-tint-fg); }
.pipe-number.is-failed { background: var(--danger-tint); color: var(--danger); }
.pipe-number.is-running::after { border-top-color: var(--brand-accent); }
.pipe-step-title b { font-size: 14px; font-weight: 500; }
.pipe-params { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.pipe-param {
  display: inline-flex; align-items: center; min-height: 20px; padding: 1px 7px;
  border: 1px solid var(--border-default); border-radius: var(--radius-sm);
  background: var(--bg-subtle); color: var(--text-secondary);
  font-size: 11px; line-height: 1.4; white-space: nowrap;
}
.pipe-step.is-failed { border-color: var(--danger); }
.pipe-step.is-incomplete { border-color: var(--warning-border); }

/* Connector: a teal line with an arrow head and the type of what flows along it. */
.pipe-line { left: 29.25px; width: 1.5px; background: var(--brand-accent); }
.pipe-link::after {
  left: 26.5px; bottom: 2px; width: 7px; height: 7px;
  border-right: 1.5px solid var(--brand-accent); border-bottom: 1.5px solid var(--brand-accent);
}
.pipe-type {
  margin-left: 24px; padding: 2px 8px; border: 1px solid var(--brand-tint-border); border-radius: var(--radius-sm);
  background: var(--brand-tint); color: var(--brand-tint-fg); font-size: 11px;
}
.pipe-add-row .pipeline-add {
  border: 1px dashed var(--border-strong); border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--bg-surface) 80%, transparent); color: var(--text-secondary); font-weight: 500;
}
.pipe-add-row .pipeline-add:hover:not(:disabled) { border-color: var(--brand-accent); color: var(--brand-tint-fg); background: var(--brand-tint); }
.pipe-end { border-radius: var(--radius-md); background: var(--bg-surface); }
.pipe-end::before { background: var(--brand-primary); }
.pipe-end::after { border-color: var(--brand-primary-fg); }
.pipe-end.is-done { background: var(--brand-tint); border-color: var(--brand-accent); }

/* Branching-plan diagram (pipeline-graph.js) uses the same language. */
.pipeline-graph-svg {
  --pg-node-bg: var(--bg-surface); --pg-file-bg: var(--bg-subtle); --pg-done-bg: var(--brand-tint); --pg-fail-bg: var(--danger-tint);
  --pg-badge-bg: var(--bg-muted); --pg-badge-done-bg: var(--brand-primary); --pg-badge-fail-bg: var(--danger);
}
.pg-edge, .pg-arrow { stroke: var(--brand-accent); }

/* Dropzone */
body .dropzone { border-radius: var(--radius-md); }

/* ------------------------------------------------------------ reduced motion */
@media (prefers-reduced-motion: reduce) {
  body .topbar { backdrop-filter: none; }
}

/* ------------------------------------------------------------ Pro plan: no dark plates, a surface card with a teal frame.
   The old design painted it as a deep green plate with light text; inside it the "inverse" text token falls back to
   the normal text colour, so every rule written for the plate stays readable. */
body .compact-plan-pro {
  --fg-inverse: var(--text-primary);
  background: var(--bg-surface) !important; color: var(--text-primary);
  border: 1px solid var(--brand-accent) !important; box-shadow: 0 0 0 1px var(--brand-accent), var(--shadow-card) !important;
}
body .compact-plan-pro::after { content: none; }
body .compact-plan-pro .primary { color: var(--brand-primary-fg); }
body .compact-plan-pro .account-badge {
  background: var(--brand-tint); color: var(--brand-tint-fg); border: 1px solid var(--brand-tint-border);
}

/* ------------------------------------------------------------ selected states: soft teal, not a solid fill
   (solid petrol is reserved for the main action). */
.tab[aria-pressed="true"], .quick-actions button[aria-pressed="true"],
.compare-toggle-bar button[aria-pressed="true"], .lib-cat.is-active, .api-sheet-tab.is-active,
.pricing-period .pro-billing-toggle button[aria-pressed="true"], .batch-type-chip.active,
.batch-type-chip.batch-all.active, .op-tile[aria-selected="true"], .project-pill.active, .tool-cat-btn.active {
  background: var(--brand-tint) !important; border-color: var(--brand-tint-border) !important;
  color: var(--brand-tint-fg) !important; box-shadow: none !important;
}
.batch-type-chip.active .batch-ext-keep:hover:not(:disabled), .batch-type-chip.batch-all.active:hover {
  background: var(--brand-tint); color: var(--brand-tint-fg);
}
.op-item[aria-selected="true"] .op-ico { background: var(--brand-tint); color: var(--brand-tint-fg); }
body .tab[aria-pressed="true"]:focus-visible { outline: 2px solid var(--brand-accent); }

/* Screen titles that are inputs or custom elements follow the H1 rule. */
.pbar-title input.pbar-name:not([type=file]) { font-weight: 600; letter-spacing: -0.025em; }

/* ------------------------------------------------------------ workspace fixes */
/* "⋯" menus sit above the storage note and the footer; app.js adds .opens-up when there is no room below. */
body .job-more-items, #results-view .request-menu-items, .tplp-menu-list { z-index: 40; }
body .opens-up > :is(.job-more-items, .request-menu-items, .tplp-menu-list) { top: auto; bottom: calc(100% + 5px); }

/* A selected file-type chip ("P7S · 1 ×") reads like "All · 5": tinted fill, tinted text. */
body .batch-type-chip.active :is(.batch-ext-keep, .batch-ext-remove) { color: var(--brand-tint-fg); }
body .batch-type-chip.active .batch-ext-remove { border-left-color: var(--brand-tint-border); }

/* Plan badge in the header is a status, not a button: it must not compete with Save / Run. */
body .account-quota.is-pro { background: var(--brand-tint); border-color: var(--brand-tint-border); color: var(--brand-tint-fg); }
body .account-avatar { background: var(--brand-tint); color: var(--brand-tint-fg); box-shadow: inset 0 0 0 1px var(--brand-tint-border); }
body img.account-avatar-photo { box-shadow: none; background: var(--bg-muted); }

/* Unavailable controls stay readable on the dark canvas: dimmed text, a visible outline. */
body .pipeline-format-chip:disabled { opacity: 1; color: var(--text-muted); border-color: var(--border-strong); border-style: dashed; background: transparent; }
html[data-dark="1"] body .pipeline-format-chip:disabled { background: transparent; border-color: var(--border-strong); }
body .pipe-run-actions .pipe-test:disabled { opacity: 1; color: var(--text-muted); border-color: var(--border-strong); background: transparent; }

/* ------------------------------------------------------------ history (/results) */
/* The page enter animation leaves a transform on #results-view and on the storage note, so each is its own layer:
   the note came later in the page and painted over the open "⋯" menu. The history view stays above it. */
body main.shell > #results-view { position: relative; z-index: 2; }
/* The storage note belongs to Studio and History, where there are files: not on /templates or /api and other pages. */
body.page-route main.shell > .storage-policy { display: none !important; }

/* Checkboxes in the toolbar are 16×16, not stretched to the 40px control height. */
body #results-view .library-controls input[type=checkbox],
body #results-view .history-meta-row input[type=checkbox],
body #results-view input.history-select { flex: none; width: 16px; height: 16px; min-width: 16px; min-height: 0; margin: 0; padding: 0; align-self: center; }

/* Selection bar: count and "Deselect" on the left, actions grouped on the right. */
body #results-view .selection-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-start; gap: 10px 16px; }
body #results-view .selection-bar .selection-info { display: flex; align-items: center; gap: 12px; }
body #results-view .selection-bar .selection-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-left: auto; }
body #results-view .selection-bar .selection-actions > * { width: auto; margin: 0; }

/* One focus ring, and only for the keyboard: a mouse click leaves no frame on the row head or the filters. */
#results-view .request-row-summary:focus:not(:focus-visible),
#results-view .request-filters button:focus:not(:focus-visible) { outline: none; box-shadow: none; }
#results-view .request-row-summary:focus-visible { outline: 2px solid var(--brand-accent); outline-offset: -2px; border-radius: var(--radius-md); box-shadow: none; }
#results-view .request-filters button[aria-pressed=true] { background: var(--brand-tint); border-color: var(--brand-tint-border); color: var(--brand-tint-fg); box-shadow: none; }

/* The trailing teal dot after "Job history" is a leftover of the old style. */
body .results-intro h1 .title-dot { display: none !important; }

/* ------------------------------------------------------------ header credits badge */
/* A quiet status badge: no conic "ring" in the border (it showed as a coloured strip). The level stays readable
   from the border and text colour. */
body .topbar .account-quota[data-level], body .topbar .account-quota[data-level].is-pro {
  border: 1px solid var(--brand-tint-border); background: var(--brand-tint); color: var(--brand-tint-fg); transition: none;
}
body .topbar .account-quota[data-level="warn"] { border-color: var(--warning-border); background: var(--warning-tint); color: var(--warning); }
body .topbar .account-quota[data-level="low"] { border-color: var(--danger-border); background: var(--danger-tint); color: var(--danger); }

/* ---- Step parameters: ready-made values under each field, an outcome placeholder and a one-line hint. */
body .pipeline-fields { align-items: start; gap: 14px 12px; }
body .pipeline-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
body .pipeline-field > label { font-size: 12px; font-weight: 500; color: var(--text-secondary); }
body .pipeline-field input::placeholder { color: var(--text-muted); opacity: 1; }
body .pipeline-suggest { display: flex; flex-wrap: wrap; gap: 4px; }
body .pipeline-suggest-chip {
  display: inline-flex; align-items: baseline; gap: 4px; width: auto; min-height: 0; margin: 0;
  padding: 3px 8px; border: 1px solid var(--border-default); border-radius: 6px; background: var(--bg-subtle);
  color: var(--text-secondary); font-size: 12px; font-weight: 500; line-height: 1.4; box-shadow: none; cursor: pointer;
}
body .pipeline-suggest-chip small { font-size: 11px; font-weight: 400; color: var(--text-muted); }
body .pipeline-suggest-chip:hover:not(:disabled) { border-color: var(--border-strong); background: var(--bg-muted); color: var(--text); }
body .pipeline-suggest-chip.is-active { border-color: var(--brand-tint-border); background: var(--brand-tint); color: var(--brand-tint-fg); }
body .pipeline-suggest-chip.is-active small { color: var(--brand-tint-fg); opacity: .75; }
body .pipeline-suggest-chip:focus:not(:focus-visible) { outline: none; }
body .pipeline-suggest-chip:disabled { opacity: .5; cursor: default; }
body .pipeline-field-hint { font-size: 11px; line-height: 1.4; color: var(--text-muted); }
