* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --red: #ff3502;
  --red-strong: #ff3600;
  --bluesky: #008bff;
  --text-muted: #666;
  --link: #0066cc;
  --drawer-bg: #f2f2f2;
  --slot-bg: #dddddd;
  --black: #000;
  --white: #fff;
  --bar-h: 47px;
  --drawer-h: 123px;
  /* iOS PWA home-indicator area; 0 in normal browsers / non-standalone mode. */
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --bar-total: calc(var(--bar-h) + var(--safe-bottom));
  --safe-top: env(safe-area-inset-top, 0px);
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
  background: #e5e5e5;
  color: #fff;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
}

button { background: none; border: none; color: inherit; font: inherit; cursor: pointer; padding: 0; }
img, svg { display: block; }

/* Mobile window: fill the phone viewport. Desktop media query below locks to 731×586. */
.view {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: #fff;
  overflow: hidden;
}
.hidden { display: none !important; }

/* ============================================================
   Sign-in screen — matches pencil frames tAHnc (mobile) & PmLkA (desktop)
   ============================================================ */
#signin-view {
  background: #fff;
  color: #000;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px 24px 60px;
}
.signin-logo {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.signin-logo img {
  width: 122px;
  height: auto;
  filter: invert(1);
}
.signin-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding-bottom: 24px;
}
.btn-bluesky {
  width: 100%;
  max-width: 360px;
  height: 44px;
  background: var(--bluesky);
  color: #fff;
  font-size: 16px;
  font-weight: 500;
  border-radius: 4px;
  transition: opacity 0.15s;
}
.btn-bluesky:active { opacity: 0.85; }
.signup-prompt {
  font-size: 13px;
  display: flex;
  gap: 4px;
  align-items: center;
}
.signup-text { color: var(--text-muted); }
.signup-link { color: var(--link); font-weight: 600; text-decoration: none; }

/* ============================================================
   Map view — matches frame z47oB (mobile) / kGk8l (desktop)
   ============================================================ */
#map-view { background: #000; }
#map-container {
  position: absolute;
  inset: 0;
  background: #222;
}
.mk-compass-control, .mk-scale-control { display: none !important; }

/* mobile: logo at top-center, desktop: moves into bottom bar */
.top-logo {
  position: absolute;
  /* Inline env() — piping through a CSS var doesn't always evaluate in Safari. */
  top: calc(env(safe-area-inset-top, 0px) * 1.2 + 30px);
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 10;
}
.top-logo img {
  width: 122px;
  height: auto;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}


/* ============================================================
   Camera preview — mobile full-width, desktop right panel
   ============================================================ */
.camera-preview {
  position: absolute;
  left: 0; right: 0; top: 0;
  bottom: calc(var(--bar-total) + var(--drawer-h));
  background: #000;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 40px;
}
.camera-preview video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}
/* Front-facing camera: show the preview mirrored so it reads like a mirror. */
.camera-preview video.mirrored { transform: scaleX(-1); }
.shutter {
  position: relative;
  width: 53px; height: 53px;
  border-radius: 50%;
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  z-index: 2;
}
.shutter span {
  width: 39px; height: 39px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #000;
  display: block;
}
.shutter:active span { transform: scale(0.92); }

/* Album preview (fullscreen tap-in-tap-out) */
.album-preview {
  position: absolute;
  left: 0; right: 0; top: 0;
  bottom: calc(var(--bar-total) + var(--drawer-h));
  background: #222;
  z-index: 20;
  display: flex; align-items: center; justify-content: center;
}
.album-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* ============================================================
   Publish drawer — frame DK8hU (mobile) / M2abm (desktop)
   ============================================================ */
.publish-drawer {
  position: absolute;
  left: 0; right: 0;
  bottom: var(--bar-total);
  height: var(--drawer-h);
  background: var(--drawer-bg);
  z-index: 15;
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 -1px 8px rgba(0,0,0,0.08);
}
.drawer-row { display: flex; align-items: center; gap: 10px; }
.drawer-icon {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  color: var(--slot-bg);
}
.drawer-icon.pin-red { color: var(--red-strong); }
.drawer-icon svg { width: 100%; height: 100%; }
.slot-row {
  display: flex;
  gap: 7px;
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}
.slot-row::-webkit-scrollbar { display: none; }
.photo-slot {
  width: 30px; height: 30px;
  flex: 0 0 30px;
  border-radius: 2px;
  background: var(--slot-bg);
  background-size: cover;
  background-position: center;
  transition: transform 0.1s;
}
.photo-slot.filled { background-color: transparent; cursor: pointer; }
.photo-slot.filled:active { transform: scale(0.94); }
.drawer-actions { display: flex; justify-content: flex-end; }
.btn-publish {
  height: 32px;
  padding: 0 18px;
  background: var(--red);
  color: #fff;
  font-size: 16px;
  font-weight: 500;
  border-radius: 2px;
}
.btn-publish:active { opacity: 0.85; }

