:root {
  --bg: #16181c;
  --card: #1f2226;
  --card-2: #26292e;
  --text: #edeeeb;
  --text-dim: #8b9096;
  --text-faint: #5b5f63;
  --amber: #e8a33d;
  --teal: #4fa88f;
  --coral: #d9634a;
  --green: #54b56a;
  --red: #e04a4a;
  --border: #2c3036;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}

button {
  font-family: inherit;
}

/* --- Wordmark --- */
.wordmark {
  font-family: "JetBrains Mono", monospace;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  letter-spacing: -0.02em;
}
.wordmark .tap {
  width: 0.62em;
  height: 0.62em;
  margin-right: 0.14em;
  flex-shrink: 0;
}
.wordmark.xl {
  font-size: 32px;
}
.wordmark.lg {
  font-size: 22px;
}
.wordmark.sm {
  font-size: 15px;
}

/* --- Auth / lock screens --- */
.lock-wrap {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 28px;
  text-align: center;
}
.lock-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: rgba(232, 163, 61, 0.14);
  border: 1px solid rgba(232, 163, 61, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
}
.lock-icon svg {
  width: 26px;
  height: 26px;
}
.lock-title {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 6px;
}
.lock-sub {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 28px;
  line-height: 1.5;
}
.lock-input {
  width: 100%;
  padding: 14px 16px;
  background: var(--card);
  border: 0.5px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
  margin-bottom: 14px;
}
.lock-input::placeholder {
  color: var(--text-dim);
}
.lock-btn {
  width: 100%;
  padding: 14px;
  background: var(--amber);
  color: #241a05;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.lock-btn:disabled {
  opacity: 0.6;
  cursor: default;
}
.lock-btn.teal {
  background: var(--teal);
  color: #0c2c24;
}
.lock-btn.secondary {
  background: transparent;
  color: var(--text);
  border: 0.5px solid var(--border);
}
.lock-btn + .lock-btn {
  margin-top: 10px;
}
.lock-foot {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 18px;
  line-height: 1.5;
}
.lock-link {
  color: var(--amber);
  cursor: pointer;
  background: none;
  border: none;
  font-size: inherit;
  font-family: inherit;
}
.lock-error {
  color: var(--red);
  font-size: 12px;
  margin: -8px 0 14px;
}
.otp-boxes {
  display: flex;
  gap: 8px;
  margin-bottom: 22px;
  justify-content: center;
}
.otp-box {
  width: 42px;
  height: 52px;
  background: var(--card);
  border: 0.5px solid var(--border);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "JetBrains Mono", monospace;
  font-size: 20px;
  font-weight: 500;
}
.otp-hidden-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

/* --- Track screen --- */
.track-screen {
  position: absolute;
  inset: 0;
}
.mapfull {
  position: absolute;
  inset: 0;
  background: #1a1d21;
}
#map {
  width: 100%;
  height: 100%;
}
.track-overlay-top {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: 220px;
  z-index: 400;
  background: rgba(31, 34, 38, 0.88);
  backdrop-filter: blur(6px);
  border-radius: 14px;
  padding: 12px 0 8px;
  border: 0.5px solid var(--border);
  text-align: center;
}
.track-overlay-top.recording {
  padding: 12px 16px 10px;
}
.sync {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--teal);
  justify-content: center;
  margin-bottom: 6px;
}
.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--teal);
}
.dot.rec {
  background: var(--coral);
}
.k {
  font-size: 15px;
  color: var(--text);
  font-weight: 700;
  letter-spacing: 0.02em;
  opacity: 0.85;
}
.v {
  font-family: "JetBrains Mono", monospace;
  font-size: 28px;
  font-weight: 500;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.v2 {
  font-family: "JetBrains Mono", monospace;
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 2px;
}
.stat-carousel {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.stat-carousel::-webkit-scrollbar {
  display: none;
}
.stat-slide {
  flex: 0 0 100%;
  scroll-snap-align: center;
  padding: 0 16px;
}
.dots {
  display: flex;
  justify-content: center;
  gap: 5px;
  margin-top: 8px;
}
.dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-faint);
}
.dots span.active {
  background: var(--amber);
}
.track-btn-wrap {
  position: absolute;
  bottom: calc(20px + env(safe-area-inset-bottom));
  right: 18px;
  z-index: 400;
}
.bigbtn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}
.bigbtn:active {
  transform: scale(0.92);
}
.bigbtn svg {
  width: 21px;
  height: 21px;
}
.bigbtn.start {
  background: linear-gradient(160deg, #3ddc84, #16a34a);
  color: #ffffff;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.35) inset,
    0 -10px 16px rgba(0, 0, 0, 0.16) inset,
    0 10px 22px -6px rgba(22, 163, 74, 0.55),
    0 3px 8px rgba(0, 0, 0, 0.3);
}
.bigbtn.stop {
  background: linear-gradient(160deg, #f0645a, #dc2626);
  color: #ffffff;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.35) inset,
    0 -10px 16px rgba(0, 0, 0, 0.16) inset,
    0 10px 22px -6px rgba(220, 38, 38, 0.55),
    0 3px 8px rgba(0, 0, 0, 0.3);
}
.bigbtn:active.start {
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.3) inset,
    0 -6px 10px rgba(0, 0, 0, 0.18) inset,
    0 4px 10px -4px rgba(22, 163, 74, 0.5);
}
.bigbtn:active.stop {
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.3) inset,
    0 -6px 10px rgba(0, 0, 0, 0.18) inset,
    0 4px 10px -4px rgba(220, 38, 38, 0.5);
}

