/* The free tools' look: the palace's two watches, its type and its gold.
   Every colour is a custom property on :root (the day watch) and is set again
   on body.night-mode (the night watch), the same class and the same
   localStorage key ("nightMode") the palace uses, so a choice made on either
   carries over. Both watches are dark. State is never shown by colour alone:
   every kind of message has its own icon and word, and selected things have
   a shape (a bar, a tick, a border style) as well as a colour.
   Class names start with tl- so a tool's own CSS never collides with them. */

@font-face {
  font-family: 'Cinzel';
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url('/fonts/cinzel.woff2') format('woff2');
}
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('/fonts/cormorant-garamond.woff2') format('woff2');
}
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: italic;
  font-weight: 300 700;
  font-display: swap;
  src: url('/fonts/cormorant-garamond-italic.woff2') format('woff2');
}

:root {
  color-scheme: dark;
  /* Day watch: the palace's lamplit brown and gold. */
  --void: #080402;
  --paper: #15110b;
  --paper-raised: #1c160f;
  --paper-sunk: #0e0a05;
  --ink: #f6ecd6;
  --ink-soft: #d2bd90;
  --rule: #8a5a18;
  --rule-soft: rgba(210, 189, 144, 0.28);
  --accent: #f0a83a;
  --accent-bright: #ffc772;
  --accent-ink: #1a0f02;          /* text on an accent fill */
  --focus: #ffe2a8;
  --btn-top: #2b1c07;
  --btn-bottom: #150d03;
  --btn-hover-top: #3d2a0b;
  --btn-hover-bottom: #1e1305;
  --ok: #a8dc8f;
  --warn: #ffd166;
  --bad: #ff9f8f;
  --info: #a9cdf5;
  --glow: rgba(201, 162, 39, 0.3);
  --checker-a: #2a2218;
  --checker-b: #3a3024;

  --font-display: 'Cinzel', Georgia, serif;
  --font-body: 'Cormorant Garamond', Georgia, serif;
  --font-ui: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: ui-monospace, 'Cascadia Mono', Consolas, 'SF Mono', Menlo, monospace;
  --radius: 4px;
  --gap: 1rem;
  --gutter: 16px;
  --measure: 72rem;
}

body.night-mode {
  /* Night watch: the palace's black and red. */
  --void: #000000;
  --paper: #0a0202;
  --paper-raised: #150505;
  --paper-sunk: #050101;
  --ink: #f6ecec;
  --ink-soft: #d9c2c2;
  --rule: #c0392b;          /* the palace's #a3241c, lifted to 3:1 for control borders */
  --rule-soft: rgba(217, 194, 194, 0.26);
  --accent: #e2543a;
  --accent-bright: #ff7d63;
  --accent-ink: #000000;
  --focus: #ffd0c4;
  --btn-top: #2a0806;
  --btn-bottom: #120202;
  --btn-hover-top: #3e0d09;
  --btn-hover-bottom: #1c0403;
  --ok: #b5e3a1;
  --warn: #ffd98a;
  --bad: #ffa898;
  --info: #b9d6f7;
  --glow: rgba(226, 84, 58, 0.35);
  --checker-a: #1c1010;
  --checker-b: #2c1c1c;
}

*, *::before, *::after { box-sizing: border-box; }
/* Components set display, which would beat the browser's own [hidden] rule. */
[hidden] { display: none !important; }
html { font-size: 106%; -webkit-text-size-adjust: 100%; }
@media (max-width: 600px) { html { font-size: 100%; } }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--void);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.15rem;
  line-height: 1.55;
  overflow-wrap: break-word;
}
::selection { background: var(--accent); color: var(--accent-ink); }
img, video, canvas, svg, audio { max-width: 100%; }
img, video, canvas { height: auto; }
a { color: var(--accent-bright); text-decoration: underline; text-underline-offset: 3px; }
a:hover { color: var(--ink); }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; line-height: 1.25; letter-spacing: 0.04em; margin: 1.6rem 0 0.6rem; }
h2 { font-size: 1.3rem; color: var(--accent-bright); }
h3 { font-size: 1.05rem; color: var(--ink); }
p { margin: 0.5rem 0; }
code, kbd, samp, pre { font-family: var(--font-mono); font-size: 0.85em; }
hr { border: 0; border-top: 1px solid var(--rule-soft); margin: 1.5rem 0; }

