/*
  Compass stylesheet. Plain CSS, no build step.

  Colours and spacing are custom properties; the dark theme follows the
  browser's prefers-color-scheme setting.
*/

:root {
  color-scheme: light dark;

  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-2: #eef1f4;
  --border: #d9dee4;
  --text: #1b2026;
  --muted: #66707c;
  --accent: #0e8f8a;
  --accent-hover: #0b7a76;
  --on-accent: #ffffff;
  --link: #0a6cb5;
  --danger: #b3261e;
  --danger-bg: #fdecea;
  --danger-border: #f3c4bf;
  --selected: #0e8f8a;
  --on-selected: #ffffff;
  --shadow: 0 1px 2px rgba(16, 24, 32, 0.06), 0 4px 16px rgba(16, 24, 32, 0.08);

  /* Read by graph.js */
  --chart-grid: rgba(27, 32, 38, 0.1);
  --chart-battery: #2a78d6;
  --chart-speed: #8b939d;
  --chart-band-charging: rgba(72, 176, 92, 0.2);
  --chart-band-full: rgba(42, 120, 214, 0.16);
  --chart-band-unplugged: rgba(214, 90, 70, 0.16);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 40px;
  --radius: 10px;
  --radius-sm: 6px;
  --header-h: 52px;
  --graph-h: 220px;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101214;
    --surface: #1a1d21;
    --surface-2: #23272c;
    --border: #2f343a;
    --text: #e7e9ec;
    --muted: #98a1ab;
    --accent: #2cc7b5;
    --accent-hover: #4ad6c6;
    --on-accent: #04211e;
    --link: #62b5f3;
    --danger: #ff8a80;
    --danger-bg: #3a1917;
    --danger-border: #6b2b27;
    --selected: #2cc7b5;
    --on-selected: #04211e;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 20px rgba(0, 0, 0, 0.35);

    --chart-grid: rgba(231, 233, 236, 0.1);
    --chart-battery: #4c9ff0;
    --chart-speed: #8a929c;
    --chart-band-charging: rgba(88, 196, 110, 0.16);
    --chart-band-full: rgba(76, 159, 240, 0.14);
    --chart-band-unplugged: rgba(240, 110, 90, 0.14);
  }
}

/* Base */

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  /* Keeps the centred header in the same place on pages with and without a scrollbar */
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3 {
  margin: 0 0 var(--space-3);
  line-height: 1.25;
  font-weight: 600;
}
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

p {
  margin: 0 0 var(--space-3);
}

a {
  color: var(--link);
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--surface-2);
  border-radius: 4px;
  padding: 1px 5px;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

/* Page header and navigation */

.site-header {
  position: sticky;
  top: 0;
  z-index: 1100;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.site-header .in {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  height: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-4);
}
.site-header a,
.site-header summary {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.site-header a:hover,
.site-header summary:hover {
  background: var(--surface-2);
}
/* Marked without a change of weight, which would nudge the links after it */
.site-header .item.current {
  box-shadow: inset 0 -2px 0 var(--accent);
  border-radius: 0;
}
.site-header .brand {
  font-weight: 600;
  padding-left: 0;
  margin-right: var(--space-2);
}
.site-header .brand:hover {
  background: none;
}
.site-header .logo {
  width: 28px;
  height: 28px;
}
.site-header .spacer {
  flex: 1;
}

/* The logo is a black SVG */
@media (prefers-color-scheme: dark) {
  img.logo, .logo img {
    filter: invert(1);
  }
}

/* Dropdown menu built on <details>, no script needed */
.menu {
  position: relative;
  min-width: 0;
}
.menu summary {
  cursor: pointer;
  list-style: none;
  color: var(--muted);
}
.menu summary::-webkit-details-marker {
  display: none;
}
.menu summary .label {
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 40vw;
}
.menu .icon {
  flex: none;
  transition: transform 0.15s;
}
.menu[open] .icon {
  transform: rotate(180deg);
}
.menu .menu-items {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 160px;
  padding: var(--space-1);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}

.icon {
  width: 1em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Page container */

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: var(--space-5) var(--space-4) var(--space-6);
}
.page.wide {
  max-width: 1200px;
}
.page > h2 {
  margin-top: var(--space-5);
}
.page > h2:first-child {
  margin-top: 0;
}

/* Cards, grid and stat tiles */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}
.card > :last-child {
  margin-bottom: 0;
}
.card-title {
  margin: 0 0 var(--space-3);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}
