/* --- iOS 浅色液态玻璃设计 --- */
:root {
    --ios-bg: #f2f4f8;
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-bg-hover: rgba(255, 255, 255, 0.92);
    --glass-border: rgba(255, 255, 255, 0.85);
    --glass-shadow: 0 12px 32px 0 rgba(31, 38, 135, 0.08);
    
    --accent-blue: #007aff;
    --accent-blue-hover: #0056b3;
    --accent-green: #34c759;
    --danger-red: #ff3b30;
    --warning-orange: #ff9500;
    
    --text-primary: #1c1c1e;
    --text-secondary: #8e8e93;
    --border-subtle: rgba(60, 60, 67, 0.12);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, sans-serif;
}

body {
    background-color: var(--ios-bg);
    color: var(--text-primary);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    position: relative;
}

.glass-bg-blobs {
    position: absolute;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 0;
    pointer-events: none;
}
.blob { position: absolute; filter: blur(80px); opacity: 0.45; border-radius: 50%; }
.blob-1 { width: 350px; height: 350px; background: #a1c4fd; top: -80px; left: -80px; }
.blob-2 { width: 450px; height: 450px; background: #c2e9fb; bottom: -100px; right: -80px; }
.blob-3 { width: 300px; height: 300px; background: #e0c3fc; top: 40%; left: 30%; }

.app-container {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(25px) saturate(180%);
    -webkit-backdrop-filter: blur(25px) saturate(180%);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
}

.glass-pill {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}

/* 顶部导航条 */
.top-bar {
    height: 56px;
    padding: 0 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 10px 14px 0 14px;
    border-radius: 20px;
    flex-shrink: 0;
}

.brand { display: flex; align-items: center; gap: 8px; }
.brand-logo {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, #007aff, #5856d6);
    color: white; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; box-shadow: 0 4px 12px rgba(0, 122, 255, 0.25);
}
.brand-title { font-size: 16px; font-weight: 700; color: var(--text-primary); display: flex; align-items: center; }

.badge {
    font-size: 11px; font-weight: 600;
    background: rgba(0, 122, 255, 0.12); color: var(--accent-blue);
    padding: 3px 10px; border-radius: 12px; margin-left: 8px; white-space: nowrap;
}

.toolbar-center { display: flex; align-items: center; gap: 10px; }

.glass-btn {
    padding: 7px 14px; border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.75);
    color: var(--text-primary); font-size: 13px; font-weight: 600;
    cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
    transition: all 0.2s ease; white-space: nowrap;
}
.glass-btn:active { transform: scale(0.96); }
.glass-btn.primary { background: var(--accent-blue); color: white; border: none; box-shadow: 0 4px 14px rgba(0, 122, 255, 0.25); }
.glass-btn.primary-subtle { background: rgba(0, 122, 255, 0.1); color: var(--accent-blue); border: 1px solid rgba(0, 122, 255, 0.2); }
.glass-btn.accent-green { background: var(--accent-green); color: white; border: none; box-shadow: 0 4px 12px rgba(52, 199, 89, 0.25); }
.glass-btn.danger { background: rgba(255, 59, 48, 0.1); color: var(--danger-red); border: 1px solid rgba(255, 59, 48, 0.2); }
.glass-btn.danger-subtle { background: rgba(255, 59, 48, 0.08); color: var(--danger-red); border: 1px solid rgba(255, 59, 48, 0.15); }
.glass-btn.warning-subtle { background: rgba(255, 149, 0, 0.08); color: var(--warning-orange); border: 1px solid rgba(255, 149, 0, 0.15); }
.glass-btn.xs { padding: 5px 10px; font-size: 11px; border-radius: 8px; }
.glass-btn.full-width { width: 100%; justify-content: center; }

.icon-btn {
    width: 32px; height: 32px; border: none; background: transparent;
    color: var(--text-primary); border-radius: 50%; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.icon-btn:active { background: rgba(0, 0, 0, 0.08); }

.status-badge {
    font-size: 12px; color: var(--accent-blue);
    background: rgba(0, 122, 255, 0.08); padding: 5px 12px;
    border-radius: 20px; display: flex; align-items: center; gap: 6px; font-weight: 500;
}

/* 主工作区 */
.main-workspace {
    flex: 1; display: flex; padding: 10px 14px 14px 14px; gap: 14px; overflow: hidden; position: relative;
}

.sidebar {
    width: 300px; border-radius: 22px; display: flex; flex-direction: column; overflow: hidden; flex-shrink: 0;
}

.sidebar-header {
    padding: 12px 16px; border-bottom: 1px solid var(--border-subtle);
    display: flex; align-items: center; justify-content: space-between;
}
.sidebar-header h3 { font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.sidebar-actions { display: flex; align-items: center; gap: 4px; }

.temp-stamp-section { padding: 10px 14px 2px 14px; }

.glass-input-wrapper { margin: 8px 14px; position: relative; }
.glass-input-wrapper i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-secondary); font-size: 12px; }
.glass-input-wrapper input {
    width: 100%; padding: 7px 10px 7px 30px; border-radius: 10px;
    border: 1px solid var(--border-subtle); background: rgba(255, 255, 255, 0.5);
    outline: none; font-size: 12px;
}

.stamp-categories { flex: 1; overflow-y: auto; padding: 4px 14px 14px 14px; -webkit-overflow-scrolling: touch; }

/* 分类组 */
.folder-group { margin-bottom: 8px; }
.folder-title {
    font-size: 14px; font-weight: 700; color: var(--text-primary);
    padding: 8px 12px; border-radius: 12px; display: flex;
    align-items: center; justify-content: space-between; cursor: pointer;
    background: rgba(255, 255, 255, 0.5); border: 1px solid var(--border-subtle);
}
.folder-title-left { display: flex; align-items: center; gap: 6px; }
.folder-title .chevron-icon { font-size: 11px; color: var(--text-secondary); transition: transform 0.3s ease; }
.folder-group.open .chevron-icon { transform: rotate(90deg); }
.folder-count-badge { font-size: 11px; font-weight: 600; background: rgba(0, 122, 255, 0.1); color: var(--accent-blue); padding: 1px 7px; border-radius: 10px; }

.folder-collapse-wrapper {
    display: grid; grid-template-rows: 0fr; opacity: 0;
    transition: grid-template-rows 0.3s ease, opacity 0.2s ease, margin 0.25s ease;
    margin-top: 0;
}
.folder-group.open .folder-collapse-wrapper { grid-template-rows: 1fr; opacity: 1; margin-top: 6px; }
.folder-collapse-inner { overflow: hidden; }

.stamp-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stamp-item {
    background: rgba(255, 255, 255, 0.75); border: 1px solid var(--glass-border);
    border-radius: 12px; padding: 8px; display: flex; flex-direction: column; align-items: center;
    cursor: pointer;
}
.stamp-item img { width: 60px; height: 60px; object-fit: contain; pointer-events: none; }
.stamp-item span { font-size: 10px; margin-top: 4px; color: var(--text-primary); font-weight: 500; text-align: center; word-break: break-all; }

/* 画布主视图区域 */
.viewport-container {
    flex: 1; position: relative; border-radius: 22px; overflow: hidden;
    background: rgba(255, 255, 255, 0.35); border: 1px solid var(--glass-border);
    display: flex; align-items: center; justify-content: center;
    touch-action: none;
}

.floating-zoom-controls {
    position: absolute; top: 12px; right: 12px; z-index: 80;
    display: flex; align-items: center; padding: 2px 6px; font-size: 12px; font-weight: 600;
}
#zoom-level { min-width: 40px; text-align: center; font-size: 11px; }

.canvas-stage {
    position: absolute; transform-origin: center center;
    box-shadow: 0 16px 48px rgba(0,0,0,0.1); border-radius: 4px;
}

#doc-canvas { display: block; background: white; }
.stamp-layer { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; }

.placed-stamp { position: absolute; pointer-events: auto; cursor: move; transform-origin: center center; touch-action: none; }
.placed-stamp img { width: 100%; height: 100%; pointer-events: none; }
.placed-stamp.selected { outline: 2px dashed var(--accent-blue); }

.stamp-handle-rotate {
    position: absolute; top: -24px; left: 50%; transform: translateX(-50%);
    width: 22px; height: 22px; background: var(--accent-blue); border-radius: 50%;
    color: white; font-size: 10px; display: flex; align-items: center; justify-content: center;
    cursor: grab; box-shadow: 0 2px 8px rgba(0,122,255,0.4); touch-action: none;
}
.stamp-handle-resize {
    position: absolute; right: -6px; bottom: -6px;
    width: 16px; height: 16px; background: var(--accent-blue);
    border: 2px solid white; border-radius: 50%; cursor: nwse-resize; touch-action: none;
}

.drop-zone-overlay {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    pointer-events: auto; z-index: 10; cursor: pointer;
}
.drop-zone-overlay.hidden { display: none; pointer-events: none; }

.drop-zone-card {
    padding: 36px 50px; border-radius: 28px; text-align: center;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.drop-zone-card:hover { transform: scale(1.02); box-shadow: 0 16px 40px rgba(0, 122, 255, 0.15); }

.drop-icon-wrapper {
    width: 64px; height: 64px;
    background: linear-gradient(135deg, rgba(0,122,255,0.1), rgba(88,86,214,0.1));
    color: var(--accent-blue); border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 28px; margin: 0 auto 16px auto;
}

/* 屏幕底部居中 Export Dock */
.bottom-dock-wrapper {
    position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 100; pointer-events: auto;
}
.bottom-dock { padding: 4px 10px; display: flex; align-items: center; gap: 8px; }
.dock-segment { display: flex; align-items: center; gap: 6px; }
.dock-divider { width: 1px; height: 18px; background: var(--border-subtle); margin: 0 2px; }

/* 右侧属性微调 */
.prop-content { padding: 16px; -webkit-overflow-scrolling: touch; }
.prop-group { margin-bottom: 16px; }
.prop-label { display: flex; justify-content: space-between; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.val-tag { color: var(--accent-blue); }

input[type="range"] { width: 100%; accent-color: var(--accent-blue); }
.glass-select {
    width: 100%; padding: 8px; border-radius: 10px; border: 1px solid var(--border-subtle);
    background: rgba(255, 255, 255, 0.7); outline: none; font-size: 12px;
}

.empty-tip { text-align: center; color: var(--text-secondary); padding: 40px 10px; font-size: 12px; }
.empty-tip i { font-size: 32px; opacity: 0.3; margin-bottom: 10px; display: block; }

/* 导出格式选择小弹窗样式 */
.export-modal-card {
    position: fixed; top: 50%; left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    width: 90vw; max-width: 380px; z-index: 1000;
    border-radius: 24px; padding: 20px;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(30px); -webkit-backdrop-filter: blur(30px);
    opacity: 0; pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.export-modal-card.show { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }

.export-format-options { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }
.format-card {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px; border-radius: 14px; background: rgba(255, 255, 255, 0.6);
    border: 1px solid var(--border-subtle); cursor: pointer; transition: all 0.2s ease;
}
.format-card:hover, .format-card.active {
    background: white; border-color: var(--accent-blue); box-shadow: 0 4px 14px rgba(0, 122, 255, 0.12);
}
.format-card-left { display: flex; align-items: center; gap: 12px; }
.format-card-icon {
    width: 36px; height: 36px; border-radius: 10px;
    background: rgba(0, 122, 255, 0.1); color: var(--accent-blue);
    display: flex; align-items: center; justify-content: center; font-size: 16px;
}
.format-card-info h4 { font-size: 13px; font-weight: 700; color: var(--text-primary); }
.format-card-info p { font-size: 10px; color: var(--text-secondary); margin-top: 2px; }
.format-radio { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--text-secondary); }
.format-card.active .format-radio { border-color: var(--accent-blue); background: var(--accent-blue); }

.modal-footer { margin-top: 10px; }

/* 弹窗遮罩 */
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
    z-index: 900; opacity: 0; pointer-events: none;
    transition: opacity 0.25s ease;
}
.modal-backdrop.show { opacity: 1; pointer-events: auto; }

/* --- 手机端响应式 --- */
.mobile-only { display: none !important; }
.desktop-only { display: inline-flex !important; }

@media (max-width: 768px) {
    .mobile-only { display: inline-flex !important; }
    .desktop-only { display: none !important; }

    .top-bar { margin: 6px 8px 0 8px; padding: 0 10px; height: 50px; border-radius: 16px; }
    .brand-title { font-size: 13px; }
    .brand-logo { width: 28px; height: 28px; font-size: 14px; }

    .main-workspace { padding: 6px 8px 8px 8px; gap: 0; }

    /* 手机端侧边栏重构为 iOS 悬浮小弹窗 */
    .sidebar.modal-card {
        position: fixed; top: 50%; left: 50%;
        transform: translate(-50%, -50%) scale(0.9);
        width: 88vw; max-width: 380px; height: auto; max-height: 82vh; max-height: 82dvh;
        z-index: 1000; border-radius: 24px;
        box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
        background: rgba(255, 255, 255, 0.96);
        backdrop-filter: blur(30px); -webkit-backdrop-filter: blur(30px);
        opacity: 0; pointer-events: none;
        transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .sidebar.modal-card.show {
        opacity: 1; pointer-events: auto;
        transform: translate(-50%, -50%) scale(1);
    }

    .viewport-container { border-radius: 16px; }

    .bottom-dock-wrapper { bottom: 8px; width: calc(100% - 16px); max-width: 380px; }
    .bottom-dock { justify-content: space-around; padding: 4px 6px; gap: 3px; }
    .dock-segment { gap: 3px; }
    .glass-btn { padding: 5px 8px; font-size: 11px; }
}