/* ==================== 全局变量（蓝色主题） ==================== */
:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: #bfdbfe;
    --text: #1e293b;
    --text-light: #64748b;
    --bg: #f8fafc;
    --bg-gradient: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 20px;
    --transition: 0.2s ease;
}

/* ==================== 重置 & 基础 ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg-gradient);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
}

/* ==================== 卡片 ==================== */
.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    transition: transform var(--transition), box-shadow var(--transition);
}
@media (min-width: 480px) {
    .card { padding: 24px; }
}
.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.card h2 {
    font-size: 1.4rem;
    margin-bottom: 20px;
    color: var(--primary);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
}
.card h3 {
    font-size: 1.1rem;
    margin-bottom: 16px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ==================== 按钮 ==================== */
.btn {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition), transform 0.1s;
    position: relative;
    overflow: hidden;
}
.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}
.btn:hover::before { left: 100%; }
.btn:active { transform: scale(0.98); }
.btn:hover { background: var(--primary-dark); box-shadow: var(--shadow-md); }

.btn-secondary { background: #64748b; }
.btn-secondary:hover { background: #475569; }
.btn-danger { background: var(--error); }
.btn-danger:hover { background: #dc2626; }
.btn-sm {
    width: auto;
    padding: 8px 16px;
    font-size: 0.9rem;
    margin-top: 8px;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ==================== 表单 ==================== */
input, textarea, select {
    width: 100%;
    padding: 12px 16px;
    margin: 10px 0;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    background: white;
    transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.2);
}
label {
    display: block;
    margin-top: 16px;
    margin-bottom: 6px;
    font-weight: 500;
}

/* ==================== 加载 & 骨架屏 ==================== */
.loading { text-align: center; padding: 60px 0; }
.spinner {
    border: 4px solid rgba(59,130,246,0.1);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
    height: 24px;
    margin: 10px 0;
}
@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ==================== 足迹时间轴 ==================== */
.timeline {
    list-style: none;
    position: relative;
}
.timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border);
}
.timeline li {
    padding: 16px 0 16px 32px;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: background var(--transition), transform var(--transition);
    overflow: visible !important;
}
.timeline li:hover {
    background: rgba(59,130,246,0.02);
    transform: translateX(4px);
}
.timeline li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 20px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 3px solid white;
    z-index: 1;
    transition: transform var(--transition);
}
.timeline li.owner-event::before {
    background: var(--primary);
    box-shadow: 0 0 0 2px rgba(59,130,246,0.5);
}
.timeline li.stranger-event::before {
    background: var(--success);
    box-shadow: 0 0 0 2px rgba(16,185,129,0.5);
}
.timeline li.latest::before {
    transform: scale(1.2);
}
.timeline li:hover::before {
    transform: scale(1.2);
}

.timeline .time {
    color: var(--text-light);
    font-size: 0.85rem;
    font-weight: 500;
}
.timeline .event {
    font-weight: 500;
}
.timeline .location {
    color: var(--primary);
    font-size: 0.9rem;
    background: rgba(59,130,246,0.08);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    display: inline-block;
}
.timeline-date-header {
    font-weight: 600;
    margin-top: 24px;
    margin-bottom: 12px;
    color: var(--primary);
    padding-left: 32px;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ==================== 足迹合并条目美化 ==================== */
.merged-event {
    cursor: pointer;
    transition: background 0.15s;
    user-select: none;          /* 防止拖动选中干扰 */
    -webkit-tap-highlight-color: transparent; /* 移动端去除点击灰块 */
}
.merged-event {
    cursor: pointer;
    transition: background 0.15s;
}
.merged-event:hover {
    background: rgba(59, 130, 246, 0.02);
}

.merged-count-badge {
    display: inline-block;
    background: var(--primary-light);
    color: var(--primary-dark);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 30px;
    margin-left: 10px;
    letter-spacing: 0.3px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
    border: 1px solid rgba(59, 130, 246, 0.15);
    vertical-align: middle;
    line-height: 1.4;
}

.merged-toggle-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 6px;
    padding-left: 8px;
    opacity: 0.8;
    transition: opacity 0.15s;
}
.merged-event:hover .merged-toggle-hint {
    opacity: 1;
}

/* ==================== 合并足迹详情列表 ==================== */
.merged-details {
    margin-left: 32px;
    border-left: 2px dashed var(--border);
    padding-left: 20px;
    margin-top: 6px;
    margin-bottom: 10px;
}

.merged-detail-item {
    display: flex;
    align-items: baseline;
    padding: 6px 0;
    font-size: 0.9rem;
    color: var(--text-light);
    border-bottom: 1px solid rgba(0, 0, 0, 0.02);
}

.merged-detail-index {
    display: inline-block;
    min-width: 28px;
    text-align: right;
    margin-right: 12px;
    font-weight: 500;
    color: var(--primary-dark);
    opacity: 0.7;
    font-size: 0.8rem;
}