/* One clear focus ring for everything, in both watches. */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}
:focus:not(:focus-visible) { outline: none; }

.tl-visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%);
  white-space: nowrap; border: 0;
}
.tl-skip {
  position: absolute; left: 0.5rem; top: -3rem; z-index: 100;
  padding: 0.5rem 0.9rem; background: var(--accent); color: var(--accent-ink);
  font-family: var(--font-ui); font-weight: 700; text-decoration: none; border-radius: var(--radius);
}
.tl-skip:focus { top: 0.5rem; }

/* ------------------------------------------------------------------ header */
.tl-header {
  border-bottom: 2px solid var(--rule);
  box-shadow: 0 1px 0 rgba(201, 162, 39, 0.15);
  background: var(--paper);
}
.tl-header-inner, .tl-header:not(:has(.tl-header-inner)) {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0.55rem var(--gutter);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}
.tl-brand {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.92rem;
  color: var(--accent-bright);
  text-decoration: none;
}
.tl-brand:hover { color: var(--ink); }
.tl-brand-mark { color: var(--accent); }
.tl-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; }
.tl-nav > a {
  font-family: var(--font-display);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
}
.tl-theme {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.55rem;
  min-height: 2.25rem;
  background: transparent;
  border: 1px solid var(--rule-soft);
  border-radius: 999px;
  color: var(--ink-soft);
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}
.tl-theme:hover { border-color: var(--accent); color: var(--ink); }
.tl-theme-knob {
  position: relative;
  width: 2.4rem;
  height: 1.3rem;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: linear-gradient(180deg, var(--btn-top), var(--btn-bottom));
  flex: none;
}
.tl-theme-knob::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: calc(1.3rem - 6px); height: calc(1.3rem - 6px);
  border-radius: 50%;
  background: var(--accent-bright);
  transition: transform 0.25s ease;
}
.tl-theme[aria-checked="true"] .tl-theme-knob::after { transform: translateX(1.1rem); }
.tl-theme-state { min-width: 1.6rem; font-family: var(--font-ui); font-weight: 700; letter-spacing: 0; text-transform: none; color: var(--ink); }

/* -------------------------------------------------------- page and intro */
.tl-main {
  flex: 1 0 auto;
  width: 100%;
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 var(--gutter) 2rem;
}
.tl-intro { margin: 1.6rem 0 1.2rem; }
.tl-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 4.6vw, 2.3rem);
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--accent-bright);
}
.tl-lede { margin: 0.4rem 0 0.7rem; font-size: 1.25rem; color: var(--ink); max-width: 46rem; }
.tl-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.2rem 0;
  padding: 0.22rem 0.7rem 0.22rem 0.55rem;
  border: 1px solid var(--accent);
  border-radius: 999px;
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
  background: var(--paper-raised);
}
.tl-badge::before {
  /* a padlock */
  content: '';
  width: 0.95rem; height: 0.95rem;
  flex: none;
  background: var(--accent-bright);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 10V7a5 5 0 0 1 10 0v3h1.5A1.5 1.5 0 0 1 20 11.5v9A1.5 1.5 0 0 1 18.5 22h-13A1.5 1.5 0 0 1 4 20.5v-9A1.5 1.5 0 0 1 5.5 10H7zm2 0h6V7a3 3 0 0 0-6 0v3z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 10V7a5 5 0 0 1 10 0v3h1.5A1.5 1.5 0 0 1 20 11.5v9A1.5 1.5 0 0 1 18.5 22h-13A1.5 1.5 0 0 1 4 20.5v-9A1.5 1.5 0 0 1 5.5 10H7zm2 0h6V7a3 3 0 0 0-6 0v3z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.tl-section { margin: 1.5rem 0; }
.tl-section > h2:first-child { margin-top: 0; }
.tl-muted, .tl-hint { color: var(--ink-soft); }
.tl-hint { font-size: 0.98rem; margin: 0.25rem 0 0; }
.tl-prose { max-width: 46rem; }

/* ------------------------------------------------------------------ cards */
.tl-card {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
  min-width: 0;
}
.tl-card > :first-child { margin-top: 0; }
.tl-card > :last-child { margin-bottom: 0; }
.tl-card + .tl-card { margin-top: 1rem; }
.tl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15.5rem), 1fr));
  gap: 0.9rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.tl-grid > .tl-card + .tl-card { margin-top: 0; }

