:root {
  color-scheme: dark;
  --panel-bg: rgba(8, 18, 18, 0.72);
  --panel-border: rgba(255, 255, 255, 0.18);
  --text: #f3fff9;
  --muted: #a9bbb5;
  --accent: #70f2a7;
  --accent-strong: #c8ff63;
  --danger: #ff756f;
  --warning: #ffd166;
  --shadow: rgba(0, 0, 0, 0.38);
}

.settings-open {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 7;
  min-width: 86px;
  height: 38px;
  border: 1px solid rgba(112, 242, 167, 0.28);
  border-radius: 8px;
  color: var(--accent);
  background: rgba(8, 18, 18, 0.72);
  box-shadow: 0 14px 38px var(--shadow);
  font-weight: 850;
  cursor: pointer;
  backdrop-filter: blur(18px) saturate(130%);
}

.settings-open:hover {
  color: #041d11;
  background: var(--accent);
}

.settings-modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  background: rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(8px);
}

.settings-modal[hidden] {
  display: none;
}

.settings-card {
  width: min(720px, 100%);
  max-height: min(760px, calc(100vh - 28px));
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background:
    radial-gradient(circle at 50% 0%, rgba(112, 242, 167, 0.1), transparent 42%),
    rgba(8, 18, 18, 0.92);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.56);
}

.settings-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.settings-header h2 {
  margin: 3px 0 0;
  font-size: 1.2rem;
}

.settings-close {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
}

.settings-help {
  margin: 12px 0 16px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
}

