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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f5f0e8;
    color: #333;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
}

#app {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    background: #f5f0e8;
    position: relative;
}

/* ===== 顶部导航 ===== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #f5f0e8;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 100;
}

.page-header.dark {
    background: #1a1a1a;
    color: #fff;
    border-bottom: none;
}

.page-header h1 {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: 1px;
}

.back-btn, .save-btn {
    background: none;
    border: none;
    font-size: 15px;
    color: #666;
    cursor: pointer;
    padding: 8px;
}

.page-header.dark .back-btn {
    color: #aaa;
}

.save-btn {
    color: #d4a574;
    font-weight: 600;
}

/* ===== 首页时间线 ===== */
.timeline-container {
    padding: 16px;
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.timeline-header h2 {
    font-size: 24px;
    font-weight: 300;
    letter-spacing: 2px;
}

.view-toggle {
    display: flex;
    gap: 8px;
}

.view-toggle button {
    background: none;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 13px;
    cursor: pointer;
}

.view-toggle button.active {
    background: #333;
    color: #fff;
    border-color: #333;
}

.stats-bar {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    padding: 16px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

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

.stat-item .number {
    display: block;
    font-size: 28px;
    font-weight: 300;
    color: #333;
}

.stat-item .label {
    font-size: 12px;
    color: #999;
    margin-top: 4px;
}

.timeline-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.timeline-item {
    background: #fff;
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    cursor: pointer;
    transition: transform 0.2s;
}

.timeline-item:active {
    transform: scale(0.98);
}

.timeline-date {
    font-size: 13px;
    color: #999;
    margin-bottom: 8px;
    letter-spacing: 1px;
}

.timeline-preview {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    min-height: 80px;
    align-items: center;
}

.timeline-preview img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1), 0 0 0 3px white;
}

.timeline-preview .placeholder {
    color: #ccc;
    font-size: 14px;
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #ccc;
}

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

.empty-state p {
    font-size: 14px;
    line-height: 1.6;
}

/* 浮动添加按钮 */
.fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #333;
    color: #fff;
    border: none;
    font-size: 28px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 90;
    transition: transform 0.2s;
}

.fab:active {
    transform: scale(0.9);
}

/* ===== 画布编辑页 ===== */
.canvas-container {
    padding: 16px;
    height: calc(100vh - 180px);
}

.canvas {
    width: 100%;
    height: 100%;
    background: #f5f0e8;
    border-radius: 16px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    background-image: 
        linear-gradient(rgba(0,0,0,0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0,0,0,0.03) 1px, transparent 1px);
    background-size: 20px 20px;
}

.sticker {
    position: absolute;
    cursor: grab;
    user-select: none;
    touch-action: none;
}

.sticker:active {
    cursor: grabbing;
}

.sticker img {
    display: block;
    pointer-events: none;
}

.sticker-tag {
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.7);
    color: #fff;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    white-space: nowrap;
    pointer-events: none;
}

.text-element {
    position: absolute;
    font-size: 16px;
    line-height: 1.5;
    max-width: 200px;
    word-wrap: break-word;
    cursor: grab;
    user-select: none;
    touch-action: none;
    font-weight: 500;
}

.text-element:active {
    cursor: grabbing;
}

/* 工具栏 */
.toolbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: 480px;
    margin: 0 auto;
    background: #fff;
    border-top: 1px solid rgba(0,0,0,0.05);
    padding: 12px 16px 24px;
    z-index: 100;
}

.toolbar-section {
    display: flex;
    justify-content: space-around;
}

.tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px 16px;
}

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

.tool-label {
    font-size: 11px;
    color: #666;
}

/* 背景选择器 */
.bg-picker {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #eee;
}

.bg-option {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.2s;
}

.bg-option:active {
    transform: scale(1.1);
}

.bg-option:hover {
    border-color: #333;
}

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

.modal-content {
    background: #fff;
    border-radius: 16px;
    padding: 20px;
    width: 100%;
    max-width: 320px;
}

.modal-content textarea {
    width: 100%;
    min-height: 100px;
    border: 1px solid #ddd;
    border-radius: 12px;
    padding: 12px;
    font-size: 16px;
    resize: none;
    font-family: inherit;
}

.modal-content input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 12px;
    font-size: 16px;
    font-family: inherit;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.modal-actions button {
    flex: 1;
    padding: 12px;
    border-radius: 12px;
    border: none;
    font-size: 15px;
    cursor: pointer;
}

.modal-actions button:first-child {
    background: #f0f0f0;
    color: #666;
}

.modal-actions button:last-child {
    background: #333;
    color: #fff;
}

/* 右键菜单 */
.context-menu {
    position: fixed;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    z-index: 1001;
    overflow: hidden;
    min-width: 120px;
}

.menu-item {
    padding: 12px 16px;
    font-size: 14px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
}

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

.menu-item:active {
    background: #f5f5f5;
}

/* ===== 日历页 ===== */
.calendar-container {
    padding: 16px;
}

.calendar-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding: 0 8px;
}

.calendar-nav button {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    color: #666;
}

