:root {
  --primary: #ff6b6b;
  --secondary: #ffd93d;
  --accent: #4d96ff;
  --multi-select: #2ecc71;
  --bg: #f7f9fc;
  --card-bg: #ffffff;
  --text: #2d3436;
  --subtext: #636e72;
  --line: #dfe6e9;
  --dot-inactive: #b2bec3;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 0;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

.header {
  background: linear-gradient(135deg, var(--primary), #ff8e53);
  color: white;
  padding: 25px 20px 30px;
  border-radius: 0 0 25px 25px;
  box-shadow: 0 8px 20px rgba(255, 107, 107, 0.3);
  position: relative;
  z-index: 10;
}
.header h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 1px;
}
.header p {
  margin: 5px 0 0;
  opacity: 0.95;
  font-size: 14px;
}

.budget-card {
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(5px);
  margin-top: 15px;
  padding: 12px;
  border-radius: 12px;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  border: 1px solid rgba(255, 255, 255, 0.3);
}
.budget-item strong {
  display: block;
  font-size: 16px;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.nav-container {
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 100;
  padding: 10px 0;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.03);
}

.nav-tabs {
  display: flex;
  overflow-x: auto;
  padding: 5px 15px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #b2bec3 transparent;
  position: relative;
  mask: linear-gradient(
    to right,
    transparent 0%,
    black 20px,
    black calc(100% - 20px),
    transparent 100%
  );
}

.nav-tabs::-webkit-scrollbar {
  height: 0;
  width: 0;
  display: none;
}

.nav-tabs:hover::-webkit-scrollbar {
  height: 4px;
  display: block;
}

.nav-tabs::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 2px;
}

.nav-tabs::-webkit-scrollbar-thumb {
  background: #b2bec3;
  border-radius: 2px;
}

.nav-tabs::-webkit-scrollbar-thumb:hover {
  background: #636e72;
}

