/* ————————————————————————————————————————————————————————————
   Trazo — hoja de estilos
   Dirección: hoja topográfica. Papel gris verdoso de mapa suizo,
   tinta pizarra y un único color de sobreimpresión (magenta de
   imprenta) reservado para tu trazo. Las cifras usan Archivo
   expandida, como un cuentakilómetros; las etiquetas, Archivo
   estrecha. Una sola familia, el eje de anchura hace el trabajo.
   ———————————————————————————————————————————————————————————— */

@font-face {
  font-family: 'Archivo';
  src: url('../fonts/archivo.woff2') format('woff2-variations'), url('../fonts/archivo.woff2') format('woff2');
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}

:root {
  /* Paleta */
  --paper:   #E9EDE9;  /* papel de mapa */
  --paper-2: #F6F8F5;  /* superficies elevadas */
  --paper-3: #DCE2DD;  /* controles en reposo */
  --ink:     #17272A;  /* tinta pizarra */
  --graphite:#5B6966;  /* texto secundario */
  --rule:    #C5CEC8;  /* filetes */
  --route:   #E0157A;  /* magenta de sobreimpresión: solo para el trazo */
  --route-slow: #2C6E8C; /* azul agua: el extremo lento de la escala */
  --contour: #A07A50;  /* curva de nivel, para avisos */
  --casing:  #FFFFFF;

  /* Colores que el mapa lee para teñirse */
  --map-land:  #E9EDE9;
  --map-water: #BFD3DA;
  --map-park:  #D6E0D3;

  --font: 'Archivo', system-ui, sans-serif;
  --tab-h: 58px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --ease: cubic-bezier(.2, .8, .2, 1);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:   #131E21;
    --paper-2: #1B282C;
    --paper-3: #263639;
    --ink:     #E4EBE7;
    --graphite:#93A49F;
    --rule:    #2E3F43;
    --route:   #FF3E98;
    --route-slow: #4FA3C7;
    --contour: #D2A472;
    --casing:  #0E1719;
    --map-land:  #162225;
    --map-water: #0F2A33;
    --map-park:  #1A2B27;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  font-variant-numeric: tabular-nums;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
svg { width: 22px; height: 22px; flex: none; }
a { color: inherit; }
:focus-visible { outline: 2.5px solid var(--route); outline-offset: 3px; border-radius: 8px; }
[hidden] { display: none !important; }

/* ——— Pantallas ——— */
#app { position: fixed; inset: 0; }
.screen { position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.screen-list, .screen-settings {
  padding: calc(var(--safe-t) + 28px) 20px calc(var(--tab-h) + var(--safe-b) + 32px);
}
.screen-list > .list-pane, .screen-settings > * { max-width: 640px; margin-inline: auto; }
.overview { display: none; }

.page-head h1 {
  font-size: 36px;
  font-stretch: 122%;
  font-weight: 780;
  letter-spacing: -0.025em;
  line-height: 1;
  margin: 0 0 8px;
}
.screen-settings .page-head { margin-bottom: 26px; }
.lede { margin: 0 0 20px; color: var(--graphite); font-stretch: 92%; }

/* ——— Mapa ——— */
.map { position: absolute; inset: 0; background: var(--map-land); }
.map-failed::after {
  content: attr(data-message);
  position: absolute; inset: 0;
  display: grid; place-items: center;
  padding: 0 40px 40%;
  text-align: center; color: var(--graphite); font-stretch: 92%;
}
.maplibregl-ctrl-attrib { font-family: var(--font); font-size: 10px; }
.maplibregl-ctrl-bottom-right { bottom: auto; top: calc(var(--safe-t) + 8px); }

.tool {
  display: grid; place-items: center;
  width: 46px; height: 46px;
  border-radius: 50%;
  background: var(--paper-2);
  color: var(--ink);
  box-shadow: 0 1px 0 var(--rule), 0 6px 18px -8px rgb(23 39 42 / .45);
  text-decoration: none;
  transition: transform .15s var(--ease);
}
.tool:active { transform: scale(.94); }
.tool[aria-pressed="true"] { color: var(--route); }

.map-tools {
  position: absolute; right: 14px;
  top: calc(var(--safe-t) + 48px);
  display: grid; gap: 10px;
}

/* Marcador de posición */
.me { width: 22px; height: 22px; position: relative; }
.me-dot {
  position: absolute; inset: 3px;
  border-radius: 50%;
  background: var(--ink);
  border: 3px solid var(--casing);
  box-shadow: 0 1px 4px rgb(0 0 0 / .3);
}
.me-halo {
  position: absolute; inset: -10px;
  border-radius: 50%;
  background: var(--ink);
  opacity: .12;
}
.me.is-recording .me-dot { background: var(--route); }
.me.is-recording .me-halo { background: var(--route); animation: halo 2.4s var(--ease) infinite; }
@keyframes halo {
  0%   { transform: scale(.5); opacity: .35; }
  100% { transform: scale(1.8); opacity: 0; }
}

/* ——— Panel de grabación ——— */
.recorder {
  position: absolute; left: 0; right: 0;
  bottom: calc(var(--tab-h) + var(--safe-b));
  background: var(--paper-2);
  border-radius: 28px 28px 0 0;
  padding: 22px 22px 12px;
  box-shadow: 0 -1px 0 var(--rule), 0 -18px 40px -24px rgb(23 39 42 / .5);
}
.recorder > * { max-width: 520px; margin-inline: auto; }

.readout {
  display: flex; align-items: baseline; gap: 10px;
  line-height: .86;
}
.readout-value {
  font-size: clamp(68px, 23vw, 112px);
  font-stretch: 125%;
  font-weight: 760;
  letter-spacing: -0.035em;
  color: var(--rule);
  transition: color .3s;
}
.readout-unit {
  font-size: 22px;
  font-stretch: 75%;
  font-weight: 600;
  color: var(--graphite);
}
[data-state="recording"] .readout-value { color: var(--ink); }
[data-state="paused"] .readout-value { color: var(--graphite); }

.stat-row {
  display: grid; grid-template-columns: 1.15fr 1fr 1fr .8fr;
  gap: 8px;
  margin: 18px auto 18px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
}
.stat-row div { min-width: 0; }
.stat-row dt, .detail-stats dt {
  font-size: 12.5px;
  font-stretch: 82%;
  font-weight: 520;
  color: var(--graphite);
  margin-bottom: 2px;
}
.stat-row dd, .detail-stats dd {
  margin: 0;
  font-size: 21px;
  font-stretch: 112%;
  font-weight: 650;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
dd small {
  font-size: 12px; font-stretch: 78%; font-weight: 550;
  color: var(--graphite); margin-left: 3px; letter-spacing: 0;
}

.controls {
  display: grid; grid-template-columns: 1fr auto 1fr;
  align-items: center; justify-items: center;
}
.ctl { display: grid; place-items: center; border-radius: 50%; }
.ctl-main {
  width: 80px; height: 80px;
  background: var(--route);
  color: #fff;
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--route) 18%, transparent), 0 10px 24px -10px var(--route);
  transition: background .25s, box-shadow .25s, transform .15s var(--ease);
}
.ctl-main svg { width: 34px; height: 34px; }
.ctl-main:active { transform: scale(.95); }
.ctl-main .when-active { display: none; }
[data-state="recording"] .ctl-main,
[data-state="paused"] .ctl-main {
  background: var(--ink); color: var(--paper-2);
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--ink) 10%, transparent);
}
[data-state="recording"] .ctl-main .when-idle,
[data-state="paused"] .ctl-main .when-idle { display: none; }
[data-state="recording"] .ctl-main .when-active,
[data-state="paused"] .ctl-main .when-active { display: block; }

