/* styles.css — Roadbook Numazu. Sobre, mobile-first, clair + sombre. */
:root {
  --bg: #f3f6fa; --card: #ffffff; --ink: #16202e; --muted: #5c6b7d;
  --line: #d9e1ea; --line-strong: #c3cedb;
  --accent: #1d4e79; --accent-ink: #ffffff; --accent-soft: #e7eef6;
  --ok: #227a4b; --ok-soft: #d7f0e0;
  --warn: #9a6600; --warn-soft: #fbeecb;
  --danger: #b23b3b; --danger-soft: #f6dcdc;
  --violet: #6b4a9e; --violet-soft: #ece2f7;
  --grey: #6b7785; --grey-soft: #e6eaef;
  --shadow: 0 4px 16px rgba(20, 40, 70, .08);
  --radius: 15px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1620; --card: #182430; --ink: #e8eef5; --muted: #9fb0c2;
    --line: #26333f; --line-strong: #33424f;
    --accent: #4f97cf; --accent-ink: #08131d; --accent-soft: #1c2b3a;
    --ok: #5cc189; --ok-soft: #143024;
    --warn: #e0b25a; --warn-soft: #33280f;
    --danger: #e08585; --danger-soft: #341a1a;
    --violet: #b79be6; --violet-soft: #241a33;
    --grey: #93a1af; --grey-soft: #202c37;
    --shadow: 0 4px 16px rgba(0, 0, 0, .35);
  }
}
:root[data-theme="dark"] {
  --bg: #0f1620; --card: #182430; --ink: #e8eef5; --muted: #9fb0c2;
  --line: #26333f; --line-strong: #33424f;
  --accent: #4f97cf; --accent-ink: #08131d; --accent-soft: #1c2b3a;
  --ok: #5cc189; --ok-soft: #143024; --warn: #e0b25a; --warn-soft: #33280f;
  --danger: #e08585; --danger-soft: #341a1a; --violet: #b79be6; --violet-soft: #241a33;
  --grey: #93a1af; --grey-soft: #202c37; --shadow: 0 4px 16px rgba(0, 0, 0, .35);
}
:root[data-theme="light"] {
  --bg: #f3f6fa; --card: #ffffff; --ink: #16202e; --muted: #5c6b7d;
  --line: #d9e1ea; --line-strong: #c3cedb; --accent: #1d4e79; --accent-ink: #fff;
  --accent-soft: #e7eef6; --ok: #227a4b; --ok-soft: #d7f0e0; --warn: #9a6600;
  --warn-soft: #fbeecb; --danger: #b23b3b; --danger-soft: #f6dcdc; --violet: #6b4a9e;
  --violet-soft: #ece2f7; --grey: #6b7785; --grey-soft: #e6eaef;
  --shadow: 0 4px 16px rgba(20, 40, 70, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink);
  -webkit-text-size-adjust: 100%; line-height: 1.4;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

/* En-tête */
header {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(135deg, var(--accent), #2f6fa0);
  color: var(--accent-ink); padding: 14px 14px 12px;
  box-shadow: var(--shadow); padding-top: calc(14px + env(safe-area-inset-top));
}
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
h1 { font-size: 19px; margin: 0; letter-spacing: .2px; }
.head-sub { font-size: 12px; opacity: .9; margin-top: 2px; }
.theme-btn {
  background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .28);
  color: #fff; border-radius: 999px; padding: 7px 10px; font-size: 15px; line-height: 1;
}
.progress-wrap {
  margin-top: 11px; background: rgba(255, 255, 255, .22);
  border-radius: 999px; height: 9px; overflow: hidden;
}
.progress { height: 100%; width: 0; background: #7fe0a9; transition: width .3s; }
.progress-label { font-size: 12px; margin-top: 5px; opacity: .95; }

/* Contrôles */
.controls { padding: 11px 12px 4px; display: grid; gap: 8px; }
.controls input, .controls select {
  width: 100%; border: 1px solid var(--line-strong); border-radius: 12px;
  padding: 12px; background: var(--card); min-height: 44px;
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn {
  border: 1px solid var(--line-strong); border-radius: 12px; padding: 12px;
  background: var(--card); font-weight: 600; min-height: 44px; text-align: center;
}
.btn.small { padding: 9px 10px; min-height: 0; font-weight: 600; font-size: 13px; }
.btn.accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* Puces de filtre */
.chips { display: flex; gap: 7px; overflow-x: auto; padding: 8px 12px 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  white-space: nowrap; border: 1px solid var(--line-strong); background: var(--card);
  border-radius: 999px; padding: 9px 13px; font-size: 13px; min-height: 40px;
}
.chip.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* Bandeau d'avertissement horaires */
.notice {
  margin: 8px 12px 2px; font-size: 12.5px; color: var(--warn);
  background: var(--warn-soft); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 11px;
}

/* Liste */
.count-line { padding: 8px 14px 2px; font-size: 12.5px; color: var(--muted); }
.list { padding: 6px 12px 96px; display: grid; gap: 10px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 13px; box-shadow: var(--shadow);
}
.card.is-done { opacity: .62; }
.card.is-ended { background: var(--grey-soft); }
.card-top { display: flex; gap: 11px; align-items: flex-start; }
.card-map {
  flex: 0 0 auto; align-self: flex-start; margin-top: 1px; background: transparent;
  border: 1px solid var(--line-strong); border-radius: 9px; width: 34px; height: 34px;
  font-size: 15px; line-height: 1; color: var(--accent); cursor: pointer;
}
.check {
  appearance: none; -webkit-appearance: none; flex: 0 0 auto;
  width: 26px; height: 26px; margin-top: 2px; border: 2px solid var(--line-strong);
  border-radius: 8px; background: var(--card); position: relative;
}
.check:checked { background: var(--ok); border-color: var(--ok); }
.check:checked::after {
  content: ""; position: absolute; left: 8px; top: 3px; width: 6px; height: 12px;
  border: solid #fff; border-width: 0 3px 3px 0; transform: rotate(45deg);
}
.title-ja { font-weight: 700; font-size: 16px; line-height: 1.25; word-break: break-word; }
.title-fr { font-size: 13.5px; color: var(--accent); font-weight: 600; margin-top: 1px; }
.title-fr.uncertain { color: var(--muted); font-style: italic; font-weight: 500; }
.meta { font-size: 12px; color: var(--muted); margin-top: 3px; }

.badges { display: flex; flex-wrap: wrap; gap: 5px; margin: 9px 0 2px; }
.badge {
  font-size: 11px; border-radius: 999px; padding: 3px 8px; background: var(--accent-soft);
  color: var(--accent); border: 1px solid transparent; display: inline-flex; align-items: center; gap: 4px;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.early { background: var(--warn-soft); color: var(--warn); }
.badge.veryearly { background: var(--danger-soft); color: var(--danger); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.ended { background: var(--grey-soft); color: var(--grey); }
.badge.confirm { background: var(--violet-soft); color: var(--violet); }
.badge.member { background: var(--accent-soft); color: var(--accent); }
.badge.fav { background: var(--warn-soft); color: var(--warn); }
.badge.visited { background: var(--ok-soft); color: var(--ok); }
.badge.live { font-weight: 700; }
.badge.live.st-open { background: var(--ok-soft); color: var(--ok); }
.badge.live.st-soon { background: var(--danger-soft); color: var(--danger); }
.badge.live.st-closed { background: var(--grey-soft); color: var(--grey); }
.badge.live.st-before { background: var(--accent-soft); color: var(--accent); }

.summary { font-size: 13px; color: var(--muted); margin-top: 7px; }
.summary b { color: var(--ink); font-weight: 600; }

/* FAB */
.fab {
  position: fixed; right: 16px; bottom: calc(18px + env(safe-area-inset-bottom));
  background: var(--accent); color: var(--accent-ink); border: none; border-radius: 999px;
  padding: 14px 18px; font-weight: 700; box-shadow: 0 8px 24px rgba(0, 0, 0, .28); z-index: 15;
}

.empty { text-align: center; padding: 46px 20px; color: var(--muted); }

/* Fiche détail (dialog) */
dialog {
  border: none; border-radius: 18px 18px 0 0; width: 100%; max-width: 620px;
  padding: 0; margin: auto auto 0; background: var(--card); color: var(--ink);
  box-shadow: 0 -8px 30px rgba(0, 0, 0, .3);
}
dialog::backdrop { background: rgba(0, 0, 0, .5); }
.sheet { padding: 16px 16px calc(20px + env(safe-area-inset-bottom)); }
.sheet-grab { width: 40px; height: 4px; border-radius: 999px; background: var(--line-strong); margin: 8px auto 12px; }
.sheet h2 { margin: 0; font-size: 19px; word-break: break-word; }
.sheet .fr { color: var(--accent); font-weight: 600; margin-top: 2px; }
.field { border-top: 1px solid var(--line); padding: 10px 0 2px; margin-top: 8px; }
.field-label { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.field .ja { font-size: 15px; margin-top: 2px; word-break: break-word; }
.field .val { font-size: 14px; margin-top: 3px; }
.field .val.muted { color: var(--muted); }
.verif { font-size: 12.5px; color: var(--warn); background: var(--warn-soft); border-radius: 10px; padding: 9px 11px; margin-top: 12px; }
.verif.ok { color: var(--ok); background: var(--ok-soft); }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 14px; }
.sheet-actions .btn { text-decoration: none; }
.sheet-actions .btn.wide { grid-column: 1 / -1; }
textarea.note {
  width: 100%; border: 1px solid var(--line-strong); border-radius: 12px; padding: 11px;
  background: var(--bg); min-height: 62px; resize: vertical; margin-top: 6px;
}
.visit-fields { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.visit-fields input {
  flex: 1 1 140px; border: 1px solid var(--line-strong); border-radius: 12px; padding: 10px;
  background: var(--bg); color: var(--ink); min-height: 42px; font-size: 15px;
}
.close-x { position: absolute; right: 10px; top: 10px; background: transparent; border: none; font-size: 22px; color: var(--muted); }

.dlg-narrow { border-radius: 16px; max-width: 460px; margin: auto; }
.dlg-narrow .sheet { padding: 18px; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; word-break: break-all; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(80px + env(safe-area-inset-bottom)); background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 999px; font-size: 13px; z-index: 50; opacity: 0;
  transition: opacity .2s; pointer-events: none;
}
.toast.show { opacity: .95; }

/* Planificateur de parcours */
.plan-form { display: grid; gap: 9px; margin-top: 6px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--bg); border-radius: 12px; padding: 4px; }
.seg-btn { border: none; background: transparent; border-radius: 9px; padding: 10px; font-weight: 600; color: var(--muted); min-height: 42px; }
.seg-btn.active { background: var(--accent); color: var(--accent-ink); }
.plan-field { display: grid; gap: 3px; font-size: 12px; color: var(--muted); }
.plan-field input, .plan-field select {
  border: 1px solid var(--line-strong); border-radius: 11px; padding: 10px; background: var(--card);
  color: var(--ink); min-height: 42px; font-size: 15px;
}
.plan-check { display: flex; align-items: center; gap: 9px; font-size: 13.5px; padding: 4px 0; }
.plan-check input { width: 20px; height: 20px; }

.plan-day { border: 1px solid var(--line); border-radius: 14px; margin-top: 12px; overflow: hidden; }
.plan-day-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--accent-soft); color: var(--accent); padding: 10px 12px; font-weight: 700;
}
.plan-day-head .sub { font-weight: 500; font-size: 12px; opacity: .85; }
.plan-day-head a { color: var(--accent); text-decoration: none; font-size: 12.5px; border: 1px solid currentColor; border-radius: 999px; padding: 5px 9px; white-space: nowrap; }
.stop { display: flex; gap: 10px; padding: 9px 12px; border-top: 1px solid var(--line); align-items: baseline; }
.stop .t { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 13px; color: var(--ink); min-width: 46px; }
.stop .body { flex: 1; min-width: 0; }
.stop .n { font-size: 14px; word-break: break-word; }
.stop .n .fr { color: var(--muted); font-size: 12px; }
.stop .sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.stop .m { font-size: 11px; white-space: nowrap; color: var(--ok); font-weight: 600; }
.stop .m.tight { color: var(--danger); }
.stop .check { align-self: center; margin-top: 0; }
.stop .body[data-plan-open] { cursor: pointer; }
.stop.is-done { opacity: .62; }
.stop.is-gone { opacity: .45; }
.stop.is-gone .n, .stop.is-gone .sub { text-decoration: line-through; }
.lunch { padding: 6px 12px; font-size: 12px; color: var(--warn); background: var(--warn-soft); border-top: 1px solid var(--line); }
.plan-excl { margin-top: 12px; }
.plan-excl summary { cursor: pointer; font-weight: 600; font-size: 14px; padding: 6px 0; }
.plan-excl .er { font-size: 12.5px; color: var(--muted); padding: 4px 0 4px 6px; border-left: 2px solid var(--line-strong); margin: 4px 0; }
.plan-note { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* Carte (superposition) */
.map-overlay { position: fixed; inset: 0; z-index: 60; background: var(--bg); display: flex; flex-direction: column; }
.map-overlay[hidden] { display: none; }
.map-bar {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow); z-index: 2;
}
.map-bar strong { font-size: 16px; }
.map-count { font-size: 12px; opacity: .9; }
.map-actions { margin-left: auto; display: flex; gap: 8px; }
.map-ibtn {
  background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .3); color: #fff;
  width: 40px; height: 40px; border-radius: 10px; font-size: 17px; line-height: 1;
}
.map-ibtn.mh-on { background: #c74a8b; border-color: #f0a6cd; }
#rbmap { flex: 1; min-height: 0; background: var(--grey-soft); }
.map-tile-note {
  display: none; position: absolute; top: 66px; left: 50%; transform: translateX(-50%);
  background: var(--warn-soft); color: var(--warn); border: 1px solid var(--line);
  padding: 7px 12px; border-radius: 999px; font-size: 12px; z-index: 3; max-width: 90%; text-align: center;
}
.map-legend {
  position: absolute; left: 10px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 3;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 8px 10px; font-size: 11.5px; box-shadow: var(--shadow); display: grid; gap: 4px;
}
.map-legend span { display: flex; align-items: center; gap: 6px; color: var(--ink); }
.map-legend i { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.25); }

/* popups Leaflet */
.rb-pop-ja { font-weight: 700; font-size: 14px; }
.rb-pop-fr { color: #2d6ea3; font-size: 12.5px; margin-top: 1px; }
.rb-pop-sub { font-size: 11.5px; color: #55606c; margin-top: 3px; }
.rb-pop-act { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.rb-pop-btn {
  font-size: 12px; font-weight: 600; border: 1px solid #cfd8e2; border-radius: 8px;
  padding: 6px 9px; background: #fff; color: #1d4e79; text-decoration: none; cursor: pointer;
}

@media (min-width: 720px) {
  .controls, .chips, .list, .count-line, .notice { max-width: 760px; margin-left: auto; margin-right: auto; }
}
