:root {
  --bg-panel: #1a2218;
  --bg-panel-soft: #243022;
  --ink: #f2efe6;
  --ink-muted: #b7c0ad;
  --accent: #d45a1a;
  --accent-soft: #e8a06a;
  --line: rgba(242, 239, 230, 0.12);
  --ok: #7cb87a;
  --map-fade: rgba(18, 24, 16, 0.55);
  --font: "Source Sans 3", "Segoe UI", sans-serif;
  --font-cond: "IBM Plex Sans Condensed", "Source Sans 3", sans-serif;
  --panel-w: min(380px, 100vw);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: #0f140e;
}

/* PWA / iOS standalone: izkoristi cel zaslon */
html.standalone,
body.standalone,
html:fullscreen,
body:fullscreen {
  height: 100%;
  height: 100dvh;
}

@media all and (display-mode: standalone) {
  html,
  body {
    height: 100%;
    height: 100dvh;
    overscroll-behavior: none;
  }

  #app {
    min-height: 100dvh;
  }

  #map {
    min-height: 100dvh;
  }
}

#app {
  display: grid;
  grid-template-columns: var(--panel-w) 1fr;
  height: 100%;
  min-height: 100dvh;
}

.panel {
  position: relative;
  z-index: 500;
  overflow-y: auto;
  padding: 1.25rem 1.15rem 1.5rem;
  background:
    linear-gradient(165deg, rgba(212, 90, 26, 0.14), transparent 42%),
    radial-gradient(ellipse at 10% 0%, rgba(124, 184, 122, 0.12), transparent 50%),
    var(--bg-panel);
  border-right: 1px solid var(--line);
  box-shadow: 8px 0 28px rgba(0, 0, 0, 0.28);
}

.panel__header h1 {
  margin: 0.15rem 0 0.35rem;
  font-family: var(--font-cond);
  font-size: 1.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.1;
}

.panel__brand {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-soft);
}

.panel__lead {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.92rem;
}

.panel__section {
  margin-top: 1.15rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.panel__section h2 {
  margin: 0 0 0.55rem;
  font-family: var(--font-cond);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.hint {
  margin: 0 0 0.65rem;
  color: var(--ink-muted);
  font-size: 0.88rem;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  margin-bottom: 0.55rem;
  font-size: 0.82rem;
  color: var(--ink-muted);
}

.field input,
.field select {
  width: 100%;
  padding: 0.55rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-panel-soft);
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
}

.field input:focus,
.field select:focus {
  outline: 2px solid rgba(212, 90, 26, 0.55);
  outline-offset: 1px;
}

.field input:disabled,
.field select:disabled {
  opacity: 0.55;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin: 0.2rem 0 0.7rem;
  font-size: 0.9rem;
  color: var(--ink);
  cursor: pointer;
}

.check input {
  margin-top: 0.2rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.62rem 0.85rem;
  border: 1px solid transparent;
  border-radius: 7px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn--primary {
  background: var(--accent);
  color: #fff8f2;
}

.btn--primary:hover {
  background: #e36a28;
}

.btn--ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}

.btn--ghost:hover {
  border-color: rgba(242, 239, 230, 0.35);
  background: rgba(255, 255, 255, 0.04);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.meta {
  margin: 0.35rem 0 0.45rem;
  font-size: 0.82rem;
  color: var(--ink-muted);
  line-height: 1.35;
}

.wind-compass {
  position: relative;
  width: 72px;
  height: 72px;
  margin: 0.4rem 0 0.6rem;
  border-radius: 50%;
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at center, rgba(212, 90, 26, 0.15), transparent 65%),
    var(--bg-panel-soft);
}

.wind-compass__arrow {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 28px solid var(--accent-soft);
  transform-origin: 50% 100%;
  transform: translate(-50%, -100%) rotate(0deg);
  transition: transform 0.35s ease;
}

.wind-compass__label {
  position: absolute;
  left: 50%;
  bottom: -1.35rem;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 0.75rem;
  color: var(--ink-muted);
}

.rates {
  margin-top: 0.75rem;
  padding: 0.7rem 0.75rem;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--line);
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--ink-muted);
}

