/* ============ 全局基础 ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --primary: #d4a96a;
    --primary-light: #e8c992;
    --primary-bg: #fdf6e8;
    --accent: #c8a991;
    --accent-light: #f0e1d2;
    --success: #8db58c;
    --warning: #e0b162;
    --danger: #d98b7c;
    --bg: #fbf8f1;
    --card: #ffffff;
    --border: #ede4d3;
    --text: #4a3f2c;
    --text-secondary: #8a7d65;
    --text-light: #b3a890;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 2px 12px rgba(212, 169, 106, 0.08);
    --shadow-lg: 0 8px 30px rgba(212, 169, 106, 0.12);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
                 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
}
body.auth-required {
    visibility: hidden;
    opacity: 0;
}

a { color: var(--primary); text-decoration: none; }

/* ============ 布局 ============ */
.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 1rem;
}

.container-wide {
    max-width: 800px;
    margin: 0 auto;
    padding: 1rem;
}

/* ============ 顶部导航 ============ */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.8rem 1rem;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar h1 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
}

.topbar .back-btn {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.9rem;
    color: var(--primary);
    cursor: pointer;
    background: none;
    border: none;
}

.topbar .user-info {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ============ 卡片 ============ */
.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 0.85rem 1rem;
    margin-bottom: 0.6rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
}

/* ============ 按钮 ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover { background: #b88e51; }

.btn-accent {
    background: var(--accent);
    color: #fff;
}
.btn-accent:hover { opacity: 0.9; }

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1.5px solid var(--primary);
}
.btn-outline:hover { background: var(--primary-bg); }

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.78rem;
}

.btn-block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
    font-size: 1.1rem;
}

/* ============ 表单 ============ */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}

.form-input {
    width: 100%;
    padding: 0.65rem 0.9rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    color: var(--text);
    background: var(--bg);
    outline: none;
    transition: border-color 0.2s;
}

.form-input:focus {
    border-color: var(--primary);
    background: #fff;
}

textarea.form-input {
    resize: vertical;
    min-height: 80px;
}

select.form-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.8rem center;
    padding-right: 2rem;
}

/* ============ 标签 ============ */
.tag {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 500;
    margin: 0.15rem;
}

.tag-primary {
    background: var(--primary-bg);
    color: var(--primary);
}

.tag-accent {
    background: var(--accent-light);
    color: #be185d;
}

.tag-selectable {
    cursor: pointer;
    border: 1.5px solid var(--border);
    background: var(--card);
    color: var(--text-secondary);
    transition: all 0.2s;
}

.tag-selectable.active {
    border-color: var(--primary);
    background: var(--primary-bg);
    color: var(--primary);
}

/* ============ 模态框 ============ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s;
}

.modal {
    background: var(--card);
    border-radius: var(--radius) var(--radius) 0 0;
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 1.5rem;
    animation: slideUp 0.3s;
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* ============ 列表 ============ */
.list-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
    cursor: pointer;
}

.list-item:hover {
    background: var(--primary-bg);
}

.list-item .icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.list-item .info {
    flex: 1;
    min-width: 0;
}

.list-item .info .name {
    font-weight: 600;
    font-size: 0.9rem;
}

.list-item .info .meta {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 0.15rem;
}

/* ============ 空状态 ============ */
.empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-light);
}

.empty .icon { font-size: 3rem; margin-bottom: 0.8rem; }
.empty p { font-size: 0.9rem; }

/* ============ Toast ============ */
.toast-container {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
}

.toast {
    padding: 0.7rem 1.2rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    animation: fadeIn 0.2s;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.toast-success { background: var(--success); color: #fff; }
.toast-error { background: var(--danger); color: #fff; }

/* ============ 图片网格 ============ */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.4rem;
}

.photo-grid .photo-item {
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    overflow: hidden;
    position: relative;
    cursor: pointer;
}

.photo-grid .photo-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s;
}

.photo-grid .photo-item:hover img {
    transform: scale(1.05);
}

/* ============ 文件夹 ============ */
.folder {
    margin-bottom: 1rem;
}

.folder-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0;
    cursor: pointer;
    user-select: none;
}

.folder-header .folder-name {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.folder-header .arrow {
    transition: transform 0.2s;
    font-size: 0.8rem;
    color: var(--text-light);
}

.folder-header .arrow.collapsed {
    transform: rotate(-90deg);
}

.folder-actions {
    display: flex;
    gap: 0.3rem;
}

/* ============ 图片预览 ============ */
.preview-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.92);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.2s;
}

.preview-overlay img {
    max-width: 95vw;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 8px;
}

.preview-overlay .desc {
    color: #fff;
    font-size: 0.9rem;
    margin-top: 1rem;
    text-align: center;
    padding: 0 1rem;
    max-width: 400px;
}

.preview-overlay .close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.15);
    color: #fff;
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============ 登录页 ============ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f5e6c8 0%, #e8c992 50%, #d4a96a 100%);
}

.login-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 2rem 1.5rem;
    width: 100%;
    max-width: 360px;
    margin: 1rem;
    box-shadow: var(--shadow-lg);
}

.login-card h1 {
    text-align: center;
    font-size: 1.5rem;
    color: var(--primary);
    margin-bottom: 0.3rem;
}

.login-card .subtitle {
    text-align: center;
    font-size: 0.82rem;
    color: var(--text-light);
    margin-bottom: 1.5rem;
}

/* ============ 首页功能网格 ============ */
.app-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    padding: 1rem 0;
}

.app-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 0.5rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    color: var(--text);
}

.app-icon:hover {
    background: var(--primary-bg);
    transform: translateY(-2px);
}

.app-icon .icon-circle {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    color: #fff;
}

.app-icon .icon-label {
    font-size: 0.8rem;
    font-weight: 500;
    text-align: center;
}

/* ============ 时间线 ============ */
.timeline {
    position: relative;
    padding-left: 2rem;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 0.65rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    margin-bottom: 0.25rem;
    padding: 0.3rem 0;
    border-bottom: 1px solid var(--border);
}

.timeline-item:last-child {
    border-bottom: none;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -1.55rem;
    top: 0.55rem;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid var(--card);
    box-shadow: 0 0 0 1.5px var(--primary-light);
}


.timeline-item .card {
    margin-bottom: 0;
}

/* ============ 地图 ============ */
#map-container {
    width: 100%;
    height: 300px;
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
}

/* ============ 响应式 ============ */
@media (min-width: 768px) {
    .modal {
        border-radius: var(--radius);
        max-width: 520px;
        margin-bottom: 2rem;
    }
    .modal-overlay {
        align-items: center;
    }
    .photo-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    .app-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ============ 工具类 ============ */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-1 { gap: 0.5rem; }
.gap-half { gap: 0.3rem; }