.merged-detail-time {
    font-family: 'SF Mono', 'Menlo', 'Monaco', 'Cascadia Code', 'Consolas', monospace;
    letter-spacing: 0.5px;
    color: var(--text);
    font-weight: 450;
}

.merged-detail-item:hover {
    background: rgba(59, 130, 246, 0.03);
    border-radius: 4px;
    padding-left: 6px;
    margin-left: -6px;
    transition: all 0.15s;
}

/* ==================== 查看更多足迹按钮 ==================== */
.expand-events-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 24px;
    background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
    color: var(--primary);
    border: 1.5px solid var(--primary-light);
    border-radius: 40px;
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.08);
    margin: 8px 0 4px;
    position: relative;
    z-index: 2;
    transform: translateY(0);
}

.expand-events-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.25);
    transform: translateY(-2px);
    z-index: 10;
}

.expand-events-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.15);
}

/* ==================== 留言 ==================== */
.message-item {
    background: #f9f9f9;
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    border-left: 4px solid var(--primary-light);
    transition: var(--transition);
}
.message-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
    border-left-color: var(--primary);
}
.message-item .meta {
    display: flex;
    justify-content: space-between;
    color: var(--text-light);
    font-size: 0.85rem;
    margin-bottom: 8px;
}
.reply-container {
    margin-left: 24px;
    margin-top: 8px;
    padding-left: 16px;
    border-left: 2px dashed var(--border);
}
.reply-item {
    background: #f0f2f5;
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 10px;
    font-size: 0.95rem;
}
.reply-item .meta {
    font-size: 0.8rem;
    margin-bottom: 4px;
}
.reply-input-area {
    margin-top: 10px;
    padding: 15px;
    background: #f9f9f9;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.reply-input-area textarea {
    margin-bottom: 10px;
    padding: 10px;
}

