:root{
  --bg:#0b1220;
  --panel:#0f1a2b;
  --panel2:#0c1626;
  --text:#e8eefc;
  --muted:#a9b5d3;
  --border:rgba(255,255,255,.08);
  --shadow:0 10px 30px rgba(0,0,0,.35);
  --primary:#3b82f6;
  --danger:#ef4444;
  --neon:#00ff88;
  /* v103: Yamato-ish accents */
  --yam-green:#06C755;
  --yam-yellow:#FFD400;
}
*{box-sizing:border-box;}
html,body{height:100%;}
body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, "Noto Sans JP", sans-serif;
  background: radial-gradient(1200px 800px at 50% -20%, rgba(59,130,246,.22), transparent 60%), var(--bg);
  color:var(--text);
  overflow:hidden;
}

.topbar{
  position:fixed; top:0; left:0; right:0;
  height: 51px;
  display:flex; align-items:center; gap:10px;
  padding:0 12px;
  background:linear-gradient(to bottom, rgba(10,18,32,.95), rgba(10,18,32,.65));
  border-bottom:1px solid var(--border);
  backdrop-filter: blur(10px);
  z-index:50;
}
.title{font-weight:800; letter-spacing:.2px; display:flex; align-items:baseline; gap:10px;}
.title .ver{opacity:.75; font-weight:700;}
.topbar-right{margin-left:auto; display:flex; align-items:center; gap:8px;}

.icon-btn{
  border:1px solid var(--border);
  background:rgba(255,255,255,.04);
  color:var(--text);
  border-radius:12px;
  height:38px; min-width: 111px;
  display:grid; place-items:center;
}

.main{
  position:fixed; top:56px; bottom:58px; left:0; right:0;
  overflow:hidden;
}
.page{
  position:absolute; inset:0;
  overflow:auto;
  padding:14px 12px 88px;
  display:none;
}
.page.active{display:block;}

.card{
  background:linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.03));
  border:1px solid var(--border);
  border-radius:18px;
  box-shadow: var(--shadow);
}
.page-card{padding:14px;}
.card-title{font-size:18px; font-weight:800; margin-bottom:10px;}

.input{
  width:100%;
  padding:12px 12px;
  border-radius:14px;
  border:1px solid var(--border);
  background:rgba(0,0,0,.25);
  color:var(--text);
  outline:none;
}
.input::placeholder{color:rgba(232,238,252,.6);}

.search-row{display:flex; gap:10px; align-items:center;}

.btn{
  border-radius:14px;
  border:1px solid var(--border);
  background:rgba(255,255,255,.04);
  color:var(--text);
  padding:12px 14px;
  font-weight:700;
}
.btn.primary{
  background: rgba(59,130,246,.85);
  border-color: rgba(59,130,246,.95);
}
.btn.danger{
  background: rgba(239,68,68,.85);
  border-color: rgba(239,68,68,.95);
}
.btn:active{transform: translateY(1px);}

.list{margin-top:12px; display:flex; flex-direction:column; gap:10px;}
.item{
  padding:12px;
  border-radius:18px;
  border:1px solid var(--border);
  background:rgba(255,255,255,.035);
  box-shadow: 0 12px 30px rgba(0,0,0,.22);
}

/* v103: page accent (Yamato colors) */
body[data-tab="search"]{
  --accent: var(--yam-green);
  --accent-bg: rgba(6,199,85,.92);
  --accent-bd: rgba(6,199,85,.95);
  --accent-border: rgba(6,199,85,.45);
  --accent-glow: rgba(6,199,85,.36);
}
body[data-tab="book"]{
  --accent: var(--yam-yellow);
  --accent-bg: rgba(255,212,0,.96);
  --accent-bd: rgba(255,212,0,.98);
  --accent-border: rgba(255,212,0,.50);
  --accent-glow: rgba(255,212,0,.40);
}

