:root {
  --bg: #F9F9F7;
  --card: #FFFFFF;
  --text: #333;
  --text2: #666;
  --text3: #999;
  --border: #E6E0D4;
  --coral: #E06A5C;
  --matcha: #8A9A5B;
  --blue: #6A8494;
  --pink: #D68A9F;
  --bronze: #D4A373;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Zen Kaku Gothic New', 'Noto Serif TC', sans-serif;
  background: #E8E6E3;
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  min-height: -webkit-fill-available;
  overflow-x: hidden;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: -webkit-fill-available;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  box-shadow: 0 0 60px rgba(0,0,0,0.15);
  position: relative;
}

/* Header */
header {
  padding: 1.25rem 1rem 0.75rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.6rem;
}

.header-sub {
  font-size: 0.55rem;
  letter-spacing: 0.2em;
  color: var(--text3);
  text-transform: uppercase;
}

.header-title {
  font-family: 'Noto Serif TC', serif;
  font-size: 1.3rem;
  font-weight: 500;
  letter-spacing: 0.05em;
}

.header-btns {
  display: flex;
  gap: 0.5rem;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: #EFEFEF;
  color: #555;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  text-decoration: none;
  font-family: inherit;
}

.icon-btn:hover { background: #E0E0E0; }
.icon-btn.active { background: #333; color: white; }

.icon-btn.vjw {
  background: linear-gradient(135deg, #1E90FF, #00CED1);
  color: white;
  font-size: 0.45rem;
  font-weight: 700;
}

.icon-btn.money {
  background: linear-gradient(135deg, #FFD700, #FFA500);
  color: white;
}

.icon-btn.edit-mode { background: var(--coral); color: white; }

/* Weather */
.weather {
  display: flex;
  gap: 0.5rem;
  padding: 0.4rem;
  background: white;
  border-radius: 8px;
  margin-bottom: 0.6rem;
  border: 1px solid var(--border);
}

.weather-city {
  flex: 1;
  padding: 0.35rem;
  text-align: center;
  border-radius: 6px;
}

.weather-city:first-child { background: linear-gradient(135deg, #E06A5C12, #E06A5C08); }
.weather-city:last-child { background: linear-gradient(135deg, #5C9CE012, #5C9CE008); }

.weather-name { font-size: 0.55rem; color: var(--text3); letter-spacing: 0.1em; }
.weather-temp { font-size: 1rem; font-weight: 500; }
.weather-desc { font-size: 0.6rem; color: var(--text2); }

/* Date Info */
.date-info {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--text2);
}

.date-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* Tabs */
.tabs {
  display: flex;
  overflow-x: auto;
  padding: 0.8rem 0.5rem;
  gap: 0.6rem;
  background: var(--bg);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex-shrink: 0;
}

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

.tab {
  flex-shrink: 0;
  min-width: 64px;
  padding: 0.6rem 0.8rem;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--text3);
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
  font-family: inherit;
}

.tab.active {
  background: white;
  border-color: var(--border);
  color: var(--text);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  transform: translateY(-2px);
}

.tab-day { 
  font-size: 0.6rem;
  letter-spacing: 0.08em; 
  text-transform: uppercase; 
  margin-bottom: 2px;
}

.tab-date { 
  font-family: 'Noto Serif TC', serif; 
  font-size: 1.15rem;
  font-weight: 600; 
  line-height: 1.1;
}

.tab.add-tab {
  background: transparent;
  border: 1px dashed #CCC;
  color: #AAA;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tab.add-tab:hover {
  border-color: var(--matcha);
  color: var(--matcha);
}

/* Content */
main {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  padding-bottom: 110px;
}

/* Hero */
.hero {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 1rem;
  aspect-ratio: 2.2/1;
  background: linear-gradient(135deg, #E0E0E0, #F5F5F5);
}

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

.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.75), rgba(0,0,0,0.2), transparent);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 0.85rem;
}

.hero-title {
  font-size: 1.1rem;
  font-weight: 500;
  color: white;
  margin-bottom: 0.2rem;
}

.hero-hl {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.65rem;
  color: rgba(255,255,255,0.9);
}

/* Day Edit Header */
.day-edit-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding: 0.5rem;
  background: #FFF5F5;
  border-radius: 8px;
  border: 1px solid #FFE0E0;
}

.day-edit-header span {
  font-size: 0.8rem;
  color: var(--coral);
}

.del-day-btn {
  padding: 0.4rem 0.8rem;
  background: var(--coral);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
  font-family: inherit;
}

/* Timeline */
.timeline {
  position: relative;
  margin-left: 0.4rem;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 8px;
  bottom: 16px;
  width: 1px;
  background: #E0E0E0;
}

.step {
  position: relative;
  display: flex;
  gap: 0.85rem;
  margin-bottom: 1.5rem;
}

.step-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  border: 3px solid var(--bg);
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  z-index: 1;
}

.step-icon.transport { background: var(--matcha); }
.step-icon.food { background: var(--pink); }
.step-icon.shopping { background: var(--bronze); }
.step-icon.sightseeing { background: var(--blue); }
.step-icon.arrival { background: #666; }

.step-body { flex: 1; padding-top: 2px; }

.step-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.35rem;
}

.step-title { font-weight: 500; font-size: 0.9rem; }
.step-time {
  font-size: 0.65rem;
  font-family: monospace;
  color: var(--text3);
  background: #EFEFEF;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
}

/* Transport Box */
.transport-box {
  background: white;
  border: 1px solid #EEE;
  border-radius: 6px;
  padding: 0.5rem;
  margin-bottom: 0.5rem;
}

.transport-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.7rem;
  margin-bottom: 0.3rem;
}

.transport-line:last-child { margin-bottom: 0; }

.transport-name {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 500;
  color: #555;
}

.transport-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
}

