/* =============================================================
   TOOL RULEBOOK
   -------------------------------------------------------------
   The one place where tool styles are decided. Every value here
   comes from what the site already uses most. The full rules for
   tool pages (layout, buttons, uploads, status) are in RULEBOOK.md.

   Tool pages build their tool from these tk- classes and keep no
   <style> block of their own. `npm run check:style` flags any style
   value written outside this file.

   Some rules start with .main and use !important. That is only
   because tool-style.css forces sizes on every button, input,
   label, p, div and span inside .main with !important. Once all
   tools use this file, those overrides can go, and so can the
   !important here.
   ============================================================= */

/* Google's copy of JetBrains Mono (loaded in tool-header.php) has no box-drawing signs, arrows or
   symbols, so they came from another font of another width and text diagrams didn't line up.
   These are JetBrains' own files, and a browser only fetches one when a page shows such a sign. */
@font-face {
  font-family: 'JetBrains Mono';
  font-weight: 400;
  font-display: swap;
  src: url('https://cdn.jsdelivr.net/gh/JetBrains/JetBrainsMono@v2.304/fonts/webfonts/JetBrainsMono-Regular.woff2') format('woff2');
  unicode-range: U+2190-22FF, U+2500-25FF, U+2700-27BF;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-weight: 500;
  font-display: swap;
  src: url('https://cdn.jsdelivr.net/gh/JetBrains/JetBrainsMono@v2.304/fonts/webfonts/JetBrainsMono-Medium.woff2') format('woff2');
  unicode-range: U+2190-22FF, U+2500-25FF, U+2700-27BF;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-weight: 700;
  font-display: swap;
  src: url('https://cdn.jsdelivr.net/gh/JetBrains/JetBrainsMono@v2.304/fonts/webfonts/JetBrainsMono-Bold.woff2') format('woff2');
  unicode-range: U+2190-22FF, U+2500-25FF, U+2700-27BF;
}

:root {
  /* Colors */
  --tk-ink: #111;              /* buttons, input text, labels */
  --tk-ink-hover: #302d2d;     /* button hover */
  --tk-heading: #0c0c0c;       /* same as --text-primary */
  --tk-text-muted: #666;
  --tk-white: #fff;
  --tk-surface: #fafafa;       /* inputs, notes, panel headers */
  --tk-border: #e5e5e5;
  --tk-border-strong: #ddd;    /* switch off, upload outline */
  --tk-success: #16803c;
  --tk-warning: #b7791f;
  --tk-error: #c62828;

  /* Spacing */
  --tk-space-xs: 6px;
  --tk-space-sm: 10px;
  --tk-space-md: 15px;
  --tk-space-lg: 20px;
  --tk-space-xl: 30px;
  --tk-space-page: 50px;

  /* Text: Outfit is the main font; JetBrains Mono is the second font, for code and text diagrams */
  --tk-font: 'Outfit', sans-serif;
  --tk-font-mono: 'JetBrains Mono', ui-monospace, 'Cascadia Mono', 'Segoe UI Mono', Consolas, 'Liberation Mono', monospace;
  /* Text in any language: Outfit for Latin letters, Noto for the scripts Outfit lacks (see tk-text--world) */
  --tk-font-world: 'Outfit', 'Noto Sans', 'Noto Sans Arabic', 'Noto Sans Devanagari', 'Noto Sans Bengali', 'Noto Sans Hebrew', 'Noto Sans Thai', 'Noto Sans SC', 'Noto Sans JP', 'Noto Sans KR', sans-serif;
  --tk-text-xs: 12px;
  --tk-text-sm: 13px;
  --tk-text-base: 14px;
  --tk-text-lg: 16px;
  --tk-weight-normal: 400;
  --tk-weight-semibold: 600;
  --tk-weight-bold: 700;
  --tk-line-height: 1.5;

  /* Corners */
  --tk-radius-sm: 8px;         /* buttons, status */
  --tk-radius-md: 10px;        /* inputs, panels, notes */
  --tk-radius-lg: 16px;        /* tool card */
  --tk-radius-pill: 20px;      /* switches, meters */
  --tk-radius-round: 50%;

  /* Tool card */
  --tk-card-small: 600px;
  --tk-card-medium: 700px;
  --tk-card-shadow: 0 15px 40px rgba(0, 0, 0, 0.08);

  /* Controls */
  --tk-control-pad-y: 8px;
  --tk-control-pad-x: 14px;
  --tk-button-pad-x: 22px;
  --tk-icon: 16px;
  --tk-textarea-height: 130px;
  --tk-textarea-tall: 200px;   /* for pasting a lot (JSON, code, lists) */
  --tk-tap-min: 40px;          /* button and input height on phones */
}

/* ---------- Tool card ----------
   Pick the size from what the tool shows, so it looks clean and is easy to use:
   - small:  the result is a short value (a number, one line, a password)
   - medium: the result is a block of text or an image
   - full:   the tool needs a big work area (editor, table, side-by-side panels)
   When in doubt, go one size up rather than squeezing the result. */

.tk-card {
  width: 100%;
  margin: var(--tk-space-page) auto;
  padding: var(--tk-space-xl);
  background: var(--tk-white);
  border-radius: var(--tk-radius-lg);
  box-shadow: var(--tk-card-shadow);
  color: var(--tk-ink);
  font-family: var(--tk-font);
  text-align: left;
  animation: fadeUp 0.5s 0.2s ease both;
}
.tk-card--small  { max-width: var(--tk-card-small); }
.tk-card--medium { max-width: var(--tk-card-medium); }
.tk-card--full   { max-width: none; }