/* Account row — ewpft */
.account-row {
  position: absolute;
  left: 0; right: 0;
  bottom: var(--bar-total);
  height: 48px;
  background: var(--drawer-bg);
  z-index: 14;
  padding: 0 12px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 -1px 8px rgba(0,0,0,0.08);
}
.account-name { color: #000; font-size: 16px; }
.btn-signout {
  height: 32px;
  padding: 0 14px;
  background: var(--red);
  color: #fff;
  font-size: 16px;
  font-weight: 500;
  border-radius: 2px;
}
.btn-signout:active { opacity: 0.85; }

/* ============================================================
   Bottom toolbar — mobile: space-between, desktop: center + logo left
   ============================================================ */
.bottom-bar {
  position: absolute;
  left: 0; right: 0;
  bottom: 0;
  height: var(--bar-total);
  background: #fff;
  z-index: 30;
  padding: 0 12px var(--safe-bottom);
  display: flex;
  align-items: center;
  box-shadow: 0 -1px 6px rgba(0,0,0,0.06);
}
.bar-logo {
  display: none;
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 90px;
  height: auto;
  filter: invert(1);
  pointer-events: none;
}
.tb-group {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.tb-btn {
  height: 36px;
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  color: var(--red);
  transition: transform 0.1s;
  padding: 0 4px;
}
/* Same optical height across icons; width follows each svg's natural aspect. */
.tb-btn svg { height: 22px; width: auto; }
.tb-btn.active { color: var(--red-strong); }
.tb-btn:active { transform: scale(0.92); }
.tb-pin { color: var(--red-strong); }
.tb-album-slot {
  width: 30px; height: 30px;
  border-radius: 2px;
  background: var(--slot-bg);
  background-size: cover;
  background-position: center;
}

/* ============================================================
   DESKTOP layout — ≥ 768px
   Follows pencil frames PmLkA (sign-in), kGk8l (map), M2abm (publish)
   Uses the exact 731×586 pixel size from the design, centered on a light-gray page.
   ============================================================ */
/* PWA / standalone: relax the fixed aspect, let the map own both safe areas. */
html.pwa,
html.pwa body {
  background: #000;
}
html.pwa .view {
  width: 100vw;
  height: 100vh;
  border-radius: 0;
  box-shadow: none;
}

@media (min-width: 768px) {
  .view {
    width: 731px;
    height: 586px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.18);
    border-radius: 2px;
  }

  /* Sign-in: keep centered, wider button group like PmLkA */
  #signin-view { padding-bottom: 80px; }
  .signin-logo img { width: 160px; }
  .btn-bluesky { max-width: 320px; }

  /* Map: hide top-center logo, show logo in bottom bar */
  .top-logo { display: none; }
  .bar-logo { display: block; }
  .bottom-bar { justify-content: center; }
  .tb-group {
    flex: 0 1 auto;
    gap: 28px;
    justify-content: center;
  }
  .tb-btn svg { height: 24px; }
  .tb-album-slot { width: 30px; height: 30px; }

  /* Publish drawer: keeps 123px height (from M2abm); big preview lives as a separate right panel on the map */
  .publish-drawer { height: var(--drawer-h); padding: 12px 16px; }

  /* Camera/album preview: 317×317 right-side panel anchored like M2abm */
  .camera-preview,
  .album-preview {
    left: auto;
    right: 0;
    top: 99px;
    bottom: auto !important;
    width: 317px;
    height: 317px;
    background: #dddddd;
    border-radius: 2px;
    overflow: hidden;
  }
  .camera-preview video { border-radius: 2px; }

  /* Account row: slides above toolbar same way */
  .account-row { padding: 0 24px; }
  .account-name { font-size: 18px; }
}

