* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #10161a;
  background: #f4f7f7;
  /* Column layout so #app takes exactly the leftover height. The header
     is not a fixed size (the sign-in form wraps on narrow screens), so
     subtracting a hard-coded header height pushes the map's floating
     controls off the bottom of the screen. */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.hidden { display: none !important; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: #00776e;
  color: #fff;
  flex: 0 0 auto;
}

.error, .topbar { flex-shrink: 0; }

.topbar h1 { font-size: 18px; margin: 0; }

.navlink {
  margin-right: auto;
  margin-left: 16px;
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  background: #00a79d;
  padding: 7px 12px;
  border-radius: 4px;
}
.navlink:hover { background: #00776e; }

#authBox { display: flex; align-items: center; gap: 10px; }

#signInForm { display: flex; gap: 8px; }

#signInForm input {
  padding: 6px 8px;
  border-radius: 4px;
  border: 1px solid #d3dae0;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 4px;
  padding: 7px 12px;
  background: #00a79d;
  color: #fff;
  font-size: 13px;
}

button:hover { background: #00776e; }

#signOutBtn { background: #6b6b6b; }

.error {
  color: #b3261e;
  background: #fdecea;
  margin: 0;
  padding: 8px 20px;
  font-size: 13px;
}

/* Map-first: the map fills the area and every control floats over it, so
   the map keeps the whole screen on a phone. dvh so mobile browser chrome
   doesn't cut off the bottom controls. */
#app {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.panel {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 320px;
  max-height: calc(100% - 24px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #e2e7ec;
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(16, 22, 26, 0.18);
  overflow: hidden;
  z-index: 3;
}

.panelToggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border-radius: 0;
  background: #00776e;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 12px;
}
.panelToggle:hover { background: #005f58; }
.chevron { font-size: 11px; }

.panelBody {
  padding: 14px;
  overflow-y: auto;
}

.panel.collapsed .panelBody { display: none; }

.panel h2 { font-size: 15px; margin: 0 0 10px; }
.panel section { margin-bottom: 26px; }

#routeForm label {
  display: block;
  font-size: 12px;
  color: #5f676e;
  margin-bottom: 10px;
}

#routeForm input {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 7px 8px;
  border-radius: 4px;
  border: 1px solid #d3dae0;
  font-size: 13px;
}

