@font-face {
  font-family: "Inter"; src: url("fonts/InterVariable.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap;
}
:root {
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --fs-xs: 12px;  --lh-xs: 16px;
  --fs-sm: 14px;  --lh-sm: 20px;
  --fs-base: 16px; --lh-base: 24px;
  --fs-lg: 20px;  --lh-lg: 28px;
  --fs-xl: 24px;  --lh-xl: 32px;
  --fw-regular: 400; --fw-medium: 500; --fw-bold: 600;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --gutter: 16px; --content-max: 720px; --bar-h: 56px; --touch: 44px;
  --radius: 8px; --radius-pill: 999px;

  --bg: #ffffff; --surface: #f5f5f3; --border: #e2e3e7;
  --text: #16181d; --text-muted: #5b616e;
  --accent: #c2261d; --accent-fg: #ffffff; --accent-soft: rgba(194, 38, 29, .22);
  --marker-selected: #16181d;
  --shadow: 0 2px 8px rgba(0, 0, 0, .18);
  --focus: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
  color-scheme: light dark;
}
@media (min-width: 768px) { :root { --gutter: 24px; } }
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317; --surface: #1b1e24; --border: #2c3038;
    --text: #ecedef; --text-muted: #9ba1ad;
    --accent: #ff6b5e; --accent-fg: #111317; --accent-soft: rgba(255, 107, 94, .28);
    --marker-selected: #ffffff;
    --shadow: 0 2px 8px rgba(0, 0, 0, .5);
  }
  .leaflet-tile-pane { filter: brightness(.75) contrast(1.1) saturate(.8); }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  font: var(--fw-regular) var(--fs-base)/var(--lh-base) var(--font);
  background: var(--bg); color: var(--text);
  -webkit-text-size-adjust: 100%;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
h1, h2, p, ul { margin: 0; padding: 0; }
:focus-visible { outline: none; box-shadow: var(--focus); }

/* shell */
#app { height: 100dvh; display: grid; grid-template-rows: minmax(0, 1fr) auto; grid-template-areas: "main" "nav"; }
#main { grid-area: main; position: relative; overflow: hidden; min-height: 0; }
#main > section { position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; }
#view-map { overflow: hidden !important; }
body[data-view="dojo"] #tabs, body[data-view="error"] #tabs { display: none; }

/* tabs */
#tabs {
  grid-area: nav; display: grid; grid-template-columns: 1fr 1fr;
  height: calc(var(--bar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg); border-top: 1px solid var(--border);
}
#tabs .wordmark { display: none; }
#tabs a {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  font-size: var(--fs-base); font-weight: var(--fw-medium); color: var(--text);
}
#tabs a span:last-child { font-size: var(--fs-sm); line-height: var(--lh-sm); }
#tabs a[aria-current="page"] { color: var(--accent); }
#tabs a[aria-current="page"]::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--accent); }

@media (min-width: 768px) {
  #app { grid-template-rows: var(--bar-h) minmax(0, 1fr); grid-template-areas: "nav" "main"; }
  #tabs {
    display: flex; height: var(--bar-h); padding: 0 var(--gutter);
    border-top: 0; border-bottom: 1px solid var(--border);
  }
  body[data-view="dojo"] #tabs { display: flex; }
  body[data-view="error"] #tabs { display: none; }
  #tabs .wordmark { display: flex; align-items: center; margin-right: auto; font-weight: var(--fw-bold); }
  #tabs a { width: auto; min-width: 96px; flex-direction: row; gap: var(--s2); padding: 0 var(--s3); }
  #tabs a[aria-current="page"]::after { top: auto; bottom: 0; }
}

