/* ============================================================================
   ГосЗадание — local layer on top of styles.css
   styles.css is a verbatim copy of the scribe design system and must stay so:
   then it can be re-synced by overwriting. Everything of our own lives here and
   is written against the theme tokens only (no hardcoded colours except the
   two select chevrons, which a data-URI cannot take from a variable).
   ========================================================================== */

/* --------------------------------------------------------------- toasts -- */
/* scribe's CSS only knows ok/err, while every caller passes success/error. */
.toast.success { border-left-color: var(--ok); }
.toast.error   { border-left-color: var(--danger); }

/* --------------------------------------------------------------- inputs -- */
/* Same rule as styles.css (text/password/search/number), for the input types
   it does not list. Each <input> carries an explicit type for this reason. */
input[type="date"],
input[type="datetime-local"],
input[type="email"],
input[type="url"] {
  width: 100%;
  background: var(--chip);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  font-size: 14.5px;
  font-family: inherit;
  transition: border-color .18s ease, background .18s ease, box-shadow .18s ease;
}
input[type="date"]:hover,
input[type="datetime-local"]:hover,
input[type="email"]:hover,
input[type="url"]:hover { border-color: var(--line-2); }
input[type="date"]:focus,
input[type="datetime-local"]:focus,
input[type="email"]:focus,
input[type="url"]:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface-2);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Locked fields (pinned in the environment, read-only role) stay readable. */
input:disabled, textarea:disabled, select:disabled {
  color: var(--muted);
  cursor: not-allowed;
  opacity: .85;
}
input:disabled:hover, textarea:disabled:hover, select:disabled:hover { border-color: var(--line); }
.switch.disabled { cursor: not-allowed; opacity: .62; }
.switch.disabled:hover { border-color: var(--line); background: var(--chip); }

/* The chevron in styles.css is a fixed #8A8A93; tie it to --muted-2 per theme. */
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239A9AA3' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}
:root[data-theme="light"] select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2362626C' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}
select.sm { padding: 7px 34px 7px 11px; font-size: 12.5px; border-radius: var(--r-xs); width: auto; }

/* Sentence-like labels (setting descriptions) read badly in uppercase. */
label.plain {
  text-transform: none;
  letter-spacing: normal;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

/* ---------------------------------------------------------- file upload -- */
/* Use the ready .dropzone + .file-pill; the native input is only a trigger. */
.dropzone input[type="file"],
input[type="file"].file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  pointer-events: none;
}
.dropzone:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ------------------------------------------------------- quote highlight -- */
.preview mark, mark.quote {
  background: var(--accent-soft);
  color: var(--text);
  border-radius: 4px;
  padding: 0 2px;
}

/* ----------------------------------------------------------- pagination -- */
.pager { margin-top: 14px; }
.card.flush .pager { margin-top: 0; padding: 12px 22px 16px; border-top: 1px solid var(--hair); }
.pager-info { font-family: var(--font-mono); font-size: 12px; color: var(--faint); }

/* --------------------------------------------------------- notes / tags -- */
.warn-box {
  background: var(--warn-soft);
  border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
  border-left-width: 3px;
  color: var(--text);
  padding: 12px 16px;
  border-radius: var(--r-xs);
  font-size: 13.5px;
  line-height: 1.55;
}
.tags { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.field-hint .tags, .switch-hint .tags { margin-left: 4px; vertical-align: middle; }
.badge.xs { padding: 2px 8px 2px 7px; font-size: 10.5px; gap: 5px; }
.badge.xs::before { width: 5px; height: 5px; }
.badge.xs.plain { padding: 2px 8px; }

/* ---------------------------------------------------------------- forms -- */
.stack > * + * { margin-top: 14px; }
.form-foot { margin-top: 18px; }
.btn-link {
  background: transparent;
  border: none;
  color: var(--accent);
  padding: 0;
  font-size: 12.5px;
  font-weight: 600;
  box-shadow: none;
}
.btn-link:hover { background: transparent; color: var(--accent-2); transform: none; }

/* ---------------------------------------------------------------- admin -- */
/* Elements whose data-roles excludes the current role (set by gz-admin.js);
   a class of its own so it never fights with .hidden toggled by other code. */
.role-hidden { display: none !important; }

#whoami { max-width: 230px; overflow: hidden; text-overflow: ellipsis; }
.pane-head { margin-bottom: 16px; }
#overview-blocks > * { margin-top: 18px; }
input.sm { padding: 7px 11px; font-size: 12.5px; border-radius: var(--r-xs); }
#audit-filter { width: 260px; max-width: 100%; }

/* Like .badge.running in colour, without the blinking dot: a static warning. */
.badge.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: var(--warn-soft); }

