:root {
  --tw-primary: #2B557F;
  --tw-primary-hover: #1F3F60;
  --tw-tint: #EAF2FB;
  --tw-tint-border: #BADCF5;
  --jp-primary: #47593F;
  --jp-primary-hover: #34432F;
  --jp-tint: #FBEEEA;
  --jp-tint-border: #F2A99C;
  --ink: #211D1A;
  --ink-soft: #514C46;
  --ink-faint: #8C8780;
  --ink-fainter: #B4AFA6;
  --line: #E5E1D8;
  --line-soft: #EFEBE2;
  --bg: #F7F5F0;
  --bg-scroll: #F2EFE7;
  --card: #FFFFFF;
  --error: #C0392B;
  --shadow-card-hover: 0 0 0 1px var(--tw-primary);
  --shadow-modal: 0 24px 64px rgba(33, 29, 26, .28);
  --shadow-frame: 0 2px 12px rgba(33, 29, 26, .06);
  --radius-s: 4px;
  --radius-m: 10px;
  --radius-l: 14px;
  --radius-xl: 20px;
  --radius-pill: 999px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans TC", "Noto Sans JP", "PingFang TC", "Hiragino Sans", "Microsoft JhengHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: var(--tw-primary); text-decoration: none; }
a:hover { color: var(--tw-primary-hover); }
button { font-family: inherit; }
input { font-family: inherit; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--ink-fainter); border-radius: 6px; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheetUp { from { transform: translateY(101%); } to { transform: none; } }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

#app { min-height: 100vh; display: flex; flex-direction: column; }

/* ---------- Header ---------- */
.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  transition: max-height .22s ease, opacity .22s ease, padding .22s ease;
  overflow: hidden;
}
.site-header.collapsed { max-height: 0; opacity: 0; padding-top: 0; padding-bottom: 0; border-bottom-color: transparent; }
.header-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 20px 12px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
}
.header-title-block { flex: 1; min-width: 0; }
.eyebrow {
  font-size: 12px; font-weight: 700; letter-spacing: .14em; color: var(--ink-faint);
  text-transform: uppercase;
}
.page-title {
  font-size: 24px; font-weight: 900; color: var(--ink); margin-top: 2px; line-height: 1.15;
}
.header-meta {
  font-size: 13px; color: var(--ink-soft); margin-top: 6px; line-height: 1.6; display: flex; flex-wrap: wrap; gap: 4px 14px;
}
.header-meta span { white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; }
.header-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.lang-toggle {
  border: 1px solid var(--line); background: var(--card); color: var(--ink-soft);
  border-radius: var(--radius-pill); height: 32px; padding: 0 12px; font-size: 12px; font-weight: 700;
  cursor: pointer; white-space: nowrap; display: flex; align-items: center; gap: 4px;
}
.lang-toggle:hover { border-color: var(--tw-primary); color: var(--tw-primary); }
.info-btn {
  width: 32px; height: 32px; border-radius: var(--radius-pill); border: 1px solid var(--line);
  background: var(--card); color: var(--ink-soft); cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; flex: none;
}
.info-btn:hover { border-color: var(--tw-primary); color: var(--tw-primary); }

/* ---------- Tabs ---------- */
.tab-bar {
  background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 19;
}
.tab-bar-inner {
  max-width: 1180px; margin: 0 auto; padding: 0 20px; display: flex; gap: 24px;
  overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.tab-bar-inner::-webkit-scrollbar { display: none; }
@media (max-width: 520px) {
  .tab-bar-inner { gap: 16px; }
}
.tab-btn {
  background: none; border: 0; padding: 14px 0 10px; cursor: pointer; font-size: 16px; font-weight: 700;
  color: var(--ink-faint); position: relative; white-space: nowrap;
}
.tab-btn.active { color: var(--ink); }
.tab-btn .indicator {
  position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--tw-primary); border-radius: 3px 3px 0 0;
}

/* ---------- Main scroll area ---------- */
.main-scroll { flex: 1; }
.content-wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

