:root {
  --bg: #0d1013; --surface: #151a1f; --surface2: #1c232a; --line: #29323b;
  --text: #e9eef2; --muted: #8b98a5; --accent: #ff8a1f; --accent-ink: #1a0f00;
  --elev: #ff8a1f; --wind: #35c8e6; --ok: #43d17c; --bad: #ff5a5a; --warn: #ffc53d;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 8px 24px rgba(0,0,0,.25);
  --r: 16px; --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #eef1f4; --surface: #ffffff; --surface2: #f4f6f8; --line: #dde3e9;
    --text: #12181d; --muted: #5e6b77; --accent: #e8700a; --accent-ink: #fff;
    --elev: #d9620a; --wind: #0a8fb0; --ok: #1d9e55; --bad: #d63a3a; --warn: #b88400;
    --shadow: 0 1px 2px rgba(15,25,35,.06), 0 6px 18px rgba(15,25,35,.06); color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #eef1f4; --surface: #ffffff; --surface2: #f4f6f8; --line: #dde3e9;
  --text: #12181d; --muted: #5e6b77; --accent: #e8700a; --accent-ink: #fff;
  --elev: #d9620a; --wind: #0a8fb0; --ok: #1d9e55; --bad: #d63a3a; --warn: #b88400;
  --shadow: 0 1px 2px rgba(15,25,35,.06), 0 6px 18px rgba(15,25,35,.06); color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
h2 { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 12px; font-weight: 650; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.tiny { font-size: 12.5px; }
[hidden] { display: none !important; }

/* ---------- cabecera ---------- */
.top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 auto; }
.brand > div { min-width: 0; overflow: hidden; }
.brand .logo { width: 30px; height: 30px; color: var(--text); flex: none; }
.brand b { display: block; font-size: 17px; letter-spacing: .02em; }
.brand span { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wx-chip {
  display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--surface);
  color: var(--text); border-radius: 999px; padding: 7px 12px; font: 600 12.5px/1 inherit; font-family: var(--mono); white-space: nowrap; cursor: pointer; flex: none;
}
.wx-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.wx-chip.live .dot { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }

main { max-width: 880px; margin: 0 auto; padding: 14px 16px; }
.view { display: none; }
.view.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card-h h2 { margin: 0; }
.card-h.pad { padding: 4px 2px 10px; }
.row { display: flex; align-items: center; }
.gap { gap: 10px; }
.wrap { flex-wrap: wrap; }
.end { justify-content: flex-end; margin-top: 12px; }

/* ---------- formularios ---------- */
.grid2, .grid3 { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.grid3 { grid-template-columns: repeat(3, 1fr); }
.span2 { grid-column: span 2; }
@media (max-width: 520px) { .grid3 { grid-template-columns: 1fr 1fr; } }
.fld { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--muted); font-weight: 600; min-width: 0; }
input, select, textarea {
  width: 100%; min-width: 0; font: 600 16px/1.2 inherit; color: var(--text); background: var(--surface2);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 11px; outline: none; font-family: inherit;
}
input[type=number] { font-family: var(--mono); font-variant-numeric: tabular-nums; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
textarea { font-weight: 500; resize: vertical; }
.inp { position: relative; display: flex; align-items: center; }
.inp input { padding-right: 42px; }
.inp em, .stepper em { position: absolute; right: 11px; font-style: normal; color: var(--muted); font-size: 13px; pointer-events: none; }
.stepper { display: grid; grid-template-columns: 52px 1fr 52px; gap: 8px; position: relative; }
.stepper input { text-align: center; font-size: 26px; padding: 10px 34px; }
.stepper em { right: 72px; top: 50%; transform: translateY(-50%); }
.stepper button { border: 1px solid var(--line); background: var(--surface2); color: var(--text); border-radius: 10px; font-size: 24px; cursor: pointer; }
input[type=range] { accent-color: var(--accent); padding: 0; border: 0; background: none; height: 28px; }
.chk { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; }
.chk input { width: 20px; height: 20px; accent-color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line);
  background: var(--surface2); color: var(--text); border-radius: 12px; padding: 12px 18px; font: 650 15px/1 inherit; cursor: pointer; font-family: inherit;
  transition: transform .06s ease, background .15s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.sm { padding: 8px 12px; font-size: 13px; border-radius: 10px; }
.btn.danger { color: var(--bad); }
.btn svg { width: 16px; height: 16px; fill: currentColor; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.link { background: none; border: 0; color: var(--accent); font: 600 13px inherit; padding: 2px 0; cursor: pointer; text-align: left; font-family: inherit; }
.seg { display: inline-flex; background: var(--surface2); border: 1px solid var(--line); border-radius: 11px; padding: 3px; }
.seg button { border: 0; background: none; color: var(--muted); font: 600 13px inherit; padding: 7px 12px; border-radius: 8px; cursor: pointer; font-family: inherit; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.25); }

/* ---------- resultado principal ---------- */
.hero { background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 10%, var(--surface)), var(--surface) 60%); }
.hero-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dial-out { background: var(--surface2); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.dial-out .lbl { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.dial-out .big { font-family: var(--mono); font-size: clamp(34px, 11vw, 54px); font-weight: 700; line-height: 1.05; font-variant-numeric: tabular-nums; margin: 4px 0 2px; }
.dial-out .big small { font-size: 14px; margin-left: 6px; color: var(--muted); font-weight: 600; }
.dial-out.elev .big span { color: var(--elev); }
.dial-out.wind .big span { color: var(--wind); }
.dial-out .sub { font-size: 13px; color: var(--text); font-weight: 600; }
.hero-meta { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 10px; }
.meta { background: var(--surface2); border-radius: 10px; padding: 7px 8px; border: 1px solid var(--line); min-width: 0; }
.meta b { display: block; font-family: var(--mono); font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.meta span { display: block; font-size: 10.5px; line-height: 1.25; color: var(--muted); margin-top: 2px; }
@media (max-width: 420px) { .meta b { font-size: 12.5px; } .hero-meta { gap: 5px; } .meta { padding: 6px 6px; } }
.warn { margin-top: 10px; padding: 9px 12px; border-radius: 10px; background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); font-weight: 600; font-size: 13.5px; }

/* ---------- viento ---------- */
.wind-box { display: grid; grid-template-columns: 200px 1fr; gap: 16px; margin-top: 14px; align-items: start; }
@media (max-width: 560px) { .wind-box { grid-template-columns: 1fr; } .clock-wrap { max-width: 230px; margin: 0 auto; } }
.clock-wrap svg { width: 100%; display: block; touch-action: none; cursor: pointer; }
.clock-cap { text-align: center; font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.wind-flds { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.wind-flds .fld:nth-child(3) { grid-column: span 2; }
.wind-flds p { grid-column: span 2; margin: 0; }

/* ---------- tabla y gráfico ---------- */
.chart { width: 100%; height: 170px; display: block; margin-bottom: 10px; }
.table-wrap { overflow-x: auto; margin: 0 -4px; }
.tbl { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 13px; font-variant-numeric: tabular-nums; }
.tbl th { font: 700 11px/1 -apple-system, "Segoe UI", sans-serif; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; text-align: right; padding: 8px 6px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); }
.tbl td { text-align: right; padding: 7px 6px; border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent); white-space: nowrap; }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl tr.hl td { background: color-mix(in srgb, var(--accent) 14%, transparent); font-weight: 700; }
.tbl tr.trans td { color: var(--warn); }
.tbl td.e { color: var(--elev); } .tbl td.w { color: var(--wind); }

/* ---------- diana ---------- */
.steps { display: flex; gap: 6px; margin-bottom: 12px; }
.steps span { flex: 1; text-align: center; font-size: 12.5px; font-weight: 700; padding: 8px 4px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); }
.steps span.on { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.steps span.done { color: var(--text); }
.drop { text-align: center; padding: 30px 18px; }
.drop h2 { font-size: 18px; text-transform: none; letter-spacing: 0; color: var(--text); }
.drop .row { justify-content: center; margin: 16px 0 12px; flex-wrap: wrap; }
.drop-ico { width: 72px; height: 72px; color: var(--muted); margin-bottom: 8px; }
.canvas-box { position: relative; border-radius: 12px; overflow: hidden; background: #000; border: 1px solid var(--line); }
.canvas-box canvas { display: block; width: 100%; height: auto; touch-action: none; }
.hint { font-size: 13.5px; padding: 9px 12px; border-radius: 10px; background: var(--surface2); border: 1px solid var(--line); margin: 12px 0; }
.hint.ok { border-color: color-mix(in srgb, var(--ok) 50%, var(--line)); }
.hint.bad { border-color: color-mix(in srgb, var(--warn) 60%, var(--line)); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.sens { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.sens input { width: 130px; }
.sens input.nshots { width: 74px; padding: 7px 8px; font-size: 15px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 8px; }
.stat { background: var(--surface2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.stat b { display: block; font-family: var(--mono); font-size: 21px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.stat i { display: block; font-style: normal; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.corr { margin-top: 12px; padding: 12px 14px; border-radius: 12px; border: 1px dashed var(--line); font-size: 14.5px; }
.corr b { font-family: var(--mono); }
.corr .e { color: var(--elev); } .corr .w { color: var(--wind); }
.score { margin-top: 10px; font-size: 14px; }
.score .pill { display: inline-block; font-family: var(--mono); background: var(--surface2); border: 1px solid var(--line); border-radius: 8px; padding: 3px 7px; margin: 2px 3px 2px 0; font-size: 13px; }
.pred { margin: 12px 0; padding: 12px 14px; background: var(--surface2); border-radius: 12px; border: 1px solid var(--line); font-size: 14px; }
.pred b { font-family: var(--mono); }

/* ---------- historial ---------- */
.hist-sum { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin-bottom: 12px; }
.hist-list { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.hcard { display: grid; grid-template-columns: 96px 1fr; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; cursor: pointer; text-align: left; color: var(--text); font: inherit; box-shadow: var(--shadow); }
.hcard img { width: 96px; height: 96px; object-fit: cover; border-radius: 10px; background: #000; }
.hcard .t { font-weight: 700; font-size: 14.5px; }
.hcard .m { font-size: 12.5px; color: var(--muted); }
.hcard .k { font-family: var(--mono); font-size: 13px; margin-top: 4px; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; border: 1px dashed var(--line); border-radius: var(--r); }

/* ---------- munición ---------- */
.ammo { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.ammo:last-child { border-bottom: 0; }
.ammo b { display: block; font-size: 14.5px; }
.ammo span { font-size: 12.5px; color: var(--muted); font-family: var(--mono); }

/* ---------- navegación ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--line);
}
.tabs button { display: flex; flex-direction: column; align-items: center; gap: 3px; background: none; border: 0; color: var(--muted); font: 600 11.5px inherit; padding: 6px 0; cursor: pointer; font-family: inherit; border-radius: 10px; }
.tabs svg { width: 24px; height: 24px; }
.tabs button.on { color: var(--accent); }
@media (min-width: 900px) {
  .tabs { left: 50%; right: auto; bottom: 16px; transform: translateX(-50%); width: 560px; border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 12px 40px rgba(0,0,0,.3); }
  .tabs button { flex-direction: row; font-size: 14px; padding: 9px 10px; gap: 8px; }
  .tabs button.on { background: color-mix(in srgb, var(--accent) 12%, transparent); }
  .tabs svg { width: 18px; height: 18px; }
}

dialog { border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--text); padding: 0; width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 40px); box-shadow: 0 30px 80px rgba(0,0,0,.5); }
dialog::backdrop { background: rgba(0,0,0,.55); backdrop-filter: blur(3px); }
#dlgBody { padding: 18px; }
.dlg-h { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.dlg-h h3 { margin: 0; font-size: 17px; }
.x { background: var(--surface2); border: 1px solid var(--line); color: var(--text); width: 34px; height: 34px; border-radius: 50%; font-size: 18px; cursor: pointer; }

.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 14px; z-index: 50; box-shadow: 0 10px 30px rgba(0,0,0,.3); max-width: calc(100vw - 32px); }

/* ---------- ajustes de la óptica ---------- */
.scope-box { margin-top: 2px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface2); }
.scope-box h3 { margin: 0; padding: 10px 12px 4px; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.scope-row { display: grid; grid-template-columns: 92px 1fr; gap: 10px; padding: 8px 12px; border-top: 1px solid color-mix(in srgb, var(--line) 60%, transparent); font-size: 14px; align-items: baseline; }
.scope-row:first-of-type { border-top: 0; }
.scope-row > span { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.scope-row b { font-family: var(--mono); }
.scope-row .e { color: var(--elev); } .scope-row .w { color: var(--wind); }
.scope-row small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }

.legend { margin: 10px 0 4px; line-height: 1.9; color: var(--muted); }
.legend .lg { display: inline-block; width: 16px; height: 0; border-top: 3px solid; vertical-align: middle; margin-right: 4px; border-radius: 2px; }
.legend .or { width: 12px; height: 12px; border: 2.5px solid #ff8a1f; border-radius: 50%; }
.legend .red { border-color: #d946ef; } .legend .ring { border-color: #ff2828; } .legend .grn { border-top-style: dashed; border-color: #43d17c; } .legend .yel { border-top-style: dashed; border-color: #ffc53d; }
.legend .xc { color: #ffc53d; } .legend .ac { color: #35c8e6; }

/* ---------- zoom ---------- */
.zoomctl { position: absolute; right: 8px; top: 8px; display: flex; flex-direction: column; gap: 6px; z-index: 2; }
.zoomctl button { width: 38px; height: 38px; border-radius: 10px; border: 1px solid rgba(255,255,255,.25); background: rgba(13,16,19,.72); color: #fff; font: 700 20px/1 system-ui, sans-serif; cursor: pointer; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.zoomctl button:active { transform: scale(.94); }

/* ---------- qué he visto / pregunta de munición ---------- */
.ask { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.ask .row2 { display: grid; grid-template-columns: 96px 1fr; gap: 8px; padding: 6px 0; font-size: 14px; align-items: baseline; }
.ask .row2 > span { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.ask .q { margin-top: 10px; font-weight: 650; }
.ask .opts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.ask .warnl { color: var(--warn); font-size: 13px; font-weight: 600; margin-top: 6px; }
