:root {
  --bg: #f6f3ee;
  --paper: #ffffff;
  --ink: #1f1b16;
  --muted: #6b6258;
  --line: #e3ddd3;
  --accent: #c2410c;
  --accent-soft: #fdf3ec;

  --c-hotel:     #7c3aed;
  --c-sight:     #0f766e;
  --c-food:      #c2410c;
  --c-suburb:    #0891b2;
  --c-transport: #64748b;
  --c-phrase:    #be185d;

  --hotel-bg:     #f3e8ff;
  --sight-bg:     #ccfbf1;
  --food-bg:      #fef3c7;
  --suburb-bg:    #cffafe;
  --transport-bg: #f1f5f9;

  --radius: 14px;
  --shadow: 0 1px 2px rgba(31,27,22,.05), 0 8px 24px rgba(31,27,22,.06);
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: -apple-system, "Noto Sans TC", "Hiragino Sans", "PingFang TC", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Hero */
.hero {
  padding: 54px 20px 28px;
  text-align: center;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fbf7f1 0%, var(--bg) 100%);
}
.hero .jp {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.hero h1 {
  margin: 0;
  font-size: clamp(26px, 5vw, 38px);
  letter-spacing: 0.08em;
  font-weight: 700;
}
.hero .dates {
  margin-top: 12px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.05em;
}
.hero .summary-row {
  margin-top: 18px;
  display: flex;
  justify-content: center;
  gap: 24px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--muted);
}
.hero .summary-row b {
  color: var(--ink);
  font-weight: 700;
  font-family: var(--mono);
  font-size: 15px;
}

/* Main tabs */
.main-tabs {
  display: flex;
  overflow-x: auto;
  padding: 10px 12px;
  gap: 6px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 100;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.main-tabs::-webkit-scrollbar { display: none; }
.tab-btn {
  flex: 0 0 auto;
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 13px;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
  letter-spacing: 0.03em;
}
.tab-btn:hover { border-color: var(--accent); }
.tab-btn.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
.tab-flag { font-size: 1em; line-height: 1; }
.tab-icon { display: inline-flex; align-items: center; color: inherit; }

/* Main content */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px 80px;
}
.view { display: none; }
.view.active { display: block; }

/* Section title (Chinese + English subtitle) */
.section-title {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 18px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.section-title h2,
.section-title .st-main {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--ink);
}
.section-title .sub,
.section-title .st-sub {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.25em;
  text-transform: uppercase;
}
.icon-wrap { display: inline-flex; align-items: center; color: var(--accent); }
.section-sub {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 16px;
  line-height: 1.65;
}

/* City header */
.city-header {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.city-header h2 {
  color: var(--ink);
  font-size: clamp(22px, 4vw, 28px);
  letter-spacing: 0.08em;
  margin: 0;
}
.city-header p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 6px;
  font-family: var(--mono);
  letter-spacing: 0.03em;
}

/* Map */
.map-wrapper {
  position: relative;
  margin-bottom: 18px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.map { height: 380px; width: 100%; background: #ece7de; }
.map-overlay {
  position: absolute;
  inset: 0;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(31,27,22,.35);
  color: #fff;
  font-size: 14px;
  letter-spacing: 0.15em;
  cursor: pointer;
  transition: opacity 0.2s;
}
.map-overlay.hidden { opacity: 0; pointer-events: none; }

/* Leaflet overrides */
.leaflet-control-layers {
  background: var(--paper) !important;
  color: var(--ink) !important;
  border: 1px solid var(--line) !important;
  border-radius: 10px !important;
  box-shadow: var(--shadow);
}
.leaflet-control-layers-expanded { padding: 0.7rem 0.9rem !important; }
.leaflet-control-layers label {
  font-size: 12px;
  margin: 0.3rem 0;
  display: block;
  letter-spacing: 0.05em;
}
.leaflet-popup-content-wrapper {
  background: var(--paper);
  color: var(--ink);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.leaflet-popup-tip { background: var(--paper); }
.leaflet-popup-content {
  margin: 0.8rem;
  font-size: 13px;
  font-family: var(--sans);
}
.leaflet-popup-content strong { color: var(--ink); letter-spacing: 0.02em; }
.leaflet-popup-content a { color: var(--accent); }

/* Map legend */
.map-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 12px;
}
.legend-icon {
  display: inline-flex;
  align-items: center;
  width: 16px;
  height: 16px;
}

/* Category accordion */
.cat-section {
  margin-bottom: 10px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.cat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
  background: var(--paper);
  transition: background 0.15s;
  min-height: 56px;
}
.cat-header:hover { background: var(--accent-soft); }
.cat-header-left { display: flex; align-items: center; gap: 12px; }
.cat-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
}
.cat-icon svg { display: block; }
.cat-icon.hotel     { background: var(--c-hotel); }
.cat-icon.sight     { background: var(--c-sight); }
.cat-icon.food      { background: var(--c-food); }
.cat-icon.suburb    { background: var(--c-suburb); }
.cat-icon.transport { background: var(--c-transport); }
.cat-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.03em;
}
.cat-count {
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
  font-family: var(--mono);
  letter-spacing: 0.1em;
}
.cat-chevron {
  color: var(--muted);
  transition: transform 0.25s;
  display: inline-flex;
  align-items: center;
}
.cat-section.open .cat-chevron { transform: rotate(180deg); }
.cat-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  border-top: 0 solid var(--line);
}
.cat-section.open .cat-body {
  max-height: 14000px;
  border-top-width: 1px;
}
.cat-body-inner {
  padding: 14px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 720px) {
  .cat-body-inner { grid-template-columns: 1fr 1fr; }
}

