/* デジタル庁デザインシステム（DADS）のカラー・タイポグラフィを参考に、
   Android（Material 3）風のレイアウトで構成 */
:root {
  --blue-50: #e8f1fe;
  --blue-100: #d9e6ff;
  --blue-200: #c5d7fb;
  --blue-900: #0017c1;
  --blue-1000: #00118f;
  --blue-1100: #000071;
  --gray-50: #f2f2f2;
  --gray-100: #e6e6e6;
  --gray-200: #d8d8db;
  --gray-420: #949494;
  --gray-600: #666666;
  --gray-700: #595959;
  --gray-900: #1a1a1a;
  --white: #ffffff;
  --red-800: #ec0000;
  --red-50: #fdeeee;
  --green-700: #197a4b;
  --green-50: #e6f5ec;
  --yellow-400: #ffd43d;
  --yellow-50: #fbf5e0;
  --tier-s: #ff6fd1;
  --tier-f: #8b4cff;
  --tier-t: #ff4b4b;

  --primary: var(--blue-900);
  --on-primary: var(--white);
  --surface: var(--white);
  --surface-dim: #f8f8fb;
  --text: var(--gray-900);
  --text-sub: var(--gray-700);
  --border: var(--gray-200);
  --focus: var(--yellow-400);

  --appbar-h: 56px;
  --navbar-h: 72px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --radius-s: 6px;
  --radius-m: 12px;
  --radius-l: 24px;
  --elev-1: 0 1px 2px rgba(0, 0, 0, .12), 0 1px 3px 1px rgba(0, 0, 0, .06);
  --elev-3: 0 4px 8px 3px rgba(0, 0, 0, .12), 0 1px 3px rgba(0, 0, 0, .2);

  color-scheme: light;
  font-family: "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", sans-serif;
  font-size: 16px;
  line-height: 1.7;
  letter-spacing: .02em;
  color: var(--text);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--surface-dim);
  overflow: hidden;
  overscroll-behavior: none;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
a { color: var(--blue-900); }
:focus-visible {
  outline: 2px solid var(--gray-900);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--focus);
}
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.disclaimer { font-size: .6875rem; color: var(--text-sub); text-align: center; padding: 16px 0 0; line-height: 1.5; }

.ic { width: 24px; height: 24px; fill: currentColor; flex: none; }
.ic-s { width: 18px; height: 18px; }