/* Layout: two columns that stack on a phone. */
.tl-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.2rem;
  align-items: start;
}
.tl-split.tl-split-wide-left { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.tl-split.tl-split-wide-right { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); }
@media (max-width: 860px) {
  .tl-split, .tl-split.tl-split-wide-left, .tl-split.tl-split-wide-right { grid-template-columns: minmax(0, 1fr); }
}
.tl-row { display: flex; flex-wrap: wrap; gap: 0.6rem 0.9rem; align-items: flex-end; }
.tl-row > * { min-width: 0; }
.tl-stack > * + * { margin-top: 0.9rem; }
.tl-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin-top: 1rem; }

/* -------------------------------------------------------------- drop zone */
.tl-drop {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 11rem;
  padding: 1.4rem 1rem;
  text-align: center;
  border: 2px dashed var(--accent);
  border-radius: 8px;
  background: var(--paper);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.tl-drop:hover { background: var(--paper-raised); }
.tl-drop.is-dragover {
  border-style: solid;
  border-width: 3px;
  background: var(--paper-raised);
  box-shadow: 0 0 0 4px var(--glow) inset;
}
.tl-drop-icon {
  width: 2.6rem; height: 2.6rem;
  color: var(--accent-bright);
}
.tl-drop-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.1rem;
  letter-spacing: 0.05em;
  color: var(--ink);
}
.tl-drop-hint { margin: 0; color: var(--ink-soft); font-size: 1.02rem; }
.tl-drop.is-compact { min-height: 0; padding: 0.9rem; flex-direction: row; flex-wrap: wrap; }

/* ---------------------------------------------------------------- buttons */
.tl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 2.6rem;
  padding: 0.55rem 1rem;
  font-family: var(--font-display);
  font-size: 0.86rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  color: var(--accent-bright);
  background: linear-gradient(180deg, var(--btn-top), var(--btn-bottom));
  border: 1px solid var(--accent);
  border-radius: 3px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 2px 6px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tl-btn:hover {
  color: var(--ink);
  background: linear-gradient(180deg, var(--btn-hover-top), var(--btn-hover-bottom));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 0 10px var(--glow);
}
.tl-btn-primary {
  color: var(--accent-ink);
  background: linear-gradient(180deg, var(--accent-bright), var(--accent));
  border-color: var(--accent-bright);
}
.tl-btn-primary:hover { color: var(--accent-ink); background: var(--accent-bright); }
/* Danger looks different in shape too: a double border and a warning mark. */
.tl-btn-danger {
  color: var(--bad);
  border: 3px double var(--bad);
}
.tl-btn-danger::before { content: '\26A0\FE0E'; font-family: var(--font-ui); font-size: 0.95em; }
.tl-btn-danger:hover { color: var(--ink); border-color: var(--ink); }
.tl-btn-small { min-height: 2.1rem; padding: 0.3rem 0.65rem; font-size: 0.74rem; }
.tl-btn-block { display: flex; width: 100%; }
.tl-btn[disabled], .tl-btn[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.55;
  box-shadow: none;
  background: var(--paper-raised);
  color: var(--ink-soft);
  border-style: dashed;
}
.tl-btn[aria-busy="true"]::after {
  content: '';
  width: 0.85em; height: 0.85em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: tl-spin 0.8s linear infinite;
}
@keyframes tl-spin { to { transform: rotate(360deg); } }
.tl-btn svg { width: 1.1em; height: 1.1em; flex: none; }
button { font: inherit; }

/* ---------------------------------------------------------- form controls */
.tl-field { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; margin: 0 0 0.9rem; }
.tl-row > .tl-field { margin-bottom: 0; flex: 1 1 11rem; }
.tl-label, .tl-field > label, .tl-fieldset > legend {
  font-family: var(--font-ui);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink);
}
.tl-input, .tl-select, .tl-textarea,
.tl-field input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]),
.tl-field select, .tl-field textarea {
  width: 100%;
  min-height: 2.6rem;
  padding: 0.5rem 0.7rem;
  font-family: var(--font-ui);
  font-size: 1rem;
  color: var(--ink);
  background: var(--paper-sunk);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}