.grid > .card,
.grid > .stat-tile {
  margin-bottom: 0;
}
.grid .span-2 {
  grid-column: span 2;
}
@media (max-width: 480px) {
  .grid .span-2 {
    grid-column: auto;
  }
}

.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  min-width: 0;
}
.stat-tile .stat-label {
  font-size: 0.8rem;
  color: var(--muted);
}
.stat-tile .stat-value {
  font-size: 1.9rem;
  font-weight: 600;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.stat-tile .stat-unit {
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--muted);
  margin-left: 2px;
}
.stat-tile .stat-note {
  font-size: 0.8rem;
  color: var(--muted);
}
.stat-tile.accent .stat-value {
  color: var(--accent);
}

/* Buttons */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  position: relative;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  line-height: 1.4;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.button:hover {
  border-color: var(--muted);
}
.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
.button.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.button.loading {
  color: transparent;
  pointer-events: none;
}
.button.loading::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border: 2px solid var(--muted);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.button.primary.loading::after {
  border-color: var(--on-accent);
  border-top-color: transparent;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Forms */

input[type="search"],
input[type="text"],
input[type="url"],
input[type="number"],
input:not([type]),
select,
textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  line-height: 1.4;
}
input[readonly] {
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: 0.9em;
}
input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 0.8;
}
textarea {
  min-height: 6em;
  resize: vertical;
}

.field {
  margin-bottom: var(--space-3);
}
.field label {
  display: block;
  margin-bottom: var(--space-1);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}
.field label a {
  font-weight: 400;
}

/* A text field with a button attached to it */
.input-group {
  display: flex;
}
.input-group input {
  flex: 1;
  min-width: 0;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  border-right: 0;
}
.input-group .button {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

/* Fields side by side */
.fields {
  display: flex;
  gap: var(--space-2);
}
.fields > input,
.fields > select,
.fields > .field {
  flex: 1;
  min-width: 0;
  margin: 0;
}

/* Tables */

.table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
.table th,
.table td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.table th {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}
.table tr:last-child td {
  border-bottom: 0;
}
.table .num {
  text-align: right;
}
.table-scroll {
  overflow-x: auto;
}

/* Alerts */

.alert,
.error {
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.alert.error,
.error {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: var(--danger-border);
}

/* Sign-in and message pages */

.splash {
  max-width: 420px;
  margin: 12vh auto 0;
  padding: 0 var(--space-4);
  text-align: center;
}
.splash .logo {
  width: 160px;
  margin: 0 auto var(--space-5);
}
.splash .logo img {
  display: block;
  width: 100%;
  height: auto;
}
.splash .login {
  max-width: 340px;
  margin: 0 auto;
}

/* Dashboard and settings lists */

.databases,
.users {
  list-style: none;
  margin: 0;
  padding: 0;
}
.databases .db a {
  display: block;
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 500;
  text-decoration: none;
}
.databases .db a:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.databases .new {
  margin-top: var(--space-4);
}

.users li {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) 0;
  overflow-wrap: anywhere;
}
.users li.new {
  display: block;
  margin-top: var(--space-2);
}
.users .remove-user {
  flex: none;
  order: 2;
  width: 24px;
  height: 24px;
  line-height: 22px;
  text-align: center;
  border-radius: 50%;
  color: var(--muted);
  font-size: 18px;
  text-decoration: none;
}
.users .remove-user:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

/* Map page */

body.map-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}
.map-page .site-header {
  flex: none;
}
.map-stage {
  position: relative;
  flex: 1;
  min-height: 0;
}
#map {
  height: 100%;
  background: var(--surface-2);
}

