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

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

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

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

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

.note-modal-overlay,
.memory-modal-overlay,
.memory-prompt-overlay,
.art-modal-overlay,
.lexicon-modal-overlay,
.onboarding-overlay {
    background: var(--editorial-overlay);
    backdrop-filter: blur(14px) saturate(1.04);
    -webkit-backdrop-filter: blur(14px) saturate(1.04);
}

.note-modal-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
    animation: fadeIn 0.2s ease both;
}

.note-modal {
    background: var(--bg-sidebar, #111);
    border: 1px solid var(--border);
    border-radius: 30px;
    width: min(100%, 620px);
    padding: 30px 30px 28px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    animation: modalSlide 0.25s ease both;
}

.note-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 18px;
}

.note-modal-title {
    font-family: var(--font-sans);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.04em;
}

.note-modal-ref {
    font-family: var(--font-sans);
    font-size: 0.72rem;
    color: var(--accent-dark);
}

.note-modal-textarea {
    width: 100%;
    min-height: 220px;
    padding: 18px 18px 16px;
    background: rgba(255, 252, 247, 0.72);
    border: 1px solid rgba(168, 132, 83, 0.16);
    border-radius: 22px;
    color: var(--text-primary);
    font-family: var(--font-serif);
    font-size: 1.06rem;
    line-height: 1.6;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.78);
}

.note-modal-textarea:focus {
    border-color: rgba(168, 132, 83, 0.36);
    box-shadow: 0 0 0 4px rgba(168, 132, 83, 0.08);
}

.note-modal-textarea::placeholder {
    color: var(--text-muted);
    opacity: 0.5;
}

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

.note-modal-cancel,
.note-modal-save {
    padding: 8px 20px;
    font-family: var(--font-sans);
    font-size: 0.78rem;
    font-weight: 500;
    border-radius: var(--radius-sm, 8px);
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid var(--border);
}

.note-modal-cancel {
    background: rgba(168, 132, 83, 0.08);
    border: 1px solid rgba(168, 132, 83, 0.16);
    color: var(--accent-dark);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.note-modal-cancel:hover {
    background: rgba(168, 132, 83, 0.12);
    border-color: rgba(168, 132, 83, 0.24);
}

.note-modal-save {
    background: rgba(196, 154, 42, 0.15);
    color: var(--accent-light);
    border-color: rgba(196, 154, 42, 0.3);
}

.note-modal-save:hover {
    background: rgba(196, 154, 42, 0.25);
    border-color: var(--accent);
}

.hl-popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
    animation: fadeIn 0.2s ease both;
}

.hl-popup {
    background: var(--bg-card, #1a1a1a);
    border: 1px solid var(--border);
    border-radius: 14px;
    max-width: 480px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 12px 48px rgba(0,0,0,0.6);
    border-top: 3px solid var(--accent);
}

.hl-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}

.hl-popup-ref {
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent-light, #c49a2a);
    letter-spacing: 0.03em;
}

.hl-popup-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
}

.hl-popup-close:hover {
    color: #fff;
}

.hl-popup-body {
    padding: 16px 18px;
}

.hl-popup-verse {
    font-family: var(--font-serif, 'EB Garamond', serif);
    font-size: 1.05rem;
    line-height: 1.65;
    color: var(--text-primary);
    margin: 0 0 8px;
}

.hl-popup-verse sup {
    font-size: 0.65em;
    color: var(--accent-light);
    font-weight: 600;
    margin-right: 2px;
}

.hl-popup-note {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.hl-popup-note-label {
    font-family: var(--font-sans);
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--accent-light, #c49a2a);
    display: block;
    margin-bottom: 6px;
}

.hl-popup-note p {
    font-family: var(--font-serif);
    font-size: 0.9rem;
    font-style: italic;
    line-height: 1.5;
    color: var(--text-muted);
    margin: 0;
}

.hl-popup-footer {
    padding: 12px 18px;
    border-top: 1px solid rgba(255,255,255,0.06);
    text-align: center;
}

.art-modal-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 16px;
    animation: fadeIn 0.2s ease both;
}

.art-modal {
    background: var(--editorial-surface-strong);
    border: 1px solid var(--border);
    border-radius: 32px;
    width: 100%;
    max-width: 620px;
    overflow: hidden;
    box-shadow: 0 8px 40px rgba(0,0,0,0.6);
    animation: modalSlide 0.25s ease both;
}

.art-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 22px 24px 16px;
    border-bottom: 1px solid var(--editorial-rule);
}

.art-modal-title {
    font-family: var(--font-sans);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--accent-dark);
    letter-spacing: 0.03em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.art-title-icon {
    color: var(--accent-light, #c49a2a);
    flex-shrink: 0;
}

.art-download-btn svg {
    vertical-align: -3px;
    margin-right: 4px;
}

.art-modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}

.art-modal-close:hover {
    color: var(--text-primary);
}

.art-modal-body {
    position: relative;
    min-height: 220px;
    padding: 20px 20px 0;
    background: transparent;
}

.art-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 56px 20px 60px;
}

.art-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

.art-loading-text {
    font-family: var(--font-display);
    font-size: 0.92rem;
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-primary);
    margin: 0 0 4px;
}

.art-loading-ref {
    font-family: var(--font-serif);
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0;
}

.art-image {
    width: 100%;
    display: block;
    border-radius: 24px;
    border: 1px solid rgba(168, 132, 83, 0.16);
    box-shadow: 0 22px 48px rgba(30, 22, 15, 0.18);
}

.art-ref-overlay {
    position: absolute;
    bottom: 56px;
    left: 0;
    right: 0;
    text-align: center;
    font-family: var(--font-serif);
    font-size: 0.82rem;
}

.lexicon-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
    animation: lexFadeIn 0.2s ease;
}

.lexicon-modal {
    background: var(--bg-card);
    border: 1px solid var(--accent-border);
    border-radius: 20px 20px 0 0;
    width: 100%;
    max-width: 640px;
    max-height: 80vh;
    overflow-y: auto;
    padding: 24px 24px 40px;
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.3);
    animation: lexSlideUp 0.28s cubic-bezier(0.34, 1.2, 0.64, 1);
    -webkit-overflow-scrolling: touch;
}

.lexicon-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.lexicon-word-title {
    font-family: var(--font-serif);
    font-size: 1.8rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}
