/* ==========================================================================
   Fernwork One · Text, Security and Utilities tool bodies (one shared sheet).
   Tokens only (assets/kit/tokens.css). Loaded after assets/kit/components.css.
   Pattern: .qt (tool) > .qt-bar (one row of actions/options) + .qt-pane (card with a head and a field)
   + .qt-card (form card) + .qt-more (inline "More options" disclosure; bottom sheet on phones).
   ========================================================================== */

.qt { container: qt / inline-size; display: flex; flex-direction: column; gap: var(--space-3); min-width: 0; font-family: var(--font-ui); color: var(--text-1); }
.qt--narrow { max-width: var(--page-max); }
.qt :where(h3, h4, p) { margin: 0; }
.qt .hidden { display: none !important; }

/* Action/option row */
.qt-bar { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); min-height: var(--control-h); }
.qt-bar__end { margin-left: auto; display: inline-flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.qt-bar__sep { width: 1px; align-self: stretch; margin: 4px var(--space-1); background: var(--border-subtle); }
.qt-inline { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); color: var(--text-2); white-space: nowrap; }
.qt-inline > .fw-select, .qt-inline > .fw-input { width: auto; }
.qt :is(select).fw-select.qt-select { width: auto; min-width: 0; height: var(--control-h-sm); font-size: var(--text-sm); padding-left: 10px; }
.qt .fw-toggle { font-size: var(--text-sm); color: var(--text-1); }
.qt .fw-check { font-size: var(--text-sm); }
.qt-label { display: block; font-size: var(--text-sm); line-height: var(--lh-sm); font-weight: 500; color: var(--text-1); margin: 0 0 6px; }
.qt-hint { font-size: var(--text-xs); line-height: var(--lh-xs); color: var(--text-3); }
.qt-stack { display: flex; flex-direction: column; gap: var(--space-3); min-width: 0; }
.qt-row { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2) var(--space-4); }

/* Grids (container queries: the rail and inspector change the width, not the viewport) */
.qt-grid2 { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-3); align-items: start; }
.qt-grid3 { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-3); align-items: end; }
@container qt (min-width: 720px) {
  .qt-grid2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .qt-grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.qt-grid2 > .qt-pane { height: 100%; }
.qt-rx-out { min-height: 220px; max-height: 420px; }
/* Stacked panes (phones, narrow columns): a 14–18 row input pushed its output a whole screen down. Keep each field to
   about a third of the screen; it still grows with the resize handle. */
@container qt (max-width: 719px) {
  .qt .qt-pane > textarea.qt-field { height: clamp(7.5rem, 30dvh, 15rem); }
  /* Where supported the field starts small and grows with its text instead. */
  @supports (field-sizing: content) {
    .qt .qt-pane > textarea.qt-field { field-sizing: content; height: auto; min-height: 7.5rem; max-height: 55dvh; }
  }
  .qt-rx-out { min-height: 7.5rem; }
  .qt .qt-ascii:empty { min-height: 6rem; }
  /* Password generator: the result comes first, then Generate, then the options. */
  .qt-pw-grid > .qt-stack { display: contents; }
  .qt-pw-grid > #pw-results { order: -2; }
  .qt-pw-grid .qt-pw-actions { order: -1; }
}

/* Pane: card with a head (label + actions) and a borderless field */
.qt-pane { position: relative; display: flex; flex-direction: column; min-width: 0; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--surface-1); overflow: hidden; }
.qt-pane:focus-within { border-color: var(--border-strong); }
/* The borderless fields have no outline of their own: the pane shows the focus ring. */
.qt-pane:has(.qt-field:focus) { border-color: var(--accent-fill); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-fill) 18%, transparent); }
.qt-pane.is-drop { border-color: var(--accent-fill); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-fill) 18%, transparent); }
.qt-pane__head { display: flex; align-items: center; gap: var(--space-2); min-height: 44px; padding: 4px 6px 4px 14px; border-bottom: 1px solid var(--border-subtle); background: var(--surface-2); }
.qt-pane__title { margin: 0; font-size: var(--text-sm); font-weight: 600; color: var(--text-1); white-space: nowrap; cursor: default; }
label.qt-pane__title { cursor: pointer; }
.qt-pane__meta { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--text-sm); color: var(--text-3); font-variant-numeric: tabular-nums; }
.qt-pane__actions { margin-left: auto; display: inline-flex; align-items: center; gap: 2px; flex: none; }
.qt-pane__actions .fw-btn { margin-left: 4px; }
.qt-pane > .qt-pane__error { margin: var(--space-3) var(--space-3) 0; }
.qt-pane__body { padding: var(--space-3) var(--space-4); }
.qt-pane__foot { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); padding: 8px 10px 8px 14px; border-top: 1px solid var(--border-subtle); }
.qt-pane :is(textarea, input).qt-field {
  display: block; width: 100%; min-height: 0; margin: 0; padding: 12px 14px; border: 0; border-radius: 0; box-shadow: none;
  background: transparent; color: var(--text-1); font: 400 13px/20px var(--font-mono); tab-size: 2; resize: vertical; outline: none;
  font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0;
}
.qt-pane :is(textarea, input).qt-field:focus { border: 0; box-shadow: none; }
.qt-pane :is(textarea, input).qt-field[readonly] { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.qt-pane :is(textarea).qt-field--prose { font: 400 15px/24px var(--font-ui); }
.qt-pane :is(textarea, input).qt-field::placeholder { color: var(--text-3); }
.qt-pane > .qt-field + .qt-field { border-top: 1px solid var(--border-subtle); }
@media (pointer: coarse) { .qt-pane :is(textarea, input).qt-field { font-size: var(--text-md); } }

/* Card (forms, results) */
.qt-card { min-width: 0; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--surface-1); padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); }
.qt-card__title { font-size: var(--text-sm); font-weight: 600; color: var(--text-1); }
.qt-card__head { display: flex; align-items: center; gap: var(--space-2); min-height: 28px; }
.qt-card__head .qt-card__title { flex: 1; }
.qt-card--sunken { background: var(--surface-2); }