/* Even spacing between everything placed in a card */
.tk-card > * + * { margin-top: var(--tk-space-lg); }
/* An empty status message at the very top takes no room */
.tk-card > .tk-status:first-child:empty + * { margin-top: 0; }

.tk-card-title {
  color: var(--tk-heading);
  font-size: var(--tk-text-lg);
  font-weight: var(--tk-weight-semibold);
  text-align: left;
}
.main .tk-card-subtitle {
  color: var(--tk-heading);
  font-size: var(--tk-text-base) !important;
  font-weight: var(--tk-weight-bold) !important;
  text-align: left;
}

/* ---------- Fields ---------- */

.tk-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--tk-space-sm);
}
.tk-row > * { flex: 1 1 140px; }
.tk-row > .tk-btn { flex: 0 0 auto; }
/* A field that takes most of the row (e.g. URL next to Method); the row stacks on phones */
.tk-row > .tk-field--wide { flex: 3 1 260px; }
/* Keeps a field and its buttons on one line at every size (e.g. a value with Copy);
   the field shrinks instead of the buttons wrapping */
.tk-row--nowrap { flex-wrap: nowrap; }
.tk-row--nowrap > :not(.tk-btn) { flex: 1 1 0; min-width: 0; }

/* Many small fields in an even grid: 3 across, 2 on phones (e.g. a unit's stats) */
.tk-field-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--tk-space-sm);
}

.tk-field {
  display: flex;
  flex-direction: column;
  gap: var(--tk-space-xs);
  min-width: 0;
}

.main .tk-label {
  display: block;
  color: var(--tk-ink) !important;
  font-size: var(--tk-text-base) !important;
  font-weight: var(--tk-weight-normal) !important;
  text-align: left;
}
.main .tk-label span { font-size: inherit !important; }
/* tool-style.css gives every label 10px above and below; the rulebook sets spacing itself */
.main .tk-label,
.main .tk-switch { margin: 0; }

.main .tk-input {
  width: 100%;
  padding: var(--tk-control-pad-y) var(--tk-control-pad-x) !important;
  color: var(--tk-ink) !important;
  background-color: var(--tk-surface) !important;
  border: 1px solid var(--tk-border) !important;
  border-radius: var(--tk-radius-md) !important;
  font-family: inherit !important;
  font-size: var(--tk-text-base) !important;
  line-height: var(--tk-line-height);
}
.main .tk-input:focus { border-color: var(--tk-ink) !important; }
/* A field the status message points at: the script sets aria-invalid="true" */
.main .tk-input[aria-invalid="true"] { border-color: var(--tk-error) !important; }
/* A box the visitor types or pastes code into (the second font, as in the code result) */
/* Code inside a sentence or a table cell: the About text, an IP address, a tag name.
   Without this it fell to the browser's default monospace, a third font. */
.main code,
.main kbd,
.main samp,
.about-content pre,
.about-content .code {
  font-family: var(--tk-font-mono) !important;
  font-variant-ligatures: none;
}
/* Sits in a sentence: its old 8px padding ran into the lines above and below */
.about-content code { padding: 0 var(--tk-space-xs); }
.search-box input { font-family: var(--tk-font); }

/* Text that may be in any language (Bilingual Document). The page sets $tk_world_fonts before
   tool-header.php so the Noto fonts load; without them Urdu, Arabic, Hindi or Chinese showed in
   the device's own font. Latin letters stay Outfit. */
.main .tk-text--world,
.main .tk-text--world * {
  font-family: var(--tk-font-world) !important;
}
/* Right-to-left text (Urdu, Arabic) lines up on the right; tool-style.css sets every block to the left */
.main .tk-text--world[dir="auto"],
.main .tk-text--world [dir="auto"] { text-align: start; }
/* Code inside text in any language (a hex color in a style guide) keeps JetBrains Mono:
   the rule above would otherwise win over .main code */
.main .tk-text--world code,
.main .tk-text--world kbd,
.main .tk-text--world samp,
.main .tk-text--world .tk-input--code {
  font-family: var(--tk-font-mono) !important;
  font-variant-ligatures: none;
}

/* Ligatures off: JetBrains Mono would draw -> as an arrow, and code must show literally */
.main .tk-input--code {
  font-family: var(--tk-font-mono) !important;
  font-variant-ligatures: none;
}
/* The ✕ that empties a search box, in the site's colors instead of the browser's blue */
.tk-input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  margin-left: var(--tk-space-xs);
  border-radius: 50%;
  cursor: pointer;
  background: var(--tk-border) center / 10px no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2 2l8 8M10 2l-8 8' stroke='%23111' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
}
/* Room for the arrow tool-style.css draws on every select */
.main select.tk-input { padding-right: 36px !important; }
.main textarea.tk-input { height: var(--tk-textarea-height); }
.main textarea.tk-input--tall { height: var(--tk-textarea-tall); }

/* Color picker: <input type="color" class="tk-input tk-input--color"> */
.main .tk-input--color {
  height: var(--tk-tap-min);
  padding: var(--tk-space-xs) !important;
  cursor: pointer;
}
.tk-input--color::-webkit-color-swatch-wrapper { padding: 0; }
/* The outline keeps a white or very light color visible on the gray input */
.tk-input--color::-webkit-color-swatch {
  border: 1px solid var(--tk-border-strong);
  border-radius: var(--tk-radius-sm);
}
.tk-input--color::-moz-color-swatch {
  border: 1px solid var(--tk-border-strong);
  border-radius: var(--tk-radius-sm);
}

