:root {
  --bg: #081d2e;
  --panel: #102b3f;
  --panel-deep: #0b2132;
  --ink: #eaf5f1;
  --muted: #acc0c7;
  --mint: #8bdfc3;
  --sun: #f5c78b;
  --warn: #f8b470;
  --danger: #fca5a5;
  --stroke: rgba(198, 229, 223, 0.18);
  --font: system-ui, -apple-system, 'Noto Sans TC', 'Microsoft JhengHei', sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 280px;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  background: linear-gradient(165deg, #0d273b 0%, var(--bg) 42%, #071826 100%);
  font: 16px/1.7 var(--font);
  display: flex;
  flex-direction: column;
}

h1, h2, h3, p { margin-top: 0; }
a { color: inherit; text-decoration: none; }
a:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 3px solid var(--sun);
  outline-offset: 3px;
  border-radius: 6px;
}
[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; top: -150px; left: 24px; z-index: 100;
  padding: 10px 18px; border-radius: 8px; background: var(--sun); color: #102533; font-weight: 700;
}
.skip-link:focus { top: 12px; }

.ambient { position: fixed; z-index: -1; pointer-events: none; border-radius: 50%; filter: blur(2px); }
.ambient-one {
  width: min(640px, 100vw); height: 640px; top: -380px; right: 0;
  background: radial-gradient(ellipse, rgba(75, 132, 124, 0.24), transparent 65%);
}
.ambient-two {
  width: min(500px, 100vw); height: 500px; left: 0; bottom: -260px;
  background: radial-gradient(ellipse, rgba(42, 97, 124, 0.26), transparent 75%);
}