.settings-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.settings-field,
.settings-check {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.settings-field-full {
  grid-column: 1 / -1;
}

.settings-field input,
.settings-field textarea,
.settings-field select {
  width: 100%;
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 650;
  text-transform: none;
}

.settings-field select {
  appearance: none;
}

.settings-field textarea {
  resize: vertical;
}

.settings-check {
  grid-template-columns: auto 1fr;
  align-items: center;
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.settings-check input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.settings-message {
  grid-column: 1 / -1;
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.settings-message.is-error {
  color: var(--danger);
}

.settings-message.is-ok {
  color: var(--accent);
}

.settings-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.settings-actions button {
  min-height: 40px;
  padding: 0 13px;
  border: 1px solid rgba(112, 242, 167, 0.28);
  border-radius: 8px;
  color: var(--accent);
  background: rgba(112, 242, 167, 0.08);
  font-weight: 850;
  cursor: pointer;
}

.settings-actions .settings-primary {
  color: #041d11;
  background: var(--accent);
}

.timeline-panel.alert-events-visible {
  display: block;
  z-index: 8;
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

@media (max-width: 720px) {
  .settings-open {
    right: max(10px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
    min-width: 76px;
    height: 34px;
    font-size: 0.78rem;
  }

  .settings-card {
    padding: 14px;
  }

  .settings-form {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .settings-actions button {
    flex: 1 1 132px;
  }
}

/* Map-first restore: compact route controls and tracker-anchored card. */
.history-panel {
  right: auto;
  bottom: max(12px, env(safe-area-inset-bottom));
  left: max(12px, env(safe-area-inset-left));
  max-width: min(560px, calc(100vw - 24px));
  padding: 8px;
  border-radius: 8px;
}

.history-controls {
  gap: 7px;
  padding-bottom: 0;
  border-bottom: 0;
}

.history-title {
  margin: 0 4px 0 2px;
  font-size: 0.74rem;
}

.day-tiles {
  display: flex;
  gap: 5px;
}

.day-tile {
  display: grid;
  gap: 1px;
  min-width: 54px;
  height: 38px;
  padding: 4px 7px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 7px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
}

.day-tile[aria-pressed="true"] {
  color: #041d11;
  background: var(--accent);
}

.day-tile strong {
  font-size: 0.72rem;
  line-height: 1;
}

.day-tile span {
  font-size: 0.66rem;
  font-weight: 800;
  opacity: 0.78;
}

.load-day-button,
.quiet-button {
  height: 38px;
  padding: 0 10px;
  font-size: 0.82rem;
}

.history-playback {
  display: none;
  grid-template-columns: 1fr auto;
  gap: 14px;
  padding-top: 8px;
}

.history-panel.history-active .history-playback {
  display: grid;
}

.history-panel.history-active {
  max-width: min(680px, calc(100vw - 24px));
}

.history-panel.history-active .history-rail-group {
  padding-bottom: 24px;
}

.history-panel.history-active .time-labels {
  font-size: 0.68rem;
}

.history-panel.history-active .tick-row {
  height: 8px;
}

.history-panel.history-active .daylight-track {
  height: 24px;
  border-radius: 8px;
}

.history-panel.history-active .daylight-track input {
  height: 24px;
}

.history-panel.history-active .daylight-track output {
  top: 32px;
  min-width: 54px;
  padding: 3px 7px;
  font-size: 0.72rem;
}

.status-panel {
  right: auto;
  bottom: auto;
  width: min(392px, calc(100vw - 40px));
}

.status-panel.tracker-callout {
  width: min(238px, calc(100vw - 24px));
  padding: 9px;
  background: rgba(20, 33, 29, 0.84);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.34);
}

.status-panel.tracker-callout h1 {
  max-width: 118px;
  font-size: 0.82rem;
}

.status-panel.tracker-callout .battery-percent {
  font-size: 1.9rem;
}

.status-panel.tracker-callout .voltage-block p:last-child {
  font-size: 0.86rem;
}

.status-panel.tracker-callout .last-seen p:last-child {
  font-size: 0.68rem;
}

@media (max-width: 720px) {
  .history-panel {
    max-width: calc(100vw - 20px);
  }

  .history-title {
    display: none;
  }

  .day-tiles {
    overflow-x: auto;
    min-width: 0;
  }

  .day-tile {
    flex: 0 0 auto;
  }

  .history-panel.history-active .history-playback {
    display: block;
  }

  .status-panel {
    bottom: auto;
  }
}

/* Keep the events timeline detached from the tracker callout. */
.timeline-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 40px;
  margin-top: 8px;
  padding: 0 12px;
  border: 1px solid rgba(112, 242, 167, 0.28);
  border-radius: 8px;
  color: var(--accent);
  background: rgba(112, 242, 167, 0.08);
  font-weight: 850;
  cursor: pointer;
}

.timeline-toggle:hover,
.timeline-toggle[aria-expanded="true"] {
  color: #041d11;
  background: var(--accent);
}

.status-panel.card-collapsed .timeline-toggle {
  display: none;
}

.status-panel.tracker-callout .timeline-toggle {
  min-height: 30px;
  margin-top: 6px;
  padding: 0 8px;
  font-size: 0.7rem;
}

.timeline-panel {
  position: fixed;
  left: 50%;
  right: auto;
  bottom: max(86px, calc(env(safe-area-inset-bottom) + 86px));
  z-index: 4;
  width: min(520px, calc(100vw - 24px));
  max-height: min(42vh, 360px);
  margin: 0;
  margin-top: 0;
  padding: 12px;
  padding-top: 12px;
  overflow: auto;
  border: 1px solid var(--panel-border);
  border-top: 1px solid var(--panel-border);
  border-radius: 8px;
  background: rgba(8, 18, 18, 0.78);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.34);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 160ms ease, transform 160ms ease;
  backdrop-filter: blur(18px) saturate(135%);
}

.timeline-panel.timeline-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

@media (max-width: 720px) {
  .timeline-panel {
    bottom: max(78px, calc(env(safe-area-inset-bottom) + 78px));
    width: calc(100vw - 20px);
    max-height: 38vh;
  }
}

/* Last-pass history playback layout. This must stay at the end. */
.history-panel {
  left: 50%;
  right: auto;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 5;
  width: min(1280px, calc(100vw - 28px));
  max-width: none;
  max-height: min(60vh, 560px);
  padding: clamp(16px, 2vw, 32px);
  overflow: auto;
  border-radius: 16px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 18px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.history-panel.history-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.history-controls {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(12px, 1.6vw, 22px);
  padding-bottom: clamp(14px, 1.8vw, 24px);
  border-bottom: 0;
}

.history-title {
  display: block;
  margin: 0;
  font-size: clamp(1rem, 1.25vw, 1.35rem);
}

.day-tiles {
  display: flex;
  gap: clamp(8px, 1vw, 14px);
  min-width: 0;
  overflow-x: auto;
  padding: 2px;
  scrollbar-width: thin;
}

.day-tile {
  flex: 0 0 auto;
  min-width: clamp(74px, 7.6vw, 112px);
  height: clamp(54px, 5.4vw, 74px);
  border-radius: 10px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.045);
}

.day-tile[aria-pressed="true"] {
  color: #041d11;
  background: #25d86c;
  box-shadow: 0 0 0 1px rgba(112, 242, 167, 0.42), 0 12px 26px rgba(37, 216, 108, 0.26);
}

.day-tile strong {
  font-size: clamp(1rem, 1.35vw, 1.38rem);
  line-height: 1.05;
}

.day-tile span {
  font-size: clamp(0.74rem, 0.9vw, 0.9rem);
  text-transform: uppercase;
}

.load-day-button {
  display: none;
}

.quiet-button {
  justify-self: end;
  min-width: 118px;
  border-color: rgba(112, 242, 167, 0.45);
  color: var(--accent);
}

.history-playback,
.history-panel.history-active .history-playback {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "rail live"
    "play live";
  gap: 18px 28px;
  padding-top: clamp(18px, 2vw, 30px);
}

.history-rail-group {
  grid-area: rail;
}

.history-live {
  grid-area: live;
}

.history-play-controls {
  grid-area: play;
  display: flex;
  align-items: center;
  gap: 12px;
}

.history-play-button {
  position: relative;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  color: #052114;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(112, 242, 167, 0.24);
}

.history-play-button span {
  position: absolute;
  top: 50%;
  left: 53%;
  width: 0;
  height: 0;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  border-left: 14px solid currentColor;
  transform: translate(-50%, -50%);
}

.history-play-button[aria-pressed="true"] span {
  left: 50%;
  width: 14px;
  height: 18px;
  border: 0;
  border-right: 5px solid currentColor;
  border-left: 5px solid currentColor;
}

.speed-controls {
  display: flex;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.speed-button {
  min-width: 58px;
  height: 36px;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-weight: 850;
  cursor: pointer;
}

.speed-button[aria-pressed="true"] {
  color: var(--accent);
  background: rgba(112, 242, 167, 0.2);
}

.daylight-track {
  isolation: isolate;
}

.daylight-track::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  z-index: 1;
  width: var(--history-progress);
  border-radius: inherit;
  background: rgba(37, 216, 108, 0.92);
  box-shadow: 0 0 24px rgba(37, 216, 108, 0.5);
  pointer-events: none;
}

.moon-icon,
.sun-icon,
.sunrise-icon {
  z-index: 2;
}

.daylight-track input {
  z-index: 4;
}

.daylight-track output {
  z-index: 5;
}

.timeline-panel,
.timeline-panel.timeline-visible {
  display: none;
}

@media (max-width: 720px) {
  .history-panel {
    bottom: max(10px, env(safe-area-inset-bottom));
    width: calc(100vw - 20px);
    max-height: 54vh;
    padding: 14px;
    border-radius: 12px;
  }

  .history-controls {
    grid-template-columns: 1fr auto;
    gap: 10px;
  }

  .history-title {
    grid-column: 1 / -1;
    display: block;
    font-size: 0.9rem;
  }

  .day-tiles {
    grid-column: 1 / 2;
  }

  .quiet-button {
    min-width: 76px;
    height: 38px;
    padding: 0 10px;
    font-size: 0.8rem;
  }

  .day-tile {
    min-width: 66px;
    height: 48px;
  }

  .history-playback,
  .history-panel.history-active .history-playback {
    display: block;
  }

  .history-live {
    display: none;
  }

  .history-play-controls {
    margin-top: 12px;
  }

  .speed-button {
    min-width: 46px;
  }
}

/* Final history playback restore: the Ajalugu button owns this large center panel. */
.history-panel {
  left: 50%;
  right: auto;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 5;
  width: min(1280px, calc(100vw - 28px));
  max-width: none;
  max-height: min(60vh, 560px);
  padding: clamp(16px, 2vw, 32px);
  overflow: auto;
  border-radius: 16px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 18px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.history-panel.history-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.history-controls {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(12px, 1.6vw, 22px);
  padding-bottom: clamp(14px, 1.8vw, 24px);
  border-bottom: 0;
}

.history-title {
  margin: 0;
  font-size: clamp(1rem, 1.25vw, 1.35rem);
}

.day-tiles {
  display: flex;
  gap: clamp(8px, 1vw, 14px);
  min-width: 0;
  overflow-x: auto;
  padding: 2px;
  scrollbar-width: thin;
}

.day-tile {
  flex: 0 0 auto;
  min-width: clamp(74px, 7.6vw, 112px);
  height: clamp(54px, 5.4vw, 74px);
  border-radius: 10px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.045);
}

.day-tile[aria-pressed="true"] {
  color: #041d11;
  background: #25d86c;
  box-shadow: 0 0 0 1px rgba(112, 242, 167, 0.42), 0 12px 26px rgba(37, 216, 108, 0.26);
}

.day-tile strong {
  font-size: clamp(1rem, 1.35vw, 1.38rem);
  line-height: 1.05;
}

.day-tile span {
  font-size: clamp(0.74rem, 0.9vw, 0.9rem);
  text-transform: uppercase;
}

.load-day-button {
  display: none;
}

.quiet-button {
  justify-self: end;
  min-width: 118px;
  border-color: rgba(112, 242, 167, 0.45);
  color: var(--accent);
}

.history-playback,
.history-panel.history-active .history-playback {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "rail live"
    "play live";
  gap: 18px 28px;
  padding-top: clamp(18px, 2vw, 30px);
}

.history-rail-group {
  grid-area: rail;
}

.history-live {
  grid-area: live;
}

.history-play-controls {
  grid-area: play;
  display: flex;
  align-items: center;
  gap: 12px;
}

.history-play-button {
  position: relative;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  color: #052114;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(112, 242, 167, 0.24);
}

.history-play-button span {
  position: absolute;
  top: 50%;
  left: 53%;
  width: 0;
  height: 0;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  border-left: 14px solid currentColor;
  transform: translate(-50%, -50%);
}

.history-play-button[aria-pressed="true"] span {
  left: 50%;
  width: 14px;
  height: 18px;
  border: 0;
  border-right: 5px solid currentColor;
  border-left: 5px solid currentColor;
}

.speed-controls {
  display: flex;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.speed-button {
  min-width: 58px;
  height: 36px;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-weight: 850;
  cursor: pointer;
}

.speed-button[aria-pressed="true"] {
  color: var(--accent);
  background: rgba(112, 242, 167, 0.2);
}

.daylight-track {
  isolation: isolate;
}

.daylight-track::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  z-index: 1;
  width: var(--history-progress);
  border-radius: inherit;
  background: rgba(37, 216, 108, 0.92);
  box-shadow: 0 0 24px rgba(37, 216, 108, 0.5);
  pointer-events: none;
}

.moon-icon,
.sun-icon,
.sunrise-icon {
  z-index: 2;
}

.daylight-track input {
  z-index: 4;
}

.daylight-track output {
  z-index: 5;
}

.timeline-panel,
.timeline-panel.timeline-visible {
  display: none;
}

@media (max-width: 720px) {
  .history-panel {
    bottom: max(10px, env(safe-area-inset-bottom));
    width: calc(100vw - 20px);
    max-height: 54vh;
    padding: 14px;
    border-radius: 12px;
  }

  .history-controls {
    grid-template-columns: 1fr auto;
    gap: 10px;
  }

  .history-title {
    grid-column: 1 / -1;
    display: block;
    font-size: 0.9rem;
  }

  .day-tiles {
    grid-column: 1 / 2;
  }

  .quiet-button {
    min-width: 76px;
    height: 38px;
    padding: 0 10px;
    font-size: 0.8rem;
  }

  .day-tile {
    min-width: 66px;
    height: 48px;
  }

  .history-playback,
  .history-panel.history-active .history-playback {
    display: block;
  }

  .history-live {
    display: none;
  }

  .history-play-controls {
    margin-top: 12px;
  }

  .speed-button {
    min-width: 46px;
  }
}

/* Timeline is controlled from the tracker card, but floats independently. */
.timeline-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 40px;
  margin-top: 8px;
  padding: 0 12px;
  border: 1px solid rgba(112, 242, 167, 0.28);
  border-radius: 8px;
  color: var(--accent);
  background: rgba(112, 242, 167, 0.08);
  font-weight: 850;
  cursor: pointer;
}

.timeline-toggle:hover,
.timeline-toggle[aria-expanded="true"] {
  color: #041d11;
  background: var(--accent);
}

.status-panel.card-collapsed .timeline-toggle {
  display: none;
}

.status-panel.tracker-callout .timeline-toggle {
  min-height: 30px;
  margin-top: 6px;
  padding: 0 8px;
  font-size: 0.7rem;
}

.timeline-panel {
  position: fixed;
  left: 50%;
  right: auto;
  bottom: max(86px, calc(env(safe-area-inset-bottom) + 86px));
  z-index: 4;
  width: min(520px, calc(100vw - 24px));
  max-height: min(42vh, 360px);
  margin: 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: rgba(8, 18, 18, 0.78);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.34);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 160ms ease, transform 160ms ease;
  backdrop-filter: blur(18px) saturate(135%);
}

.timeline-panel.timeline-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

@media (max-width: 720px) {
  .timeline-panel {
    bottom: max(78px, calc(env(safe-area-inset-bottom) + 78px));
    width: calc(100vw - 20px);
    max-height: 38vh;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #07100e;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
a {
  font: inherit;
}

#map {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

body.globe-mode #map {
  background: radial-gradient(circle at 50% 45%, #071a32 0%, #020713 62%, #000 100%);
}

.map-tools {
  position: fixed;
  top: max(18px, env(safe-area-inset-top));
  right: calc(max(18px, env(safe-area-inset-right)) + 52px);
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw - 96px);
  padding: 6px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: rgba(8, 18, 18, 0.7);
  box-shadow: 0 14px 38px var(--shadow);
  backdrop-filter: blur(18px) saturate(130%);
}

.tool-button,
.style-button {
  height: 36px;
  border: 0;
  border-radius: 6px;
  color: var(--text);
  background: transparent;
  cursor: pointer;
}

.tool-button {
  position: relative;
  width: 36px;
  border: 1px solid rgba(255, 255, 255, 0.13);
}

.tool-button:hover,
.style-button:hover,
.style-button[aria-pressed="true"] {
  background: rgba(255, 255, 255, 0.14);
}

.target-icon {
  position: absolute;
  inset: 9px;
  border: 2px solid var(--accent);
  border-radius: 50%;
}

.target-icon::before,
.target-icon::after {
  content: "";
  position: absolute;
  background: var(--accent);
}

.target-icon::before {
  top: 50%;
  left: -6px;
  width: 26px;
  height: 2px;
  transform: translateY(-50%);
}

.target-icon::after {
  top: -6px;
  left: 50%;
  width: 2px;
  height: 26px;
  transform: translateX(-50%);
}

.tool-button[aria-pressed="true"] {
  background: rgba(112, 242, 167, 0.18);
}

.geofence-icon {
  position: absolute;
  top: 5px;
  left: 50%;
  width: 16px;
  height: 20px;
  border-radius: 50% 50% 50% 0;
  background:
    radial-gradient(circle at 62% 38%, transparent 0 3px, var(--accent) 3.4px);
  box-shadow: 0 0 0 1px rgba(200, 255, 99, 0.42);
  transform: translateX(-50%) rotate(-45deg);
}

.geofence-icon::after {
  content: "";
  position: absolute;
  right: -9px;
  bottom: -7px;
  width: 29px;
  height: 11px;
  border: 3px solid var(--accent-strong);
  border-top-color: transparent;
  border-radius: 50%;
  transform: rotate(45deg);
}

.geofence-toggle[aria-pressed="false"] .geofence-icon {
  opacity: 0.38;
  filter: grayscale(0.8);
}

.globe-icon {
  position: absolute;
  inset: 8px;
  border: 2px solid var(--accent);
  border-radius: 50%;
}

.globe-icon::before,
.globe-icon::after {
  content: "";
  position: absolute;
  border: 1.5px solid var(--accent);
  border-radius: 50%;
}

.globe-icon::before {
  top: -2px;
  right: 4px;
  bottom: -2px;
  left: 4px;
}

.globe-icon::after {
  top: 7px;
  right: -2px;
  left: -2px;
  height: 0;
  border-right: 0;
  border-bottom: 0;
  border-left: 0;
}

.projection-toggle[aria-pressed="true"] .globe-icon,
.projection-toggle[aria-pressed="true"] .globe-icon::before,
.projection-toggle[aria-pressed="true"] .globe-icon::after {
  border-color: var(--accent-strong);
}

.style-switcher {
  display: flex;
  gap: 3px;
}

.style-button {
  min-width: 56px;
  padding: 0 10px;
  font-size: 0.78rem;
  font-weight: 800;
}

.style-button[aria-pressed="true"] {
  color: #041d11;
  background: var(--accent);
}

.status-panel {
  position: fixed;
  top: max(20px, env(safe-area-inset-top));
  left: max(20px, env(safe-area-inset-left));
  z-index: 2;
  width: min(392px, calc(100vw - 40px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 20px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: var(--panel-bg);
  box-shadow: 0 24px 70px var(--shadow);
  backdrop-filter: blur(22px) saturate(130%);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow,
.metric-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1 {
  margin: 4px 0 0;
  font-size: 1.35rem;
  line-height: 1.18;
  font-weight: 760;
}

.status-badge {
  flex: 0 0 auto;
  min-width: 88px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.status-badge.online {
  color: #062d18;
  background: var(--accent);
}

.status-badge.offline {
  color: #32100e;
  background: var(--danger);
}

.status-badge.unknown {
  color: #2d250a;
  background: var(--warning);
}

.status-badge.history {
  color: #041d11;
  background: #8dd7ff;
}

.history-panel {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  left: max(18px, env(safe-area-inset-left));
  z-index: 3;
  max-width: 980px;
  margin: 0 auto;
  padding: 26px 30px 24px;
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.11), transparent 44%),
    rgba(10, 17, 19, 0.76);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(28px) saturate(140%);
  --history-progress: 0%;
  --history-label-left: 0%;
}

.history-controls {
  display: flex;
  align-items: center;
  gap: 18px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
}

.history-title {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.date-field {
  position: relative;
  width: 176px;
}

.date-field input {
  width: 100%;
  height: 46px;
  padding: 0 44px 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  font-size: 1rem;
  font-weight: 800;
}

.date-field input::-webkit-calendar-picker-indicator {
  position: absolute;
  right: 0;
  width: 44px;
  height: 100%;
  cursor: pointer;
  opacity: 0;
}

.calendar-icon {
  position: absolute;
  top: 13px;
  right: 14px;
  width: 18px;
  height: 18px;
  pointer-events: none;
  border: 2px solid var(--text);
  border-radius: 4px;
}

.calendar-icon::before,
.calendar-icon::after {
  content: "";
  position: absolute;
  background: var(--text);
}

.calendar-icon::before {
  top: 4px;
  right: -2px;
  left: -2px;
  height: 2px;
}

.calendar-icon::after {
  top: -5px;
  left: 4px;
  width: 7px;
  height: 5px;
  background: transparent;
  border-right: 2px solid var(--text);
  border-left: 2px solid var(--text);
}

.load-day-button,
.quiet-button,
.live-view-button {
  height: 46px;
  border: 0;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 850;
  cursor: pointer;
}

.load-day-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0 22px;
  color: #f7fbff;
  background: linear-gradient(180deg, #2f78ff, #124fd3);
  box-shadow: 0 10px 30px rgba(18, 79, 211, 0.36);
}

.download-icon {
  position: relative;
  width: 18px;
  height: 20px;
  border-bottom: 2px solid currentColor;
}

.download-icon::before,
.download-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  background: currentColor;
  transform: translateX(-50%);
}

.download-icon::before {
  top: 1px;
  width: 2px;
  height: 13px;
}

.download-icon::after {
  top: 9px;
  width: 10px;
  height: 10px;
  background: transparent;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateX(-50%) rotate(45deg);
}

.quiet-button {
  padding: 0 16px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.load-day-button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.history-playback {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 28px;
  align-items: center;
  padding-top: 24px;
}

.history-rail-group {
  position: relative;
  min-width: 0;
  padding-bottom: 34px;
}

.time-labels {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  margin-bottom: 8px;
  color: rgba(243, 255, 249, 0.78);
  font-size: 0.9rem;
}

.time-labels span:nth-child(2),
.time-labels span:nth-child(3),
.time-labels span:nth-child(4) {
  text-align: center;
}

.time-labels span:last-child {
  text-align: right;
}

.tick-row {
  height: 13px;
  margin: 0 9px 3px;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.48) 0 1px,
      transparent 1px calc(100% / 24)
    );
  mask-image: linear-gradient(to bottom, transparent 0 3px, #000 3px 100%);
}

.daylight-track {
  position: relative;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 13px;
  background:
    linear-gradient(90deg, #0c1b62 0%, #16225e 17%, #ffd36c 40%, #fff8be 50%, #ffd16b 62%, #341d5f 82%, #07145a 100%);
  box-shadow:
    inset 0 0 28px rgba(255, 255, 255, 0.16),
    0 12px 28px rgba(0, 0, 0, 0.3);
}

.daylight-track::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    radial-gradient(circle at 10% 35%, rgba(255, 255, 255, 0.44) 0 1px, transparent 2px),
    radial-gradient(circle at 14% 65%, rgba(255, 255, 255, 0.24) 0 1px, transparent 2px),
    radial-gradient(circle at 88% 38%, rgba(255, 255, 255, 0.4) 0 1px, transparent 2px),
    radial-gradient(circle at 92% 68%, rgba(255, 255, 255, 0.22) 0 1px, transparent 2px);
  pointer-events: none;
}

.daylight-track input {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 38px;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.daylight-track output {
  position: absolute;
  top: 52px;
  left: clamp(34px, var(--history-label-left), calc(100% - 34px));
  min-width: 66px;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  color: var(--text);
  background: rgba(16, 24, 26, 0.86);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.36);
  font-size: 0.92rem;
  font-weight: 850;
  text-align: center;
  transform: translateX(-50%);
}

.daylight-track output::before {
  content: "";
  position: absolute;
  top: -26px;
  left: 50%;
  width: 2px;
  height: 26px;
  background: rgba(255, 255, 255, 0.86);
  transform: translateX(-50%);
}

.daylight-track output::after {
  content: "";
  position: absolute;
  top: -40px;
  left: 50%;
  width: 18px;
  height: 18px;
  border: 4px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  background: #172022;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
  transform: translateX(-50%);
}

.history-panel:not(.history-active) .daylight-track output::before,
.history-panel:not(.history-active) .daylight-track output::after {
  display: none;
}

.moon-icon,
.sun-icon,
.sunrise-icon {
  position: absolute;
  z-index: 1;
  pointer-events: none;
}

.moon-icon {
  top: 10px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  box-shadow: -5px 0 0 0 #ffffff;
}

.moon-start {
  left: 4%;
}

.moon-end {
  right: 4%;
}

.sun-icon {
  top: 11px;
  left: 50%;
  width: 16px;
  height: 16px;
  border: 3px solid #ffb21d;
  border-radius: 50%;
  background: #ffcf3f;
  transform: translateX(-50%);
}

.sunrise-icon {
  bottom: 10px;
  width: 22px;
  height: 11px;
  border: 3px solid #ffffff;
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
}

.sunrise-icon::after {
  content: "";
  position: absolute;
  right: -6px;
  bottom: -3px;
  left: -6px;
  height: 2px;
  background: #ffffff;
}

.sunrise-start {
  left: 26%;
}

.sunset-end {
  right: 22%;
}

.history-live {
  display: flex;
  align-items: center;
  align-self: stretch;
  padding-left: 26px;
  border-left: 1px solid rgba(255, 255, 255, 0.2);
}

.live-view-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  border: 1px solid #2f78ff;
  color: var(--text);
  background: rgba(47, 120, 255, 0.08);
}

.eye-icon {
  position: relative;
  width: 24px;
  height: 14px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.eye-icon::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 8px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
}

.card-toggle {
  position: relative;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
}

.card-toggle span,
.card-toggle span::before {
  content: "";
  position: absolute;
  left: 7px;
  width: 12px;
  height: 2px;
  border-radius: 999px;
  background: var(--accent);
}

.card-toggle span {
  top: 12px;
}

.card-toggle span::before {
  top: 0;
  transform: rotate(90deg);
}

.card-toggle[aria-expanded="true"] span::before {
  transform: rotate(0deg);
}

.battery-readout {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-top: 24px;
  padding: 18px 0 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.13);
  border-bottom: 1px solid rgba(255, 255, 255, 0.13);
}

.battery-percent {
  margin: 2px 0 0;
  color: var(--accent-strong);
  font-size: 4rem;
  line-height: 0.92;
  font-weight: 820;
}

.voltage-block {
  min-width: 92px;
  text-align: right;
}

.voltage-block p:last-child {
  margin: 4px 0 4px;
  font-size: 1.35rem;
  font-weight: 740;
}

.last-seen {
  margin-top: 18px;
}

.last-seen p:last-child,
.coordinates p:last-child {
  margin: 4px 0 0;
  font-size: 0.95rem;
  line-height: 1.45;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.metrics-grid div {
  min-height: 58px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.metrics-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.metrics-grid strong {
  display: block;
  margin-top: 5px;
  overflow-wrap: anywhere;
  font-size: 1rem;
}

.coordinates {
  margin-top: 18px;
}

.maps-link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  margin-top: 18px;
  padding: 0 16px;
  border: 1px solid rgba(112, 242, 167, 0.5);
  border-radius: 8px;
  color: #041d11;
  background: var(--accent);
  text-decoration: none;
  font-weight: 800;
}

.maps-link.disabled {
  pointer-events: none;
  color: rgba(255, 255, 255, 0.58);
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.12);
}

.timeline-panel {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.13);
}

.timeline-header,
.timeline-item-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

#timeline-count {
  min-width: 28px;
  padding: 3px 7px;
  border-radius: 999px;
  color: #041d11;
  background: var(--accent);
  font-size: 0.72rem;
  font-weight: 850;
  text-align: center;
}