/* Card */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  position: relative;
}
.card::before {
  content: "";
  position: absolute;
  left: 0; top: 14px; bottom: 14px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--line);
}
.card.hotel::before     { background: var(--c-hotel); }
.card.sight::before     { background: var(--c-sight); }
.card.food::before      { background: var(--c-food); }
.card.suburb::before    { background: var(--c-suburb); }
.card.transport::before { background: var(--c-transport); }

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 8px;
}
.card-title {
  font-size: 16px;
  color: var(--ink);
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.4;
}
.card-original {
  color: var(--muted);
  font-size: 11px;
  margin-top: 3px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.card-tags { display: flex; gap: 0.3rem; flex-wrap: wrap; flex-shrink: 0; }
.card-tag {
  font-size: 10px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--line);
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.1em;
}
.card-tag.hotel     { background: var(--hotel-bg);     color: var(--c-hotel); }
.card-tag.sight     { background: var(--sight-bg);     color: var(--c-sight); }
.card-tag.food      { background: var(--food-bg);      color: var(--c-food); }
.card-tag.suburb    { background: var(--suburb-bg);    color: var(--c-suburb); }
.card-tag.transport { background: var(--transport-bg); color: var(--c-transport); }
.card-tag.booked    { background: var(--accent-soft);  color: var(--accent); }

.card-desc {
  margin-top: 6px;
  font-size: 13.5px;
  color: var(--ink);
  line-height: 1.65;
}
.card-icon {
  display: inline-flex;
  align-items: center;
  vertical-align: -2px;
  margin-right: 0.35rem;
  color: var(--accent);
}
.card-history {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--accent-soft);
  border-left: 2px solid var(--accent);
  font-size: 12.5px;
  color: var(--ink);
  border-radius: 0 6px 6px 0;
  line-height: 1.6;
}
.card-history .card-icon { color: var(--accent); }
.card-transit {
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--muted);
}
.card-transit .card-icon { color: var(--c-sight); }
.card-address {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  font-family: var(--mono);
  letter-spacing: 0.02em;
}
.card-address .card-icon { color: var(--muted); }

.card-links {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.card-links a,
.card-locate {
  background: var(--ink);
  color: #fff;
  text-decoration: none;
  font-size: 12px;
  padding: 7px 14px;
  border-radius: 999px;
  font-weight: 500;
  letter-spacing: 0.05em;
  border: 1px solid var(--ink);
  cursor: pointer;
  font-family: var(--sans);
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.card-links a.secondary {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--line);
}
.card-links a:active,
.card-locate:active { opacity: 0.75; transform: scale(0.97); }
.card-links a svg { opacity: 0.8; }
.card-locate {
  background: var(--accent);
  border-color: var(--accent);
}

/* Phrases */
.phrase-lang-tabs,
.phrase-cat-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.phrase-lang-tabs button,
.phrase-cat-tabs button {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 12.5px;
  letter-spacing: 0.05em;
  min-height: 34px;
}
.phrase-lang-tabs button.active,
.phrase-cat-tabs button.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.phrase-intro {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--muted);
  font-size: 12.5px;
  margin-bottom: 14px;
  line-height: 1.7;
  box-shadow: var(--shadow);
}