/* --- Icon button (hamburger / back), reused in the floating Track overlay,
   the History topbar, and Trip detail's backrow --- */
.icon-btn {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card);
  border: 0.5px solid var(--border);
  border-radius: 50%;
  color: var(--text);
  cursor: pointer;
  justify-self: start;
}
.icon-btn svg {
  width: 17px;
  height: 17px;
}
.track-menu-btn {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top));
  left: 14px;
  z-index: 500;
  background: rgba(38, 41, 46, 0.85);
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}

/* --- History / lists --- */
.page {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 14px 18px;
}
.topbar h1 {
  font-size: 17px;
  font-weight: 600;
  margin: 0;
  text-align: center;
}
.expbtn {
  justify-self: end;
  font-size: 13px;
  color: var(--amber);
  background: none;
  border: none;
  font-weight: 500;
  cursor: pointer;
}
.content {
  flex: 1;
  overflow-y: auto;
  padding: 0 18px 24px;
}
.card {
  background: var(--card);
  border: 0.5px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.card-label {
  font-size: 12px;
  color: var(--text-dim);
}
.card-value {
  font-family: "JetBrains Mono", monospace;
  font-size: 22px;
  margin-top: 4px;
}
.triprow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 0.5px solid var(--border);
  cursor: pointer;
  background: none;
  border-left: none;
  border-right: none;
  border-top: none;
  width: 100%;
  text-align: left;
  color: inherit;
}
.triprow:last-child {
  border-bottom: none;
}
.triprow .l .d {
  font-size: 14px;
  font-weight: 500;
}
.triprow .l .c {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}
.triprow .r {
  font-family: "JetBrains Mono", monospace;
  font-size: 14px;
  text-align: right;
}
.triprow .r .sub {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}
.month-hdr {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 500;
  margin: 18px 0 6px;
  letter-spacing: 0.02em;
  display: flex;
  justify-content: space-between;
}
.trip-card {
  padding: 0 16px;
}
.empty-state {
  color: var(--text-dim);
  font-size: 13px;
  text-align: center;
  padding: 40px 20px;
}

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 11, 13, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  /* Above .track-menu-btn (500) and any topbar/drawer chrome so modals always float on top. */
  z-index: 1200;
}
.modal-overlay-t {
  transition: opacity 180ms ease-out;
}
.modal-overlay-t-start,
.modal-overlay-t-leave-end {
  opacity: 0;
}
.modal {
  width: 100%;
  max-width: 400px;
  max-height: calc(100% - 20px);
  overflow-y: auto;
  background: linear-gradient(180deg, var(--card-2), var(--card));
  border-radius: 22px;
  padding: 22px 22px calc(22px + env(safe-area-inset-bottom));
  border: 0.5px solid var(--border);
  box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.02) inset;
}
.modal-t {
  transition: opacity 220ms cubic-bezier(0.16, 1, 0.3, 1), transform 220ms cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-t-start,
.modal-t-leave-end {
  opacity: 0;
  transform: scale(0.92) translateY(10px);
}
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}
.modal h2 {
  font-size: 17px;
  margin: 0 0 4px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.modal .sub {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 16px;
}
.modal-close {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card);
  border: 0.5px solid var(--border);
  border-radius: 50%;
  color: var(--text-dim);
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease, transform 150ms ease;
  margin-top: -2px;
}
.modal-close svg {
  width: 14px;
  height: 14px;
}
.modal-close:hover {
  background: var(--border);
  color: var(--text);
}
.modal-close:active {
  transform: scale(0.9);
}
.segmented {
  display: flex;
  gap: 3px;
  background: var(--card);
  border: 0.5px solid var(--border);
  border-radius: 11px;
  padding: 3px;
  margin-bottom: 18px;
}
.segmented button {
  flex: 1;
  padding: 9px 4px;
  background: transparent;
  border: none;
  border-radius: 9px;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease, box-shadow 150ms ease;
}
.segmented button.sel {
  background: var(--amber);
  color: #241a05;
  font-weight: 600;
  box-shadow: 0 2px 8px -2px rgba(232, 163, 61, 0.55);
}
.modal .field {
  margin-bottom: 10px;
}
.modal .field label {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  display: block;
  margin-bottom: 5px;
}
.modal-input {
  width: 100%;
  padding: 11px 13px;
  background: var(--card);
  border: 0.5px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.modal-input::placeholder {
  color: var(--text-dim);
}
.modal-input:focus {
  outline: none;
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(232, 163, 61, 0.18);
}
.optrow {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 14px;
  background: var(--card);
  border-radius: 11px;
  margin-bottom: 8px;
  border: 0.5px solid var(--border);
  cursor: pointer;
  font-size: 14px;
  width: 100%;
  color: inherit;
  text-align: left;
  transition: border-color 150ms ease, background 150ms ease, transform 100ms ease;
}
.optrow:active {
  transform: scale(0.99);
}
.optrow.sel {
  border-color: var(--amber);
  background: #2a2115;
}
.radio {
  width: 17px;
  height: 17px;
  border-radius: 50%;
  border: 1.5px solid var(--text-dim);
  flex-shrink: 0;
  transition: border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}
.optrow.sel .radio {
  border-color: var(--amber);
  background: var(--amber);
  box-shadow: inset 0 0 0 3px #2a2115;
}
.savebtn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(180deg, #edad4c, var(--amber));
  color: #241a05;
  border: none;
  border-radius: 12px;
  font-weight: 700;
  font-size: 14px;
  margin-top: 14px;
  cursor: pointer;
  box-shadow: 0 8px 20px -8px rgba(232, 163, 61, 0.6);
  transition: transform 100ms ease, box-shadow 150ms ease, filter 150ms ease;
}
.savebtn:hover {
  filter: brightness(1.05);
}
.savebtn:active {
  transform: scale(0.98);
  box-shadow: 0 4px 12px -6px rgba(232, 163, 61, 0.5);
}
.field {
  margin-bottom: 14px;
}
.field label {
  font-size: 12px;
  color: var(--text-dim);
  display: block;
  margin-bottom: 6px;
}
.field input[type="date"] {
  width: 100%;
  padding: 10px 12px;
  background: var(--card);
  border: 0.5px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-family: "JetBrains Mono", monospace;
}

/* --- Hamburger drawer --- */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 11, 13, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: stretch;
  justify-content: flex-start;
  z-index: 1200;
}
.drawer {
  width: 78%;
  max-width: 300px;
  height: 100%;
  background: var(--card-2);
  border-right: 0.5px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: calc(20px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
  box-shadow: 24px 0 60px -12px rgba(0, 0, 0, 0.5);
}
.drawer-t {
  transition: opacity 220ms cubic-bezier(0.16, 1, 0.3, 1), transform 220ms cubic-bezier(0.16, 1, 0.3, 1);
}
.drawer-t-start {
  opacity: 0;
  transform: translateX(-16px);
}
.drawer-header {
  padding: 4px 10px 20px;
  border-bottom: 0.5px solid var(--border);
  margin-bottom: 12px;
}
.drawer-email {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 6px;
  word-break: break-all;
}
.drawer-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 10px;
  background: none;
  border: none;
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}
.drawer-item .ic {
  font-size: 16px;
  width: 20px;
  text-align: center;
  color: var(--text-dim);
}
.drawer-item:hover {
  background: var(--card);
}
.drawer-item.active {
  color: var(--amber);
}
.drawer-item.active .ic {
  color: var(--amber);
}
.drawer-item.danger {
  color: var(--red);
}
.drawer-item.danger .ic {
  color: var(--red);
}
.drawer-divider {
  height: 0.5px;
  background: var(--border);
  margin: 8px 4px;
}
.drawer-spacer {
  flex: 1;
}
.drawer-version {
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
  padding: 10px 10px 2px;
}

