/* Layout: phone-first single column. Sticky top bar, file card, sticky search + filter,
   then pin cards with one big "Open in Google Maps" button each. Wider screens just centre the column. */
:root {
  --bg: #F3F5F7;
  --surface: #FFFFFF;
  --fg: #13202B;
  --muted: #5B6875;
  --line: #D9DFE5;
  --accent: #0B5CAD;
  --accent-ink: #FFFFFF;
  --accent-soft: #E3EEFA;
  --ok: #17803D;
  --ok-ink: #FFFFFF;
  --ok-soft: #E3F4E8;
  --danger: #B42318;
  --danger-soft: #FDECEA;
  --warn: #8A5300;
  --warn-soft: #FFF2D6;
  --font-latin: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --font-urdu: "Noto Naskh Arabic", "Noto Nastaliq Urdu", "Geeza Pro", "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Roboto Mono", Menlo, monospace;
  --radius: 14px;
  --tap: 48px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0D1318; --surface: #151D24; --fg: #E6EDF3; --muted: #94A3B2; --line: #26323D;
    --accent: #6AA8F0; --accent-ink: #06223F; --accent-soft: #16283A;
    --ok: #5CC97F; --ok-ink: #06240F; --ok-soft: #14301F;
    --danger: #F4A9A0; --danger-soft: #3B1C19;
    --warn: #F2C46B; --warn-soft: #33290F;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: var(--font-latin); font-size: 16px; line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}
[dir="rtl"] body { font-family: var(--font-urdu); line-height: 1.8; }
[hidden] { display: none !important; }
button, input, a { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.ltr { direction: ltr; unicode-bidi: isolate; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; font-weight: 700; font-size: 18px; }
.brand img { width: 30px; height: 30px; border-radius: 8px; flex: none; }
.brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-btn {
  min-height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.chip-btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.wrap {
  max-width: 640px; margin: 0 auto;
  padding-block: 16px calc(env(safe-area-inset-bottom, 0px) + 32px);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: grid; gap: 14px;
}

/* Buttons */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 16px; border-radius: 12px; border: 1px solid transparent;
  font-weight: 600; font-size: 16px; text-decoration: none; cursor: pointer; text-align: center;
}
.btn svg { width: 20px; height: 20px; flex: none; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:active { filter: brightness(.92); }
.btn-outline { background: var(--surface); color: var(--fg); border-color: var(--line); }
.btn-outline:active { background: var(--accent-soft); }
.btn-big { min-height: 56px; font-size: 17px; }
.btn[aria-disabled="true"] { opacity: .4; pointer-events: none; }

/* Notices */
.notice { padding: 12px 14px; border-radius: 12px; font-size: 15px; }
.notice-error { background: var(--danger-soft); color: var(--danger); }
.ios-hint { display: flex; gap: 10px; align-items: flex-start; background: var(--accent-soft); }
.ios-hint p { margin: 0; flex: 1; }
.ios-hint button { background: none; border: 0; padding: 4px 8px; font-weight: 600; color: var(--accent); cursor: pointer; }

/* Shared surfaces */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0; }
.muted { color: var(--muted); }
.center { text-align: center; }
.screen { display: grid; gap: 14px; }
.screen-head h1 { margin: 0; font-size: 24px; line-height: 1.3; }

/* Back button + account menu in the top bar */
.back {
  display: inline-flex; align-items: center; gap: 2px; min-height: 40px; padding: 0 10px 0 4px;
  border: 0; border-radius: 10px; background: transparent; color: var(--accent); font-weight: 600; cursor: pointer;
}
.back svg { width: 22px; height: 22px; }
[dir="rtl"] .back svg { transform: scaleX(-1); }
.back:not([hidden]) + .brand span { display: none; }
.account { position: relative; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); padding: 0; overflow: hidden;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-family: var(--font-latin); cursor: pointer;
  display: grid; place-items: center;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.account-menu {
  position: absolute; top: calc(100% + 8px); inset-inline-end: 0; z-index: 25; width: min(280px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 8px 28px rgb(0 0 0 / .18); padding: 14px; display: grid; gap: 4px;
}
.account-name { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
.account-email { margin: 0 0 8px; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.offline-banner {
  padding: 8px max(16px, env(safe-area-inset-right, 0px)) 8px max(16px, env(safe-area-inset-left, 0px));
  background: var(--warn-soft); color: var(--warn); font-size: 14px; text-align: center;
}

/* Sign-in / sign-up */
.intro { padding: 22px 18px; display: grid; gap: 14px; }
.intro h1, .intro h2 { margin: 0; font-size: 24px; line-height: 1.3; text-wrap: balance; }
.intro p { margin: 0; }
.google-slot { height: 44px; overflow: hidden; display: flex; justify-content: center; align-items: center; }
/* Google draws its logo before its stylesheet arrives: keep it small and hidden until the button frame is in. */
.google-slot svg { width: 18px; height: 18px; }
.google-slot:not(:has(iframe)) > * { visibility: hidden; }
/* Sign in / Sign up: a clear two-way switch, the open tab filled in the app colour. */
.filters.auth-tabs { grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px; background: var(--bg); border: 1px solid var(--line); border-radius: 14px; }
.filters.auth-tabs button {
  min-height: 48px; border-radius: 10px; font-size: 16px; font-weight: 700; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: background .15s, color .15s;
}
.filters.auth-tabs button svg { width: 18px; height: 18px; }
.filters.auth-tabs button:not([aria-pressed="true"]):hover { color: var(--fg); background: var(--accent-soft); }
.filters.auth-tabs button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); box-shadow: 0 2px 8px rgb(0 0 0 / .2); }
.filters.auth-tabs button:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 2px; }
.auth-form { display: grid; gap: 12px; }
.field { display: grid; gap: 6px; font-weight: 600; font-size: 15px; }
.field input {
  width: 100%; min-height: 52px; padding: 0 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg); color: var(--fg); font: inherit; font-size: 18px; font-weight: 500;
}
.field input:focus-visible { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
.field input[dir="ltr"] { text-align: start; }
.field-hint { margin: -4px 0 0; font-size: 14px; color: var(--muted); }
.check { display: flex; align-items: center; gap: 10px; min-height: 40px; font-size: 15px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.form-error { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--danger-soft); color: var(--danger); font-weight: 600; }
.auth-form .link-btn { justify-self: center; }
.or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
#screen-password .btn { width: 100%; }
.auth-switch { color: var(--muted); font-size: 15px; }
.link-btn { border: 0; background: none; padding: 6px 2px; min-height: 32px; color: var(--accent); font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; }
/* Google's button is a light-scheme iframe; matching it avoids an opaque white box in dark mode. */
.google-slot iframe { color-scheme: light; }

/* My files */
.file-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.file-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); display: grid; }
.file-open {
  display: grid; gap: 6px; padding: 14px 14px 10px; border: 0; background: none; text-align: start; cursor: pointer; width: 100%;
}
.file-open strong { font-size: 18px; overflow-wrap: anywhere; }
.file-open .muted { font-size: 14px; }
.file-open .bar { height: 8px; }
.file-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 0 14px 10px; }
.file-foot .sync-status { margin: 0; }
.remove { min-height: 36px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--danger); font-size: 14px; font-weight: 600; cursor: pointer; }
.remove.is-armed { background: var(--danger); border-color: var(--danger); color: var(--surface); }
.sync-status { font-size: 13px; color: var(--muted); }
.sync-status.is-pending { color: var(--warn); }
.steps { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; counter-reset: step; }
.steps li { display: flex; gap: 12px; align-items: flex-start; counter-increment: step; }
.steps li::before {
  content: counter(step); flex: none; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 14px;
  font-family: var(--font-latin);
}