/* Label · control rows inside a card (Password, QR, Timestamp) */
.qt-rows { display: flex; flex-direction: column; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--surface-1); }
.qt-rows .qt-r { display: grid; grid-template-columns: minmax(96px, 160px) minmax(0, 1fr); align-items: center; gap: var(--space-2) var(--space-4); min-height: 52px; padding: 8px var(--space-4); border-top: 1px solid var(--border-subtle); }
.qt-rows > .qt-r:first-child, .qt-rows > :first-child > .qt-r:first-child { border-top: 0; }
.qt-r__label { font-size: var(--text-sm); font-weight: 500; color: var(--text-1); }
.qt-r__label small { display: block; font-weight: 400; color: var(--text-3); font-size: var(--text-xs); }
.qt-r__ctl { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2) var(--space-3); min-width: 0; }
.qt-r__ctl > :is(input, select, textarea).fw-input, .qt-r__ctl > :is(select).fw-select { flex: 1 1 200px; }
@media (max-width: 639px) { .qt-rows .qt-r { grid-template-columns: minmax(0, 1fr); gap: 6px; } }

/* Kit slider with the value on the label row (range below); .qt-range = range and value on one row */
.qt .fw-slider { flex: 1 1 220px; min-width: 0; }
.qt .fw-slider.qt-range { display: flex; align-items: center; gap: var(--space-3); }
.qt .fw-slider.qt-range input[type="range"] { flex: 1; min-width: 0; }
.qt .fw-slider.qt-range .fw-slider__value { min-width: 36px; font-size: var(--text-base); font-weight: 600; color: var(--text-1); }

/* Monospace output well */
.qt-out { position: relative; min-width: 0; border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); background: var(--surface-2);
  padding: 10px 12px; font: 400 13px/20px var(--font-mono); color: var(--text-1); white-space: pre-wrap; overflow-wrap: anywhere; overflow: auto;
  font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }
.qt-out:empty::before { content: attr(data-empty); color: var(--text-3); font-family: var(--font-ui); }
.qt-pane > .qt-out { border: 0; border-radius: 0; background: transparent; }

/* Inline error / status lines (engine writes plain text into them) */
.qt-error { padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--danger-border); background: var(--danger-bg); color: var(--danger); font: 500 var(--text-sm)/var(--lh-sm) var(--font-mono); overflow-wrap: anywhere; }
.qt-error--ui { font-family: var(--font-ui); }
.qt-warning { padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--warning-border); background: var(--warning-bg); color: var(--warning); font-size: var(--text-sm); }
.qt-status { font-size: var(--text-sm); color: var(--text-2); font-variant-numeric: tabular-nums; }

