/* ============================================
   Travel Guide Design System
   Mobile-first | Capsule Buttons | Rounded Cards
   ============================================ */

/* ---------- CSS Variables ---------- */
:root {
  --primary: #0E7C86;
  --secondary: #2F5F98;
  --accent: #F97316;
  --bg: #F2F7F5;
  --card: #FFFFFF;
  --white: #FFFFFF;
  --text-main: #17211F;
  --text: var(--text-main);
  --text-sub: #5F6F6B;
  --text-hint: #8A9A96;
  --success: #16A34A;
  --warning: #D97706;
  --danger: #DC2626;
  --primary-light: rgba(14, 124, 134, 0.1);
  --primary-dark: #07565D;
  --accent-light: rgba(249, 115, 22, 0.12);

  --gradient: linear-gradient(135deg, #0E7C86, #2F5F98);
  --gradient-warm: linear-gradient(135deg, #F97316, #FACC15);
  --shadow: 0 10px 28px rgba(23, 33, 31, 0.08);
  --shadow-fab: 0 12px 32px rgba(14, 124, 134, 0.28);
  --radius-lg: 18px;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-btn: 999px;
  --radius-input: 12px;
  --radius-img: 12px;

  --font: -apple-system, 'PingFang SC', 'Helvetica Neue', sans-serif;
}


/* ============================================
   1. Global Reset & Base
   ============================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 22px;
  font-weight: 400;
  color: var(--text-main);
  background:
    linear-gradient(180deg, rgba(14, 124, 134, 0.08), transparent 260px),
    radial-gradient(circle at 16% 0%, rgba(249, 115, 22, 0.08), transparent 240px),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: opacity 0.2s;
}

a:active {
  opacity: 0.7;
}

img {
  display: block;
  max-width: 100%;
}

ul, ol {
  list-style: none;
}

input, button, textarea, select {
  font: inherit;
  color: inherit;
  border: none;
  outline: none;
  background: none;
}

button {
  cursor: pointer;
}

/* Container - mobile first max-width 480px, desktop 720px */
.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}


/* ============================================
   2. Navigation Bar
   ============================================ */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--card);
  box-shadow: 0 1px 8px rgba(15, 23, 42, 0.04);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 16px;
}

.nav-logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.5px;
}

.nav-logo::before {
  content: '✈️';
  margin-right: 6px;
  font-size: 16px;
}

.nav-links {
  display: flex;
  gap: 16px;
  align-items: center;
}

.nav-links a {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-sub);
  padding: 4px 0;
  position: relative;
}

.nav-links a.active {
  color: var(--primary);
}

.nav-links a.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--gradient);
  border-radius: 1px;
}


/* ============================================
   3. Hero Area
   ============================================ */
.hero {
  background: var(--gradient);
  color: #fff;
  padding: 48px 24px 56px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -40%;
  right: -20%;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
}

.hero::after {
  content: '';
  position: absolute;
  bottom: -30%;
  left: -15%;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
}

.hero-title {
  font-size: 28px;
  line-height: 32px;
  font-weight: 700;
  margin-bottom: 8px;
  position: relative;
  z-index: 1;
}

.hero-subtitle {
  font-size: 14px;
  line-height: 22px;
  opacity: 0.85;
  margin-bottom: 24px;
  position: relative;
  z-index: 1;
}

.hero-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  position: relative;
  z-index: 1;
}


/* ============================================
   4. Search Bar
   ============================================ */
.search-section {
  padding: 16px 0 8px;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--card);
  border-radius: var(--radius-btn);
  padding: 4px 4px 4px 20px;
  box-shadow: var(--shadow);
}

.search-bar input {
  flex: 1;
  height: 40px;
  font-size: 14px;
  line-height: 22px;
  color: var(--text-main);
  min-width: 0;
}

.search-bar input::placeholder {
  color: var(--text-sub);
}

.search-bar .btn {
  flex-shrink: 0;
  border-radius: var(--radius-btn);
  padding: 10px 24px;
}


/* ============================================
   5. Tags / Pills (horizontal scroll)
   ============================================ */
.tags {
  display: flex;
  gap: 8px;
  padding: 12px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
}

.tags::-webkit-scrollbar {
  display: none;
}

.tag {
  flex-shrink: 0;
  scroll-snap-align: start;
  padding: 6px 18px;
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
  color: var(--text-sub);
  background: var(--card);
  border: 1.5px solid transparent;
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  white-space: nowrap;
}

.tag:hover {
  color: var(--primary);
  border-color: var(--primary);
}

