/* ============================================================
   Generador de Códigos QR Universal · 1000HW v2
   Vanilla CSS, mobile-first, sin dependencias externas
   ============================================================ */

/* ─── Reset y variables ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

:root,
[data-theme="dark"] {
  --void: #050505;
  --void-2: #0a0a0a;
  --soft-gray: #1a1a1a;
  --structure: #333333;
  --structure-2: #444444;
  --concrete: #e0e0e0;
  --neutral-300: #cccccc;
  --neutral-400: #aaaaaa;
  --neutral-500: #888888;
  --neutral-600: #666666;
  --acid: #ccff00;
  --acid-dim: #b3e600;
  --warn: #f5c518;
  --err: #ff6b6b;
  --ok: #5ee68a;
  --ink-strong: #ffffff;
  --body-pattern: radial-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  --panel-bg: #0f0f0f;
  --input-bg: #0a0a0a;
  --modal-overlay: rgba(0, 0, 0, 0.8);

  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;

  --radius: 4px;
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 24px rgba(204, 255, 0, 0.2);
  --max-width: 1100px;
  --transition: 200ms ease;
}

[data-theme="light"] {
  --void: #ffffff;
  --void-2: #f4f4f4;
  --soft-gray: #ececec;
  --structure: #cfcfcf;
  --structure-2: #b8b8b8;
  --concrete: #181818;
  --neutral-300: #4f4f4f;
  --neutral-400: #a8a8a8a;
  --neutral-500: #8a8a8a;
  --neutral-600: #888888;
  --acid: #7da000;
  --acid-dim: #547300;
  --warn: #b88500;
  --err: #c4392f;
  --ok: #2d9a55;
  --ink-strong: #050505;
  --body-pattern: radial-gradient(rgba(0, 0, 0, 0.04) 1px, transparent 1px);
  --panel-bg: #f9f9f9;
  --input-bg: #ffffff;
  --modal-overlay: rgba(0, 0, 0, 0.45);
}

/* ─── Base ──────────────────────────────────────────────────── */
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  color: var(--concrete);
  background-color: var(--void);
  background-image: var(--body-pattern);
  background-size: 32px 32px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--transition), color var(--transition);
}

::selection { background: var(--acid); color: var(--void); }

a {
  color: var(--acid);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover, a:focus-visible { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--acid);
  outline-offset: 2px;
}

h1, h2, h3, h4 { margin: 0 0 0.6em; font-weight: 700; letter-spacing: -0.01em; }
p { margin: 0 0 1em; }

button { font-family: inherit; }

/* ─── Offline-ready banner ──────────────────────────────────── */
.offline-banner {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: var(--acid);
  color: var(--void);
  font-size: 0.875rem;
  font-weight: 600;
  animation: slide-down 350ms ease-out;
}
.offline-banner[hidden] { display: none; }
.offline-banner__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--void);
  color: var(--acid);
  font-weight: 800;
  font-size: 0.75rem;
}
.offline-banner__text { flex: 1; }
.offline-banner__close {
  background: transparent;
  border: 0;
  color: var(--void);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.4rem;
  border-radius: var(--radius);
  min-height: 44px;
  min-width: 44px;
}
.offline-banner__close:hover { background: rgba(0, 0, 0, 0.15); }

@keyframes slide-down {
  from { transform: translateY(-100%); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .offline-banner { animation: none; }
}

/* ─── Site header / nav ─────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(5, 5, 5, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--structure);
}
.offline-banner:not([hidden]) ~ .site-header { top: 38px; }

.site-nav {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.site-nav__back {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--neutral-500);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  transition: color var(--transition);
}
.site-nav__back:hover { color: var(--acid); text-decoration: none; }
.site-nav__brand {
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}
.site-nav__brand-accent { color: var(--acid); }

/* ─── Main / hero ───────────────────────────────────────────── */
.site-main {
  flex: 1;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1rem 3rem;
}

.tool-hero {
  border-bottom: 1px solid var(--structure);
  padding-bottom: 1.75rem;
  margin-bottom: 2rem;
}
.tool-hero__cat {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  border: 1px solid var(--acid);
  color: var(--acid);
  padding: 0.25rem 0.6rem;
  margin-bottom: 1rem;
}
.tool-hero__title {
  font-size: clamp(2rem, 5vw + 1rem, 3.2rem);
  line-height: 1.05;
  color: #ffffff;
  margin: 0 0 1rem;
}
.tool-hero__lead {
  font-size: clamp(1rem, 1.5vw + 0.6rem, 1.15rem);
  color: var(--neutral-400);
  max-width: 65ch;
  margin: 0;
}

/* ─── Tool layout ───────────────────────────────────────────── */
.tool-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}
.tool-controls {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-width: 0;
}