.ctl-side {
  width: 56px; height: 56px;
  background: var(--paper-3);
  color: var(--ink);
  visibility: hidden;
  transition: transform .15s var(--ease);
}
.ctl-side:active { transform: scale(.94); }
[data-state="recording"] #btnPause,
[data-state="paused"] #btnPause { visibility: visible; }
[data-state="paused"] #btnPause { background: var(--route); color: #fff; }
.ctl-ghost { visibility: hidden !important; }

.gps {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  margin: 12px auto 0;
  font-size: 13px; font-stretch: 88%;
  color: var(--graphite);
}
.gps-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--rule); }
.gps[data-q="good"] .gps-dot { background: var(--route-slow); }
.gps[data-q="fair"] .gps-dot { background: var(--contour); }
.gps[data-q="poor"] .gps-dot { background: var(--route); }

/* Aviso de trayecto a medias */
.banner {
  position: absolute; left: 14px; right: 74px;
  top: calc(var(--safe-t) + 48px);
  background: var(--paper-2);
  border-radius: 18px;
  padding: 14px 16px;
  box-shadow: 0 1px 0 var(--rule), 0 10px 30px -14px rgb(23 39 42 / .5);
}
.banner p { margin: 0 0 10px; font-size: 15px; }
.banner-actions { display: flex; gap: 8px; justify-content: flex-end; }
.banner .btn { padding: 9px 14px; font-size: 14px; }

