/* UV Sol — sistema visual "Golden hour workbench" (ref. Getharvest / styles.refero.design)
   Lienzo crema, tarjetas blancas flotantes, un único naranja, sans geométrica + serif para el hero. */
:root {
  --flame: #fa5d00;
  --flame-soft: #fff0e6;
  --marigold: #fee3b5;
  --parchment: #e3d6c5;
  --ink: #1d1e1c;
  --ironwood: #4a4a47;
  --stone: #615f5c;
  --ash: #777571;
  --driftwood: #8e8b87;
  --bone: #c0bbb6;
  --mist: #ebe5dd;
  --cream: #fff8f1;
  --paper: #ffffff;

  /* Escala UV (datos, no marca): tonos cálidos que conviven con el naranja */
  --uv-low: #4f9d62;
  --uv-mod: #dba100;
  --uv-high: #fa5d00;
  --uv-vhigh: #d7262d;
  --uv-ext: #8a4bd6;

  --r-card: 20px;
  --r-ctl: 16px;
  --shadow-card: 0 1px 2px rgba(29, 30, 28, .04), 0 12px 32px -12px rgba(250, 166, 0, .22);
  --shadow-btn: 0 2px 6px rgba(0, 0, 0, .18);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font: 16px/1.5 "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  letter-spacing: .015em;
  padding: calc(var(--safe-top) + 16px) 16px calc(var(--safe-bottom) + 32px);
  max-width: 560px;
  margin-inline: auto;
  overscroll-behavior-y: contain;
}
h1, h2, h3 { margin: 0; font-weight: 600; }
h2 { font-size: 12px; color: var(--ash); text-transform: uppercase; letter-spacing: .12em; margin-bottom: 14px; font-weight: 600; }
button { font: inherit; color: inherit; letter-spacing: inherit; }
button:active { transform: translateY(1px); }
a { color: var(--flame); text-decoration: none; }
a:hover { text-decoration: underline; }
b { font-weight: 600; }

.hidden { display: none !important; }

/* Cabecera */
header { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
#place-btn { flex: 1; min-width: 0; text-align: left; background: none; border: 0; padding: 0; }
#place-name {
  font-family: "Fraunces", "Georgia", serif; font-weight: 500; font-size: 30px; line-height: 1.15;
  letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#place-sub { font-size: 13px; color: var(--stone); margin-top: 2px; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  border: 1px solid var(--mist); background: var(--paper); color: var(--ironwood);
  display: grid; place-items: center; font-size: 18px; cursor: pointer; box-shadow: var(--shadow-card);
}
.icon-btn.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Tarjetas */
.card {
  background: var(--paper); border-radius: var(--r-card); box-shadow: var(--shadow-card);
  padding: 20px; margin-bottom: 16px;
}
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.grid-3 .stat .v { font-size: 15px; }
.grid-2 .stat .v { font-size: 16px; }
.stat { background: var(--cream); border-radius: 14px; padding: 12px 14px; }
.stat .k { font-size: 12px; color: var(--stone); }
.stat .v { font-size: 18px; font-weight: 600; margin-top: 3px; color: var(--ink); }
.stat .v small { font-size: 12px; color: var(--stone); font-weight: 500; }
.muted { color: var(--stone); }
.small { font-size: 13px; }

