:root{
  --bg:#f8fafc;
  --card:#ffffff;
  --ink:#0f172a;
  --muted:#64748b;
  --border:#dbe3ef;
  --primary:#0f172a;
  --soft:#eef2f7;
}

*{box-sizing:border-box}
html,body,#app{height:100%;margin:0}
body{
  font-family:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  color:var(--ink);
  background:var(--bg);
}

button,a,input{
  font:inherit;
}

button{
  cursor:pointer;
}

.topbar{
  height:68px;
  background:var(--primary);
  color:#fff;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:10px 16px;
  box-shadow:0 2px 14px rgba(15,23,42,.22);
  position:relative;
  z-index:1000;
}

.brand{min-width:0}
.title{
  font-size:20px;
  font-weight:850;
  line-height:1.05;
}
.subtitle{
  margin-top:3px;
  font-size:13px;
  color:#dbeafe;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.topActions{
  display:flex;
  gap:8px;
  align-items:center;
  flex-wrap:wrap;
  justify-content:flex-end;
}

.ghost{
  border:1px solid rgba(255,255,255,.65);
  background:#fff;
  color:#0f172a;
  border-radius:999px;
  padding:9px 13px;
  font-weight:850;
  min-height:40px;
}

main{
  height:calc(100% - 68px);
  display:grid;
  grid-template-columns:360px 1fr 390px;
  min-height:0;
}

.controls{
  background:#fff;
  border-right:1px solid var(--border);
  padding:12px;
  overflow:auto;
}

.tabs{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin-bottom:12px;
}

.tab{
  border:1px solid var(--border);
  background:#fff;
  border-radius:999px;
  padding:9px 12px;
  font-weight:800;
  color:#0f172a;
}

.tab.active{
  background:#0f172a;
  color:#fff;
  border-color:#0f172a;
}

.searchrow{
  display:grid;
  grid-template-columns:1fr auto;
  gap:8px;
  margin-bottom:10px;
}

.searchrow input{
  height:42px;
  border:1px solid var(--border);
  border-radius:14px;
  padding:0 12px;
  min-width:0;
}

.searchrow button,
.layerActions button,
.small{
  border:1px solid var(--border);
  background:#fff;
  border-radius:14px;
  padding:9px 11px;
  font-weight:800;
  color:#0f172a;
}

.layerActions{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:8px;
  margin-bottom:10px;
}

.layers{
  display:flex;
  flex-direction:column;
  gap:8px;
}

.layer{
  display:flex;
  align-items:center;
  gap:9px;
  border:1px solid var(--border);
  background:#fff;
  padding:9px 10px;
  border-radius:14px;
  font-size:14px;
  line-height:1.2;
}

.layer input{
  width:18px;
  height:18px;
  flex:0 0 auto;
}

.dot{
  width:13px;
  height:13px;
  border-radius:999px;
  flex:0 0 auto;
}

#map{
  min-width:0;
  min-height:0;
}

.listpanel{
  background:#f8fafc;
  border-left:1px solid var(--border);
  min-height:0;
  overflow:auto;
}

.listhead{
  background:rgba(255,255,255,.96);
  backdrop-filter:blur(8px);
  position:sticky;
  top:0;
  z-index:30;
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:10px;
  padding:13px;
  border-bottom:1px solid var(--border);
}

.listhead h2{
  margin:0;
  font-size:18px;
}

.listhead p{
  margin:3px 0 0;
  font-size:13px;
  color:var(--muted);
}

.placelist{
  display:flex;
  flex-direction:column;
  gap:10px;
  padding:12px;
}

.place{
  background:#fff;
  border:1px solid var(--border);
  border-radius:18px;
  padding:12px;
  box-shadow:0 4px 16px rgba(15,23,42,.06);
}

.place.done{
  opacity:.62;
}

.placeTop{
  display:flex;
  justify-content:space-between;
  gap:10px;
}

.name{
  font-size:16px;
  font-weight:850;
  line-height:1.25;
}

.meta{
  margin-top:3px;
  font-size:12px;
  color:var(--muted);
  line-height:1.35;
}

.badge{
  flex:0 0 auto;
  align-self:flex-start;
  font-size:11px;
  background:#eef2ff;
  color:#3730a3;
  padding:5px 8px;
  border-radius:999px;
  font-weight:800;
}

.actions{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin-top:11px;
}

.actions button,
.actions a{
  min-height:40px;
  border-radius:14px;
  border:1px solid var(--border);
  background:#fff;
  color:#0f172a;
  padding:9px 11px;
  font-weight:850;
  text-decoration:none;
  display:inline-flex;
  align-items:center;
  justify-content:center;
}

.actions .primary,
button.primary,
a.primary{
  background:#0f172a;
  color:#fff;
  border-color:#0f172a;
}

.drawer{
  position:fixed;
  right:0;
  top:0;
  height:100%;
  width:min(520px,100%);
  background:#fff;
  z-index:2000;
  box-shadow:-18px 0 50px rgba(15,23,42,.24);
  transform:translateX(105%);
  transition:transform .22s ease;
  overflow:auto;
  border-left:1px solid var(--border);
}

.drawer.open{
  transform:translateX(0);
}

.close{
  position:sticky;
  top:8px;
  float:right;
  z-index:5;
  margin:8px;
  width:42px;
  height:42px;
  border-radius:999px;
  border:1px solid var(--border);
  background:#fff;
  font-size:28px;
  line-height:1;
}