/* Verdict badges written by the engines (legacy .badge classes mapped onto kit verdicts) */
.qt .badge { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; height: auto; padding: 4px 12px 4px 10px !important; border-radius: var(--radius-pill); border: 1px solid var(--border-subtle);
  background: var(--surface-sunken); color: var(--text-1); font: 600 var(--text-sm)/var(--lh-sm) var(--font-ui) !important; white-space: normal; text-transform: none; letter-spacing: 0; }
.qt .badge-success { color: var(--success); background: var(--success-bg); border-color: var(--success-border); }
.qt .badge-danger { color: var(--danger); background: var(--danger-bg); border-color: var(--danger-border); }
.qt .badge-primary { color: var(--accent-text); background: var(--accent-subtle-bg); border-color: var(--accent-border); font: 500 12px/18px var(--font-mono) !important; min-height: 22px; padding: 1px 8px !important; }
.qt .badge .fw-icon, .qt .badge svg { width: 16px; height: 16px; flex: none; }

/* More options: inline disclosure that pushes content down; bottom sheet on phones */
.qt-more-btn[aria-expanded="true"] { background: var(--surface-active); color: var(--text-1); }
.qt-more-btn .qt-more-btn__sum { color: var(--text-3); font-weight: 400; }
.qt-more { border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--surface-2); padding: var(--space-3) var(--space-4); display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3) var(--space-5); }
.qt-more__head { display: none; }
.qt-more--stack { flex-direction: column; align-items: stretch; }
.qt-more .fw-field { min-width: 180px; }
.qt-sheet-scrim { position: fixed; inset: 0; z-index: 60020; /* above the app bar (60000), like the kit's top-layer sheets */ background: var(--scrim); animation: fw-fade-in var(--dur-2) var(--ease-out); }
@media (max-width: 639px) {
  .qt-more.is-sheet {
    position: fixed; z-index: 60021; inset: auto 0 0 0; margin: 0; max-height: 80dvh; overflow: auto; overscroll-behavior: contain;
    border-radius: 16px 16px 0 0; border-width: 1px 0 0; background: var(--surface-overlay); box-shadow: var(--shadow-3);
    padding: 0 var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom)); flex-direction: column; align-items: stretch; gap: var(--space-3);
    animation: fw-sheet-in var(--dur-3) var(--ease-out);
  }
  .qt-more.is-sheet .qt-more__head { display: flex; align-items: center; gap: var(--space-2); position: sticky; top: 0; z-index: 1; margin: 0 calc(-1 * var(--space-4)); padding: var(--space-3) var(--space-2) var(--space-2) var(--space-4); background: var(--surface-overlay); }
  .qt-more.is-sheet .qt-more__title { flex: 1; font-size: var(--text-md); font-weight: 600; }
}

/* Toggle-chip built from a real checkbox (regex flags) */
.qt-flags { display: flex; flex-wrap: wrap; gap: 4px; }
.qt-flag { position: relative; display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: var(--radius-sm); border: 1px solid var(--border-subtle);
  background: var(--surface-1); color: var(--text-2); font-size: var(--text-sm); cursor: pointer; user-select: none; white-space: nowrap; }
.qt-flag input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.qt-flag b { font: 600 13px/1 var(--font-mono); color: var(--text-1); }
@media (hover: hover) { .qt-flag:hover { border-color: var(--border-strong); } }
.qt-flag:has(input:checked) { background: var(--accent-subtle-bg); border-color: var(--accent-border); color: var(--accent-text); }
.qt-flag:has(input:checked) b { color: var(--accent-text); }
.qt-flag:has(input:focus-visible) { outline: 2px solid var(--accent-ring); outline-offset: 2px; }
.qt-flag:has(input:disabled) { opacity: .45; cursor: not-allowed; }
@media (pointer: coarse) { .qt-flag { height: 44px; } }

/* Big pattern field "/ pattern /flags" */
.qt-rx { display: flex; align-items: stretch; min-height: 48px; border: 1px solid var(--border-strong); border-radius: var(--radius-md); background: var(--surface-1); overflow: hidden; box-shadow: var(--shadow-1); }
.qt-rx:focus-within { border-color: var(--accent-fill); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-fill) 20%, transparent); }
.qt-rx__slash { display: grid; place-items: center; padding: 0 4px 0 14px; color: var(--text-3); font: 500 18px/1 var(--font-mono); }
.qt-rx__flags { display: grid; place-items: center; padding: 0 14px 0 2px; color: var(--accent-text); font: 600 16px/1 var(--font-mono); min-width: 24px; }
.qt-rx :is(input).qt-rx__in { flex: 1; min-width: 0; height: auto; border: 0; border-radius: 0; outline: 0; box-shadow: none; background: transparent; color: var(--text-1); font: 500 16px/1 var(--font-mono); padding: 0 4px;
  font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }
