:root {
  color-scheme: light;
  --bg: #f7f8f6;
  --panel: #ffffff;
  --text: #17201a;
  --muted: #5d685f;
  --line: #dce2dd;
  --accent: #146c43;
  --accent-strong: #0f5132;
  --focus: #b9e6cf;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.5;
}

a {
  color: var(--accent-strong);
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar {
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
}

.topbar .shell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  gap: 20px;
}

.brand {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  color: var(--text);
  font-size: 22px;
  font-weight: 700;
  text-decoration: none;
}

/* Breaking Bad-style element tiles for the W and U of the wordmark. */
.brand .tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.18em;
  height: 1.18em;
  margin: 0 1px;
  background: var(--accent);
  color: #fff;
  border-radius: 4px;
  line-height: 1;
}

.brand .tld {
  color: var(--muted);
  font-weight: 400;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  margin-left: auto;
  min-width: 0;
}

.language-links {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  gap: 10px;
  font-size: 14px;
  white-space: nowrap;
}

.market-picker {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 4px;
}

.market-picker .flag {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.5;
}

.market-picker .flag[aria-pressed="true"] {
  opacity: 1;
  border-color: var(--accent);
}

/* time.is-style focus: keep the hero compact so the tool + result sit
   above the fold, especially on mobile. The task is the page, not the headline. */
.hero {
  padding: 30px 0 14px;
}

.hero h1 {
  max-width: 780px;
  margin: 0;
  font-size: clamp(28px, 4.4vw, 48px);
  line-height: 1.08;
}

.hero p {
  max-width: 680px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 17px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  padding: 20px 0 48px;
}

.card,
.tool {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.card {
  padding: 20px;
  text-decoration: none;
  position: relative;
  overflow: hidden;
}

.card h3 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 21px;
}

.card p {
  margin: 0;
  color: var(--muted);
}

