* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.4 var(--font-ui);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
a { color: inherit; }
button { font: inherit; color: inherit; }
.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app {
  max-width: var(--app-max);
  margin: 0 auto;
  padding: calc(var(--safe-t) + 10px) calc(var(--gutter) + var(--safe-r)) calc(var(--tab-h) + var(--safe-b) + 8px) calc(var(--gutter) + var(--safe-l));
}

/* ---- now header ---- */
.now__top { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: -4px 0 2px; }
.placebtn {
  appearance: none; border: 0; background: none; padding: 4px 6px 4px 0; display: inline-flex; align-items: center; gap: 4px;
  font-size: 15px; font-weight: 600; color: var(--text); cursor: pointer; min-width: 0;
}
.placebtn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.placebtn svg { width: 12px; height: 12px; fill: none; stroke: var(--text-dim); stroke-width: 1.6; flex: none; }
.note-line { grid-column: 1 / -1; font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.note-line.warn {
  color: var(--warn-ink); background: var(--warn); border-radius: 8px; padding: 5px 10px; font-weight: 600; font-size: 13px;
}
.problem { margin: 16px 0; padding: 14px; border-radius: 10px; background: var(--surface); color: var(--text); font-size: 14px; }
.view.loading .stack, .view.loading .readout, .view.loading .days, .view.loading .now > :not(.now__top) { opacity: .45; transition: opacity .2s; }
.now { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 2px 12px; align-items: center; }
.now__temp { font-size: 54px; font-weight: 300; line-height: 1; letter-spacing: -0.03em; }
.now__side { min-width: 0; line-height: 1.3; }
.now__sky { font-size: 16px; font-weight: 600; }
.now__feels, .now__facts { color: var(--text-dim); font-size: 13px; }
.now__facts { color: var(--text); }
.radar { display: flex; flex-direction: column; gap: 5px; align-items: stretch; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  min-height: 32px; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); text-decoration: none; font-weight: 600; font-size: 14px;
}
.btn--radar { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn--radar .icon { width: 17px; height: 17px; }
.btn--ghost { background: transparent; color: var(--text-dim); font-weight: 500; min-height: 26px; padding: 2px 10px; font-size: 13px; }
.now.rainy .btn--radar { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }

.issued { font-size: 11px; color: var(--text-faint); white-space: nowrap; }

/* ---- day strip ---- */
.days {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px;
  margin: 8px 0 6px;
}
.day {
  appearance: none; border: 1px solid transparent; background: var(--surface); border-radius: 10px;
  padding: 4px 2px 3px; display: flex; flex-direction: column; align-items: center; gap: 1px;
  font-variant-numeric: tabular-nums; min-width: 0; cursor: pointer;
}
.day__name { font-size: 12px; color: var(--text-dim); font-weight: 600; }
.day__hi { font-size: 15px; line-height: 1.2; font-weight: 600; }
.day__lo { font-size: 13px; line-height: 1.15; color: var(--text-dim); }
.day__pop { font-size: 11px; color: var(--text-faint); display: flex; align-items: center; gap: 1px; min-height: 14px; }
.day__pop.wet { color: var(--text); }
.day__pop svg { width: 9px; height: 11px; fill: var(--s-rain); }
.day[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--surface)); }

