:root{
  --bg:#0f1410; --panel:#161d16; --line:#2a3528;
  --ink:#e8efe4; --muted:#9db096; --accent:#7bb661; --accent-ink:#0c120a;
  --danger:#c8643a;
}
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0; background:var(--bg); color:var(--ink);
  font:16px/1.5 "Inter",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  -webkit-font-smoothing:antialiased; overflow:hidden;
}

/* View switching */
.view{position:fixed; inset:0; display:none; flex-direction:column}
.view.is-active{display:flex}

/* ---- Login ---- */
#view-login{align-items:center; justify-content:center; padding:24px;
  background:radial-gradient(120% 80% at 50% 0%, #1a241a 0%, var(--bg) 60%)}
.login-card{width:100%; max-width:340px; text-align:center}
.logo{font-size:56px; line-height:1}
.login-card h1{font-size:34px; margin:.2em 0 .05em; letter-spacing:-.02em}
.tagline{color:var(--muted); margin:0 0 28px}
.btn-google{
  width:100%; display:flex; align-items:center; justify-content:center; gap:10px;
  padding:14px 18px; border-radius:14px; border:1px solid var(--line);
  background:#fff; color:#1f2937; font-size:16px; font-weight:600; cursor:pointer;
}
.btn-google:active{transform:translateY(1px)}
.btn-google .g{font-weight:800; color:#4285F4}
.login-msg{min-height:1.2em; margin-top:16px; font-size:14px; color:var(--muted); line-height:1.5}
.login-msg.error{color:var(--danger)}

.or-divider{display:flex; align-items:center; gap:12px; margin:18px 0; color:var(--muted); font-size:13px}
.or-divider::before,.or-divider::after{content:''; flex:1; height:1px; background:var(--line)}
.email-form{display:flex; flex-direction:column; gap:10px}
.email-form input{
  width:100%; background:#0e140d; color:var(--ink); border:1px solid var(--line);
  border-radius:12px; padding:14px; font:16px "Inter",sans-serif; min-height:50px; text-align:center;
}
.email-form input:focus{outline:none; border-color:var(--accent); box-shadow:0 0 0 3px rgba(123,182,97,.2)}
.btn-email{
  width:100%; min-height:50px; border-radius:12px; cursor:pointer; font-size:15px; font-weight:600;
  background:transparent; color:var(--ink); border:1px solid var(--line);
}
.btn-email:hover{border-color:var(--accent); color:var(--accent)}
.btn-email:disabled{opacity:.6; cursor:default}

/* ---- Map view ---- */
.topbar{
  display:flex; align-items:center; justify-content:space-between;
  padding:calc(env(safe-area-inset-top) + 10px) 14px 10px;
  background:var(--panel); border-bottom:1px solid var(--line); z-index:5;
}
.brand{font-weight:700}
.topbar-right{display:flex; align-items:center; gap:10px}
.icon-btn{background:transparent; border:1px solid var(--line); color:var(--ink);
  width:38px; height:38px; border-radius:10px; font-size:18px; cursor:pointer}
.icon-btn:active{transform:translateY(1px)}
.avatar{width:32px; height:32px; border-radius:50%; background:var(--line); object-fit:cover; display:block}
.avatar-btn{padding:0; border:none; background:transparent; cursor:pointer; border-radius:50%; width:34px; height:34px}
.avatar-btn img{width:34px; height:34px; border-radius:50%; background:var(--line); object-fit:cover}
.topbar-right{gap:6px}
.icon-btn{width:36px; height:36px; font-size:17px}
.icon-btn.active{border-color:var(--accent); color:var(--accent)}
@media(max-width:380px){ .brand{font-size:14px} .icon-btn{width:33px; height:33px; font-size:15px} }

#map{flex:1; width:100%; background:#0b0f0a}

.map-status{
  position:fixed; left:50%; transform:translateX(-50%);
  bottom:calc(env(safe-area-inset-bottom) + 18px);
  background:rgba(22,29,22,.95); border:1px solid var(--line); color:var(--ink);
  padding:9px 16px; border-radius:999px; font-size:13px; max-width:90vw; text-align:center;
  box-shadow:0 6px 20px rgba(0,0,0,.4); opacity:0; transition:opacity .25s; pointer-events:none;
}
.map-status.show{opacity:1}

.fab{
  position:fixed; right:18px; bottom:calc(env(safe-area-inset-bottom) + 18px);
  width:60px; height:60px; border-radius:50%; border:none; cursor:pointer;
  background:var(--accent); color:var(--accent-ink); font-size:34px; line-height:1;
  box-shadow:0 8px 24px rgba(0,0,0,.45); z-index:5;
}
.fab:active{transform:translateY(1px)}

/* ---- Bottom sheet ---- */
.scrim{
  position:fixed; inset:0; z-index:20; background:rgba(0,0,0,.55);
  opacity:0; transition:opacity .25s ease;
}
.scrim.show{opacity:1}

.sheet{
  position:fixed; left:0; right:0; bottom:0; z-index:30;
  background:var(--panel); border-top:1px solid var(--line);
  border-radius:20px 20px 0 0; padding:6px 18px calc(env(safe-area-inset-bottom) + 20px);
  max-height:88vh; overflow-y:auto;
  transform:translateY(110%); transition:transform .28s cubic-bezier(.32,.72,0,1);
  box-shadow:0 -10px 40px rgba(0,0,0,.5);
}
.sheet.show{transform:translateY(0)}
@media(min-width:640px){
  .sheet{left:50%; right:auto; width:480px; transform:translate(-50%,110%)}
  .sheet.show{transform:translate(-50%,0)}
}
.sheet-handle{
  width:40px; height:4px; border-radius:99px; background:var(--line);
  margin:8px auto 6px; flex:none;
}
.sheet-head{display:flex; align-items:center; justify-content:space-between; gap:12px; margin:4px 0 14px}
.sheet-title{font-size:19px; font-weight:700}
.icon-close{
  background:transparent; border:none; color:var(--muted); cursor:pointer;
  width:44px; height:44px; margin:-10px -10px -10px 0; display:grid; place-items:center; border-radius:10px;
}
.icon-close:hover{color:var(--ink); background:rgba(255,255,255,.05)}

/* form fields */
.field{display:block; margin-bottom:16px}
.flabel{display:block; font-size:13px; font-weight:600; color:var(--muted); margin-bottom:7px}
.flabel .req{color:var(--accent)}
.flabel .hint{font-weight:400; color:var(--muted); opacity:.8}
#pin-form select, #pin-form input[type=text], #pin-form textarea{
  width:100%; background:#0e140d; color:var(--ink);
  border:1px solid var(--line); border-radius:12px; padding:13px 14px;
  font:16px "Inter",sans-serif; min-height:48px;
}
#pin-form textarea{min-height:80px; resize:vertical; line-height:1.5}
#pin-form select:focus, #pin-form input:focus, #pin-form textarea:focus{
  outline:none; border-color:var(--accent); box-shadow:0 0 0 3px rgba(123,182,97,.2);
}

