:root {
    --bg-color: #121212;
    --surface-color: #1e1e1e;
    --text-primary: #ffffff;
    --text-secondary: #aaaaaa;
    --accent-color: #bb86fc;
    --border-color: #333333;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 导航栏 */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    height: 60px;
    background-color: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    position: relative;
}

.nav-brand {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--accent-color);
    flex-shrink: 0;
}

.nav-tabs {
    display: flex;
    gap: 10px;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.nav-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-left: auto;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    padding: 8px 16px;
    border-radius: 4px;
    transition: all 0.3s;
}

.tab-btn:hover {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    color: var(--accent-color);
    background-color: rgba(187, 134, 252, 0.1);
}

/* 主体内容区 */
.content {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.view-section {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    overflow-y: auto;
}

.view-section.active {
    opacity: 1;
    pointer-events: auto;
}

/* 视图 1: 时间瀑布流 */
.time-view-container {
    display: flex;
    position: relative;
    min-height: 100%;
}

.photo-grid {
    flex: 1;
    position: relative;
    padding: 20px;
    margin-right: 80px;
    /* 为时间轴留出空间 */
}

.photo-grid a {
    position: absolute;
    display: block;
    overflow: hidden;
    border-radius: 4px;
    background-color: var(--surface-color);
    transition: transform 0.2s;
}

.photo-grid a:hover {
    transform: scale(1.02);
    z-index: 2;
}

.photo-grid img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* 时间轴 */
.timeline {
    position: fixed;
    right: 20px;
    top: 80px;
    bottom: 20px;
    width: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-y: auto;
    scrollbar-width: none;
    /* Firefox */
}

.timeline::-webkit-scrollbar {
    display: none;
    /* Chrome */
}

.timeline-node {
    color: var(--text-secondary);
    font-size: 0.8rem;
    padding: 8px 0;
    cursor: pointer;
    transition: color 0.3s;
    text-align: center;
}

.timeline-node:hover,
.timeline-node.active {
    color: var(--accent-color);
    font-weight: bold;
}

.timeline-node.year {
    font-size: 1rem;
    font-weight: bold;
    margin-top: 10px;
    color: var(--text-primary);
}

/* 视图 2: 地图 */
#map-container {
    width: 100%;
    height: 100%;
    background-color: var(--surface-color);
}

/* 将 Leaflet 缩放控件移到左下角 */
#map-container .leaflet-top.leaflet-left {
    top: auto;
    bottom: 24px;
}

.custom-cluster-icon {
    background: transparent;
    border: none;
}

.map-photo-pin-wrapper {
    background: transparent !important;
    border: none !important;
}

.map-photo-pin {
    position: relative;
    width: 56px;
    height: 56px;
    box-sizing: border-box;
    border-radius: 8px;
    overflow: hidden;
    border: 2.5px solid #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
    cursor: pointer;
    transition: transform 0.15s ease;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.map-photo-pin:hover {
    transform: scale(1.1);
}

.map-pin-count {
    position: absolute;
    bottom: 3px;
    left: 3px;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-size: 11px;
    font-weight: bold;
    padding: 1px 5px;
    border-radius: 4px;
    line-height: 1.3;
    min-width: 16px;
    text-align: center;
    pointer-events: none;
}

/* 视图 3: 旅程 */
.journey-controls {
    position: sticky;
    top: 0;
    background-color: var(--surface-color);
    padding: 15px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
    z-index: 10;
}

.journey-controls-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-width: 180px;
    max-width: 300px;
}

.control-group label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.control-group label small {
    opacity: 0.6;
}

.control-group span {
    color: var(--accent-color);
    font-weight: bold;
}

.home-info {
    min-width: 300px;
}

#home-select {
    width: 100%;
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

#home-select:hover,
#home-select:focus {
    border-color: var(--accent-color);
}

.journey-controls-actions {
    align-items: center;
    gap: 12px;
}

.btn-action {
    background: rgba(187, 134, 252, 0.15);
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
    padding: 6px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    white-space: nowrap;
    transition: background 0.2s;
}

.btn-action:hover {
    background: rgba(187, 134, 252, 0.3);
}

/* 刷新按钮 */
.btn-refresh {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 5px 14px;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: not-allowed;
    opacity: 0.4;
    transition: all 0.3s;
    white-space: nowrap;
}

.btn-refresh.highlight {
    background: rgba(187, 134, 252, 0.2);
    border-color: var(--accent-color);
    color: var(--accent-color);
    cursor: pointer;
    opacity: 1;
    animation: refresh-pulse 2s ease-in-out infinite;
}

.btn-refresh.highlight:hover {
    background: rgba(187, 134, 252, 0.4);
}

@keyframes refresh-pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