.qt-rx :is(input).qt-rx__in:focus { border: 0; box-shadow: none; }

/* Highlighted matches / diff rows */
.qt mark { background: var(--mark-bg, color-mix(in srgb, var(--warning) 26%, transparent)); color: inherit; border-radius: 2px; }
.qt-diff { max-height: 520px; overflow: auto; font: 400 13px/20px var(--font-mono); font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }
.qt-diff .table-wrapper { border: 0; border-radius: 0; margin: 0; overflow: visible; }
.qt-diff table { width: 100%; border-collapse: collapse; font: inherit; }
.qt-diff th { position: sticky; top: 0; z-index: 1; padding: 6px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border-subtle); text-align: left; font: 600 var(--text-xs)/var(--lh-xs) var(--font-ui); color: var(--text-2); }
.qt-diff td { padding: 1px 10px; border: 0; vertical-align: top; color: var(--text-1); }
.qt-diff td:nth-child(odd) { text-align: right; color: var(--text-3) !important; background: var(--surface-1); border-right: 1px solid var(--border-subtle); font-size: var(--text-xs); }
.qt-diff td:nth-child(3) { border-left: 1px solid var(--border-strong); }
.qt-diff > div { padding: 1px 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.qt-diff [data-collapsed-count] { background: var(--surface-sunken) !important; color: var(--text-3) !important; font: 500 var(--text-xs)/26px var(--font-ui); text-align: center; }
.qt-diff mark { background: color-mix(in srgb, var(--warning) 32%, transparent); }

/* Tables (regex groups, hash results) */
.qt-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.qt-table th { text-align: left; font-weight: 500; color: var(--text-2); padding: 8px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border-subtle); white-space: nowrap; }
.qt-table td { padding: 8px 12px; border-bottom: 1px solid var(--border-subtle); color: var(--text-1); vertical-align: top; }
.qt-table tr:last-child td { border-bottom: 0; }
.qt-table .text-mono { font-family: var(--font-mono); font-size: var(--text-xs); overflow-wrap: anywhere; }
.qt-table-wrap { overflow: auto; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--surface-1); }

/* Stats (Word Count) */
.qt-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--border-subtle); overflow: hidden; }
@container qt (min-width: 720px) { .qt-stats { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.qt-stat { display: flex; flex-direction: column; gap: 2px; padding: var(--space-3) clamp(var(--space-2), 3cqi, var(--space-4)); background: var(--surface-1); min-width: 0; }
.qt-stat__v { font-size: var(--text-xl); line-height: var(--lh-xl); font-weight: 600; letter-spacing: var(--tracking-tight); font-variant-numeric: tabular-nums; color: var(--text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qt-stat__l { font-size: var(--text-xs); color: var(--text-3); }

/* Choice chips that act as buttons (Case Converter) */
.qt-choices { display: flex; flex-wrap: wrap; gap: 6px; }
.qt-choices .fw-chip { height: 32px; cursor: pointer; }
.qt-choices .fw-chip.is-last { background: var(--accent-subtle-bg); color: var(--accent-text); border-color: var(--accent-border); }

@media (pointer: coarse) { .qt-choices .fw-chip { height: 44px; } }

/* Dropzone / file intake rows */
.qt-drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-2); min-height: 160px; padding: var(--space-6); text-align: center; cursor: pointer;
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius-md); background: var(--surface-2); color: var(--text-2); transition: border-color var(--dur-2) var(--ease-out), background var(--dur-2) var(--ease-out); }
.qt-drop.drag-over { border-color: var(--accent-fill); background: color-mix(in srgb, var(--accent-subtle-bg) 60%, var(--surface-2)); }
@media (hover: hover) { .qt-drop:hover { border-color: var(--accent-fill); background: color-mix(in srgb, var(--accent-subtle-bg) 60%, var(--surface-2)); } }
.qt-drop:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: 3px; }
.qt-drop__icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; background: var(--surface-1); border: 1px solid var(--border-subtle); color: var(--accent-text); }
.qt-drop__title { font-size: var(--text-md); font-weight: 600; color: var(--text-1); }
.qt-drop__sub { font-size: var(--text-sm); color: var(--text-3); }