/* ─── Panel ─────────────────────────────────────────────────── */
.panel {
  background: var(--void);
  border: 1px solid var(--structure);
  border-radius: var(--radius);
  padding: 1.5rem;
  position: relative;
  margin: 0;
}
.panel__tab {
  position: absolute;
  top: -0.7rem;
  left: 0.85rem;
  background: var(--acid);
  color: var(--void);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius);
}
.panel__title {
  font-size: 1.25rem;
  color: #ffffff;
  margin: 0 0 0.25rem;
  font-weight: 700;
}
.panel__hint {
  color: var(--neutral-500);
  font-size: 0.9rem;
  margin: 0 0 1.25rem;
}
.panel__group {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--structure);
}
.panel__group:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

/* ─── Field ─────────────────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}
.field[hidden] { display: none !important; }
.field:last-child { margin-bottom: 0; }
.field label,
.field--inline-check label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--neutral-500);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.field--inline-check {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  margin: 0;
}
.field--inline-check label {
  text-transform: none;
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--neutral-300);
  letter-spacing: 0;
  cursor: pointer;
}
.field--inline-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--acid);
  margin: 0;
  flex: 0 0 auto;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.field-help {
  font-size: 0.75rem;
  color: var(--neutral-500);
  margin: 0.3rem 0 0;
}
.field-help code {
  font-family: var(--font-mono);
  background: var(--soft-gray);
  padding: 0.05em 0.3em;
  border-radius: 2px;
  color: var(--acid);
  font-size: 0.95em;
}

.char-counter {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--neutral-600);
}

/* ─── Inputs ────────────────────────────────────────────────── */
.field input[type="text"],
.field input[type="tel"],
.field input[type="email"],
.field input[type="url"],
.field input[type="number"],
.field input[type="datetime-local"],
.field textarea,
.field select {
  background: var(--soft-gray);
  border: 1px solid var(--structure);
  border-radius: var(--radius);
  color: #ffffff;
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 0.65rem 0.75rem;
  width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition);
  min-height: 44px;
}
.field textarea { resize: vertical; min-height: 80px; }
.field input::placeholder,
.field textarea::placeholder { color: var(--neutral-600); }
.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--acid);
  box-shadow: 0 0 0 3px rgba(204, 255, 0, 0.18);
  outline: none;
}
.field select {
  cursor: pointer;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--neutral-500) 50%),
    linear-gradient(135deg, var(--neutral-500) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 12px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 2rem;
}
.field select option { background: var(--void-2); color: #ffffff; }

/* ─── Type selector (radio buttons group) ──────────────────── */
.type-selector {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.5rem;
}
.type-selector__option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--structure);
  background: var(--soft-gray);
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  min-height: 44px;
}
.type-selector__option:hover { border-color: var(--acid); }
.type-selector__option input[type="radio"] {
  accent-color: var(--acid);
  flex: 0 0 auto;
  margin: 0;
}
.type-selector__option:has(input:checked) {
  border-color: var(--acid);
  background: rgba(204, 255, 0, 0.05);
}
.type-selector__label {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  font-size: 0.85rem;
  color: #ffffff;
  font-weight: 600;
  min-width: 0;
}
.type-selector__label small {
  font-weight: 400;
  color: var(--neutral-500);
  font-size: 0.7rem;
  text-transform: none;
  letter-spacing: 0;
}

/* ─── Color fields ──────────────────────────────────────────── */
.color-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.color-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.color-field__label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--neutral-500);
}
.color-field__swatch {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.color-field__swatch-box {
  width: 56px;
  height: 56px;
  border: 1px solid var(--structure);
  cursor: pointer;
  border-radius: var(--radius);
  flex: 0 0 auto;
  transition: border-color var(--transition);
}
.color-field__swatch-box:hover,
.color-field__swatch-box:focus-visible { border-color: var(--acid); }
.color-field__hex {
  flex: 1;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--structure);
  color: #ffffff;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 0.35rem 0;
  text-transform: uppercase;
  border-radius: 0;
  min-width: 0;
  min-height: 36px;
}
.color-field__hex:focus {
  outline: none;
  border-color: var(--acid);
}
.color-field__hint {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--neutral-600);
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ─── Mobile: color row stacks vertically (fixes hex-input overflow ≤600px) ── */
@media (max-width: 600px) {
  .color-row {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }
  /* Hint at the larger hex font on narrow viewports so the value stays legible
     without forcing a horizontal scroll inside the input. */
  .color-field__hex { font-size: 0.9rem; }
}