.tk-note {
  padding: var(--tk-space-sm) var(--tk-space-md);
  background: var(--tk-surface);
  border-radius: var(--tk-radius-md);
  text-align: center;
}
.main .tk-help {
  color: var(--tk-text-muted);
  font-size: var(--tk-text-sm) !important;
}
.main .tk-help span { font-size: inherit !important; }
/* A hint that warns, e.g. a counter over its limit */
.main .tk-help.is-error { color: var(--tk-error); }
/* A line to write on in a document preview (TkOffice): it stays one line and is cut at the
   panel's edge on phones, instead of wrapping onto a second line */
.main .tk-help--line { white-space: nowrap; overflow: hidden; }

/* ---------- Buttons ----------
   Where buttons go, the same in every tool:
   1. Inputs first (what the user types, uploads or picks).
   2. The main action (Generate, Convert) right below them, in .tk-actions,
      with secondary actions (Clear, Choose another) next to it.
      Only the main action is black; the rest are tk-btn--secondary.
   3. The result in a .tk-panel. Copy and Download always sit in the panel
      header (.tk-panel__actions), on the right, with a heading for the result
      (h3.tk-card-subtitle) on the left. Never put Copy anywhere else.
   4. Copy and Download only show once there is a result: start them with the
      hidden attribute and let the script show them after converting (and hide
      them again on Clear). Tools that generate live, so a result is there from
      the start (e.g. password, lorem), show Copy right away. */

.tk-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--tk-space-sm);
}

.main .tk-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--tk-space-xs);
  padding: var(--tk-control-pad-y) var(--tk-button-pad-x) !important;
  color: var(--tk-white);
  background: var(--tk-ink);
  border: 1px solid var(--tk-ink);
  border-radius: var(--tk-radius-sm) !important;
  font-family: inherit !important;
  font-size: var(--tk-text-xs) !important;
  font-weight: var(--tk-weight-semibold);
  line-height: var(--tk-line-height);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.main .tk-btn:hover {
  color: var(--tk-white) !important;
  background: var(--tk-ink-hover) !important;
  border-color: var(--tk-ink-hover);
}
.main .tk-btn--secondary {
  color: var(--tk-ink);
  background: var(--tk-white);
  border-color: var(--tk-border);
}
.main .tk-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.main .tk-btn .material-symbols-outlined,
.main .tk-btn svg {
  width: var(--tk-icon);
  height: var(--tk-icon);
  font-size: var(--tk-icon) !important;
}
.main .tk-btn svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* ---------- Switches (on/off options) ---------- */

.tk-switch-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: var(--tk-space-sm);
}

/* Wider columns for long option names (e.g. in a half-width settings panel) */
.tk-switch-group--wide { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

.tk-switch {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--tk-space-sm);
  padding: var(--tk-control-pad-y) var(--tk-control-pad-x);
  background: var(--tk-surface);
  border-radius: var(--tk-radius-md);
  cursor: pointer;
}
/* The real checkbox stays focusable for keyboards; the track draws it */
.main .tk-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}
.tk-switch__track {
  position: relative;
  flex-shrink: 0;
  width: 40px;
  height: 22px;
  background: var(--tk-border-strong);
  border-radius: var(--tk-radius-pill);
  transition: background 0.3s;
}
.tk-switch__track::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: var(--tk-white);
  border-radius: var(--tk-radius-round);
  transition: transform 0.3s;
}
.tk-switch input:checked + .tk-switch__track { background: var(--tk-ink); }
.tk-switch input:checked + .tk-switch__track::before { transform: translateX(18px); }
.tk-switch input:focus-visible + .tk-switch__track { outline: 2px solid var(--tk-ink); outline-offset: 2px; }
/* An option that doesn't apply right now (its input is disabled) */
.tk-switch:has(input:disabled) { opacity: 0.5; cursor: not-allowed; }

/* ---------- Checklist item (a box to tick, e.g. a step done) ----------
   <label class="tk-check"><input type="checkbox"><span class="tk-check__text">Step</span></label>
   A ticked step is crossed out and grayed, so what's left stands out. */

.main .tk-check {
  display: flex;
  align-items: flex-start;
  gap: var(--tk-space-sm);
  margin: 0;
  cursor: pointer;
}
.main .tk-check input {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  padding: 0 !important;
  background: var(--tk-white) no-repeat center / 12px !important;
  border: 1px solid var(--tk-border-strong) !important;
  border-radius: 4px !important;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}
.main .tk-check input:checked {
  background-color: var(--tk-ink) !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") !important;
  border-color: var(--tk-ink) !important;
}
.tk-check input:focus-visible { outline: 2px solid var(--tk-ink); outline-offset: 2px; }
.main .tk-check__text {
  color: var(--tk-ink);
  font-size: var(--tk-text-base) !important;
  line-height: var(--tk-line-height);
}
.main .tk-check input:checked + .tk-check__text {
  color: var(--tk-text-muted);
  text-decoration: line-through;
}
/* A list of steps to tick */
.tk-checklist {
  display: grid;
  gap: var(--tk-space-sm);
}
/* A tickable item with a button at its end (e.g. remove): the button stays
   centred beside the text, however many lines the text wraps to */
.tk-check-row {
  display: flex;
  align-items: center;
  gap: var(--tk-space-sm);
}
.tk-check-row > .tk-check { flex: 1 1 auto; min-width: 0; }
.tk-check-row > .tk-btn { flex-shrink: 0; }
/* A muted details line under an item's name */
.main .tk-check__meta {
  display: block;
  color: var(--tk-text-muted);
  font-size: var(--tk-text-sm) !important;
}

