/* ==========================================
   11. 彈出遮罩與對話框 (Modals & Overlays)
   ========================================== */
#mobile-sidebar-overlay {
    z-index: 1010 !important;
    visibility: hidden;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--modal-overlay);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    opacity: 0;
    transition: opacity 0.3s, visibility 0.3s;
}

#mobile-sidebar-overlay.active {
    visibility: visible;
    opacity: 1;
}

#modal-overlay,
#confirm-overlay,
#calendar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--modal-overlay);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 2000;
}

#confirm-overlay {
    z-index: 10000 !important;
}

#calendar-overlay {
    z-index: 3000;
}

body.avatar-delete-confirm #confirm-overlay {
    z-index: 10004 !important;
}

#modal-overlay.active,
#confirm-overlay.active,
#calendar-overlay.active {
    opacity: 1;
}

div[id$="-modal"]:not(#full-editor-modal) {
    opacity: 0;
    transform: translate(-50%, -42%) scale(0.96);
    transition: opacity 0.25s cubic-bezier(0.2, 0.8, 0.2, 1),
        transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
    pointer-events: none;
}

div[id$="-modal"].active:not(#full-editor-modal) {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    pointer-events: auto;
}

.editor-external-top-bar {
    position: fixed;
    z-index: 2003;
    display: none;
    align-items: center;
    justify-content: space-between;
    width: 90%;
    max-width: 400px;
    height: var(--modal-bar-height);
    padding: 8px;
    border-radius: 18px;
    background: var(--popup-bg);
    backdrop-filter: blur(var(--blur-val));
    -webkit-backdrop-filter: blur(var(--blur-val));
    border: 1px solid var(--glass-border);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18), var(--glass-inner-highlight);
    box-sizing: border-box;
    opacity: 0;
    pointer-events: none;
    transform: translateY(34px) scale(0.94) translateZ(0);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1) 0s, opacity 0.18s ease 0s;
    user-select: none;
    -webkit-user-select: none;
}

.editor-external-top-bar.active {
    display: flex;
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1) translateZ(0);
    transition: transform 0.44s cubic-bezier(0.34, 1.38, 0.64, 1) 0.06s, opacity 0.24s ease 0.06s;
}

[data-no-glass="true"] .editor-external-top-bar,
[data-no-glass="true"] #editor-external-top-bar .segment-slider {
    transition: none !important;
}

#editor-external-top-bar #unified-type-selector {
    width: 100%;
    height: 100%;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    border-radius: 12px;
    touch-action: manipulation;
}

#editor-external-top-bar #unified-type-selector .segment-slider {
    top: 0;
    bottom: 0;
    left: 0;
    width: calc(100% / 3);
    transform-origin: left center;
    transition: none;
}

#editor-external-top-bar #unified-type-selector .segment-slider::before {
    border-radius: 12px;
    transform: none;
    transition: none;
}

#editor-external-top-bar #unified-type-selector .segment-btn {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.3px;
    color: var(--text-secondary);
    white-space: nowrap;
    transition: none;
}

#editor-external-top-bar #unified-type-selector .segment-btn span {
    display: inline-flex;
    align-items: center;
    line-height: 1;
}

#editor-external-top-bar #unified-type-selector .segment-btn.active {
    color: #FAF6EE;
}

#editor-external-top-bar #unified-type-selector .segment-btn svg {
    width: 21px;
    height: 21px;
    display: block;
    flex-shrink: 0;
    transform: none;
    transition: none;
}

.editor-edit-header {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    box-sizing: border-box;
    gap: 12px;
}

.editor-title-group {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.editor-title-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    color: var(--primary);
    flex-shrink: 0;
}

.editor-title-icon svg {
    width: 20px;
    height: 20px;
    display: block;
}

.editor-modal-title {
    margin: 0;
    display: inline-flex;
    align-items: center;
    font-size: 21px;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
}

.editor-edit-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.editor-edit-actions .action-delete-btn {
    display: flex;
    width: 44px;
    height: 44px;
    margin: 0;
    border-radius: 12px;
}