/* --- Trip detail --- */
.backrow {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px 10px;
}
.backrow h1 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}
.detail-map-card {
  height: 180px;
  padding: 0;
  overflow: hidden;
  position: relative;
}
#detail-map {
  width: 100%;
  height: 100%;
}
.detailstat {
  display: flex;
  gap: 22px;
  padding: 14px 0;
  border-bottom: 0.5px solid var(--border);
  margin-bottom: 14px;
}
.detailstat div .k {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 600;
}
.detailstat div .v {
  font-family: "JetBrains Mono", monospace;
  font-size: 17px;
  margin-top: 3px;
}
.pill {
  display: inline-block;
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 20px;
  background: #2a2115;
  color: var(--amber);
  font-weight: 500;
  margin-bottom: 4px;
}
.addr {
  font-size: 13px;
  color: var(--text-dim);
  margin: 2px 0;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.addr .pin {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}
.addr .pin.a {
  background: var(--teal);
}
.addr .pin.b {
  background: var(--amber);
}
.ghostbtn {
  width: 100%;
  padding: 13px;
  background: var(--card);
  border: 0.5px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  margin-top: 8px;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, transform 100ms ease;
}
.ghostbtn:active {
  transform: scale(0.98);
  background: var(--card-2);
}
.ghostbtn.danger {
  color: var(--red);
  background: rgba(224, 74, 74, 0.08);
  border-color: rgba(224, 74, 74, 0.35);
}
.ghostbtn.danger:active {
  background: rgba(224, 74, 74, 0.16);
}