.transport-info {
  display: flex;
  gap: 0.4rem;
  color: #888;
  font-size: 0.65rem;
}

.transport-badge {
  background: #F5F5F0;
  padding: 0.08rem 0.25rem;
  border-radius: 3px;
  font-size: 0.55rem;
}

/* Location */
.location-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.35rem;
}

.location-text {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.7rem;
  color: #777;
}

.map-btn {
  font-size: 0.65rem;
  color: #888;
  border: 1px solid #DDD;
  padding: 0.25rem 0.5rem;
  border-radius: 12px;
  background: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.15rem;
  text-decoration: none;
  font-family: inherit;
}

.step-desc {
  font-size: 0.8rem;
  color: var(--text2);
  font-weight: 300;
  margin-bottom: 0.5rem;
  line-height: 1.55;
}

.spots {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.5rem;
}

.spot {
  padding: 0.15rem 0.35rem;
  background: white;
  border: 1px solid #E0E0E0;
  border-radius: 4px;
  font-size: 0.65rem;
  color: var(--text2);
}

.tips {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid #F0F0F0;
}

.tip {
  display: flex;
  align-items: flex-start;
  gap: 0.3rem;
  font-size: 0.65rem;
  margin-bottom: 0.15rem;
}

.tip.food { color: var(--pink); }
.tip.info { color: var(--blue); }
.tip svg { flex-shrink: 0; margin-top: 1px; opacity: 0.7; }

/* Edit Step Buttons */
.step-edit-btns {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px dashed #EEE;
}

.step-edit-btn {
  padding: 0.3rem 0.6rem;
  font-size: 0.65rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
}

.step-edit-btn.del {
  background: #FFE0E0;
  color: var(--coral);
}

/* Add Step Button */
.add-step-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.75rem;
  margin-top: 1rem;
  border: 1px dashed #CCC;
  border-radius: 8px;
  background: transparent;
  color: #999;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}

.add-step-btn:hover {
  border-color: var(--matcha);
  color: var(--matcha);
}

