:root {
  --primary: #FF7B3D;
  --primary-dark: #E56730;
  --accent: #ff6b35;
  --accent-dark: #e55a2b;
  --bg: #f8f9fa;
  --surface: #ffffff;
  --text: #1a1a2e;
  --text-secondary: #6c757d;
  --border: #e9ecef;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --radius: 16px;
  --radius-sm: 10px;
}

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

html, body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
}

body.page-no-nav {
  padding-bottom: 20px;
}

/* Header */
.header {
  background: var(--surface);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.header .logo {
  width: 150px;
  height: auto;
  object-fit: contain;
}

.header .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 14px;
  overflow: hidden;
}

.header .avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.header .avatar.with-img {
  background: transparent;
}

/* Tabs */
.tabs {
  display: flex;
  background: var(--surface);
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
}

.tab {
  flex: 1;
  text-align: center;
  padding: 14px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  position: relative;
  border: none;
  background: none;
}

.tab.active {
  color: var(--primary-dark);
}

.tab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 20%;
  right: 20%;
  height: 3px;
  background: var(--primary);
  border-radius: 3px 3px 0 0;
}

/* Cards */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  margin: 16px 20px;
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.2s;
  position: relative;
}

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

.card-image {
  width: 100%;
  height: 180px;
  object-fit: cover;
}

.card-content {
  padding: 16px;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 8px;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: var(--text-secondary);
}

.card-meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.route-info {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

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

.route-dot.start { background: var(--primary); }
.route-dot.end { background: var(--accent); }

.route-line {
  flex: 1;
  height: 2px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 1px;
}

.route-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

/* CTA Button */
.cta-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: white;
  border: none;
  padding: 16px 28px;
  border-radius: 50px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(255,107,53,0.4);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.cta-btn:active { transform: scale(0.96); }

.fab {
  position: fixed;
  bottom: 90px;
  right: max(20px, calc((100vw - 480px) / 2 + 20px));
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: white;
  border: none;
  font-size: 28px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(255,107,53,0.5);
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fab span { font-size: 14px; font-weight: 700; }

/* Bottom Nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  margin: 0 auto;
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 60px;
  padding: 8px 20px max(20px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  z-index: 999999;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 11px;
  padding: 4px 16px;
  border: none;
  background: none;
  cursor: pointer;
}

.nav-item.active { color: var(--primary-dark); }

.nav-cta {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: white;
  padding: 10px 18px;
  border-radius: 24px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(255,107,53,0.4);
  border: none;
  white-space: nowrap;
}

.nav-item svg {
  width: 24px;
  height: 24px;
}

/* Forms */
.form-group {
  margin: 16px 20px;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.form-input, .form-textarea {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  background: var(--surface);
  transition: border-color 0.2s;
}

.form-input:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary);
}

input[type="date"] {
  max-width: 100%;
  min-width: 0;
  -webkit-appearance: none;
  appearance: none;
}

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

/* Upload Areas */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 32px 20px;
  margin: 0 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg);
}

.upload-area:hover {
  border-color: var(--primary);
  background: rgba(46,204,113,0.04);
}

.upload-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.upload-text {
  font-size: 14px;
  color: var(--text-secondary);
}

/* Photo Grid */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 16px 20px;
}

.photo-item {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
}

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

.photo-add {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  border: 2px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--text-secondary);
  cursor: pointer;
  background: var(--bg);
}

/* Timeline */
.timeline {
  position: relative;
  padding-left: 28px;
  margin: 16px 20px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  padding-bottom: 24px;
}

.timeline-dot {
  position: absolute;
  left: -24px;
  top: 4px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
  border: 3px solid var(--surface);
}

.timeline-content {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 16px;
  box-shadow: var(--shadow);
}

/* Segments List */
.segment-card {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin: 12px 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
}

.segment-day {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
}

.segment-day .day-num {
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}

.segment-day .day-label {
  font-size: 10px;
  opacity: 0.9;
}

.segment-info {
  flex: 1;
}

.segment-title {
  font-weight: 600;
  font-size: 15px;
}

.segment-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Page Header with Back */
.page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 100;
}

.back-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
}

.page-title {
  font-size: 18px;
  font-weight: 700;
}

/* Section */
.section {
  margin-top: 20px;
}