/* map + settings: green family */
body[data-tab="map"],
body[data-tab="history"]{
  --accent: var(--yam-green);
  --accent-bg: rgba(6,199,85,.92);
  --accent-bd: rgba(6,199,85,.95);
  --accent-border: rgba(6,199,85,.45);
  --accent-glow: rgba(6,199,85,.32);
}

/* headings */
body[data-tab="search"] #page-search .card-title,
body[data-tab="book"] #page-book .card-title,
body[data-tab="map"] #page-map .card-title,
body[data-tab="history"] #page-history .card-title{
  color: var(--accent);
}

/* primary buttons inside each page (keep map/settings untouched) */
body[data-tab="search"] #page-search .btn.primary,
body[data-tab="book"] #page-book .btn.primary,
body[data-tab="map"] #page-map .btn.primary,
body[data-tab="history"] #page-history .btn.primary{
  background: linear-gradient(to bottom, rgba(255,255,255,.16), rgba(0,0,0,.06)), var(--accent-bg);
  border-color: var(--accent-bd);
  color:#001018;
  box-shadow:
    0 10px 20px rgba(0,0,0,.20),
    0 0 0 1px rgba(0,0,0,.10),
    0 0 16px var(--accent-glow);
}

/* list card border + glow (B: also in detail via modal-sheet rules below) */
body[data-tab="search"] #page-search .item,
body[data-tab="book"] #page-book .item{
  border-width: .75px;
  border-color: var(--accent-border);
  box-shadow:
    0 12px 30px rgba(0,0,0,.22),
    0 0 0 2px rgba(255,255,255,.03),
    0 0 28px var(--accent-glow);
}

/* header card border + glow (match list cards) */
body[data-tab="search"] #page-search .page-card{
  border-width: .75px;
  border-color: var(--accent-border);
  box-shadow:
    0 12px 30px rgba(0,0,0,.22),
    0 0 0 2px rgba(255,255,255,.03),
    0 0 28px var(--accent-glow);
}

/* active tab highlight */
body[data-tab="search"] .tab[data-tab="search"].active,
body[data-tab="book"] .tab[data-tab="book"].active,
body[data-tab="map"] .tab[data-tab="map"].active,
body[data-tab="history"] .tab[data-tab="history"].active{
  color: var(--accent);
}

/* v90: 荷主管理カードだけ「開く」を右上に固定（誤操作防止＆見た目統一） */
.shipper-item{position:relative;}
.shipper-item .item-left{padding-right:110px;}
.shipper-item .shipper-actions{
  position:absolute;
  top:50%;
  right:12px;
  width:auto;
  margin-left:0;
  transform: translateY(-50%);
}
/* v91: 「開く」ボタンサイズをアドレス帳（.smallbtn）と完全一致させる */
.shipper-item .shipper-actions .shipper-openbtn{width:88px; padding:0;}

/* Shipper page head (only within page-search) */
.shipper-head{position:relative; display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:10px; min-height:64px;}
.shipper-head-left{display:flex; align-items:center; gap:10px; min-width:0;}
.shipper-title{
  position:absolute;
  left:50%;
  transform:translateX(-50%);
  display:flex;
  align-items:center;
  justify-content:center;
  min-height:54px;
  line-height:1;
  width:max-content;
  white-space:nowrap;
  pointer-events:none;
}
.shipper-cat{
  /* v143: cat shifted left while keeping title position */
  width: 118px;
  height: 54px;
  flex: 0 0 auto;
  margin-left: -18px;
}

.shipper-add{height:44px; padding:0 14px; border-radius:16px; font-weight:900; white-space:nowrap;}

