/* Inter, self-hosted (no third-party requests). The imprint contact image is rendered with the
   same font files, so it matches the page text. Subsets: scripts/build-fonts.mjs. */
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap; src: url('/assets/fonts/inter-400.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap; src: url('/assets/fonts/inter-600.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 700; font-display: swap; src: url('/assets/fonts/inter-700.woff2') format('woff2'); }

/* ==========================================================================
   TinyLab360 design system
   Tokens -> base -> layout -> components. Tool pages may add their own CSS
   for the tool area but should reuse tokens and components where possible.
   Fonts are self-hosted (Inter) – nothing is loaded from third parties.
   ========================================================================== */

:root {
  --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;

  --c-bg: #ffffff;
  --c-surface: #f6f7fb;
  --c-surface-2: #eceef6;
  --c-border: #dcdfea;
  --c-text: #161a2b;
  --c-text-muted: #5a6078;
  --c-primary: #4f46e5;
  --c-primary-hover: #4338ca;
  --c-primary-contrast: #ffffff;
  --c-accent: #0891b2;
  --c-success: #047857;
  --c-success-bg: #d1fae5;
  --c-warning: #92400e;
  --c-warning-bg: #fef3c7;
  --c-danger: #b91c1c;
  --c-focus: #f59e0b;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 4px 12px rgb(16 24 40 / 6%);

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-12: 3rem;

  --container: 72rem;
  --gutter: 1rem;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --c-bg: #0f1220;
    --c-surface: #171b2e;
    --c-surface-2: #20253c;
    --c-border: #2e3450;
    --c-text: #e8eaf4;
    --c-text-muted: #a2a8c3;
    --c-primary: #818cf8;
    --c-primary-hover: #a5b4fc;
    --c-primary-contrast: #0f1220;
    --c-accent: #22d3ee;
    --c-success: #6ee7b7;
    --c-success-bg: #06372a;
    --c-warning: #fcd34d;
    --c-warning-bg: #3b2a06;
    --c-danger: #f87171;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 4px 12px rgb(0 0 0 / 25%);
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--c-text);
  background: var(--c-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
img, svg, canvas { max-width: 100%; }
a { color: var(--c-primary); text-underline-offset: 2px; }
a:hover { color: var(--c-primary-hover); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 var(--space-4); }
h1 { font-size: clamp(1.75rem, 1.2rem + 2.2vw, 2.6rem); letter-spacing: -0.02em; }
h2 { font-size: clamp(1.35rem, 1.1rem + 1vw, 1.75rem); letter-spacing: -0.01em; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 var(--space-4); }
code, kbd, pre { font-family: var(--font-mono); font-size: 0.92em; }
kbd {
  padding: 0.05em 0.4em;
  border: 1px solid var(--c-border);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--c-surface);
}
:focus-visible { outline: 3px solid var(--c-focus); outline-offset: 2px; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: -999px; top: 0; z-index: 100; padding: var(--space-2) var(--space-4); background: var(--c-primary); color: var(--c-primary-contrast); }
.skip-link:focus { left: var(--space-2); top: var(--space-2); }

/* ---------- Layout ---------- */
.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: var(--gutter); }
.site-main { flex: 1; }
.section { padding-block: var(--space-8); }