.timeline-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.timeline-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.timeline-item {
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-left: 4px solid var(--warning);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.timeline-item.sent {
  border-left-color: var(--accent);
}

.timeline-item.failed {
  border-left-color: var(--danger);
}

.timeline-item-title strong {
  font-size: 0.88rem;
}

.timeline-item-title span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.timeline-meta,
.timeline-details {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.timeline-item a {
  display: inline-block;
  margin-top: 7px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
  text-decoration: none;
}

.error-message {
  margin: 14px 0 0;
  padding: 10px 12px;
  border: 1px solid rgba(255, 117, 111, 0.34);
  border-radius: 8px;
  color: #ffd9d7;
  background: rgba(255, 117, 111, 0.14);
  line-height: 1.4;
}

.mower-marker {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(112, 242, 167, 0.18);
  box-shadow: 0 0 0 0 rgba(112, 242, 167, 0.5);
  animation: pulse 1.8s infinite;
}

.mower-marker::after {
  content: "";
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  background: var(--accent-strong);
  box-shadow: 0 0 20px rgba(200, 255, 99, 0.85);
}

.maplibregl-ctrl-top-right {
  top: 18px;
  right: 18px;
}

.maplibregl-ctrl-group {
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(8, 18, 18, 0.72);
  backdrop-filter: blur(16px);
}

.maplibregl-ctrl button {
  width: 36px;
  height: 36px;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(112, 242, 167, 0.52);
  }
  70% {
    box-shadow: 0 0 0 22px rgba(112, 242, 167, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(112, 242, 167, 0);
  }
}

@media (max-width: 720px) {
  .status-panel {
    top: auto;
    right: max(12px, env(safe-area-inset-right));
    bottom: calc(max(12px, env(safe-area-inset-bottom)) + 154px);
    left: max(12px, env(safe-area-inset-left));
    width: auto;
    max-height: min(42vh, 460px);
    padding: 16px;
  }

  .maplibregl-ctrl-top-right {
    top: 12px;
    right: 12px;
  }

  .map-tools {
    top: max(12px, env(safe-area-inset-top));
    right: calc(max(12px, env(safe-area-inset-right)) + 48px);
    max-width: calc(100vw - 78px);
  }

  .style-switcher {
    overflow-x: auto;
    max-width: calc(100vw - 88px);
  }

  .style-button {
    flex: 0 0 auto;
  }

  h1 {
    font-size: 1.12rem;
  }

  .battery-percent {
    font-size: 3.2rem;
  }

  .history-panel {
    right: max(10px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
    left: max(10px, env(safe-area-inset-left));
    padding: 12px;
    border-radius: 12px;
  }

  .history-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 8px;
    padding-bottom: 12px;
  }

  .history-title {
    display: none;
  }

  .date-field {
    width: auto;
    min-width: 0;
  }

  .date-field input,
  .load-day-button,
  .quiet-button {
    height: 38px;
    font-size: 0.82rem;
  }

  .date-field input {
    padding-left: 9px;
  }

  .calendar-icon {
    top: 10px;
    right: 10px;
  }

  .load-day-button {
    gap: 6px;
    padding: 0 10px;
  }

  .quiet-button {
    padding: 0 10px;
  }

  .download-icon {
    width: 15px;
    height: 17px;
  }

  .history-playback {
    display: block;
    padding-top: 12px;
  }

  .history-rail-group {
    padding-bottom: 28px;
  }

  .time-labels {
    font-size: 0.68rem;
  }

  .tick-row {
    margin-right: 7px;
    margin-left: 7px;
  }

  .daylight-track {
    height: 32px;
    border-radius: 10px;
  }

  .daylight-track input {
    height: 32px;
  }

  .daylight-track output {
    top: 42px;
    min-width: 56px;
    padding: 4px 8px;
    font-size: 0.78rem;
  }

  .daylight-track output::before {
    top: -21px;
    height: 21px;
  }

  .daylight-track output::after {
    top: -32px;
    width: 14px;
    height: 14px;
    border-width: 3px;
  }

  .moon-icon {
    top: 8px;
  }

  .sun-icon {
    top: 8px;
  }

  .sunrise-icon {
    bottom: 8px;
  }

  .history-live {
    display: none;
  }
}

@media (max-width: 390px) {
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .battery-readout {
    align-items: flex-start;
    flex-direction: column;
  }

  .voltage-block {
    text-align: left;
  }
}

.status-panel.tracker-callout {
  width: min(260px, calc(100vw - 24px));
  max-height: none;
  padding: 10px;
  overflow: visible;
  border-radius: 8px;
  box-shadow: 0 14px 42px rgba(0, 0, 0, 0.32);
  transition: opacity 160ms ease, transform 160ms ease;
  will-change: left, top, transform;
}

.status-panel.tracker-callout-hidden {
  pointer-events: none;
  opacity: 0;
}

.status-panel.tracker-callout::after {
  content: "";
  position: absolute;
  left: 50%;
  width: 12px;
  height: 12px;
  background: var(--panel-bg);
  transform: translateX(-50%) rotate(45deg);
}

.status-panel.tracker-callout[data-anchor="above"]::after {
  bottom: -7px;
  border-right: 1px solid var(--panel-border);
  border-bottom: 1px solid var(--panel-border);
}

.status-panel.tracker-callout[data-anchor="below"]::after {
  top: -7px;
  border-left: 1px solid var(--panel-border);
  border-top: 1px solid var(--panel-border);
}

.status-panel.tracker-callout .panel-header {
  align-items: center;
  gap: 8px;
}

.status-panel.tracker-callout .card-toggle {
  order: 3;
}

.status-panel.tracker-callout .eyebrow {
  display: none;
}

.status-panel.tracker-callout h1 {
  max-width: 132px;
  margin: 0;
  overflow: hidden;
  font-size: 0.95rem;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-panel.tracker-callout .status-badge {
  min-width: 66px;
  padding: 5px 7px;
  font-size: 0.66rem;
}

.status-panel.card-collapsed {
  width: auto !important;
  min-width: 178px;
}

.status-panel.card-collapsed .battery-readout,
.status-panel.card-collapsed .last-seen,
.status-panel.card-collapsed .metrics-grid,
.status-panel.card-collapsed .coordinates,
.status-panel.card-collapsed .maps-link,
.status-panel.card-collapsed .timeline-panel,
.status-panel.card-collapsed .error-message {
  display: none;
}

.status-panel.tracker-callout .battery-readout {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  margin-top: 7px;
  padding: 7px 0;
}

.status-panel.tracker-callout .battery-percent {
  font-size: 2.15rem;
}

.status-panel.tracker-callout .voltage-block {
  min-width: 72px;
  text-align: right;
}

.status-panel.tracker-callout .voltage-block p:last-child {
  margin: 2px 0 0;
  font-size: 0.98rem;
}

.status-panel.tracker-callout .last-seen {
  margin-top: 8px;
}

.status-panel.tracker-callout .last-seen p:last-child {
  display: -webkit-box;
  margin-top: 2px;
  overflow: hidden;
  font-size: 0.76rem;
  line-height: 1.25;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.status-panel.tracker-callout .metrics-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
  margin-top: 7px;
}

.status-panel.tracker-callout .metrics-grid div {
  min-height: 36px;
  padding: 5px 6px;
}

.status-panel.tracker-callout .metrics-grid span {
  font-size: 0.62rem;
}

.status-panel.tracker-callout .metrics-grid strong {
  margin-top: 2px;
  font-size: 0.7rem;
}

.status-panel.tracker-callout .metrics-grid div:nth-child(4),
.status-panel.tracker-callout .metrics-grid div:nth-child(5),
.status-panel.tracker-callout .coordinates,
.status-panel.tracker-callout .timeline-panel {
  display: none;
}

.status-panel.tracker-callout .maps-link {
  min-height: 30px;
  margin-top: 7px;
  padding: 0 8px;
  font-size: 0.7rem;
}

.status-panel.tracker-callout .error-message {
  margin-top: 8px;
  padding: 7px 8px;
  font-size: 0.76rem;
}

@media (max-width: 720px) {
  .status-panel.tracker-callout {
    width: min(232px, calc(100vw - 24px));
    padding: 9px;
  }

  .status-panel.tracker-callout h1 {
    max-width: 114px;
    font-size: 0.86rem;
  }

  .status-panel.tracker-callout .status-badge {
    min-width: 58px;
    padding: 4px 6px;
    font-size: 0.6rem;
  }

  .status-panel.tracker-callout .battery-percent {
    font-size: 1.9rem;
  }

  .status-panel.tracker-callout .voltage-block {
    min-width: 64px;
  }

  .status-panel.tracker-callout .voltage-block p:last-child {
    font-size: 0.88rem;
  }

  .status-panel.tracker-callout .last-seen p:last-child {
    font-size: 0.7rem;
  }

  .status-panel.tracker-callout .metrics-grid div {
    min-height: 32px;
    padding: 5px 6px;
  }

  .status-panel.tracker-callout .metrics-grid span {
    font-size: 0.58rem;
  }

  .status-panel.tracker-callout .metrics-grid strong,
  .status-panel.tracker-callout .maps-link {
    font-size: 0.7rem;
  }
}

/* Final map-first restore overrides. Keep this section last. */
.history-panel {
  right: auto;
  bottom: max(12px, env(safe-area-inset-bottom));
  left: max(12px, env(safe-area-inset-left));
  max-width: min(560px, calc(100vw - 24px));
  padding: 8px;
  border-radius: 8px;
}

.history-controls {
  gap: 7px;
  padding-bottom: 0;
  border-bottom: 0;
}

.history-title {
  margin: 0 4px 0 2px;
  font-size: 0.74rem;
}

.day-tiles {
  display: flex;
  gap: 5px;
}

.day-tile {
  display: grid;
  gap: 1px;
  min-width: 54px;
  height: 38px;
  padding: 4px 7px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 7px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
}

.day-tile[aria-pressed="true"] {
  color: #041d11;
  background: var(--accent);
}

.day-tile strong {
  font-size: 0.72rem;
  line-height: 1;
}

.day-tile span {
  font-size: 0.66rem;
  font-weight: 800;
  opacity: 0.78;
}

.load-day-button,
.quiet-button {
  height: 38px;
  padding: 0 10px;
  font-size: 0.82rem;
}

.history-playback {
  display: none;
  grid-template-columns: 1fr auto;
  gap: 14px;
  padding-top: 8px;
}

.history-panel.history-active .history-playback {
  display: grid;
}

.history-panel.history-active {
  max-width: min(680px, calc(100vw - 24px));
}

.history-panel.history-active .history-rail-group {
  padding-bottom: 24px;
}

.history-panel.history-active .time-labels {
  font-size: 0.68rem;
}

.history-panel.history-active .tick-row {
  height: 8px;
}

.history-panel.history-active .daylight-track {
  height: 24px;
  border-radius: 8px;
}

.history-panel.history-active .daylight-track input {
  height: 24px;
}

.history-panel.history-active .daylight-track output {
  top: 32px;
  min-width: 54px;
  padding: 3px 7px;
  font-size: 0.72rem;
}

.status-panel {
  right: auto;
  bottom: auto;
  width: min(392px, calc(100vw - 40px));
}

.status-panel.tracker-callout {
  width: min(238px, calc(100vw - 24px));
  padding: 9px;
  background: rgba(20, 33, 29, 0.84);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.34);
}

.status-panel.tracker-callout h1 {
  max-width: 118px;
  font-size: 0.82rem;
}

.status-panel.tracker-callout .battery-percent {
  font-size: 1.9rem;
}

.status-panel.tracker-callout .voltage-block p:last-child {
  font-size: 0.86rem;
}

.status-panel.tracker-callout .last-seen p:last-child {
  font-size: 0.68rem;
}

@media (max-width: 720px) {
  .history-panel {
    max-width: calc(100vw - 20px);
  }

  .history-title {
    display: none;
  }

  .day-tiles {
    overflow-x: auto;
    min-width: 0;
  }

  .day-tile {
    flex: 0 0 auto;
  }

  .history-panel.history-active .history-playback {
    display: block;
  }

  .status-panel {
    bottom: auto;
  }
}

/* Keep the events timeline detached from the tracker callout. */
.timeline-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 40px;
  margin-top: 8px;
  padding: 0 12px;
  border: 1px solid rgba(112, 242, 167, 0.28);
  border-radius: 8px;
  color: var(--accent);
  background: rgba(112, 242, 167, 0.08);
  font-weight: 850;
  cursor: pointer;
}

.timeline-toggle:hover,
.timeline-toggle[aria-expanded="true"] {
  color: #041d11;
  background: var(--accent);
}

.status-panel.card-collapsed .timeline-toggle {
  display: none;
}

.status-panel.tracker-callout .timeline-toggle {
  min-height: 30px;
  margin-top: 6px;
  padding: 0 8px;
  font-size: 0.7rem;
}

.timeline-panel {
  position: fixed;
  left: 50%;
  right: auto;
  bottom: max(86px, calc(env(safe-area-inset-bottom) + 86px));
  z-index: 4;
  width: min(520px, calc(100vw - 24px));
  max-height: min(42vh, 360px);
  margin: 0;
  margin-top: 0;
  padding: 12px;
  padding-top: 12px;
  overflow: auto;
  border: 1px solid var(--panel-border);
  border-top: 1px solid var(--panel-border);
  border-radius: 8px;
  background: rgba(8, 18, 18, 0.78);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.34);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 160ms ease, transform 160ms ease;
  backdrop-filter: blur(18px) saturate(135%);
}