/* Header */
.site-header {
  border-bottom: 1px solid rgba(199, 225, 226, 0.12);
  background: rgba(8, 29, 46, 0.86);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 40;
}
.header-inner {
  max-width: 1120px; min-height: 76px; padding: 10px 32px; margin: auto;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: inline-flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; flex: none;
  background: linear-gradient(135deg, #9be6d0, #427f8f); color: #052030; font-size: 22px; font-weight: 900;
}
.brand-text { display: flex; flex-direction: column; gap: 2px; line-height: 1.2; min-width: 0; }
.brand-text strong { font-size: 19px; letter-spacing: 0.01em; }
.brand-text small { font-size: 11px; letter-spacing: 0.14em; color: var(--muted); }

.site-nav { display: flex; align-items: center; flex-wrap: wrap; gap: 20px; font-size: 13.5px; font-weight: 600; color: #c8d8dc; }
.site-nav > a:not(.nav-cta):hover { color: var(--mint); }
.nav-cta {
  display: inline-flex; align-items: center; gap: 8px; color: #082132;
  background: var(--mint); padding: 9px 15px; border-radius: 8px; font-weight: 800;
  transition: background 0.18s ease, transform 0.18s ease;
}
.nav-cta:hover { background: #b6f2d9; transform: translateY(-1px); }

/* Main container */
.my-travel-main {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 40px 32px 72px;
  flex: 1 0 auto;
}

.eyebrow, .kicker { font-size: 11px; font-weight: 800; letter-spacing: 0.16em; }
.eyebrow { display: inline-flex; align-items: center; gap: 10px; color: var(--mint); margin: 0 0 14px; }
.eyebrow-line { width: 24px; height: 1px; background: var(--mint); flex: none; }
.kicker { color: var(--mint); margin: 0 0 6px; }
.muted { color: var(--muted); }

/* Hero & Traveler Summary Strip */
.travel-hero { padding-bottom: 32px; }
.travel-hero h1, .debug-hero h1 {
  font-family: Georgia, 'Noto Serif TC', serif;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.28;
  letter-spacing: -0.02em;
  margin: 0 0 12px;
}
.hero-lead { max-width: 680px; color: #bed1d6; font-size: 15px; line-height: 1.85; margin: 0 0 22px; }

.traveler-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--stroke);
  border-radius: 16px;
  background: rgba(16, 43, 63, 0.56);
  backdrop-filter: blur(8px);
  overflow: hidden;
}
.strip-item {
  padding: 16px 20px;
  border-left: 1px solid var(--stroke);
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.strip-item:first-child { border-left: 0; }
.strip-label { font-size: 12px; color: var(--muted); }
.strip-value { font-size: 18px; color: var(--ink); overflow-wrap: anywhere; }

.vip-honor-bar {
  margin: 14px 0 0;
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid rgba(245, 199, 139, 0.45);
  background: rgba(245, 199, 139, 0.1);
  color: var(--sun);
  font-size: 13.5px;
  font-weight: 700;
}

/* Source Banner & Switcher */
.source-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  margin: 0 0 18px;
  border-radius: 14px;
  border: 1px solid rgba(139, 223, 195, 0.28);
  background: rgba(16, 43, 63, 0.68);
}
.source-banner-info { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; min-width: 0; flex: 1 1 280px; }
.source-banner-text { font-size: 13.5px; color: #cde0e5; line-height: 1.5; }
.source-pill {
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 800; letter-spacing: 0.04em;
  background: rgba(139, 223, 195, 0.16); color: var(--mint); border: 1px solid rgba(139, 223, 195, 0.34);
  flex: none;
}
.source-pill--cloud { background: rgba(139, 223, 195, 0.2); color: var(--mint); }
.source-pill--warn { background: rgba(248, 180, 112, 0.18); color: var(--warn); border-color: rgba(248, 180, 112, 0.45); }

.source-switch-group, .sort-switch { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.switch-btn {
  appearance: none;
  background: rgba(11, 33, 50, 0.72);
  color: var(--muted);
  border: 1px solid var(--stroke);
  border-radius: 999px;
  padding: 6px 13px;
  font: 600 12.5px/1.3 var(--font);
  cursor: pointer;
  transition: all 0.16s ease;
}
.switch-btn:hover { color: var(--ink); border-color: rgba(139, 223, 195, 0.52); }
.switch-btn.is-active {
  background: var(--mint);
  color: #082030;
  border-color: var(--mint);
  font-weight: 800;
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: 10px; font: 700 14px/1.3 var(--font);
  border: 1px solid transparent; cursor: pointer; transition: all 0.18s ease;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--mint); color: #072030; }
.btn-primary:hover:not(:disabled) { background: #b6f2d9; }
.btn-secondary { background: rgba(16, 43, 63, 0.75); color: var(--ink); border-color: var(--stroke); }
.btn-secondary:hover:not(:disabled) { border-color: rgba(139, 223, 195, 0.55); color: var(--mint); }

/* Empty & Corrupt State Cards */
.state-card {
  padding: 32px;
  border-radius: 18px;
  border: 1px solid var(--stroke);
  background: rgba(16, 43, 63, 0.62);
  max-width: 720px;
}
.state-card--warn { border-color: rgba(248, 180, 112, 0.48); background: rgba(48, 34, 24, 0.44); }
.state-card h2 { font-family: Georgia, 'Noto Serif TC', serif; font-size: clamp(22px, 3vw, 28px); margin-bottom: 12px; }
.state-card-copy { color: #cbe0e5; line-height: 1.85; margin-bottom: 14px; }
.state-card-note { color: var(--sun); font-size: 14px; margin-bottom: 22px; }
.card-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 20px; }

/* Sections & KPI Grid */
.content-section { margin-top: 32px; }
.section-head { margin-bottom: 18px; }
.section-head--split {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px;
}
.section-head h2 {
  font-family: Georgia, 'Noto Serif TC', serif;
  font-size: clamp(22px, 2.6vw, 30px);
  margin: 0;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.kpi-card {
  padding: 18px 20px;
  border-radius: 16px;
  border: 1px solid var(--stroke);
  background: rgba(16, 43, 63, 0.58);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.kpi-card--mint { border-color: rgba(139, 223, 195, 0.36); }
.kpi-card--sun { border-color: rgba(245, 199, 139, 0.36); }
.kpi-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.kpi-value {
  font-family: Georgia, 'Noto Serif TC', serif;
  font-size: clamp(22px, 2.3vw, 28px);
  line-height: 1.25;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.kpi-card--mint .kpi-value { color: var(--mint); }
.kpi-card--sun .kpi-value { color: var(--sun); }
.kpi-note { font-size: 12.5px; color: var(--muted); line-height: 1.55; margin: 2px 0 0; }
.kpi-inline-link { margin-top: 6px; font-size: 13px; font-weight: 700; color: var(--mint); }
.kpi-inline-link:hover { text-decoration: underline; }

.progress-track {
  width: 100%; height: 6px; border-radius: 999px;
  background: rgba(198, 229, 223, 0.14); overflow: hidden; margin: 4px 0 2px;
}
.progress-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--mint), var(--sun));
  transition: width 0.3s ease;
}

/* Minimal Text State Footprints */
.footprint-empty {
  padding: 24px 26px;
  border-radius: 16px;
  border: 1px dashed var(--stroke);
  background: rgba(16, 43, 63, 0.38);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.footprint-empty p { margin: 0; color: #c4d7dc; max-width: 620px; }

.footprint-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}
.footprint-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 20px;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: rgba(16, 43, 63, 0.54);
}
.footprint-main { min-width: 0; flex: 1 1 240px; }
.footprint-name-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 3px; }
.footprint-state-name { font-size: 17px; color: var(--ink); }
.footprint-meta { margin: 0; font-size: 13px; color: var(--muted); }
.footprint-tag {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 700;
}
.footprint-tag--current {
  background: rgba(139, 223, 195, 0.18); color: var(--mint); border: 1px solid rgba(139, 223, 195, 0.42);
}
.footprint-tag--chest {
  background: rgba(245, 199, 139, 0.16); color: var(--sun); border: 1px solid rgba(245, 199, 139, 0.38);
}
.footprint-count {
  font-size: 13px; font-weight: 700; color: var(--sun);
  padding: 4px 11px; border-radius: 999px;
  background: rgba(245, 199, 139, 0.1); border: 1px solid rgba(245, 199, 139, 0.25);
  white-space: nowrap;
}

/* Debug Workspace */
.debug-workspace { display: grid; gap: 20px; }
.debug-top-row {
  display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 16px;
  margin-bottom: 14px;
}
.debug-panel {
  padding: 22px 24px;
  border-radius: 16px;
  border: 1px solid var(--stroke);
  background: rgba(11, 33, 50, 0.78);
  min-width: 0;
}
.debug-panel h2 { font-size: 18px; margin: 0 0 14px; color: var(--ink); }
.debug-panel-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 14px;
}
.debug-panel-head h2 { margin: 0; }

.debug-meta-grid {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 18px;
}
.debug-meta-item {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(8, 25, 38, 0.62);
  border: 1px solid rgba(198, 229, 223, 0.12);
  min-width: 0;
}
.debug-meta-item dt { font: 700 11.5px/1.3 var(--mono); color: var(--muted); margin-bottom: 4px; }
.debug-meta-item dd { margin: 0; font: 600 13px/1.45 var(--mono); color: var(--ink); overflow-wrap: anywhere; }

.debug-error-banner {
  margin: 14px 0 0;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(252, 165, 165, 0.4);
  color: var(--danger);
  font-size: 13.5px;
  overflow-wrap: anywhere;
}

.diag-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.diag-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  background: rgba(8, 25, 38, 0.56);
  border: 1px solid rgba(198, 229, 223, 0.11);
}
.diag-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 72px; padding: 3px 9px; border-radius: 999px;
  font: 800 11px/1.3 var(--mono); letter-spacing: 0.04em; flex: none;
}
.diag-badge--pass { background: rgba(139, 223, 195, 0.18); color: var(--mint); border: 1px solid rgba(139, 223, 195, 0.4); }
.diag-badge--warn { background: rgba(248, 180, 112, 0.18); color: var(--warn); border: 1px solid rgba(248, 180, 112, 0.45); }
.diag-badge--fail { background: rgba(239, 68, 68, 0.18); color: var(--danger); border: 1px solid rgba(252, 165, 165, 0.45); }
.diag-badge--skipped { background: rgba(172, 192, 199, 0.14); color: var(--muted); border: 1px solid rgba(172, 192, 199, 0.3); }
.diag-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.diag-label { font-size: 13.5px; color: var(--ink); }
.diag-detail { font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }

.debug-accordion-stack { display: grid; gap: 10px; }
.debug-details {
  border-radius: 12px;
  border: 1px solid rgba(198, 229, 223, 0.16);
  background: rgba(8, 25, 38, 0.65);
  overflow: hidden;
}
.debug-summary {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 15px; cursor: pointer; list-style: none; user-select: none;
}
.debug-summary::-webkit-details-marker { display: none; }
.debug-summary-key { font: 700 13.5px/1.4 var(--mono); color: var(--mint); }
.debug-summary-meta { font: 500 12px/1.4 var(--mono); color: var(--muted); }
.debug-code {
  margin: 0;
  padding: 14px 16px;
  border-top: 1px solid rgba(198, 229, 223, 0.12);
  background: #061522;
  color: #d6ebe5;
  font: 12.5px/1.6 var(--mono);
  overflow-x: auto;
  max-height: 460px;
  white-space: pre-wrap;
  word-break: break-word;
}
.debug-code--raw { max-height: 540px; }

.debug-toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.action-feedback { margin: 0 0 12px; font-size: 13px; color: var(--mint); }
.action-feedback.is-error { color: var(--danger); }

/* Footer */
.site-footer {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 32px 36px;
  border-top: 1px solid rgba(198, 229, 223, 0.12);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
}
.footer-brand { font-weight: 800; color: var(--ink); }
.footer-links { display: inline-flex; flex-wrap: wrap; gap: 14px; }
.footer-links a:hover { color: var(--mint); }

/* Responsive Breakpoints */
@media (max-width: 960px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .header-inner { padding: 12px 18px; flex-wrap: wrap; }
  .site-nav { width: 100%; justify-content: space-between; gap: 12px; font-size: 13px; }
  .my-travel-main { padding: 28px 18px 56px; }
  .traveler-strip { grid-template-columns: 1fr; }
  .strip-item { border-left: 0; border-top: 1px solid var(--stroke); }
  .strip-item:first-child { border-top: 0; }
  .debug-meta-grid { grid-template-columns: 1fr; }
  .site-footer { padding: 20px 18px 32px; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .state-card, .debug-panel { padding: 20px 16px; }
  .diag-row { flex-direction: column; gap: 6px; }
  .btn { width: 100%; }
  .card-actions, .debug-toolbar { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
