* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --primary: #1a365d;
    --secondary: #d4af37;
    --accent: #ff6b35;
    --success: #22c55e;
    --warning: #eab308;
    --danger: #ef4444;
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    position: fixed;
}

#app {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* 顶部状态栏 */
#top-bar {
    background: linear-gradient(135deg, var(--primary) 0%, #2d4a6f 100%);
    color: white;
    padding: 12px 16px;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

#weather-widget {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    background: rgba(255,255,255,0.15);
    padding: 6px 10px;
    border-radius: 20px;
}

#page-title {
    font-size: 18px;
    font-weight: 600;
}

#time-display {
    font-size: 14px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

/* 搜索栏 */
#search-bar {
    background: white;
    padding: 12px;
    border-bottom: 1px solid var(--border);
    display: none;
}

#search-bar.active {
    display: block;
}

#search-input {
    width: 100%;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: 25px;
    font-size: 15px;
    background: var(--bg);
    outline: none;
    margin-bottom: 10px;
}

#search-input:focus {
    border-color: var(--secondary);
    background: white;
}

#filter-buttons {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
}

#filter-buttons::-webkit-scrollbar {
    display: none;
}

.filter-btn {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: white;
    font-size: 13px;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* 页面容器 */
.page {
    flex: 1;
    overflow-y: auto;
    display: none;
    -webkit-overflow-scrolling: touch;
}

.page.active {
    display: block;
}

.page[data-page="map"].active {
    display: flex;
    flex-direction: column;
}

/* 地图 */
#map-container {
    position: relative;
    flex: 1;
}

#map {
    width: 100%;
    height: 100%;
    z-index: 1;
}

#locate-btn, #reset-map-btn {
    position: absolute;
    right: 16px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
    font-size: 22px;
    cursor: pointer;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

#locate-btn {
    bottom: calc(100px + var(--safe-bottom));
}

#reset-map-btn {
    bottom: calc(160px + var(--safe-bottom));
}

#locate-btn:active, #reset-map-btn:active {
    transform: scale(0.95);
}

/* 自定义地图标记 */
.custom-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
    transition: transform 0.2s;
}

.custom-marker:hover {
    transform: scale(1.2);
}

.wait-time-label {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--success);
    color: white;
    font-size: 10px;
    font-weight: bold;
    padding: 2px 5px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.wait-time-label.yellow { background: var(--warning); }
.wait-time-label.orange { background: #f97316; }
.wait-time-label.red { background: var(--danger); }
.wait-time-label.gray { background: #6b7280; font-size: 9px; }

.user-marker {
    width: 20px;
    height: 20px;
    background: #3b82f6;
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.3);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.5); }
    70% { box-shadow: 0 0 0 15px rgba(59, 130, 246, 0); }
    100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
}

/* 路线页面 */
#route-page {
    padding: 16px;
    padding-bottom: calc(80px + var(--safe-bottom));
}

.route-form {
    background: white;
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    margin-bottom: 16px;
}

.route-input-group {
    margin-bottom: 12px;
}

.route-input-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-light);
}

.route-input-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 15px;
    background: var(--bg);
    outline: none;
}

.waypoint-input {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.waypoint-input select {
    flex: 1;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 15px;
    background: var(--bg);
    outline: none;
}

.remove-waypoint {
    width: 44px;
    border: none;
    background: #fee2e2;
    color: var(--danger);
    border-radius: 10px;
    font-size: 18px;
    cursor: pointer;
}

#add-waypoint-btn {
    width: 100%;
    padding: 10px;
    border: 2px dashed var(--border);
    border-radius: 10px;
    background: transparent;
    color: var(--text-light);
    font-size: 14px;
    cursor: pointer;
    margin-bottom: 12px;
}

.primary-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary) 0%, #2d4a6f 100%);
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 10px;
    transition: transform 0.2s;
}

.primary-btn:active {
    transform: scale(0.98);
}

.ai-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--secondary) 0%, #f59e0b 100%);
    color: var(--primary);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
}

.ai-btn:active {
    transform: scale(0.98);
}

.secondary-btn {
    padding: 10px 20px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: white;
    font-size: 14px;
    cursor: pointer;
}

#ai-preferences {
    background: white;
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    margin-bottom: 16px;
}

#ai-preferences h4 {
    margin-bottom: 12px;
}

.preference-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.preference-options label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    cursor: pointer;
}

.route-summary {
    background: linear-gradient(135deg, var(--primary) 0%, #2d4a6f 100%);
    color: white;
    border-radius: 16px;
    padding: 16px;
    display: flex;
    justify-content: space-around;
    margin-bottom: 16px;
}

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

.summary-label {
    display: block;
    font-size: 12px;
    opacity: 0.8;
    margin-bottom: 4px;
}

.summary-value {
    display: block;
    font-size: 20px;
    font-weight: 700;
}

#route-directions {
    background: white;
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    margin-bottom: 16px;
}

.direction-step {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.direction-step:last-child {
    border-bottom: none;
}

.step-number {
    width: 28px;
    height: 28px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
}

.step-content {
    flex: 1;
}

.step-text {
    font-size: 15px;
    margin-bottom: 4px;
}

.step-meta {
    font-size: 13px;
    color: var(--text-light);
}

#ai-itinerary {
    background: white;
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

#ai-itinerary h4 {
    margin-bottom: 16px;
}

.timeline-item {
    display: flex;
    gap: 12px;
    padding-bottom: 16px;
    position: relative;
}

.timeline-item:not(:last-child)::before {
    content: '';
    position: absolute;
    left: 15px;
    top: 36px;
    bottom: 0;
    width: 2px;
    background: var(--border);
}