.tl-textarea, .tl-field textarea { min-height: 7rem; resize: vertical; line-height: 1.45; }
.tl-input::placeholder, .tl-textarea::placeholder, .tl-field input::placeholder, .tl-field textarea::placeholder { color: var(--ink-soft); opacity: 0.85; }
.tl-input:hover, .tl-select:hover, .tl-textarea:hover,
.tl-field input:hover, .tl-field select:hover, .tl-field textarea:hover { border-color: var(--accent); }
.tl-input:focus-visible, .tl-select:focus-visible, .tl-textarea:focus-visible,
.tl-field input:focus-visible, .tl-field select:focus-visible, .tl-field textarea:focus-visible { border-color: var(--accent-bright); }
select option { background: var(--paper-raised); color: var(--ink); }
input[type="number"] { font-variant-numeric: tabular-nums; }
.tl-field [aria-invalid="true"], .tl-input[aria-invalid="true"] { border: 2px dashed var(--bad); }
.tl-error-text { color: var(--bad); font-family: var(--font-ui); font-size: 0.9rem; margin: 0.2rem 0 0; }
.tl-error-text::before { content: '\2715  '; font-weight: 700; }

input[type="checkbox"], input[type="radio"], input[type="range"], progress { accent-color: var(--accent); }
input[type="color"] {
  width: 3.2rem; height: 2.6rem; padding: 0.15rem;
  background: var(--paper-sunk); border: 1px solid var(--rule); border-radius: var(--radius);
}
.tl-check {
  display: inline-flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.25rem 0;
  font-family: var(--font-ui);
  font-size: 0.98rem;
  cursor: pointer;
}
.tl-check input { width: 1.2rem; height: 1.2rem; margin: 0.12rem 0 0; flex: none; }
.tl-fieldset {
  margin: 0 0 1rem;
  padding: 0.7rem 0.9rem 0.8rem;
  border: 1px solid var(--rule-soft);
  border-radius: var(--radius);
  min-width: 0;
}
.tl-fieldset > legend { padding: 0 0.35rem; }
.tl-options { display: flex; flex-wrap: wrap; gap: 0.2rem 1.2rem; }
.tl-options.tl-options-column { flex-direction: column; }

/* A slider with its value beside it: <div class="tl-range"><label>..</label><input type=range id=x><output for=x></output></div> */
.tl-range { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 0.25rem 0.8rem; margin: 0 0 0.9rem; }
.tl-range > label { grid-column: 1 / -1; font-family: var(--font-ui); font-size: 0.92rem; font-weight: 600; }
.tl-range input[type="range"] { width: 100%; min-height: 1.8rem; margin: 0; }
.tl-range output {
  min-width: 4.2rem;
  padding: 0.15rem 0.45rem;
  text-align: right;
  font-family: var(--font-ui);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--ink);
  background: var(--paper-sunk);
  border: 1px solid var(--rule-soft);
  border-radius: var(--radius);
}

/* -------------------------------------------------------------------- tabs */
[role="tablist"] {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 1rem;
}
[role="tab"] {
  position: relative;
  min-height: 2.6rem;
  padding: 0.5rem 0.9rem;
  font-family: var(--font-display);
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: var(--radius) var(--radius) 0 0;
  cursor: pointer;
}
[role="tab"]:hover { color: var(--ink); background: var(--paper-raised); }
[role="tab"][aria-selected="true"] {
  color: var(--accent-bright);
  font-weight: 700;
  background: var(--paper);
  border-color: var(--rule);
  margin-bottom: -1px;
}
/* the selected tab also carries a thick bar: a shape, not just a colour */
[role="tab"][aria-selected="true"]::after {
  content: '';
  position: absolute;
  left: 0.5rem; right: 0.5rem; bottom: 0.25rem;
  height: 3px;
  background: currentColor;
  border-radius: 2px;
}

/* ------------------------------------------------------------------ tables */
.tl-table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--rule-soft); border-radius: var(--radius); }
.tl-table { width: 100%; border-collapse: collapse; font-family: var(--font-ui); font-size: 0.92rem; }
.tl-table th, .tl-table td { padding: 0.5rem 0.65rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--rule-soft); }
.tl-table th { font-weight: 700; color: var(--ink); background: var(--paper-raised); position: sticky; top: 0; }
.tl-table tbody tr:nth-child(even) td { background: rgba(255, 255, 255, 0.025); }
.tl-table td.tl-num, .tl-table th.tl-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tl-table td { overflow-wrap: anywhere; }