/* ---------- App bar ---------- */
.appbar {
  position: fixed; inset: 0 0 auto 0;
  height: calc(var(--appbar-h) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 4px 0 16px;
  display: flex; align-items: center; gap: 8px;
  background: var(--surface);
  z-index: 20;
  transition: box-shadow .2s;
}
.appbar.raised { box-shadow: var(--elev-1); }
.appbar-title { flex: 1; margin: 0; font-size: 1.25rem; font-weight: 700; line-height: 1.4; }
.appbar-actions { display: flex; }
.icon-btn {
  width: 48px; height: 48px; border: 0; border-radius: 50%;
  background: transparent; color: var(--text-sub);
  display: inline-grid; place-items: center;
}
.icon-btn:hover { background: rgba(0, 0, 0, .05); }
.icon-btn:active { background: rgba(0, 0, 0, .1); }

/* ---------- Views ---------- */
main {
  position: fixed;
  top: calc(var(--appbar-h) + env(safe-area-inset-top, 0px));
  bottom: calc(var(--navbar-h) + var(--safe-b));
  left: 0; right: 0;
}
.view { position: absolute; inset: 0; display: none; flex-direction: column; }
.view.active { display: flex; }
.view-body {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 12px 16px 104px;
}

.subbar { background: var(--surface); flex: none; }
.tabs { display: flex; border-bottom: 1px solid var(--border); }
.tab {
  flex: 1; height: 48px; border: 0; background: none;
  color: var(--text-sub); font-weight: 500; position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.2;
}
.tab small { font-size: .75rem; font-weight: 400; }
.tab[aria-selected="true"] { color: var(--blue-900); font-weight: 700; }
.tab[aria-selected="true"]::after {
  content: ""; position: absolute; bottom: 0; left: 25%; right: 25%;
  height: 3px; border-radius: 3px 3px 0 0; background: var(--blue-900);
}

.segmented {
  display: flex; margin: 10px 16px; border: 1px solid var(--gray-420); border-radius: 999px; overflow: hidden;
}
.seg {
  flex: 1; height: 40px; border: 0; background: transparent; font-size: .875rem; font-weight: 500;
}
.seg + .seg { border-left: 1px solid var(--gray-420); }
.seg[aria-pressed="true"] { background: var(--blue-100); color: var(--blue-1100); }
.seg[aria-pressed="true"]::before { content: "✓ "; }

/* ---------- Navigation bar ---------- */
.navbar {
  position: fixed; inset: auto 0 0 0;
  height: calc(var(--navbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: flex; background: #f3f5fb; z-index: 20;
  border-top: 1px solid var(--gray-100);
}
.nav-item {
  flex: 1; border: 0; background: none; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
  font-size: .75rem; font-weight: 500; color: var(--text-sub); line-height: 1.2;
}
.nav-ind {
  width: 64px; height: 32px; border-radius: 16px; display: grid; place-items: center;
  transition: background .2s;
}
.nav-item[aria-current="page"] { color: var(--gray-900); font-weight: 700; }
.nav-item[aria-current="page"] .nav-ind { background: var(--blue-100); color: var(--blue-1000); }

/* ---------- FAB / Snackbar ---------- */
.fab {
  position: fixed; right: 16px;
  bottom: calc(var(--navbar-h) + var(--safe-b) + 16px);
  height: 56px; min-width: 56px; padding: 0 20px 0 16px; gap: 8px;
  border: 0; border-radius: 16px;
  background: var(--blue-900); color: var(--on-primary);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--elev-3); z-index: 15; font-weight: 700;
}
.fab:hover { background: var(--blue-1000); }
.fab:active { background: var(--blue-1100); }

.snackbar {
  position: fixed; left: 16px; right: 16px;
  bottom: calc(var(--navbar-h) + var(--safe-b) + 16px);
  margin: 0 auto; max-width: 560px;
  background: #2b2b2b; color: #fff; border-radius: var(--radius-s);
  padding: 14px 16px; font-size: .875rem; box-shadow: var(--elev-3);
  z-index: 60; transform: translateY(24px); opacity: 0; pointer-events: none;
  transition: transform .2s, opacity .2s;
}
.snackbar.show { transform: none; opacity: 1; }

/* ---------- Common components ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-m);
  padding: 12px 16px; margin-bottom: 8px; display: block; width: 100%; text-align: left;
}
button.card:active, .card.tappable:active { background: var(--gray-50); }
.card-row { display: flex; gap: 8px; align-items: flex-start; }
.card-main { flex: 1; min-width: 0; }
.card-title { font-weight: 700; line-height: 1.5; margin: 2px 0; white-space: pre-line; }
.card-meta { font-size: .8125rem; color: var(--text-sub); line-height: 1.5; }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.section-h {
  font-size: .875rem; font-weight: 700; color: var(--blue-1000);
  margin: 20px 0 8px; display: flex; align-items: center; gap: 8px;
}
.section-h:first-child { margin-top: 4px; }
.section-h .count { font-weight: 400; color: var(--text-sub); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 16px 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 32px; padding: 0 12px; border: 1px solid var(--gray-420); border-radius: 8px;
  background: var(--surface); font-size: .8125rem; font-weight: 500; display: inline-flex; align-items: center; gap: 4px;
}
.chip[aria-pressed="true"] { background: var(--blue-100); border-color: var(--blue-100); color: var(--blue-1100); }
.chip[aria-pressed="true"]::before { content: "✓"; }
.tag {
  display: inline-block; font-size: .6875rem; line-height: 1; padding: 4px 6px; border-radius: 4px;
  background: var(--gray-50); color: var(--text-sub); margin: 4px 4px 0 0; font-weight: 500;
}
.tag.blue { background: var(--blue-50); color: var(--blue-1000); }
.tag.warn { background: var(--red-50); color: var(--red-800); }
.tag.ok { background: var(--green-50); color: var(--green-700); }
.booth-code {
  display: inline-grid; place-items: center; min-width: 48px; height: 24px; padding: 0 6px;
  border-radius: 4px; color: #fff; font-size: .75rem; font-weight: 700; flex: none;
}
.booth-code.S { background: var(--tier-s); color: #4a0033; }
.booth-code.F { background: var(--tier-f); }
.booth-code.T { background: var(--tier-t); }

.star-btn { color: var(--gray-420); margin: -8px -8px -8px 0; }
.star-btn[aria-pressed="true"] { color: #e5a800; }
.check-btn[aria-pressed="true"] { color: var(--green-700); }

.btn {
  height: 48px; padding: 0 20px; border-radius: 8px; font-weight: 700; font-size: 1rem;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--blue-900); background: var(--surface); color: var(--blue-900);
}
.btn:hover { background: var(--blue-50); }
.btn.primary { background: var(--blue-900); color: #fff; }
.btn.primary:hover { background: var(--blue-1000); }
.btn.primary:active { background: var(--blue-1100); }
.btn.danger { border-color: var(--red-800); color: var(--red-800); }
.btn.danger:hover { background: var(--red-50); }
.btn.text { border-color: transparent; background: none; padding: 0 12px; }
.btn.text:hover { background: var(--blue-50); }
.btn.block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.btn-row .btn { flex: 1 1 140px; }

.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: .875rem; font-weight: 700; margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%; min-height: 48px; padding: 10px 12px; border: 1px solid var(--gray-600); border-radius: 8px;
  background: var(--surface); font-size: 1rem;
}
.field textarea { min-height: 120px; resize: vertical; line-height: 1.6; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; min-width: 0; }
.hint { font-size: .8125rem; color: var(--text-sub); }

.empty { text-align: center; color: var(--text-sub); padding: 48px 16px; }
.empty .ic { width: 48px; height: 48px; color: var(--gray-420); }
.empty p { margin: 8px 0 16px; }

/* ---------- タイムテーブル（マイ予定） ---------- */
.timeline { position: relative; margin-left: 44px; }
.tl-hour {
  position: absolute; left: -44px; right: 0; border-top: 1px solid var(--gray-100);
  font-size: .75rem; color: var(--text-sub);
}
.tl-hour span { position: absolute; top: -10px; left: 0; width: 38px; text-align: right; background: var(--surface-dim); }
.tl-ev {
  position: absolute; border: 0; border-radius: 8px; padding: 4px 8px; overflow: hidden; text-align: left;
  background: var(--blue-100); color: var(--blue-1100); border-left: 4px solid var(--blue-900);
  font-size: .8125rem; line-height: 1.35;
}
.tl-ev.custom { background: var(--yellow-50); color: #4d3b00; border-left-color: #c79200; }
.tl-ev.conflict { box-shadow: inset 0 0 0 2px var(--red-800); }
.tl-ev b { display: block; font-weight: 700; }
.tl-ev .t { font-size: .6875rem; opacity: .85; }
.tl-now { position: absolute; left: -6px; right: 0; height: 2px; background: var(--red-800); z-index: 2; }
.tl-now::before { content: ""; position: absolute; left: -4px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--red-800); }

.searchbar {
  display: flex; align-items: center; gap: 8px; height: 48px; padding: 0 16px;
  background: #eef0f7; border-radius: 24px; color: var(--text-sub);
}
.searchbar input { flex: 1; border: 0; background: transparent; outline: none; min-width: 0; height: 100%; color: var(--text); }
.searchbar:focus-within { box-shadow: 0 0 0 2px var(--blue-900); }
.list-search { margin: 0 16px 4px; }

/* ---------- マップ ---------- */
#view-map { background: #e9eef2; }
#map { flex: 1; background: #e9eef2; }
.map-search {
  position: absolute; top: 8px; left: 12px; right: 12px; z-index: 500;
}
.map-search .searchbar { background: var(--surface); box-shadow: var(--elev-1); }
.map-chips { padding: 8px 0 0; }
.map-chips .chip { box-shadow: var(--elev-1); border-color: transparent; }
.suggest {
  list-style: none; margin: 4px 0 0; padding: 4px 0; background: var(--surface); border-radius: var(--radius-m);
  box-shadow: var(--elev-3); max-height: 50vh; overflow-y: auto;
}
.suggest li button {
  width: 100%; border: 0; background: none; text-align: left; padding: 10px 16px; display: flex; gap: 12px; align-items: center;
  min-height: 48px; line-height: 1.4;
}
.suggest li button:hover, .suggest li button:focus-visible { background: var(--blue-50); }
.map-tools {
  position: absolute; right: 12px; bottom: 16px; z-index: 500; display: flex; flex-direction: column; gap: 12px;
}
.fab-small {
  width: 48px; height: 48px; border-radius: 12px; border: 0; background: var(--surface); color: var(--blue-900);
  box-shadow: var(--elev-3); display: grid; place-items: center;
}
.leaflet-container { font-family: inherit; }
.leaflet-control-zoom { display: none; }
.booth-hit { cursor: pointer; }
.pin-icon { display: grid; place-items: center; font-size: 13px; font-weight: 700; color: #fff; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.pin-icon.fav { background: #e5a800; }
.pin-icon.visited { background: var(--green-700); }
.pin-icon.both { background: linear-gradient(135deg, #e5a800 50%, var(--green-700) 50%); }
.map-label {
  background: var(--blue-900); color: #fff; border: 0; border-radius: 6px; font-weight: 700; padding: 4px 8px;
  box-shadow: var(--elev-1);
}
.map-label::before { display: none; }
.pulse {
  border-radius: 50%; border: 3px solid var(--blue-900); background: rgba(0, 23, 193, .15);
  animation: pulse 1.4s ease-out infinite;
}
@keyframes pulse { 0% { transform: scale(.6); opacity: 1; } 100% { transform: scale(1.6); opacity: 0; } }

/* ---------- Bottom sheet ---------- */
.sheet {
  position: fixed; inset: auto 0 0 0; margin: 0 auto; width: 100%; max-width: 640px;
  max-height: 92vh; max-height: 92dvh; padding: 0; border: 0;
  border-radius: 28px 28px 0 0; background: var(--surface); color: var(--text);
  display: flex; flex-direction: column;
  box-shadow: var(--elev-3);
}
.sheet:not([open]) { display: none; }
.sheet[open] { animation: sheetUp .22s cubic-bezier(.2, 0, 0, 1); }
.sheet::backdrop { background: rgba(0, 0, 0, .4); }
@keyframes sheetUp { from { transform: translateY(40%); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet-handle { width: 32px; height: 4px; border-radius: 2px; background: var(--gray-420); margin: 12px auto 4px; flex: none; }
.sheet-content { overflow-y: auto; padding: 4px 20px calc(24px + var(--safe-b)); }
.sheet-head { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.sheet-head h2 { flex: 1; margin: 6px 0 0; font-size: 1.25rem; line-height: 1.5; white-space: pre-line; }
.sheet-head .icon-btn { margin: -4px -12px 0 0; }
.sheet .lead { white-space: pre-line; font-size: .9375rem; }
.sheet .speakers { margin: 8px 0; padding: 0; list-style: none; font-size: .875rem; color: var(--text-sub); }
.sheet .speakers li { padding: 2px 0; }
.toggle-row { display: flex; gap: 8px; margin: 12px 0 16px; flex-wrap: wrap; }
.toggle-row .btn { flex: 1 1 120px; }
.btn[aria-pressed="true"] { background: var(--blue-900); color: #fff; }
.btn.fav[aria-pressed="true"] { background: #e5a800; border-color: #e5a800; color: #1a1a1a; }
.btn.visit[aria-pressed="true"] { background: var(--green-700); border-color: var(--green-700); }
.rating { display: flex; gap: 2px; margin-bottom: 8px; }
.rating button { border: 0; background: none; width: 40px; height: 40px; display: grid; place-items: center; color: var(--gray-420); border-radius: 50%; }
.rating button[aria-pressed="true"] { color: #e5a800; }
.warn-box { display: flex; gap: 8px; align-items: flex-start; background: var(--red-50); color: #a30000; padding: 10px 12px; border-radius: 8px; font-size: .875rem; margin: 8px 0; }
.info-box { background: var(--blue-50); padding: 12px 16px; border-radius: var(--radius-m); font-size: .875rem; }
.saved { font-size: .75rem; color: var(--green-700); min-height: 1.2em; }

/* ---------- Memo / Backup ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-m); padding: 12px 16px; }
.stat b { display: block; font-size: 1.5rem; line-height: 1.3; color: var(--blue-900); }
.stat span { font-size: .8125rem; color: var(--text-sub); }
.progress { height: 8px; border-radius: 4px; background: var(--gray-100); overflow: hidden; margin: 4px 0 16px; }
.progress i { display: block; height: 100%; background: var(--green-700); }
.contact-actions { display: flex; gap: 4px; margin-top: 4px; }
.contact-actions a { display: inline-flex; align-items: center; gap: 4px; font-size: .8125rem; padding: 6px 10px; border-radius: 16px; background: var(--blue-50); text-decoration: none; color: var(--blue-1000); }
.mini-stars { color: #e5a800; font-size: .8125rem; letter-spacing: 0; }
.memo-excerpt { font-size: .875rem; color: var(--text); margin-top: 4px; white-space: pre-line; }

@media (min-width: 720px) {
  .view-body { padding-left: max(16px, calc(50% - 360px)); padding-right: max(16px, calc(50% - 360px)); }
}
