body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(-45deg, #667eea, #f5f7fa, #764ba2, #ffffff, #f093fb, #e8f5e9, #4facfe, #f0f4f8, #00f2fe, #43e97b, #fafbfc, #38f9d7);
    background-size: 400% 400%;
    animation: auroraFlow 20s ease infinite;
    overflow-y: auto;
    height: auto;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    color: #2c3e50;
}

@keyframes auroraFlow {
    0% { background-position: 0% 50%; }
    25% { background-position: 50% 100%; }
    50% { background-position: 100% 50%; }
    75% { background-position: 50% 0%; }
    100% { background-position: 0% 50%; }
}

#wall {
    position: relative;
    width: 99vw;
    min-height: 100vh;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    grid-auto-flow: dense;
    gap: 20px;
    padding: 40px 20px;
    box-sizing: border-box;
}

.card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: none;
    border-radius: 16px;
    padding: 0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    word-wrap: break-word;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    transform: scale(0.95) translateY(10px);
    position: relative;
    transform-style: preserve-3d;
    perspective: 1000px;
}

/* Card flip container */
.card-inner {
    position: relative;
    width: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.card.flipped .card-inner {
    transform: rotateY(180deg);
}

/* Card front and back faces */
.card-front, .card-back {
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    padding: 24px;
}

.card-front {
    position: relative;
}

.card-back {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    transform: rotateY(180deg);
    display: flex;
    flex-direction: column;
    padding: 32px 24px;
    box-sizing: border-box;
}

/* Subtle gradient overlay on cards */
.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.card:hover::before {
    opacity: 1;
}

.card.small {
    grid-column: span 1;
    grid-row: span 1;
}

.card.medium {
    grid-column: span 2;
    grid-row: span 1;
}

.card.large {
    grid-column: span 2;
    grid-row: span 2;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
}

.quote-text {
    font-family: 'Georgia', serif;
    font-size: 1.05em;
    line-height: 1.6;
    color: #2c3e50;
    margin-bottom: 12px;
}

.quote-text p {
    margin: 0;
    font-style: italic;
}

.tags {
    opacity: 0;
    font-size: 0.75em;
    margin-top: 12px;
    font-weight: 500;
    letter-spacing: 0.5px;
    transition: opacity 0.3s ease;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.card:hover .tags {
    opacity: 1;
}

.tag {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 500;
    transition: transform 0.2s ease;
}

.tag:hover {
    transform: scale(1.05);
}

/* Pastel color palette for tags */
.tag:nth-child(6n+1) { background: #ffd6e7; color: #c2185b; } /* Pink */
.tag:nth-child(6n+2) { background: #d4e8ff; color: #1976d2; } /* Blue */
.tag:nth-child(6n+3) { background: #d4f4dd; color: #2e7d32; } /* Green */
.tag:nth-child(6n+4) { background: #fff3cd; color: #f57c00; } /* Yellow */
.tag:nth-child(6n+5) { background: #e8d5ff; color: #6a1b9a; } /* Purple */
.tag:nth-child(6n+6) { background: #ffdfcc; color: #d84315; } /* Orange */

.card.flipped {
    z-index: 10;
}

.card .details {
    margin-top: 16px;
}

.card-back .description {
    font-style: italic;
    color: #7f8c8d;
    line-height: 1.6;
    font-size: 1em;
    text-align: center;
    margin: 24px 0 0 0;
    word-wrap: break-word;
    white-space: normal;
}

.card-back .back-label {
    font-size: 0.8em;
    color: #95a5a6;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0;
    text-align: center;
    font-weight: 600;
    padding-top: 8px;
}

.description {
    font-style: italic;
    color: #7f8c8d;
    margin-top: 12px;
    margin-bottom: 16px;
    line-height: 1.5;
    font-size: 0.95em;
}

.resonate-btn, .delete-btn, .edit-btn {
    margin-top: 8px;
    margin-right: 8px;
    padding: 8px 16px;
    background: #ecf0f1;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.85em;
    font-weight: 500;
    color: #34495e;
}

.resonate-btn:hover {
    background: #a8e6cf;
    color: #27ae60;
    transform: translateY(-2px);
}

.delete-btn:hover {
    background: #ffb3b3;
    color: #e74c3c;
    transform: translateY(-2px);
}

.edit-btn:hover {
    background: #dfe6e9;
    color: #2c3e50;
    transform: translateY(-2px);
}

/* Admin-only elements - hidden by default */
.admin-only {
    display: none !important;
}

/* Show admin elements when body has admin-mode class */
body.admin-mode .admin-only {
    display: block !important;
}

/* Exception: icon buttons need flex display */
body.admin-mode #logout-btn {
    display: flex !important;
}

/* Exception: edit-fields should NEVER show from admin-only, only from editing class */
body.admin-mode .edit-fields {
    display: none !important;
}

/* Hide manage button in admin mode */
body.admin-mode #manage-btn {
    display: none !important;
}

/* Fixed buttons - modern floating style */
#manage-btn, #logout-btn, #add-note-btn, #shuffle-btn {
    position: fixed;
    right: 24px;
    padding: 14px 20px;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    z-index: 100;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
    font-size: 0.9em;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

/* Manage/Logout icon buttons */
#manage-btn, #logout-btn {
    bottom: 160px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    color: #7f8c8d;
    padding: 12px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#manage-btn:hover {
    background: white;
    color: #667eea;
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 6px 24px rgba(102, 126, 234, 0.3);
}

#logout-btn:hover {
    background: #fff5f5;
    color: #e74c3c;
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(231, 76, 60, 0.3);
}

#add-note-btn {
    bottom: 90px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    letter-spacing: 0.3px;
}

#add-note-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.4);
}

#shuffle-btn {
    bottom: 24px;
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
    letter-spacing: 0.3px;
}

#shuffle-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(44, 62, 80, 0.4);
}