/* ---------- Slider ---------- */

/* JS sets --tk-range-fill (0%–100%) to colour the part left of the thumb.
   The input is as tall as the thumb and its ring, so the thumb never runs
   into the label above it. Line and thumb grow on touch screens. */
.main .tk-range {
  --tk-range-track: 4px;
  --tk-range-thumb: 16px;
  --tk-range-ring: 4px;
  display: block;
  width: 100%;
  height: calc(var(--tk-range-thumb) + 2 * var(--tk-range-ring)) !important;
  padding: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}
.tk-range::-webkit-slider-runnable-track {
  height: var(--tk-range-track);
  border-radius: var(--tk-radius-pill);
  background: linear-gradient(90deg, var(--tk-ink) var(--tk-range-fill, 50%), var(--tk-border) var(--tk-range-fill, 50%));
}
.tk-range::-webkit-slider-thumb {
  width: var(--tk-range-thumb);
  height: var(--tk-range-thumb);
  margin-top: calc((var(--tk-range-track) - var(--tk-range-thumb)) / 2);
  background: var(--tk-ink);
  border-radius: var(--tk-radius-round);
  box-shadow: 0 0 0 var(--tk-range-ring) rgba(0, 0, 0, 0.1);
  -webkit-appearance: none;
}
.tk-range::-moz-range-track {
  height: var(--tk-range-track);
  border-radius: var(--tk-radius-pill);
  background: var(--tk-border);
}
.tk-range::-moz-range-progress {
  height: var(--tk-range-track);
  border-radius: var(--tk-radius-pill);
  background: var(--tk-ink);
}
.tk-range::-moz-range-thumb {
  width: var(--tk-range-thumb);
  height: var(--tk-range-thumb);
  background: var(--tk-ink);
  border: none;
  border-radius: var(--tk-radius-round);
  box-shadow: 0 0 0 var(--tk-range-ring) rgba(0, 0, 0, 0.1);
}
.tk-range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 var(--tk-range-ring) var(--tk-border-strong); }
/* A slider that doesn't apply right now (e.g. quality for PNG): dimmed like a disabled button or switch */
.main .tk-range:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Meter (e.g. password strength) ---------- */

.tk-meter {
  height: 6px;
  overflow: hidden;
  background: var(--tk-border);
  border-radius: var(--tk-radius-pill);
}
.tk-meter__fill {
  width: 0;
  height: 100%;
  background: var(--tk-ink);
  transition: width 0.3s, background 0.3s;
}
.tk-meter__fill.is-weak   { width: 30%;  background: var(--tk-error); }
.tk-meter__fill.is-medium { width: 60%;  background: var(--tk-warning); }
.tk-meter__fill.is-strong { width: 100%; background: var(--tk-success); }
.tk-card > .tk-meter + .tk-help { margin-top: var(--tk-space-xs); }
/* A progress bar (e.g. steps ticked): the script sets --tk-meter-fill (0%–100%) on the fill */
.tk-meter__fill--progress { width: var(--tk-meter-fill, 0%); }

/* ---------- Result panel (header with actions + body) ---------- */

.tk-panel {
  overflow: hidden;
  background: var(--tk-white);
  border: 1px solid var(--tk-border);
  border-radius: var(--tk-radius-md);
}
.tk-panel__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--tk-space-sm);
  /* Same height with or without a button, so side-by-side panels line up */
  min-height: calc(var(--tk-tap-min) + 2 * var(--tk-space-sm));
  padding: var(--tk-space-sm) var(--tk-space-md);
  background: var(--tk-surface);
  border-bottom: 1px solid var(--tk-border);
}
/* A long heading wraps onto more lines instead of pushing a small button
   (e.g. an icon-only Copy) under it */
.tk-panel__head > .tk-card-subtitle {
  flex: 1 1 140px;
  min-width: 0;
}
/* Item cards on a tray have one small button each (e.g. Copy): it always stays
   beside the item's heading, which wraps instead */
.tk-panel__body--stack .tk-panel__head { flex-wrap: nowrap; }
.tk-panel__body--stack .tk-panel__head > .tk-card-subtitle { flex-basis: 0; }
/* When the buttons don't fit beside the heading (several on a phone),
   they move under it and stay on the right */
.tk-panel__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--tk-space-sm);
  margin-left: auto;
}
.tk-panel__body {
  padding: var(--tk-space-lg);
  color: var(--tk-ink);
  line-height: var(--tk-line-height);
  overflow-wrap: anywhere;
}
/* Result text filled in by JS: keeps its line breaks; shows data-placeholder while empty */
.tk-panel__body--text { white-space: pre-wrap; }
.tk-panel__body--text:empty::before {
  content: attr(data-placeholder);
  color: var(--tk-text-muted);
}
.tk-panel__body--scroll {
  height: var(--tk-textarea-height);
  overflow-y: auto;
}
/* Text diagrams whose columns must line up (ASCII art, box and tree diagrams,
   class diagrams). The one place a fixed-width font is allowed: the system's
   own, nothing is downloaded. Lines never wrap; long ones scroll sideways. */
.main .tk-panel__body--diagram,
.main .tk-panel__body--diagram * {
  font-family: var(--tk-font-mono) !important;
}
.tk-panel__body--diagram {
  font-variant-ligatures: none;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
  /* Tight enough that │ and █ join from line to line */
  line-height: 1.2;
}
/* The empty-state hint stays ordinary text */
.main .tk-panel__body--diagram:empty::before {
  font-family: var(--tk-font) !important;
  white-space: normal;
}
/* Code results (source code, config files, JSON/YAML/XML/SQL) in the same fixed-width
   font, so indentation reads as in an editor (owner's decision, 2026-11-01). Only the
   font changes: pair it with --pre so lines keep their spacing and scroll sideways. */