/* ─── Logo upload ───────────────────────────────────────────── */
.logo-upload {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px dashed var(--structure);
  background: var(--soft-gray);
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color var(--transition);
  font-size: 0.9rem;
  color: var(--neutral-300);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.8rem;
  min-height: 44px;
}
.logo-upload:hover { border-color: var(--acid); }
.logo-upload input[type="file"] {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}
.logo-upload__badge {
  background: var(--acid);
  color: var(--void);
  padding: 0.15rem 0.4rem;
  border-radius: 2px;
  font-size: 0.65rem;
  font-weight: 700;
}

/* ─── Expert details ────────────────────────────────────────── */
.expert-details {
  background: var(--void);
  border: 1px solid var(--structure);
  border-radius: var(--radius);
  position: relative;
  margin: 0;
}
.expert-details > summary {
  list-style: none;
  cursor: pointer;
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  user-select: none;
}
.expert-details > summary::-webkit-details-marker { display: none; }
.expert-details > summary::after {
  content: "▾";
  margin-left: auto;
  color: var(--acid);
  transition: transform var(--transition);
}
.expert-details[open] > summary::after { transform: rotate(180deg); }
.expert-details__title {
  font-size: 1.05rem;
  color: #ffffff;
  font-weight: 700;
}
.expert-details__sub {
  font-size: 0.8rem;
  color: var(--neutral-500);
}
.expert-details__body {
  padding: 1.25rem 1.5rem 1.5rem;
  border-top: 1px solid var(--structure);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.expert-details__group-title {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--acid);
  margin: 0 0 0.75rem;
  border-left: 2px solid var(--acid);
  padding: 0 0 0 0.5rem;
  margin-left: -0.5rem;
}
.expert-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}
.expert-checkbox {
  display: flex;
  gap: 0.5rem;
  border: 1px solid var(--structure);
  padding: 0.7rem;
  background: var(--void);
  cursor: pointer;
  border-radius: var(--radius);
  transition: border-color var(--transition);
}
.expert-checkbox:hover { border-color: var(--acid); }
.expert-checkbox input[type="checkbox"] {
  accent-color: var(--acid);
  margin-top: 0.2rem;
  flex: 0 0 auto;
}
.expert-checkbox__label {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.85rem;
  min-width: 0;
}
.expert-checkbox__title { color: #ffffff; font-weight: 700; }
.expert-checkbox__sub { color: var(--neutral-500); font-size: 0.75rem; }

/* ─── Slider ────────────────────────────────────────────────── */
.slider-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--neutral-400);
  margin-bottom: 0.3rem;
}
.slider-row strong {
  font-family: var(--font-mono);
  color: var(--acid);
  font-size: 0.95rem;
  font-weight: 700;
}
.slider {
  width: 100%;
  height: 24px;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
}
.slider::-webkit-slider-runnable-track {
  width: 100%; height: 4px;
  background: var(--structure);
  border-radius: 2px;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  background: var(--acid);
  cursor: pointer;
  margin-top: -6px;
  border-radius: 0; border: 0;
}
.slider::-moz-range-track {
  width: 100%; height: 4px;
  background: var(--structure);
  border-radius: 2px;
}
.slider::-moz-range-thumb {
  width: 16px; height: 16px;
  background: var(--acid);
  cursor: pointer;
  border-radius: 0; border: 0;
}
.slider-info {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--neutral-500);
  background: var(--void-2);
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--structure);
  margin-top: 0.4rem;
}
.slider-info strong { color: #ffffff; }

/* ─── Expiration / batch panels ─────────────────────────────── */
.expiration-panel,
.batch-panel {
  margin-top: 0.5rem;
  padding: 0.75rem;
  background: var(--void-2);
  border: 1px solid var(--structure);
  border-radius: var(--radius);
}
.expiration-panel[hidden],
.batch-panel[hidden] { display: none; }
.batch-panel__row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 0.5rem;
  margin: 0.5rem 0 0.75rem;
}