/* Modal styles - premium feel */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(44, 62, 80, 0.7);
    backdrop-filter: blur(8px);
    z-index: 200;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

.modal.show {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 24px;
    max-width: 440px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-content h3 {
    margin-top: 0;
    color: #2c3e50;
    font-size: 1.4em;
    margin-bottom: 24px;
    font-weight: 600;
}

.modal textarea, .modal input[type="text"], .modal input[type="password"] {
    width: 100%;
    margin: 12px 0;
    padding: 14px 16px;
    border: 2px solid #ecf0f1;
    border-radius: 12px;
    box-sizing: border-box;
    font-family: inherit;
    font-size: 1em;
    transition: all 0.3s ease;
    background: #fafafa;
}

.modal textarea:focus, .modal input:focus {
    outline: none;
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.modal input[type="password"] {
    letter-spacing: 0.2em;
}

.modal textarea {
    min-height: 100px;
    resize: vertical;
    font-family: inherit;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    justify-content: flex-end;
}

.modal button {
    padding: 12px 28px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 500;
    transition: all 0.2s ease;
}

.modal button:active {
    transform: scale(0.97);
}

.modal button:first-of-type {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.modal button:first-of-type:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.modal button:last-of-type {
    background: #ecf0f1;
    color: #7f8c8d;
}

.modal button:last-of-type:hover {
    background: #dfe6e9;
    transform: translateY(-2px);
}

/* Admin login modal specific styling */
.admin-login h3 {
    text-align: center;
    font-style: italic;
    color: #7f8c8d;
    font-weight: 400;
}

.admin-login input[type="password"] {
    text-align: center;
}

.error-message {
    color: #e74c3c;
    font-size: 0.9em;
    text-align: center;
    min-height: 20px;
    margin-top: 8px;
    animation: shake 0.4s ease;
    font-weight: 500;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.error-message:empty {
    display: none;
}

/* Inline edit mode for cards */
.card.editing .quote-text, .card.editing .description, .card.editing .tags {
    display: none;
}

.edit-fields {
    display: none !important;
}

/* Edit fields only visible when BOTH editing AND admin mode */
.card.editing .edit-fields {
    display: block !important;
}

.edit-fields textarea, .edit-fields input {
    width: 100%;
    margin: 8px 0;
    padding: 12px;
    border: 2px solid #ecf0f1;
    border-radius: 10px;
    box-sizing: border-box;
    font-family: inherit;
    transition: border-color 0.3s ease;
    background: #fafafa;
}

.edit-fields textarea:focus, .edit-fields input:focus {
    outline: none;
    border-color: #667eea;
    background: white;
}

.edit-fields button {
    margin: 8px 8px 0 0;
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.edit-fields .save-edit {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.edit-fields .save-edit:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.edit-fields .cancel-edit {
    background: #ecf0f1;
    color: #7f8c8d;
}

.edit-fields .cancel-edit:hover {
    background: #dfe6e9;
    transform: translateY(-2px);
}

/* Responsiveness */
@media (max-width: 768px) {
    #wall {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 16px;
        padding: 24px 16px;
    }
    
    .card {
        padding: 20px;
    }
    
    .card.large {
        grid-column: span 1;
        grid-row: span 1;
    }
    
    #manage-btn, #logout-btn, #add-note-btn, #shuffle-btn {
        right: 16px;
    }
    
    #manage-btn, #logout-btn {
        bottom: 140px;
        width: 44px;
        height: 44px;
    }
    
    #add-note-btn {
        bottom: 80px;
    }
    
    #shuffle-btn {
        bottom: 20px;
    }
}