.main .tk-panel__body--code,
.main .tk-panel__body--code * {
  font-family: var(--tk-font-mono) !important;
}
.tk-panel__body--code { font-variant-ligatures: none; }
.main .tk-panel__body--code:empty::before { font-family: var(--tk-font) !important; }

/* Text whose spaces and line lengths matter (ASCII art, aligned output):
   lines never wrap; a long line scrolls sideways inside the panel */
.tk-panel__body--pre {
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
}
/* Its empty-state hint wraps like ordinary text */
.tk-panel__body--pre:empty::before { white-space: normal; }

/* Text with marks stacked far above and below the letters (e.g. Zalgo text):
   extra line height and padding so the marks of the first and last lines show */
.tk-panel__body--roomy {
  padding-top: var(--tk-space-xl);
  padding-bottom: var(--tk-space-xl);
  line-height: 2.5;
}

/* Grows with a long result (e.g. generated data) up to 400px, then scrolls */
.tk-panel__body--tall {
  max-height: 400px;
  overflow-y: auto;
}
.tk-panel__body--center { text-align: center; }
/* One short value that is the whole result (a PIN, a code): large and bold,
   the same size as the page title */
.main .tk-panel__body--big {
  font-size: 26px !important;
  font-weight: var(--tk-weight-bold) !important; /* tool-style.css sets every .main div to 400 !important */
  letter-spacing: 0.04em;
}

/* Live preview of the visitor's own design (spinner, glass card, dark mode switch).
   The script renders the generated code inside a shadow root on this body, so the
   preview is exactly what the code makes and the site's CSS can't change it.
   A visitor-chosen backdrop is passed in with --tk-preview-bg. */
.tk-panel__body--preview {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
  overflow: hidden;
  background: var(--tk-preview-bg, var(--tk-surface));
}

/* The visitor's own page shown in a sandboxed <iframe> (e.g. an HTML viewer) */
.tk-frame {
  display: block;
  width: 100%;
  height: 500px;
  background: var(--tk-white);
  border: 1px solid var(--tk-border);
  border-radius: var(--tk-radius-md);
}

/* A diagram the visitor drags things around in (e.g. pipeline steps).
   touch-action: none lets a finger drag instead of scrolling the page. */
.tk-canvas {
  display: block;
  width: 100%;
  height: 500px;
  touch-action: none;
  cursor: grab;
}
.tk-canvas:active { cursor: grabbing; }

/* A list of item cards (e.g. one panel per unit) on a gray tray */
.tk-panel__body--stack {
  display: grid;
  gap: var(--tk-space-md);
  background: var(--tk-surface);
}
.tk-panel__body.tk-panel__body--stack > * + * { margin-top: 0; }
/* Short item cards (e.g. reference entries) two or more across where there is room, one on phones */
.tk-panel__body--stack.tk-panel__body--cols {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
}
/* Photos as results (e.g. pose ideas): three across where there is room, one per row on phones */
.tk-panel__body--stack.tk-panel__body--photos {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr));
}
/* A photo card: every photo the same shape and edge to edge, so the rows line up */
.tk-panel--photo {
  display: flex;
  flex-direction: column;
}
.tk-panel--photo > .tk-panel__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--tk-space-sm);
}
/* 2 by 3 is the shape of most photos, so a pose keeps its head and feet.
   overflow: hidden stops a taller photo from stretching its box. */
.tk-photo {
  position: relative;
  display: block;
  flex: none;
  overflow: hidden;
  aspect-ratio: 2 / 3;
  background: var(--tk-surface);
}
.tk-photo--landscape { aspect-ratio: 3 / 2; }
.tk-photo--square { aspect-ratio: 1; }
.main .tk-photo img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  max-height: none; /* the 400px limit on images in a result panel doesn't apply: the box sets the size */
  object-fit: cover;
  border-radius: 0;
}

/* A wide table (e.g. a spreadsheet) scrolls sideways inside its panel;
   the page and the panel header never do. */
.tk-panel__body--table {
  padding: 0;
  overflow-x: auto;
}
.tk-table {
  width: 100%;
  border-collapse: collapse;
}
.main .tk-table th,
.main .tk-table td {
  padding: var(--tk-space-xs) var(--tk-space-sm);
  color: var(--tk-ink);
  font-size: var(--tk-text-base) !important;
  text-align: left;
  white-space: nowrap;
  vertical-align: middle;
  background: var(--tk-white);
  border-bottom: 1px solid var(--tk-border);
}
.main .tk-table th {
  color: var(--tk-text-muted);
  font-size: var(--tk-text-xs) !important;
  font-weight: var(--tk-weight-semibold);
  background: var(--tk-surface);
}
.tk-table tbody tr:last-child td { border-bottom: none; }
/* A table that also scrolls down (with tk-panel__body--tall) keeps its column names in view.
   The line under them is a shadow, because a collapsed border scrolls away with the rows. */