.site-header { border-bottom: 1px solid var(--c-border); background: var(--c-bg); }
.site-header__inner { display: flex; align-items: center; gap: var(--space-6); min-height: 3.5rem; }
.logo { display: inline-flex; align-items: center; gap: var(--space-2); text-decoration: none; color: var(--c-text); font-size: 1.15rem; }
.logo strong { color: var(--c-primary); }
.site-nav { flex: 1; }
.site-nav__link { color: var(--c-text-muted); text-decoration: none; font-weight: 500; }
.site-nav__link:hover { color: var(--c-text); }
/* Language switcher: a <details> dropdown, works without JavaScript. */
.lang-switch { position: relative; }
.lang-switch__toggle {
  display: inline-flex; align-items: center; gap: var(--space-2);
  min-height: 2.25rem; padding: 0.3rem 0.6rem;
  border: 1px solid var(--c-border); border-radius: var(--radius);
  font-size: 0.9rem; font-weight: 600; color: var(--c-text);
  cursor: pointer; list-style: none; user-select: none;
}
.lang-switch__toggle::-webkit-details-marker { display: none; }
.lang-switch__toggle:hover { background: var(--c-surface); }
.lang-switch__chevron { transition: transform 0.15s; }
.lang-switch[open] .lang-switch__chevron { transform: rotate(180deg); }
.lang-switch__menu {
  position: absolute; right: 0; top: calc(100% + 0.35rem); z-index: 30;
  min-width: 12rem; max-height: 70vh; overflow-y: auto;
  margin: 0; padding: var(--space-1); list-style: none;
  background: var(--c-bg); border: 1px solid var(--c-border); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.lang-switch__link {
  display: flex; justify-content: space-between; align-items: center; gap: var(--space-4);
  padding: 0.45rem 0.65rem; border-radius: var(--radius-sm);
  color: var(--c-text); text-decoration: none; font-size: 0.95rem;
}
.lang-switch__link:hover { background: var(--c-surface-2); color: var(--c-text); }
.lang-switch__link.is-active { background: var(--c-surface-2); font-weight: 600; }
.lang-switch__code { font-size: 0.75rem; font-weight: 600; color: var(--c-text-muted); }

.site-footer { margin-top: var(--space-12); border-top: 1px solid var(--c-border); background: var(--c-surface); font-size: 0.9rem; color: var(--c-text-muted); }
.site-footer__inner { display: grid; gap: var(--space-4); padding-block: var(--space-8); }
.site-footer__about { max-width: 40rem; margin: 0; }
.site-footer a { color: var(--c-text-muted); }
.site-footer a:hover { color: var(--c-text); }
.site-footer__links, .site-footer__legal { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); }

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: var(--c-surface-2);
  --btn-fg: var(--c-text);
  --btn-border: var(--c-border);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 2.5rem; padding: 0.45rem 0.95rem;
  font: inherit; font-weight: 600; font-size: 0.95rem; line-height: 1.2;
  color: var(--btn-fg); background: var(--btn-bg);
  border: 1px solid var(--btn-border); border-radius: var(--radius);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { --btn-bg: var(--c-border); color: var(--btn-fg); }
.btn:disabled, .btn[aria-disabled='true'] { opacity: 0.5; cursor: not-allowed; }
.btn--primary { --btn-bg: var(--c-primary); --btn-fg: var(--c-primary-contrast); --btn-border: var(--c-primary); }
.btn--primary:hover { --btn-bg: var(--c-primary-hover); --btn-border: var(--c-primary-hover); }
.btn--secondary { --btn-bg: var(--c-bg); }
.btn--secondary:hover { --btn-bg: var(--c-surface); }
.btn--ghost { --btn-bg: transparent; --btn-border: transparent; }
.btn--ghost:hover { --btn-bg: var(--c-surface-2); }
.btn--sm { min-height: 2rem; padding: 0.3rem 0.65rem; font-size: 0.85rem; }
.btn--lg { min-height: 3rem; padding: 0.7rem 1.3rem; font-size: 1.05rem; }
.btn--icon { padding-inline: 0.55rem; }
.btn[aria-pressed='true'] { --btn-bg: var(--c-primary); --btn-fg: var(--c-primary-contrast); --btn-border: var(--c-primary); }

.btn-group { display: inline-flex; flex-wrap: wrap; gap: var(--space-1); }