/* ---------- List filters ---------- */
.filter-bar {
  background: var(--card); border-bottom: 1px solid var(--line); padding: 14px 20px 10px;
}
.filter-bar-inner { max-width: 1180px; margin: 0 auto; }
.search-row {
  display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: var(--radius-pill);
  height: 40px; padding: 0 14px; background: var(--card);
}
.search-row input { flex: 1; min-width: 0; border: 0; outline: 0; font-size: 16px; color: var(--ink); background: none; }
.search-row svg { flex: none; }
.clear-btn {
  border: 0; background: var(--line-soft); width: 20px; height: 20px; border-radius: var(--radius-pill); cursor: pointer;
  color: var(--ink-soft); font-size: 12px; line-height: 1; flex: none;
}
.chip-row { display: flex; align-items: center; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.chip {
  display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--card); color: var(--ink-soft);
  border-radius: var(--radius-pill); height: 32px; padding: 0 14px; font-size: 13px; font-weight: 700; cursor: pointer;
  white-space: nowrap; flex: none;
}
.chip.active-tw { border-color: var(--tw-primary); background: var(--tw-tint); color: var(--tw-primary); }
.chip.active-jp { border-color: var(--jp-primary); background: var(--jp-tint); color: var(--jp-primary); }
.icon-btn {
  flex: none; display: flex; align-items: center; justify-content: center; width: 32px; height: 32px;
  border-radius: var(--radius-pill); border: 1px solid var(--line); background: var(--card); color: var(--ink-soft); cursor: pointer;
  margin-left: auto;
}
.icon-btn:hover { border-color: var(--tw-primary); color: var(--tw-primary); }
.count-line { font-size: 12px; color: var(--ink-faint); margin-top: 10px; }
.count-line b { color: var(--ink); font-weight: 700; }

/* ---------- Card grid ---------- */
.scroll-region { background: var(--bg-scroll); min-height: 60vh; }
.grid-pad { padding: 14px 20px 40px; max-width: 1180px; margin: 0 auto; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 10px; }