/* Determinate progress written by engines into a native <progress> */
.qt progress { appearance: none; -webkit-appearance: none; width: 100%; height: 6px; border: 0; border-radius: 6px; background: var(--surface-active); overflow: hidden; }
.qt progress::-webkit-progress-bar { background: var(--surface-active); border-radius: 6px; }
.qt progress::-webkit-progress-value { background: var(--accent-fill); border-radius: 6px; transition: width var(--dur-2) var(--ease-out); }
.qt progress::-moz-progress-bar { background: var(--accent-fill); border-radius: 6px; }

/* Engine spinners (legacy .spinner) inside tables */
.qt .spinner { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--surface-active); border-top-color: var(--accent-fill); animation: fw-spin .7s linear infinite; vertical-align: middle; }

/* Busy button: label stays readable, a spinner leads it */
.qt .fw-btn.qt-busy { pointer-events: none; }
.qt .fw-btn.qt-busy::before { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: fw-spin .7s linear infinite; }

/* Copy flash on text buttons uses the kit (.is-copied) */

/* ───── Text tools specifics ───── */
.qt-banner-out :is(textarea).qt-field { font-family: "Courier New", ui-monospace, monospace; white-space: pre; overflow: auto; line-height: 1.15; }
.qt-ascii { min-height: 360px; max-height: 640px; overflow: auto; margin: 0; padding: var(--space-3); background: #0f0f12; color: #e5e5e5; border-radius: 0 0 var(--radius-md) var(--radius-md);
  font-family: "Courier New", ui-monospace, monospace; font-size: var(--text-2xs); line-height: 1; white-space: pre; font-variant-ligatures: none; }
.qt-ascii:empty { display: grid; place-items: center; min-height: 200px; background: var(--surface-sunken); }
.qt-ascii:empty::before { content: attr(data-empty); color: var(--text-3); font: 400 var(--text-sm)/1.4 var(--font-ui); white-space: normal; text-align: center; padding: 0 var(--space-4); }
.qt-file { display: flex; align-items: center; gap: var(--space-3); min-height: 56px; padding: 8px 8px 8px 12px; border: 1px dashed var(--border-strong); border-radius: var(--radius-md); background: var(--surface-2); }
.qt-file.drag-over { border-color: var(--accent-fill); border-style: solid; background: var(--accent-subtle-bg); }
.qt-file__thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; background: var(--surface-sunken); border: 1px solid var(--border-subtle); flex: none; display: grid; place-items: center; color: var(--text-3); overflow: hidden; }
.qt-file__thumb img { width: 100%; height: 100%; object-fit: cover; }
.qt-file__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.qt-file__name { font-size: var(--text-sm); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qt-file__meta { font-size: var(--text-xs); color: var(--text-3); }
.qt-file input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* ───── Security specifics ───── */
.qt-hashes .qt-table td:first-child { width: 1%; white-space: nowrap; }
.qt-hashes .qt-table td:last-child { width: 1%; }
.qt-legacy { display: block; font-size: var(--text-xs); color: var(--text-3); font-weight: 400; }
.qt-pw-list { display: flex; flex-direction: column; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); overflow: hidden; background: var(--surface-1); }
.qt-pw-list .file-item { display: flex; align-items: center; gap: var(--space-2); margin: 0; padding: 10px 6px 10px 14px; border: 0; border-top: 1px solid var(--border-subtle); border-radius: 0; background: transparent; cursor: pointer; }
.qt-pw-list .file-item:first-child { border-top: 0; }
@media (hover: hover) { .qt-pw-list .file-item:hover { background: var(--surface-2); } }
.qt-pw-list .text-mono { font-family: var(--font-mono); font-size: var(--text-md) !important; line-height: 24px; letter-spacing: .01em; font-variant-ligatures: none; }
.qt-pw-list .file-item:only-child .text-mono { font-size: var(--text-xl) !important; line-height: 30px; }
.qt-pw-c-up { color: var(--series-1); } .qt-pw-c-num { color: var(--series-2); } .qt-pw-c-sym { color: var(--series-7); }
.qt-entropy { display: flex; flex-direction: column; gap: 8px; }
.qt-entropy .strength-meter { height: 6px; gap: 4px; }
.qt-entropy .strength-meter span { border-radius: 3px; }
.qt-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 160px; padding: var(--space-6); text-align: center; color: var(--text-3); border: 1px dashed var(--border-subtle); border-radius: var(--radius-md); }
.qt-empty h4 { font-size: var(--text-md); font-weight: 600; color: var(--text-2); }
.qt-empty p { font-size: var(--text-sm); }
.qt-jwt-pre { margin: 0; max-height: 420px; }
.qt-details { border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--surface-1); }
.qt-details > summary { cursor: pointer; display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 var(--space-4); font-size: var(--text-sm); font-weight: 500; color: var(--text-2); list-style: none; }
.qt-details > summary::-webkit-details-marker { display: none; }
.qt-details > summary .fw-icon { transition: transform var(--dur-1) var(--ease-out); }
.qt-details[open] > summary .fw-icon { transform: rotate(90deg); }
.qt-details > p { padding: 0 var(--space-4) var(--space-4); font-size: var(--text-sm); color: var(--text-2); line-height: var(--lh-base); }
.qt-details code { font-family: var(--font-mono); font-size: var(--text-xs); background: var(--surface-sunken); padding: 1px 5px; border-radius: 4px; overflow-wrap: anywhere; }