.tag.active {
  color: #fff;
  background: var(--gradient);
  border-color: transparent;
}

/* Hot words */
.hot-words {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 0 4px;
}

.hot-word {
  padding: 5px 14px;
  background: var(--card);
  border-radius: var(--radius-btn);
  font-size: 12px;
  line-height: 18px;
  color: var(--text-sub);
  cursor: pointer;
  border: 1px solid #f0f0f0;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.hot-word:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(91, 140, 255, 0.06);
}

.hot-word:nth-child(-n+3) {
  color: var(--accent);
  font-weight: 600;
}


/* ============================================
   6. Card Base
   ============================================ */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform 0.2s;
  will-change: transform;
}

.card:hover {
  transform: translateY(-2px);
}

.card:active {
  transform: scale(0.98);
}

.card-body {
  padding: 14px 16px;
}


/* ============================================
   7. Waterfall / Masonry
   ============================================ */
.waterfall {
  columns: 2;
  column-gap: 12px;
  padding: 8px 0;
}

.waterfall .card {
  break-inside: avoid;
  margin-bottom: 12px;
}


/* ============================================
   8. Guide Card (Waterfall item)
   ============================================ */
.guide-card {
  position: relative;
}

.guide-card .cover-wrap {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-img) var(--radius-img) 0 0;
}

.guide-card img {
  width: 100%;
  display: block;
  object-fit: cover;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius-img) var(--radius-img) 0 0;
}

.guide-card .card-body {
  padding: 10px 12px;
}

.guide-card .title {
  font-size: 14px;
  font-weight: 600;
  line-height: 22px;
  color: var(--text-main);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.guide-card .meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 12px;
  line-height: 18px;
  color: var(--text-sub);
}

.guide-card .author {
  display: flex;
  align-items: center;
  gap: 4px;
}

.guide-card .likes {
  color: var(--accent);
  font-weight: 600;
}

.guide-card .dest-tag {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 2px 10px;
  font-size: 11px;
  color: #fff;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  border-radius: var(--radius-btn);
}

.collect-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.2s;
  border: none;
}

.collect-btn:active {
  transform: scale(1.2);
}

.collect-btn.active {
  color: var(--danger);
}


/* ============================================
   9. Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
  border-radius: var(--radius-btn);
  border: none;
  cursor: pointer;
  transition: transform 0.2s, background 0.2s, color 0.2s, box-shadow 0.2s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--gradient);
  color: #fff;
  box-shadow: 0 4px 16px rgba(91, 140, 255, 0.3);
  will-change: transform;
}

.btn-primary:hover {
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}

.btn-outline:hover {
  background: rgba(91, 140, 255, 0.06);
}

.btn-ghost {
  background: transparent;
  color: var(--text-sub);
  padding: 8px 12px;
}

.btn-sm {
  padding: 6px 16px;
  font-size: 12px;
  line-height: 18px;
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn-accent {
  background: var(--accent);
  color: #fff;
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

/* White button for hero */
.btn-white {
  background: #fff;
  color: var(--primary);
  font-weight: 700;
}

.btn-white:hover {
  box-shadow: 0 6px 20px rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

/* Disabled state */
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}


/* ============================================
   10. Forms
   ============================================ */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  line-height: 22px;
  color: var(--text-main);
  margin-bottom: 6px;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 12px 16px;
  font-size: 14px;
  line-height: 22px;
  color: var(--text-main);
  background: var(--card);
  border: 1.5px solid #e5e7eb;
  border-radius: var(--radius-input);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-sub);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91, 140, 255, 0.15);
}

.form-group textarea {
  resize: vertical;
  min-height: 100px;
}


/* ============================================
   11. Bottom Tab Bar
   ============================================ */
.tab-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 -10px 32px rgba(23, 33, 31, 0.1);
  border-top: 1px solid rgba(14, 124, 134, 0.08);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex; align-items: flex-end; justify-content: space-around;
  padding: 0 4px;
  padding-bottom: env(safe-area-inset-bottom);
  height: calc(60px + env(safe-area-inset-bottom));
}
.tab-bar a {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 6px 0 4px;
  font-size: 10px; line-height: 14px; color: var(--text-sub);
  transition: color .2s; text-decoration: none; gap: 2px;
  will-change: transform;
}
.tab-bar a svg { flex-shrink: 0; }
.tab-bar a.active { color: var(--primary); }
.tab-bar a.active svg { stroke: var(--primary); }