.timeline-panel.timeline-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

@media (max-width: 720px) {
  .timeline-panel {
    bottom: max(78px, calc(env(safe-area-inset-bottom) + 78px));
    width: calc(100vw - 20px);
    max-height: 38vh;
  }
}

/* Absolute final history playback layout. */
.history-panel {
  left: 50%;
  right: auto;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 5;
  width: min(1280px, calc(100vw - 28px));
  max-width: none;
  max-height: min(60vh, 560px);
  padding: clamp(16px, 2vw, 32px);
  overflow: auto;
  border-radius: 16px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 18px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.history-panel.history-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.history-controls {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(12px, 1.6vw, 22px);
  padding-bottom: clamp(14px, 1.8vw, 24px);
  border-bottom: 0;
}

.history-title {
  display: block;
  margin: 0;
  font-size: clamp(1rem, 1.25vw, 1.35rem);
}

.day-tiles {
  display: flex;
  gap: clamp(8px, 1vw, 14px);
  min-width: 0;
  overflow-x: auto;
  padding: 2px;
  scrollbar-width: thin;
}

.day-tile {
  flex: 0 0 auto;
  min-width: clamp(74px, 7.6vw, 112px);
  height: clamp(54px, 5.4vw, 74px);
  border-radius: 10px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.045);
}

