:root {
  --ink: #10212e;
  --muted: #687783;
  --paper: #f4f1e9;
  --panel: #fffdf8;
  --line: #ddd8ce;
  --blue: #176b87;
  --blue-dark: #0d4f68;
  --sky: #d9ebef;
  --orange: #ec805c;
  --shadow: 0 16px 48px rgba(29, 45, 54, .09);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: "DM Sans", sans-serif; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: 8px; background: linear-gradient(90deg, var(--blue), #6fb5bd 55%, var(--orange)); }
main { width: min(1380px, calc(100% - 40px)); margin: 0 auto; padding: 38px 0 52px; }
.hero { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 22px; }
.eyebrow { margin: 0 0 10px; color: var(--blue); font-size: 12px; font-weight: 700; letter-spacing: .14em; }
h1, h2 { margin: 0; letter-spacing: -.045em; line-height: 1; }
h1 { font-size: clamp(38px, 5vw, 64px); max-width: 760px; }
h2 { font-size: clamp(30px, 4vw, 48px); }
.intro { margin: 10px 0 0; color: var(--muted); font-size: 16px; }
.source { color: var(--muted); font-size: 13px; white-space: nowrap; }
a { color: inherit; text-underline-offset: 3px; }

.search-panel { padding: 16px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); }
.inputs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.city-field { position: relative; padding-left: 34px; transition: opacity .15s; }
.city-field.dragging { opacity: .35; }
.city-field label { position: absolute; top: 7px; left: 46px; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .1em; pointer-events: none; }
.city-field input { width: 100%; height: 54px; padding: 22px 76px 6px 12px; border: 1px solid var(--line); border-radius: 0; background: transparent; color: var(--ink); font-family: inherit; font-size: 15px; font-weight: 600; outline: none; }
.city-field input:focus { border-color: var(--blue); box-shadow: inset 0 0 0 1px var(--blue); }
.remove { position: absolute; right: 5px; top: 12px; width: 30px; height: 30px; border: 0; background: transparent; color: var(--muted); font-size: 21px; cursor: pointer; }
.map-pick { position: absolute; right: 35px; top: 12px; width: 30px; height: 30px; border: 0; background: transparent; color: var(--blue); font-size: 18px; cursor: pointer; }
.order-controls { position: absolute; inset: 0 auto 0 0; width: 28px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.order-controls button { width: 25px; height: 17px; padding: 0; border: 0; background: transparent; color: var(--muted); font: 14px/1 inherit; cursor: pointer; }
.order-controls button:disabled { opacity: .2; cursor: default; }
.drag-handle { color: var(--muted); font-size: 16px; line-height: 14px; cursor: grab; }
.actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 12px; }
.button { min-height: 48px; padding: 0 18px; border: 1px solid var(--blue); font-family: inherit; font-size: 14px; font-weight: 700; cursor: pointer; }
.button-primary { min-width: 220px; background: var(--blue); color: white; }
.button-primary:hover { background: var(--blue-dark); }
.button-primary span { margin-left: 18px; }
.button-secondary { background: transparent; color: var(--blue); }
.button:disabled { opacity: .55; cursor: wait; }
.message { min-height: 26px; padding: 14px 2px 0; color: var(--muted); font-size: 14px; }
.message.error { color: #a7392d; }

.results { margin-top: 42px; }
.result-head { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 20px; }
.legend { display: flex; gap: 18px; color: var(--muted); font-size: 12px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
.dot.max { background: var(--orange); }
.dot.rain { background: var(--blue); }
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); }
table { width: 100%; min-width: 1680px; border-collapse: collapse; table-layout: fixed; }
th, td { width: 96px; padding: 15px 8px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); text-align: center; }
th:first-child, td:first-child { position: sticky; left: 0; z-index: 2; width: 170px; padding-left: 18px; background: var(--panel); text-align: left; box-shadow: 5px 0 10px rgba(16,33,46,.04); }
thead th { color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; }
.date-day { display: block; margin-top: 4px; color: var(--ink); font-size: 17px; font-weight: 700; }
.city-name { display: block; font-size: 15px; font-weight: 700; }
.city-country { color: var(--muted); font-size: 11px; }
.rain-total { display: block; margin-top: 6px; color: var(--blue); font-size: 11px; font-weight: 600; }
.weather-icon { display: block; margin-bottom: 5px; font-size: 24px; line-height: 1; }
.temps { font-size: 15px; font-weight: 700; }
.temps .min { color: var(--muted); font-weight: 400; }
.rain-value { margin-top: 5px; color: var(--blue); font-size: 11px; font-weight: 600; white-space: nowrap; }
.hint { display: none; margin: 10px 0 0; color: var(--muted); font-size: 11px; text-align: right; }

.map-dialog { width: min(900px, calc(100% - 24px)); max-width: none; padding: 0; border: 0; background: transparent; color: var(--ink); }
.map-dialog::backdrop { background: rgba(10, 25, 35, .68); backdrop-filter: blur(4px); }
.map-modal { padding: 24px; background: var(--panel); box-shadow: 0 24px 80px rgba(0,0,0,.3); }
.map-head, .map-foot { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.map-head { margin-bottom: 18px; }
.map-head h2 { font-size: clamp(26px, 4vw, 40px); }
.close-map { align-self: flex-start; width: 42px; height: 42px; border: 1px solid var(--line); background: transparent; color: var(--ink); font-size: 26px; cursor: pointer; }
.map-search { display: flex; gap: 8px; margin-bottom: 12px; }
.map-search input { flex: 1; min-width: 0; height: 48px; padding: 0 14px; border: 1px solid var(--line); background: transparent; color: var(--ink); font: inherit; }
#map { height: min(52vh, 470px); min-height: 310px; background: var(--sky); }
.map-foot { margin-top: 14px; }
.map-foot p { margin: 0; color: var(--muted); font-size: 14px; }
.leaflet-control-attribution { font-family: "DM Sans", sans-serif; }

@media (max-width: 760px) {
  main { width: min(100% - 24px, 1380px); padding-top: 32px; }
  .hero, .result-head { align-items: start; flex-direction: column; }
  .source { display: none; }
  .inputs { grid-template-columns: 1fr; }
  .actions { flex-direction: column-reverse; }
  .button { width: 100%; }
  .hint { display: block; }
  .map-modal { padding: 16px; }
  .map-search, .map-foot { align-items: stretch; flex-direction: column; }
  #map { min-height: 280px; }
}