/* ─── Buttons ───────────────────────────────────────────────── */
.btn {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.95rem;
  border: 0;
  border-radius: var(--radius);
  padding: 0.75rem 1.2rem;
  cursor: pointer;
  min-height: 44px;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition), color var(--transition);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.btn--primary {
  background: var(--acid);
  color: var(--void);
  box-shadow: var(--shadow-glow);
}
.btn--primary:hover, .btn--primary:focus-visible {
  background: var(--acid-dim);
  transform: translateY(-1px);
}
.btn--primary:active { transform: translateY(0); }
.btn--primary:disabled {
  background: var(--structure);
  color: var(--neutral-500);
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}
.btn--ghost {
  background: var(--void);
  color: var(--concrete);
  border: 1px solid var(--structure);
}
.btn--ghost:hover { border-color: var(--concrete); }
.btn--full { width: 100%; }

/* ─── Alerts ────────────────────────────────────────────────── */
.alert {
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  font-size: 0.9rem;
  margin: 0 0 2rem;
}
.alert[hidden] { display: none; }
.alert--error {
  background: rgba(255, 107, 107, 0.1);
  border: 1px solid rgba(255, 107, 107, 0.5);
  color: var(--err);
}
.alert--info {
  background: var(--soft-gray);
  border-left: 4px solid var(--acid);
  color: var(--neutral-400);
}
.alert--info strong { color: var(--acid); }

/* ─── Preview panel ─────────────────────────────────────────── */
.preview-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-self: start;
  position: sticky;
  top: 4.5rem;
}
.preview-panel__bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.5rem;
}
.preview-panel__bar-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--neutral-500);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  flex: 1;
}
.preview-panel__contrast {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
}
.contrast--perfect { color: var(--acid); }
.contrast--ok { color: #f5c518; }
.contrast--err { color: var(--err); }
.traffic-light {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex: 0 0 auto;
}
.traffic-light--perfect { background: var(--acid); box-shadow: 0 0 8px var(--acid); }
.traffic-light--ok { background: #f5c518; box-shadow: 0 0 8px #f5c518; }
.traffic-light--err { background: var(--err); box-shadow: 0 0 12px var(--err); }

.preview-canvas-wrap {
  background: #ffffff;
  border: 2px solid var(--structure);
  padding: 1rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 280px;
  border-radius: var(--radius);
}
.preview-canvas-wrap canvas {
  display: block;
  max-width: 100%;
  height: auto;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.preview-watermark {
  position: absolute;
  bottom: 0.25rem;
  right: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: rgba(0, 0, 0, 0.25);
  transform: rotate(-90deg);
  transform-origin: bottom right;
  letter-spacing: 0.1em;
  pointer-events: none;
  user-select: none;
}

.preview-meta {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--neutral-500);
  padding: 0 0.5rem;
}
.preview-meta span { white-space: nowrap; }

.actions-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

/* ─── Prose (contenido corto + largo) ───────────────────────── */
.prose, .long-content {
  max-width: 70ch;
  margin: 0 auto 3rem;
  color: var(--neutral-400);
  line-height: 1.65;
}
.prose h2, .long-content h2 {
  color: #ffffff;
  font-size: 1.6rem;
  margin-top: 2.2rem;
  border-bottom: 1px solid var(--structure);
  padding-bottom: 0.4rem;
}
.prose h2:first-child, .long-content h2:first-child { margin-top: 0; }
.prose h3, .long-content h3 {
  color: var(--acid);
  font-size: 1.2rem;
  margin-top: 1.8rem;
}
.prose p, .long-content p { margin: 0 0 1em; }
.prose ul, .prose ol, .long-content ul, .long-content ol {
  padding-left: 1.4em;
  margin: 0 0 1em;
}
.prose li, .long-content li { margin-bottom: 0.4em; }
.prose code, .long-content code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--soft-gray);
  padding: 0.1em 0.35em;
  border-radius: 3px;
  color: var(--acid);
  /* Long unbreakable tokens (e.g. WIFI:T:WPA;S:…;P:…;;, file names)
     must wrap on narrow viewports or they expand <body> past viewport.
     overflow-wrap: anywhere allows breaks inside the token when no
     natural break point exists. */
  overflow-wrap: anywhere;
  word-break: break-word;
}
/* Belt-and-suspenders: make <p> wrappers themselves allow mid-word breaks
   so the long token shrinks the container rather than overflowing it. */