.day-tile[aria-pressed="true"] {
  color: #041d11;
  background: #25d86c;
  box-shadow: 0 0 0 1px rgba(112, 242, 167, 0.42), 0 12px 26px rgba(37, 216, 108, 0.26);
}

.day-tile strong {
  font-size: clamp(1rem, 1.35vw, 1.38rem);
  line-height: 1.05;
}

.day-tile span {
  font-size: clamp(0.74rem, 0.9vw, 0.9rem);
  text-transform: uppercase;
}

.load-day-button {
  display: none;
}

.quiet-button {
  justify-self: end;
  min-width: 118px;
  border-color: rgba(112, 242, 167, 0.45);
  color: var(--accent);
}

.history-playback,
.history-panel.history-active .history-playback {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "rail live"
    "play live";
  gap: 18px 28px;
  padding-top: clamp(18px, 2vw, 30px);
}

.history-rail-group {
  grid-area: rail;
}

.history-live {
  grid-area: live;
}

.history-play-controls {
  grid-area: play;
  display: flex;
  align-items: center;
  gap: 12px;
}

.history-play-button {
  position: relative;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  color: #052114;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(112, 242, 167, 0.24);
}

.history-play-button span {
  position: absolute;
  top: 50%;
  left: 53%;
  width: 0;
  height: 0;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  border-left: 14px solid currentColor;
  transform: translate(-50%, -50%);
}

