/* Page layout: the header, the side panel with its tabs, and the map area.
   Wide screens: the panel is docked on the left (drag its edge to resize, \ or the header button to hide it).
   Under 1100 px it's narrower; under 900 px it becomes a bottom sheet over the map. */

/* ---------- header ---------- */
.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 30;
  height: var(--top-h);
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 0 var(--s3) 0 var(--s4);
  padding-left: max(var(--s4), env(safe-area-inset-left));
  padding-right: max(var(--s3), env(safe-area-inset-right));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
  color: var(--text);
  text-decoration: none;
  border-radius: var(--r);
}
.logo {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-ink);
  --logo-ink: var(--accent);
  box-shadow:
    inset 0 -2px 0 rgba(0, 0, 0, 0.15),
    0 2px 10px rgba(242, 163, 58, 0.25);
}
.logo svg {
  width: 24px;
  height: 24px;
}
.logo.lg {
  width: 56px;
  height: 56px;
  border-radius: 15px;
}
.logo.lg svg {
  width: 38px;
  height: 38px;
}
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.brand-text b {
  font: 700 19px var(--f-cond);
  letter-spacing: 0.02em;
}
.brand-text small {
  font-size: 11.5px;
  color: var(--text-3);
  letter-spacing: 0.02em;
}
.brand {
  width: calc(var(--panel-w) - 72px);
  min-width: 0;
}
.panel-toggle {
  margin-right: var(--s2);
}
body.panel-off .panel-toggle {
  color: var(--accent);
}

.top-acts {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--s1);
}
.savestate {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 11px;
  border-radius: 30px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-2);
  font-size: var(--t-xs);
  font-weight: 550;
}
.savestate:hover {
  background: var(--surface-3);
  color: var(--text);
}
.savestate .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px var(--ok-soft);
}
.savestate[data-state="saving"] .dot {
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  animation: blink 0.9s ease-in-out infinite;
}
.savestate[data-state="error"],
.savestate[data-state="warn"] {
  color: var(--danger);
  border-color: rgba(239, 107, 94, 0.4);
}
.savestate[data-state="error"] .dot,
.savestate[data-state="warn"] .dot {
  background: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}
@keyframes blink {
  50% {
    opacity: 0.35;
  }
}
.only-phone {
  display: none;
}

/* ---------- app: panel + map ---------- */
.app {
  position: fixed;
  inset: var(--top-h) 0 0 0;
  display: grid;
  grid-template-columns: var(--panel-w) minmax(0, 1fr);
}
body.panel-off .app {
  grid-template-columns: 0 minmax(0, 1fr);
}
body.panel-off .panel {
  visibility: hidden;
}
.panel {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.presize {
  position: absolute;
  z-index: 3;
  top: 0;
  bottom: 0;
  right: -4px;
  width: 8px;
  cursor: col-resize;
  touch-action: none;
}
.presize::after {
  content: "";
  position: absolute;
  inset: 0 3px;
  border-radius: 2px;
  transition: background var(--fast);
}
.presize:hover::after,
.presize:focus-visible::after,
body.resizing .presize::after {
  background: var(--accent);
}
body.resizing {
  cursor: col-resize;
  user-select: none;
}
.grab {
  display: none;
}
.tabs {
  flex: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: var(--s1);
  margin: var(--s3) var(--s4) 0;
  padding: var(--s1);
  border-radius: 12px;
  background: var(--field);
  border: 1px solid var(--line);
}
.tabs button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-2);
  font-weight: 600;
  font-size: var(--t-sm);
  transition:
    background var(--fast),
    color var(--fast);
}
.tabs button:hover {
  color: var(--text);
}
.tabs button[aria-selected="true"] {
  background: var(--surface-4);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}
.tabs button[aria-selected="true"] .ic {
  color: var(--accent);
}
.tabs .n {
  min-width: 20px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  font: 600 10.5px/18px var(--f-mono);
  text-align: center;
  background: var(--accent);
  color: var(--accent-ink);
}
.tabs .n:empty {
  display: none;
}
.tabs .n.live {
  background: var(--ok);
  color: #04221a;
}
.phead {
  flex: none;
  padding: var(--s3) var(--s4) 0;
}
.phead:empty {
  display: none;
}
.pbody {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--s3) var(--s4) 28px;
  outline: none;
}
.pfoot {
  flex: none;
  padding: 10px var(--s4);
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface);
}
body.loading .pbody,
body.loading .phead,
body.loading .map-empty,
body.loading .nav {
  visibility: hidden;
}

/* ---------- tablets and narrow windows ---------- */
@media (max-width: 1099px) {
  :root {
    --panel-w: 340px;
  }
  .brand-text small {
    display: none;
  }
}

/* ---------- phones: the panel is a bottom sheet ---------- */
@media (max-width: 899px) {
  :root {
    --top-h: 54px;
  }
  .topbar {
    gap: var(--s2);
    padding: 0 6px 0 12px;
  }
  .brand {
    width: auto;
  }
  .panel-toggle,
  .presize {
    display: none;
  }
  
  .only-phone {
    display: inline-grid;
  }
  .hide-phone {
    display: none;
  }
  .savestate .t {
    display: none;
  }
  .savestate {
    width: 30px;
    padding: 0;
    justify-content: center;
    border: 0;
  }
  
  
  
  .app,
  body.panel-off .app {
    display: block;
  }
  body.panel-off .panel {
    visibility: visible;
  }
  /* the map fills the screen under the sheet: see the phones section in map.css */
  .panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 50%;
    z-index: 20;
    border-right: 0;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    border-top: 1px solid var(--line-2);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
    transition: height 0.26s var(--ease);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .panel.dragging {
    transition: none;
  }
  .grab {
    display: block;
    flex: none;
    height: 22px;
    border: 0;
    background: none;
    touch-action: none;
    cursor: grab;
  }
  .grab span {
    display: block;
    width: 40px;
    height: 5px;
    margin: 0 auto;
    border-radius: 5px;
    background: #3a4950;
  }
  .tabs {
    margin-top: 0;
  }
  .panel[data-sheet="peek"] .phead,
  .panel[data-sheet="peek"] .pbody,
  .panel[data-sheet="peek"] .pfoot {
    display: none;
  }
}

/* the mark carries its own dark tile, so the box around it is just its shape and glow */
.logo {
  background: none;
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(242, 163, 58, 0.35),
    0 2px 12px rgba(242, 163, 58, 0.22);
}
.logo svg,
.logo.lg svg {
  width: 100%;
  height: 100%;
}