.timeline-time {
    width: 45px;
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
    flex-shrink: 0;
    padding-top: 4px;
}

.timeline-dot {
    width: 32px;
    height: 32px;
    background: var(--secondary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    z-index: 1;
}

.timeline-content {
    flex: 1;
    padding-top: 4px;
}

.timeline-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 2px;
}

.timeline-desc {
    font-size: 13px;
    color: var(--text-light);
}

/* 演出页面 */
#shows-page {
    padding: 16px;
    padding-bottom: calc(80px + var(--safe-bottom));
}

.shows-filter {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    margin-bottom: 16px;
    -webkit-overflow-scrolling: touch;
}

.shows-filter::-webkit-scrollbar {
    display: none;
}

.show-filter-btn {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: white;
    font-size: 14px;
    white-space: nowrap;
    cursor: pointer;
}

.show-filter-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.show-card {
    background: white;
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    display: flex;
    gap: 12px;
    align-items: center;
}

.show-card.upcoming {
    border-left: 4px solid var(--accent);
    animation: highlight 2s infinite;
}

@keyframes highlight {
    0%, 100% { box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
    50% { box-shadow: 0 2px 20px rgba(255, 107, 53, 0.2); }
}

.show-icon {
    font-size: 36px;
}

.show-info {
    flex: 1;
}

.show-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.show-area {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 8px;
}

.show-times {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.show-time-badge {
    padding: 4px 10px;
    background: var(--bg);
    border-radius: 12px;
    font-size: 13px;
}

.show-time-badge.soon {
    background: var(--accent);
    color: white;
    font-weight: 600;
}

.show-countdown {
    text-align: center;
}

.countdown-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
}

.countdown-label {
    font-size: 11px;
    color: var(--text-light);
}

/* 个人中心 */
#profile-page {
    padding: 16px;
    padding-bottom: calc(80px + var(--safe-bottom));
}

.profile-section {
    background: white;
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.profile-section h3 {
    font-size: 16px;
    margin-bottom: 12px;
}

.list-container {
    min-height: 60px;
}

.empty-text {
    text-align: center;
    color: var(--text-light);
    font-size: 14px;
    padding: 20px 0;
}

.favorite-item, .history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.favorite-item:last-child, .history-item:last-child {
    border-bottom: none;
}

.item-name {
    font-size: 15px;
}

.item-meta {
    font-size: 12px;
    color: var(--text-light);
}

.item-action {
    padding: 6px 12px;
    border: none;
    background: var(--primary);
    color: white;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
}

.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.setting-item:last-child {
    border-bottom: none;
}

/* 开关样式 */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 28px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary);
}

input:checked + .slider:before {
    transform: translateX(22px);
}

.about-text {
    font-size: 14px;
    color: var(--text-light);
    line-height: 1.6;
    text-align: center;
}

/* 弹窗 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 20px 20px 0 0;
    width: 100%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: white;
    border-radius: 20px 20px 0 0;
}

.modal-header h3 {
    font-size: 18px;
}

.close-btn {
    font-size: 28px;
    color: var(--text-light);
    cursor: pointer;
    line-height: 1;
}

.modal-body {
    padding: 20px;
}

.wait-time-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 25px;
    margin-bottom: 16px;
}

.wait-time-badge.green { background: #dcfce7; color: #166534; }
.wait-time-badge.yellow { background: #fef9c3; color: #854d0e; }
.wait-time-badge.orange { background: #ffedd5; color: #9a3412; }
.wait-time-badge.red { background: #fee2e2; color: #991b1b; }
.wait-time-badge.gray { background: #f3f4f6; color: #4b5563; }

.wait-label {
    font-size: 14px;
}

.wait-value {
    font-size: 20px;
    font-weight: 700;
}

.poi-type {
    display: inline-block;
    padding: 4px 12px;
    background: var(--bg);
    border-radius: 12px;
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 12px;
}

.poi-desc {
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 16px;
    color: var(--text);
}

.poi-meta {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 14px;
    color: var(--text-light);
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    gap: 10px;
}

.modal-actions button {
    flex: 1;
    margin: 0;
}

/* 底部导航 */
#bottom-nav {
    display: flex;
    background: white;
    border-top: 1px solid var(--border);
    padding-bottom: var(--safe-bottom);
    z-index: 1000;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

.nav-btn {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    color: var(--text-light);
    transition: color 0.2s;
}

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

.nav-icon {
    font-size: 22px;
}

.nav-text {
    font-size: 11px;
    font-weight: 500;
}

/* Leaflet 地图样式覆盖 */
.leaflet-container {
    font-family: inherit;
    background: #e8f4e8 !important;
}

.leaflet-control-zoom {
    display: none !important;
}

/* 园区区域样式 */
.area-label {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    text-shadow: 0 1px 2px rgba(255,255,255,0.8);
    white-space: nowrap;
}

/* 搜索结果 */
.search-results {
    position: absolute;
    top: 100%;
    left: 12px;
    right: 12px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
}

.search-result-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: var(--bg);
}

.result-name {
    font-size: 15px;
    font-weight: 500;
}

.result-meta {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 2px;
}

/* Toast 提示 */
.toast {
    position: fixed;
    top: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 14px;
    z-index: 3000;
    animation: fadeInOut 2s ease;
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translateX(-50%) translateY(-20px); }
    15% { opacity: 1; transform: translateX(-50%) translateY(0); }
    85% { opacity: 1; transform: translateX(-50%) translateY(0); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-20px); }
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}