#daterange,
#calendar {
  position: absolute;
  z-index: 1000;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
#daterange {
  top: 10px;
  left: 54px;
  width: min(660px, calc(100% - 360px));
}
#daterange .in {
  padding: var(--space-2);
}
#daterange .fields + .fields,
#daterange #trip-create-form {
  margin-top: var(--space-2);
}
#daterange #trip-create-form select {
  flex: 0 1 140px;
}

#calendar {
  top: 10px;
  right: 10px;
  width: 280px;
  max-height: calc(100% - 34px);
  overflow-y: auto;
  font-size: 13px;
}
.cal-bar,
.cal-nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1);
}
.cal-step,
#cal-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  min-height: 32px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.cal-step {
  flex: none;
  width: 32px;
  font-size: 18px;
}
#cal-toggle {
  flex: 1;
  min-width: 0;
  font-weight: 600;
}
#cal-toggle .icon {
  flex: none;
  color: var(--muted);
  transition: transform 0.15s;
}
#cal-toggle[aria-expanded="true"] .icon {
  transform: rotate(180deg);
}
.cal-step:hover:not(:disabled),
#cal-toggle:hover {
  background: var(--surface-2);
}
.cal-step:disabled {
  color: var(--muted);
  opacity: 0.4;
  cursor: default;
}
.cal-step:focus-visible,
#cal-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
#cal-panel {
  padding: 0 var(--space-2) var(--space-2);
  border-top: 1px solid var(--border);
}
.cal-nav {
  padding: var(--space-2) 0;
}
.cal-nav select {
  flex: 1 1 0;
  min-width: 0;
  padding: 4px 6px;
}
/* The year only needs four digits; the month gets the rest, enough for "September" */
.cal-nav #cal-year {
  flex: 0 0 70px;
}
.cal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-2);
}
.cal-legend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--muted);
  font-size: 11px;
}
.cal-legend i {
  width: 11px;
  height: 11px;
  border-radius: 3px;
}

table.calendar {
  width: 100%;
  border-collapse: separate;
  border-spacing: 2px;
  table-layout: fixed;
  line-height: 28px;
  font-variant-numeric: tabular-nums;
}
.calendar th {
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
}
.calendar th,
.calendar td {
  padding: 0;
  text-align: center;
}
.calendar td.future {
  color: var(--muted);
  opacity: 0.5;
}
.calendar td a {
  display: block;
  position: relative;
  border-radius: 5px;
  color: var(--text);
  text-decoration: none;
}
/* Shading by distance travelled that day */
.calendar a.lv1, .cal-legend .lv1 { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.calendar a.lv2, .cal-legend .lv2 { background: color-mix(in srgb, var(--accent) 26%, transparent); }
.calendar a.lv3, .cal-legend .lv3 { background: color-mix(in srgb, var(--accent) 46%, transparent); }
.calendar a.lv4, .cal-legend .lv4 { background: color-mix(in srgb, var(--accent) 70%, transparent); }
.calendar a.lv5, .cal-legend .lv5 { background: var(--accent); }
.calendar a.lv5 { color: var(--on-accent); }
/* A day with a flight */
.calendar a.flight::after,
.cal-legend .flight::before {
  content: "";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}
.cal-legend .flight {
  position: relative;
  margin-left: var(--space-2);
  padding-left: 9px;
}
.cal-legend .flight::before {
  top: 50%;
  left: 0;
  right: auto;
  margin-top: -2px;
}
.calendar td a.today {
  font-weight: 700;
  text-decoration: underline;
}
.calendar td a:hover {
  box-shadow: inset 0 0 0 2px var(--muted);
}
.calendar td a.selected {
  box-shadow: inset 0 0 0 2px var(--text);
  font-weight: 700;
}

#graphs {
  flex: none;
  position: relative;
  height: var(--graph-h);
  padding: var(--space-2) var(--space-3);
  background: var(--surface);
  border-top: 1px solid var(--border);
}
#battery-chart {
  position: relative;
  width: 100%;
  height: 100%;
}
#chart-reset-zoom {
  position: absolute;
  top: 28px;
  right: 70px;
  padding: 2px 10px;
  font-size: 12px;
}