.prose p, .long-content p {
  overflow-wrap: anywhere;
}
.prose details, .long-content details {
  border: 1px solid var(--structure);
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  margin: 0 0 0.6em;
  background: var(--void-2);
}
.prose details summary, .long-content details summary {
  cursor: pointer;
  font-weight: 600;
  color: #ffffff;
  list-style: none;
}
.prose details summary::-webkit-details-marker,
.long-content details summary::-webkit-details-marker { display: none; }
.prose details summary::before,
.long-content details summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 0.5rem;
  transition: transform var(--transition);
}
.prose details[open] summary::before,
.long-content details[open] summary::before { transform: rotate(90deg); }
.prose details p, .long-content details p { margin: 0.6em 0 0; }

.long-content {
  border-top: 1px solid var(--structure);
  padding-top: 2.5rem;
}

/* Glosario */
.glossary { margin: 0; }
.glossary dt {
  font-weight: 700;
  color: #ffffff;
  margin-top: 0.8em;
}
.glossary dd {
  margin: 0.2em 0 0 0;
  padding-left: 0;
}

/* ─── Footer ────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--structure);
  padding: 1.5rem 1rem;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--neutral-600);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.site-footer a { color: var(--neutral-500); }
.site-footer a:hover { color: var(--acid); text-decoration: none; }
.site-footer p { margin: 0.3em 0; }
.site-footer__small { text-transform: none; letter-spacing: 0.02em; }

/* ─── Donation toast ────────────────────────────────────────── */
.donation-toast {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 200;
  /* Force width (not just max-width) so flex children cannot stretch the
     container past 360px on desktop. Previously it grew to 408px because
     the .donation-toast__body text kept its intrinsic width. */
  width: min(360px, calc(100vw - 2rem));
  max-width: min(360px, calc(100vw - 2rem));
  box-sizing: border-box;
  background: var(--void-2);
  border: 1px solid var(--structure);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 0.85rem 1rem;
  display: flex;
  gap: 0.75rem;
  align-items: center;
  animation: toast-in 600ms cubic-bezier(0.16, 1, 0.3, 1);
}
.donation-toast[hidden] { display: none; }
@keyframes toast-in {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .donation-toast { animation: none; }
}

.donation-toast__icon {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  background: rgba(204, 255, 0, 0.12);
  color: var(--acid);
  border-radius: var(--radius);
}
.donation-toast__body {
  flex: 1;
  min-width: 0;
  /* Allow long sub-text to wrap so it never forces the toast wider
     than its max-width. */
  overflow-wrap: anywhere;
  word-break: break-word;
}
.donation-toast__title {
  margin: 0 0 0.2em;
  font-size: 0.9rem;
  font-weight: 700;
  color: #ffffff;
}
.donation-toast__sub {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--neutral-500);
  line-height: 1.35;
}
.donation-toast__actions {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding-left: 0.6rem;
  border-left: 1px solid var(--structure);
}
.donation-toast__btn {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border: 0;
  background: transparent;
  padding: 0.35rem 0;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  border-radius: var(--radius);
  min-height: 28px;
  text-align: center;
}
.donation-toast__btn--primary { color: var(--acid); font-weight: 700; }
.donation-toast__btn--primary:hover { color: var(--acid-dim); text-decoration: underline; }
.donation-toast__btn--ghost { color: var(--neutral-600); }
.donation-toast__btn--ghost:hover { color: var(--concrete); }

/* ─── Mobile: donation toast compact / full-width (fixes overflow ≤600px) ── */
@media (max-width: 600px) {
  .donation-toast {
    /* Span almost the full viewport, with a tight safe-area margin. */
    left: 0.75rem;
    right: 0.75rem;
    bottom: 0.75rem;
    max-width: none;
    width: auto;
    padding: 0.7rem 0.85rem;
    gap: 0.6rem;
  }
  .donation-toast__icon {
    width: 32px;
    height: 32px;
  }
  .donation-toast__actions {
    /* Allow the actions column to shrink below its content's intrinsic
       width when the body column grows. Without this, the toast overflows
       on viewports < ~360px because the buttons are white-space: nowrap. */
    min-width: 0;
    flex-shrink: 1;
    padding-left: 0.5rem;
    gap: 0.25rem;
  }
  .donation-toast__btn {
    font-size: 0.72rem;
    padding: 0.4rem 0.5rem;
    min-height: 32px;
  }
}