/* ——— Botones ——— */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 18px;
  border-radius: 14px;
  font-weight: 600;
  font-stretch: 96%;
  transition: transform .15s var(--ease), background .2s;
}
.btn:active { transform: scale(.98); }
.btn svg { width: 20px; height: 20px; }
.btn-solid { background: var(--ink); color: var(--paper-2); }
.btn-quiet { background: var(--paper-3); color: var(--ink); }
.btn-wide { width: 100%; }
.btn-text {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 12px 4px; font-weight: 550; font-stretch: 94%;
}
.btn-text svg { width: 19px; height: 19px; }
.btn-danger { color: #B3261E; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-danger { color: #FF8A80; } }

/* ——— Lista de trayectos ——— */
.month {
  position: sticky; top: calc(-28px - var(--safe-t));
  margin: 0; padding: 18px 0 8px;
  background: var(--paper);
  font-size: 14px; font-stretch: 90%; font-weight: 600;
  color: var(--graphite);
  z-index: 1;
}
.trip {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 14px; align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--rule);
  text-decoration: none;
}
.trip:active { opacity: .7; }
.trip-shape {
  width: 64px; height: 64px;
  border-radius: 16px;
  background: var(--paper-2);
  box-shadow: inset 0 0 0 1px var(--rule);
}
.trip-shape svg { width: 64px; height: 64px; display: block; }
.trip-shape path { fill: none; stroke: var(--route); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.trip-shape circle { fill: var(--paper-2); stroke: var(--ink); stroke-width: 1.8; }
.trip-name { font-weight: 620; font-size: 16px; line-height: 1.25; margin: 0; }
.trip-meta { margin: 2px 0 0; font-size: 13.5px; font-stretch: 90%; color: var(--graphite); }
.trip-km { text-align: right; line-height: 1; }
.trip-km b { display: block; font-size: 24px; font-stretch: 122%; font-weight: 720; letter-spacing: -0.02em; }
.trip-km small { font-size: 12px; font-stretch: 80%; color: var(--graphite); font-weight: 550; }

.empty { text-align: center; padding: 24px 12px; }
.empty svg { width: 220px; height: 150px; margin: 8px auto 6px; display: block; }
.empty svg path { fill: none; stroke: var(--rule); stroke-width: 1.4; }
.empty svg .route { stroke: var(--route); stroke-width: 2.6; stroke-linecap: round; stroke-dasharray: 2 7; }
.empty h2 { font-size: 20px; font-stretch: 110%; margin: 10px 0 6px; font-weight: 700; }
.empty p { color: var(--graphite); margin: 0 auto 20px; max-width: 30ch; }

/* ——— Detalle ——— */
.screen-detail { background: var(--paper-2); }
.detail-map { position: relative; height: 48vh; min-height: 280px; }
.tool-back { position: absolute; left: 14px; top: calc(var(--safe-t) + 12px); }
.tool-speed { position: absolute; right: 14px; top: calc(var(--safe-t) + 12px); }
.legend {
  position: absolute; right: 14px; top: calc(var(--safe-t) + 68px);
  display: flex; align-items: center; gap: 8px;
  padding: 7px 11px; border-radius: 999px;
  background: var(--paper-2);
  font-size: 12px; font-stretch: 85%; color: var(--graphite);
  box-shadow: 0 1px 0 var(--rule);
}
.legend i { width: 54px; height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--route-slow), var(--route)); }