.calendar-nav span {
    font-size: 17px;
    font-weight: 500;
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-bottom: 8px;
    text-align: center;
}

.calendar-weekdays span {
    font-size: 12px;
    color: #999;
    padding: 8px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    cursor: pointer;
    position: relative;
    background: #fff;
    transition: transform 0.2s;
}

.calendar-day:active {
    transform: scale(0.95);
}

.calendar-day.empty {
    background: transparent;
    cursor: default;
}

.calendar-day.empty:active {
    transform: none;
}

.day-number {
    font-size: 14px;
    font-weight: 500;
}

.calendar-day.has-record {
    background: #333;
    color: #fff;
}

.calendar-day.today {
    box-shadow: 0 0 0 2px #d4a574;
}

.day-thumb {
    width: 28px;
    height: 28px;
    object-fit: cover;
    border-radius: 6px;
    margin-top: 2px;
}

.day-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #d4a574;
    margin-top: 4px;
}

/* ===== 统计页 ===== */
.stats-container {
    padding: 16px;
    padding-bottom: 40px;
}

.stats-hero {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
}

.stat-big {
    flex: 1;
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.stat-big span {
    display: block;
    font-size: 42px;
    font-weight: 200;
    color: #333;
}

.stat-big label {
    font-size: 13px;
    color: #999;
    margin-top: 8px;
    display: block;
}

.stats-section {
    margin-bottom: 24px;
}

.stats-section h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 12px;
    color: #666;
    letter-spacing: 1px;
}

.streak-display {
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.streak-display span:first-child {
    font-size: 56px;
    font-weight: 200;
    color: #d4a574;
}

.streak-label {
    font-size: 24px;
    color: #666;
    margin-left: 4px;
}

.streak-sub {
    font-size: 13px;
    color: #999;
    margin-top: 8px;
}

.sticker-wall {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
}

.wall-img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s;
}

.wall-img:active {
    transform: scale(0.95);
}

.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 16px;
    background: #fff;
    border-radius: 16px;
}

.tag-item {
    background: #f5f0e8;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 14px;
    color: #666;
}

.heatmap {
    background: #fff;
    border-radius: 16px;
    padding: 16px;
    overflow-x: auto;
}

.heatmap-grid {
    display: grid;
    grid-template-columns: repeat(53, 1fr);
    gap: 3px;
    min-width: 400px;
}

.heatmap-cell {
    aspect-ratio: 1;
    border-radius: 3px;
    background: #eee;
}

.heatmap-cell.has-record {
    background: #d4a574;
}

.empty-tip {
    text-align: center;
    color: #ccc;
    font-size: 14px;
    padding: 20px;
}

/* ===== 加载动画 ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #eee;
    border-top-color: #d4a574;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-overlay p {
    margin-top: 12px;
    font-size: 14px;
    color: #999;
}

/* ===== 工具类 ===== */
.hidden {
    display: none !important;
}

/* 深色背景适配 */
.canvas[style*="#2c2c2c"] {
    background-image: 
        linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px) !important;
}

/* ===== 设置面板 ===== */
.settings-btn {
    position: fixed;
    bottom: 24px;
    left: 24px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #fff;
    border: none;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 2px 12px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 90;
    transition: transform 0.2s;
}

.settings-btn:active {
    transform: scale(0.9);
}

.settings-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.settings-content {
    background: #fff;
    border-radius: 24px 24px 0 0;
    padding: 24px;
    width: 100%;
    max-width: 480px;
    max-height: 80vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

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

.settings-content h3 {
    font-size: 18px;
    margin-bottom: 20px;
    text-align: center;
    color: #333;
}

.settings-item {
    display: flex;
    flex-direction: column;
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.settings-item:hover {
    background: #f5f5f5;
}

.settings-item span {
    font-size: 15px;
    color: #333;
    font-weight: 500;
}

.settings-item small {
    font-size: 12px;
    color: #999;
    margin-top: 4px;
}

.settings-item.danger span {
    color: #e74c3c;
}

.close-settings {
    width: 100%;
    padding: 14px;
    border-radius: 12px;
    border: none;
    background: #f0f0f0;
    font-size: 15px;
    cursor: pointer;
    margin-top: 16px;
}

/* 旋转手柄 */
.rotate-handle {
    position: absolute;
    top: -20px;
    right: -20px;
    width: 28px;
    height: 28px;
    background: #d4a574;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: grab;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    z-index: 1001;
    user-select: none;
}

.rotate-handle:active {
    cursor: grabbing;
    transform: scale(1.1);
}

/* 标签样式 - 黑色半透明，右下角，与图片重叠 */
.sticker-tag {
    position: absolute;
    bottom: -8px;
    right: -8px;
    background: rgba(0,0,0,0.75);
    color: #fff;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 10;
    backdrop-filter: blur(4px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* 选中状态 */
.sticker.selected {
    filter: brightness(1.05);
}

.sticker.selected img {
    box-shadow: 0 4px 16px rgba(212,165,116,0.4), 0 0 0 4px #d4a574;
}