/* ───── Utilities specifics ───── */
.qt-preview { display: grid; place-items: center; min-height: 260px; padding: var(--space-4); border-radius: var(--radius-sm); background: var(--surface-sunken); }
.qt-preview canvas { display: block; max-width: 100%; height: auto; background: #fff; border-radius: 4px; box-shadow: var(--shadow-1); }
.qt-qr { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-3); align-items: start; }
@container qt (min-width: 760px) { .qt-qr { grid-template-columns: minmax(0, 1fr) minmax(280px, 380px); } }
.qt-qr__side { display: flex; flex-direction: column; gap: var(--space-3); }
@container qt (min-width: 760px) { .qt-qr__side { position: sticky; top: calc(var(--appbar-h) + var(--space-4)); } }
.qt-qr__actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); }
.qt-qr__actions .fw-btn--primary { grid-column: 1 / -1; }
.qt-form { display: flex; flex-direction: column; gap: var(--space-3); }
.qt-form .fw-field > .qt-label { margin: 0; }
.qt-form-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-3); }
@container qt (min-width: 560px) { .qt-form-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.qt-color-input { display: inline-flex; align-items: center; gap: 8px; font-size: var(--text-sm); color: var(--text-2); }
.qt :is(input[type="color"]) { width: 44px; height: 36px; padding: 2px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-1); cursor: pointer; }
.qt-scan { position: relative; aspect-ratio: 4 / 3; overflow: hidden; border-radius: var(--radius-md); background: #000; }
.qt-scan video, .qt-scan canvas { width: 100%; height: 100%; object-fit: contain; display: block; }
.qt-scan.drag-over { outline: 2px solid var(--accent-fill); outline-offset: 2px; }
.qt-scan__hint { position: absolute; inset: 0; display: grid; place-items: center; padding: var(--space-4); text-align: center; color: #b4b4bb; font-size: var(--text-sm); pointer-events: none; }
.qt-scan.has-content .qt-scan__hint { display: none; }
/* Nothing opened yet: a light drop area instead of a black "dead video" box. Stacked (phones) it is left out: the
   buttons above already say what to do, and the decoded content moves up. */
.qt-scan:not(.has-content) { background: var(--surface-2); border: 1.5px dashed var(--border-strong); }
.qt-scan:not(.has-content) .qt-scan__hint { color: var(--text-3); }
.qt-scan:not(.has-content) canvas { visibility: hidden; }
@container qt (max-width: 719px) { .qt-scan:not(.has-content) { display: none; } }
.qt-kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; margin: 0; font-size: var(--text-sm); overflow-wrap: anywhere; }
.qt-kv dt { color: var(--text-3); font-weight: 500 !important; }
.qt-kv dd { margin: 0; font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-1); }
.util-state-bar { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2) var(--space-4); margin-top: var(--space-5); padding-top: var(--space-4); border-top: 1px solid var(--border-subtle); color: var(--text-2); font-size: var(--text-sm); }
.util-state-bar .fw-toggle { font-size: var(--text-sm); color: var(--text-2); }
.util-state-bar button[hidden] { display: none !important; }