/* Leaflet controls in the page's theme (the vendored leaflet.css is untouched) */
.leaflet-container {
  font-family: var(--font);
}
.leaflet-bar a,
.leaflet-bar a:hover {
  background-color: var(--surface);
  color: var(--text);
  border-bottom-color: var(--border);
}
.leaflet-bar a:hover {
  background-color: var(--surface-2);
}
.leaflet-touch .leaflet-bar,
.leaflet-bar {
  border-color: var(--border);
}
.leaflet-container .leaflet-control-attribution {
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  color: var(--muted);
}
.leaflet-container .leaflet-control-attribution a {
  color: var(--link);
}

/* Share page: nothing but the map */
html.full, .share-page {
  height: 100%;
}
.share-page #map {
  height: 100%;
}

.message {
  margin-top: 3em;
  padding: 0 var(--space-4);
  text-align: center;
}

/* Phone width */

@media (max-width: 700px) {
  .site-header .in {
    padding: 0 var(--space-3);
  }
  .site-header a,
  .site-header summary {
    padding: var(--space-2);
  }
  /* Room for the menu: the logo stands for the name, the address is cut short */
  .site-header .brand span {
    display: none;
  }
  .site-header .in {
    gap: 0;
  }
  .site-header .menu {
    min-width: 0;
  }
  .site-header .menu .label {
    max-width: 22vw;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}
@media (max-width: 420px) {
  .site-header .menu .label {
    display: none;
  }
  .site-header .in {
    padding: 0 var(--space-2);
  }
  .site-header a,
  .site-header summary {
    padding: var(--space-2) 6px;
    font-size: 14px;
  }
}
@media (max-width: 700px) {

  /* The map page becomes one scrolling column:
     date and calendar, map, graph, range form */
  body.map-page {
    height: auto;
  }
  .map-stage {
    display: contents;
  }
  #calendar { order: 1; }
  #map { order: 2; flex: none; }
  /* Taller, the legend wraps over several lines at this width */
  #graphs { order: 3; height: 300px; }
  #daterange { order: 4; }
  #daterange,
  #calendar {
    position: static;
    width: auto;
    border-radius: 0;
    border-width: 0 0 1px;
    box-shadow: none;
  }
  #map {
    height: 58vh;
    min-height: 300px;
  }
  /* The date stays in reach while the page scrolls */
  #calendar {
    position: sticky;
    top: var(--header-h);
    max-height: calc(100dvh - var(--header-h));
    font-size: 15px;
  }
  .cal-step,
  #cal-toggle {
    min-height: 44px;
  }
  .cal-step {
    width: 44px;
  }
  #cal-panel {
    padding: 0 var(--space-3) var(--space-3);
  }
  table.calendar {
    max-width: 420px;
    margin: 0 auto;
    line-height: 40px;
  }
  .cal-nav select {
    padding: 9px 8px;
  }
  #daterange {
    border-width: 1px 0 0;
  }
  .fields {
    flex-wrap: wrap;
  }
  #daterange .fields > input {
    flex: 1 1 40%;
  }
  #daterange .fields > #timezone {
    flex: 1 1 50%;
  }
}

/* Stats pages */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.small {
  font-size: 0.8rem;
}
.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.tag {
  display: inline-block;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.7rem;
  vertical-align: 1px;
}
.button.small {
  padding: 2px 9px;
}