.nav-tab {
  flex: 0 0 auto;
  padding: 8px 18px;
  margin-right: 12px;
  background: white;
  border-radius: 50px;
  font-size: 14px;
  font-weight: 500;
  color: var(--subtext);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  border: 1px solid transparent;
  text-decoration: none;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.nav-tab.active {
  background: var(--primary);
  color: white;
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(255, 107, 107, 0.4);
  font-weight: bold;
}

.day-view {
  display: none;
  padding: 10px 15px 80px;
  max-width: 600px;
  margin: 0 auto;
  animation: fadeIn 0.4s ease-out;
}

@media (max-width: 480px) {
  .day-view {
    padding: 10px 12px 80px;
  }
}
.day-view.active-view {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.day-header {
  margin: 20px 0 20px;
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  display: flex;
  align-items: baseline;
}
.day-header span {
  font-size: 14px;
  color: var(--subtext);
  font-weight: normal;
  margin-left: 10px;
  background: #fff;
  padding: 4px 10px;
  border-radius: 20px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.timeline {
  position: relative;
  padding-left: 0;
}
.timeline::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 15px;
  bottom: 0;
  width: 2px;
  background: var(--line);
  border-radius: 2px;
}

.event-card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 0;
  position: relative;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
  border: 1px solid rgba(0, 0, 0, 0.02);
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  cursor: pointer;
}

.event-card::before {
  content: "";
  position: absolute;
  left: -10px;
  top: -7px;
  width: 14px;
  height: 14px;
  background: var(--bg);
  border: 3px solid var(--dot-inactive);
  border-radius: 50%;
  z-index: 1;
  transition: all 0.3s ease;
}

.event-card.active-card {
  position: relative;
  z-index: 2;
  border-radius: 16px;
  box-shadow: 0 0 0 4px rgba(255, 107, 107, 0.1), 0 10px 30px rgba(255, 107, 107, 0.25);
  animation: breathe 2s infinite ease-in-out;
}

.event-card.active-card::before {
  border-color: var(--primary);
  background-color: var(--primary);
  box-shadow: inset 0 0 0 3px white;
  width: 16px;
  height: 16px;
  left: -11px;
  top: -8px;
}

@keyframes breathe {
  0% {
    box-shadow: 0 0 0 4px rgba(255, 107, 107, 0.1), 0 10px 30px rgba(255, 107, 107, 0.25);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(255, 107, 107, 0.2), 0 10px 40px rgba(255, 107, 107, 0.35);
  }
  100% {
    box-shadow: 0 0 0 4px rgba(255, 107, 107, 0.1), 0 10px 30px rgba(255, 107, 107, 0.25);
  }
}

@keyframes breathe-green {
  0% {
    box-shadow: 0 0 0 4px rgba(46, 204, 113, 0.1), 0 10px 30px rgba(46, 204, 113, 0.25);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(46, 204, 113, 0.2), 0 10px 40px rgba(46, 204, 113, 0.35);
  }
  100% {
    box-shadow: 0 0 0 4px rgba(46, 204, 113, 0.1), 0 10px 30px rgba(46, 204, 113, 0.25);
  }
}

.event-card.transport {
  border-left: 4px solid var(--accent);
}
.event-card.hotel {
  border-left: 4px solid var(--secondary);
}
.event-card.spot {
  border-left: 4px solid var(--primary);
}
.event-card.food {
  border-left: 4px solid var(--accent);
}

.tab-container {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 0;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
  border: 1px solid rgba(0, 0, 0, 0.02);
  border-left: 4px solid var(--multi-select);
  position: relative;
}

.tab-container::before {
  content: "";
  position: absolute;
  left: -10px;
  top: -7px;
  width: 14px;
  height: 14px;
  background: var(--bg);
  border: 3px solid var(--dot-inactive);
  border-radius: 50%;
  z-index: 1;
  transition: all 0.3s ease;
}

.tab-container.active-card {
  position: relative;
  z-index: 2;
  border-radius: 16px;
  box-shadow: 0 0 0 4px rgba(46, 204, 113, 0.1), 0 10px 30px rgba(46, 204, 113, 0.25);
  animation: breathe-green 2s infinite ease-in-out;
}

.tab-container.active-card::before {
  content: "";
  position: absolute;
  left: -11px;
  top: -8px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 4px solid var(--primary);
  background-color: var(--primary);
  box-shadow: inset 0 0 0 3px white;
}

.tab-container > .time {
  margin-bottom: 12px;
}

.tab-buttons {
  display: flex;
  justify-content: flex-start;
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
  scrollbar-width: none;
  position: relative;
}

.tab-buttons::-webkit-scrollbar {
  display: none;
}

.tab-buttons:hover::-webkit-scrollbar {
  display: block;
  height: 4px;
}

.tab-buttons::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 2px;
}

.tab-buttons::-webkit-scrollbar-thumb {
  background: #b2bec3;
  border-radius: 2px;
}

.tab-buttons::-webkit-scrollbar-thumb:hover {
  background: #636e72;
}

.tab-btn {
  background: #f0f2f5;
  border: 1px solid #e0e0e0;
  color: #b2bec3;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.3s ease;
  flex: 0 0 auto;
  opacity: 0.7;
  min-width: 80px;
  text-align: center;
}

.tab-btn:hover {
  background: #e8e8e8;
  border-color: #d0d0d0;
  opacity: 0.85;
  color: #636e72;
}

.tab-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  font-weight: 600;
  opacity: 1;
}

.tab-contents {
  position: relative;
  min-height: auto;
}

.tab-content {
  display: none;
  animation: fadeIn 0.3s ease;
}

.tab-content.active {
  display: block;
}

.time {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 8px;
}

.time .time-label {
  flex-shrink: 0;
}

.time .tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-end;
  align-items: center;
}
.duration {
  font-weight: normal;
  font-size: 12px;
  color: #666;
  background: #f0f2f5;
  padding: 3px 8px;
  border-radius: 6px;
}

.duration.alert {
  background: #ffebee;
  color: #ff5252;
  font-weight: 600;
}