.main .tk-panel__body--table.tk-panel__body--tall .tk-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: none;
  box-shadow: inset 0 -1px 0 var(--tk-border);
}
/* The pinned first column's name stays above the names scrolling under it */
.main .tk-panel__body--table.tk-panel__body--tall .tk-table--pin-first thead th:first-child {
  z-index: 3;
  box-shadow: inset -1px -1px 0 var(--tk-border);
}
/* A short column (a type, a number) takes only the room it needs, so a long value beside it stays on one line */
.main .tk-table .tk-table__fit {
  width: 1%;
  min-width: 0;
  white-space: nowrap;
}
/* Cells with sentences (descriptions, notes) wrap instead of making the table very wide */
.main .tk-table--wrap td {
  min-width: 140px;
  white-space: normal;
  overflow-wrap: anywhere;
  vertical-align: top;
}
.tk-table .tk-input { min-width: 90px; }
/* A select also needs room for its arrow, so the chosen option isn't cut off */
.tk-table select.tk-input { min-width: 130px; }
/* Keeps the first column (e.g. the row's name) in view while scrolling sideways */
.tk-table--pin-first th:first-child,
.tk-table--pin-first td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  border-right: 1px solid var(--tk-border);
}

/* A nested list result, e.g. a table of contents preview */
.main .tk-list ul,
.main .tk-list ol {
  margin: 0;
  padding-left: var(--tk-space-lg);
}
.tk-list ul { list-style: disc; }
.tk-list ol { list-style: decimal; }
.tk-list li + li,
.tk-list li > ul,
.tk-list li > ol { margin-top: var(--tk-space-xs); }
.main .tk-list a {
  color: var(--tk-ink);
  text-decoration: underline;
}

/* Small count or note next to a result heading, e.g. "3 results" */
.main .tk-panel__meta {
  margin-left: var(--tk-space-xs);
  color: var(--tk-text-muted);
  font-size: var(--tk-text-sm) !important;
  font-weight: var(--tk-weight-normal);
}
/* In side-by-side panels the count goes under the heading, so Copy/Download
   stay beside it and both panel headers keep the same height */
.main .tk-compare .tk-panel__head .tk-panel__meta {
  display: block;
  margin-left: 0;
}

/* ---------- Mode switch (e.g. Encode / Decode) ----------
   Buttons with aria-pressed; the chosen one is white, so it never competes
   with the card's one black main button. */

.tk-segmented {
  display: grid;
  /* 88px fits a short label, so three options share one row on a phone;
     two options still split the row in half */
  grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  gap: var(--tk-space-xs);
  padding: var(--tk-space-xs);
  background: var(--tk-surface);
  border: 1px solid var(--tk-border);
  border-radius: var(--tk-radius-md);
}
.main .tk-segmented__option,
.main .tk-segmented__option:hover {
  padding: var(--tk-control-pad-y) var(--tk-space-sm) !important;
  color: var(--tk-text-muted) !important;
  background: transparent !important;
  border: 1px solid transparent;
  border-radius: var(--tk-radius-sm) !important;
  font-family: inherit !important;
  font-size: var(--tk-text-xs) !important;
  font-weight: var(--tk-weight-semibold);
  cursor: pointer;
}
.main .tk-segmented__option[aria-pressed="true"],
.main .tk-segmented__option[aria-pressed="true"]:hover {
  color: var(--tk-ink) !important;
  background: var(--tk-white) !important;
  border-color: var(--tk-border);
}

/* ---------- Info grid (label + value boxes) ---------- */

.tk-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--tk-space-sm);
}
/* Two boxes per row, so four facts make a tidy 2 x 2 instead of 3 + 1 */
.tk-facts--pairs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
/* Four short values in one row (2 x 2 on phones) */
.tk-facts--quad { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tk-fact {
  display: flex;
  flex-direction: column;
  gap: var(--tk-space-xs);
  min-width: 0;
  padding: var(--tk-space-sm) var(--tk-space-md);
  background: var(--tk-surface);
  border-radius: var(--tk-radius-md);
}
.main .tk-fact__label {
  color: var(--tk-text-muted);
  font-size: var(--tk-text-xs) !important;
}
.main .tk-fact__value {
  color: var(--tk-ink);
  font-size: var(--tk-text-base) !important;
  font-weight: var(--tk-weight-semibold);
  overflow-wrap: anywhere;
}

/* ---------- Verdict (e.g. valid / risky / invalid) ----------
   A clear answer at the top of a result: a round icon in the status
   color, the verdict as a title and one short reason under it. */

.tk-verdict {
  display: flex;
  align-items: center;
  gap: var(--tk-space-md);
}
.tk-verdict__icon {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: var(--tk-tap-min);
  height: var(--tk-tap-min);
  color: var(--tk-white);
  background: var(--tk-text-muted);
  border-radius: var(--tk-radius-round);
}
.main .tk-verdict__icon .material-symbols-outlined { font-size: 24px !important; }
.tk-verdict__body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.main .tk-verdict__title {
  color: var(--tk-ink);
  font-size: var(--tk-text-lg) !important;
  font-weight: var(--tk-weight-semibold) !important;
}
.main .tk-verdict__text {
  color: var(--tk-text-muted);
  font-size: var(--tk-text-base) !important;
}
.tk-verdict.is-success .tk-verdict__icon { background: var(--tk-success); }
.tk-verdict.is-warning .tk-verdict__icon { background: var(--tk-warning); }
.tk-verdict.is-error   .tk-verdict__icon { background: var(--tk-error); }
.main .tk-verdict.is-success .tk-verdict__title { color: var(--tk-success); }
.main .tk-verdict.is-warning .tk-verdict__title { color: var(--tk-warning); }
.main .tk-verdict.is-error   .tk-verdict__title { color: var(--tk-error); }

/* ---------- Tag (a small status label next to an item, e.g. Added / Removed / Changed) ---------- */

.main .tk-tag {
  display: inline-block;
  padding: 0 var(--tk-space-xs);
  color: var(--tk-text-muted);
  font-size: var(--tk-text-xs) !important;
  font-weight: var(--tk-weight-semibold);
  line-height: var(--tk-line-height);
  white-space: nowrap;
  border: 1px solid currentColor;
  border-radius: var(--tk-radius-pill);
}
.main .tk-tag.is-success { color: var(--tk-success); }
.main .tk-tag.is-warning { color: var(--tk-warning); }
.main .tk-tag.is-error   { color: var(--tk-error); }
.tk-card-subtitle .tk-tag { margin-left: var(--tk-space-xs); vertical-align: middle; }

/* ---------- Upload area ----------
   Rules for every tool that takes a file:
   - After upload, hide the drop area and show the file as a .tk-file row:
     icon, name, size and a remove button. Remove clears the tool and
     brings the drop area back.
   - A converter with no settings converts as soon as the file arrives;
     it has no Convert button. Only converters with real settings
     (quality, size, format options) keep one. */

.tk-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--tk-space-xs);
  min-height: 200px;
  padding: var(--tk-space-xl) var(--tk-space-lg);
  text-align: center;
  background: var(--tk-surface);
  border: 2px dashed var(--tk-border-strong);
  border-radius: var(--tk-radius-md);
  cursor: pointer;
}
.tk-dropzone.is-dragover { border-color: var(--tk-ink); }
.tk-dropzone__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  margin-bottom: var(--tk-space-sm);
  background: var(--tk-ink);
  border-radius: var(--tk-radius-round);
}
.tk-dropzone__icon svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: var(--tk-white);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.main .tk-dropzone__title {
  color: var(--tk-ink);
  font-size: var(--tk-text-lg) !important;
  font-weight: var(--tk-weight-semibold) !important;
}
.main .tk-dropzone__text {
  color: var(--tk-text-muted);
  font-size: var(--tk-text-base) !important;
}
.main .tk-dropzone__hint {
  color: var(--tk-text-muted);
  font-size: var(--tk-text-xs) !important;
}