/* File card */
.file-card { display: grid; gap: 12px; }
.file-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.file-head h2 { margin: 0; font-size: 20px; overflow-wrap: anywhere; }
.file-head span { color: var(--muted); font-size: 14px; }
.progress { display: grid; gap: 6px; }
.progress-label { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.bar { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--ok); border-radius: inherit; transition: width .3s; }
[dir="rtl"] .bar span { margin-inline-start: 0; }
.file-card details summary { cursor: pointer; color: var(--accent); font-weight: 600; min-height: 32px; }
.shared { margin: 8px 0 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.shared li { border: 1px solid var(--line); border-radius: 999px; padding: 2px 12px; font-size: 14px; }
.shared .k { color: var(--muted); margin-inline-end: 6px; }

/* Sticky search + filter */
.controls {
  position: sticky; z-index: 10; top: var(--topbar-h, 60px);
  display: grid; gap: 8px; padding-block: 8px; margin-block: -8px; background: var(--bg);
}
.search {
  width: 100%; min-height: var(--tap); padding: 0 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); color: var(--fg); font-size: 16px;
}
.filters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; background: var(--line); border-radius: 12px; }
.filters button {
  min-height: 40px; border: 0; border-radius: 9px; background: transparent; font-size: 14px; font-weight: 600;
  color: var(--muted); cursor: pointer; font-variant-numeric: tabular-nums;
}
.filters button[aria-pressed="true"] { background: var(--surface); color: var(--fg); box-shadow: 0 1px 2px rgb(0 0 0 / .12); }
.count { color: var(--muted); font-size: 13px; margin: 0; }

