/* ============================================================
   ねこさんぽ — スマホ向けスタイル
   ============================================================ */
:root {
  --bg: #fdf6ec;
  --card: #ffffff;
  --ink: #4a3b2c;
  --ink-sub: #9b8a75;
  --accent: #f59e4c;
  --accent-deep: #e07f28;
  --accent-soft: #fde8cf;
  --green: #7bb661;
  --red: #e4694f;
  --line: #f0e3d0;
  --shadow: 0 2px 10px rgba(120, 90, 40, .10);
  --radius: 16px;
  --tabbar-h: 62px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overscroll-behavior-y: none;
}

body {
  font-family: "Hiragino Maru Gothic ProN", "BIZ UDGothic", "Yu Gothic", "Meiryo", sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  max-width: 520px;
  margin: 0 auto;
}

/* ---------------- ヘッダー ---------------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
  background: linear-gradient(180deg, #fff3e0, var(--bg));
  border-bottom: 1px solid var(--line);
}

.app-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: .06em;
}
.app-title .paw { font-size: 1.05rem; }

.icon-btn {
  border: none;
  background: var(--card);
  border-radius: 50%;
  width: 38px;
  height: 38px;
  font-size: 1.05rem;
  box-shadow: var(--shadow);
  cursor: pointer;
  color: var(--ink);
}
.icon-btn:active { transform: scale(.92); }

/* ---------------- メイン / タブ ---------------- */
.app-main {
  padding: 12px 14px calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 16px);
}

.tab-pane { display: none; }
.tab-pane.active { display: block; animation: fadein .25s ease; }

@keyframes fadein {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.tab-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 520px;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex;
  background: #fffdf8;
  border-top: 1px solid var(--line);
  z-index: 600;
}

.tab-btn {
  flex: 1;
  border: none;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: .68rem;
  color: var(--ink-sub);
  cursor: pointer;
}
.tab-btn .tab-icon { font-size: 1.35rem; filter: grayscale(1) opacity(.55); }
.tab-btn.active { color: var(--accent-deep); font-weight: 700; }
.tab-btn.active .tab-icon { filter: none; transform: translateY(-1px); }

/* ---------------- カード共通 ---------------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.card-title { font-size: 1rem; margin-bottom: 8px; }
.card-sub { font-size: .78rem; color: var(--ink-sub); margin-bottom: 12px; }

/* ---------------- さんぽタブ ---------------- */
.walk-map {
  height: 42vh;
  min-height: 240px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 1;
  background: #e8e0d0;
}

.gps-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .75rem;
  color: var(--ink-sub);
  margin: 8px 4px 10px;
}
.gps-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: #c9bda9;
  flex: none;
}
.gps-dot.ok   { background: var(--green); box-shadow: 0 0 6px var(--green); }
.gps-dot.bad  { background: var(--red); }
.gps-dot.wait { background: var(--accent); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .3; } }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.stat-card {
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 10px 4px;
  text-align: center;
}
.stat-label { font-size: .68rem; color: var(--ink-sub); margin-bottom: 3px; }
.stat-value { font-size: 1.12rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: .62rem; font-weight: 400; color: var(--ink-sub); }