/* A list of chosen files. */
.tl-files { list-style: none; margin: 0.8rem 0 0; padding: 0; font-family: var(--font-ui); font-size: 0.95rem; }
.tl-files > li {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem 0.8rem;
  padding: 0.5rem 0.2rem;
  border-bottom: 1px solid var(--rule-soft);
}
.tl-files .tl-file-name { flex: 1 1 12rem; min-width: 0; overflow-wrap: anywhere; color: var(--ink); }
.tl-files .tl-file-size { color: var(--ink-soft); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- progress */
.tl-progress { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.8rem; margin: 0.9rem 0; font-family: var(--font-ui); }
.tl-progress[hidden] { display: none; }
.tl-progress progress {
  flex: 1 1 12rem;
  height: 0.95rem;
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--paper-sunk);
  overflow: hidden;
}
.tl-progress progress::-webkit-progress-bar { background: var(--paper-sunk); }
.tl-progress progress::-webkit-progress-value { background: repeating-linear-gradient(135deg, var(--accent) 0 10px, var(--accent-bright) 10px 20px); }
.tl-progress progress::-moz-progress-bar { background: repeating-linear-gradient(135deg, var(--accent) 0 10px, var(--accent-bright) 10px 20px); }
.tl-progress progress:indeterminate { background: repeating-linear-gradient(135deg, var(--paper-sunk) 0 10px, var(--rule) 10px 20px); background-size: 28px 28px; animation: tl-stripes 1s linear infinite; }
.tl-progress progress:indeterminate::-webkit-progress-bar { background: transparent; }
.tl-progress progress:indeterminate::-moz-progress-bar { background: transparent; }
@keyframes tl-stripes { to { background-position: 28px 0; } }
.tl-progress-text { flex: 1 1 100%; color: var(--ink); font-size: 0.92rem; font-variant-numeric: tabular-nums; }
@media (min-width: 640px) { .tl-progress-text { flex: 0 1 auto; } }
.tl-progress[data-state="done"] .tl-progress-text { color: var(--ok); font-weight: 700; }
.tl-progress[data-state="failed"] .tl-progress-text { color: var(--bad); font-weight: 700; }

/* --------------------------------------------- status lines, notices, toasts */
.tl-status, .tl-notice {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  margin: 0.8rem 0;
  padding: 0.6rem 0.8rem;
  font-family: var(--font-ui);
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--paper-raised);
  border: 1px solid var(--rule-soft);
  border-left: 5px solid var(--info);
  border-radius: var(--radius);
}
.tl-status:empty, .tl-status[hidden] { display: none; }
.tl-notice { flex-direction: column; gap: 0.2rem; }
.tl-notice > p { margin: 0; }
.tl-notice-title { font-weight: 700; }
.tl-status::before {
  content: 'i';
  flex: none;
  display: inline-grid; place-items: center;
  width: 1.35rem; height: 1.35rem;
  border-radius: 50%;
  font-weight: 800; font-size: 0.85rem;
  color: var(--accent-ink);
  background: var(--info);
}
.tl-status[data-kind="success"], .tl-notice[data-kind="success"] { border-left: 5px solid var(--ok); }
.tl-status[data-kind="success"]::before { content: '\2713'; background: var(--ok); }
.tl-status[data-kind="warning"], .tl-notice[data-kind="warning"] { border-left: 5px dashed var(--warn); }
.tl-status[data-kind="warning"]::before { content: '!'; background: var(--warn); border-radius: 3px; clip-path: polygon(50% 0, 100% 100%, 0 100%); padding-top: 0.25rem; }
.tl-status[data-kind="error"], .tl-notice[data-kind="error"] { border-left: 5px double var(--bad); border-left-width: 6px; }
.tl-status[data-kind="error"]::before { content: '\2715'; background: var(--bad); border-radius: 3px; }