/* Shipper list badges + memo preview */
.shipper-badges{display:flex; flex-wrap:wrap; gap:8px; margin-top:8px;}
.badge{display:inline-flex; align-items:center; gap:6px; padding:6px 10px; border-radius:12px; border:1px solid rgba(255,255,255,.08); background:rgba(255,255,255,.04); font-size:12px; font-weight:900; letter-spacing:.1px;}
.badge.count{color: var(--yam-yellow); border-color: rgba(255,212,0,.30); background: rgba(255,212,0,.12);}
.badge.memo.has{color: var(--yam-green); border-color: rgba(6,199,85,.30); background: rgba(6,199,85,.12);}
.badge.memo.none{color: rgba(232,238,252,.70);}
.badge.map{color: rgba(255,120,120,.95); border-color: rgba(255,120,120,.28); background: rgba(255,120,120,.10); cursor:pointer;}
.badge .bico{font-size:12px; line-height:1; opacity:.95;}
.shipper-memo-preview{margin-top:8px; font-size:13px; color: rgba(232,238,252,.86); white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.item-top{display:flex; gap:10px; align-items:flex-start;}
.item-title{font-size:16px; font-weight:900;}
.name-ico{display:inline-block; margin-right:8px; font-size:1em; line-height:1; vertical-align:-0.08em;}
.name-text{display:inline-block;}
.item-sub{font-size:13px; color:var(--muted); margin-top:4px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.item-tags{margin-top:8px; display:flex; gap:8px; flex-wrap:wrap;}
.tag{
  font-size:12px; font-weight:800;
  padding:6px 10px;
  border-radius:999px;
  background:rgba(255,255,255,.05);
  border:1px solid var(--border);
  color:var(--text);
}
.tag.ok{background:rgba(59,130,246,.15); border-color:rgba(59,130,246,.35);}

.item-actions{margin-left:auto; display:flex; flex-direction:column; gap:8px; align-items:flex-end; width:104px;}
.smallbtn{height:44px;border-radius:16px;border:1px solid rgba(255,255,255,.08);background:rgba(255,255,255,.03);color:#fff;font-weight:900;font-size:16px;width:88px;display:flex;align-items:center;justify-content:center;white-space:nowrap}
/* Map button tweaks */
.mapbtn .label{font-size:16px;font-weight:900;color:#fff;}
/* icon spacing handled below */
.mapreg{width:110px;}

/* remove extra inner padding coming from .btn */
.btn.smallbtn{padding:0;}

/* v60: add buttons in edit modal (avoid overflow) */
.addbtn{height:44px;border-radius:16px;border:1px solid rgba(255,255,255,.08);background:rgba(255,255,255,.03);color:#fff;font-weight:900;font-size:14px;padding:0 14px;display:inline-flex;align-items:center;justify-content:center;white-space:nowrap;width:auto;max-width:100%;}

.mapbtn{height:44px;border-radius:16px;border:1px solid rgba(255,255,255,.08);background:rgba(255,255,255,.03);color:#fff;font-weight:900;font-size:16px;width:88px;display:flex;align-items:center;justify-content:center;gap:0;line-height:1;white-space:nowrap}
.mapbtn .ico{
  font-size:14px;
  line-height:1;
  /* Nudge the icon slightly downward to match the text baseline */
  position:relative;
  top:2px;
  /* Reduce the gap between icon and label */
  margin-right:2px;
}

.muted{color:var(--muted);}
.small{font-size:12px;}

.tabbar{
  position:fixed; left:0; right:0; bottom:0;
  /* v122: compact tabbar */
  height:60px;
  display:flex;
  padding:6px 8px calc(8px + env(safe-area-inset-bottom));
  background:linear-gradient(to top, rgba(6,10,16,.96), rgba(10,18,32,.72));
  border-top:1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index:50;
}
/* NOTE: 下部の“バー”(ホームインジケータ風)は不要なので表示しない */
.tabbar::after{display:none;}

.tab{
  flex:1;
  border:none;
  background:transparent;
  color:rgba(232,238,252,.62);
  font-weight:900;
  letter-spacing:.2px;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:4px;
  padding-top:0;
}
.tab.active{color:var(--neon);}

.tab-icon{display:inline-flex; align-items:center; justify-content:center; height:26px;}
.tab-icon .ico{width:24px; height:24px; display:block;}
.tab-icon .tab-ico{
  width:26px; height:26px; display:block;
  background: currentColor;
  -webkit-mask: var(--ico) center/contain no-repeat;
  mask: var(--ico) center/contain no-repeat;
}
/* Glow only when active */
.tab.active .tab-ico{
  filter: drop-shadow(0 0 8px rgba(0,255,136,.70))
          drop-shadow(0 0 18px rgba(0,255,136,.35));
}
/* Align all labels (slightly smaller) */
.tab-label{font-size:13px; line-height:1; white-space:nowrap;}

/* MAP */
#page-map{padding:0;}
#map{position:absolute; inset:0;}
.center-marker{
  position:absolute;
  left:50%; top:50%;
  width:44px; height:44px;
  transform:translate(-50%,-50%);
  border-radius:999px;
  border:2px solid rgba(59,130,246,.9);
  box-shadow: 0 0 0 8px rgba(59,130,246,.12);
  pointer-events:none;
}
/* "＋ピン"表示（中心固定） */
.center-marker::before,
.center-marker::after{
  content:"";
  position:absolute;
  left:50%; top:50%;
  transform:translate(-50%,-50%);
  background:rgba(59,130,246,.95);
  border-radius:2px;
}
.center-marker::before{ width:18px; height:2px; }
.center-marker::after{ width:2px; height:18px; }

/* Leaflet crosshair (divIcon) — used during "地図登録" to keep the ＋ピン persistent */
.crosshair-icon{ background:transparent; border:none; }
.crosshair-plus{
  width:44px; height:44px;
  border-radius:999px;
  border:2px solid rgba(59,130,246,.9);
  box-shadow: 0 0 0 8px rgba(59,130,246,.12);
  position:relative;
}
.crosshair-plus::before,
.crosshair-plus::after{
  content:"";
  position:absolute;
  left:50%; top:50%;
  transform:translate(-50%,-50%);
  background:rgba(59,130,246,.95);
  border-radius:2px;
}
.crosshair-plus::before{ width:18px; height:2px; }
.crosshair-plus::after{ width:2px; height:18px; }

/* Avoid double center markers while placing */
body.placingpin .center-marker{ display:none; }
.pinbar{
  position:absolute;
  right:calc(10px + env(safe-area-inset-right)); bottom:calc(72px + env(safe-area-inset-bottom));
  left:auto;
  display:flex; align-items:center; justify-content:flex-end;
  padding:0;
  background:transparent;
  border:none;
  box-shadow:none;
  backdrop-filter:none;
  z-index:400;
}
.pinbar-title{font-weight:900;}
.pinbar-desc{font-size:12px; color:var(--muted); margin-top:2px;}
.pinbar-left{flex:1; min-width:0;}
.pinbar-btn{
  width:56px;
  height:56px;
  padding:0;
  border-radius:9999px;
  font-size:28px;
  line-height:1;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  white-space:nowrap;
}
.maphint{
  position:absolute;
  left:12px; right:12px; bottom:140px;
  padding:10px 12px;
  border-radius:14px;
  background:rgba(12,22,38,.60);
  border:1px solid rgba(255,255,255,.06);
  color:rgba(232,238,252,.78);
  font-size:12px;
  z-index:350;
}

/* Leaflet tweaks */
.leaflet-control-zoom{
  box-shadow:none;
  border:1px solid var(--border);
  border-radius:14px;
  overflow:hidden;
}
.leaflet-control-zoom a{
  background:rgba(12,22,38,.88);
  color:var(--text);
  border:none;
}

/* MODAL */
.modal{position:fixed; inset:0; z-index:1000;}
.modal-backdrop{position:absolute; inset:0; background:rgba(0,0,0,.55);}
.modal-sheet{
  position:absolute; left:12px; right:12px; bottom:12px;
  border-radius:22px;
  background:rgba(12,22,38,.95);
  border:1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  overflow:hidden;
  display:flex;
  flex-direction:column;
  max-height: calc(100vh - 24px);
  max-height: calc(100svh - 24px);
  max-height: calc(100dvh - 24px);
}

/* v103: modal border + glow per page (B: show accent on detail cards too) */
#modal[data-tab="search"] .modal-sheet,
#modal[data-tab="book"] .modal-sheet{
  border-width: .75px;
  border-color: var(--accent-border);
  box-shadow:
    0 18px 44px rgba(0,0,0,.42),
    0 0 0 2px rgba(255,255,255,.03),
    0 0 34px var(--accent-glow);
}

/* v53: Card detail overlay position (keep overlay, just shift it upward) */
.modal.pos-top .modal-sheet{
  top: 72px;
  bottom: auto;
  min-height: 56vh;
  min-height: 56svh;
  min-height: 56dvh;
  max-height: calc(100vh - 84px);
  max-height: calc(100svh - 84px);
  max-height: calc(100dvh - 84px);
}
.modal-header{display:flex; align-items:center; padding:12px 12px; border-bottom:1px solid rgba(255,255,255,.06);}
.modal-title{font-weight:900;}
.modal-header .icon-btn{margin-left:auto;}
.modal-body{
  padding:12px;
  display:flex;
  flex-direction:column;
  gap:10px;
  overflow:auto;
  -webkit-overflow-scrolling: touch;
  flex: 1 1 auto;
}
.field{display:flex; flex-direction:column; gap:6px;}
.label{font-size:12px; color:var(--muted); font-weight:800;}
.modal-actions{display:flex; gap:10px; padding:12px; border-top:1px solid rgba(255,255,255,.06); flex:0 0 auto;}
.modal-actions .btn{flex:1;}

hr.sep{border:none; border-top:1px solid rgba(255,255,255,.08); margin:6px 0;}

@media (min-width: 740px){
  .page{padding-left:18px; padding-right:18px;}
  .pinbar{left:18px; right:18px;}
  .maphint{left:18px; right:18px;}
}

.namelist{display:flex; flex-direction:column; gap:10px; margin-bottom:10px;}

.modal-header{display:flex;align-items:center;gap:10px;}
.modal-header-actions{margin-left:auto;display:flex;gap:8px;align-items:center;}
.modal-header-actions .btn{padding:10px 12px;border-radius:12px;font-weight:900;}
.modal-header-actions .btn.primary{background:var(--accent);color:#001018;border:none;}
.modal-actions{display:flex;gap:10px;}

/* v14: header buttons (編集/地図) */
.modal-header-actions{gap:6px;}
.hdrbtn{
  background: rgba(77,163,255,0.22);
  border: 1px solid rgba(77,163,255,0.55);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  font-weight: 1000;
}

/* v15: force header actions to right, next to close */
.modal-header{align-items:center;}
.modal-title{flex:0 0 auto;}
.modal-header-actions{
  flex: 1 1 auto;
  display:flex;
  justify-content:flex-end;
  margin-left:auto;
}
#modalClose{flex:0 0 auto;}

/* v50: "未整理"一覧は上部（ヘッダー）を一切使わない。ブラウザUIに被らないよう、
   モーダル上部を消して本文から始める */
.modal.noheader .modal-header{display:none;}
.modal.noheader .modal-body{padding-top:12px;}

.booknew{white-space:nowrap; padding:12px 16px; border-radius:16px;}

/* v18: big centered New button on book page */
.book-new-center{display:flex;justify-content:center;margin-top:18px;}
.booknew{
  white-space:nowrap;
  padding:16px 26px;
  border-radius:18px;
  font-weight:1000;
  min-width: 62%;
}

/* v19: list card typography */
.item-address{font-weight:1000; opacity:0.95; margin-top:4px;}
/* v54: phone typography should match the name (size/weight) */
.item-phone{
  font-size:16px;
  font-weight:900;
  opacity:1;
  margin-top:6px;
  color:var(--text);
  /* 電話番号みたいに“区切りなしの長い文字列”でもボタン側を押し出さない */
  overflow-wrap:anywhere;
  word-break:break-word;
}

/* v54: detail overlay phone typography should match the name (size/weight) */
.detail-phone{font-size:20px; font-weight:900; color:var(--text); opacity:1;}

/* v55: icons for detail overlay rows (address / phone / memo / map) */
.detail-address,
.detail-phone,
.detail-memo,
.detail-map{
  display:flex;
  align-items:baseline;
  gap:10px;
}
.detail-address .ico,
.detail-phone .ico,
.detail-memo .ico,
.detail-map .ico{
  width:22px;
  min-width:22px;
  text-align:center;
  font-size:16px;
  line-height:1;
  position:relative;
  top:2px;
}
.detail-address .line-text,
.detail-phone .line-text,
.detail-memo .line-text,
.detail-map .line-text{
  min-width:0;
  overflow-wrap:anywhere;
}

/* v97: メモは改行(\n)も表示しつつ自然に折り返す */
.detail-memo .line-text{
  white-space: pre-wrap;
  word-break: break-word;
}
.detail-memo{margin-top:6px;}
.detail-map{margin-top:6px;}

/* v20: detail card address 강조 */
.detail-address{
  font-size: 20px;
  color: var(--text);
  opacity: 0.98;
  white-space: normal;
  overflow-wrap: anywhere;
  margin-top: 6px;
}

/* v22: keep 'Open' button size consistent even when map button wraps */




/* v23: right-align map button label */


/* v25: keep '開く' button size fixed (never stretches) */
.openbtn{
  height: 44px;
  min-height: 44px;
  max-height: 44px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}




/* v33: map button text should be tight (no extra spacing), keep colors unchanged */
.mapbtn, .mapbtn-tight{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:0;
  white-space:nowrap;
}

.mapbtn{writing-mode: horizontal-tb;}

.mapbtn .label{line-height:1;}

/* v37: right-side action buttons (開く/地図/地図登録) - symmetric spacing & centered text */
.item-actions .btn.smallbtn,
.item-actions .btn.smallbtn.openbtn,
.item-actions .btn.smallbtn.mapbtn{
  height: 44px;
  min-height: 44px;
  max-height: 44px;
  padding: 0 10px;              /* tighter like v22 */
  display: flex;
  align-items: center;          /* vertical center */
  justify-content: center;      /* horizontal center */
  line-height: 1;              /* avoid bottom-heavy baseline */
  font-size: 16px;             /* match name feeling */
  font-weight: 1000;           /* match name weight */
  color: #fff;                 /* white text */
  white-space: nowrap;         /* no wrap (地図登録 1行) */
}

/* keep icon/text slightly separated only for 地図 (single small gap) */
.item-actions .btn.smallbtn.mapbtn{
  gap: 8px;
}

/* remove any accidental opacity making text gray */
.item-actions .btn.smallbtn,
.item-actions .btn.smallbtn *{
  opacity: 1 !important;
}

/* ensure 地図登録 never turns vertical writing */
.item-actions .btn.smallbtn{ writing-mode: horizontal-tb; }

/* ボタン文字を少し下げる（2px） */
.item-actions .btn.smallbtn .btntext,
.item-actions .btn.smallbtn.mapbtn .label,
.card-actions .btn.smallbtn .btntext,
.card-actions .btn.smallbtn.mapbtn .label{
  position: relative;
  top: 2px;
}

/* v41: move map icon+text together */
.mapwrap{position:relative; top:2px; display:inline-flex; align-items:center; gap:6px;}


/* v58: improve readability in card detail overlay (more spacing + separators) */
.sep{
  border:0;
  border-top:1px solid var(--border);
  margin:12px 0;
  opacity:0.9;
}
.detail-address,
.detail-phone,
.detail-memo,
.detail-map{
  padding:10px 0;
  margin-top:0 !important;
}
