/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #f5f6f2;
  --surface: #ffffff;
  --surface-2: #eef1ec;
  --text: #14201c;
  --muted: #5b6863;
  --line: #dfe4de;
  --accent: #0f766e;
  --accent-strong: #0b5c56;
  --accent-soft: #d9f1ed;
  --sun: #f59e0b;
  --warn-bg: #fff6e0;
  --warn-text: #7a4b00;
  --danger: #b42318;
  --shadow: 0 1px 2px rgba(20, 32, 28, .06), 0 8px 24px rgba(20, 32, 28, .07);
  --radius: 18px;
  --radius-sm: 12px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1220; --surface: #121b2e; --surface-2: #1a2540; --text: #e7edf5; --muted: #9aa8bd;
    --line: #26324d; --accent: #2dd4bf; --accent-strong: #5eead4; --accent-soft: #123a3a;
    --warn-bg: #3a2c0b; --warn-text: #fcd38a; --danger: #f97066;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1220; --surface: #121b2e; --surface-2: #1a2540; --text: #e7edf5; --muted: #9aa8bd;
  --line: #26324d; --accent: #2dd4bf; --accent-strong: #5eead4; --accent-soft: #123a3a;
  --warn-bg: #3a2c0b; --warn-text: #fcd38a; --danger: #f97066;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--sans); font-size: 16px; line-height: 1.6; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; overflow-x: clip;
}
img, svg { display: block; max-width: 100%; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: var(--accent); text-underline-offset: 2px; }
p { text-wrap: pretty; }
h1, h2, h3 { text-wrap: balance; line-height: 1.15; letter-spacing: -0.015em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
::selection { background: var(--accent); color: #fff; }
.skip-link { position: fixed; top: -100px; left: 1rem; padding: .6rem 1rem; background: var(--surface); z-index: 999; border-radius: 8px; }
.skip-link:focus { top: 1rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* =============================================================
   3. Layout
   ============================================================= */
.wrap { width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 16px; }
main { padding-bottom: 48px; }
section { margin-top: 40px; }
.prose { max-width: 720px; }
.prose p, .prose ul, .prose ol { margin-top: .8em; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose h2 { margin-top: 1.4em; font-size: 1.4rem; }
.prose h3 { margin-top: 1.2em; font-size: 1.1rem; }
h2.sec-title { font-size: 1.45rem; margin-bottom: 12px; }
.sec-sub { color: var(--muted); margin-bottom: 16px; }

/* =============================================================
   4. Header & footer
   ============================================================= */
.site-header { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.site-header .wrap { display: flex; align-items: center; gap: 12px; height: 56px; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 800; color: var(--text); text-decoration: none; letter-spacing: -.02em; font-size: 1.08rem; }
.logo { min-width: 0; line-height: 1.1; }
.logo svg { width: 28px; height: 28px; flex: none; }
.nav { margin-left: auto; flex: none; display: flex; align-items: center; gap: 4px; }
.nav a { color: var(--text); text-decoration: none; padding: 8px 10px; border-radius: 10px; font-size: .94rem; font-weight: 600; white-space: nowrap; }
.btn-instalar { white-space: nowrap; }
@media (max-width: 539px) {
  .site-header .logo { font-size: .95rem; }
  .site-header .nav a { padding: 8px 6px; }
  /* Si aparece "Instalar app" no entra todo: queda solo el ícono de la marca. */
  .site-header .wrap:has(.btn-instalar:not([hidden])) .logo span { display: none; }
}
.nav a:hover { background: var(--surface-2); }
.nav .nav-opt { display: none; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; color: var(--text); }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 20px; height: 20px; }
.btn-instalar { padding: 8px 12px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; font-size: .9rem; }
.tema-sol { display: none; }
:root[data-theme="dark"] .tema-sol { display: block; }
:root[data-theme="dark"] .tema-luna { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tema-sol { display: block; }
  :root:not([data-theme="light"]) .tema-luna { display: none; }
}

.site-footer { border-top: 1px solid var(--line); background: var(--surface); padding: 32px 0 40px; font-size: .92rem; color: var(--muted); }
.foot-grid { display: grid; gap: 24px; }
.foot-grid h3 { font-size: .95rem; color: var(--text); margin-bottom: 8px; }
.foot-grid ul { list-style: none; padding: 0; display: grid; gap: 4px; }
.foot-grid a { color: var(--muted); }
.foot-legal { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); }

/* =============================================================
   5. Hero + tarjeta del conversor
   ============================================================= */
.hero { padding-top: 18px; }
.hero h1 { font-size: clamp(1.45rem, 5.4vw, 2.3rem); font-weight: 800; }
.hero .bajada { color: var(--muted); margin-top: 4px; font-size: .98rem; }

.tool-card { margin-top: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.campo-label { display: block; font-size: .8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.monto-input {
  width: 100%; font-size: 1.9rem; font-weight: 800; padding: 10px 14px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--line); background: var(--surface-2); font-variant-numeric: tabular-nums;
}
.monto-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }

.par { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 12px; position: relative; }
.picker {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 56px; padding: 8px 12px; text-align: left;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm); background: var(--surface);
  transition: border-color .2s var(--ease-out), background .2s var(--ease-out);
}
.picker:hover { border-color: var(--accent); }
.picker .flag { flex: none; }
.pk-code { font-weight: 800; font-size: 1.05rem; }
.pk-name { color: var(--muted); font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; }
.pk-caret { width: 18px; height: 18px; flex: none; color: var(--muted); }
.flag { width: 24px; height: 18px; object-fit: cover; border-radius: 3px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .08); background: var(--surface-2); }

.btn-invertir {
  justify-self: center; width: 44px; height: 44px; margin: -4px 0; display: grid; place-items: center; border-radius: 50%;
  background: var(--accent); color: #fff; box-shadow: var(--shadow); z-index: 1;
}
:root[data-theme="dark"] .btn-invertir { color: #052e2b; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-invertir { color: #052e2b; } }
.btn-invertir svg { width: 22px; height: 22px; transform: rotate(90deg); }
.btn-invertir.girar svg { animation: girar .45s var(--ease-out); }
@keyframes girar { from { transform: rotate(90deg); } to { transform: rotate(270deg); } }

.dolar-tipo { margin-top: 12px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: .92rem; }
.dolar-tipo label { font-weight: 700; }
.dolar-tipo select { padding: 8px 10px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface-2); font-weight: 600; }
.dolar-tipo small { color: var(--muted); flex-basis: 100%; }

.resultado-box { margin-top: 14px; padding: 14px; border-radius: var(--radius-sm); background: var(--accent-soft); }
.resultado { display: block; font-size: 1.05rem; line-height: 1.3; word-break: break-word; }
.resultado strong { font-size: clamp(1.7rem, 7.5vw, 2.4rem); font-weight: 800; color: var(--accent-strong); font-variant-numeric: tabular-nums; }
.res-from { color: var(--muted); display: block; font-size: .95rem; }
.res-code { font-weight: 700; color: var(--accent-strong); }
.tasa-linea { margin-top: 6px; font-size: .86rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.tool-card[data-state="loading"] .resultado { color: var(--muted); }
.tool-card[data-state="loading"] .resultado-box { animation: pulso 1.4s ease-in-out infinite; }
@keyframes pulso { 50% { opacity: .6; } }

.acciones { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; border-radius: 12px; font-weight: 700; font-size: .95rem; text-decoration: none; }
.btn-sec { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.btn-sec:hover { border-color: var(--accent); }
.link-btn { color: var(--accent); font-weight: 700; text-decoration: underline; padding: 0; }

.info-tasas { margin-top: 12px; font-size: .8rem; color: var(--muted); line-height: 1.5; }
.info-tasas a { color: var(--muted); }
.aviso { margin-top: 10px; padding: 10px 12px; border-radius: 10px; font-size: .86rem; background: var(--warn-bg); color: var(--warn-text); }
.aviso-ref { margin-top: 10px; font-size: .8rem; color: var(--muted); display: flex; gap: 6px; }
.error-tasas { margin-top: 10px; color: var(--danger); font-size: .9rem; }
.noscript { margin-top: 12px; padding: 12px; border-radius: 10px; background: var(--warn-bg); color: var(--warn-text); }

/* =============================================================
   6. Componentes
   ============================================================= */
/* Conversión múltiple */
.multi-card, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.multi-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.multi-head h2 { font-size: 1.2rem; }
.multi-lista { list-style: none; padding: 0; display: grid; gap: 6px; }
.multi-item { display: flex; align-items: center; gap: 4px; }
.multi-sel { flex: 1; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); text-align: left; min-width: 0; }
.multi-sel:hover { outline: 1.5px solid var(--accent); }
.mi-txt { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.25; }
.mi-code { font-weight: 800; }
.mi-name { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mi-val { font-weight: 800; font-variant-numeric: tabular-nums; text-align: right; }
.multi-vacio { color: var(--muted); padding: 8px 0; }
.star { width: 40px; height: 40px; flex: none; border-radius: 10px; font-size: 1.25rem; color: var(--line); line-height: 1; }
.star.is-on { color: var(--sun); }
.star:hover { background: var(--surface-2); }

/* Dólar en Argentina */
/* Tantas columnas como entren con un mínimo legible: se adapta al ancho real (también en la columna lateral). */
.dolar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 148px), 1fr)); gap: 8px; }
.dolar-card { min-width: 0; text-align: left; padding: 12px; border-radius: 14px; background: var(--surface); border: 1.5px solid var(--line); display: flex; flex-direction: column; gap: 2px; transition: border-color .2s var(--ease-out); }
.dolar-card:hover { border-color: var(--accent); }
.dolar-card.is-sel { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.dc-nombre { font-weight: 800; font-size: 1rem; }
.dc-fila { display: flex; justify-content: space-between; flex-wrap: wrap; column-gap: 6px; font-size: .88rem; }
.dc-fila b { margin-left: auto; white-space: nowrap; }
.dc-fila span:first-child { color: var(--muted); }
.dc-fila b { font-variant-numeric: tabular-nums; }
.dc-fecha { font-size: .72rem; color: var(--muted); margin-top: 4px; }
.dolar-nota { font-size: .82rem; color: var(--muted); margin-top: 10px; }

/* Tablas */
.tablas { display: grid; gap: 16px; }
.tabla-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.tabla-wrap h3 { font-size: 1rem; padding: 12px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
table.conv { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.conv th, table.conv td { padding: 9px 14px; text-align: left; border-bottom: 1px solid var(--line); }
table.conv tr:last-child td { border-bottom: 0; }
table.conv td:last-child, table.conv th:last-child { text-align: right; font-weight: 700; }
table.conv th { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.tabla-fecha { font-size: .82rem; color: var(--muted); margin-top: 8px; }

/* Pares / enlaces */
.pares { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 8px; list-style: none; padding: 0; }
.pares a { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: var(--text); font-weight: 600; font-size: .93rem; }
.pares a:hover { border-color: var(--accent); }
.pares .flag { width: 20px; height: 15px; }

/* Pasos */
.pasos { display: grid; gap: 10px; list-style: none; padding: 0; counter-reset: paso; }
.pasos li { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 14px 14px 54px; position: relative; }
.pasos li::before { counter-increment: paso; content: counter(paso); position: absolute; left: 14px; top: 14px; width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-strong); font-weight: 800; display: grid; place-items: center; font-size: .9rem; }

/* Preguntas frecuentes */
.faq { display: grid; gap: 8px; }
.faq details { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 0 16px; }
.faq summary { cursor: pointer; font-weight: 700; padding: 14px 0; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-size: 1.3rem; line-height: 1; color: var(--accent); }
.faq details[open] summary::after { content: "–"; }
.faq details p { padding-bottom: 14px; color: var(--muted); }

/* Anuncios (espacios reservados) */
.ad-slot { margin: 32px auto 0; min-height: 100px; max-width: 970px; display: grid; place-items: center; border: 1px dashed var(--line); border-radius: 12px; color: var(--muted); font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; }
.ad-slot.in-content { min-height: 250px; }
/* Anuncio lateral: solo aparece en el margen derecho cuando sobra lugar (nunca encima del contenido). */
.ad-lateral { display: none; }

/* Selector de monedas */
dialog.selector { border: 0; padding: 0; background: var(--surface); color: var(--text); width: min(560px, 100vw); max-width: 100vw; height: min(680px, 100dvh); max-height: 100dvh; border-radius: 0; box-shadow: var(--shadow); }
dialog.selector::backdrop { background: rgba(5, 10, 20, .55); }
dialog.selector[open] { display: flex; flex-direction: column; }
.sel-head { padding: 12px 12px 8px; border-bottom: 1px solid var(--line); }
.sel-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sel-top h2 { font-size: 1.1rem; padding-left: 4px; }
.sel-buscar { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface-2); font-size: 1rem; }
.sel-buscar:focus { outline: none; border-color: var(--accent); }
.sel-lista { list-style: none; padding: 6px 8px 16px; overflow-y: auto; flex: 1; overscroll-behavior: contain; }
.sel-grupo { font-size: .75rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; padding: 12px 8px 4px; }
.sel-item { display: flex; align-items: center; }
.sel-opt { flex: 1; display: flex; align-items: center; gap: 10px; padding: 9px 8px; border-radius: 10px; text-align: left; min-width: 0; }
.sel-opt:hover, .sel-opt:focus-visible { background: var(--surface-2); }
.so-code { font-weight: 800; width: 3.2em; flex: none; }
.so-txt { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.so-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.so-pais { font-size: .78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sel-vacio { padding: 20px 8px; color: var(--muted); }
html.sel-abierto { overflow: hidden; }

/* Páginas de texto */
.page-head { padding-top: 24px; }
.page-head h1 { font-size: clamp(1.6rem, 5vw, 2.2rem); }
.legal-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-top: 16px; }
.todo { background: var(--warn-bg); color: var(--warn-text); padding: 0 4px; border-radius: 4px; }
.migas { font-size: .85rem; color: var(--muted); margin-top: 14px; }
.migas a { color: var(--muted); }

/* =============================================================
   8. Responsive
   ============================================================= */
@media (min-width: 540px) {
  dialog.selector { border-radius: var(--radius); height: min(680px, 90dvh); }
}
@media (min-width: 720px) {
  .tool-card { padding: 22px; }
  .par { grid-template-columns: 1fr auto 1fr; align-items: center; }
  .btn-invertir { margin: 0; }
  .btn-invertir svg { transform: none; }
  @keyframes girar { from { transform: rotate(0); } to { transform: rotate(180deg); } }
  .nav .nav-opt { display: inline-block; }
  .tablas { grid-template-columns: 1fr 1fr; }
  .foot-grid { grid-template-columns: 2fr 1fr 1fr 1fr; }
}
@media (min-width: 960px) {
  .layout-2 { display: grid; grid-template-columns: 1.15fr .85fr; gap: 24px; align-items: start; }
  .layout-2 > section { margin-top: 0; }
}

/* Excepción a los cortes estándar: el anuncio de 160 px necesita 1040 px de contenido + margen a cada lado (≈1410 px). */
@media (min-width: 1440px) and (min-height: 720px) {
  .ad-lateral {
    display: grid; position: fixed; z-index: 5; top: 80px; left: calc(50% + 520px + 28px);
    width: 160px; height: 600px; margin: 0; background: var(--bg);
  }
}

/* =============================================================
   9. Reduced-motion (solo efectos intrusivos)
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  .tool-card[data-state="loading"] .resultado-box { animation: none; }
}