/* Settings: the save bar sticks to the bottom of the viewport while the long
   list scrolls, so "Сохранить" is always one click away. */
.save-bar {
  position: sticky;
  bottom: 16px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
}
.save-bar.dirty { border-color: var(--accent); }
.save-bar.dirty #settings-dirty { color: var(--accent); font-weight: 600; }
.card .section-label { margin: 22px 0 12px; }
.card .section-label:first-child { margin-top: 0; }
.secret-value { display: flex; gap: 8px; align-items: center; }
.secret-value input { flex: 1; min-width: 0; }
td .cell-list { display: flex; flex-wrap: wrap; gap: 5px; }
td .cell-detail {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--faint);
  max-width: 340px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
td.actions .row { justify-content: flex-end; flex-wrap: nowrap; }
.you { color: var(--accent); font-family: var(--font-mono); font-size: 11px; font-weight: 600; margin-left: 6px; }
#users-body .cell-main { white-space: nowrap; }
.auth-card .card-note { text-align: center; }

/* ------------------------------------------------------------ keywords -- */
/* Bare switch for table cells: the track only, no card around it. */
.switch.compact { padding: 0; border: none; background: transparent; gap: 0; vertical-align: middle; }
.switch.compact:hover, .switch.compact.on { border: none; background: transparent; }

/* Filter toggles: a .chip that holds a hidden checkbox. */
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: 7px 11px;
  border-radius: var(--r-xs);
  border: 1px solid var(--line);
  background: var(--chip);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: normal;
  text-transform: none;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: border-color .18s ease, background .18s ease, color .18s ease;
}
.filter-chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.filter-chip::before {
  content: "";
  width: 12px;
  height: 12px;
  flex: none;
  border-radius: 4px;
  border: 1.5px solid var(--line-2);
  background: var(--surface-2);
}
.filter-chip:hover { border-color: var(--line-2); color: var(--text); }
.filter-chip.on { border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: var(--accent-soft); color: var(--accent); }
.filter-chip.on::before { border-color: var(--accent); background: var(--accent); box-shadow: inset 0 0 0 2px var(--surface); }
.filter-chip:focus-within { box-shadow: 0 0 0 3px var(--accent-soft); }

.kw-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 0 22px 16px; }
.kw-filters input[type="search"] { width: 260px; max-width: 100%; }
.kw-filters select.sm { min-width: 150px; }
.kw-title { font-weight: 600; line-height: 1.4; min-width: 220px; }
#kw-head .status-strip { margin-bottom: 8px; }
#kw-head .kw-note { margin: 0 0 4px; }
#kw-nav { margin: 18px 0 16px; flex-wrap: wrap; }
#kw-nav .count { margin-left: 6px; font-family: var(--font-mono); font-size: 11px; color: var(--accent); }
tr.clickable:focus-visible td { background: var(--accent-soft); }

/* Read-only text from the data (titles, descriptions): escaped, wraps, scrolls. */
.text-box {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 11px 14px;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 220px;
  overflow: auto;
}
textarea { resize: vertical; line-height: 1.55; }

/* Synonym usage examples (moderation queue, keyword card). */
details.examples summary { cursor: pointer; color: var(--accent); font-size: 12.5px; font-weight: 600; white-space: nowrap; }
details.examples[open] summary { margin-bottom: 8px; }
.example {
  border-left: 2px solid var(--line-2);
  padding: 4px 0 4px 10px;
  margin-bottom: 8px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--muted-2);
  max-width: 460px;
  white-space: normal;
  word-break: break-word;
}
.example .cell-main { font-size: 12.5px; }

.kw-filters input[type="date"] { width: auto; padding: 6px 10px; font-size: 12.5px; border-radius: var(--r-xs); }

/* ------------------------------------------------------- checks / cards -- */
.ck-reason { font-size: 12px; color: var(--muted-2); margin-top: 5px; max-width: 320px; line-height: 1.45; }
.modal-body .preview.raw.boxed, .preview.raw.boxed {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 14px 16px;
  max-height: 440px;
  overflow: auto;
  font-family: var(--font-ui);
  font-size: 13.5px;
  color: var(--muted-2);
}
.preview.raw .ck-title { color: var(--text); font-weight: 700; font-size: 14.5px; }
details.raw-json pre.preview.raw.boxed, pre.preview.raw.boxed.diff { font-family: var(--font-mono); font-size: 12px; }