/* ---- readout (sticky values row above the stacked charts) ---- */
.readout {
  position: sticky; top: 0; z-index: 3;
  margin: 0 calc(-1 * var(--gutter)); padding: var(--safe-t) var(--gutter) 6px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  min-height: 44px; font-size: 13px; line-height: 1.35; font-variant-numeric: tabular-nums;
}
.readout__when { font-weight: 600; font-size: 13px; padding-top: 4px; display: flex; justify-content: space-between; gap: 8px; }
.readout__when .range { color: var(--text-faint); font-weight: 400; }
.readout__when button { border: 0; background: none; color: var(--accent); padding: 0; font-size: 13px; cursor: pointer; }
.readout__vals { display: flex; flex-wrap: wrap; gap: 0 12px; }
.rv { white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
.rv b { font-weight: 600; color: var(--text); }
.rv span { color: var(--text-dim); }
.key { display: inline-block; width: 10px; height: 2px; border-radius: 1px; background: currentColor; flex: none; }
.key--thin { height: 1px; }
.key--area { height: 8px; width: 8px; border-radius: 2px; }

/* ---- stacked charts ---- */
.stack { margin-top: 2px; }
.chart { margin-top: 4px; }
.chart__head { display: flex; align-items: baseline; gap: 10px; font-size: 11px; line-height: 1.3; color: var(--text-dim); }
.chart__title { color: var(--text); font-weight: 600; font-size: 12px; }
.chart__legend { display: flex; gap: 10px; flex-wrap: wrap; }
.chart__legend span { display: inline-flex; align-items: center; gap: 4px; }
.chart__plot { position: relative; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.chart__plot .uplot { font-family: var(--font-ui); }
.chart__plot .u-over { cursor: crosshair; }
.chart__plot .u-cursor-x { border-right: 1px solid var(--now) !important; opacity: .7; }
.chart__plot .u-cursor-pt { border-width: 2px !important; }

.note { font-size: 12px; color: var(--text-faint); margin: 10px 0 0; }

/* ---- locations ---- */
.vhead { font-size: 20px; font-weight: 600; margin: 4px 0 12px; }
.sub { font-size: 14px; font-weight: 600; margin: 22px 0 8px; }
.places { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.place { display: flex; align-items: center; gap: 4px; border-bottom: 1px solid var(--line); min-height: 56px; }
.place--current .place__name::after { content: " · showing"; color: var(--text-faint); font-weight: 400; font-size: 12px; }
.place__main {
  appearance: none; border: 0; background: none; text-align: left; flex: 1; min-width: 0; padding: 8px 4px;
  display: flex; flex-direction: column; cursor: pointer;
}
.place__name { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.place__sub { font-size: 12px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.place__star, .place__btn {
  appearance: none; border: 0; background: none; width: 44px; height: 44px; border-radius: 10px; flex: none;
  font-size: 20px; color: var(--text-faint); cursor: pointer;
}
.place__star[aria-pressed="true"] { color: var(--warn); }
.place__btn:disabled { opacity: .3; }
.place__edit { flex-direction: row; align-items: center; gap: 4px; }
.place__edit input, .search input {
  flex: 1; min-width: 0; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg-raised); color: inherit; font: inherit; font-size: 16px; outline: none;
}
.place__edit input:focus, .search input:focus { border-color: var(--accent); }
.place--confirm { gap: 8px; padding-right: 4px; }
.btn--danger { background: var(--bias-pos); color: #fff; border-color: transparent; }
.btn--wide { width: 100%; }
.search { display: flex; gap: 8px; margin-top: 10px; }
.pl-msg { font-size: 13px; color: var(--text-dim); margin: 8px 0 0; min-height: 1.2em; }
.pl-msg.err { color: var(--bias-pos); }
.pl-empty { color: var(--text-dim); margin: 4px 0 12px; }
.results { display: flex; flex-direction: column; }
.result {
  appearance: none; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left;
  padding: 10px 4px; display: flex; flex-direction: column; cursor: pointer; color: inherit;
}
.result:hover, .place__main:hover, .picker__item:hover { background: var(--surface); }

.about { margin: 28px 0 0; font-size: 12px; color: var(--text-faint); text-align: center; }
.about a { color: var(--text-dim); text-decoration: none; }
.about a:hover { text-decoration: underline; }
.linkish { font: inherit; color: var(--text-dim); background: none; border: 0; padding: 0; cursor: pointer; }
.linkish:hover { text-decoration: underline; }

/* ---- location picker (from the header) ---- */
.picker {
  border: 1px solid var(--line); border-radius: 14px; padding: 6px; width: min(340px, calc(100vw - 32px));
  background: var(--bg-raised); color: var(--text);
}
.picker::backdrop { background: rgb(0 0 0 / .45); }
.picker__list { display: flex; flex-direction: column; max-height: 60vh; overflow: auto; }
.picker__item {
  appearance: none; border: 0; background: none; color: inherit; text-align: left; border-radius: 10px;
  padding: 10px 12px; display: flex; flex-direction: column; cursor: pointer;
}
.picker__item.is-current { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.picker .btn--ghost { margin-top: 4px; }

/* ---- tab bar ---- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(3, 1fr);
  height: calc(var(--tab-h) + var(--safe-b));
  padding: 0 var(--safe-r) var(--safe-b) var(--safe-l);
  background: color-mix(in srgb, var(--bg-raised) 94%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.tab {
  appearance: none; border: 0; background: none; text-decoration: none; color: var(--text-faint);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; cursor: pointer;
}
.tab[aria-current="page"] { color: var(--accent); }
.tab .icon { width: 22px; height: 22px; }

.error { padding: 24px 0; color: var(--text-dim); }

/* ---- desktop: wider column, header beside the day strip ---- */
@media (min-width: 900px) {
  :root { --app-max: 1080px; --gutter: 24px; }
  #view-now { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); column-gap: 32px; align-items: center; }
  #view-now > .readout, #view-now > .stack, #view-now > .problem { grid-column: 1 / -1; }
  #view-places { max-width: 640px; margin: 0 auto; }
  .days { margin: 0; }
  .day { padding: 8px 2px 6px; }
  .readout { margin-top: 12px; }
  .tabs { padding-left: max(var(--safe-l), calc((100vw - 520px) / 2)); padding-right: max(var(--safe-r), calc((100vw - 520px) / 2)); }
}
