@import url('https://fonts.googleapis.com/css2?family=Zen+Kaku+Gothic+New:wght@500;700;900&family=Noto+Sans+JP:wght@400;500;700&family=Barlow+Condensed:wght@500;600;700&display=swap');

:root {
  --navy: #0a1a3a;
  --navy-2: #13295a;
  --navy-ink: #24345a;
  --orange: #ff8c42;
  --orange-deep: #ff6a2c;
  --paper: #ffffff;
  --mist: #f2f4f8;
  --line: #dfe3ec;
  --muted: #5b6680;
  --ok: #1f8a5b;
  --radius: 18px;
  --tap: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font-display: 'Zen Kaku Gothic New', 'Hiragino Sans', 'Noto Sans JP', sans-serif;
  --font-body: 'Noto Sans JP', 'Hiragino Sans', sans-serif;
  --font-num: 'Barlow Condensed', 'Zen Kaku Gothic New', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  color: var(--navy);
  background: var(--paper);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, a { font-family: inherit; }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; letter-spacing: .01em; }

/* ---- 共通パーツ ---- */
.demo-badge {
  position: fixed; top: calc(env(safe-area-inset-top, 0px) + 8px); left: 50%; transform: translateX(-50%);
  z-index: 50; font-size: 11px; font-weight: 700; letter-spacing: .08em;
  background: rgba(10,26,58,.86); color: #fff; padding: 3px 10px; border-radius: 99px;
  pointer-events: none;
}
.avatar {
  width: 48px; height: 48px; border-radius: 50%; overflow: hidden; flex: none;
  background: var(--navy-2); color: #fff; display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: 20px;
  box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--orange);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: var(--tap); width: 100%; border: 0; border-radius: 14px;
  font-size: 18px; font-weight: 700; cursor: pointer; text-decoration: none;
  transition: transform .08s ease, filter .15s ease;
}
.btn:active { transform: scale(.98); }
.btn-go { background: linear-gradient(180deg, var(--orange), var(--orange-deep)); color: #fff; box-shadow: 0 6px 16px rgba(255,106,44,.32); }
.btn-navy { background: var(--navy); color: #fff; }
.btn-ghost { background: var(--mist); color: var(--navy); }
.btn-line { background: #fff; color: var(--navy); border: 2px solid var(--line); }
.btn svg { width: 22px; height: 22px; flex: none; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translate(-50%, 20px);
  background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 15px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 80; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- 地図のピン（顔写真＋進行方向） ---- */
.pin { position: relative; width: 64px; height: 64px; transition: opacity .3s ease; }
.pin .heading {
  position: absolute; inset: -14px; transition: transform .6s linear;
}
.pin .heading::before {
  content: ''; position: absolute; left: 50%; top: 0; transform: translateX(-50%);
  border-left: 11px solid transparent; border-right: 11px solid transparent; border-bottom: 16px solid var(--orange-deep);
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.25));
}
.pin .ring {
  position: absolute; inset: 0; border-radius: 50%; background: rgba(255,140,66,.35);
  animation: ring 2.2s ease-out infinite;
}
.pin .face {
  position: absolute; inset: 6px; border-radius: 50%; overflow: hidden; background: var(--navy-2);
  border: 3px solid #fff; box-shadow: 0 4px 12px rgba(10,26,58,.35);
  display: grid; place-items: center; color: #fff; font-family: var(--font-display); font-weight: 700; font-size: 22px;
}
.pin .face img { width: 100%; height: 100%; object-fit: cover; }
.pin.stale { opacity: .45; }
.pin.stale .ring { animation: none; opacity: 0; }
@keyframes ring { 0% { transform: scale(.85); opacity: .9; } 100% { transform: scale(1.7); opacity: 0; } }

.dest-pin {
  position: absolute; left: 0; top: 0;
  width: 34px; height: 34px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  background: var(--navy); border: 3px solid #fff; box-shadow: 0 3px 8px rgba(10,26,58,.4);
}
.dest-pin::after { content: ''; position: absolute; width: 10px; height: 10px; background: #fff; border-radius: 50%; left: 9px; top: 9px; }

@media (prefers-reduced-motion: reduce) {
  .pin .ring { animation: none; }
  .pin .heading { transition: none; }
  * { scroll-behavior: auto !important; }
}

.maplibregl-ctrl-attrib { font-size: 10px; }

/* ===== ステップ2：アプリ画面の共通部品 ===== */
.app-head {
  background: var(--navy); color: #fff; padding: calc(env(safe-area-inset-top,0px) + 14px) 16px 16px;
  display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 20;
}
.app-head h1 { font-family: var(--font-display); font-size: 19px; margin: 0; font-weight: 700; flex: 1; }
.icon-btn {
  min-width: 48px; min-height: 48px; border: 0; background: transparent; color: inherit; border-radius: 12px;
  display: inline-grid; place-items: center; cursor: pointer; text-decoration: none; font-size: 15px; font-weight: 700; padding: 0 8px;
}
.icon-btn svg { width: 26px; height: 26px; }
.page { max-width: 560px; margin: 0 auto; padding: 18px 16px calc(120px + var(--safe-b)); }
.panel { background: #fff; border-radius: var(--radius); padding: 18px; margin-bottom: 14px; box-shadow: 0 2px 10px rgba(10,26,58,.06); }
.panel h2 { font-family: var(--font-display); font-size: 16px; margin: 0 0 12px; }

.field { display: block; margin-bottom: 16px; }
.field > span.lbl { display: block; font-weight: 700; font-size: 15px; margin-bottom: 6px; }
.field > span.lbl em { font-style: normal; font-size: 12px; font-weight: 700; color: #b5410f; margin-left: 6px; }
.field small { display: block; color: var(--muted); font-size: 13px; margin-top: 6px; line-height: 1.5; }
.input, select.input, textarea.input {
  width: 100%; min-height: 54px; border: 2px solid var(--line); border-radius: 12px; padding: 12px 14px;
  font-size: 17px; font-family: inherit; color: var(--navy); background: #fff; -webkit-appearance: none; appearance: none;
}
select.input { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 22px) 50%, calc(100% - 16px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 40px; }
.input:focus { border-color: var(--navy); outline: none; box-shadow: 0 0 0 3px rgba(255,140,66,.35); }
.row2 { display: grid; grid-template-columns: 1.3fr 1fr; gap: 10px; }
.form-error { background: #fff1e8; color: #9a3a0e; border-radius: 12px; padding: 12px 14px; font-size: 15px; margin: 0 0 14px; font-weight: 500; }
.hint { color: var(--muted); font-size: 14px; }

.photo-pick { display: flex; align-items: center; gap: 16px; }
.photo-pick .avatar { width: 88px; height: 88px; font-size: 32px; }
.photo-pick label.btn { width: auto; flex: 1; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.map-box { height: 260px; border-radius: 14px; overflow: hidden; border: 2px solid var(--line); margin-top: 10px; position: relative; }
.map-state { font-size: 13px; margin-top: 6px; font-weight: 700; }
.map-state.ok { color: var(--ok); }
.map-state.ng { color: #b5410f; }
.inline-btn { display: flex; gap: 8px; }
.inline-btn .input { flex: 1; }
.inline-btn .btn { width: auto; padding: 0 16px; font-size: 15px; white-space: nowrap; }

.list-item { display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 14px; padding: 14px 16px; margin-bottom: 10px; text-decoration: none; color: var(--navy); min-height: 72px; box-shadow: 0 2px 10px rgba(10,26,58,.06); }
.list-item b { display: block; font-family: var(--font-display); font-size: 17px; }
.list-item span.s { display: block; font-size: 13px; color: var(--muted); }
.list-item svg.chev { margin-left: auto; flex: none; width: 20px; height: 20px; color: var(--muted); }
#list .list-head { display: none; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.empty b { display: block; font-family: var(--font-display); color: var(--navy); font-size: 17px; margin-bottom: 6px; }

.radio-row { display: grid; gap: 8px; }
.radio-row label { display: flex; align-items: center; gap: 10px; min-height: 52px; border: 2px solid var(--line); border-radius: 12px; padding: 0 14px; font-weight: 500; cursor: pointer; }
.radio-row input { width: 22px; height: 22px; accent-color: var(--orange-deep); }
.radio-row label:has(input:checked) { border-color: var(--navy); }

.fab-bar { position: fixed; left: 0; right: 0; bottom: calc(64px + var(--safe-b)); padding: 10px 16px; z-index: 15; pointer-events: none; }
.fab-bar .btn { max-width: 528px; margin: 0 auto; pointer-events: auto; }
.save-bar { position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--line); padding: 10px 16px calc(10px + var(--safe-b)); z-index: 15; }
.save-bar .btn { max-width: 528px; margin: 0 auto; }
.btn-danger { background: #fff; color: #b5410f; border: 2px solid #f3c7b2; }
.btn[disabled] { opacity: .6; pointer-events: none; }

nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(3, 1fr); padding-bottom: var(--safe-b); z-index: 20;
}
nav.tabs a { min-height: 64px; display: grid; place-items: center; gap: 2px; font-size: 12px; font-weight: 700; color: var(--muted); padding: 8px 0; text-decoration: none; }
nav.tabs a svg { width: 24px; height: 24px; }
nav.tabs a[aria-current="page"] { color: var(--navy); }
nav.tabs a[aria-current="page"] svg { color: var(--orange-deep); }
[hidden] { display: none !important; }
.field span.lbl em { font-style: normal; font-size: 12px; font-weight: 700; color: #b5410f; margin-left: 6px; }

/* ===== デスクトップ（幅700px以上）での見せ方 ===== */
@media (min-width: 700px) {
  body { padding-top: 60px; }
  .page { max-width: 760px; padding-left: 32px; padding-right: 32px; }
  .app-head { position: static; background: transparent; color: var(--navy); padding-top: 22px; padding-bottom: 4px; padding-left: calc(50% - 380px); padding-right: calc(50% - 380px); }
  .panel { padding: 26px 28px; }
  .field { margin-bottom: 20px; }
  .map-box { height: 340px; }

  /* ① メニューは上部のバーへ（下端のタブバーは使わない） */
  nav.tabs {
    top: 0; bottom: auto; left: 0; right: 0; transform: none; width: auto; max-width: none; height: 60px;
    border: 0; border-bottom: 1px solid var(--line); border-radius: 0; box-shadow: none;
    display: flex; align-items: stretch; justify-content: center; gap: 4px; padding: 0 20px;
  }
  nav.tabs .brand-mini { position: absolute; left: 28px; top: 50%; transform: translateY(-50%); }
  nav.tabs a { display: flex; flex-direction: row; gap: 8px; align-items: center; min-height: 44px; padding: 0 20px; font-size: 14px; border-radius: 10px; }
  nav.tabs a[aria-current="page"] { background: var(--mist); }
  nav.tabs a svg { width: 20px; height: 20px; }

  /* 追加ボタンは右下の浮かんだボタンに */
  .fab-bar { left: auto; right: 36px; bottom: 36px; transform: none; width: auto; padding: 0; }
  .fab-bar .btn { max-width: none; width: auto; padding: 0 28px; border-radius: 999px; min-height: 58px; }

  /* ② フォームは2列組み（対になる入力欄だけ横並び） */
  form.panel { display: grid; grid-template-columns: 1fr 1fr; column-gap: 22px; align-items: start; }
  form.panel .field { grid-column: 1 / -1; }
  form.panel .row2 { grid-column: 1 / -1; }
  form.panel .field:has(select[name=client_id]),
  form.panel .field:has(input[name=date]),
  form.panel .field:has(input[name=company]),
  form.panel .field:has(input[name=contact_name]) { grid-column: auto; }
  form.panel .field:has(input[name=date]) > div { display: flex; gap: 8px; }
  form.panel .field:has(input[name=date]) input { min-width: 0; }

  /* ③ 一覧は表形式（見出し行つき） */
  #list { display: block; background: #fff; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; box-shadow: 0 2px 10px rgba(10,26,58,.06); }
  #list .list-head { display: grid; grid-template-columns: 280px 1fr 20px; gap: 12px; align-items: center; padding: 12px 18px 10px; font-size: 13px; font-weight: 700; color: var(--muted); border-bottom: 2px solid var(--line); }
  #list .list-head b { font-weight: 700; }
  #list .list-item { border-radius: 0; margin: 0; box-shadow: none; border-bottom: 1px solid var(--line); min-height: 60px; }
  #list .list-item:last-child { border-bottom: 0; }
  #list .list-item > div:first-child { display: grid; grid-template-columns: 280px 1fr; gap: 12px; align-items: baseline; flex: 1; min-width: 0; }
  #list .list-item span.s { margin-top: 0; align-self: center; }

  /* 予定カード（ホーム）は2列のカード並びに */
  body > main { max-width: 940px; }
  #today-list, #later { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; align-items: start; }
  #today-list .visit, #later .visit { margin-bottom: 0; }
  #later .section-h { grid-column: 1 / -1; }
  #today-list .panel { grid-column: 1 / -1; }
  body > main.page { padding-bottom: calc(180px + var(--safe-b)); }
  body > header.top { max-width: 940px; margin: 16px auto 0; border-radius: 24px; }
}
.brand-mini { display: none; align-items: center; gap: 8px; font-family: var(--font-num); font-weight: 700; font-size: 22px; letter-spacing: .02em; }
.brand-mini i { width: 10px; height: 10px; border-radius: 50%; background: var(--orange); }