/* Timestamp */
.qt-now { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px var(--space-4); padding: var(--space-3) var(--space-4); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--surface-2); }
.qt-now__label { font-size: var(--text-xs); font-weight: 600; color: var(--text-3); text-transform: none; }
.ts-now { font: 500 var(--text-lg)/var(--lh-lg) var(--font-mono); color: var(--text-1); font-variant-numeric: tabular-nums; }
.qt-now .qt-hint { font-family: var(--font-mono); font-size: var(--text-sm); color: var(--text-2); }
.qt-tsgrid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-3); }
@container qt (min-width: 760px) { .qt-tsgrid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.ts-row { display: grid; grid-template-columns: 112px minmax(0, 1fr); align-items: center; gap: var(--space-3); min-height: 48px; padding: 6px 6px 6px var(--space-4); border-top: 1px solid var(--border-subtle); }
.ts-row:first-child { border-top: 0; }
.ts-row { position: relative; }
.ts-row > :is(.qt-error, .qt-warning) { position: absolute; z-index: 2; top: calc(100% - 6px); left: var(--space-4); right: 6px; box-shadow: var(--shadow-2); pointer-events: none; }
.ts-row > label { font-size: var(--text-sm); color: var(--text-2); }
.ts-row > :is(input).fw-input { font-family: var(--font-mono); font-size: var(--text-sm); }
.ts-row > :is(input).fw-input[readonly] { background: var(--surface-2); box-shadow: none; }
@media (max-width: 479px) { .ts-row { grid-template-columns: minmax(0, 1fr); gap: 4px; padding: 8px var(--space-3); } }

/* Color picker (engine keeps its .cp-* classes; colours follow the tokens) */
.qt-color { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); align-items: start; }
@container qt (min-width: 760px) { .qt-color { grid-template-columns: minmax(240px, 1fr) minmax(320px, 1.6fr); } }
.qt-color .color-preview-wrap { display: flex; flex-direction: column; gap: 10px; }
.qt-color .cp-area { position: relative; width: 100%; aspect-ratio: 4 / 3; min-height: 200px; border-radius: var(--radius-md); border: 1px solid var(--border-subtle); cursor: crosshair; touch-action: none;
  -webkit-touch-callout: none; user-select: none; overflow: hidden; background: linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, var(--cp-hue, #f00)); }
.qt-color .cp-area:focus-visible, .qt-color .cp-hue:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: 2px; }
.qt-color .cp-thumb { position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.55), 0 1px 4px rgba(0,0,0,.35); transform: translate(-50%, -50%); pointer-events: none; }
.qt-color .cp-hue { position: relative; height: 22px; border-radius: 999px; border: 1px solid var(--border-subtle); cursor: pointer; touch-action: none; user-select: none;
  background: linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%); }
.qt-color .cp-hue-thumb { position: absolute; top: 50%; width: 14px; height: 28px; border-radius: 6px; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.55), 0 1px 4px rgba(0,0,0,.35); transform: translate(-50%, -50%); pointer-events: none; }
.qt-color .cp-swatch-row { display: flex; align-items: center; gap: 10px; }
.qt-color .cp-swatch { width: 56px; height: 36px; border-radius: var(--radius-sm); border: 1px solid var(--border-subtle); flex: none;
  background-image: repeating-conic-gradient(var(--checker-a) 0 25%, var(--checker-b) 0 50%); background-size: 10px 10px; }
.qt-color #col-name { font: 500 var(--text-sm)/1 var(--font-mono); color: var(--text-2); }
.color-field { display: grid; grid-template-columns: 88px minmax(0, 1fr); align-items: center; gap: var(--space-3); min-height: 44px; padding: 4px 6px 4px var(--space-4); border-top: 1px solid var(--border-subtle); }
.color-field:first-child { border-top: 0; }
.color-field > label { font-size: var(--text-sm); color: var(--text-2); }
.color-field > :is(input).fw-input { font-family: var(--font-mono); font-size: var(--text-sm); height: 32px; }
.color-slider { display: grid; grid-template-columns: 18px minmax(0, 1fr) 64px; align-items: center; gap: var(--space-3); min-height: 32px; font: 600 12px/1 var(--font-mono); color: var(--text-2); }
.color-slider input[type="range"] { width: 100%; accent-color: var(--accent-fill); }
.color-slider :is(input[type="number"]).fw-input { height: 30px; padding: 0 8px; font-family: var(--font-mono); font-size: var(--text-sm); }
.qt-swatches { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 3px; }
.qt-harmonies { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--space-3); }
.qt-swatches button, .qt-harmonies button { border: 1px solid color-mix(in srgb, var(--text-1) 12%, transparent) !important; border-radius: 6px !important; }
.qt-swatches button:focus-visible, .qt-harmonies button:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: 2px; }
.qt-harmonies > div > div:first-child { font-size: var(--text-xs) !important; color: var(--text-3) !important; margin-bottom: 4px !important; }
.qt-contrast { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--space-3); }
.qt-contrast > div { border-color: var(--border-subtle) !important; border-radius: var(--radius-md) !important; background: var(--surface-1); }
.qt-contrast .text-sm { font-size: var(--text-sm); color: var(--text-2); }