.history-play-button[aria-pressed="true"] span {
  left: 50%;
  width: 14px;
  height: 18px;
  border: 0;
  border-right: 5px solid currentColor;
  border-left: 5px solid currentColor;
}

.speed-controls {
  display: flex;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.speed-button {
  min-width: 58px;
  height: 36px;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-weight: 850;
  cursor: pointer;
}

.speed-button[aria-pressed="true"] {
  color: var(--accent);
  background: rgba(112, 242, 167, 0.2);
}

.daylight-track {
  isolation: isolate;
}

.daylight-track::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  z-index: 1;
  width: var(--history-progress);
  border-radius: inherit;
  background: rgba(37, 216, 108, 0.92);
  box-shadow: 0 0 24px rgba(37, 216, 108, 0.5);
  pointer-events: none;
}

.moon-icon,
.sun-icon,
.sunrise-icon {
  z-index: 2;
}

.daylight-track input {
  z-index: 4;
}

.daylight-track output {
  z-index: 5;
}

.timeline-panel,
.timeline-panel.timeline-visible {
  display: none;
}

@media (max-width: 720px) {
  .history-panel {
    bottom: max(10px, env(safe-area-inset-bottom));
    width: calc(100vw - 20px);
    max-height: 54vh;
    padding: 14px;
    border-radius: 12px;
  }

  .history-controls {
    grid-template-columns: 1fr auto;
    gap: 10px;
  }

  .history-title {
    grid-column: 1 / -1;
    display: block;
    font-size: 0.9rem;
  }

  .day-tiles {
    grid-column: 1 / 2;
  }

  .quiet-button {
    min-width: 76px;
    height: 38px;
    padding: 0 10px;
    font-size: 0.8rem;
  }

  .day-tile {
    min-width: 66px;
    height: 48px;
  }

  .history-playback,
  .history-panel.history-active .history-playback {
    display: block;
  }

  .history-live {
    display: none;
  }

  .history-play-controls {
    margin-top: 12px;
  }

  .speed-button {
    min-width: 46px;
  }
}

.history-panel.history-active {
  max-width: none;
}

/* Playback range styling: taller bar with white range handles. */
.history-panel {
  --history-range-start: 0%;
  --history-range-width: 0%;
  --history-start-left: 0%;
  --history-end-left: 100%;
}

.history-rail-group {
  padding-top: 28px;
  padding-bottom: 48px;
}

.daylight-track,
.history-panel.history-active .daylight-track {
  height: 56px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 10px;
}

.daylight-track input,
.history-panel.history-active .daylight-track input {
  height: 56px;
}

.daylight-track::after {
  display: none;
}

.history-range-fill {
  position: absolute;
  top: -1px;
  bottom: -1px;
  left: var(--history-range-start);
  z-index: 2;
  width: var(--history-range-width);
  border: 1px solid rgba(255, 255, 255, 0.34);
  background: rgba(37, 216, 108, 0.94);
  box-shadow: 0 0 30px rgba(37, 216, 108, 0.42);
  pointer-events: none;
}

.history-range-handle {
  position: absolute;
  top: -7px;
  z-index: 6;
  width: 32px;
  height: 70px;
  border: 2px solid rgba(255, 255, 255, 0.95);
  border-radius: 9px;
  background: linear-gradient(180deg, #ffffff, #e5e2dc);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.36);
  pointer-events: none;
  transform: translateX(-50%);
}

.history-range-handle::before,
.history-range-handle::after {
  content: "";
  position: absolute;
  top: 25px;
  width: 3px;
  height: 20px;
  border-radius: 999px;
  background: rgba(80, 82, 82, 0.68);
}

.history-range-handle::before {
  left: 11px;
}

.history-range-handle::after {
  right: 11px;
}

.history-range-start {
  left: var(--history-start-left);
}

.history-range-end {
  left: var(--history-end-left);
}

.history-range-label {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  min-width: 58px;
  padding: 6px 9px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  color: var(--text);
  background: rgba(16, 24, 26, 0.9);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.36);
  font-size: 0.82rem;
  font-weight: 850;
  text-align: center;
  transform: translateX(-50%);
}

.history-range-label::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  width: 10px;
  height: 10px;
  border-right: 1px solid rgba(255, 255, 255, 0.22);
  border-bottom: 1px solid rgba(255, 255, 255, 0.22);
  background: inherit;
  transform: translate(-50%, -5px) rotate(45deg);
}

.moon-icon {
  top: 19px;
}

.sun-icon {
  top: 18px;
}

.sunrise-icon {
  bottom: 16px;
}

.daylight-track output,
.history-panel.history-active .daylight-track output {
  top: 68px;
}

.daylight-track output::before {
  top: -38px;
  height: 38px;
}

.daylight-track output::after {
  top: -51px;
}

@media (max-width: 720px) {
  .history-rail-group {
    padding-top: 24px;
    padding-bottom: 42px;
  }

  .daylight-track,
  .history-panel.history-active .daylight-track {
    height: 46px;
  }

  .daylight-track input,
  .history-panel.history-active .daylight-track input {
    height: 46px;
  }

  .history-range-handle {
    top: -6px;
    width: 26px;
    height: 58px;
  }

  .history-range-handle::before,
  .history-range-handle::after {
    top: 21px;
    height: 16px;
  }

  .history-range-handle::before {
    left: 9px;
  }

  .history-range-handle::after {
    right: 9px;
  }

  .history-range-label {
    min-width: 50px;
    padding: 5px 7px;
    font-size: 0.72rem;
  }

  .moon-icon {
    top: 14px;
  }

  .sun-icon {
    top: 13px;
  }

  .sunrise-icon {
    bottom: 13px;
  }

  .daylight-track output,
  .history-panel.history-active .daylight-track output {
    top: 56px;
  }
}

/* Final functional range/log overrides. */
.history-play-controls {
  flex-wrap: wrap;
}

.log-toggle-button {
  height: 36px;
  min-width: 76px;
  padding: 0 14px;
  border: 1px solid rgba(112, 242, 167, 0.36);
  border-radius: 8px;
  color: var(--accent);
  background: rgba(112, 242, 167, 0.08);
  font-weight: 850;
  cursor: pointer;
}

.log-toggle-button[aria-expanded="true"] {
  color: #041d11;
  background: var(--accent);
}

.daylight-track {
  cursor: pointer;
}

.history-range-handle {
  pointer-events: auto;
  cursor: ew-resize;
  touch-action: none;
}

.log-overlay {
  position: fixed;
  inset: 0;
  z-index: 7;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.32);
}

.log-overlay[hidden] {
  display: none;
}

.log-container {
  width: min(980px, calc(100vw - 28px));
  max-height: min(74vh, 620px);
  overflow: hidden;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: rgba(8, 18, 18, 0.9);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.44);
  backdrop-filter: blur(22px) saturate(135%);
}

.log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.13);
}

.log-title {
  font-weight: 850;
}

.log-close {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.log-table-wrap {
  max-height: min(62vh, 540px);
  overflow: auto;
}

.log-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.log-table th,
.log-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  text-align: left;
  white-space: nowrap;
}