/* Ten tabs: a little less padding keeps them on one row at the 1180px shell. */
.tabs .tab { padding: 9px 12px; gap: 7px; }
details.raw-json summary { cursor: pointer; color: var(--accent); font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.quote-text { color: var(--muted-2); font-size: 12.5px; }
.text-box.tall { max-height: 360px; }
.metric-line { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; line-height: 1.7; }
.metric-line span { color: var(--faint); }
.metric-line b { color: var(--text); font-weight: 600; white-space: nowrap; }
.metric-tree tr.mt-group td { color: var(--text); font-weight: 700; background: var(--chip); }
.unused-list { max-height: 260px; overflow: auto; }

/* Selection checkboxes (runs, prompt versions, key value codes). */
input[type="checkbox"].pick { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); cursor: pointer; vertical-align: middle; }
.code-list {
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  padding: 4px;
}
.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0;
  padding: 7px 10px;
  border-radius: var(--r-xs);
  text-transform: none;
  letter-spacing: normal;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted-2);
  cursor: pointer;
}
.check-row:hover { background: var(--chip-hover); color: var(--text); }
.check-row .mono { font-size: 12px; color: var(--faint); min-width: 38px; }
.check-row input { margin-top: 2px; }

/* Unified diff of prompt versions. */
.diff .add { color: var(--ok); }
.diff .del { color: var(--danger); }
.diff .hunk { color: var(--accent); }
.diff .meta { color: var(--faint); }
pre.diff { font-family: var(--font-mono); font-size: 12px; }

/* ---------------------------------------------------------------- charts -- */
/* Own SVG on theme tokens: one axis, thin bars, recessive grid. */
.chart { display: block; width: 100%; height: auto; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--faint-2); font-family: var(--font-mono); font-size: 10px; }
.chart .s-ok, .legend .s-ok { fill: var(--ok); background: var(--ok); }
.chart .s-fail, .legend .s-fail { fill: var(--accent); background: var(--accent); }
.chart .s-other, .legend .s-other { fill: var(--faint); background: var(--faint); }
.chart .s-main, .legend .s-main { fill: var(--accent); background: var(--accent); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover { fill: var(--chip-hover); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend b { color: var(--text); font-family: var(--font-mono); font-weight: 600; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.spark { width: 110px; height: 24px; display: block; }
.spark polyline { fill: none; stroke: var(--accent); stroke-width: 1.6; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.chart-tip {
  position: fixed;
  z-index: 300;
  pointer-events: none;
  white-space: pre;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r-xs);
  box-shadow: var(--shadow-md);
  padding: 8px 11px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--text);
}

.dropzone:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.dropzone.compact { padding: 22px 18px; }
.file-pill .fp-clear { margin-left: auto; }

@media (max-width: 620px) {
  #whoami { display: none !important; }
  .btn-text { display: none; }
}
@media (max-width: 420px) {
  #health-text { display: none; }
}

/* ------------------------------------------------------- /docs contents -- */
/* Was an inline <style> in scribe/ui.py (DOCS_PAGE). */
#toc { display: flex; flex-direction: column; gap: 1px; }
#toc a {
  display: block;
  padding: 7px 10px;
  border-radius: var(--r-xs);
  border-left: 2px solid transparent;
  color: var(--muted-2);
  font-size: 13px;
  line-height: 1.4;
  transition: color .15s ease, background .18s ease, border-color .18s ease;
}
#toc a:hover { color: var(--text); background: var(--chip); }
#toc a.active {
  color: var(--accent);
  background: var(--accent-soft);
  border-left-color: var(--accent);
}
#toc a.sub { padding-left: 22px; font-size: 12.5px; color: var(--faint); }
#toc a.sub:hover { color: var(--text); }
#toc a.sub.active { color: var(--accent); }

/* A heading must not slide under the sticky top bar when jumped to. */
.preview h1, .preview h2, .preview h3 { scroll-margin-top: 86px; }

#doc-row { align-items: flex-start; gap: 20px; }
#toc-card { flex: 0 0 250px; position: sticky; top: 86px; max-height: calc(100vh - 120px); overflow: auto; }
#doc-card { min-width: 0; }

@media (max-width: 900px) {
  #doc-row { flex-direction: column; }
  #toc-card { position: static; flex: 1 1 auto; width: 100%; max-height: none; }
}