/* chips */
.chips{display:flex; flex-wrap:wrap; gap:8px}
.chip{
  background:#0e140d; color:var(--ink); border:1px solid var(--line);
  border-radius:999px; padding:10px 14px; font-size:14px; cursor:pointer; min-height:40px;
  transition:background .15s, border-color .15s, color .15s;
}
.chip.sm{padding:8px 12px; min-height:36px; font-size:13px}
.chip:hover{border-color:var(--muted)}
.chip.on{background:var(--accent); color:var(--accent-ink); border-color:var(--accent); font-weight:600}
.chips.months{gap:6px}

/* rating */
.rating{display:flex; gap:4px}
.star{
  background:transparent; border:none; cursor:pointer; font-size:30px; line-height:1;
  color:var(--line); padding:2px 4px; min-width:44px; min-height:44px;
}
.star.on{color:#e0b341}

.field-error{
  background:rgba(200,100,58,.12); border:1px solid var(--danger); color:#f0d6c9;
  border-radius:10px; padding:10px 12px; font-size:14px; margin-bottom:14px;
}

/* sheet actions */
.sheet-actions{display:flex; gap:10px; margin-top:18px}
.sheet-actions button{
  flex:1; min-height:50px; border-radius:12px; font-size:16px; font-weight:600; cursor:pointer; border:1px solid transparent;
}
.btn-primary{background:var(--accent); color:var(--accent-ink); border-color:var(--accent)}
.btn-primary:disabled{opacity:.6; cursor:default}
.btn-ghost{background:transparent; color:var(--ink); border-color:var(--line)}
.btn-danger{background:transparent; color:var(--danger); border-color:var(--danger); flex:0 0 auto; padding:0 20px}
.btn-danger:hover{background:rgba(200,100,58,.12)}

/* detail view */
.detail-title{font-size:21px; font-weight:700; display:flex; align-items:center; gap:10px}
.detail-emoji{font-size:26px}
.detail-rows{display:flex; flex-direction:column; gap:2px; margin-bottom:6px}
.drow{display:flex; justify-content:space-between; gap:16px; padding:11px 0; border-bottom:1px solid var(--line)}
.drow.col{flex-direction:column; gap:5px}
.drow:last-child{border-bottom:none}
.dk{color:var(--muted); font-size:14px; flex:none}
.dv{text-align:right}
.drow.col .dv{text-align:left}
.dv.notes{line-height:1.55; white-space:pre-wrap}
.dv.coord{font-variant-numeric:tabular-nums; color:var(--muted); font-size:14px}
.dv.stars{color:#e0b341; letter-spacing:2px}

/* photos */
.photo-grid{display:flex; flex-wrap:wrap; gap:8px; margin:2px 0 14px}
.photo-cell{position:relative; width:84px; height:84px; border-radius:12px; overflow:hidden; background:#0e140d; border:1px solid var(--line)}
.photo-cell img{width:100%; height:100%; object-fit:cover; display:block}
.photo-del{
  position:absolute; top:3px; right:3px; width:26px; height:26px; border-radius:50%;
  background:rgba(0,0,0,.62); color:#fff; border:none; cursor:pointer; font-size:17px; line-height:1;
  display:grid; place-items:center;
}
.photo-add{
  width:84px; height:84px; border-radius:12px; border:1.5px dashed var(--line); cursor:pointer;
  display:flex; flex-direction:column; align-items:center; justify-content:center; gap:2px; color:var(--muted);
}
.photo-add span:first-child{font-size:24px; line-height:1}
.photo-add .pa-label{font-size:12px}
.photo-add:hover{border-color:var(--accent); color:var(--accent)}
.photo-add.busy{opacity:.5; pointer-events:none}

/* source tag (which map/collection a pin belongs to) */
.source-tag{
  display:inline-block; font-size:12px; font-weight:600; color:var(--accent);
  background:rgba(123,182,97,.12); border:1px solid rgba(123,182,97,.3);
  padding:4px 10px; border-radius:999px; margin:0 0 12px;
}

/* groups manager */
.muted-note{color:var(--muted); font-size:13px; line-height:1.5; margin:0 0 16px}
.group-section{margin-bottom:22px}
.group-h{font-size:14px; color:var(--muted); text-transform:uppercase; letter-spacing:.05em; margin:0 0 10px}
.group-list{display:flex; flex-direction:column; gap:10px; margin-bottom:10px}
.empty{color:var(--muted); font-size:14px; margin:0}
.group-card{background:#0e140d; border:1px solid var(--line); border-radius:14px; padding:13px 14px}
.group-top{display:flex; align-items:center; gap:10px; margin-bottom:8px}
.group-name{font-weight:600; font-size:16px}
.badge{font-size:11px; color:var(--muted); border:1px solid var(--line); border-radius:999px; padding:2px 8px}
.member-chips{display:flex; flex-wrap:wrap; gap:6px; margin-bottom:8px}
.member{
  display:inline-flex; align-items:center; gap:4px; font-size:13px; color:var(--ink);
  background:#161d16; border:1px solid var(--line); border-radius:999px; padding:5px 10px;
}
.member.owner{color:var(--muted)}
.m-x{background:transparent; border:none; color:var(--muted); cursor:pointer; font-size:16px; line-height:1; padding:0 0 0 2px}
.m-x:hover{color:var(--danger)}
.member-add{display:flex; gap:8px; margin-bottom:8px}
.member-add input{
  flex:1; background:#161d16; border:1px solid var(--line); border-radius:10px; color:var(--ink);
  padding:9px 11px; font:14px "Inter",sans-serif; min-height:40px;
}
.group-create{display:flex; gap:8px}
.group-create input{
  flex:1; background:#0e140d; border:1px solid var(--line); border-radius:10px; color:var(--ink);
  padding:10px 12px; font:15px "Inter",sans-serif; min-height:44px;
}
.btn-primary.sm,.btn-ghost.sm{flex:0 0 auto; min-height:40px; padding:0 16px; font-size:14px; border-radius:10px; font-weight:600; cursor:pointer}
.btn-primary.sm{background:var(--accent); color:var(--accent-ink); border:1px solid var(--accent)}
.btn-ghost.sm{background:transparent; color:var(--ink); border:1px solid var(--line)}
.group-actions{display:flex; gap:14px; margin-top:4px}
.link-btn{background:transparent; border:none; color:var(--accent); cursor:pointer; font-size:14px; padding:6px 0}
.link-btn.danger{color:var(--danger)}

/* sharing block in pin detail */
.share-block{margin:6px 0 14px; padding-top:14px; border-top:1px solid var(--line)}
.share-block .flabel{margin-bottom:8px}
.two-col{display:flex; gap:12px}
.two-col .field{flex:1}

/* nearby list */
.nearby-list{display:flex; flex-direction:column; gap:6px}
.nearby-row{
  display:flex; align-items:center; gap:12px; width:100%; text-align:left; cursor:pointer;
  background:#0e140d; border:1px solid var(--line); border-radius:12px; padding:11px 13px; color:var(--ink);
}
.nearby-row:hover{border-color:var(--muted)}
.nb-emoji{font-size:22px; flex:none}
.nb-main{display:flex; flex-direction:column; flex:1; min-width:0}
.nb-title{font-weight:600}
.nb-sub{font-size:13px; color:var(--muted)}
.nb-dist{font-size:13px; color:var(--accent); font-variant-numeric:tabular-nums; flex:none}

/* toast */
.toast{
  position:fixed; left:50%; transform:translate(-50%,20px); z-index:60;
  bottom:calc(env(safe-area-inset-bottom) + 24px);
  background:#1f2b1e; border:1px solid var(--line); color:var(--ink);
  padding:12px 18px; border-radius:12px; font-size:14px; max-width:90vw; text-align:center;
  box-shadow:0 8px 28px rgba(0,0,0,.5); opacity:0; pointer-events:none; transition:opacity .25s, transform .25s;
}
.toast.show{opacity:1; transform:translate(-50%,0)}

@media(prefers-reduced-motion: reduce){
  .sheet,.scrim,.toast{transition:none}
}

/* ---- Boot error ---- */
.boot-error{
  position:fixed; inset:auto 16px 16px 16px; z-index:50;
  background:#2a1a14; border:1px solid var(--danger); color:#f0d6c9;
  padding:14px 16px; border-radius:12px; font-size:14px;
}