.stats-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}
.stats-head h2 {
  margin: 0;
}
.stats-head select {
  width: auto;
}
.stats .grid {
  margin-bottom: var(--space-4);
}
.stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  align-items: stretch;
}
.stats-row > .card {
  min-width: 0;
}
.stats-row > .grow {
  flex: 1 1 520px;
}
.stats-row > .half {
  flex: 1 1 420px;
}
.card-title .muted {
  font-weight: 400;
  font-size: 0.85rem;
  margin-left: var(--space-2);
}

:root {
  --heat-0: #e3e7ec;
  --heat-1: #b5e3df;
  --heat-2: #74cdc6;
  --heat-3: #2fb1a9;
  --heat-4: #0e8f8a;
  /* Hexagons on the world map: a stronger ramp, they are small and sit on grey */
  --hex-1: #6fcbc4;
  --hex-2: #2aa9a1;
  --hex-3: #0e807b;
  --hex-4: #07504d;
}
@media (prefers-color-scheme: dark) {
  :root {
    --heat-0: #262b31;
    --heat-1: #154743;
    --heat-2: #1c6f69;
    --heat-3: #25a096;
    --heat-4: #3fd6c9;
    --hex-1: #1f837c;
    --hex-2: #2bb3a8;
    --hex-3: #5fe0d4;
    --hex-4: #c4f7f1;
  }
}
.heatmap-scroll {
  overflow-x: auto;
  padding-bottom: var(--space-2);
}
.heatmap {
  display: block;
  width: 100%;
  min-width: 620px;
  max-width: 980px;
  height: auto;
}
.heatmap-label {
  font-size: 9px;
  fill: var(--muted);
}
.heat-0 { fill: var(--heat-0); }
.heat-1 { fill: var(--heat-1); }
.heat-2 { fill: var(--heat-2); }
.heat-3 { fill: var(--heat-3); }
.heat-4 { fill: var(--heat-4); }
.heatmap a:hover rect,
.heatmap a:focus rect {
  stroke: var(--text);
  stroke-width: 1;
}
.heatmap-legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  font-size: 0.75rem;
}

.streaks {
  flex: 0 1 220px;
  text-align: center;
}
.streaks hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: var(--space-4) 0;
}
.streak-number {
  font-size: 2.4rem;
  font-weight: 600;
  line-height: 1.1;
  color: var(--accent);
}
.streak-longest {
  font-size: 1.3rem;
  font-weight: 600;
}

.compare {
  margin-bottom: var(--space-4);
}
.compare-head {
  display: flex;
  justify-content: space-between;
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 2px;
}
.compare-head .muted {
  font-weight: 400;
}
.compare-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}
.compare-year {
  width: 2.6em;
  color: var(--muted);
}
.compare-value {
  width: 7.5em;
  text-align: right;
}
.track {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.track .fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}
.track .fill.previous {
  background: var(--muted);
  opacity: 0.55;
}