.drawerBody{
  clear:both;
  padding:10px 18px 28px;
}

.drawer h2{
  margin:0 44px 10px 0;
  font-size:25px;
  line-height:1.12;
}

.drawer h3{
  margin:0 0 7px;
  font-size:16px;
}

.drawer p,
.drawer li{
  font-size:15px;
  line-height:1.46;
}

.pillrow{
  display:flex;
  flex-wrap:wrap;
  gap:7px;
  margin:8px 0 14px;
}

.pill{
  background:#eef2f7;
  color:#334155;
  padding:6px 9px;
  border-radius:999px;
  font-size:12px;
  font-weight:800;
}

.section{
  margin:14px 0;
}

.note{
  background:#f8fafc;
  border:1px solid var(--border);
  border-radius:16px;
  padding:12px;
}

.aiGrid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:8px;
  margin-top:8px;
}

.aiGrid button{
  min-height:42px;
  border-radius:14px;
  border:1px solid #cbd5e1;
  background:#fff;
  color:#0f172a;
  font-weight:850;
  padding:9px 10px;
}

.aiGrid button:disabled{
  opacity:.55;
}

.aiBox{
  margin:14px 0;
  padding:13px 14px;
  border-radius:16px;
  background:#f8fafc;
  border:1px solid #dbe3ef;
  line-height:1.45;
  font-size:15px;
}

.aiBox b{
  display:block;
  margin-bottom:5px;
}

.userMarker{
  background:#2563eb;
  border:3px solid #fff;
  border-radius:999px;
  box-shadow:0 0 0 4px rgba(37,99,235,.25);
}

.leaflet-popup-content button{
  min-height:36px;
  border-radius:10px;
  border:1px solid #cbd5e1;
  background:#0f172a;
  color:#fff;
  padding:7px 10px;
  font-weight:800;
}

@media(max-width:1100px){
  main{
    grid-template-columns:330px 1fr;
    grid-template-rows:1fr 42%;
  }

  .listpanel{
    grid-column:1 / 3;
    border-left:0;
    border-top:1px solid var(--border);
  }
}

@media(max-width:900px){
  html,body,#app{min-height:100%}

  .topbar{
    height:auto;
    min-height:62px;
    padding:10px 12px;
    align-items:flex-start;
    position:sticky;
    top:0;
  }

  .title{
    font-size:18px;
  }

  .subtitle{
    font-size:12px;
    max-width:52vw;
  }

  .topActions{
    gap:6px;
    max-width:48vw;
  }

  .topActions .ghost{
    min-height:38px;
    padding:8px 9px;
    font-size:12px;
  }

  main{
    height:auto;
    display:flex;
    flex-direction:column;
  }

  .controls{
    order:1;
    border-right:0;
    border-bottom:1px solid var(--border);
    padding:10px;
    overflow:visible;
  }

  .tabs{
    flex-wrap:nowrap;
    overflow-x:auto;
    -webkit-overflow-scrolling:touch;
    scrollbar-width:none;
    padding-bottom:4px;
  }

  .tabs::-webkit-scrollbar{display:none}

  .tab{
    flex:0 0 auto;
    min-height:40px;
  }

  .searchrow{
    grid-template-columns:1fr auto;
    margin-bottom:8px;
  }

  .searchrow input,
  .searchrow button{
    height:42px;
  }

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

  .layers{
    flex-direction:row;
    overflow-x:auto;
    -webkit-overflow-scrolling:touch;
    scrollbar-width:none;
    padding-bottom:3px;
  }

  .layers::-webkit-scrollbar{display:none}

  .layer{
    flex:0 0 auto;
    max-width:245px;
    border-radius:999px;
  }

  .layer span:last-child{
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
  }

  #map{
    order:2;
    height:44dvh;
    min-height:315px;
    border-bottom:1px solid var(--border);
  }

  .listpanel{
    order:3;
    border-left:0;
    border-top:0;
    min-height:auto;
  }

  .listhead{
    top:0;
  }

  .drawer{
    left:0;
    right:0;
    bottom:0;
    top:auto;
    height:auto;
    width:100%;
    max-height:88dvh;
    border-radius:22px 22px 0 0;
    transform:translateY(105%);
    box-shadow:0 -14px 40px rgba(15,23,42,.25);
    border-left:0;
  }

  .drawer.open{
    transform:translateY(0);
  }

  .drawerBody{
    padding:8px 16px 24px;
  }

  .drawer h2{
    font-size:22px;
  }

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

@media(max-width:420px){
  .subtitle{max-width:48vw}
  .topActions{max-width:46vw}
  .searchrow{grid-template-columns:1fr}
  .searchrow button{width:100%}
  .aiGrid{grid-template-columns:1fr}
  #map{height:42dvh;min-height:300px}
}

/* === AI AUDIO UX v13 === */
.audioControls{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin-top:12px;
}

.audioControls button{
  min-height:40px;
  border-radius:14px;
  border:1px solid #cbd5e1;
  background:#fff;
  color:#0f172a;
  font-weight:850;
  padding:8px 11px;
}

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

@media(min-width:700px){
  .aiGrid{
    grid-template-columns:1fr 1fr 1fr;
  }
}
/* === END AI AUDIO UX v13 === */
