:root {
  color-scheme: light dark;
  --bg: #f4f1ea;
  --surface: #fffdf8;
  --surface-2: #f8f5ee;
  --text: #20211f;
  --muted: #666861;
  --border: #d8d2c5;
  --accent: #8f1d2c;
  --accent-soft: #f1dfe2;
  --fixed: #1f6b48;
  --fixed-soft: #dcece4;
  --todo: #9a4a00;
  --todo-soft: #f7e6d5;
  --free: #315c8a;
  --free-soft: #dfeaf5;
  --optional: #6a6076;
  --optional-soft: #ebe6f0;
  --shadow: 0 14px 36px rgba(41, 34, 22, .09);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171714;
    --surface: #22221e;
    --surface-2: #2a2924;
    --text: #f2efe7;
    --muted: #c0bcb1;
    --border: #46433b;
    --accent: #e49aa4;
    --accent-soft: #4b2b31;
    --fixed: #82c5a2;
    --fixed-soft: #244333;
    --todo: #f0b06f;
    --todo-soft: #50351f;
    --free: #9cc1e7;
    --free-soft: #263e55;
    --optional: #c1b0d2;
    --optional-soft: #3c3446;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", sans-serif; line-height: 1.55; }
a { color: inherit; }
.page { width: min(1500px, 100%); margin: 0 auto; padding: 24px; }
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 18px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-family: Georgia, "Times New Roman", "Noto Serif JP", serif; font-size: clamp(1.65rem, 3vw, 2.55rem); font-weight: 500; letter-spacing: .02em; }
.subtitle { margin-bottom: 0; color: var(--muted); font-size: .93rem; }
.draft-label { flex: 0 0 auto; border: 1px solid var(--border); border-radius: 999px; padding: 7px 12px; background: var(--surface); color: var(--muted); font-size: .78rem; white-space: nowrap; }
.day-tabs { display: grid; grid-template-columns: repeat(var(--tab-count, 6), minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
.day-tab { border: 1px solid var(--border); border-radius: 12px; padding: 10px 8px; background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.day-tab:hover { border-color: var(--accent); }
.day-tab[aria-selected="true"] { border-color: var(--accent); background: var(--accent); color: #fff; }
.day-tab span { display: block; font-size: .75rem; opacity: .82; }
.overview { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(360px, .85fr); gap: 16px; align-items: stretch; margin-bottom: 16px; }
.map-panel, .day-panel, .schedule-panel { border: 1px solid var(--border); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); }
.map-panel, .schedule-panel { overflow: hidden; }
#map { width: 100%; min-height: 520px; background: var(--surface-2); }
.map-fallback { display: grid; align-content: center; gap: 12px; min-height: 520px; padding: 28px; }
.map-fallback ol { margin: 0; padding-left: 24px; }
.day-panel { display: flex; flex-direction: column; padding: 22px; }
.day-kicker { margin-bottom: 5px; color: var(--accent); font-size: .78rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.day-panel h2 { margin-bottom: 8px; font-size: 1.45rem; font-weight: 600; }
.day-summary { margin-bottom: 18px; color: var(--muted); }
.day-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.meta-item { border-top: 1px solid var(--border); padding-top: 10px; }
.meta-label { display: block; margin-bottom: 2px; color: var(--muted); font-size: .74rem; }
.meta-value { font-weight: 600; }
.flex-note { margin-top: auto; border-left: 4px solid var(--accent); padding: 12px 14px; background: var(--accent-soft); }
.flex-note strong { display: block; margin-bottom: 3px; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 18px; color: var(--muted); font-size: .78rem; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; }
.schedule-header { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 18px 20px 14px; border-bottom: 1px solid var(--border); }
.schedule-header h2 { margin-bottom: 0; font-size: 1.15rem; }
.route-note { margin: 0; color: var(--muted); font-size: .78rem; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 1120px; }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { background: var(--surface-2); color: var(--muted); font-size: .76rem; font-weight: 600; letter-spacing: .04em; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
.time-cell { width: 125px; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.place-cell { width: 215px; }
.transit-cell { width: 185px; color: var(--muted); }
.note-cell { color: var(--muted); }
.task-cell { width: 245px; }
.place-title { display: flex; align-items: flex-start; gap: 8px; font-weight: 600; }
.place-number { display: inline-grid; flex: 0 0 24px; width: 24px; height: 24px; place-items: center; border-radius: 50%; background: var(--accent); color: #fff; font-size: .75rem; }
.status { display: inline-block; margin-bottom: 5px; border-radius: 999px; padding: 3px 8px; font-size: .72rem; font-weight: 600; white-space: nowrap; }
.status-fixed { background: var(--fixed-soft); color: var(--fixed); }
.status-todo { background: var(--todo-soft); color: var(--todo); }
.status-free { background: var(--free-soft); color: var(--free); }
.status-optional { background: var(--optional-soft); color: var(--optional); }
.task-text { display: block; }
.map-link { display: inline-block; margin-top: 5px; color: var(--accent); font-size: .75rem; }
.leaflet-container { font: inherit; }
.route-marker { display: grid; width: 30px; height: 30px; place-items: center; border: 3px solid #fff; border-radius: 50%; background: #8f1d2c; color: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.28); font-size: 12px; font-weight: 700; }
.leaflet-popup-content { line-height: 1.45; }
.leaflet-popup-content strong { display: block; margin-bottom: 3px; }
footer { margin-top: 14px; color: var(--muted); font-size: .75rem; text-align: right; }

@media (max-width: 960px) {
  .page { padding: 16px; }
  .overview { grid-template-columns: 1fr; }
  #map, .map-fallback { min-height: 430px; }
  .day-panel { min-height: 0; }
  .flex-note { margin-top: 4px; }
  .day-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .hero { align-items: flex-start; flex-direction: column; gap: 10px; }
  .day-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #map, .map-fallback { min-height: 360px; }
  .day-meta { grid-template-columns: 1fr; }
  .schedule-header { align-items: flex-start; flex-direction: column; }
  th, td { padding: 11px 12px; }
}