/* 地图视图内刷新按钮定位 */
#view-map .btn-refresh {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1000;
}

.save-status {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.save-status.bound {
    color: #4caf50;
}

.save-status.error {
    color: #f44336;
}

input[type=range] {
    width: 100%;
    accent-color: var(--accent-color);
}

.journey-list {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.journey-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-secondary);
    text-align: center;
    gap: 10px;
}

.journey-empty-icon {
    font-size: 3rem;
    opacity: 0.5;
}

.journey-empty-title {
    font-size: 1.1rem;
    color: var(--text-primary);
}

.journey-empty-hint {
    font-size: 0.9rem;
    opacity: 0.7;
}

.journey-empty-hint b {
    color: var(--accent-color);
}

.journey-card {
    background-color: var(--surface-color);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border-color);
}

.journey-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    align-items: center;
}

.journey-title {
    font-size: 1.1rem;
    font-weight: bold;
}

.journey-meta {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.journey-preview-wrapper {
    position: relative;
    overflow: hidden;
}

.journey-preview {
    display: flex;
    gap: 10px;
    overflow: hidden;
    padding-bottom: 10px;
}

.journey-preview a {
    display: block;
    flex-shrink: 0;
}

.journey-preview img {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 6px;
    display: block;
}

.journey-expand-overlay {
    position: absolute;
    top: 0;
    right: 0;
    height: 100px;
    width: 200px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 12px;
    background: linear-gradient(to right,
            transparent 0%,
            rgba(30, 30, 30, 0.5) 20%,
            rgba(30, 30, 30, 0.88) 55%,
            var(--surface-color) 100%);
    z-index: 2;
}

.journey-expand-btn {
    background: rgba(187, 134, 252, 0.2);
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
    padding: 6px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    white-space: nowrap;
    transition: background 0.2s, transform 0.2s;
}

.journey-expand-btn:hover {
    background: rgba(187, 134, 252, 0.4);
    transform: scale(1.05);
}

/* 旅程浮窗 */
.journey-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.journey-modal-overlay.active {
    opacity: 1;
}

.journey-modal {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    width: 92vw;
    height: 88vh;
    max-width: 1400px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.95);
    transition: transform 0.25s ease;
}

.journey-modal-overlay.active .journey-modal {
    transform: scale(1);
}

.journey-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.journey-modal-title {
    font-size: 1.1rem;
    font-weight: bold;
}

.journey-modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
}

.journey-modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.journey-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-content: flex-start;
}

.journey-modal-body a {
    display: block;
    flex-shrink: 0;
}

.journey-modal-body img {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 6px;
    display: block;
    transition: transform 0.2s;
}

.journey-modal-body img:hover {
    transform: scale(1.05);
}

/* 加载动画 */
.loading-dots::after {
    content: '';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {

    0%,
    20% {
        content: '';
    }

    40% {
        content: '.';
    }

    60% {
        content: '..';
    }

    80%,
    100% {
        content: '...';
    }
}

/* 滚动条美化 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* 导航栏本地文件夹按钮 */
.nav-action {
    background: rgba(187, 134, 252, 0.15);
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    white-space: nowrap;
    transition: background 0.2s;
}

.nav-action:hover {
    background: rgba(187, 134, 252, 0.3);
}

.nav-save-cache:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 本地模式进度条 */
.local-progress {
    display: none;
    background: var(--surface-color);
    color: var(--accent-color);
    padding: 8px 20px;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 10;
}

/* 本地模式网格布局 */
.photo-grid.local-grid-mode {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px;
    margin-right: 80px;
}

.photo-grid.local-grid-mode a {
    position: static;
}

.local-grid-item {
    width: 180px;
    height: 180px;
    border-radius: 6px;
    overflow: hidden;
    background: var(--surface-color);
    flex-shrink: 0;
    position: relative;
}

.local-grid-item a {
    display: block;
    width: 100%;
    height: 100%;
}

.local-grid-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.2s;
}

.local-grid-item img:hover {
    transform: scale(1.05);
}

.local-placeholder {
    width: 100%;
    height: 100%;
    background: var(--surface-color);
    animation: placeholder-pulse 1.5s ease-in-out infinite;
}

@keyframes placeholder-pulse {

    0%,
    100% {
        opacity: 0.4;
    }

    50% {
        opacity: 0.7;
    }
}

/* 欢迎/空状态提示 */
.source-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    color: var(--text-secondary);
    text-align: center;
    gap: 12px;
    position: absolute;
    inset: 0;
}

.source-welcome-icon {
    font-size: 3rem;
    opacity: 0.5;
}

.source-welcome-hint {
    font-size: 0.9rem;
    opacity: 0.7;
    line-height: 1.6;
}

.source-welcome-hint b {
    color: var(--accent-color);
}