/* Center trip launcher - raised circle */
.tab-bar .tab-ai {
  position: relative; top: -14px; flex: none;
  display: flex; flex-direction: column; align-items: center;
  text-decoration: none; margin: 0 8px; gap: 2px;
}
.tab-bar .tab-ai .tab-ai-btn {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--gradient);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-fab);
  transition: transform .2s;
}
.tab-bar .tab-ai .tab-ai-btn svg { stroke: #fff; }
.tab-bar .tab-ai:active .tab-ai-btn { transform: scale(.95); }
.tab-bar .tab-ai span { font-size: 11px; color: var(--primary); font-weight: 900; letter-spacing: .2px; }


/* ============================================
   12. Toast
   ============================================ */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  padding: 10px 28px;
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
  color: #fff;
  background: rgba(31, 41, 55, 0.9);
  backdrop-filter: blur(8px);
  border-radius: var(--radius-btn);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  animation: toastIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  white-space: nowrap;
}

.toast-success { background: rgba(34, 197, 94, 0.92); }
.toast-warning { background: rgba(245, 158, 11, 0.92); }
.toast-error   { background: rgba(239, 68, 68, 0.92); }

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-12px) scale(0.9);
  }
}


/* ============================================
   13. Loading Overlay
   ============================================ */
.loading {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(91, 140, 255, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  font-size: 14px;
  color: var(--text-sub);
  animation: loadingDots 1.5s ease-in-out infinite;
}

@keyframes loadingDots {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}


/* ============================================
   14. Avatar
   ============================================ */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-sm { width: 28px; height: 28px; font-size: 12px; }
.avatar-lg { width: 56px; height: 56px; font-size: 22px; }
.avatar-xl { width: 72px; height: 72px; font-size: 28px; }


/* ============================================
   15. Empty State
   ============================================ */
.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-sub);
}

.empty .empty-icon {
  font-size: 56px;
  margin-bottom: 12px;
  line-height: 1;
}

.empty .empty-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 22px;
  color: var(--text-main);
  margin-bottom: 4px;
}

.empty .empty-desc {
  font-size: 14px;
  line-height: 22px;
  color: var(--text-sub);
  margin-bottom: 16px;
}


/* ============================================
   16. Spinner Section (Compact)
   ============================================ */
.spinner-section {
  background: var(--gradient);
  border-radius: var(--radius-lg);
  padding: 20px 16px;
  margin: 12px 0;
  text-align: center;
  color: #fff;
  position: relative;
  overflow: hidden;
}

.spinner-section::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -30%;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
}

.spinner-section h3 {
  font-size: 16px;
  font-weight: 700;
  line-height: 22px;
  margin-bottom: 2px;
  position: relative;
  z-index: 1;
}

.spinner-section .hint {
  font-size: 12px;
  line-height: 18px;
  opacity: 0.75;
  margin-bottom: 12px;
  position: relative;
  z-index: 1;
}

.spinner-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  position: relative;
  z-index: 1;
}

.spinner-wrap {
  position: relative;
  flex-shrink: 0;
}

.spinner-pointer {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 18px;
  z-index: 2;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.3));
}

#spinnerCanvas {
  display: block;
  border-radius: 50%;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

#spinBtn {
  padding: 10px 32px;
  border-radius: var(--radius-btn);
  font-size: 15px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  background: #fff;
  color: var(--primary);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: transform 0.15s, box-shadow 0.15s;
}

#spinBtn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

#spinBtn:active {
  transform: translateY(0);
}


/* ============================================
   17. Postcard Modal
   ============================================ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
}

.postcard {
  position: relative;
  z-index: 1;
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 36px 24px 24px;
  text-align: center;
  max-width: 300px;
  width: 88%;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.2);
  animation: postcardIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.postcard-emoji {
  font-size: 56px;
  margin-bottom: 8px;
  line-height: 1;
}

.postcard-city {
  font-size: 22px;
  font-weight: 700;
  line-height: 28px;
  color: var(--text-main);
}

.postcard-tagline {
  font-size: 12px;
  line-height: 18px;
  color: var(--text-sub);
  font-style: italic;
  margin: 6px 0 4px;
}

.postcard-desc {
  font-size: 14px;
  line-height: 22px;
  color: var(--text-sub);
  margin-bottom: 20px;
}

.postcard .btn {
  margin: 4px;
}

@keyframes postcardIn {
  from {
    transform: scale(0.7) rotate(-3deg);
    opacity: 0;
  }
  to {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}


/* ============================================
   18. Category Grid (2x5)
   ============================================ */