.tl-toasts {
  position: fixed;
  z-index: 90;
  right: max(var(--gutter), env(safe-area-inset-right));
  bottom: max(var(--gutter), env(safe-area-inset-bottom));
  width: min(26rem, calc(100vw - 2 * var(--gutter)));
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}
.tl-toast-region { display: flex; flex-direction: column; gap: 0.5rem; }
.tl-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.65rem 0.6rem 0.65rem 0.75rem;
  font-family: var(--font-ui);
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-left: 5px solid var(--info);
  border-radius: var(--radius);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.6);
  animation: tl-toast-in 0.18s ease-out;
}
@keyframes tl-toast-in { from { transform: translateY(8px); opacity: 0; } }
.tl-toast[data-kind="success"] { border-left: 5px solid var(--ok); }
.tl-toast[data-kind="warning"] { border-left: 5px dashed var(--warn); }
.tl-toast[data-kind="error"] { border-left: 6px double var(--bad); }
.tl-toast-icon {
  flex: none;
  display: inline-grid; place-items: center;
  width: 1.35rem; height: 1.35rem;
  border-radius: 50%;
  font-weight: 800; font-size: 0.85rem;
  color: var(--accent-ink);
  background: var(--info);
}
.tl-toast[data-kind="success"] .tl-toast-icon { background: var(--ok); }
.tl-toast[data-kind="warning"] .tl-toast-icon { background: var(--warn); border-radius: 3px; }
.tl-toast[data-kind="error"] .tl-toast-icon { background: var(--bad); border-radius: 3px; }
.tl-toast-text { flex: 1; margin: 0; min-width: 0; overflow-wrap: anywhere; }
.tl-toast-close {
  flex: none;
  width: 2rem; height: 2rem;
  margin: -0.3rem -0.1rem -0.3rem 0;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
}
.tl-toast-close:hover { color: var(--ink); border-color: var(--rule-soft); }

/* ------------------------------------------------ previews and output boxes */
.tl-preview {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 10rem;
  padding: 0.6rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper-sunk);
  overflow: auto;
}
/* A checkerboard behind pictures, so see-through parts show as see-through. */
.tl-preview.tl-checker, .tl-checker {
  background-color: var(--checker-a);
  background-image:
    linear-gradient(45deg, var(--checker-b) 25%, transparent 25%, transparent 75%, var(--checker-b) 75%),
    linear-gradient(45deg, var(--checker-b) 25%, transparent 25%, transparent 75%, var(--checker-b) 75%);
  background-size: 20px 20px;
  background-position: 0 0, 10px 10px;
}
.tl-preview img, .tl-preview canvas, .tl-preview video { display: block; max-width: 100%; max-height: 70vh; object-fit: contain; }
.tl-preview.tl-pixelated img, .tl-preview.tl-pixelated canvas, .tl-pixelated { image-rendering: pixelated; }
.tl-preview-empty { color: var(--ink-soft); font-family: var(--font-ui); font-size: 0.95rem; text-align: center; }
.tl-output, pre.tl-output, .tl-code {
  display: block;
  width: 100%;
  margin: 0.6rem 0;
  padding: 0.75rem 0.9rem;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper-sunk);
  border: 1px solid var(--rule-soft);
  border-radius: var(--radius);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overflow: auto;
  max-height: 32rem;
  tab-size: 4;
}
.tl-output.tl-nowrap { white-space: pre; overflow-wrap: normal; }
:not(pre) > code { padding: 0.05rem 0.3rem; background: var(--paper-sunk); border: 1px solid var(--rule-soft); border-radius: 3px; }
kbd {
  padding: 0.05rem 0.35rem; font-size: 0.8em;
  border: 1px solid var(--rule); border-bottom-width: 2px; border-radius: 3px; background: var(--paper-raised);
}
.tl-meter { font-family: var(--font-ui); font-variant-numeric: tabular-nums; }
.tl-details { margin: 1rem 0; border: 1px solid var(--rule-soft); border-radius: var(--radius); background: var(--paper); }
.tl-details > summary {
  cursor: pointer;
  padding: 0.6rem 0.8rem;
  font-family: var(--font-display);
  font-size: 0.88rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent-bright);
}
.tl-details > :not(summary) { margin-left: 0.9rem; margin-right: 0.9rem; }
.tl-details[open] > summary { border-bottom: 1px solid var(--rule-soft); margin-bottom: 0.6rem; }