#digest .card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.digest-nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}
.digest-nav select {
  width: auto;
  padding: 2px 6px;
}
.digest-numbers {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
  text-align: center;
  margin-bottom: var(--space-4);
}
.digest-numbers strong {
  display: block;
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
}
.digest-numbers .muted {
  font-size: 0.75rem;
}
.small-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: var(--space-3) 0 var(--space-2);
}
.chart-box {
  position: relative;
  height: 150px;
}
.plain-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.plain-list li {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
}
.plain-list li:last-child {
  border-bottom: 0;
}
.plain-list.ranked {
  counter-reset: rank;
}
.plain-list.ranked li > span:first-child::before {
  counter-increment: rank;
  content: counter(rank) ".";
  display: inline-block;
  width: 1.8em;
  color: var(--muted);
}
.first-visits {
  max-height: 320px;
  overflow-y: auto;
}
.card-title.with-tabs {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.tabs {
  display: inline-flex;
  padding: 2px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  letter-spacing: 0;
  text-transform: none;
}
.tabs button {
  padding: 3px 10px;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
.tabs button[aria-selected="true"],
.tabs button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(16, 24, 32, 0.15);
}
.tabs button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.tabs .count {
  margin-left: 2px;
  font-weight: 400;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.attribution {
  margin-top: var(--space-4);
}

/* World map */

.world-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  margin-bottom: var(--space-3);
}
.world-bar .tabs {
  font-size: 0.85rem;
}
.world-legend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: auto;
}
.world-legend i {
  width: 11px;
  height: 11px;
  border-radius: 3px;
}
.world-legend .hex-1 { background: var(--hex-1); }
.world-legend .hex-2 { background: var(--hex-2); }
.world-legend .hex-3 { background: var(--hex-3); }
.world-legend .hex-4 { background: var(--hex-4); }
.world-map {
  height: min(62vh, 560px);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: var(--space-4);
}
.world-map.leaflet-container {
  background: var(--surface);
}
.world-embed {
  margin: 0;
  background: var(--surface);
}
.world-embed .world-map {
  height: 100vh;
  border: 0;
  border-radius: 0;
  margin: 0;
}
.world-summary {
  position: absolute;
  left: var(--space-3);
  bottom: var(--space-3);
  z-index: 500;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.85rem;
}
.world-list tr {
  cursor: default;
}
.world-list tr.highlight td {
  background: var(--surface-2);
}
.embed-code {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

/* Sharing */

.share-status {
  position: absolute;
  left: 50%;
  bottom: var(--space-4);
  transform: translateX(-50%);
  z-index: 800;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  max-width: calc(100% - 2 * var(--space-4));
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  white-space: nowrap;
}
.share-status #share-speed:empty {
  display: none;
}
.share-status #share-speed {
  color: var(--muted);
}
.share-links {
  list-style: none;
  margin: 0;
  padding: 0;
}
.share-links li {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
}
.share-links li:last-child {
  border-bottom: 0;
}
.share-links li.ended {
  opacity: 0.6;
}
.share-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.share-info input {
  margin-top: var(--space-2);
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

/* Places (geofences) */

.places-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 1fr);
  gap: var(--space-4);
  align-items: start;
}
.places-single {
  max-width: 720px;
}
.places-map {
  position: sticky;
  top: var(--space-4);
  margin-bottom: var(--space-4);
}
#places-map {
  height: min(70vh, 620px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  /* Leaflet's panes use z-indexes up to 1000; keep them under the menu */
  isolation: isolate;
}
.places-map p {
  margin: var(--space-2) 0 0;
}
@media (max-width: 860px) {
  .places-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .places-map {
    position: static;
  }
  #places-map {
    height: 50vh;
  }
}
.places .card h3 {
  margin-top: 0;
}
.places .card-title.with-tabs {
  flex-wrap: wrap;
}
.places .tabs button {
  white-space: nowrap;
}
.places form > .field,
.places form > .fields {
  margin-bottom: var(--space-3);
}
.places .field.narrow {
  flex: 0 0 9.5em;
}
.places textarea {
  font-family: var(--font-mono);
  font-size: 0.8rem;
}
.places input[type="file"] {
  margin-top: var(--space-2);
  font-size: 0.85rem;
}
.hook-options {
  align-items: flex-end;
  flex-wrap: wrap;
}
.field.checks {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.field.checks label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  font-weight: 400;
  color: var(--text);
}
.field.checks input {
  width: auto;
}
.place-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.place-list li {
  border-bottom: 1px solid var(--border);
}
.place-list li:last-child {
  border-bottom: 0;
}
.place-list summary,
.place-list > li > a {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-3) 0;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  list-style: none;
}
.place-list summary::-webkit-details-marker {
  display: none;
}
.place-list summary:focus-visible,
.place-list > li > a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.place-list .place-name {
  font-weight: 600;
}
.place-list > li > a:hover .place-name {
  color: var(--accent);
}
.place-list > li > a .place-name::after {
  content: "›";
  float: right;
  font-weight: 400;
  color: var(--muted);
}
.hook-list summary .place-name::after {
  content: "Edit";
  float: right;
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--accent);
}
.hook-list details[open] summary .place-name::after {
  content: "Close";
}
.hook-list .hook-url {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.place-list details form {
  padding-bottom: var(--space-3);
}
.add-hook {
  margin-top: var(--space-3);
}
.add-hook > summary {
  display: inline-block;
  list-style: none;
}
.add-hook > summary::-webkit-details-marker {
  display: none;
}
.add-hook[open] > summary {
  display: none;
}
.places .back {
  margin: 0 0 var(--space-2);
  font-size: 0.9rem;
}
.places > h2.place-title .muted {
  font-size: 0.9rem;
  font-weight: 400;
}
.place-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.button.danger {
  margin-left: auto;
  color: var(--danger);
}
.button.danger:hover {
  background: var(--danger-bg);
  border-color: var(--danger-border);
}
.place-events .bad {
  color: var(--danger);
}
.place-events td {
  vertical-align: top;
}
.place-events .day,
.place-events .time,
.place-events .stayed {
  white-space: nowrap;
}
.place-events .day {
  font-weight: 600;
}
/* A stronger line where a new day begins */
.place-events tbody tr.new-day:not(:first-child) td {
  border-top: 2px solid var(--border);
}
.place-events .event-kind {
  white-space: nowrap;
}
.place-events .event-kind::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  border: 2px solid var(--muted);
  box-sizing: border-box;
}
.place-events .kind-enter::before {
  background: var(--accent);
  border-color: var(--accent);
}
.place-events .kind-cross::before {
  border-style: dotted;
}
.place-events .kind-change::before {
  border-radius: 2px;
  background: var(--muted);
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
details.card > summary {
  cursor: pointer;
}
details.card > summary h3 {
  display: inline;
  margin: 0;
}
details.card[open] > summary {
  margin-bottom: var(--space-3);
}
pre.code {
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  overflow-x: auto;
}
/* The two handles of a circle being edited */
.place-handle {
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
  cursor: move;
}
.place-handle.edge {
  background: #fff;
  border-color: var(--accent);
  cursor: ew-resize;
}

/* Searching for a place above the Places map. The "searching" note and the
   results float over the map, so nothing on the page moves when they appear. */
.place-search {
  position: relative;
  margin-bottom: var(--space-2);
}
.place-search p,
.place-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 10;
  margin: var(--space-1) 0 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: 0 6px 20px rgba(16, 24, 32, 0.18);
}
.place-search p {
  padding: var(--space-2) var(--space-3);
}
.place-results {
  list-style: none;
  padding: 0;
  max-height: 320px;
  overflow-y: auto;
}
.place-results li + li {
  border-top: 1px solid var(--border);
}
.place-results button {
  display: flex;
  flex-direction: column;
  gap: 1px;
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.place-results button:hover,
.place-results button:focus-visible {
  background: var(--surface-2);
  outline: none;
}

/* Suggested places */
.suggested-link {
  margin: var(--space-3) 0 0;
}
.places .stats-head h2 {
  margin: 0;
}
.suggestions {
  list-style: none;
  margin: 0;
  padding: 0;
}
.suggestion {
  cursor: pointer;
}
.suggestion.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.suggestion-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.suggestion-number,
.suggestion-pin {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
}
.suggestion-pin {
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}
.suggestion .badge {
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 0.8rem;
  font-weight: 600;
}
.suggestion .badge.kind-home,
.suggestion .badge.kind-work {
  background: var(--accent);
  color: #fff;
}
.suggestion-why {
  margin: 0 0 var(--space-3);
}
.button.dismiss {
  margin-left: auto;
}
.dismissed-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) 0;
}
.dismissed-list li > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