.category-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px 8px;
  padding: 16px 0;
}

.category-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--text-main);
  transition: transform 0.2s;
}

.category-item:active {
  transform: scale(0.95);
}

.category-icon {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(91, 140, 255, 0.1), rgba(123, 97, 255, 0.1));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  line-height: 1;
}

.category-name {
  font-size: 12px;
  line-height: 18px;
  font-weight: 500;
  text-align: center;
  color: var(--text-sub);
}


/* ============================================
   19. Destination Card (Square)
   ============================================ */
.dest-card {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 1 / 1;
  cursor: pointer;
}

.dest-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.dest-card .dest-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 32px 12px 12px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.6), transparent);
  color: #fff;
}

.dest-card .dest-name {
  font-size: 16px;
  font-weight: 600;
  line-height: 22px;
}

.dest-card .dest-sub {
  font-size: 12px;
  line-height: 18px;
  opacity: 0.8;
}


/* ============================================
   20. Experience Card
   ============================================ */
.exp-card {
  display: flex;
  gap: 12px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
  transition: transform 0.2s;
}

.exp-card:active {
  transform: scale(0.98);
}

.exp-card .exp-img {
  width: 100px;
  height: 100px;
  border-radius: var(--radius-img);
  object-fit: cover;
  flex-shrink: 0;
}

.exp-card .exp-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.exp-card .exp-type {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  color: var(--primary);
  background: rgba(91, 140, 255, 0.08);
  border-radius: var(--radius-btn);
  align-self: flex-start;
}

.exp-card .exp-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 22px;
  color: var(--text-main);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 4px;
}

.exp-card .exp-summary {
  font-size: 12px;
  line-height: 18px;
  color: var(--text-sub);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 2px;
}

.exp-card .exp-stats {
  display: flex;
  gap: 16px;
  font-size: 12px;
  line-height: 18px;
  color: var(--text-sub);
  margin-top: 6px;
}

.exp-card .exp-stats span {
  display: flex;
  align-items: center;
  gap: 4px;
}


/* ============================================
   21. AI Input Area
   ============================================ */
.ai-input-area {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.ai-input-area::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  padding: 2px;
  background: var(--gradient);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.ai-input-area .ai-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 22px;
  color: var(--text-main);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-input-area textarea {
  width: 100%;
  min-height: 80px;
  padding: 12px 16px;
  font-size: 14px;
  line-height: 22px;
  color: var(--text-main);
  border: 1.5px solid #e5e7eb;
  border-radius: var(--radius-input);
  resize: vertical;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: var(--card);
}

.ai-input-area textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91, 140, 255, 0.15);
}

.ai-input-area .ai-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}


/* ============================================
   22. Page Hero (with rounded bottom)
   ============================================ */
.page-hero {
  background: var(--gradient);
  color: #fff;
  padding: 32px 20px 40px;
  margin: 0 -16px;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  position: relative;
  overflow: hidden;
}

.page-hero::before {
  content: '';
  position: absolute;
  top: -30%;
  right: -15%;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
}

.page-hero h1 {
  font-size: 28px;
  line-height: 32px;
  font-weight: 700;
  margin-bottom: 4px;
  position: relative;
  z-index: 1;
}

.page-hero p {
  font-size: 14px;
  line-height: 22px;
  opacity: 0.85;
  position: relative;
  z-index: 1;
}


/* ============================================
   Section Title
   ============================================ */
.section-title {
  font-size: 22px;
  font-weight: 700;
  line-height: 28px;
  color: var(--text-main);
  padding: 20px 0 12px;
}

.section-subtitle {
  font-size: 14px;
  line-height: 22px;
  color: var(--text-sub);
  margin-top: -8px;
  padding-bottom: 12px;
}


/* ============================================
   Utility Classes
   ============================================ */
.text-center { text-align: center; }
.text-main   { color: var(--text-main); }
.text-sub    { color: var(--text-sub); }
.text-primary { color: var(--primary); }
.text-accent  { color: var(--accent); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }

.fw-400 { font-weight: 400; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.p-16  { padding: 16px; }

.hidden  { display: none !important; }
.flex    { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.w-full { width: 100%; }

/* Truncate */
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}


/* ============================================
   Desktop Responsive (min-width: 768px)
   ============================================ */
@media (min-width: 768px) {
  .container {
    max-width: 720px;
  }

  .nav-inner {
    max-width: 720px;
  }

  .waterfall {
    columns: 3;
    column-gap: 16px;
  }

  .waterfall .card {
    margin-bottom: 16px;
  }

  .category-grid {
    gap: 16px 12px;
  }

  .hero {
    padding: 64px 32px 72px;
  }

  .hero-title {
    font-size: 36px;
    line-height: 42px;
  }

  .page-hero {
    padding: 48px 32px 56px;
  }
}


/* ============================================
   Scroll Entrance Animations
   ============================================ */
.anim-fade-in {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity .5s ease, transform .5s ease;
}
.anim-fade-in.anim-visible {
  opacity: 1;
  transform: translateY(0);
}
.anim-fade-in.anim-delay-1 { transition-delay: .08s; }
.anim-fade-in.anim-delay-2 { transition-delay: .16s; }
.anim-fade-in.anim-delay-3 { transition-delay: .24s; }
.anim-fade-in.anim-delay-4 { transition-delay: .32s; }
.anim-fade-in.anim-delay-5 { transition-delay: .4s; }

/* ============================================
   View Transitions API
   ============================================ */
@view-transition {
  navigation: auto;
}
body.home-page::view-transition-old(root),
body.home-page::view-transition-new(root) {
  animation: none;
}

::view-transition-old(root) {
  animation: 200ms ease-out both fade-out;
}
::view-transition-new(root) {
  animation: 300ms ease-out both fade-in;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fade-out {
  from { opacity: 1; }
  to { opacity: 0.3; }
}

/* ============================================
   Page Transition Animation Classes
   ============================================ */
.page-enter {
  animation: pageSlideUp .35s ease-out both;
}
@keyframes pageSlideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Tab bar active indicator transition */
.tab-bar a.active::after,
.tab-bar a.active span {
  transition: all .2s ease;
}

/* Smooth hover transitions for interactive elements */
a, button, .card, .chip, .hero-quick-tag, .persona-item {
  transition: all .15s ease;
}

/* ============================================
   Mobile / iOS Safe Area
   ============================================ */
@supports (padding: env(safe-area-inset-top)) {
  .tab-bar {
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }
  .cover-shell, .hero-wrap {
    padding-top: env(safe-area-inset-top);
  }
  .back-btn, .detail-header {
    top: calc(16px + env(safe-area-inset-top));
  }
}

/* Prevent iOS rubber-band overscroll bounce on inputs */
@supports (-webkit-touch-callout: none) {
  input, textarea, select {
    font-size: 16px !important;
  }
}

/* ============================================
   Foldable / Wide Screen
   ============================================ */
@media (min-width: 480px) {
  .detail-header, .route-content-panel, .city-header, .content-panel {
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
  }
}
@media (min-width: 768px) {
  .detail-header, .route-content-panel, .city-header, .content-panel {
    max-width: 720px;
  }
  .persona-test, .rank-section, .pit-section, .eye-section {
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
  }
}
@media (min-width: 1024px) {
  .detail-header, .route-content-panel, .city-header, .content-panel {
    max-width: 960px;
  }
  .node-card { padding: 18px; }
  .rank-scroll, .city-scroll, .route-scroll { gap: 16px; }
}

/* ============================================
   Dark Mode (manual toggle via .dark class)
   ============================================ */
.dark {
  --bg: #0F1A1A;
  --card: #1A2727;
  --white: #1A2727;
  --text-main: #E2EFED;
  --text: var(--text-main);
  --text-sub: #9AB0AC;
  --text-hint: #6B8580;
  --primary-light: rgba(14, 124, 134, .2);
  --shadow: 0 4px 20px rgba(0,0,0,.3);
  --shadow-fab: 0 8px 28px rgba(0,0,0,.4);
}
.dark body { background: #0F1A1A; color: #E2EFED; }
.dark .node-card, .dark .info-card, .dark .transport-card, .dark .tips-card, .dark .food-item, .dark .hotel-item, .dark .budget-section, .dark .photo-card, .dark .rank-card, .dark .attr-city-card, .dark .comment-item, .dark .pitfall-item {
  background: #1A2727;
  border-color: rgba(14,124,134,.15);
  box-shadow: 0 4px 16px rgba(0,0,0,.3);
}
.dark .route-command-card, .dark .city-command-card {
  background: rgba(26,39,39,.96);
  border-color: rgba(14,124,134,.15);
}
.dark .cover-shell { background: #0A1212; }
.dark .content-shell, .dark .route-content-shell {
  background: rgba(26,39,39,.9);
  border-color: rgba(14,124,134,.12);
}
.dark .content-head {
  background: linear-gradient(180deg, #1A2727, #152020);
}
.dark .detail-tabs .tab { color: #6B8580; }
.dark .detail-tabs .tab.active { color: #4ECDC4; border-bottom-color: #4ECDC4; }
.dark .tab-bar { background: #1A2727; border-color: rgba(14,124,134,.15); }
.dark .tab-bar a { color: #6B8580; }
.dark .tab-bar a.active { color: #4ECDC4; }
.dark input, .dark textarea {
  background: #152020 !important;
  border-color: rgba(14,124,134,.2) !important;
  color: #E2EFED !important;
}
.dark .budget-row { background: #152020; }
.dark .attr-toggle-btn {
  background: linear-gradient(135deg, rgba(14,124,134,.15), rgba(47,95,152,.15));
  border-color: rgba(14,124,134,.3);
  color: #4ECDC4;
}
.dark .transport-connector .tc-info {
  background: #152020;
  border-color: rgba(14,124,134,.2);
  color: #9AB0AC;
}
.dark .meta-item, .dark .score-tag {
  background: rgba(14,124,134,.15);
  color: #4ECDC4;
}
.dark .command-kicker {
  background: rgba(14,124,134,.2);
  color: #4ECDC4;
}
.dark .budget-total {
  background: linear-gradient(135deg, rgba(14,124,134,.1), rgba(47,95,152,.1));
}
.dark .share-panel { background: #1A2727; }
.dark .nc-actions { border-color: rgba(14,124,134,.1); }
.dark .nc-checkin {
  background: #152020;
  border-color: rgba(14,124,134,.15);
  color: #9AB0AC;
}

/* Auto dark mode (when no manual toggle) */
@media (prefers-color-scheme: dark) {
  html:not(.dark):not(.light) {
    --bg: #0F1A1A;
    --card: #1A2727;
    --white: #1A2727;
    --text-main: #E2EFED;
    --text: var(--text-main);
    --text-sub: #9AB0AC;
    --text-hint: #6B8580;
    --primary-light: rgba(14, 124, 134, .2);
    --shadow: 0 4px 20px rgba(0,0,0,.3);
  }
  html:not(.dark):not(.light) body { background: #0F1A1A; color: #E2EFED; }
  html:not(.dark):not(.light) .node-card, html:not(.dark):not(.light) .info-card, html:not(.dark):not(.light) .budget-section, html:not(.dark):not(.light) .photo-card, html:not(.dark):not(.light) .rank-card, html:not(.dark):not(.light) .attr-city-card {
    background: #1A2727;
    border-color: rgba(14,124,134,.15);
  }
  html:not(.dark):not(.light) .route-command-card, html:not(.dark):not(.light) .city-command-card {
    background: rgba(26,39,39,.96);
  }
html:not(.dark):not(.light) .tab-bar { background: #1A2727; }
  html:not(.dark):not(.light) .detail-tabs .tab.active { color: #4ECDC4; border-bottom-color: #4ECDC4; }
}

/* Dark mode toggle button */
.dark-toggle {
  position: fixed !important;
  top: auto !important;
  bottom: calc(88px + env(safe-area-inset-bottom)) !important;
  right: max(12px, calc((100vw - 430px) / 2 + 12px)) !important;
  z-index: 1001 !important;
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(0,0,0,.3); border: 1px solid rgba(255,255,255,.15);
  color: #fff; font-size: 16px; cursor: pointer;
  display: flex !important; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
  box-shadow: 0 12px 26px rgba(23, 33, 31, .18);
}

body.home-page .home-section,
body.discover-page .section,
body.profile-page main > section,
body.guide-detail-page .city-brief-card,
body.guide-detail-page .route-content-panel,
body.city-detail-page .content-panel,
body.luggage-page .lg-card,
body.luggage-page .section-head,
.container.ai-page #aiResultArea .ai-result,
.page-wrap .todo-toolbar,
.page-wrap .task-board {
  position: relative;
}

body.home-page .home-section + .home-section::before,
body.discover-page .section + .section::before,
body.profile-page main > section + section::before,
body.guide-detail-page .route-content-panel::before,
body.city-detail-page .content-panel::before,
body.luggage-page .lg-card + .lg-card::before,
body.luggage-page .section-head::before,
.container.ai-page #aiResultArea .ai-result::before,
.page-wrap .todo-toolbar::before,
.page-wrap .task-board::before {
  content: '';
  position: absolute;
  left: 16px;
  right: 16px;
  top: -10px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(48, 38, 27, .16), transparent);
}

body.guide-detail-page .timeline-day + .timeline-day,
body.luggage-page .pack-section + .pack-section {
  position: relative;
}

body.guide-detail-page .timeline-day + .timeline-day::before,
body.luggage-page .pack-section + .pack-section::before {
  content: '';
  position: absolute;
  left: 16px;
  right: 16px;
  top: -6px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(48, 38, 27, .14), transparent);
}

html.dark body.home-page .home-section + .home-section::before,
html.dark body.discover-page .section + .section::before,
html.dark body.profile-page main > section + section::before,
html.dark body.guide-detail-page .route-content-panel::before,
html.dark body.city-detail-page .content-panel::before,
html.dark body.luggage-page .lg-card + .lg-card::before,
html.dark body.luggage-page .section-head::before,
html.dark .container.ai-page #aiResultArea .ai-result::before,
html.dark .page-wrap .todo-toolbar::before,
html.dark .page-wrap .task-board::before,
html.dark body.guide-detail-page .timeline-day + .timeline-day::before,
html.dark body.luggage-page .pack-section + .pack-section::before {
  background: linear-gradient(90deg, transparent, rgba(255,252,247,.16), transparent);
}

body.guide-detail-page .route-content-panel.anim-fade-in,
body.guide-detail-page .city-brief-card.anim-fade-in,
body.discover-page .discover-hero .anim-fade-in,
body.home-page .home-hero .anim-fade-in,
body.home-page .inspiration-priority.anim-fade-in {
  opacity: 1;
  transform: none;
  transition: none;
}

/* ============================================
   Unified bottom tab safety net
   Keeps the main app tabs visible across redesigned pages.
   ============================================ */
.tab-bar {
  position: fixed !important;
  left: 50% !important;
  right: auto !important;
  bottom: 0 !important;
  width: 100% !important;
  max-width: 430px !important;
  transform: translateX(-50%) !important;
  z-index: 999 !important;
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  background: rgba(255,252,247,.92) !important;
  border-top: 1px solid rgba(48,38,27,.07) !important;
  box-shadow: 0 -14px 34px rgba(48,38,27,.08) !important;
  backdrop-filter: blur(22px) saturate(180%) !important;
  -webkit-backdrop-filter: blur(22px) saturate(180%) !important;
}
.tab-bar .tab-ai .tab-ai-btn {
  border-radius: 19px !important;
  background: linear-gradient(135deg, #F06D2F, #D94B1F) !important;
  box-shadow: 0 12px 24px rgba(240,109,47,.30) !important;
}

/* ============================================
   Unified dark mode for redesigned pages
   ============================================ */
html.dark {
  color-scheme: dark;
  --bg: #101817;
  --card: #182321;
  --white: #182321;
  --text-main: #F7F1E9;
  --text: #F7F1E9;
  --text-sub: #CFC3B4;
  --text-hint: #9F9385;
  --primary-light: rgba(79, 209, 197, .14);
  --accent-light: rgba(240, 109, 47, .18);

  --home-bg: #101817; --home-paper: #182321; --home-ink: #F7F1E9; --home-soft: #CFC3B4; --home-muted: #9F9385; --home-line: rgba(255,252,247,.10); --home-brand-soft: rgba(79,209,197,.14); --home-accent-soft: rgba(240,109,47,.18);
  --d-bg: #101817; --d-paper: #182321; --d-ink: #F7F1E9; --d-soft: #CFC3B4; --d-muted: #9F9385; --d-line: rgba(255,252,247,.10); --d-brand-soft: rgba(79,209,197,.14); --d-accent-soft: rgba(240,109,47,.18);
  --ai-bg: #101817; --ai-paper: #182321; --ai-ink: #F7F1E9; --ai-soft: #CFC3B4; --ai-muted: #9F9385; --ai-line: rgba(255,252,247,.10); --ai-brand-soft: rgba(79,209,197,.14); --ai-accent-soft: rgba(240,109,47,.18);
  --p-bg: #101817; --p-paper: #182321; --p-ink: #F7F1E9; --p-soft: #CFC3B4; --p-muted: #9F9385; --p-line: rgba(255,252,247,.10); --p-brand-soft: rgba(79,209,197,.14); --p-accent-soft: rgba(240,109,47,.18);
  --m-bg: #101817; --m-paper: #182321; --m-ink: #F7F1E9; --m-soft: #CFC3B4; --m-muted: #9F9385; --m-line: rgba(255,252,247,.10); --m-brand-soft: rgba(79,209,197,.14); --m-accent-soft: rgba(240,109,47,.18);
  --todo-bg: #101817; --todo-paper: #182321; --todo-ink: #F7F1E9; --todo-soft: #CFC3B4; --todo-muted: #9F9385; --todo-line: rgba(255,252,247,.10); --todo-brand-soft: rgba(79,209,197,.14); --todo-accent-soft: rgba(240,109,47,.18);
  --c-bg: #101817; --c-paper: #182321; --c-ink: #F7F1E9; --c-soft: #CFC3B4; --c-muted: #9F9385; --c-line: rgba(255,252,247,.10); --c-brand-soft: rgba(79,209,197,.14);
  --skin-bg: #101817; --skin-paper: #182321; --skin-ink: #F7F1E9; --skin-soft: #CFC3B4; --skin-muted: #9F9385; --skin-line: rgba(255,252,247,.10); --skin-brand-soft: rgba(79,209,197,.14);
}
html.dark body {
  background:
    radial-gradient(circle at 18% 0%, rgba(240,109,47,.10), transparent 34%),
    radial-gradient(circle at 92% 18%, rgba(79,209,197,.12), transparent 28%),
    linear-gradient(180deg, #141C1B 0%, #101817 48%, #0D1413 100%) !important;
  color: #F7F1E9;
}
html.dark .planner-card,
html.dark .persona-card,
html.dark .surface,
html.dark .profile-card,
html.dark .route-item,
html.dark .tip-item,
html.dark .story-card,
html.dark .tool-card,
html.dark .pit-item-new,
html.dark .adopt-card,
html.dark .edit-section,
html.dark .ai-controls,
html.dark .ai-result,
html.dark .ai-loading,
html.dark .city-card,
html.dark .city-tile,
html.dark .explore-card-new,
html.dark .rank-box,
html.dark .context-strip,
html.dark .monthly-card,
html.dark .alert-panel,
html.dark .avoidance-card,
html.dark .info-card,
html.dark .attr-card,
html.dark .transport-card,
html.dark .tips-card,
html.dark .city-command-card,
html.dark .route-command-card,
html.dark .route-content-shell,
html.dark .content-shell {
  background: rgba(24,35,33,.94) !important;
  border-color: rgba(255,252,247,.10) !important;
  color: #F7F1E9 !important;
}
html.dark input,
html.dark textarea,
html.dark select,
html.dark .search-field,
html.dark .route-input,
html.dark .summary-cell,
html.dark .context-item,
html.dark .node-form,
html.dark .day-editor,
html.dark .form-group input,
html.dark .form-group textarea,
html.dark .form-group select {
  background: #111B1A !important;
  border-color: rgba(255,252,247,.10) !important;
  color: #F7F1E9 !important;
}
html.dark input::placeholder,
html.dark textarea::placeholder { color: #7F7468 !important; }
html.dark .tab-bar { background: rgba(24,35,33,.94) !important; border-top-color: rgba(255,252,247,.10) !important; }
html.dark .tab-bar a { color: #9F9385 !important; }
html.dark .tab-bar a.active { color: #F7F1E9 !important; }
html.dark .dark-toggle { background: rgba(24,35,33,.94) !important; color: #F7F1E9 !important; border: 1px solid rgba(255,252,247,.10) !important; }
html.dark .pretrip-section {
  background: linear-gradient(135deg, rgba(31,43,40,.96), rgba(22,56,54,.88)) !important;
  border-color: rgba(255,252,247,.10) !important;
}
html.dark .pretrip-item { background: rgba(255,252,247,.06) !important; border-color: rgba(255,252,247,.08) !important; }
html.dark .pretrip-title,
html.dark .pretrip-label { color: #F7F1E9 !important; }
html.dark .pretrip-desc,
html.dark .pretrip-item.done .pretrip-label { color: #9F9385 !important; }
html.dark .pretrip-sub { background: rgba(78,205,196,.14) !important; color: #8EE7DF !important; }
html.dark .node-card .nc-title { color: #F7F1E9 !important; }
html.dark .node-card .nc-desc,
html.dark .node-card .nc-meta,
html.dark .timeline-day-header span { color: #B9ADA0 !important; }
html.dark .section-title h2,
html.dark .ri-title,
html.dark .tool-title,
html.dark .pf-name,
html.dark .work-title,
html.dark .profile-title,
html.dark .msg-name {
  color: #F7F1E9 !important;
}
html.dark .ri-reason,
html.dark .tool-desc,
html.dark .work-desc,
html.dark .profile-sub,
html.dark .msg-text {
  color: #CFC3B4 !important;
}