/* map */
.map { position: absolute; inset: 0; background: var(--surface); font-family: var(--font); }
.map .leaflet-control-zoom { display: none; }
@media (min-width: 768px) { .map .leaflet-control-zoom { display: block; } }
.leaflet-container { font-family: var(--font); }
.leaflet-control-zoom { border: 1px solid var(--border) !important; border-radius: var(--radius); overflow: hidden; }
.leaflet-control-zoom a { width: var(--touch) !important; height: var(--touch) !important; line-height: var(--touch) !important; background: var(--bg); color: var(--text); border-color: var(--border); }
.leaflet-control-attribution { font-size: 10px; line-height: 16px; background: var(--bg) !important; color: var(--text-muted); padding: 0 var(--s1); }
.leaflet-control-attribution a { color: var(--text-muted); position: relative; display: inline-block; }
.leaflet-control-attribution a::after { content: ""; position: absolute; inset: -14px -4px; }
.dm-marker, .dm-cluster { background: none; border: 0; display: flex; align-items: center; justify-content: center; }
.dm-marker .dot {
  width: 26px; height: 26px; border-radius: 50%; background: var(--accent);
  border: 2px solid var(--bg); box-shadow: var(--shadow); transition: transform .12s;
}
.dm-marker.selected .dot { background: var(--marker-selected); transform: scale(1.2); }
.dm-marker:focus-visible { box-shadow: none; }
.dm-marker:focus-visible .dot { box-shadow: var(--focus); }
.dm-cluster .cl {
  width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: var(--accent-fg);
  box-shadow: 0 0 0 4px var(--accent-soft); display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-sm); font-weight: var(--fw-bold); font-variant-numeric: tabular-nums;
}
.map-card-wrap { position: absolute; z-index: 1100; left: var(--gutter); right: var(--gutter); bottom: 28px; }
.map-card {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--s3);
  min-height: var(--touch); padding: var(--s3) var(--s4); background: var(--bg);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.mc-text { display: grid; min-width: 0; }