/* Hero UV */
.card.hero-card { position: relative; overflow: hidden; }
.card.hero-card::before {
  content: ""; position: absolute; inset: -40% -20% auto auto; width: 70%; aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(closest-side, var(--marigold), transparent 70%); opacity: .8; pointer-events: none;
}
.hero { position: relative; display: grid; grid-template-columns: 150px 1fr; gap: 18px; align-items: center; }
.ring { position: relative; width: 150px; height: 150px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .track { fill: none; stroke: var(--mist); stroke-width: 10; }
.ring .bar { fill: none; stroke: var(--uv-col, var(--uv-low)); stroke-width: 10; stroke-linecap: round; transition: stroke-dasharray .6s ease, stroke .4s; }
.ring .center { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.ring .num { font-family: "Fraunces", "Georgia", serif; font-size: 54px; font-weight: 500; line-height: 1; color: var(--ink); letter-spacing: -.02em; }
.ring .lbl { font-size: 11px; color: var(--ash); margin-top: 6px; text-transform: uppercase; letter-spacing: .12em; }
.hero-side .level { font-size: 24px; font-weight: 600; color: var(--uv-col); letter-spacing: -.01em; }
.hero-side .desc { color: var(--stone); font-size: 14px; margin: 4px 0 12px; line-height: 1.45; }
.chip { display: inline-block; padding: 5px 11px; border-radius: 999px; background: var(--cream); border: 1px solid var(--mist); font-size: 13px; margin: 2px 4px 2px 0; color: var(--ironwood); }

.alert-banner {
  position: relative; margin-top: 14px; padding: 12px 14px; border-radius: 14px;
  background: color-mix(in srgb, var(--uv-col) 10%, var(--paper));
  border: 1px solid color-mix(in srgb, var(--uv-col) 35%, transparent);
  font-size: 14px; line-height: 1.45; color: var(--ironwood);
}

/* Botones */
.btn {
  background: var(--flame); color: #fff; border: 0; border-radius: var(--r-ctl); padding: 12px 18px;
  font-weight: 600; cursor: pointer; box-shadow: var(--shadow-btn);
}
.btn.ghost { background: var(--paper); color: var(--ink); border: 1px solid var(--bone); box-shadow: none; }
.btn:disabled { opacity: .45; box-shadow: none; }

/* Gráfico horario */
.chart { width: 100%; height: 150px; display: block; }
.chart .bar { rx: 3; }
.chart .bar.sel { stroke: var(--ink); stroke-width: 1.5; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .now { stroke: var(--ink); stroke-width: 1.5; stroke-dasharray: 3 3; }
.chart .thr { stroke: var(--flame); stroke-width: 1; stroke-dasharray: 4 4; opacity: .7; }
.chart .grid { stroke: var(--mist); }
.chart text { fill: var(--ash); font-size: 10px; }
.detail { font-size: 13px; color: var(--stone); margin-top: 10px; min-height: 1.4em; line-height: 1.5; }
.detail b { color: var(--ink); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--stone); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* Semana */
.week { display: flex; gap: 8px; overflow-x: auto; padding: 2px; margin: -2px; scrollbar-width: none; }
.week::-webkit-scrollbar { display: none; }
.day { flex: 1 0 66px; background: var(--cream); border-radius: 14px; padding: 10px 4px; text-align: center; }
.day .d { font-size: 11px; color: var(--stone); text-transform: capitalize; }
.day .w { font-size: 18px; margin: 3px 0; }
.day .u { font-family: "Fraunces", "Georgia", serif; font-size: 22px; font-weight: 500; line-height: 1; }
.day .t { font-size: 11px; color: var(--stone); margin-top: 4px; }
.day.today { background: var(--paper); box-shadow: inset 0 0 0 1.5px var(--flame); }

/* Brújula */
.sun-wrap { display: grid; grid-template-columns: 170px 1fr; gap: 16px; align-items: center; }
.compass { width: 170px; height: 170px; }
.compass .face { fill: var(--cream); stroke: var(--mist); }
.compass text { fill: var(--stone); font-size: 12px; font-weight: 600; text-anchor: middle; dominant-baseline: middle; }
.compass .path { fill: none; stroke: var(--flame); stroke-opacity: .3; stroke-width: 3; }
.compass .sun { fill: var(--flame); filter: drop-shadow(0 0 6px rgba(250, 93, 0, .5)); }
.compass .sun.below { fill: var(--bone); filter: none; }
.compass .tick { stroke: var(--bone); }
.compass .needle { stroke: var(--flame); stroke-width: 2; }
.compass .north { fill: var(--ink); }
.elev { margin-top: 10px; }
.elev .track { height: 8px; background: var(--mist); border-radius: 4px; overflow: hidden; }
.elev .fill { height: 100%; background: linear-gradient(90deg, var(--marigold), var(--flame)); border-radius: 4px; }
.times { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; text-align: center; }
.times .t { background: var(--cream); border-radius: 14px; padding: 10px 4px; }
.times .t .k { font-size: 11px; color: var(--stone); }
.times .t .v { font-size: 14px; font-weight: 600; margin-top: 2px; }

/* Consejos */
.skin { display: flex; gap: 6px; margin: 8px 0 12px; }
.skin button {
  flex: 1; height: 40px; border-radius: 12px; border: 2px solid transparent; cursor: pointer;
  font-weight: 600; font-size: 13px; color: var(--ink);
}
.skin button.sel { border-color: var(--ink); box-shadow: 0 0 0 2px var(--paper); }
ul.tips { margin: 12px 0 0; padding-left: 18px; color: var(--ironwood); }
ul.tips li { margin-bottom: 6px; font-size: 14px; line-height: 1.5; }
ul.tips li::marker { color: var(--flame); }

/* Temporizador */
.timer { margin-top: 12px; background: var(--cream); border-radius: 14px; padding: 14px; }
.timer select { background: var(--paper); color: var(--ink); border: 1px solid var(--bone); border-radius: 12px; padding: 7px 10px; font: inherit; }
.timer .track { height: 8px; background: var(--mist); border-radius: 4px; overflow: hidden; margin: 10px 0; }
.timer .fill { height: 100%; background: linear-gradient(90deg, var(--marigold), var(--flame), var(--uv-vhigh)); width: 0; transition: width 1s linear; }
.timer-left { font-family: "Fraunces", "Georgia", serif; font-size: 40px; font-weight: 500; text-align: center; margin-top: 12px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.timer-left.done { color: var(--uv-vhigh); animation: pulse 1s ease-in-out infinite; }

/* Lugares */
.search { display: flex; gap: 8px; }
.search input {
  flex: 1; background: var(--paper); border: 1px solid var(--bone); color: var(--ink);
  border-radius: var(--r-ctl); padding: 12px 14px; font: inherit; letter-spacing: inherit; min-width: 0;
}
.search input:focus { outline: 2px solid var(--flame); outline-offset: -1px; border-color: transparent; }
.search input::placeholder { color: var(--driftwood); }
.list { margin-top: 10px; }
.place { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-top: 1px solid var(--mist); cursor: pointer; }
.place:first-child { border-top: 0; }
.place .n { flex: 1; min-width: 0; }
.place .n b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.place .n span { font-size: 12px; color: var(--stone); }
.place .uv { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-weight: 600; color: #fff; font-size: 17px; line-height: 1; }
.place .uv small { font-size: 9px; font-weight: 500; opacity: .9; margin-top: 2px; }
.place .star { background: none; border: 0; font-size: 20px; padding: 4px; cursor: pointer; color: var(--flame); }

/* Alertas */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 14px; color: var(--ironwood); margin-bottom: 8px; }
input[type=range] { width: 100%; accent-color: var(--flame); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.switch input { width: 50px; height: 30px; flex: none; appearance: none; background: var(--mist); border-radius: 15px; position: relative; cursor: pointer; border: 0; transition: background .2s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--paper); box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: left .2s; }
.switch input:checked { background: var(--flame); }
.switch input:checked::after { left: 23px; }
.switch input:disabled { opacity: .4; }
.status { font-size: 13px; color: var(--stone); margin-top: 10px; min-height: 1.4em; }
.status.ok { color: var(--uv-low); }
.status.err { color: var(--uv-vhigh); }
.ios-hint { font-size: 13px; color: var(--ironwood); background: var(--flame-soft); border-radius: 14px; padding: 12px 14px; margin-top: 12px; line-height: 1.5; }

footer { text-align: center; font-size: 12px; color: var(--driftwood); margin-top: 12px; }

/* Estado de carga / error */
#loading { text-align: center; padding: 60px 0; color: var(--stone); }
#loading .sun { font-size: 48px; animation: pulse 1.4s ease-in-out infinite; display: block; margin-bottom: 12px; }
@keyframes pulse { 50% { transform: scale(1.12); opacity: .7; } }
#error { text-align: center; padding: 40px 16px; }

@media (max-width: 380px) {
  .hero { grid-template-columns: 130px 1fr; }
  .ring { width: 130px; height: 130px; }
  .ring .num { font-size: 46px; }
  .sun-wrap { grid-template-columns: 140px 1fr; }
  .compass { width: 140px; height: 140px; }
  #place-name { font-size: 26px; }
}