.walk-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.btn-walk {
  width: 100%;
  border: none;
  border-radius: 999px;
  padding: 15px 20px;
  font-size: 1.08rem;
  font-weight: 700;
  font-family: inherit;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  transition: transform .1s;
}
.btn-walk:active { transform: scale(.97); }
.btn-walk.start {
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  box-shadow: 0 4px 14px rgba(224, 127, 40, .4);
}
.btn-walk.stop {
  background: linear-gradient(135deg, #ec7f68, var(--red));
  box-shadow: 0 4px 14px rgba(228, 105, 79, .4);
}
.btn-walk-icon { font-size: 1.4rem; }

.btn-demo {
  border: 1px dashed var(--ink-sub);
  background: none;
  color: var(--ink-sub);
  font-family: inherit;
  font-size: .74rem;
  border-radius: 999px;
  padding: 6px 16px;
  cursor: pointer;
}

/* ---------------- たびタブ ---------------- */
.journey-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  background: linear-gradient(135deg, #fff3e0, #ffe7c7);
}
.journey-cat svg { width: 74px; height: 74px; display: block; }
.journey-cat-name { font-weight: 700; font-size: 1rem; }
.journey-total { font-size: .82rem; color: var(--accent-deep); margin-top: 4px; font-weight: 700; }
.journey-next { font-size: .74rem; color: var(--ink-sub); margin-top: 4px; }

.journey-map-wrap { overflow: hidden; }
#journey-svg { width: 100%; height: auto; display: block; }

.souvenir-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.souvenir {
  background: var(--accent-soft);
  border-radius: 14px;
  padding: 10px 4px 8px;
  text-align: center;
  position: relative;
}
.souvenir .s-icon { font-size: 1.6rem; display: block; }
.souvenir .s-name { font-size: .62rem; margin-top: 4px; display: block; color: var(--ink); }
.souvenir .s-req  { font-size: .58rem; color: var(--ink-sub); display: block; }
.souvenir.locked { background: #f3ede2; }
.souvenir.locked .s-icon { filter: grayscale(1) opacity(.35); }
.souvenir.locked .s-name { color: var(--ink-sub); }
.souvenir.new::after {
  content: "NEW";
  position: absolute;
  top: -6px; right: -4px;
  background: var(--red);
  color: #fff;
  font-size: .55rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 2px 6px;
}

/* ---------------- きろくタブ ---------------- */
.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.cal-month { font-weight: 700; font-size: 1rem; }

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: .68rem;
  color: var(--ink-sub);
  margin-bottom: 4px;
}
.cal-weekdays .sun { color: var(--red); }
.cal-weekdays .sat { color: #5b8fd4; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-day {
  aspect-ratio: 1;
  border: none;
  background: none;
  border-radius: 12px;
  font-family: inherit;
  font-size: .8rem;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
}
.cal-day:disabled { opacity: 0; pointer-events: none; }
.cal-day.walked { background: var(--accent-soft); font-weight: 700; }
.cal-day.walked::after { content: "🐾"; font-size: .6rem; line-height: 1; }
.cal-day.today { outline: 2px solid var(--accent); }
.cal-day.selected { background: var(--accent); color: #fff; }
.cal-day.selected::after { filter: brightness(3); }

.day-detail-list .walk-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--line);
}
.day-detail-list .walk-item:last-child { border-bottom: none; }
.walk-item .w-icon { font-size: 1.3rem; }
.walk-item .w-main { flex: 1; }
.walk-item .w-time { font-size: .72rem; color: var(--ink-sub); }
.walk-item .w-stats { font-size: .82rem; font-weight: 700; margin-top: 2px; }
.empty-note { font-size: .78rem; color: var(--ink-sub); }

.summary-month { font-size: .82rem; line-height: 1.9; }
.summary-month b { color: var(--accent-deep); }

/* ---------------- モーダル ---------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(74, 59, 44, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal-backdrop[hidden] { display: none; }

.modal {
  background: var(--card);
  border-radius: 20px;
  padding: 22px 20px;
  width: 100%;
  max-width: 360px;
  max-height: 82vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,.25);
  animation: pop .22s ease;
}
@keyframes pop {
  from { opacity: 0; transform: scale(.92); }
  to   { opacity: 1; transform: none; }
}

.modal-title { font-size: 1.05rem; text-align: center; margin-bottom: 16px; }

.field { display: block; margin-bottom: 14px; }
.field-label { display: block; font-size: .8rem; margin-bottom: 5px; }
.field-label small { color: var(--ink-sub); font-size: .68rem; }
.field input[type="number"] {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 1rem;
  font-family: inherit;
  background: #fffdf8;
  color: var(--ink);
}
.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.field-row .field-label { margin-bottom: 0; flex: 1; }
.field-row input[type="checkbox"] {
  width: 24px; height: 24px;
  accent-color: var(--accent);
  flex: none;
}

.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.btn-primary, .btn-secondary {
  flex: 1;
  border: none;
  border-radius: 999px;
  padding: 12px;
  font-size: .95rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-deep)); color: #fff; }
.btn-secondary { background: var(--accent-soft); color: var(--accent-deep); }

.settings-note { font-size: .66rem; color: var(--ink-sub); text-align: center; margin-top: 12px; }

/* 結果モーダル */
.summary-cat { font-size: 3rem; text-align: center; }
.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.summary-grid .sg-item {
  background: var(--accent-soft);
  border-radius: 12px;
  padding: 10px;
  text-align: center;
}
.summary-grid .sg-label { font-size: .68rem; color: var(--ink-sub); }
.summary-grid .sg-value { font-size: 1.15rem; font-weight: 700; }

.summary-souvenirs { text-align: center; font-size: .85rem; }
.summary-souvenirs .got {
  display: inline-block;
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 6px 14px;
  margin: 4px 2px;
  font-weight: 700;
  animation: pop .3s ease;
}

/* Leaflet 微調整 */
.leaflet-control-attribution { font-size: .55rem !important; }
.cat-marker { filter: drop-shadow(0 2px 3px rgba(0,0,0,.3)); }