.timeline {
  margin-top: 0.75rem;
  padding: 0.7rem 0.75rem;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid var(--line);
}

.timeline input[type="range"] {
  width: 100%;
  margin: 0.35rem 0 0.2rem;
  accent-color: var(--accent);
}

.rates strong {
  color: var(--ink);
  font-weight: 600;
}

.legend ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.4rem;
  font-size: 0.88rem;
  color: var(--ink-muted);
}

.swatch {
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 3px;
  flex-shrink: 0;
}

.swatch--1h {
  background: rgba(232, 120, 48, 0.55);
  border: 2px solid #e87830;
}

.swatch--6h {
  background: rgba(180, 40, 30, 0.35);
  border: 2px solid #b4281e;
}

.swatch--ignition {
  border-radius: 50%;
  background: #ffd166;
  border: 2px solid #d45a1a;
}

.swatch--gps {
  border-radius: 50%;
  background: #3d8bfd;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(61, 139, 253, 0.5);
}

.disclaimer {
  margin: 1.25rem 0 0;
  padding: 0.75rem 0.8rem;
  border-left: 3px solid var(--accent);
  background: rgba(0, 0, 0, 0.2);
  color: var(--ink-muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

#map {
  height: 100%;
  min-height: 100dvh;
  background: #1c241a;
}

.panel-toggle {
  display: none;
  position: fixed;
  top: max(0.75rem, env(safe-area-inset-top));
  right: max(0.75rem, env(safe-area-inset-right));
  left: auto;
  z-index: 1100;
  min-width: 2.75rem;
  height: 2.75rem;
  padding: 0 0.85rem;
  gap: 0.4rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(26, 34, 24, 0.94);
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.panel-toggle__icon {
  font-size: 1.15rem;
  line-height: 1;
}

.panel-backdrop {
  display: none;
}

.status {
  position: fixed;
  right: 1rem;
  bottom: max(5.5rem, calc(env(safe-area-inset-bottom) + 5rem));
  z-index: 900;
  max-width: min(360px, calc(100vw - 2rem));
  padding: 0.7rem 0.9rem;
  border-radius: 8px;
  background: rgba(26, 34, 24, 0.94);
  border: 1px solid var(--line);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  font-size: 0.88rem;
  line-height: 1.35;
}

.status--error {
  border-color: rgba(212, 90, 26, 0.7);
}

.status--ok {
  border-color: rgba(124, 184, 122, 0.55);
}

.leaflet-container {
  font: inherit;
  background: #1c241a;
}

.ignition-icon {
  display: block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffd166;
  border: 2px solid #d45a1a;
  box-shadow: 0 0 0 4px rgba(212, 90, 26, 0.25);
}

.gps-icon {
  display: block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #3d8bfd;
  border: 2px solid #fff;
  box-shadow: 0 0 0 3px rgba(61, 139, 253, 0.35);
}

@media (max-width: 860px) {
  #app {
    grid-template-columns: 1fr;
  }

  .panel {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(360px, 92vw);
    max-width: 100%;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    z-index: 1000;
    padding-top: max(1.25rem, env(safe-area-inset-top));
    padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
  }

  body.panel-open .panel {
    transform: translateX(0);
  }

  .panel-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  body.panel-open .panel-toggle {
    right: max(0.75rem, env(safe-area-inset-right));
    left: auto;
  }

  body.panel-open .panel-toggle__text {
    display: none;
  }

  body.panel-open .panel-toggle::after {
    content: "✕";
    font-size: 1.1rem;
  }

  body.panel-open .panel-toggle__icon {
    display: none;
  }

  .panel-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 950;
    background: rgba(0, 0, 0, 0.45);
    border: 0;
    padding: 0;
    cursor: pointer;
  }

  .panel-backdrop[hidden] {
    display: none;
  }

  .leaflet-bottom.leaflet-right {
    margin-bottom: max(0.5rem, env(safe-area-inset-bottom));
    margin-right: max(0.35rem, env(safe-area-inset-right));
  }

  .leaflet-control-attribution {
    max-width: calc(100vw - 5rem);
    font-size: 9px;
  }
}