/* Pin cards */
.pins { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.pin { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: grid; gap: 10px; }
.pin.is-verified { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 35%, var(--line)); }
.pin-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pin-no { font-size: 26px; font-weight: 800; line-height: 1.1; font-family: var(--font-latin); overflow-wrap: anywhere; }
.pin-no small { display: block; font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .04em; }
.badge { margin-inline-start: auto; display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; background: var(--ok); color: var(--ok-ink); font-size: 13px; font-weight: 700; }
.badge svg { width: 14px; height: 14px; }
.coords { margin: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.coords code { font-family: var(--font-mono); font-size: 14px; font-variant-numeric: tabular-nums; }
.copy { min-height: 32px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); font-size: 13px; font-weight: 600; cursor: pointer; }
.kind { font-size: 13px; color: var(--muted); }
.preview { margin: 0; font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.preview b { color: var(--fg); font-weight: 600; }
.pin-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pin-actions .btn-big { grid-column: 1 / -1; }
.verify[aria-pressed="true"] { background: var(--ok); color: var(--ok-ink); border-color: var(--ok); }
.verified-at { margin: 0; display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--ok); font-weight: 700; }
.verified-at svg { width: 16px; height: 16px; flex: none; }
.pin details summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 14px; min-height: 32px; }
.fields { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 14px; margin: 6px 0 0; font-size: 14px; }
.fields dt { color: var(--muted); }
.fields dd { margin: 0; overflow-wrap: anywhere; }
.no-loc { margin: 0; color: var(--danger); font-size: 14px; }
.no-match { text-align: center; color: var(--muted); padding: 24px 0; }
.privacy { margin: 4px 0 0; color: var(--muted); font-size: 13px; text-align: center; }

/* Toast */
.toast {
  position: fixed; z-index: 30; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  width: min(560px, calc(100% - 32px));
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 12px;
  background: var(--fg); color: var(--bg); box-shadow: 0 6px 24px rgb(0 0 0 / .25); font-size: 15px;
}
.toast p { margin: 0; flex: 1; }
.toast button { background: none; border: 0; color: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; min-height: 36px; padding: 0 6px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Privacy page */
.legal h1 { margin: 0; font-size: 24px; }
.legal h2 { font-size: 18px; margin: 18px 0 6px; }
.legal p, .legal li { max-width: 65ch; }
.legal ul { padding-inline-start: 20px; display: grid; gap: 6px; }
a.brand { color: inherit; text-decoration: none; }

/* Admin page */
.temp-password { display: grid; gap: 10px; padding: 14px; border-radius: 12px; background: var(--ok-soft); }
.temp-password p { margin: 0; }
.temp-value { font-family: var(--font-mono); font-size: 32px; font-weight: 800; letter-spacing: .12em; color: var(--ok); }