.log-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: rgba(8, 18, 18, 0.96);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.log-table tbody tr {
  cursor: pointer;
}

.log-table tbody tr:hover,
.log-table tbody tr:focus {
  background: rgba(112, 242, 167, 0.1);
  outline: none;
}

@media (max-width: 720px) {
  .log-overlay {
    padding: 10px;
  }

  .log-container {
    width: calc(100vw - 20px);
    max-height: 70vh;
  }

  .log-table {
    font-size: 0.78rem;
  }

  .log-table th,
  .log-table td {
    padding: 8px 10px;
  }
}

/* Compact ajatelg mockup pass. Keep this at the end. */
.history-panel {
  bottom: max(24px, env(safe-area-inset-bottom));
  width: min(1120px, calc(100vw - 32px));
  max-height: min(72vh, 460px);
  padding: 22px 24px;
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.1), transparent 42%),
    rgba(7, 19, 18, 0.82);
}

.history-panel.history-expanded {
  width: min(1440px, calc(100vw - 24px));
  max-height: min(82vh, 620px);
}

.history-controls {
  display: grid;
  grid-template-columns: 64px auto minmax(0, 1fr) 64px;
  align-items: center;
  gap: 12px;
  padding-bottom: 18px;
}

.history-title {
  margin: 0 14px;
  color: var(--text);
  font-size: 1.18rem;
  font-weight: 900;
  text-transform: uppercase;
}

.history-nav-button {
  position: relative;
  width: 62px;
  height: 62px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
}

.history-nav-button:disabled {
  cursor: default;
  opacity: 0.38;
}

.history-nav-button span {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 17px;
  height: 17px;
  border-top: 4px solid currentColor;
  border-left: 4px solid currentColor;
}

.history-prev span {
  transform: translate(-35%, -50%) rotate(-45deg);
}

.history-next span {
  transform: translate(-65%, -50%) rotate(135deg);
}

.day-tiles {
  justify-content: center;
  gap: 10px;
  overflow-x: auto;
}

.day-tile {
  min-width: 92px;
  height: 62px;
  border-radius: 10px;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.04);
}

.day-tile strong {
  font-size: 1.12rem;
}

.day-tile span {
  font-size: 0.82rem;
  opacity: 0.82;
}

.day-tile[aria-pressed="true"] {
  background: linear-gradient(180deg, #35f176, #1bc960);
  box-shadow: 0 10px 28px rgba(37, 216, 108, 0.34);
}

.load-day-button,
#live-button {
  display: none;
}

.history-playback,
.history-panel.history-active .history-playback {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "rail rail"
    "play live";
  gap: 18px;
  padding-top: 0;
}

.history-rail-group {
  grid-area: rail;
  padding: 30px 20px 42px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.025);
}

.history-live {
  grid-area: live;
  align-self: center;
  padding-left: 0;
  border-left: 0;
}

.live-view-button {
  height: 52px;
  min-width: 164px;
  justify-content: center;
  border-color: rgba(112, 242, 167, 0.5);
  border-radius: 11px;
  font-size: 1rem;
}

.history-play-controls {
  grid-area: play;
  align-self: center;
  gap: 16px;
}

.history-play-button {
  width: 58px;
  height: 58px;
  box-shadow: 0 14px 34px rgba(112, 242, 167, 0.3);
}

.speed-controls {
  height: 52px;
  border-radius: 11px;
}

.speed-button {
  min-width: 72px;
  height: 52px;
  font-size: 1.05rem;
}

.log-toggle-button {
  position: relative;
  height: 52px;
  min-width: 116px;
  padding: 0 18px 0 42px;
  border-radius: 11px;
  font-size: 1rem;
}

.log-toggle-button::before {
  content: "";
  position: absolute;
  top: 17px;
  left: 18px;
  width: 17px;
  height: 13px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: skewX(-12deg);
}

.log-toggle-button::after {
  content: "";
  position: absolute;
  top: 14px;
  left: 22px;
  width: 19px;
  height: 13px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  transform: rotate(-10deg);
}

.history-fullscreen-button {
  position: relative;
  width: 52px;
  height: 52px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 11px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
}

.history-fullscreen-button span,
.history-fullscreen-button span::before,
.history-fullscreen-button span::after {
  position: absolute;
  width: 18px;
  height: 18px;
  content: "";
}

.history-fullscreen-button span {
  inset: 16px;
  background:
    linear-gradient(currentColor, currentColor) left top / 8px 2px no-repeat,
    linear-gradient(currentColor, currentColor) left top / 2px 8px no-repeat,
    linear-gradient(currentColor, currentColor) right top / 8px 2px no-repeat,
    linear-gradient(currentColor, currentColor) right top / 2px 8px no-repeat,
    linear-gradient(currentColor, currentColor) left bottom / 8px 2px no-repeat,
    linear-gradient(currentColor, currentColor) left bottom / 2px 8px no-repeat,
    linear-gradient(currentColor, currentColor) right bottom / 8px 2px no-repeat,
    linear-gradient(currentColor, currentColor) right bottom / 2px 8px no-repeat;
}

.time-labels {
  margin: 0 10px 18px;
  font-size: 0.92rem;
}

.tick-row {
  height: 12px;
  margin: 0 18px 4px;
}

.daylight-track,
.history-panel.history-active .daylight-track {
  height: 64px;
  border-radius: 13px;
}

.daylight-track input,
.history-panel.history-active .daylight-track input {
  height: 64px;
}

.history-range-handle {
  top: -8px;
  width: 38px;
  height: 80px;
  border-radius: 10px;
}

.history-range-handle::before,
.history-range-handle::after {
  top: 29px;
  height: 22px;
}

.history-range-handle::before {
  left: 14px;
}

.history-range-handle::after {
  right: 14px;
}

.history-range-label,
.daylight-track output {
  border-radius: 9px;
  font-size: 0.86rem;
}

.daylight-track output,
.history-panel.history-active .daylight-track output {
  top: -56px;
}

.daylight-track output::before {
  top: 100%;
  height: 88px;
}

.daylight-track output::after {
  top: calc(100% + 47px);
  width: 22px;
  height: 22px;
  border-color: rgba(255, 255, 255, 0.88);
  background: rgba(37, 216, 108, 0.72);
}

@media (max-width: 760px) {
  .history-panel {
    bottom: max(10px, env(safe-area-inset-bottom));
    width: calc(100vw - 20px);
    max-height: 70vh;
    padding: 14px;
  }

  .history-controls {
    grid-template-columns: 42px auto minmax(0, 1fr) 42px;
    gap: 7px;
    padding-bottom: 12px;
  }

  .history-nav-button {
    width: 42px;
    height: 42px;
    border-radius: 9px;
  }

  .history-title {
    margin: 0 4px;
    font-size: 0.86rem;
  }

  .day-tiles {
    justify-content: flex-start;
  }

  .day-tile {
    min-width: 66px;
    height: 46px;
  }

  .history-playback,
  .history-panel.history-active .history-playback {
    display: block;
  }

  .history-rail-group {
    padding: 24px 10px 36px;
  }

  .daylight-track,
  .history-panel.history-active .daylight-track {
    height: 48px;
  }

  .daylight-track input,
  .history-panel.history-active .daylight-track input {
    height: 48px;
  }

  .history-play-controls {
    margin-top: 12px;
    gap: 8px;
  }

  .history-play-button,
  .history-fullscreen-button {
    width: 44px;
    height: 44px;
  }

  .speed-controls {
    height: 44px;
  }

  .speed-button {
    min-width: 44px;
    height: 44px;
    font-size: 0.86rem;
  }

  .log-toggle-button {
    height: 44px;
    min-width: 86px;
    padding-right: 10px;
    font-size: 0.86rem;
  }

  .history-live {
    display: none;
  }
}

/* Compact v2: shrink the full ajatelg/timeline surface. */
.history-panel {
  bottom: max(14px, env(safe-area-inset-bottom));
  width: min(760px, calc(100vw - 24px));
  max-height: min(58vh, 300px);
  padding: 12px 14px;
  border-radius: 12px;
}

.history-panel.history-expanded {
  width: min(980px, calc(100vw - 20px));
  max-height: min(70vh, 430px);
}

.history-controls {
  grid-template-columns: 38px auto minmax(0, 1fr) 38px;
  gap: 7px;
  padding-bottom: 9px;
}

.history-title {
  margin: 0 8px;
  font-size: 0.78rem;
}

.history-nav-button {
  width: 38px;
  height: 38px;
  border-radius: 8px;
}

.history-nav-button span {
  width: 12px;
  height: 12px;
  border-top-width: 3px;
  border-left-width: 3px;
}

.day-tiles {
  gap: 6px;
}

.day-tile {
  min-width: 58px;
  height: 40px;
  padding: 4px 7px;
  border-radius: 7px;
}

.day-tile strong {
  font-size: 0.78rem;
}

.day-tile span {
  font-size: 0.62rem;
}

.history-playback,
.history-panel.history-active .history-playback {
  gap: 9px;
}

.history-rail-group {
  padding: 20px 12px 28px;
  border-radius: 12px;
}