.section-title {
  font-size: 16px;
  font-weight: 700;
  padding: 0 20px;
  margin-bottom: 12px;
}

/* GPX File */
.gpx-file {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  margin: 8px 20px;
}

.gpx-icon {
  font-size: 24px;
}

.gpx-name {
  font-size: 14px;
  font-weight: 600;
}

.gpx-status {
  font-size: 12px;
  color: var(--primary);
  margin-left: auto;
}

/* Map Container */
#map {
  width: 100%;
  height: 400px;
  border-radius: var(--radius-sm);
}

.map-container {
  margin: 0 20px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.elevation-chart-wrap {
  margin: 0 20px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 12px;
  box-shadow: var(--shadow);
}

.elevation-chart-wrap canvas {
  width: 100%;
  height: 180px;
  display: block;
}

/* Journey Content */
.journey-content {
  margin: 20px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.day-section {
  margin-bottom: 28px;
}

.day-section:last-child { margin-bottom: 0; }

.day-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.day-badge {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
}

.day-date {
  font-size: 13px;
  color: var(--text-secondary);
}

.day-note {
  font-size: 15px;
  line-height: 1.8;
  color: var(--text);
}

.day-photos {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.day-photos img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

/* Fullscreen Image */
.fullscreen-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.95);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
}

.fullscreen-overlay.active { display: flex; }

.fullscreen-overlay img {
  max-width: 95%;
  max-height: 90vh;
  object-fit: contain;
}

.close-fullscreen {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
}

/* Stats */
.stats-bar {
  display: flex;
  justify-content: space-around;
  padding: 16px 20px;
  background: var(--surface);
  margin: 0 20px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}

.stat-item {
  text-align: center;
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary-dark);
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Action Buttons Row */
.action-row {
  display: flex;
  gap: 12px;
  margin: 16px 20px;
}

.btn {
  flex: 1;
  padding: 14px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: all 0.2s;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 2px solid var(--border);
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: white;
}

/* Progress Steps */
.steps {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 16px 20px;
  background: var(--surface);
}

.step {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
}

.step.active { background: var(--primary); }

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.empty-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

.empty-desc {
  font-size: 14px;
  color: var(--text-secondary);
}

/* Cover Map Thumbnail */
.cover-map-thumb {
  width: 80px;
  height: 80px;
  border-radius: 10px;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
  clip-path: inset(0 round 10px);
  -webkit-clip-path: inset(0 round 10px);
}

.cover-map-thumb .leaflet-container {
  width: 80px !important;
  height: 80px !important;
  background: #e8f0e3 !important;
}

/* Photo Pin on Map */
.photo-pin {
  border-radius: 50%;
  overflow: hidden;
  cursor: pointer;
}

.photo-pin img {
  display: block;
}

/* Tags */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.tag {
  background: rgba(46,204,113,0.1);
  color: var(--primary-dark);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

/* Divider */
.divider {
  height: 1px;
  background: var(--border);
  margin: 16px 20px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

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

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

.modal-desc {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

/* Login Modal */
.login-modal {
  text-align: left;
  display: flex;
  flex-direction: column;
}

.login-modal > * {
  margin-bottom: 20px;
}

.login-modal > *:last-child {
  margin-bottom: 0;
}

.login-modal .form-input {
  padding: 14px 16px;
}

.login-code-row {
  display: flex;
  gap: 12px;
}

.login-code-row .form-input {
  flex: 1;
  margin-bottom: 0;
}

.login-code-row .btn {
  flex: 0 0 auto;
  padding: 14px 16px;
  white-space: nowrap;
  font-size: 13px;
}

/* 错误信息无内容时不占高度，有内容时上方10px、下方20px */
.login-modal .login-error {
  color: #e74c3c;
  font-size: 13px;
  margin: 0;
  min-height: 0;
}

.login-modal .login-error:not(:empty) {
  margin-top: 10px;
  margin-bottom: 20px;
}

/* 按钮行 */
.login-modal .action-row {
  margin: 0;
  gap: 20px;
}

.hidden {
  display: none !important;
}

/* Button loading spinner */
.btn-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.btn-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid rgba(0, 0, 0, 0.15);
  border-top-color: rgba(0, 0, 0, 0.7);
  border-radius: 50%;
  animation: btn-spin 0.8s linear infinite;
}

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

/* Toast notification */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 1000000;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
}