/* ---------- Uploaded file row ---------- */

.tk-file {
  display: flex;
  align-items: center;
  gap: var(--tk-space-sm);
  padding: var(--tk-space-xs) var(--tk-space-xs) var(--tk-space-xs) var(--tk-space-md);
  background: var(--tk-surface);
  border: 1px solid var(--tk-border);
  border-radius: var(--tk-radius-md);
}
.main .tk-file__icon {
  flex-shrink: 0;
  color: var(--tk-ink);
  font-size: var(--tk-icon) !important;
}
.main .tk-file__name {
  min-width: 0;
  overflow: hidden;
  color: var(--tk-ink);
  font-size: var(--tk-text-base) !important;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.main .tk-file__size {
  flex-shrink: 0;
  color: var(--tk-text-muted);
  font-size: var(--tk-text-sm) !important;
}
.tk-file > .tk-btn { margin-left: auto; }
/* More than one button in a file row (e.g. Replace and remove) */
.tk-file__actions {
  display: flex;
  flex-shrink: 0;
  gap: var(--tk-space-xs);
  margin-left: auto;
}

/* Square button holding only an icon (e.g. remove file) */
.main .tk-btn--icon {
  flex-shrink: 0;
  padding: var(--tk-control-pad-y) !important;
}
@media (max-width: 768px) {
  .main .tk-btn--icon { min-width: var(--tk-tap-min); }
}

/* ---------- Side by side (e.g. original next to result) ----------
   Two or more panels in a row; they stack on their own on narrow screens. */

.tk-compare {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--tk-space-md);
  align-items: start;
}

/* Two or more panels stacked in one side of a tk-compare (e.g. tags above a preview) */
.tk-stack {
  display: grid;
  gap: var(--tk-space-md);
  align-content: start;
}

/* A preview next to long settings stays in view while the visitor scrolls
   through them. Only when side by side: stacked on phones it would cover them. */
@media (min-width: 769px) {
  .tk-sticky {
    position: sticky;
    top: var(--tk-space-lg);
  }
}

/* ---------- Images in panels ---------- */

.tk-panel__body > * + * { margin-top: var(--tk-space-sm); }
.tk-panel__body img,
.tk-panel__body video {
  display: block;
  max-width: 100%;
  height: auto;
  max-height: 400px;
  margin-left: auto;
  margin-right: auto;
  border-radius: var(--tk-radius-md);
}

/* An audio player in a panel: full width, so it never sticks out of the card on phones */
.tk-panel__body audio {
  display: block;
  width: 100%;
}

/* A small preview of an uploaded image (e.g. a logo), not the result itself */
.tk-panel__body img.tk-thumb {
  max-width: 160px;
  max-height: 120px;
  object-fit: contain;
}
/* Pixel art (e.g. sprite frames): square corners so edge pixels show, and no smoothing when scaled */
.tk-panel__body img.tk-img--pixel {
  border-radius: 0;
  image-rendering: pixelated;
}
/* A result whose own corners are the point (e.g. rounded corners): square corners, so it shows exactly as saved */
.tk-panel__body img.tk-img--square {
  border-radius: 0;
}

/* An icon-only Copy that just copied: the icon stays the copy icon, the button turns green for a moment */
.main .tk-btn.is-copied {
  color: var(--tk-success) !important;
  border-color: var(--tk-success) !important;
}
/* Stays white while the mouse is on it: the green icon can't be read on the dark hover colour */
.main .tk-btn.is-copied:hover { background: var(--tk-white) !important; }