.exhibitor-card {
  display: flex; gap: 14px; padding: 14px; background: var(--card); border-radius: var(--radius-l); cursor: pointer;
  align-items: center; transition: box-shadow .12s ease; min-width: 0;
}
.exhibitor-card:hover { box-shadow: var(--shadow-card-hover); }
.card-thumb {
  position: relative; width: 72px; height: 72px; border-radius: var(--radius-m); flex: none; overflow: hidden;
  background: var(--tw-tint); display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 900; color: var(--tw-primary);
}
.card-thumb.jp { background: var(--jp-tint); color: var(--jp-primary); }
.card-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.card-top-row { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; overflow: hidden; }
.booth-badge {
  font-size: 12px; font-weight: 700; color: #FFFFFF; background: var(--ink); border-radius: var(--radius-s);
  padding: 2px 6px; letter-spacing: .04em; white-space: nowrap; flex: none;
}
.booth-badge.tw { background: var(--tw-primary); }
.booth-badge.jp { background: var(--jp-primary); }
.area-tag {
  font-size: 12px; font-weight: 500; line-height: 1.5; border-radius: var(--radius-pill); padding: 1px 8px;
  white-space: nowrap; border: 1px solid var(--tw-tint-border); background: var(--tw-tint); color: var(--tw-primary);
}
.area-tag.jp { border-color: var(--jp-tint-border); background: var(--jp-tint); color: var(--jp-primary); }
.card-name { font-size: 16px; font-weight: 700; color: var(--ink); line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-sub { font-size: 13px; color: var(--ink-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.heart-btn {
  flex: none; display: flex; align-items: center; justify-content: center; width: 40px; height: 40px;
  border-radius: var(--radius-pill); border: 1px solid var(--line); background: var(--card); cursor: pointer;
}
.heart-btn.lg { width: 48px; height: 48px; border-width: 1.5px; }
.heart-btn svg { stroke: var(--ink-faint); fill: none; stroke-width: 1.6; }

.empty-state { text-align: center; padding: 64px 20px; }
.empty-state .title { font-size: 18px; font-weight: 700; color: var(--ink); margin-top: 14px; }
.empty-state .note { font-size: 14px; color: var(--ink-faint); margin-top: 6px; line-height: 1.6; }
.empty-state button {
  margin-top: 20px; border: 0; background: var(--tw-primary); color: #fff; border-radius: var(--radius-pill);
  height: 40px; padding: 0 24px; font-size: 14px; font-weight: 700; cursor: pointer;
}

/* ---------- Map tab ---------- */
.map-layout { padding: 20px; max-width: 1180px; margin: 0 auto; display: grid; grid-template-columns: minmax(0,1.4fr) minmax(320px,1fr); gap: 20px; align-items: start; }
@media (max-width: 900px) {
  .map-layout { grid-template-columns: minmax(0,1fr); padding: 14px 20px 24px; gap: 14px; }
}
.map-col { position: sticky; top: 0; }
@media (max-width: 900px) { .map-col { position: static; } }

.area-switch { display: flex; gap: 8px; padding-bottom: 10px; }
.area-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 1.5px solid var(--line); background: var(--card); border-radius: var(--radius-m); padding: 10px 8px; cursor: pointer;
}
.area-btn .label { font-size: 14px; font-weight: 700; color: var(--ink-soft); }
.area-btn .sub { font-size: 14px; color: var(--ink-faint); }
.area-btn.sel-tw { border-color: var(--tw-primary); background: var(--tw-tint); }
.area-btn.sel-tw .label { color: var(--tw-primary); }
.area-btn.sel-jp { border-color: var(--jp-primary); background: var(--jp-tint); }
.area-btn.sel-jp .label { color: var(--jp-primary); }

.map-box {
  position: relative; border-radius: var(--radius-l); background: var(--line-soft); box-shadow: 0 0 0 1px var(--line);
  overflow: hidden; cursor: grab; width: 100%; height: auto;
  /* touch-action is set inline/dynamically per zoom level (see app.js) -- at
     k=1 there's nothing to pan, so a vertical swipe should scroll the page
     natively instead of being trapped by the map's own gesture handling. */
}
.map-box.grabbing { cursor: grabbing; }
.map-stage { position: absolute; top: 0; left: 0; transform-origin: 0 0; }
.map-stage img { position: absolute; inset: 0; width: 100%; height: 100%; user-select: none; pointer-events: none; display: block; }
.booth-hit {
  position: absolute; cursor: pointer; border-radius: calc(3px / var(--k, 1));
}
.map-box.tw .booth-hit:hover { box-shadow: 0 0 0 calc(2.5px / var(--k, 1)) var(--tw-primary); background: rgba(43,85,127,.14); }
.map-box.jp .booth-hit:hover { box-shadow: 0 0 0 calc(2.5px / var(--k, 1)) var(--jp-primary); background: rgba(71,89,63,.16); }
.booth-hit.selected {
  background: rgba(255, 222, 113, .55) !important;
  box-shadow: 0 0 0 calc(3px / var(--k, 1)) var(--ink), 0 0 0 calc(6.5px / var(--k, 1)) #FFDE71 !important;
}
.booth-icon {
  /* Deliberately NOT compensated by var(--k): this scales naturally with the
     map's own zoom transform (inherited from #mapStage), same as the floor
     plan and booths themselves. */
  position: absolute; width: 22px; height: 22px;
  border-radius: 50%; overflow: hidden; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 900; color: var(--tw-primary); background: var(--tw-tint);
  box-shadow: 0 0 0 1.5px #fff, 0 0 0 2.5px rgba(33,29,26,.22);
}
.booth-icon.jp { color: var(--jp-primary); background: var(--jp-tint); }
.booth-icon img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

/* Placement variants: each anchors a different point of the booth (set via
   inline left/top) and offsets the icon clear of it, so icons near a map
   edge or a tightly-packed double column don't overlap their neighbors. */
.booth-icon.pos-center-top { transform: translate(-50%, -112%); }
.booth-icon.pos-center-bottom { transform: translate(-50%, 12%); }
.booth-icon.pos-left-center { transform: translate(-112%, -50%); }
.booth-icon.pos-right-center { transform: translate(12%, -50%); }
.map-controls { position: absolute; right: 10px; bottom: 10px; display: flex; flex-direction: column; gap: 6px; }
.map-controls button {
  width: 36px; height: 36px; border-radius: 10px; border: 0; background: rgba(33,29,26,.82); color: #fff;
  font-size: 16px; font-weight: 700; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.zoom-badge {
  position: absolute; left: 10px; top: 10px; background: rgba(255,255,255,.94); border-radius: 6px; padding: 4px 8px;
  font-size: 12px; color: var(--ink-soft); font-weight: 700;
}
.map-hint { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--ink-soft); align-items: center; padding-top: 10px; }
.map-hint span { display: flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

.detail-col { display: flex; flex-direction: column; gap: 12px; }
.map-placeholder { background: var(--card); border-radius: var(--radius-l); padding: 20px; font-size: 13px; color: var(--ink-faint); line-height: 1.7; }
.map-detail-card { background: var(--card); border-radius: var(--radius-l); padding: 20px; }

.quicklist-card { background: var(--card); border-radius: var(--radius-l); padding: 14px 0 4px; display: flex; flex-direction: column; min-height: 0; }
.quicklist-title { font-size: 12px; font-weight: 700; color: var(--ink-faint); letter-spacing: .04em; padding: 0 16px 10px; flex: none; }
.quicklist-scroll { overflow-y: auto; max-height: 420px; padding: 0 8px 8px; }
.quicklist-row {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px; border: 0; background: none;
  border-radius: var(--radius-m); cursor: pointer; text-align: left;
}
.quicklist-row:hover { background: var(--bg-scroll); }
.quicklist-row.selected.tw { background: var(--tw-tint); }
.quicklist-row.selected.jp { background: var(--jp-tint); }
.ql-name { font-size: 14px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 900px) { .quicklist-scroll { max-height: 320px; } }

/* ---------- Sheet / Modal ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(33,29,26,.5); z-index: 40; display: flex; align-items: center;
  justify-content: center; padding: 24px; animation: fadeIn .16s ease-out;
}
.panel {
  background: var(--card); width: 100%; max-width: 560px; min-width: 0; border-radius: var(--radius-xl); box-shadow: var(--shadow-modal);
  max-height: 88vh; overflow-y: auto; animation: fadeIn .16s ease-out;
}
@media (max-width: 640px) {
  .overlay { align-items: flex-end; padding: 0; }
  .panel { border-radius: var(--radius-xl) var(--radius-xl) 0 0; animation: sheetUp .22s cubic-bezier(.2,.8,.2,1); max-height: 92vh; }
}
.panel-pad { padding: 20px; }
.sheet-header {
  position: sticky; top: 0; background: var(--card); padding: 14px 20px 10px; border-bottom: 1px solid var(--line);
  display: flex; align-items: flex-start; gap: 10px; z-index: 2;
}
.sheet-logo {
  position: relative; width: 80px; height: 80px; border-radius: var(--radius-m); flex: none; overflow: hidden;
  background: var(--tw-tint); display: flex; align-items: center; justify-content: center; font-size: 32px; font-weight: 900; color: var(--tw-primary);
}
.sheet-logo.jp { background: var(--jp-tint); color: var(--jp-primary); }
.sheet-logo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.close-btn {
  flex: none; border: 0; background: var(--line-soft); width: 32px; height: 32px; border-radius: var(--radius-pill);
  cursor: pointer; color: var(--ink-soft); font-size: 14px;
}
.sheet-name { font-size: 22px; font-weight: 900; color: var(--ink); margin-top: 6px; line-height: 1.25; text-wrap: pretty; }
.sheet-body { padding: 14px 20px 20px; }
.desc-block { font-size: 14px; color: var(--ink); line-height: 1.8; white-space: pre-wrap; }
.gallery-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 14px; }
.gallery-grid a { display: block; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--line-soft); position: relative; }
.gallery-grid img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.gallery-grid a:hover { box-shadow: 0 0 0 2px var(--tw-primary); }
.links-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.link-chip {
  display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: var(--radius-pill);
  height: 34px; padding: 0 14px; font-size: 13px; font-weight: 700; color: var(--ink-soft);
}
.link-chip:hover { border-color: var(--tw-primary); color: var(--tw-primary); }
.cta-row { display: flex; gap: 6px; margin-top: 16px; }
.btn-outline {
  flex: 1; display: flex; align-items: center; justify-content: center; height: 48px; border-radius: var(--radius-pill);
  border: 1.5px solid var(--tw-primary); color: var(--tw-primary); font-size: 15px; font-weight: 700; cursor: pointer; background: none;
}
.btn-outline.jp { border-color: var(--jp-primary); color: var(--jp-primary); }
.btn-solid {
  width: 100%; margin-top: 8px; height: 48px; border-radius: var(--radius-pill); border: 0; background: var(--tw-primary);
  color: #fff; font-size: 15px; font-weight: 700; cursor: pointer;
}
.btn-solid.jp { background: var(--jp-primary); }
.btn-solid:hover { background: var(--tw-primary-hover); }
.btn-pinkoi {
  display: flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none;
  background: #2B557F;
}
.btn-pinkoi:hover { background: var(--tw-primary-hover); color: #fff; }

.sheet-title { font-size: 18px; font-weight: 700; color: var(--ink); }
.sheet-note { font-size: 14px; color: var(--ink-soft); line-height: 1.7; margin-top: 10px; text-wrap: pretty; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff;
  border-radius: var(--radius-pill); padding: 10px 20px; font-size: 14px; font-weight: 700; animation: toastIn .18s ease-out;
  z-index: 60; white-space: nowrap; max-width: 90%; overflow: hidden; text-overflow: ellipsis;
}

.info-table { margin-top: 6px; }
.info-day { display: flex; align-items: baseline; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.info-day:last-child { border-bottom: 0; }
.info-day .d { font-size: 13px; font-weight: 700; color: var(--ink-faint); width: 84px; flex: none; }
.info-day .sessions { font-size: 14px; color: var(--ink); line-height: 1.7; }
.info-day .sessions .note { font-size: 12px; color: var(--ink-faint); }

.site-footer { border-top: 1px solid var(--line); padding: 24px 20px 40px; text-align: center; font-size: 12px; color: var(--ink-faint); }
.site-footer a { color: var(--ink-faint); text-decoration: underline; }

.about-tab { max-width: 720px; display: flex; flex-direction: column; gap: 14px; }
.about-card { background: var(--card); border-radius: var(--radius-l); padding: 20px; }
.about-intro { font-size: 16px; line-height: 1.85; }
.video-embed { position: relative; width: 100%; padding-top: 56.25%; border-radius: var(--radius-m); overflow: hidden; background: var(--line-soft); }
.video-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.social-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 14px; }
@media (max-width: 720px) {
  .social-grid { grid-template-columns: repeat(2, 1fr); }
}
.social-card {
  display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 16px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-m); text-align: center; transition: box-shadow .12s ease;
}
.social-card:hover { box-shadow: 0 0 0 1px var(--tw-primary); }
.social-card-head { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.social-card-icon {
  display: flex; align-items: center; justify-content: center; width: 32px; height: 32px;
  border-radius: 999px; background: var(--tw-tint); color: var(--tw-primary); flex: none;
}
.social-card-label { font-size: 16px; font-weight: 700; color: var(--ink); line-height: 1.4; }
.social-card-qr { width: 100%; max-width: 130px; border-radius: 8px; box-shadow: 0 0 0 1px var(--line); }
.qr-hint { font-size: 12px; color: var(--ink-faint); text-align: center; margin-top: 14px; }
@media (max-width: 640px) {
  .social-grid { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .card-grid { grid-template-columns: 1fr; }
  .page-title { font-size: 20px; }
}