.status { font-size: 12px; color: #5f676e; min-height: 16px; }

.summary {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 10px 0 0;
  padding: 10px;
  background: #edf0f2;
  border-radius: 6px;
}

.summary div { display: flex; justify-content: space-between; font-size: 13px; }
.summary dt { color: #5f676e; }
.summary dd { margin: 0; font-weight: 600; }

.note {
  font-size: 12px;
  color: #9c6d23;
  background: #fff6e0;
  border: 1px solid #f0dca0;
  border-radius: 6px;
  padding: 8px 10px;
  margin-top: 10px;
}

.hint { font-size: 12px; color: #5f676e; margin: 0 0 10px; }

.typeToggle { display: flex; gap: 6px; margin-bottom: 8px; }

.typeBtn {
  flex: 1;
  background: #edf0f2;
  color: #10161a;
}

.typeBtn.active {
  background: #00a79d;
  color: #fff;
}

#pottyForm input,
#flagForm input[type="text"],
#routeRating input[type="text"],
#pottyForm select,
#flagForm select {
  display: block;
  width: 100%;
  margin-bottom: 8px;
  padding: 7px 8px;
  border-radius: 4px;
  border: 1px solid #d3dae0;
  font-size: 13px;
  background: #fff;
}

.btnRow { display: flex; gap: 8px; margin-bottom: 8px; }
.btnRow button { flex: 1; }
#cancelPottyBtn, #cancelFlagBtn { background: #6b6b6b; }

.inlineRow { display: flex; gap: 6px; align-items: center; margin-top: 4px; }
.inlineRow input { flex: 1; margin-top: 0 !important; }
.inlineRow button { flex: 0 0 auto; padding: 7px 10px; }

.fieldLabel {
  display: block;
  font-size: 12px;
  color: #5f676e;
  margin-bottom: 8px;
}
.fieldLabel select, .fieldLabel input[type="range"] { margin-top: 4px; width: 100%; }

.pinLabel {
  font-size: 12px;
  color: #00776e;
  background: #edf0f2;
  border-radius: 4px;
  padding: 6px 8px;
  margin: 0 0 10px;
}

/* Which tap-the-map action is armed. Only one can be active, so these
   read as a segmented control rather than three independent buttons. */
.modeToggle { display: flex; gap: 6px; margin-bottom: 8px; }
.modeBtn {
  flex: 1;
  background: #edf0f2;
  color: #10161a;
  font-size: 12px;
  padding: 7px 6px;
}
.modeBtn.active { background: #00776e; color: #fff; }

.flagKindBtn { flex: 1; background: #edf0f2; color: #10161a; }
.flagKindBtn.active { background: #c1882d; color: #fff; }

.rating {
  margin-top: 12px;
  padding: 10px;
  background: #f4f7f7;
  border: 1px solid #e2e7ec;
  border-radius: 6px;
}
.rating h3 { font-size: 13px; margin: 0 0 8px; }
.stars { display: flex; gap: 6px; margin-bottom: 6px; }
.starBtn {
  flex: 1;
  background: #edf0f2;
  color: #10161a;
  font-weight: 600;
}
.starBtn.active { background: #c1882d; color: #fff; }

.legend { list-style: none; padding: 0; margin: 12px 0 0; font-size: 12px; display: flex; flex-wrap: wrap; gap: 10px 14px; }
.legend li { display: flex; align-items: center; gap: 6px; }

.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.pee { background: #2f80ed; }
.dot.poop { background: #7a4a2b; }
.dot.avoid { background: #c0392b; }
.dot.shade { background: #00a79d; }

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

/* Primary action: log where the walker is standing right now. */
.fab {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 6px 18px rgba(16, 22, 26, 0.3);
}
.fab:disabled { opacity: 0.75; }
.fabIcon { font-size: 17px; }

.mapHint {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  margin: 0;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(16, 22, 26, 0.85);
  color: #fff;
  font-size: 12px;
  max-width: 80%;
  text-align: center;
}

.sheetBackdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 22, 26, 0.35);
  z-index: 8;
}

/* Bottom sheet on phones; a floating card on wider screens. */
.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9;
  max-height: 85%;
  overflow-y: auto;
  padding: 10px 16px 20px;
  background: #fff;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -6px 24px rgba(16, 22, 26, 0.25);
}

.sheetGrip {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: #d3dae0;
  margin: 0 auto 10px;
}

.sheetLocation {
  margin: 0 0 10px;
  font-size: 12px;
  color: #5f676e;
  text-align: center;
}

.sheetActions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 4px 0 8px;
}

/* Big tap targets: these get used one-handed, outdoors, holding a leash. */
.bigBtn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px 6px;
  font-size: 20px;
  line-height: 1;
  border-radius: 10px;
}
.bigBtn span { font-size: 12px; font-weight: 600; }
.bigBtn.pee { background: #2f80ed; }
.bigBtn.pee:hover { background: #2569c4; }
.bigBtn.poop { background: #7a4a2b; }
.bigBtn.poop:hover { background: #613a22; }
.bigBtn.flag { background: #c1882d; }
.bigBtn.flag:hover { background: #a06f22; }

.linkBtn {
  display: block;
  width: 100%;
  background: none;
  color: #5f676e;
  text-decoration: underline;
  padding: 6px;
}
.linkBtn:hover { background: none; color: #10161a; }

.fieldGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fieldGrid label { margin-bottom: 0; }

@media (min-width: 761px) {
  /* Keep the sheet a compact card rather than a full-width bar. */
  .sheet {
    left: auto;
    right: 24px;
    bottom: 88px;
    width: 360px;
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(16, 22, 26, 0.28);
  }
  .sheetGrip { display: none; }
}

@media (max-width: 760px) {
  .topbar { padding: 8px 12px; }
  .topbar h1 { font-size: 16px; }
  #signInForm { flex-wrap: wrap; justify-content: flex-end; }

  .panel {
    top: 8px;
    left: 8px;
    right: 8px;
    width: auto;
    max-height: calc(100% - 16px);
  }
  /* Collapsed, the planner is just its own title bar, leaving the map clear. */
  .panel.collapsed { box-shadow: 0 4px 12px rgba(16, 22, 26, 0.2); }

  .fab {
    right: 12px;
    bottom: 12px;
    padding: 16px 22px;
    font-size: 16px;
  }

  .fieldGrid { grid-template-columns: 1fr; }

  /* Comfortable thumb targets and no iOS zoom-on-focus (needs >= 16px). */
  .sheet input, .sheet select { font-size: 16px; padding: 10px; }
  .bigBtn { padding: 18px 6px; }
}