@media (max-width: 639px) {
  .qt-label-more { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .qt-bar > .fw-btn--primary { flex: 1 1 auto; }
  .qt-pane__head { padding-left: 12px; }
}
@media print { .qt-bar, .qt-pane__actions, .qt-more, .util-state-bar { display: none !important; } }

/* Engines toggle `.active` on segmented buttons; style it like the kit's pressed state */
.qt .fw-seg__opt.active { background: var(--surface-selected); color: var(--text-1); box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 0 0 1px var(--border-subtle); }
.qt .fw-seg__opt .fw-icon { width: 16px; height: 16px; }

/* Utilities moves focus to the newly shown tool region on hash changes (screen readers land in the tool);
   the region itself is not a control, so it gets no ring. */
.tab-content[tabindex="-1"]:focus, .tab-content[tabindex="-1"]:focus-visible { outline: none; }

/* Fixed-width small fields (data-w = preferred px) that shrink instead of overflowing on phones */
.qt :is(input, select).qt-w { flex: 0 1 auto; min-width: 0; max-width: 100%; }
.qt :is(input, select).qt-w[data-w="96"] { width: 96px; }
.qt :is(input, select).qt-w[data-w="110"] { width: 110px; }
.qt :is(input, select).qt-w[data-w="140"] { width: 140px; }
.qt :is(input, select).qt-w[data-w="180"] { width: 180px; }
.qt :is(input, select).qt-w[data-w="200"] { width: 200px; }
.qt :is(input, select).qt-w[data-w="240"] { width: 240px; }
.qt-inline { min-width: 0; max-width: 100%; }
@media (max-width: 479px) {
  .qt-inline:has(> :is(input, select).qt-w[data-w="200"], > :is(input, select).qt-w[data-w="240"]) { flex: 1 1 100%; }
  .qt-inline > :is(input, select).qt-w[data-w="200"], .qt-inline > :is(input, select).qt-w[data-w="240"] { flex: 1 1 auto; width: auto; }
}
.ts-now { font-size: clamp(16px, 5.4cqi, var(--text-lg)); overflow-wrap: anywhere; }
.qt-pane__head { flex-wrap: wrap; }
@media (max-width: 479px) { .color-field { grid-template-columns: 64px minmax(0, 1fr); padding-left: var(--space-3); } }
.qt-diff th, .qt-table th { text-transform: none; letter-spacing: 0; font-size: var(--text-xs); }
/* In a column layout (phone sheet, stacked panel) flex-basis must not turn into a height */
.qt-more.is-sheet > *, .qt-more--stack > * { flex: none !important; }
.qt-more.is-sheet .fw-slider { width: 100%; }
@media (max-width: 639px) { .qt-bar__sep { display: none; } }

/* Image to ASCII: the real file input is invisible, so its label shows the keyboard focus */
.qt-file:has(input:focus-visible) { outline: 2px solid var(--accent-ring); outline-offset: 2px; border-color: var(--accent-fill); }

/* Color Picker touch targets (≥ 44 px on coarse pointers) */
@media (pointer: coarse) {
  .qt-swatches { grid-template-columns: repeat(5, minmax(44px, 1fr)); gap: 4px; }
  .qt-swatches button, .qt-harmonies button { min-width: 44px; min-height: 44px; }
  .qt-harmonies { grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); }
  .qt-color .cp-hue { height: 44px; border-radius: 12px; }
  .qt-color .cp-hue-thumb { height: 50px; }
  .color-slider { min-height: 44px; }
  .color-slider input[type="range"] { height: 44px; }
}
/* Touch: form fields keep 16 px text so iOS does not zoom the page when one gets focus (the old pages had 16 px). */
@media (pointer: coarse) {
  .qt :is(select).fw-select.qt-select, .ts-row > :is(input).fw-input, .color-field > :is(input).fw-input,
  .color-slider :is(input[type="number"]).fw-input { font-size: var(--text-md); }
}