.mc-name { font-weight: var(--fw-bold); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mc-sub { font-size: var(--fs-sm); line-height: var(--lh-sm); color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mc-arts { font-size: var(--fs-sm); line-height: var(--lh-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mc-chev { display: flex; color: var(--text-muted); }
@media (min-width: 768px) { .map-card-wrap { right: auto; width: 360px; left: var(--gutter); bottom: var(--gutter); } }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: var(--touch);
  padding: 0 var(--s2); border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--text); font-size: var(--fs-sm); font-weight: var(--fw-bold);
  cursor: pointer; white-space: nowrap; overflow: hidden; min-width: 0; gap: var(--s2);
}
.ico { display: inline-flex; flex: none; }
.btn.filled { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.error { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s4); height: 100%; padding: var(--gutter); text-align: center; }

/* week */
.filter {
  position: sticky; top: 0; z-index: 3; height: var(--bar-h); display: flex; align-items: center; gap: var(--s2);
  padding: 0 var(--gutter); background: var(--bg); border-bottom: 1px solid var(--border);
  overflow-x: auto; scrollbar-width: none;
}
.filter::-webkit-scrollbar { display: none; }
.chip-btn { flex: none; min-height: var(--touch); padding: 0; border: 0; background: none; cursor: pointer; }
.chip-btn span {
  display: flex; align-items: center; height: 36px; padding: 0 var(--s4); border-radius: var(--radius-pill);
  background: var(--surface); font-size: var(--fs-sm); font-weight: var(--fw-medium); white-space: nowrap;
}
.chip-btn[aria-pressed="true"] span { background: var(--accent); color: var(--accent-fg); }
.week-list { max-width: var(--content-max); margin: 0 auto; }
@media (min-width: 768px) { .filter { padding: 0 max(var(--gutter), calc((100% - var(--content-max)) / 2 + var(--gutter))); } }
.day {
  position: sticky; top: var(--bar-h); z-index: 2; height: 32px; display: flex; align-items: center;
  padding: 0 var(--gutter); background: var(--surface); font-size: var(--fs-sm); font-weight: var(--fw-bold);
}
.day.today { color: var(--accent); }
.row {
  display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: var(--s3); min-height: var(--bar-h);
  padding: var(--s2) var(--gutter); border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums;
}
.row.over { opacity: .5; }
.t-start { display: block; font-weight: var(--fw-bold); }
.t-end { display: block; font-size: var(--fs-xs); line-height: var(--lh-xs); color: var(--text-muted); }
.t-end .dash { display: none; }
.main { display: block; min-width: 0; }
.r-title { display: block; font-weight: var(--fw-medium); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-sub { display: block; font-size: var(--fs-sm); line-height: var(--lh-sm); color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { padding: var(--s5); color: var(--text-muted); }
@media (min-width: 768px) {
  .row { grid-template-columns: 112px minmax(0, 1fr) minmax(0, auto); align-items: center; }
  .time { white-space: nowrap; }
  .t-start, .t-end { display: inline; }
  .t-end { font-size: inherit; line-height: inherit; color: inherit; font-weight: var(--fw-bold); }
  .t-end .dash { display: inline; }
  .main { display: contents; }
  .r-sub { text-align: right; max-width: 280px; }
}

/* detail */
.bar { position: sticky; top: 0; z-index: 3; height: var(--bar-h); display: flex; align-items: center; padding: 0 var(--s2); background: var(--bg); }
.back { width: var(--touch); height: var(--touch); border: 0; background: none; display: flex; align-items: center; justify-content: center; cursor: pointer; border-radius: var(--radius); }
.col { max-width: var(--content-max); margin: 0 auto; padding: 0 var(--gutter) var(--s7); }
.name { font-size: var(--fs-xl); line-height: var(--lh-xl); font-weight: var(--fw-bold); }
.badge { display: inline-block; margin-top: var(--s2); padding: 0 var(--s3); border-radius: var(--radius-pill); background: var(--surface); font-size: var(--fs-xs); line-height: var(--lh-xl); }
.chips { list-style: none; display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s3); }
.chip { padding: var(--s1) var(--s3); border-radius: var(--radius-pill); background: var(--surface); font-size: var(--fs-sm); line-height: var(--lh-sm); }
.actions { display: flex; gap: var(--s2); margin-top: var(--s4); }
.actions .btn { height: 48px; }
.actions .btn.tel { flex: 1 1 auto; font-variant-numeric: tabular-nums; padding: 0 var(--s3); }
.btn.icon { flex: none; width: 48px; min-height: 48px; padding: 0; }
.photos {
  display: flex; gap: var(--s2); overflow-x: auto; scroll-snap-type: x mandatory; margin: var(--s4) calc(-1 * var(--gutter)) 0;
  padding: 0 var(--gutter); scroll-padding: 0 var(--gutter); scrollbar-width: none;
}
.photos::-webkit-scrollbar { display: none; }
.photos img { flex: none; height: 160px; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius); background: var(--surface); scroll-snap-align: start; }
@media (min-width: 768px) { .photos { margin: var(--s4) 0 0; padding: 0; } .photos img { height: 200px; } }
.block { margin-top: var(--s5); }
.h { font-size: var(--fs-sm); line-height: var(--lh-sm); font-weight: var(--fw-bold); text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin-bottom: var(--s3); }
.loc { padding-bottom: var(--s4); margin-bottom: var(--s4); border-bottom: 1px solid var(--border); }
.loc:last-child { border-bottom: 0; margin-bottom: 0; }
.loc-label { font-weight: var(--fw-bold); }
.loc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s3); }
.loc-text { min-width: 0; }
.loc-addr { color: var(--text-muted); }
.times { display: grid; grid-template-columns: 32px max-content minmax(0, 1fr); column-gap: var(--s3); row-gap: var(--s1); font-variant-numeric: tabular-nums; }
.t-day { font-weight: var(--fw-bold); }
.pre { white-space: pre-line; }

.kv { display: grid; grid-template-columns: fit-content(50%) minmax(0, 1fr); column-gap: var(--s4); row-gap: var(--s1); font-variant-numeric: tabular-nums; }
.kv-k { color: var(--text-muted); }
.kv-full { grid-column: 1 / -1; }

.minimap { height: 180px; border-radius: var(--radius); overflow: hidden; margin-bottom: var(--s4); background: var(--surface); z-index: 0; }
@media (min-width: 768px) { .minimap { height: 240px; } }

.dm-label { display: none; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 2px var(--s2); font: var(--fw-medium) var(--fs-xs)/var(--lh-xs) var(--font); white-space: nowrap; }
.dm-label::before { display: none; }
.show-labels .dm-label { display: block; }
