:root {
    --primary-bg: #FFF8F5;
    --primary-pink: #FFB6C1;
    --primary-pink-light: #FFE4E8;
    --primary-accent: #FF8FAB;
    --primary-deep: #E8738A;
    --text-primary: #4A4A4A;
    --text-secondary: #8A8A8A;
    --card-bg: #FFFFFF;
    --shadow-sm: 0 2px 8px rgba(255, 182, 193, 0.15);
    --shadow-md: 0 4px 16px rgba(255, 182, 193, 0.2);
    --shadow-lg: 0 8px 32px rgba(255, 182, 193, 0.25);
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

html,
body {
    height: 100%;
    overflow: hidden;
    touch-action: manipulation;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--primary-bg);
    color: var(--text-primary);
    line-height: 1.5;
}

/* Main App Container */
.app {
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
    overflow: hidden;
    position: relative;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--card-bg);
    box-shadow: var(--shadow-sm);
    position: relative;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.icon-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary-pink-light);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.icon-btn:active {
    transform: scale(0.95);
    background: var(--primary-pink);
}

.icon-btn svg {
    width: 22px;
    height: 22px;
    fill: var(--primary-deep);
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Avatar */
.avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-pink) 0%, var(--primary-accent) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
}

/* Main Content Area */
.main-content {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: 
        radial-gradient(circle at 20% 20%, rgba(255, 182, 193, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(135, 206, 235, 0.15) 0%, transparent 50%),
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 20px,
            rgba(255, 255, 255, 0.3) 20px,
            rgba(255, 255, 255, 0.3) 21px
        );
}

/* Canvas View */
.canvas-view {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    opacity: 1;
    transition: opacity 0.3s ease, transform 0.3s ease;
    transform: scale(1);
}

.tool-btn {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: var(--primary-pink-light);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tool-btn:active,
.tool-btn.active {
    background: var(--primary-pink);
}

.tool-btn svg {
    width: 22px;
    height: 22px;
    fill: var(--primary-deep);
}

.color-picker {
    display: flex;
    gap: 4px;
    padding: 0 8px;
}

.color-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.color-dot:active {
    transform: scale(1.15);
}

.color-dot.selected {
    border-color: var(--text-primary);
    box-shadow: 0 0 0 2px var(--card-bg);
}

/* Notes Display */
#notesDisplay {
    padding: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    align-content: flex-start;
    min-height: 100%;
}

.note-card {
    border: 3px solid #000;
    padding: 14px;
    border-radius: 12px;
    box-shadow: 4px 4px 0px #000;
    width: 140px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transform: rotate(-2deg);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

@media (min-width: 768px) {
    .note-card {
        width: 340px;
        padding: 32px;
        gap: 16px;
    }
    .note-card h4 {
        font-size: 22px;
    }
    .note-card p {
        font-size: 18px;
    }
    .note-card span:first-child {
        font-size: 40px !important;
    }
    #notesDisplay {
        gap: 36px;
        padding: 50px;
    }
}

.note-card:nth-child(even) {
    transform: rotate(2deg);
}

.note-card:nth-child(3n) {
    transform: rotate(-1deg);
}

.note-card:nth-child(5n) {
    transform: rotate(3deg);
}

.note-card:hover {
    transform: scale(1.1) rotate(0deg) !important;
    box-shadow: 6px 6px 0px #000;
    z-index: 10;
}

.note-card h4 {
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.note-card p {
    font-size: 10px;
    line-height: 1.4;
}

/* Note Modal */
#noteModalContent {
    text-align: center;
    padding: 30px;
}

#noteModalContent h3 {
    font-size: 20px;
    margin-bottom: 10px;
}

#noteModalContent p {
    font-size: 16px;
    line-height: 1.5;
    margin-bottom: 20px;
}

.note-like-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    margin: 0 auto 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: center;
}

.note-like-btn svg {
    width: 44px;
    height: 44px;
    fill: white;
    stroke: #555;
    stroke-width: 2;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
    transition: all 0.2s ease;
}

.note-like-btn.liked svg {
    fill: #ff4757;
    stroke: #ff4757;
    animation: likePop 0.3s ease;
}

@keyframes likePop {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.note-likes-display {
    font-size: 12px;
    color: #666;
    margin-bottom: 10px;
    padding: 6px 10px;
    background: rgba(255,255,255,0.5);
    border-radius: 12px;
    display: none;
}

/* Empty States */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    fill: var(--primary-pink);
    margin-bottom: 16px;
}

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

/* Toast */
.toast {
    position: fixed;
    bottom: calc(100px + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--text-primary);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-size: 14px;
    z-index: 2000;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Utility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}