/* A score shown as a ring that fills up (e.g. reading level). JS sets --tk-gauge-fill (0-100). */
.tk-gauge {
  --tk-gauge-fill: 0;
  --tk-gauge-color: var(--tk-ink);
  display: grid;
  place-items: center;
  width: 150px;
  max-width: 100%;
  aspect-ratio: 1;
  margin: 0 auto;
  border-radius: 50%;
  background: conic-gradient(var(--tk-gauge-color) calc(var(--tk-gauge-fill) * 1%), var(--tk-border) 0);
}
.tk-gauge.is-success { --tk-gauge-color: var(--tk-success); }
.tk-gauge.is-warning { --tk-gauge-color: var(--tk-warning); }
.tk-gauge.is-error { --tk-gauge-color: var(--tk-error); }
.tk-gauge__inner {
  display: grid;
  place-content: center;
  width: 78%;
  aspect-ratio: 1;
  text-align: center;
  background: var(--tk-white);
  border-radius: 50%;
}
.main .tk-gauge__value {
  font-size: 26px !important;
  font-weight: var(--tk-weight-bold) !important;
  line-height: 1.1;
}
/* A large emoji beside the ring (the owner asked for it on the reading level result) */
.main .tk-gauge__emoji {
  display: block;
  font-size: 56px !important;
  line-height: 1.1;
  text-align: center;
}
.main .tk-gauge__label {
  color: var(--tk-text-muted);
  font-size: var(--tk-text-xs) !important;
}

/* ---------- Status message ----------
   Only for what the user can't already see, mostly errors ("Please enter
   text.", "Please select a valid PNG image."). No success message when the
   result itself appears. When a tool needs one, it goes at the top of the
   card: right under the card heading, or first if there is no heading. */

.tk-status {
  padding: var(--tk-space-sm) var(--tk-space-md);
  color: var(--tk-ink);
  text-align: center;
  background: var(--tk-surface);
  border: 1px solid var(--tk-border);
  border-radius: var(--tk-radius-sm);
}
.tk-status:empty { display: none; }
.tk-status.is-success { color: var(--tk-success); }
.tk-status.is-error   { color: var(--tk-error); }
/* A notice that isn't an error (e.g. "Only 30 different names could be made") */
.tk-status.is-warning { color: var(--tk-warning); }

/* Bold words keep the size of the text around them (tool-style.css shrinks every
   <strong> in .main to 12px); rulebook pieces that size a strong still win */
.tk-card strong { font-size: inherit !important; }

/* Links inside a result (e.g. a generated document), a help line or a note, in ink, not browser blue */
.main .tk-panel__body a:not(.tk-btn),
.main .tk-card .tk-help a:not(.tk-btn),
.main .tk-card .tk-note a:not(.tk-btn) {
  color: var(--tk-ink);
  text-decoration: underline;
}

/* Highlighted words in a result (e.g. adverbs found): <mark> in any tool card */
.tk-card mark {
  padding: 0 2px;
  color: var(--tk-ink);
  font-weight: var(--tk-weight-semibold);
  background: var(--tk-border);
  border-radius: 4px;
}

/* Elements hidden with the hidden attribute stay hidden */
.tk-card [hidden] { display: none !important; }

/* Same entrance animation the title and FAQ blocks use */
.tk-fade-up { animation: fadeUp 0.5s ease both; }

/* One full turn of an icon, e.g. the refresh icon when clicked.
   The script adds .is-spinning and removes it when the turn ends. */
@keyframes tk-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
.is-spinning { animation: tk-spin 0.5s ease; }
@media (prefers-reduced-motion: reduce) {
  .is-spinning { animation: none; }
}

/* Shared about text under every tool: long words and links wrap instead of
   pushing the page wider than the screen */
.about-content { overflow-wrap: anywhere; }

/* ---------- Phones and tablets ---------- */

@media (max-width: 768px) {
  .main .tk-btn,
  .main .tk-input:not(textarea),
  .main .tk-segmented__option,
  .tk-switch {
    min-height: var(--tk-tap-min);
  }
  /* A bigger box and row for fingers */
  .main .tk-check { min-height: var(--tk-tap-min); align-items: center; }
  .main .tk-check input { width: 22px; height: 22px; margin: 0; }
  /* Thicker line and bigger thumb for fingers, same height as the strength bar */
  .main .tk-range {
    --tk-range-track: 6px;
    --tk-range-thumb: 22px;
  }
}

@media (max-width: 600px) {
  .tk-card {
    margin: var(--tk-space-xl) auto;
    padding: var(--tk-space-lg);
  }
  /* Two boxes side by side are too narrow for sentences or long emails on a phone */
  .tk-facts--pairs { grid-template-columns: 1fr; }
  /* A mode switch with four options makes a tidy 2 x 2 instead of 3 + 1 */
  .tk-segmented:has(> :nth-child(4):last-child) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tk-facts--quad,
  .tk-field-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tk-actions > .tk-btn { flex: 1 1 auto; }
}

/* ---------- Printing (TkPrint in assets/js/tool-print-kit.js) ---------- */
/* The hidden print frame holds only the tool's document, inside a bare .main, at full page width */
body.tk-print-doc { margin: 0; background: #fff; }
body.tk-print-doc .main {
  margin: 0 !important;
  padding: 0 !important;
  width: auto !important;
  max-width: none !important;
  min-height: 0 !important;
  animation: none !important;
}
body.tk-print-doc .tk-panel__body img { max-height: none; }
body.tk-print-doc * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
@media print {
  @page { margin: 12mm; }
}

/* Plain text links (no class of their own) in tool pages are black, visited ones too */
a:where(:not([class])), a:where(:not([class])):visited { color: var(--tk-ink); }