/* Below ~380px the toast body becomes too tight with the actions column on
   the right, so we stack: icon+body on top row, full-width actions below.
   Keeps WCAG contrast and aria-label intact (visual layout only). */
@media (max-width: 380px) {
  .donation-toast {
    flex-wrap: wrap;
    align-items: stretch;
  }
  .donation-toast__icon {
    align-self: flex-start;
  }
  .donation-toast__body {
    flex: 1 1 auto;
    min-width: 0;
  }
  .donation-toast__actions {
    flex: 1 0 100%;
    flex-direction: row;
    justify-content: flex-end;
    gap: 0.6rem;
    padding-left: 0;
    padding-top: 0.5rem;
    margin-top: 0.4rem;
    border-left: 0;
    border-top: 1px solid var(--structure);
  }
}

/* ─── Color picker modal ────────────────────────────────────── */
.color-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.color-modal[hidden] { display: none; }
.color-modal__card {
  background: #0f0f0f;
  border: 1px solid var(--acid);
  box-shadow: 0 0 50px rgba(204, 255, 0, 0.2);
  padding: 1.5rem;
  max-width: 360px;
  width: calc(100% - 2rem);
  position: relative;
  border-radius: var(--radius);
}
.color-modal__close {
  position: absolute;
  top: 0.25rem;
  right: 0.5rem;
  background: transparent;
  border: 0;
  color: var(--neutral-500);
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius);
  min-height: 44px;
  min-width: 44px;
}
.color-modal__close:hover { color: #ffffff; background: rgba(255, 255, 255, 0.05); }
.color-modal__title {
  font-size: 1.1rem;
  color: #ffffff;
  margin: 0 0 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.color-map, .hue-slider {
  display: block;
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--structure);
}
.color-map { height: 200px; cursor: crosshair; touch-action: none; margin-bottom: 0.75rem; }
.hue-slider { height: 30px; cursor: ew-resize; touch-action: none; margin-bottom: 1rem; }
.color-modal__footer {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.color-modal__preview {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
}
.color-modal__preview-box {
  width: 32px;
  height: 32px;
  border: 1px solid #ffffff;
  flex: 0 0 auto;
  border-radius: var(--radius);
}
.color-modal__preview-hex {
  font-family: var(--font-mono);
  color: var(--acid);
  font-size: 0.9rem;
  flex: 1;
}

/* ─── Mobile-only: form inputs respect parent width (BUG-1 fix) ──
   Without this, default <input size="20"> keeps a ~150px intrinsic
   width on narrow viewports and pushes <body> past viewport width.
   Only applies ≤600px — desktop unchanged. */
@media (max-width: 600px) {
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="url"],
  input[type="number"],
  input[type="search"],
  input[type="password"],
  input[type="datetime-local"],
  textarea,
  select {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }
}

/* ─── Skip-link (WCAG 2.1 — Bypass Blocks) ────────────────── */
.skip-link {
  position: absolute;
  top: -100px;
  left: 0.5rem;
  background: var(--acid);
  color: var(--void);
  padding: 0.6rem 1rem;
  font-weight: 700;
  text-decoration: none;
  z-index: 9999;
  border-radius: var(--radius);
  border: 2px solid var(--void);
}
.skip-link:focus,
.skip-link:focus-visible {
  top: 0.5rem;
  outline: 3px solid var(--ink-strong);
}

/* ─── Theme + Lang toggles (HIGH gap #4, #3) ─────────────────── */
.toolbar-toggles {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: auto;
}
.toggle-btn {
  background: transparent;
  border: 1px solid var(--structure-2);
  color: var(--neutral-300);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.4rem 0.65rem;
  border-radius: var(--radius);
  cursor: pointer;
  min-height: 36px;
  min-width: 36px;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.toggle-btn:hover { background: var(--soft-gray); color: var(--acid); }
.toggle-btn[aria-pressed="true"],
.toggle-btn.is-active {
  background: var(--acid);
  color: var(--void);
  border-color: var(--acid);
}
.toggle-btn:focus-visible {
  outline: 2px solid var(--acid);
  outline-offset: 2px;
}
@media (max-width: 600px) {
  .site-nav { gap: 0.5rem; flex-wrap: wrap; padding: 0.6rem 0.75rem; }
  .site-nav__brand { display: none; }
  .toggle-btn { font-size: 0.72rem; padding: 0.35rem 0.5rem; min-height: 32px; }
}

/* ─── History panel (HIGH gap #5) ─────────────────────────────── */
.history-panel {
  margin: 1.25rem 0 0;
  padding: 1rem 1.25rem 1.25rem;
  background: var(--panel-bg);
  border: 1px solid var(--structure);
  border-radius: var(--radius);
}
.history-panel__title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
  margin: 0 0 0.75rem;
}
.history-panel__count {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--neutral-500);
  font-weight: 400;
}
.history-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.65rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.history-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem;
  background: var(--void-2);
  border: 1px solid var(--structure);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition);
  text-align: center;
  font-size: 0.78rem;
  color: var(--neutral-300);
}
.history-item:hover { border-color: var(--acid); transform: translateY(-1px); }
.history-item:focus-visible {
  outline: 2px solid var(--acid);
  outline-offset: 2px;
}
.history-item__img {
  width: 84px;
  height: 84px;
  background: #fff;
  border-radius: 2px;
  display: block;
  image-rendering: pixelated;
}
.history-item__type {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--acid);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.history-item__snippet {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--neutral-500);
  width: 100%;
}
.history-empty {
  color: var(--neutral-500);
  font-style: italic;
  padding: 1rem;
  text-align: center;
  grid-column: 1 / -1;
  font-size: 0.85rem;
}
.history-clear {
  background: transparent;
  border: 1px solid var(--structure-2);
  color: var(--neutral-400);
  font-size: 0.75rem;
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius);
  cursor: pointer;
  margin-left: auto;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: inherit;
  min-height: 36px;
}
.history-clear:hover { color: var(--err); border-color: var(--err); }
@media (max-width: 600px) {
  .history-list { grid-template-columns: repeat(auto-fill, minmax(95px, 1fr)); gap: 0.45rem; }
  .history-item__img { width: 72px; height: 72px; }
}