/* ---------- Badges ---------- */
.badges { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.badge {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.25rem 0.7rem; border-radius: 999px;
  font-size: 0.85rem; font-weight: 600; line-height: 1.3;
  background: var(--c-surface-2); color: var(--c-text);
}
.badge--local { background: var(--c-success-bg); color: var(--c-success); }
.badge--offline { background: var(--c-surface-2); color: var(--c-accent); }
.badge--server { background: var(--c-warning-bg); color: var(--c-warning); }

/* ---------- Cards ---------- */
.card { background: var(--c-bg); border: 1px solid var(--c-border); border-radius: var(--radius-lg); padding: var(--space-6); box-shadow: var(--shadow); }

/* ---------- Forms ---------- */
.field { display: grid; gap: var(--space-1); }
.label { font-size: 0.85rem; font-weight: 600; color: var(--c-text-muted); }
.input, .select {
  min-height: 2.5rem; padding: 0.4rem 0.7rem; font: inherit;
  color: var(--c-text); background: var(--c-bg);
  border: 1px solid var(--c-border); border-radius: var(--radius);
}
input[type='range'] { accent-color: var(--c-primary); }
input[type='color'] { width: 2.5rem; height: 2.5rem; padding: 2px; border: 1px solid var(--c-border); border-radius: var(--radius); background: var(--c-bg); cursor: pointer; }

/* ---------- Home ---------- */
/* Hero text keeps a readable line length but stays aligned with the container below. */
.home-hero { padding-block: var(--space-12) var(--space-6); }
.home-hero > * { max-width: 52rem; }
.home-hero .lead, .lead { font-size: 1.15rem; color: var(--c-text-muted); }
.eyebrow { font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.8rem; color: var(--c-primary); margin-bottom: var(--space-2); }
.tool-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); }
.tool-card { display: flex; flex-direction: column; gap: var(--space-2); position: relative; }
.tool-card__cat { font-size: 0.8rem; font-weight: 600; color: var(--c-text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.tool-card__title { margin: 0; }
.tool-card__title a { color: var(--c-text); text-decoration: none; }
.tool-card__title a::after { content: ''; position: absolute; inset: 0; } /* whole card clickable */
.tool-card:hover { border-color: var(--c-primary); }
.tool-card__text { color: var(--c-text-muted); flex: 1; }
.root-chooser__list { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-3); }

/* ---------- Tool page frame ---------- */
.tool-hero { padding-block: var(--space-8) var(--space-6); }
.tool-hero__lead { font-size: 1.1rem; color: var(--c-text-muted); max-width: 48rem; }
.tool-area { /* The tool decides how this looks. Full width by default. */ }
/* Same left edge as the hero and the tool; only the line length is limited. */
.prose-area > * { max-width: 52rem; }

.steps { list-style: none; counter-reset: step; padding: 0; margin: 0; display: grid; gap: var(--space-4); }
.steps__item { counter-increment: step; position: relative; padding-left: 3rem; }
.steps__item::before {
  content: counter(step); position: absolute; left: 0; top: 0;
  width: 2.1rem; height: 2.1rem; border-radius: 50%; display: grid; place-items: center;
  background: var(--c-primary); color: var(--c-primary-contrast); font-weight: 700;
}
.steps__title { margin: 0.2rem 0 0.25rem; }
.steps__item p { margin: 0; color: var(--c-text-muted); }

.prose h3 { margin-top: var(--space-6); }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li { margin-bottom: var(--space-1); }

.faq { display: grid; gap: var(--space-2); }
.faq__item { border: 1px solid var(--c-border); border-radius: var(--radius); background: var(--c-bg); }
.faq__q { cursor: pointer; padding: var(--space-3) var(--space-4); font-weight: 600; list-style-position: inside; }
.faq__a { padding: 0 var(--space-4) var(--space-2); color: var(--c-text-muted); }
.faq__item[open] .faq__q { border-bottom: 1px solid var(--c-border); margin-bottom: var(--space-3); }

.not-found h1 { font-size: 4rem; color: var(--c-primary); }

@media (max-width: 40rem) {
  .site-header__inner { gap: var(--space-3); }
  .logo__text { display: none; }
  .lang-switch__current { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Imprint contact details: an image rendered from the IMPRESSUM_* variables
   (scripts/contact-image.mjs) in the page's font, size and colours – light and dark, 1x and 2x. */
.contact-image { display: block; max-width: 100%; height: auto; }

/* ---------- Tool panels (two-column text tools) ----------
   Shared by text tools: <div class="tool-panels"> with <section class="tool-panel"> children. */
.tool-panels { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 26rem), 1fr)); }
.tool-panel {
  display: flex; flex-direction: column; gap: var(--space-2); min-width: 0;
  padding: var(--space-3); background: var(--c-surface);
  border: 1px solid var(--c-border); border-radius: var(--radius-lg);
}
.is-dragover .tool-panel { border-color: var(--c-primary); background: var(--c-surface-2); }
.tool-panel__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2); }
.tool-panel__title { font-weight: 700; }
.code-box {
  width: 100%; height: clamp(14rem, 45vh, 32rem); margin: 0; padding: var(--space-3);
  font-family: var(--font-mono); font-size: 0.82rem; line-height: 1.55; color: var(--c-text);
  background: var(--c-bg); border: 1px solid var(--c-border); border-radius: var(--radius);
  resize: vertical; overflow: auto; white-space: pre; tab-size: 4;
}
.code-box--wrap { white-space: pre-wrap; word-break: break-all; }
.code-box--auto { height: auto; min-height: 4rem; max-height: 32rem; resize: none; }
.code-box:empty::before { content: attr(data-empty); color: var(--c-text-muted); font-family: var(--font-sans); }
.tool-status { min-height: 1.5em; margin: 0; font-size: 0.9rem; color: var(--c-text-muted); }
.tool-status.is-error { color: var(--c-danger); }
.tool-status.is-ok { color: var(--c-success); }
.tool-options { margin-top: var(--space-4); padding: var(--space-4) var(--space-6); }
.tool-options > summary { cursor: pointer; font-weight: 700; }
.tool-options__body { display: grid; gap: var(--space-4) var(--space-8); grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); margin-top: var(--space-3); }
.tool-fieldset { display: grid; gap: var(--space-2); align-content: start; margin: 0; padding: 0; border: 0; }
.tool-fieldset legend { margin-bottom: var(--space-2); font-size: 0.85rem; font-weight: 600; color: var(--c-text-muted); }
.tool-check { display: flex; align-items: center; gap: var(--space-2); font-size: 0.95rem; cursor: pointer; }
.tool-check input { accent-color: var(--c-primary); width: 1rem; height: 1rem; flex: none; }
.mark-hit { padding: 0 0.15em; border-radius: 3px; color: #111827; background: #fecaca; }
.mark-hit--soft { background: #bfdbfe; }
.tool-toast {
  position: fixed; left: 50%; bottom: var(--space-6); z-index: 50;
  max-width: min(560px, calc(100vw - 32px)); padding: 12px 18px; transform: translateX(-50%);
  border-radius: var(--radius); background: var(--c-text); color: var(--c-bg);
  font-weight: 600; box-shadow: var(--shadow);
}
.tool-toast[data-kind='error'] { background: var(--c-danger); color: #fff; }

/* ---------- Region selection after "Capture screen" (shared/image/crop.ts) ---------- */

.region-select {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  background: #1b2129;
}
.region-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px 16px;
  background: var(--c-bg);
  border-bottom: 1px solid var(--c-border);
}
.region-hint { flex: 1; margin: 0; font-weight: 600; }
.region-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 12px;
  overflow: hidden;
}
.region-frame { position: relative; flex: none; cursor: crosshair; touch-action: none; user-select: none; overflow: hidden; }
.region-image { display: block; width: 100%; height: 100%; }
.region-dim { position: absolute; inset: 0; background: rgb(0 0 0 / 35%); }
.region-selection {
  position: absolute;
  border: 2px solid #fff;
  outline: 1px dashed var(--c-primary);
  box-shadow: 0 0 0 9999px rgb(0 0 0 / 45%);
  pointer-events: none;
}


/* Staging site (test.tinylab360.com) */
.staging-banner {
  margin: 0;
  padding: 0.35rem var(--gutter);
  background: var(--c-warning-bg);
  color: var(--c-warning);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
}