.note {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.tool {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 24px;
  padding: 24px;
  margin: 16px 0 40px;
  /* Reserve space so the JS-rendered tool doesn't shift the page (CLS). */
  min-height: 300px;
  align-content: start;
}

.controls,
.results {
  display: grid;
  align-content: start;
  gap: 16px;
}

.field {
  display: grid;
  gap: 6px;
}

[data-pixel-fields],
[data-print-fields] {
  display: grid;
  gap: 16px;
}

label,
.label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

input,
select,
button {
  min-height: 44px;
  border-radius: 8px;
  font: inherit;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  padding: 10px 12px;
  background: #fff;
  color: var(--text);
}

input:focus,
select:focus,
button:focus {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.segmented,
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

button {
  border: 1px solid var(--line);
  padding: 0 14px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

button[aria-pressed="true"],
.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}

.result-row strong {
  text-align: right;
  font-size: 17px;
  overflow-wrap: anywhere;
}

.hash-row {
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.hash-k {
  display: block;
  margin-bottom: 2px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.hash-v {
  display: block;
  font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13px;
  word-break: break-all;
  user-select: all;
}

.tool-chart {
  margin: 2px 0 4px;
}

.tool-chart .chart {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.chart-area {
  fill: var(--focus);
}

.chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

/* Explanatory diagrams inside content sections (static, hand-drawn SVG). */
.amort-diagram {
  display: block;
  width: 100%;
  max-width: 480px;
  height: auto;
  margin: 16px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.amort-diagram .d-interest {
  fill: #f0cdbc;
}

.amort-diagram .d-principal {
  fill: var(--focus);
}

.amort-diagram .d-label {
  font: 700 13px Arial, Helvetica, sans-serif;
  fill: var(--text);
}

/* The first row is the headline answer — make it the focal point. */
.result-row:first-child strong {
  font-size: 23px;
  line-height: 1.15;
  color: var(--accent-strong);
}

.content-section {
  max-width: 920px;
  padding: 8px 0 56px;
}

.content-section h2 {
  margin: 32px 0 10px;
  font-size: 28px;
  line-height: 1.2;
}

.content-section h3 {
  margin: 24px 0 8px;
  font-size: 20px;
}

.content-section p,
.content-section li {
  color: var(--muted);
}

.content-section ul {
  padding-left: 22px;
}

.formula {
  border-left: 4px solid var(--accent);
  margin: 18px 0;
  padding: 12px 16px;
  background: #fff;
  color: var(--text);
  font-weight: 700;
}

.content-section table {
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 14px;
}

.content-section th,
.content-section td {
  border: 1px solid var(--line);
  padding: 6px 12px;
  text-align: left;
}

.content-section th {
  background: #f1f3f0;
}

.diagram-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin: 20px 0;
}

.diagram {
  width: 100%;
  min-height: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

/* Internal linking strip (time.is-style density), below the useful content. */
.related {
  padding: 4px 0 36px;
}

.related h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.related-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  font-size: 14px;
}

.footer {
  border-top: 1px solid var(--line);
  padding: 24px 0;
  color: var(--muted);
  font-size: 14px;
}

@media (max-width: 760px) {
  .tool {
    grid-template-columns: 1fr;
    padding: 18px;
    margin: 12px 0 28px;
    min-height: 420px;
  }

  /* Maximise above-the-fold space for the tool itself on phones. */
  .hero {
    padding: 16px 0 8px;
  }

  .hero h1 {
    font-size: clamp(22px, 6.4vw, 30px);
  }

  .hero p {
    margin: 8px 0 0;
    font-size: 14.5px;
  }

  .result-row:first-child strong {
    font-size: 21px;
  }

  .topbar .shell {
    min-height: 56px;
    gap: 10px;
    padding: 0;
  }

  .brand {
    font-size: 16px;
  }

  .topbar-actions {
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .topbar-actions::-webkit-scrollbar {
    display: none;
  }

  .language-links {
    gap: 8px;
    font-size: 13px;
  }

  .market-picker .flag {
    min-height: 34px;
    padding: 2px 5px;
  }
}

textarea {
  width: 100%;
  min-height: 180px;
  border: 1px solid var(--line);
  padding: 12px;
  background: #fff;
  color: var(--text);
  font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 14px;
  border-radius: 8px;
  resize: vertical;
}

textarea:focus {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.checkbox-list {
  display: grid;
  gap: 10px;
  margin: 8px 0;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: normal;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: auto;
  min-height: auto;
  margin: 0;
  cursor: pointer;
}

.password-display {
  font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 20px;
  background: #f1f3f0;
  padding: 14px;
  border-radius: 8px;
  border: 1px dashed var(--line);
  text-align: center;
  word-break: break-all;
  user-select: all;
  margin-bottom: 12px;
}

.strength-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 16px;
}

.strength-bar {
  flex: 1;
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  position: relative;
}

.strength-fill {
  height: 100%;
  border-radius: 3px;
  width: 0;
  transition: width 0.3s, background-color 0.3s;
}

.strength-weak .strength-fill { background: #dc3545; width: 33%; }
.strength-medium .strength-fill { background: #ffc107; width: 66%; }
.strength-strong .strength-fill { background: #198754; width: 100%; }

.qr-preview {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 200px;
}

.qr-preview canvas, .qr-preview img {
  max-width: 100%;
  height: auto !important;
}

.bmi-indicator {
  font-size: 16px;
  font-weight: bold;
  padding: 6px 12px;
  border-radius: 6px;
  display: inline-block;
  margin-top: 8px;
}

.bmi-underweight { background: #cff4fc; color: #055160; }
.bmi-healthy { background: #d1e7dd; color: #0f5132; }
.bmi-overweight { background: #fff3cd; color: #664d03; }
.bmi-obese { background: #f8d7da; color: #842029; }

.word-count-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.word-count-card {
  background: #f8f9fa;
  border: 1px solid var(--line);
  padding: 12px;
  border-radius: 8px;
  text-align: center;
}

.word-count-card span {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.word-count-card strong {
  font-size: 18px;
  color: var(--text);
}

.density-list {
  display: grid;
  gap: 6px;
  font-size: 13px;
  margin-top: 10px;
}

.density-title {
  margin-top: 12px;
}

.world-clock {
  margin-top: 6px;
}

.wc-title {
  margin: 8px 0 4px;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
}

.wc-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 6px 0;
  font-size: 14px;
}

.wc-row strong {
  font-variant-numeric: tabular-nums;
}

/* Conversor de zonas: fila origen ⇄ destino. */
.tz-convert {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
}
.tz-convert .field {
  flex: 1 1 120px;
  min-width: 0;
}
.tz-swap {
  align-self: end;
  height: 40px;
  min-width: 44px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--accent-strong);
  border-radius: 8px;
  font-size: 18px;
  cursor: pointer;
}
.tz-swap:hover {
  border-color: var(--accent);
}

/* Reloj mundial: buscar y añadir ciudades. */
.wc-add {
  display: flex;
  gap: 8px;
  margin: 10px 0 6px;
}
.wc-add input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
}
.wc-add button {
  flex: 0 0 auto;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  padding: 0 16px;
  cursor: pointer;
  font-size: 14px;
}
.wc-add button:hover {
  background: var(--accent-strong);
}
.wc-city {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
}
.wc-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 8px;
  flex: 0 0 auto;
}
.wc-dot.day {
  background: #f4b740;
}
.wc-dot.night {
  background: #324b8f;
}
.wc-time em {
  color: var(--muted);
  font-size: 12px;
  margin-left: 8px;
}
.wc-utc {
  color: var(--muted);
  font-size: 11px;
  margin-left: 6px;
}
.wc-x {
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0 2px 0 8px;
  flex: 0 0 auto;
}
.wc-x:hover {
  color: #d14b4b;
}

.u-center {
  text-align: center;
}

.density-item {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px dashed var(--line);
  padding-bottom: 4px;
}

/* ---- Categorias: iconos, watermark, breadcrumb, grupos ---- */

/* Icono monocolor mint por categoria (compartido por tarjeta y watermark). */
.cat-finance { background-image: url(/assets/img/cat/finance.svg); }
.cat-datetime { background-image: url(/assets/img/cat/datetime.svg); }
.cat-math { background-image: url(/assets/img/cat/math.svg); }
.cat-text { background-image: url(/assets/img/cat/text.svg); }
.cat-developer { background-image: url(/assets/img/cat/developer.svg); }
.cat-converters { background-image: url(/assets/img/cat/converters.svg); }

/* En tarjeta: cuadrante inferior derecho, detras del texto. */
.card[class*="cat-"] {
  background-repeat: no-repeat;
  background-position: right -35px bottom -35px;
  background-size: 123px;
}

/* En pagina (main): watermark grande y tenue, sin estorbar controles. */
main.shell[class*="cat-"] {
  background-repeat: no-repeat;
  background-position: right -30px bottom 24px;
  background-size: 300px;
}

/* Breadcrumb. */
.breadcrumb {
  font-size: 13px;
  color: var(--muted);
  padding: 14px 0 0;
}
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent-strong); text-decoration: underline; }
.breadcrumb .sep { margin: 0 7px; color: var(--line); }
.breadcrumb [aria-current="page"] { color: var(--text); }

/* Home agrupado por categoria. */
.cat-group { position: relative; }
.cat-head {
  margin: 22px 0 2px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.cat-head a { color: var(--muted); text-decoration: none; }
.cat-head a:hover { color: var(--accent-strong); }
.cat-group .grid { padding: 12px 0 10px; }

/* Pie agrupado por categoria. */
.related-group { margin-bottom: 16px; }
.related-group h3 { margin: 0 0 6px; font-size: 14px; color: var(--text); }
.related-group h3 a { color: var(--text); text-decoration: none; }
.related-group h3 a:hover { color: var(--accent-strong); text-decoration: underline; }

/* Encabezado solo para lectores de pantalla (jerarquía h1>h2>h3 en hubs). */
.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;
}