/* ─── Light theme: ensure print & overlays look right ─────────── */
[data-theme="light"] .preview-canvas-wrap { border-color: var(--structure-2); }
[data-theme="light"] .panel { background: var(--panel-bg); }
[data-theme="light"] .field input,
[data-theme="light"] .field select,
[data-theme="light"] .field textarea {
  background: var(--input-bg);
  color: var(--concrete);
  border-color: var(--structure);
}
[data-theme="light"] .color-modal { background: var(--modal-overlay); }
[data-theme="light"] .color-modal__card { background: var(--input-bg); color: var(--concrete); }
[data-theme="light"] .color-modal__close { color: var(--neutral-500); }
[data-theme="light"] .color-modal__close:hover { color: var(--ink-strong); }
[data-theme="light"] .glossary dt { color: var(--ink-strong); }
[data-theme="light"] .preview-canvas-wrap { background: #fff; }
[data-theme="light"] .preview-watermark { color: rgba(0, 0, 0, 0.06); }
[data-theme="light"] .donation-toast { background: #1a1a1a; color: var(--concrete); }
[data-theme="light"] .donation-toast__title { color: var(--concrete); }

/* ─── Visually-hidden (WCAG: accessible but invisible) ────────── */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}


/* ─── Print ─────────────────────────────────────────────────── */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
    background-image: none !important;
  }
  .site-header, .offline-banner, .donation-toast,
  .actions-row, .preview-panel__bar, .preview-meta,
  .site-footer, .alert--info, .tool-controls, .color-modal {
    display: none !important;
  }
  .tool-layout { grid-template-columns: 1fr !important; }
  .preview-panel { position: static !important; }
  .preview-canvas-wrap { border-color: #999; box-shadow: none; }
  .prose, .long-content { color: #000; }
  .prose h2, .prose h3, .long-content h2, .long-content h3 { color: #000; }
}

/* ─── Breakpoints ───────────────────────────────────────────── */
@media (min-width: 700px) {
  .tool-layout { grid-template-columns: minmax(0, 1fr) 360px; gap: 1.5rem; }
  .expert-grid { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 900px) {
  .site-main { padding: 3rem 2rem 4rem; }
  .preview-canvas-wrap { min-height: 360px; }
  .donation-toast { bottom: 2rem; right: 2rem; }
}
@media (min-width: 1100px) {
  .tool-layout { grid-template-columns: minmax(0, 1fr) 420px; gap: 2rem; }
}
