:root {
  --ink: #102a2e;
  --muted: #617277;
  --paper: #f5f3ed;
  --card: #fffefa;
  --line: #d9ded9;
  --teal: #087c78;
  --teal-dark: #075b59;
  --coral: #ea755e;
  --blue: #4d9ebc;
  --shadow: 0 20px 60px rgba(27, 54, 57, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 84% -10%, rgba(77, 158, 188, 0.13), transparent 34rem),
    var(--paper);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input { font: inherit; }
button { color: inherit; }

.masthead, main, footer { width: min(1440px, calc(100% - 56px)); margin-inline: auto; }

.masthead {
  min-height: 190px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  padding: 48px 0 30px;
  border-bottom: 1px solid rgba(16, 42, 46, 0.18);
}

.eyebrow, .place-kicker, .metric-label {
  display: block;
  margin: 0 0 10px;
  color: var(--teal);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(2.5rem, 5vw, 5.1rem); font-weight: 500; line-height: 0.95; letter-spacing: -0.045em; }
.header-note { display: flex; align-items: center; gap: 10px; padding-bottom: 8px; color: var(--muted); font-size: 0.9rem; white-space: nowrap; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--coral); box-shadow: 0 0 0 5px rgba(234,117,94,.14); }

.intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; padding: 36px 0 28px; }
.intro h2 { margin: 0 0 7px; font-size: 1.08rem; letter-spacing: -0.01em; }
.intro p { max-width: 650px; margin: 0; color: var(--muted); line-height: 1.55; }
.refresh-all { display: inline-flex; align-items: center; gap: 9px; border: 0; border-bottom: 1px solid var(--ink); background: transparent; padding: 6px 0; cursor: pointer; font-weight: 700; }
.refresh-all svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.refresh-all:hover svg { transform: rotate(90deg); transition: transform .25s ease; }

.weather-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.weather-card { min-width: 0; overflow: hidden; background: var(--card); border: 1px solid rgba(16,42,46,.13); border-radius: 18px; box-shadow: var(--shadow); }
.card-top { display: flex; gap: 9px; padding: 16px; border-bottom: 1px solid var(--line); background: rgba(245,243,237,.55); }
.location-form { flex: 1; min-width: 0; display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; background: #fff; transition: border-color .2s, box-shadow .2s; }
.location-form:focus-within { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(8,124,120,.11); }
.location-form svg { width: 18px; margin-left: 13px; fill: none; stroke: var(--muted); stroke-width: 1.8; }
.location-form input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; padding: 12px 9px; color: var(--ink); }
.location-form button { align-self: stretch; border: 0; border-left: 1px solid var(--line); background: transparent; padding: 0 15px; font-weight: 800; cursor: pointer; }
.location-form button:hover { color: var(--teal); }
.location-button { display: grid; place-items: center; width: 44px; border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; }
.location-button:hover { border-color: var(--teal); color: var(--teal); }
.location-button svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }

.card-content { min-height: 495px; }
.loading-state, .error-state { min-height: 495px; display: flex; align-items: center; justify-content: center; gap: 14px; color: var(--muted); }
.loading-state strong, .loading-state span, .error-state strong, .error-state span { display: block; }
.loading-state strong, .error-state strong { color: var(--ink); margin-bottom: 4px; }
.spinner { width: 28px; height: 28px; border: 3px solid #dce8e5; border-top-color: var(--teal); border-radius: 50%; animation: spin .85s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-state { padding: 30px; flex-wrap: wrap; text-align: left; }
.error-icon { display: grid !important; place-items: center; width: 31px; height: 31px; border-radius: 50%; color: #fff; background: var(--coral); font-weight: 900; }
.retry-button { border: 1px solid var(--ink); background: transparent; border-radius: 8px; padding: 8px 12px; cursor: pointer; }

.forecast-state { padding: 25px 25px 18px; }
.place-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.place-kicker { margin-bottom: 6px; font-size: 0.63rem; }
.place-name { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.65rem, 3vw, 2.25rem); font-weight: 500; line-height: 1.08; letter-spacing: -0.035em; }
.current-temp { display: flex; align-items: flex-start; line-height: .85; font-size: 3rem; font-weight: 300; letter-spacing: -0.08em; }
.current-temp small { margin: 2px 0 0 3px; color: var(--muted); font-size: .8rem; font-weight: 700; letter-spacing: 0; }
.summary-row { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-top: 10px; color: var(--muted); font-size: .88rem; }
.summary-row p { margin: 0; }
.range { white-space: nowrap; }

.chart-wrap { margin-top: 25px; }
.chart-heading { display: flex; justify-content: space-between; font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.chart-unit { color: var(--muted); }
.temp-chart { display: block; width: 100%; height: 188px; overflow: visible; margin-top: 9px; }
.time-axis { display: grid; grid-template-columns: repeat(5, 1fr); margin-top: 5px; color: var(--muted); font-size: .66rem; }
.time-axis span:nth-child(n+2):nth-child(-n+4) { text-align: center; }
.time-axis span:last-child { text-align: right; }

.metrics { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 24px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.metric { padding: 15px 12px 14px; }
.metric:first-child { padding-left: 0; }
.metric + .metric { border-left: 1px solid var(--line); }
.metric-label { margin-bottom: 7px; font-size: .58rem; }
.metric strong { display: block; margin-bottom: 3px; font-size: 1.07rem; }
.metric > span:last-child { display: block; color: var(--muted); font-size: .66rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-foot { display: flex; justify-content: space-between; gap: 15px; margin-top: 14px; color: var(--muted); font-size: .64rem; }

footer { display: flex; justify-content: space-between; gap: 40px; padding: 32px 0 45px; color: var(--muted); font-size: .75rem; line-height: 1.5; }
footer p { margin: 0; max-width: 750px; }
footer a { color: var(--ink); }
#global-updated { white-space: nowrap; text-align: right; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }

@media (max-width: 860px) {
  .masthead, main, footer { width: min(100% - 32px, 700px); }
  .masthead { min-height: 155px; }
  .weather-grid { grid-template-columns: 1fr; }
  .header-note { display: none; }
}

@media (max-width: 520px) {
  .masthead { min-height: 128px; padding-top: 32px; }
  .intro { align-items: flex-start; flex-direction: column; padding-top: 27px; }
  .forecast-state { padding-inline: 18px; }
  .card-top { padding: 12px; }
  .card-content, .loading-state, .error-state { min-height: 470px; }
  .current-temp { font-size: 2.5rem; }
  .metrics { grid-template-columns: 1fr; }
  .metric, .metric:first-child { padding: 11px 0; }
  .metric + .metric { border-left: 0; border-top: 1px solid var(--line); }
  footer { flex-direction: column; gap: 12px; }
  #global-updated { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; }
}

/* Dense graphical-forecast layout */
.card-content { min-height: 0; }
.loading-state, .error-state { min-height: 720px; }
.forecast-state { padding: 17px 19px 13px; }
.place-row { align-items: center; padding-bottom: 13px; border-bottom: 1px solid var(--line); }
.place-name { font-size: clamp(1.35rem, 2.2vw, 1.85rem); }
.coordinates { margin: 4px 0 0; color: var(--muted); font: 600 .66rem/1.3 ui-monospace, SFMono-Regular, Menlo, monospace; }
.now-block { display: flex; align-items: center; justify-content: flex-end; gap: 12px; text-align: right; }
.now-block .condition { max-width: 125px; color: var(--muted); font-size: .7rem; line-height: 1.25; }
.current-temp { font-size: 2.45rem; }
.plot-stack { margin-top: 9px; }
.plot { position: relative; padding: 10px 0 8px; border-bottom: 1px solid var(--line); }
.plot-title { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 4px; }
.plot-title strong { font-size: .69rem; letter-spacing: .08em; text-transform: uppercase; }
.plot-title > span { color: var(--muted); font-size: .61rem; }
.legend { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 3px; color: var(--muted); font-size: .58rem; }
.legend span { display: inline-flex; align-items: center; gap: 4px; }
.legend span::before { content: ""; width: 10px; height: 2px; background: var(--key); }
.plot svg { display: block; width: 100%; }
.temperature-chart { height: 108px; }
.wind-chart { height: 92px; }
.percent-plot svg { height: 68px; }
.wind-arrows { display: grid; grid-template-columns: repeat(8, 1fr); margin-top: 2px; color: var(--muted); font-size: .65rem; text-align: center; }
.wind-arrows span { display: flex; justify-content: center; gap: 3px; white-space: nowrap; }
.wind-arrows b { color: var(--ink); font-size: .75rem; transform-origin: center; }
.type-grid { display: grid; grid-template-columns: 61px repeat(48, minmax(1px, 1fr)); gap: 1px; align-items: center; }
.type-label { padding-right: 5px; color: var(--muted); font-size: .57rem; }
.type-cell { height: 11px; border-radius: 1px; background: #e9ece8; }
.type-cell.active.rain { background: #3d9cb9; }
.type-cell.active.snow { background: #8db9d0; }
.type-cell.active.freezing { background: #a07ab7; }
.type-cell.active.sleet { background: #db755e; }
.shared-time-axis { display: grid; grid-template-columns: repeat(5, 1fr); padding-top: 7px; color: var(--muted); font-size: .57rem; }
.shared-time-axis span:nth-child(n+2):nth-child(-n+4) { text-align: center; }
.shared-time-axis span:last-child { text-align: right; }
.card-foot { align-items: flex-end; margin-top: 11px; }
.card-foot > div { display: flex; flex-direction: column; gap: 3px; }
.nws-detail { color: var(--teal-dark); font-weight: 700; text-decoration: none; }
.nws-detail:hover { text-decoration: underline; }

@media (min-width: 1240px) {
  .weather-grid { gap: 18px; }
  .forecast-state { padding-inline: 21px; }
}

@media (max-width: 520px) {
  .loading-state, .error-state { min-height: 650px; }
  .forecast-state { padding-inline: 14px; }
  .place-row { align-items: flex-start; }
  .now-block { gap: 7px; }
  .now-block .condition { max-width: 88px; }
  .current-temp { font-size: 2rem; }
  .type-grid { grid-template-columns: 52px repeat(48, minmax(1px, 1fr)); }
  .type-label { font-size: .52rem; }
}

/* Screen-first compact comparison mode */
body { background: #f1f2ee; }
main, footer { width: min(1800px, calc(100% - 12px)); }
.weather-grid { gap: 6px; padding-top: 6px; }
.weather-card { border-radius: 9px; box-shadow: 0 4px 16px rgba(27,54,57,.055); }
.card-top { gap: 5px; padding: 5px; }
.location-form { border-radius: 6px; }
.location-form svg { width: 14px; margin-left: 8px; }
.location-form input { padding: 6px; font-size: .73rem; }
.location-form button { padding: 0 9px; font-size: .68rem; }
.location-button { width: 32px; border-radius: 6px; }
.location-button svg { width: 14px; }
.remove-panel { width: 25px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); cursor: pointer; font-size: 1rem; line-height: 1; }
.remove-panel:hover { background: rgba(234,117,94,.12); color: #b84f3c; }
.remove-panel:disabled { visibility: hidden; }
.loading-state, .error-state { min-height: 310px; }
.forecast-state { padding: 6px 8px 5px; }
.place-row { min-height: 40px; padding: 0 0 5px; }
.place-name { font-size: 1.05rem; }
.coordinates { margin-top: 2px; font-size: .5rem; }
.now-block { gap: 6px; }
.now-block .condition { max-width: 100px; font-size: .55rem; }
.current-temp { font-size: 1.65rem; }
.current-temp small { font-size: .55rem; }
.plot-stack { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 9px; margin-top: 2px; }
.plot { min-width: 0; padding: 4px 0 3px; }
.plot svg { cursor: crosshair; }
.plot:nth-last-child(-n+2) { border-bottom: 0; }
.plot-title { margin-bottom: 1px; }
.plot-title strong { font-size: .54rem; letter-spacing: .065em; }
.plot-title > span { font-size: .49rem; }
.legend { gap: 6px; margin-bottom: 1px; font-size: .46rem; }
.legend span { gap: 3px; }
.legend span::before { width: 7px; }
.temperature-chart { height: 62px; }
.wind-chart { height: 52px; }
.percent-plot svg { height: 36px; }
.wind-arrows { grid-template-columns: repeat(8, 1fr); margin: -1px 0; font-size: .45rem; }
.wind-arrows span { gap: 1px; }
.wind-arrows b { font-size: .53rem; }
.type-grid { grid-template-columns: 45px repeat(48, minmax(1px, 1fr)); gap: 1px; }
.type-label { padding-right: 2px; font-size: .43rem; }
.type-cell { height: 6px; }
.plot-time { display: grid; grid-template-columns: repeat(3, 1fr); margin: 1px 0 0 27px; color: var(--muted); font-size: .41rem; line-height: 1; }
.plot-time span:nth-child(2) { text-align: center; }
.plot-time span:last-child { text-align: right; }
.precip-types-plot .plot-time { margin-left: 46px; }
.chart-tooltip { position: absolute; top: 18px; left: 0; z-index: 5; min-width: 105px; padding: 5px 7px; border-radius: 5px; background: rgba(16,42,46,.94); color: #fff; box-shadow: 0 5px 15px rgba(16,42,46,.2); pointer-events: none; font-size: .49rem; line-height: 1.45; transform: translateX(5px); }
.chart-tooltip.flip { transform: translateX(calc(-100% - 5px)); }
.chart-tooltip strong, .chart-tooltip span { display: block; white-space: nowrap; }
.chart-tooltip strong { margin-bottom: 2px; color: #c8eeea; font-size: .5rem; }
.chart-tooltip i { display: inline-block; width: 6px; height: 2px; margin-right: 4px; vertical-align: middle; background: var(--tip-color, #fff); }
.hover-line { pointer-events: none; }
.card-foot { margin-top: 3px; padding-top: 3px; border-top: 1px solid var(--line); font-size: .46rem; }
.card-foot > div { gap: 1px; }
footer { align-items: center; gap: 14px; padding: 6px 2px 8px; font-size: .56rem; }
footer p { max-width: none; }
.refresh-all { flex: none; gap: 3px; padding: 2px 0; font-size: .58rem; }
.add-panel { flex: none; border: 1px solid var(--teal); border-radius: 5px; background: var(--teal); color: #fff; padding: 4px 8px; cursor: pointer; font-size: .58rem; font-weight: 800; }
.add-panel:hover { background: var(--teal-dark); }
#global-updated { margin-left: auto; }

@media (max-width: 860px) {
  main, footer { width: min(100% - 10px, 760px); }
  .weather-grid { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
  .plot-stack { column-gap: 6px; }
  .plot-time { margin-left: 23px; font-size: .36rem; }
  .type-grid { grid-template-columns: 39px repeat(48, minmax(1px, 1fr)); }
}