.editor-external-bottom-bar {
    position: fixed;
    z-index: 2003;
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 90%;
    max-width: 400px;
    height: var(--modal-bar-height);
    padding: 0 10px;
    border-radius: 18px;
    background: var(--popup-bg);
    backdrop-filter: blur(var(--blur-val));
    -webkit-backdrop-filter: blur(var(--blur-val));
    border: 1px solid var(--glass-border);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18), var(--glass-inner-highlight);
    box-sizing: border-box;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-34px) scale(0.94) translateZ(0);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1) 0s, opacity 0.18s ease 0s;
    user-select: none;
    -webkit-user-select: none;
}

.editor-external-bottom-bar.active {
    display: flex;
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1) translateZ(0);
    transition: transform 0.44s cubic-bezier(0.34, 1.38, 0.64, 1) 0.06s, opacity 0.24s ease 0.06s;
}

.editor-external-bottom-bar .btn-primary {
    flex: 1;
    height: 52px;
    padding: 0 16px;
    border-radius: 12px;
    font-size: 16.5px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
}

#editor-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    padding: 28px 24px;
    border-radius: 24px;
    width: 90%;
    max-width: 400px;
    height: min(536px, calc(100vh - 2 * (var(--modal-bar-height) + 24px)));
    max-height: min(536px, calc(100vh - 2 * (var(--modal-bar-height) + 24px)));
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2), var(--glass-inner-highlight);
    display: none;
    flex-direction: column;
    box-sizing: border-box;
    background: var(--popup-bg);
    backdrop-filter: blur(var(--blur-val));
    -webkit-backdrop-filter: blur(var(--blur-val));
    border: 1px solid var(--glass-border);
    pointer-events: none;
    text-align: left;
    overflow-y: auto;
    z-index: 2001;
    opacity: 0;
    transform: translate(-50%, calc(-50% + 16px)) scale(0.95);
    transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1) 0.04s, transform 0.22s cubic-bezier(0.4, 0, 0.2, 1) 0.04s;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: auto;
}

#editor-modal.active {
    display: flex !important;
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
    transition: opacity 0.28s cubic-bezier(0.2, 0.8, 0.2, 1) 0s, transform 0.42s cubic-bezier(0.34, 1.38, 0.64, 1) 0s;
}

#calendar-modal,
#confirm-modal,
#settings-modal,
#cloud-alert-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    padding: 30px;
    border-radius: 24px;
    width: 90%;
    max-width: 400px;
    height: auto;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2), var(--glass-inner-highlight);
    display: none;
    box-sizing: border-box;
    background: var(--popup-bg);
    backdrop-filter: blur(var(--blur-val));
    -webkit-backdrop-filter: blur(var(--blur-val));
    border: 1px solid var(--glass-border);
    pointer-events: none;
    text-align: left;
}

#calendar-modal {
    padding: 24px;
    max-width: 460px;
    background: var(--calendar-bg);
    backdrop-filter: blur(var(--blur-val));
    -webkit-backdrop-filter: blur(var(--blur-val));
    z-index: 3001;
}

#confirm-modal,
#settings-modal {
    max-width: 350px;
    z-index: 10001 !important;
}

body.avatar-delete-confirm #confirm-modal {
    z-index: 10005 !important;
}

#cloud-alert-modal {
    max-width: 350px;
    z-index: 10003 !important;
}

#editor-create-container {
    width: 100%;
    height: 100%;
    min-height: 0;
    flex: 1;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.editor-modal-timestamp {
    width: 100%;
    text-align: right;
    font-size: 14.5px;
    color: var(--text-secondary);
    opacity: 0.8;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.2px;
    margin-top: 14px;
    padding-right: 2px;
    transform: translateY(12px);
    flex-shrink: 0;
    user-select: none;
    -webkit-user-select: none;
    line-height: 1.4;
    white-space: nowrap;
    box-sizing: border-box;
}