.status {
  font-weight: normal;
  font-size: 12px;
  color: #666;
  background: #f0f2f5;
  padding: 3px 8px;
  border-radius: 6px;
}

.title {
  font-size: 17px;
  font-weight: 700;
  margin: 0;
  color: #2d3436;
}

.desc {
  font-size: 14px;
  color: var(--subtext);
  margin-bottom: 12px;
  line-height: 1.6;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.tag {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  background: #f1f2f6;
  color: #636e72;
}
.tag.food {
  background: #fff5e6;
  color: #ff9f43;
}
.tag.alert {
  background: #ffebee;
  color: #ff5252;
  font-weight: 600;
}

.action-btn {
  flex: 0 1 auto;
  text-align: center;
  padding: 8px 12px;
  height: 20px;
  line-height: 24px;
  background: white;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.2s;
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.action-btn:hover {
  background: #f8f9fa;
  border-color: #dee2e6;
}
.action-btn:active,
.event-card.active-card .action-btn {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: translateY(1px);
}
.action-btn span {
  margin-right: 6px;
  font-size: 16px;
}

.action-buttons-container {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 0;
  padding: 0 4px;
  flex-wrap: wrap;
}

.action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 0px;
}

.action-row-left {
  flex: 0 0 auto;
}

.action-row-right {
  flex: 0 1 auto;
  text-align: center;
}

.footer {
  text-align: center;
  padding: 20px;
  color: #b2bec3;
  font-size: 12px;
  padding-bottom: 40px;
}

.expand-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease-out, opacity 0.3s ease;
  opacity: 0;
}
.expand-content.expanded {
  max-height: 1000px;
  opacity: 1;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}
.expand-hint {
  font-size: 12px;
  color: var(--accent);
  margin-top: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}
.expand-hint::after {
  content: "▼";
  transition: transform 0.3s;
}
.expand-hint.expanded::after {
  transform: rotate(180deg);
}

.distance-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: -4px 0;
  position: relative;
  z-index: 3;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.tab-content .distance-indicator {
  margin: -4px 0;
}

/* 与激活卡片关联的距离胶囊 */
.distance-indicator.attached-to-active-card {
  z-index: 4 !important;
}

/* 卡片前后的距离胶囊都应跟随卡片状态 */
.event-card.active-card + .distance-indicator,
.tab-container.active-card + .distance-indicator {
  margin-top: 0;
  z-index: 2;
}

.distance-indicator + .event-card.active-card,
.distance-indicator + .tab-container.active-card {
  margin-top: 0;
}

/* 特殊处理：当卡片被激活时，提升卡片层级 */
.event-card.active-card,
.tab-container.active-card {
  position: relative;
  z-index: 2;
}

/* 确保前后相邻元素都被正确处理 */
.distance-indicator + .event-card.active-card,
.distance-indicator + .tab-container.active-card,
.event-card.active-card + .distance-indicator,
.tab-container.active-card + .distance-indicator {
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.tab-content .desc {
  font-size: 14px;
  color: var(--subtext);
  margin-bottom: 12px;
  line-height: 1.6;
}

.tab-content .expand-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease-out, opacity 0.3s ease;
  opacity: 0;
}

.tab-content .expand-content.expanded {
  max-height: 1000px;
  opacity: 1;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

.tab-content .expand-hint {
  font-size: 12px;
  color: var(--accent);
  margin-top: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

.tab-content .expand-hint::after {
  content: "▼";
  transition: transform 0.3s;
}

.tab-content .expand-hint.expanded::after {
  transform: rotate(180deg);
}

.simple-layout {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.simple-layout .time {
  margin-bottom: 0;
}

.title-action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.title-action-row .title {
  flex: 1;
}

.title-action-row .action-buttons-container {
  flex: 0 1 auto;
  text-align: center;
}

.timeline .event-card:last-child {
  margin-bottom: 25px;
}

.distance-badge {
  background: #e8f0fe;
  color: #4285f4;
  padding: 6px 14px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}

.distance-arrow {
  font-size: 10px;
  color: #4285f4;
}