.detail-sheet {
  position: relative;
  margin-top: -26px;
  background: var(--paper-2);
  border-radius: 26px 26px 0 0;
  padding: 26px 22px calc(var(--safe-b) + 32px);
}
.detail-sheet > * { max-width: 600px; margin-inline: auto; }
.trip-title {
  display: block; width: 100%;
  border: 0; background: none; padding: 0 0 4px;
  font-size: 27px; font-stretch: 112%; font-weight: 720; letter-spacing: -0.015em;
  border-bottom: 1.5px solid transparent;
  border-radius: 0;
  resize: none; overflow: hidden;
  line-height: 1.12;
}
.trip-title:focus { outline: none; border-bottom-color: var(--route); }
.trip-date { margin: 2px auto 22px; color: var(--graphite); font-stretch: 92%; }

.detail-stats {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 16px 10px;
  margin: 0 auto 26px;
}
.detail-stats .hero { grid-column: 1 / -1; }
.detail-stats .hero dd {
  font-size: clamp(54px, 17vw, 76px);
  font-stretch: 125%; font-weight: 760; letter-spacing: -0.035em; line-height: .9;
}
.detail-stats .hero dd small { font-size: 20px; }

.profile { margin: 0 auto 28px; }
.profile figcaption {
  display: flex; justify-content: space-between;
  font-size: 12.5px; font-stretch: 85%; color: var(--graphite); margin-bottom: 6px;
}
.profile svg { width: 100%; height: 96px; display: block; overflow: visible; }
.profile .area { fill: color-mix(in srgb, var(--route) 12%, transparent); }
.profile .line { fill: none; stroke: var(--route); stroke-width: 1.8; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.profile .base { stroke: var(--rule); stroke-width: 1; vector-effect: non-scaling-stroke; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.actions .btn-wide { grid-column: 1 / -1; }

/* ——— Ajustes ——— */
.group { margin-bottom: 28px; }
.group h2 {
  font-size: 14px; font-stretch: 90%; font-weight: 600;
  color: var(--graphite); margin: 0 0 8px 4px;
}
.group > .row:first-of-type, .group > h2 + .row, .group > .note + .row { border-radius: 16px 16px 0 0; }
.group > .row:last-child { border-radius: 0 0 16px 16px; border-bottom: 0; }
.group > h2 + .row:last-child, .group > .note + .row:last-child { border-radius: 16px; }
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  width: 100%;
  padding: 14px 16px;
  background: var(--paper-2);
  border-bottom: 1px solid var(--rule);
  text-align: left;
}
.row b { display: block; font-weight: 600; }
.row small { display: block; color: var(--graphite); font-size: 13.5px; font-stretch: 92%; margin-top: 2px; line-height: 1.35; }
.row-btn:active { background: var(--paper-3); }
.row-danger b { color: #B3261E; }
.note { margin: 0 4px 10px; color: var(--graphite); font-size: 14.5px; font-stretch: 94%; }
.colophon { color: var(--graphite); font-size: 12.5px; font-stretch: 90%; text-align: center; margin-top: 36px; }

.switch {
  appearance: none; flex: none;
  width: 50px; height: 30px; border-radius: 999px;
  background: var(--paper-3);
  position: relative; transition: background .2s;
  box-shadow: inset 0 0 0 1px var(--rule);
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .25);
  transition: transform .2s var(--ease);
}
.switch:checked { background: var(--ink); }
.switch:checked::after { transform: translateX(20px); }

.seg { display: flex; flex: none; background: var(--paper-3); border-radius: 11px; padding: 3px; }
.seg button { padding: 6px 10px; border-radius: 8px; font-size: 14px; font-stretch: 90%; font-weight: 550; color: var(--graphite); }
.seg button[aria-checked="true"] { background: var(--paper-2); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / .12); }
.screen-settings .row:has(.seg) { flex-wrap: wrap; }