/* ------------------------------------------------------------------ footer */
.tl-footer {
  flex: none;
  margin-top: 2.5rem;
  border-top: 1px solid var(--rule);
  background: var(--paper);
}
.tl-footer > * { max-width: var(--measure); }
.tl-footer {
  padding: 1rem var(--gutter) 1.6rem;
  text-align: center;
  font-size: 1rem;
  color: var(--ink-soft);
}
.tl-footer p { margin: 0.35rem auto; max-width: 46rem; }
.tl-footer strong { color: var(--ink); }
.tl-footer a { color: var(--accent-bright); }

/* ------------------------------------------------------------ hub (/tools) */
.tl-hero { text-align: center; margin: 2rem auto 1.2rem; max-width: 48rem; }
.tl-hero .tl-title { font-size: clamp(1.6rem, 5.5vw, 2.6rem); }
.tl-hero .tl-lede { margin-left: auto; margin-right: auto; }
.tl-divider { display: flex; align-items: center; justify-content: center; gap: 0.7rem; width: 220px; max-width: 70%; margin: 0.8rem auto; }
.tl-divider::before, .tl-divider::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, var(--accent), transparent); }
.tl-divider span { width: 7px; height: 7px; background: var(--accent-bright); transform: rotate(45deg); flex: none; }
.tl-search { max-width: 34rem; margin: 1.2rem auto 0.4rem; }
.tl-search input { font-size: 1.05rem; }
.tl-search-count { text-align: center; font-family: var(--font-ui); font-size: 0.92rem; color: var(--ink-soft); min-height: 1.4em; margin: 0.3rem 0 0; }
.tl-cat { margin: 2rem 0 0; }
.tl-cat > h2 { display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap; border-bottom: 1px solid var(--rule); padding-bottom: 0.35rem; }
.tl-cat > h2 .tl-cat-count { font-family: var(--font-ui); font-size: 0.85rem; font-weight: 500; letter-spacing: 0; color: var(--ink-soft); }
.tl-cat-blurb { color: var(--ink-soft); margin: 0.2rem 0 0.9rem; }
.tl-cat[hidden], .tl-tool-card[hidden] { display: none; }
.tl-tool-card { padding: 0; display: flex; }
.tl-tool-card > a {
  display: flex; flex-direction: column; gap: 0.3rem;
  width: 100%;
  padding: 0.9rem 1rem 1rem;
  color: var(--ink);
  text-decoration: none;
  border-radius: var(--radius);
}
.tl-tool-card > a:hover { background: var(--paper-raised); }
.tl-tool-card > a:hover .tl-tool-name { text-decoration: underline; text-underline-offset: 3px; }
.tl-tool-name { margin: 0; font-family: var(--font-display); font-size: 1rem; letter-spacing: 0.04em; color: var(--accent-bright); }
.tl-tool-name::after { content: '\00a0\203A'; }   /* a no-break space, so the arrow never sits alone on a line */
.tl-tool-blurb { margin: 0; font-size: 1.05rem; line-height: 1.4; color: var(--ink); }
.tl-why { max-width: 46rem; margin: 2.5rem auto 0; }
.tl-why h2 { text-align: center; }
.tl-empty { text-align: center; color: var(--ink-soft); font-family: var(--font-ui); }

/* ------------------------------------------------------------- odds, ends */
.tl-js .tl-no-js { display: none; }
.tl-pill {
  display: inline-block; padding: 0.05rem 0.5rem; border: 1px solid var(--rule); border-radius: 999px;
  font-family: var(--font-ui); font-size: 0.78rem; color: var(--ink-soft);
}

@media (max-width: 480px) {
  .tl-btn { width: auto; }
  .tl-actions > .tl-btn { flex: 1 1 auto; }
  .tl-card { padding: 0.85rem 0.8rem; }
  .tl-theme-label { display: none; }
  .tl-theme::before { content: 'Night'; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

@media (forced-colors: active) {
  .tl-btn, .tl-drop, .tl-card, .tl-status, .tl-toast, [role="tab"][aria-selected="true"] { border: 2px solid CanvasText; }
  .tl-badge::before, .tl-theme-knob::after { background: CanvasText; }
}

@media print {
  .tl-header, .tl-footer, .tl-toasts, .tl-no-print, .tl-skip { display: none !important; }
  body { background: #fff; color: #000; }
}