/* Maps View */
.maps-header {
  text-align: center;
  margin-bottom: 1rem;
}

.maps-title {
  font-family: 'Noto Serif TC', serif;
  font-size: 1rem;
  letter-spacing: 0.1em;
}

.maps-sub {
  font-size: 0.6rem;
  color: var(--text3);
  letter-spacing: 0.15em;
  margin-top: 0.2rem;
}

.map-card {
  background: white;
  border-radius: 10px;
  padding: 0.85rem;
  margin-bottom: 0.6rem;
  border: 1px solid #F0F0F0;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  transition: all 0.2s;
}

.map-card:hover {
  border-color: var(--bronze);
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.map-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
}

.map-card-body { flex: 1; min-width: 0; }
.map-card-tag { font-size: 0.5rem; font-weight: 600; letter-spacing: 0.12em; color: var(--text3); text-transform: uppercase; }
.map-card-title { font-weight: 500; font-size: 0.9rem; }
.map-card-desc { font-size: 0.65rem; color: var(--text3); }

/* Footer */
footer {
  background: white;
  border-top: 1px solid #F0F0F0;
  padding: 0.8rem;
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  z-index: 100;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

.footer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}

.footer-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem;
  background: var(--bg);
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  color: #555;
  text-decoration: none;
  transition: background 0.2s;
}

.footer-btn:active {
  background: #E0E0E0;
}

/* Modal - Zoomable Image */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.95);
  z-index: 200;
  display: none;
  flex-direction: column;
  animation: fadeIn 0.2s;
  overflow: hidden;
}

.modal.active { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-close {
  position: absolute;
  top: max(env(safe-area-inset-top, 16px), 16px);
  right: 16px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.25);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 210;
  backdrop-filter: blur(8px);
}

.modal-content {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
  width: 100%;
  height: 100%;
}

.modal-content img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  transform-origin: center center;
  transition: transform 0.1s linear;
  will-change: transform;
}

.modal-hint {
  position: absolute;
  bottom: max(env(safe-area-inset-bottom, 24px), 24px);
  left: 50%;
  transform: translateX(-50%);
  padding: 0.6rem 1.2rem;
  background: rgba(0,0,0,0.6);
  border-radius: 50px;
  color: white;
  font-size: 0.8rem;
  backdrop-filter: blur(8px);
  pointer-events: none;
}

/* Edit Modal (New Design) */
.edit-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(2px);
}

.edit-modal.active { display: flex; }

.edit-box {
  background: white;
  border-radius: 16px;
  width: 100%;
  max-width: 400px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 1.5rem;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.edit-box h3 {
  font-size: 1.1rem;
  margin-bottom: 1.2rem;
  color: var(--text);
  border-bottom: 2px solid var(--border);
  padding-bottom: 0.5rem;
}

.edit-field { margin-bottom: 1rem; }

.edit-field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 0.4rem;
}

.edit-field input,
.edit-field textarea,
.edit-field select {
  width: 100%;
  padding: 0.6rem;
  border: 1px solid #DDD;
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  transition: border 0.2s;
}

.edit-field input:focus,
.edit-field textarea:focus {
  outline: none;
  border-color: var(--matcha);
  box-shadow: 0 0 0 3px rgba(138, 154, 91, 0.1);
}

.edit-field textarea {
  min-height: 60px;
  resize: vertical;
}

.edit-btns {
  display: flex;
  gap: 0.8rem;
  margin-top: 1.5rem;
}

.edit-btns button {
  flex: 1;
  padding: 0.8rem;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}

.edit-btns .cancel {
  background: #EEE;
  color: #666;
}

.edit-btns .save {
  background: var(--matcha);
  color: white;
}

.hidden { display: none !important; }

@media (min-width: 481px) {
  body { padding: 1.5rem 0; }
  .app {
    border-radius: 20px;
    min-height: calc(100vh - 3rem);
    overflow: hidden;
  }
}