/* ==================== 视图切换 & 地图/日历 ==================== */
.view-toggle {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}
.view-toggle button {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    border-radius: var(--radius);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}
.view-toggle button.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
#mapContainer {
    width: 100%;
    height: 400px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    display: none;
}
#calendarContainer {
    width: 100%;
    margin-bottom: 20px;
    display: none;
}
.locate-btn {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    margin-bottom: 10px;
    font-size: 0.9rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.locate-btn:hover { background: #f5f5f5; }
.map-controls {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 8px;
}

/* ==================== 绑定页 ==================== */
.bind-box {
    background: linear-gradient(135deg, #e0f2fe 0%, #dbeafe 100%);
    border-radius: var(--radius-lg);
    padding: 40px 24px;
    text-align: center;
    margin-bottom: 24px;
    border: 1px solid rgba(59,130,246,0.2);
    position: relative;
    overflow: hidden;
}
.bind-box::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(59,130,246,0.05), transparent);
    transform: rotate(45deg);
    animation: float 8s linear infinite;
}
@keyframes float {
    0% { transform: translateX(-100%) rotate(45deg); }
    100% { transform: translateX(100%) rotate(45deg); }
}
.bind-box .icon { font-size: 64px; margin-bottom: 20px; position: relative; z-index: 1; }
.bind-box h2, .bind-box p { position: relative; z-index: 1; }
.bind-box p { color: var(--text-light); font-size: 1.05rem; }

/* ==================== 物品信息紧凑版（移动优先） ==================== */
.item-info {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 8px 0 4px;
    margin-bottom: 8px;
}

.item-avatar {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 26px;
    font-weight: bold;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.item-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.item-details {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.item-title-row {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 6px 10px;
}

.item-name {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
    word-break: break-word;
}

.item-id {
    font-size: 0.7rem;
    color: var(--text-light);
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 30px;
    font-family: 'SF Mono', monospace;
    white-space: nowrap;
    letter-spacing: 0.3px;
    border: 1px solid var(--border);
}

.item-owner {
    font-size: 0.95rem;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 4px;
    word-break: break-word;
}

.item-message {
    font-size: 0.9rem;
    color: var(--text-light);
    background: rgba(59, 130, 246, 0.04);
    padding: 8px 12px;
    border-radius: 12px;
    margin-top: 2px;
    line-height: 1.45;
    word-break: break-word;
    border: 1px solid rgba(59, 130, 246, 0.08);
}

/* 删除旧样式干扰 */
.item-details p,
.item-details .label,
.item-details .value {
    display: none;
}

/* ==================== HTTPS 提示 ==================== */
.https-warning {
    background: #fff3cd;
    color: #856404;
    padding: 14px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 0.9rem;
    text-align: center;
    border-left: 4px solid #ff9800;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* ==================== 响应式修正 ==================== */
@media (max-width: 480px) {
    .container { padding: 16px; }
    .card { padding: 20px; }
    .bind-box { padding: 30px 20px; }
    /* 移除原有的 .item-info 冲突规则，保留紧凑版原生表现 */
    .timeline li { padding-left: 28px; }
    .timeline-date-header { padding-left: 28px; }
    .reply-container { margin-left: 12px; padding-left: 12px; }
    #mapContainer { height: 300px; }
    .calendar-grid { font-size: 0.8rem; }
    .expand-events-btn { padding: 8px 18px; font-size: 0.9rem; }
}

/* 移动端进一步优化（屏宽 < 400px） */
@media (max-width: 400px) {
    .item-info {
        gap: 12px;
    }
    .item-avatar {
        width: 50px;
        height: 50px;
        font-size: 24px;
    }
    .item-name {
        font-size: 1.1rem;
    }
    .item-id {
        font-size: 0.65rem;
        padding: 2px 6px;
        white-space: normal;
        word-break: break-all;
    }
    .item-owner {
        font-size: 0.9rem;
    }
    .item-message {
        font-size: 0.85rem;
        padding: 6px 10px;
    }
}

/* ==================== 动画 & 工具 ==================== */
.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 4px; }
::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #a1a1a1; }

/* ==================== 模态框 ==================== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s;
}
.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--card-bg);
    border-radius: 20px;
    max-width: 550px;
    width: 95%;
    padding: 24px;
    border: 2px solid transparent;
    background-clip: padding-box;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.02), 0 8px 24px rgba(0,0,0,0.12), 0 20px 40px -12px rgba(0,0,0,0.2);
    animation: slideIn 0.3s;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}
.modal-content::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 22px;
    z-index: -1;
    opacity: 0.3;
    transition: opacity var(--transition);
}
.modal-content:hover::before { opacity: 0.5; }
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    padding-bottom: 15px;
    margin-bottom: 20px;
}
.modal-header h3 { margin: 0; color: var(--primary); }
.close-btn {
    color: var(--text-light);
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}
.close-btn:hover { color: var(--error); }
.modal-body { margin-bottom: 20px; }
.modal-body label { display: block; margin-bottom: 5px; font-weight: 500; }
.modal-body input,
.modal-body textarea,
.modal-body select {
    width: 100%;
    padding: 12px;
    margin-bottom: 24px;
    border: 2px solid #e2e8f0;
    border-radius: var(--radius);
    font-size: 1rem;
}
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    border-top: 1px solid var(--border);
    padding-top: 24px;
}
.modal-footer .btn {
    width: auto;
    padding: 12px 24px;
    margin-top: 0;
}
@keyframes slideIn {
    from { transform: translateY(-30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ==================== 日历（优化版） ==================== */
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.calendar-nav {
    background: none;
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}
.calendar-nav:hover {
    background: var(--primary-light);
    border-color: var(--primary);
}
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    text-align: center;
}
.calendar-weekday {
    font-weight: 600;
    color: var(--text-light);
    padding: 8px 0;
    font-size: 0.85rem;
}
.calendar-day {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 4px;
    min-height: 55px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
}
.calendar-day.empty {
    background: transparent;
    border-color: transparent;
    cursor: default;
}
.calendar-day:hover:not(.empty) {
    transform: scale(1.02);
    box-shadow: var(--shadow-sm);
    background: rgba(59, 130, 246, 0.03);
    border-color: var(--primary-light);
}
.calendar-day.has-event {
    background: rgba(59, 130, 246, 0.05);
    font-weight: 500;
}
.calendar-day.today {
    border: 2px solid var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}
.day-number {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 4px;
}
.event-dot {
    width: 6px;
    height: 6px;
    background: var(--primary);
    border-radius: 50%;
    margin: 2px 0;
}
.event-count-badge {
    font-size: 0.65rem;
    background: var(--primary);
    color: white;
    border-radius: 10px;
    padding: 1px 5px;
    margin-top: 2px;
    font-weight: 600;
    line-height: 1.3;
}

/* ==================== 图表 ==================== */
.chart-container { margin-bottom: 20px; }
.chart { width: 100%; height: 300px; }
.stats-loading {
    text-align: center;
    padding: 20px;
    color: var(--text-light);
}

/* 日历格子补充样式 */
.calendar-day .day-number {
    font-size: 1rem;
    font-weight: 500;
}
.calendar-day .event-dot {
    width: 5px;
    height: 5px;
    background: var(--primary);
    border-radius: 50%;
    margin-top: 3px;
}
.calendar-day .event-count-badge {
    font-size: 0.65rem;
    background: var(--primary-light);
    color: var(--primary-dark);
    border-radius: 10px;
    padding: 1px 5px;
    margin-top: 2px;
    line-height: 1.2;
}
.calendar-day.today {
    background: rgba(59, 130, 246, 0.1);
    border: 2px solid var(--primary);
}
@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

/* 地图信息窗口美化 */
.map-info-window {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
.map-info-window button.map-copy-btn:hover {
    background: #3b82f6 !important;
    color: white !important;
    border-color: #3b82f6 !important;
}
.amap-info-content {
    border-radius: 16px !important;
    box-shadow: 0 8px 20px rgba(0,0,0,0.15) !important;
}