/* ——— Barra de pestañas ——— */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  height: calc(var(--tab-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--paper-2);
  border-top: 1px solid var(--rule);
  z-index: 5;
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--graphite);
  font-size: 11.5px; font-stretch: 88%; font-weight: 560;
  position: relative;
}
.tabbar a[aria-current="page"] { color: var(--ink); }
.tabbar a[aria-current="page"]::before {
  content: ''; position: absolute; top: -1px; width: 28px; height: 2.5px;
  border-radius: 0 0 2px 2px; background: var(--route);
}
body[data-screen="trayecto"] .tabbar { display: none; }

/* ——— Hojas (diálogos) ——— */
dialog.sheet {
  width: 100%; max-width: 520px;
  margin: auto auto 0;
  padding: 26px 22px calc(var(--safe-b) + 18px);
  border: 0; border-radius: 26px 26px 0 0;
  background: var(--paper-2); color: var(--ink);
}
dialog.sheet[open] { animation: sheet-in .32s var(--ease); }
dialog.sheet::backdrop { background: rgb(10 20 22 / .42); }
@keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } }
dialog.sheet h2 { font-size: 22px; font-stretch: 110%; font-weight: 720; margin: 0 0 6px; letter-spacing: -0.01em; }
dialog.sheet p { color: var(--graphite); margin: 0 0 18px; }
dialog.sheet form { display: grid; gap: 10px; }
dialog.sheet form > .btn-text { justify-self: center; }
.field { display: grid; gap: 6px; font-size: 14px; font-stretch: 92%; font-weight: 560; color: var(--graphite); }
.field input {
  width: 100%; padding: 13px 14px; border-radius: 12px;
  border: 1.5px solid var(--rule); background: var(--paper);
  color: var(--ink); font-size: 16px; font-stretch: 100%; font-weight: 450;
}
.field input:focus { outline: none; border-color: var(--ink); }
.form-error { color: #B3261E !important; margin: 0 !important; font-size: 14.5px; }
.sync-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; background: var(--route-slow); }
.sync-dot.is-pending { background: var(--contour); }
.sync-dot.is-error { background: var(--route); }
.trip-pending { color: var(--contour); }
.steps { margin: 6px 0 4px; padding-left: 22px; display: grid; gap: 8px; }
.steps li::marker { font-weight: 700; color: var(--route); }

