:root {
  --bg: #f6f5f2;
  --surface: rgba(255, 255, 255, 0.92);
  --text: #1d1d1f;
  --muted: #6b6b70;
  --line: rgba(0, 0, 0, 0.08);
  --accent: #2f6fde;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  --radius: 14px;
  --scroll: rgba(0, 0, 0, 0.18);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111214;
    --surface: rgba(28, 29, 32, 0.92);
    --text: #f2f2f4;
    --muted: #9a9aa2;
    --line: rgba(255, 255, 255, 0.08);
    --accent: #6c9cff;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    --scroll: rgba(255, 255, 255, 0.2);
  }
}

* { box-sizing: border-box; }

/* Thin themed scrollbars instead of the system ones (Firefox/new Chrome use the first rule,
   Safari and older Chrome the ::-webkit ones) */
* { scrollbar-width: thin; scrollbar-color: var(--scroll) transparent; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

#map { position: fixed; inset: 0; }

h1 { font-size: 18px; margin: 0; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.panel, .detail {
  position: fixed;
  z-index: 1000;
  background: var(--surface);
  backdrop-filter: blur(12px);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel {
  top: 16px;
  left: 16px;
  width: 320px;
  max-height: calc(100% - 32px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--line);
  gap: 10px;
}
.panel-head .head-text { flex: 1; min-width: 0; }
.btn-icon.who { width: 38px; height: 38px; border-radius: 10px; font-size: 22px; flex: none; }

/* Profile picker ("Kdo se dívá?") */
.profiles {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 24px;
  background: var(--bg);
}
.profiles[hidden] { display: none; }
.profiles h1 { font-size: 30px; }
.profile-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 22px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.profile-grid li {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 112px;
  cursor: pointer;
}
.profile-grid .avatar {
  display: grid;
  place-items: center;
  width: 112px;
  height: 112px;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 52px;
  border: 3px solid transparent;
  transition: border-color 0.15s, transform 0.15s;
}
.profile-grid li:hover .avatar { border-color: var(--accent); transform: scale(1.04); }
.profile-grid .pname { color: var(--muted); font-size: 15px; text-align: center; overflow-wrap: anywhere; }
.profile-grid li:hover .pname { color: var(--text); }
.profile-grid .padd .avatar { color: var(--muted); font-size: 44px; box-shadow: none; border: 2px dashed var(--line); }
.profiles.managing .profile-grid li:not(.padd) .avatar { opacity: 0.75; }
.profiles.managing .profile-grid li:not(.padd) .avatar::after { content: '✏️'; position: absolute; font-size: 26px; }
.pdel {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: #d33;
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.btn-link {
  border: 1px solid var(--muted);
  border-radius: 8px;
  padding: 7px 16px;
  background: none;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}
.btn-link:hover { color: var(--text); border-color: var(--text); }
@media (max-width: 700px) {
  .profile-grid li, .profile-grid .avatar { width: 92px; }
  .profile-grid .avatar { height: 92px; font-size: 42px; }
}

.btn-icon {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: var(--line);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.btn-icon:hover { background: var(--accent); color: #fff; }

.btn {
  border: 0;
  border-radius: 10px;
  padding: 9px 14px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn.danger { background: transparent; color: #d64545; padding: 6px 0; font-weight: 500; }

.add {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 8px;
}
.add input {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font: inherit;
}
.add input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.add-fields { display: grid; gap: 8px; }
.hint, .coords { margin: 0; color: var(--muted); font-size: 12px; }

.results { list-style: none; margin: 0; padding: 0; }
.results li {
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.results li:hover { background: var(--line); }
.results small { color: var(--muted); }

.list {
  list-style: none;
  margin: 0;
  padding: 6px;
  overflow-y: auto;
}
.list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  cursor: pointer;
}
.list li:hover, .list li.active { background: var(--line); }
.list .name { flex: 1; min-width: 0; }
.list .name strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .name small { color: var(--muted); }
.list .wx { font-size: 18px; }
.list .t {
  min-width: 52px;
  text-align: center;
  padding: 3px 8px;
  border-radius: 999px;
  color: #fff;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Map markers */
.temp-marker { background: none; border: 0; }
.temp-pin {
  position: relative;
  transform: translate(-50%, -100%);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 999px;
  color: #fff;
  font: 700 13px/1 system-ui, sans-serif;
  white-space: nowrap;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
  border: 2px solid #fff;
  transition: transform 0.15s;
}
.temp-pin::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -7px;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #fff;
}
.temp-pin:hover, .temp-pin.active { transform: translate(-50%, -100%) scale(1.15); z-index: 10; }
.temp-pin .lbl { font-weight: 500; opacity: 0.95; }

/* Detail */
.detail {
  right: 16px;
  bottom: 16px;
  width: 380px;
  padding: 18px;
  max-height: calc(100% - 32px);
  overflow-y: auto;
}
.detail .close { position: absolute; top: 12px; right: 12px; }
.detail h2 { margin: 0; font-size: 20px; padding-right: 40px; }
.now {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0 16px;
}
.now .big { font-size: 44px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.now .wx { font-size: 34px; }
.now small { display: block; color: var(--muted); }

.days { display: grid; gap: 6px; }
.day {
  display: grid;
  grid-template-columns: 52px 26px 34px 1fr 34px 50px;
  white-space: nowrap;
  align-items: center;
  gap: 6px;
  font-variant-numeric: tabular-nums;
}
.day .dn { color: var(--muted); text-transform: capitalize; }
.day .min { text-align: right; color: var(--muted); }
.day .max { font-weight: 700; }
.day .rain { text-align: right; color: var(--accent); font-size: 12px; }
.track { position: relative; height: 6px; border-radius: 3px; background: var(--line); }
.track .range { position: absolute; top: 0; bottom: 0; border-radius: 3px; }

.flights-head { margin: 16px 0 6px; font-size: 13px; font-weight: 600; }
.flights-head small { display: block; color: var(--muted); font-weight: 400; font-size: 11px; }
.flights {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.term {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px;
  border-radius: 10px;
  background: var(--line);
  min-width: 0;
}
.term .tn { color: var(--muted); font-size: 11px; }
.term a { color: inherit; text-decoration: none; border-radius: 6px; }
.fl-best { display: flex; flex-direction: column; margin-bottom: 2px; }
.fl-price { font-size: 17px; font-weight: 700; color: var(--accent); white-space: nowrap; }
.fl-meta { color: var(--muted); font-size: 11px; white-space: nowrap; }
.fl-alt { display: flex; justify-content: space-between; gap: 4px; color: var(--muted); white-space: nowrap; }
.fl-alt span:last-child { color: var(--text); font-weight: 600; }
.term a:hover .fl-price, .fl-alt:hover span { text-decoration: underline; }
.fl-none { color: var(--muted); font-size: 11px; }
.sw-head { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; white-space: nowrap; }
.term > .sw-head:nth-child(2) { margin-top: 0; padding-top: 0; border-top: 0; }
.fl-alt.sw { font-size: 11px; }
.fl-alt.sw span:last-child { font-weight: 600; }
@media (max-width: 700px) {
  .term { padding: 6px; }
}

.detail-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
}

.leaflet-container { background: var(--bg); font: inherit; }

/* Mobile: the list collapses into a header bar, the detail is a bottom sheet over the map */
@media (max-width: 700px) {
  .panel {
    top: calc(10px + env(safe-area-inset-top));
    left: 10px;
    right: 10px;
    width: auto;
    max-height: 60%;
  }
  .panel-head { padding: 10px 12px; border-bottom: 0; }
  .panel.expanded .panel-head { border-bottom: 1px solid var(--line); }
  .panel .head-text { cursor: pointer; }
  .panel #who-name::after { content: ' ▾'; color: var(--muted); font-size: 14px; }
  .panel.expanded #who-name::after { content: ' ▴'; }
  .panel:not(.expanded) .list,
  .panel:not(.expanded) .add { display: none; }
  .list { overflow-y: auto; -webkit-overflow-scrolling: touch; }

  .detail {
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-height: 62%;
    padding: 22px 16px calc(16px + env(safe-area-inset-bottom));
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.18);
  }
  .detail::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    width: 40px;
    height: 4px;
    margin-left: -20px;
    border-radius: 2px;
    background: var(--line);
  }
  .detail .close { top: 14px; right: 12px; }
  .now { margin: 8px 0 12px; }
  .now .big { font-size: 38px; }

  /* 16px+ stops iOS from zooming into the page when an input gets focus */
  .add input { font-size: 16px; }
  .leaflet-control-attribution { font-size: 9px; }
}

/* Loading indicator in place of the weather icon */
.spinner {
  display: inline-block;
  width: 1em;
  height: 1em;
  vertical-align: -0.15em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  opacity: 0.8;
  animation: spin 0.8s linear infinite;
}
.list .spinner { color: var(--muted); width: 18px; height: 18px; }
@keyframes spin { to { transform: rotate(360deg); } }