.phrase-list { display: grid; gap: 10px; }
.phrase-item {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.phrase-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.phrase-text { flex: 1; min-width: 0; }
.phrase-play {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s, background 0.15s;
  font-family: inherit;
}
.phrase-play:active { transform: scale(0.9); }
.phrase-play.playing {
  background: var(--accent);
  animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(194,65,12,0.4); }
  50% { box-shadow: 0 0 0 8px rgba(194,65,12,0); }
}
.phrase-zh {
  font-size: 12.5px;
  color: var(--muted);
  letter-spacing: 0.03em;
}
.phrase-orig {
  font-size: 17px;
  color: var(--ink);
  margin: 3px 0;
  font-weight: 600;
  letter-spacing: 0.02em;
  word-break: break-word;
}
.phrase-pron {
  font-size: 12px;
  color: var(--accent);
  font-family: var(--mono);
  letter-spacing: 0.03em;
}
.phrase-en {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  font-family: var(--mono);
  letter-spacing: 0.05em;
}
.phrase-note {
  font-size: 12px;
  color: var(--muted);
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  line-height: 1.6;
}

/* Itinerary (timeline style) */
.iti-day {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  border-left: 3px solid var(--accent);
}
.iti-date {
  font-weight: 700;
  color: var(--ink);
  font-size: 15px;
  letter-spacing: 0.05em;
}
.iti-date .iti-dash { color: var(--muted); font-weight: 400; margin: 0 6px; }
.iti-theme {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 4px;
  letter-spacing: 0.02em;
}
.iti-blocks {
  margin-top: 12px;
  display: grid;
  gap: 6px;
}
.iti-block {
  font-size: 13px;
  display: flex;
  gap: 12px;
  padding: 4px 0;
  line-height: 1.6;
}
.iti-time {
  color: var(--accent);
  flex: 0 0 5rem;
  font-weight: 600;
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: 0.05em;
}
.iti-hotel {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  letter-spacing: 0.02em;
}

/* Currency widget */
.currency-widget,
.transit-widget {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.currency-grid { display: grid; gap: 8px; }
.currency-row {
  display: grid;
  grid-template-columns: 90px 1fr 100px;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 10px;
  border: 1px solid var(--line);
}
.currency-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  color: var(--ink);
  font-size: 13.5px;
  letter-spacing: 0.05em;
}
.currency-flag { font-size: 1.1rem; line-height: 1; }
.currency-code { font-family: var(--mono); }
.currency-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 15px;
  font-family: var(--mono);
  background: var(--paper);
  color: var(--ink);
  text-align: right;
  min-height: 38px;
  letter-spacing: 0.03em;
}
.currency-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(194,65,12,0.12);
}
.currency-name {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.05em;
}
@media (max-width: 480px) {
  .currency-row { grid-template-columns: 80px 1fr; }
  .currency-name { display: none; }
}

.rate-summary {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
@media (min-width: 560px) {
  .rate-summary { grid-template-columns: 1fr 1fr 1fr; }
}
.rate-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.rate-flag { font-size: 1.3rem; line-height: 1; }
.rate-body { flex: 1; min-width: 0; }
.rate-main {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  font-family: var(--mono);
  letter-spacing: 0.03em;
}
.rate-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  font-family: var(--mono);
  letter-spacing: 0.03em;
}

.rate-status {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 11px;
  color: var(--muted);
  flex-wrap: wrap;
  letter-spacing: 0.05em;
}
.rate-source { font-weight: 600; }
.rate-date { color: var(--muted); font-family: var(--mono); }
.rate-refresh-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--accent);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  transition: transform 0.15s;
}
.rate-refresh-btn:active { transform: scale(0.9); }
.rate-refresh-btn.spinning svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.rate-error { color: var(--accent); }

/* Transit costs */
.transit-city {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
}
.transit-city:first-child { margin-top: 0; padding-top: 0; border-top: none; }
.transit-city h3 {
  font-size: 14px;
  color: var(--ink);
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 0.08em;
  font-weight: 700;
}
.transit-flag { font-size: 1.1rem; }

.cost-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
@media (min-width: 560px) {
  .cost-grid { grid-template-columns: 1fr 1fr; }
}
.cost-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
}
.cost-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  flex-wrap: wrap;
}
.cost-label {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.4;
  min-width: 0;
  letter-spacing: 0.02em;
}
.cost-price {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex-shrink: 0;
}
.price-main {
  background: var(--ink);
  color: #fff;
  font-size: 11.5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 700;
  font-family: var(--mono);
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.price-twd {
  font-size: 10.5px;
  color: var(--accent);
  font-family: var(--mono);
  font-weight: 600;
  letter-spacing: 0.03em;
}
.cost-note {
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.55;
}

/* Footer */
footer {
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  padding: 24px 16px 8px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* Mobile tweaks */
@media (max-width: 480px) {
  .hero { padding: 46px 16px 22px; }
  main { padding: 18px 12px 60px; }
  .map { height: 320px; }
  .card { padding: 14px; }
  .iti-block { flex-direction: column; gap: 2px; }
  .iti-time { flex: none; }
  .tab-btn { padding: 7px 12px; font-size: 12px; }
}