.style-pick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 8px; }
.pick { display: grid; gap: 8px; font-size: 14px; font-weight: 560; text-align: center; }
.pick i { display: block; aspect-ratio: 1; border-radius: 16px; box-shadow: inset 0 0 0 1px var(--rule); }
.pick-light i { background: linear-gradient(135deg, #E9EDE9 55%, #BFD3DA 55%); }
.pick-dark i { background: linear-gradient(135deg, #162225 55%, #0F2A33 55%); }
.pick-sat i { background: linear-gradient(135deg, #4B5A3A 0 40%, #6E6B4E 40% 70%, #2D4A55 70%); }
.pick-pnoa i { background: repeating-linear-gradient(115deg, #7C8A5A 0 9px, #9AA272 9px 12px), #8A945F; }
.pick[aria-current="true"] i { box-shadow: inset 0 0 0 2.5px var(--route); }

/* ——— Avisos ——— */
.toast {
  position: fixed; left: 50%; z-index: 10;
  bottom: calc(var(--tab-h) + var(--safe-b) + 16px);
  transform: translate(-50%, 20px);
  max-width: min(92vw, 440px);
  padding: 12px 16px; border-radius: 14px;
  background: var(--ink); color: var(--paper-2);
  font-size: 14.5px; line-height: 1.35;
  opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .3s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
body[data-screen="grabar"] .toast { bottom: auto; top: calc(var(--safe-t) + 14px); transform: translate(-50%, -20px); }
body[data-screen="grabar"] .toast.show { transform: translate(-50%, 0); }

/* ————————————————————————————————————————————————————————————
   Escritorio (ordenador o tablet apaisada)
   La barra de pestañas pasa a ser una columna a la izquierda.
   ———————————————————————————————————————————————————————————— */
@media (min-width: 1024px) {
  :root { --rail: 84px; }
  #app { left: var(--rail); }
  .tabbar {
    top: 0; right: auto; width: var(--rail); height: auto;
    padding: 22px 0 0;
    grid-template-columns: 1fr; grid-auto-rows: 74px; align-content: start;
    border-top: 0; border-right: 1px solid var(--rule);
  }
  .tabbar a[aria-current="page"]::before { top: 18px; left: 0; width: 3px; height: 38px; border-radius: 0 2px 2px 0; }
  .tabbar a svg { width: 24px; height: 24px; }
  body[data-screen="trayecto"] .tabbar { display: grid; }
  .toast, body[data-screen="grabar"] .toast { left: calc(50% + var(--rail) / 2); bottom: 28px; top: auto; transform: translate(-50%, 20px); }
  .toast.show, body[data-screen="grabar"] .toast.show { transform: translate(-50%, 0); }

  /* Grabar: el panel flota a la izquierda */
  .screen-record .recorder { bottom: 24px; left: 24px; }

  /* Trayectos: lista + mapa general */
  .screen-list { display: grid; grid-template-columns: minmax(380px, 440px) 1fr; padding: 0; overflow: hidden; }
  .screen-list > .list-pane {
    max-width: none; margin: 0; overflow-y: auto;
    padding: 36px 26px 40px;
    border-right: 1px solid var(--rule);
  }
  .list-pane .month { top: -36px; }
  .overview { display: block; position: relative; }
  .trip { margin-inline: -12px; padding-inline: 12px; border-radius: 14px; border-bottom-color: transparent; box-shadow: 0 1px 0 var(--rule); }
  .trip:hover, .trip.is-hover { background: var(--paper-2); box-shadow: none; }
  .trip:active { opacity: 1; }

  /* Detalle: mapa a la izquierda, ficha a la derecha */
  .screen-detail { display: grid; grid-template-columns: 1fr minmax(400px, 460px); overflow: hidden; }
  .detail-map { height: 100%; min-height: 0; }
  .detail-sheet {
    margin: 0; border-radius: 0; overflow-y: auto;
    border-left: 1px solid var(--rule);
    padding: 34px 30px 40px;
  }
  .tool-back { top: 18px; left: 18px; }
  .tool-speed { top: 18px; right: 18px; }
  .legend { top: 74px; right: 18px; }

  /* Hojas: centradas como diálogos */
  dialog.sheet { margin: auto; border-radius: 22px; padding: 28px 26px 22px; }
  dialog.sheet[open] { animation: dialog-in .22s var(--ease); }
  @keyframes dialog-in { from { transform: scale(.97); opacity: 0; } }

  .row-btn:hover { background: var(--paper-3); }
}

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

/* Pantallas más anchas (tablet u ordenador): panel flotante a la izquierda */
@media (min-width: 820px) {
  .recorder {
    left: 20px; right: auto; width: 420px;
    bottom: calc(var(--tab-h) + 20px);
    border-radius: 28px;
  }
}