.time-labels {
  margin: 0 6px 9px;
  font-size: 0.62rem;
}

.tick-row {
  height: 7px;
  margin: 0 12px 3px;
}

.daylight-track,
.history-panel.history-active .daylight-track {
  height: 36px;
  border-radius: 8px;
}

.daylight-track input,
.history-panel.history-active .daylight-track input {
  height: 36px;
}

.history-range-handle {
  top: -5px;
  width: 24px;
  height: 46px;
  border-radius: 7px;
  border-width: 1px;
}

.history-range-handle::before,
.history-range-handle::after {
  top: 16px;
  width: 2px;
  height: 13px;
}

.history-range-handle::before {
  left: 8px;
}

.history-range-handle::after {
  right: 8px;
}

.history-range-label,
.daylight-track output {
  min-width: 44px;
  padding: 4px 6px;
  border-radius: 6px;
  font-size: 0.62rem;
}

.history-range-label {
  bottom: calc(100% + 8px);
}

.daylight-track output,
.history-panel.history-active .daylight-track output {
  top: -39px;
}

.daylight-track output::before {
  height: 57px;
}

.daylight-track output::after {
  top: calc(100% + 30px);
  width: 14px;
  height: 14px;
  border-width: 3px;
}

.moon-icon {
  top: 10px;
  transform: scale(0.72);
}

.sun-icon {
  top: 9px;
  transform: translateX(-50%) scale(0.72);
}

.sunrise-icon {
  bottom: 9px;
  transform: scale(0.72);
  transform-origin: center bottom;
}

.history-play-controls {
  gap: 8px;
}

.history-play-button {
  width: 36px;
  height: 36px;
}

.history-play-button span {
  border-top-width: 7px;
  border-bottom-width: 7px;
  border-left-width: 11px;
}

.history-play-button[aria-pressed="true"] span {
  width: 11px;
  height: 14px;
  border-right-width: 4px;
  border-left-width: 4px;
}

.speed-controls {
  height: 34px;
  border-radius: 8px;
}

.speed-button {
  min-width: 42px;
  height: 34px;
  font-size: 0.78rem;
}

.log-toggle-button {
  height: 34px;
  min-width: 76px;
  padding: 0 10px 0 30px;
  border-radius: 8px;
  font-size: 0.78rem;
}

.log-toggle-button::before {
  top: 11px;
  left: 11px;
  width: 13px;
  height: 10px;
}

.log-toggle-button::after {
  top: 9px;
  left: 14px;
  width: 14px;
  height: 10px;
}

.live-view-button {
  height: 34px;
  min-width: 112px;
  border-radius: 8px;
  font-size: 0.78rem;
}

.eye-icon {
  transform: scale(0.78);
}

.history-fullscreen-button {
  width: 34px;
  height: 34px;
  border-radius: 8px;
}

.history-fullscreen-button span {
  inset: 9px;
}

@media (max-width: 760px) {
  .history-panel {
    bottom: max(8px, env(safe-area-inset-bottom));
    width: calc(100vw - 16px);
    max-height: 46vh;
    padding: 9px;
  }

  .history-controls {
    grid-template-columns: 32px auto minmax(0, 1fr) 32px;
    gap: 5px;
    padding-bottom: 8px;
  }

  .history-title {
    font-size: 0.7rem;
  }

  .history-nav-button {
    width: 32px;
    height: 32px;
  }

  .day-tile {
    min-width: 52px;
    height: 34px;
  }

  .history-rail-group {
    padding: 18px 8px 24px;
  }

  .daylight-track,
  .history-panel.history-active .daylight-track {
    height: 34px;
  }

  .daylight-track input,
  .history-panel.history-active .daylight-track input {
    height: 34px;
  }

  .history-play-controls {
    gap: 6px;
  }

  .speed-button {
    min-width: 34px;
  }

  .log-toggle-button {
    min-width: 64px;
    padding-left: 24px;
  }
}

/* Timeline pointer cleanup: only range handles are draggable. */
.history-panel,
.history-panel * {
  cursor: default;
  user-select: none;
}

.history-panel button,
.history-panel [role="button"] {
  cursor: pointer;
}

.daylight-track,
.daylight-track input,
.daylight-track output,
.history-range-fill,
.moon-icon,
.sun-icon,
.sunrise-icon {
  cursor: default;
}

.daylight-track input {
  pointer-events: none;
}

.history-range-handle {
  cursor: ew-resize;
}

.daylight-track output {
  pointer-events: auto;
  cursor: grab;
  touch-action: none;
}

.daylight-track output:active {
  cursor: grabbing;
}

/* Mobile-only fix: make ajatelg usable without touching desktop. */
@media (max-width: 760px) {
  body:has(.history-panel.history-visible) .status-panel.tracker-callout {
    opacity: 1;
    pointer-events: auto;
  }

  .map-tools {
    top: max(8px, env(safe-area-inset-top));
    right: max(8px, env(safe-area-inset-right));
    max-width: calc(100vw - 16px);
    gap: 4px;
    padding: 4px;
  }

  .tool-button,
  .style-button {
    height: 30px;
    border-radius: 6px;
    font-size: 0.74rem;
  }

  .tool-button {
    width: 30px;
  }

  .style-button {
    padding: 0 9px;
  }

  .history-panel {
    bottom: max(8px, env(safe-area-inset-bottom));
    width: calc(100vw - 16px);
    max-height: 34vh;
    padding: 8px;
    overflow: hidden;
  }

  .history-controls {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr) 30px;
    grid-template-areas:
      "prev title next"
      "days days days";
    gap: 6px;
    padding-bottom: 7px;
  }

  .history-prev {
    grid-area: prev;
  }

  .history-next {
    grid-area: next;
  }

  .history-title {
    grid-area: title;
    margin: 0;
    text-align: center;
    font-size: 0.72rem;
  }

  .history-nav-button {
    width: 30px;
    height: 30px;
  }

  .day-tiles {
    grid-area: days;
    justify-content: flex-start;
    gap: 5px;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .day-tile {
    min-width: 48px;
    height: 32px;
    padding: 3px 6px;
  }

  .day-tile strong {
    font-size: 0.68rem;
  }

  .day-tile span {
    font-size: 0.54rem;
  }

  .history-rail-group {
    padding: 16px 7px 22px;
    border-radius: 10px;
  }

  .time-labels {
    margin-bottom: 7px;
    font-size: 0.58rem;
  }

  .tick-row {
    height: 6px;
    margin-bottom: 2px;
  }

  .daylight-track,
  .history-panel.history-active .daylight-track {
    height: 30px;
  }

  .daylight-track input,
  .history-panel.history-active .daylight-track input {
    height: 30px;
  }

  .history-range-handle {
    top: -4px;
    width: 22px;
    height: 38px;
  }

  .history-range-label,
  .daylight-track output {
    min-width: 38px;
    padding: 3px 5px;
    font-size: 0.56rem;
  }

  .daylight-track output,
  .history-panel.history-active .daylight-track output {
    top: -32px;
  }

  .daylight-track output::before {
    height: 47px;
  }

  .daylight-track output::after {
    top: calc(100% + 24px);
    width: 12px;
    height: 12px;
  }

  .history-play-controls {
    margin-top: 7px;
    gap: 5px;
  }

  .history-play-button,
  .history-fullscreen-button {
    width: 32px;
    height: 32px;
  }

  .speed-controls,
  .log-toggle-button {
    height: 32px;
  }

  .speed-button {
    min-width: 31px;
    height: 32px;
    font-size: 0.68rem;
  }

  .log-toggle-button {
    min-width: 56px;
    padding: 0 8px;
    font-size: 0.68rem;
  }

  .log-toggle-button::before,
  .log-toggle-button::after {
    display: none;
  }
}

/* Settings and alert event overlay overrides must stay last. */
.timeline-panel.alert-events-visible {
  display: block;
  z-index: 8;
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}


/* Mobile map controls fix: crosshair icon + zoom button positioning */
@media (max-width: 760px) {
  .target-icon {
    inset: 6px;
  }

  .target-icon::before {
    left: -3px;
    width: calc(100% + 6px);
  }

  .target-icon::after {
    top: -3px;
    height: calc(100% + 6px);
  }

  .maplibregl-ctrl-top-right {
    top: calc(max(8px, env(safe-area-inset-top)) + 44px);
    right: max(8px, env(safe-area-inset-right));
  }
}


/* Expand/collapse icon toggle on card-toggle button */
.card-toggle {
  display: grid;
  place-items: center;
}

.card-toggle span,
.card-toggle span::before {
  display: none;
}

.card-toggle[aria-expanded="true"] .expand-icon {
  display: none;
}

.card-toggle[aria-expanded="true"] .collapse-icon {
  display: block;
}

.card-toggle[aria-expanded="false"] .expand-icon,
.card-toggle:not([aria-expanded="true"]) .expand-icon {
  display: block;
}

.card-toggle[aria-expanded="false"] .collapse-icon,
.card-toggle:not([aria-expanded="true"]) .collapse-icon {
  display: none;
}
