/* ========== CSS 部分 ========== */
* { box-sizing: border-box; margin: 0; }
body {
    font-family: system-ui, -apple-system, sans-serif;
    background: #f1f5f9;
    min-height: 100vh; min-height: 100dvh;
    display: flex; justify-content: center; align-items: center;
    padding: 20px; padding-bottom: env(safe-area-inset-bottom, 20px);
    overflow-x: hidden;
}
.container {
    max-width: 950px; width: 100%; background: white; border-radius: 24px;
    padding: 30px; box-shadow: 0 12px 48px rgba(0, 0, 0, 0.07);
}
h1 {
    font-size: 1.8rem; color: #0f172a; display: flex; align-items: center;
    gap: 10px; flex-wrap: wrap; margin-top: 0; margin-bottom: 6px;
}
h1 small { font-size: 0.9rem; font-weight: normal; color: #64748b; }
.help-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1.5px solid #cbd5e1;
    border-radius: 20px;
    cursor: pointer;
    background: white;
    color: #475569;
    transition: all 0.2s;
    white-space: nowrap;
    margin-left: 4px;
}
.help-btn:hover { background: #f1f5f9; border-color: #3b82f6; color: #3b82f6; }
.input-tabs {
    display: flex; gap: 0; margin-bottom: 0; background: #f1f5f9;
    border-radius: 14px; padding: 5px; width: fit-content; flex-wrap: wrap;
}
.input-tab {
    padding: 10px 22px; font-size: 0.9rem; font-weight: 600; border: none;
    border-radius: 10px; cursor: pointer; background: transparent; color: #64748b;
    transition: all 0.25s; white-space: nowrap; display: flex; align-items: center; gap: 7px;
}
.input-tab.active { background: white; color: #0f172a; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.input-tab:hover:not(.active) { color: #475569; background: rgba(255,255,255,0.5); }
textarea {
    width: 100%; height: 160px; padding: 14px; font-family: 'Courier New', monospace;
    font-size: 13px; border: 2px solid #e2e8f0; border-radius: 12px; resize: vertical;
    background: #fafcff; transition: border-color 0.2s, opacity 0.25s; margin-top: 10px;
}
textarea:focus { border-color: #3b82f6; outline: none; box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }
textarea.hidden { display: none; }
textarea.drag-over { border-color: #3b82f6 !important; border-style: dashed !important; background: #eff6ff !important; }
.upload-zone {
    width: 100%; min-height: 160px; border: 2px dashed #cbd5e1; border-radius: 14px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 10px; cursor: pointer; background: #fafcff; transition: all 0.25s;
    padding: 30px 20px; margin-top: 10px; text-align: center; user-select: none;
    position: relative; overflow: hidden;
}
.upload-zone.hidden { display: none; }
.upload-zone:hover { border-color: #3b82f6; background: #f8faff; }
.upload-zone.drag-over { border-color: #3b82f6 !important; border-style: solid !important; background: #eff6ff !important; transform: scale(1.01); }
.upload-zone .upload-icon { font-size: 3rem; pointer-events: none; transition: transform 0.3s; }
.upload-zone.drag-over .upload-icon { transform: translateY(-6px); }
.upload-zone .upload-label { font-weight: 600; color: #475569; font-size: 1rem; }
.upload-zone .upload-hint { font-size: 0.8rem; color: #94a3b8; }
.upload-zone .upload-loading { display: none; font-size: 0.9rem; color: #3b82f6; font-weight: 500; }
.upload-zone.loading .upload-icon, .upload-zone.loading .upload-label, .upload-zone.loading .upload-hint { display: none; }
.upload-zone.loading .upload-loading { display: block; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%,100%{opacity:1;} 50%{opacity:0.4;} }
.upload-zone input[type="file"] { position: absolute; opacity: 0; width: 100%; height: 100%; top: 0; left: 0; cursor: pointer; }
.actions { display: flex; flex-direction: column; gap: 10px; margin: 16px 0 20px; }
.actions-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.actions-row.extract-row {
    flex-direction: column;
    align-items: stretch;
}
.actions-row.extract-row .btn-group {
    width: 100%;
    justify-content: flex-end;
    margin-top: 10px;
}
.actions-row .btn-group {
    display: flex;
    gap: 10px;
    flex: 0 0 auto;
    align-items: center;
}
.actions-row .btn-group button {
    width: 120px;
    flex-shrink: 0;
}
.btn-group.stacked {
    flex-direction: column;
    width: 100%;
    margin-left: 0;
    align-items: stretch;
}
.btn-group.stacked > button {
    width: 100% !important;
    flex: none;
}
.btn-group .sub-row, .btn-group .link-row { display: none; }
.btn-group.stacked .sub-row {
    display: flex;
    gap: 10px;
    width: 100%;
    justify-content: center;
}
.btn-group.stacked .sub-row button {
    flex: 1;
    min-width: 0;
    width: auto !important;
}
.btn-group.stacked .link-row {
    display: block;
    text-align: center;
    font-size: 0.75rem;
    color: #94a3b8;
    padding: 4px 0 0;
}
.link-status { font-size: 0.75rem; color: #94a3b8; max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; }
.tool-toggle-btn .arrow { display: inline-block; transition: transform 0.3s ease; font-size: 0.7rem; margin-left: 2px; }
.tool-toggle-btn.open .arrow { transform: rotate(180deg); }
.actions button {
    padding: 10px 0; font-size: 0.95rem; font-weight: 600; border: none; border-radius: 30px;
    cursor: pointer; transition: background 0.15s, transform 0.1s; white-space: nowrap;
    text-align: center; background: #e2e8f0; color: #1e293b;
}
.actions button:hover { transform: scale(1.02); }
.actions button.primary { background: #3b82f6; color: white; }
.actions button.primary:hover { background: #2563eb; }
.actions button.secondary { background: #e2e8f0; color: #1e293b; }
.actions button.secondary:hover { background: #cbd5e1; }
#resultContainer { margin-top: 6px; border: 1px solid #e2e8f0; border-radius: 16px; padding: 16px; background: #f8fafc; }
#statsAndTools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px; margin-bottom: 12px; }
#statsAndTools.hidden { display: none; }
.stats { font-size: 0.95rem; color: #475569; }
.stats span { font-weight: 700; color: #0f172a; }
.toolbar { display: flex; flex-direction: column; align-items: stretch; gap: 8px; flex: 1; }
.toolbar-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: center; }
.toolbar-row:first-child button { flex: 1; min-width: 80px; max-width: 180px; }
.toolbar-row:last-child { justify-content: center; }
.toolbar-row:last-child button { min-width: 140px; flex: 1; max-width: 280px; }
#selectedCount { font-size: 0.9rem; color: #475569; white-space: nowrap; margin-left: 4px; }
.toolbar button { padding: 6px 16px; font-size: 0.85rem; border: 1px solid #cbd5e1; border-radius: 30px; background: white; cursor: pointer; font-weight: 500; color: #1e293b; transition: background 0.1s; white-space: nowrap; }
.toolbar button:hover { background: #f1f5f9; }
.color-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; max-height: 200px; overflow-y: auto; padding: 8px 6px; border: 1px solid #e2e8f0; border-radius: 12px; background: white; }
.color-item { display: inline-flex; align-items: center; padding: 2px 6px 2px 2px; border-radius: 20px; gap: 6px; font-size: 0.9rem; user-select: none; }
.color-item input[type="checkbox"] { width: 15px; height: 15px; accent-color: #3b82f6; cursor: pointer; margin: 0; flex-shrink: 0; }
.color-swatch { display: inline-block; width: 1.2rem; height: 1.2rem; border-radius: 6px; border: 1px solid #d1d5db; flex-shrink: 0; }
.color-label { font-family: 'Courier New', monospace; font-weight: 500; word-break: break-all; }
.empty-state { color: #94a3b8; font-style: italic; padding: 12px 0; text-align: center; }
#replaceArea { margin-top: 16px; padding-top: 14px; border-top: 1px dashed #d1d5db; }
#replaceArea.hidden { display: none; }
.replace-area { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }
.replace-area label { font-weight: 500; color: #0f172a; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.replace-area input { padding: 8px 14px; border: 1.5px solid #d1d5db; border-radius: 30px; font-family: 'Courier New', monospace; font-size: 0.95rem; width: 160px; background: white; transition: border-color 0.2s; }
.replace-area input:focus { border-color: #3b82f6; outline: none; box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }
.replace-area button { padding: 8px 26px; background: #0f172a; color: white; border: none; border-radius: 30px; font-weight: 600; cursor: pointer; transition: background 0.15s; }
.replace-area button:hover { background: #1e293b; }
.replace-area button:disabled { opacity: 0.4; cursor: not-allowed; }
#replaceStatus { font-size: 0.85rem; color: #64748b; }
#bubbleSection { margin-top: 24px; border-top: 2px solid #e2e8f0; padding-top: 16px; }
#bubbleSection.hidden { display: none; }
.bubble-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.bubble-header h2 { font-size: 1.2rem; color: #0f172a; margin: 0; }
.bubble-preview-container { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.preview-box {
    width: 200px; height: 200px; border: 2px solid #e2e8f0; border-radius: 16px;
    background-color: #ffffff;
    background-image: linear-gradient(45deg, #e5e7eb 25%, transparent 25%),
                      linear-gradient(-45deg, #e5e7eb 25%, transparent 25%),
                      linear-gradient(45deg, transparent 75%, #e5e7eb 75%),
                      linear-gradient(-45deg, transparent 75%, #e5e7eb 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    display: flex; align-items: center; justify-content: center; overflow: hidden; flex-shrink: 0;
}
.preview-box svg { width: 100%; height: 100%; }
.bubble-controls { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: 12px; }
.control-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.control-row label { font-weight: 500; color: #475569; width: 70px; font-size: 0.9rem; }
.control-row input { padding: 6px 12px; border: 1.5px solid #d1d5db; border-radius: 20px; font-family: 'Courier New', monospace; font-size: 0.9rem; width: 100px; background: white; transition: border-color 0.2s; }
.control-row input:focus { border-color: #3b82f6; outline: none; box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }
.bubble-actions { display: flex; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.bubble-actions button { padding: 8px 20px; border-radius: 30px; font-weight: 600; font-size: 0.9rem; border: none; cursor: pointer; transition: background 0.2s, transform 0.1s; }
.bubble-actions button:hover { transform: scale(1.02); }
.btn-export { background: #0f172a; color: white; }
.btn-export:hover { background: #1e293b; }
.btn-apply { background: #3b82f6; color: white; }
.btn-apply:hover { background: #2563eb; }
.bubble-code-output { margin-top: 12px; background: #f1f5f9; border-radius: 12px; padding: 12px; font-family: 'Courier New', monospace; font-size: 0.8rem; white-space: pre-wrap; word-break: break-all; max-height: 120px; overflow-y: auto; border: 1px solid #e2e8f0; color: #0f172a; display: none; }
.bubble-code-output.show { display: block; }
#toast-container { position: fixed; top: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; max-width: 360px; pointer-events: none; }
.toast { background: #0f172a; color: white; padding: 14px 20px; border-radius: 16px; font-size: 0.95rem; font-weight: 500; box-shadow: 0 8px 24px rgba(0,0,0,0.15); animation: slideIn 0.3s ease-out; pointer-events: auto; display: flex; align-items: center; gap: 10px; }
.toast.success { background: #16a34a; }
.toast.error { background: #dc2626; }
.toast .toast-icon { font-size: 1.2rem; }
@keyframes slideIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
.toast-out { animation: slideOut 0.25s ease-in forwards; }
@keyframes slideOut { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(40px); } }
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0); display: none; justify-content: center; align-items: flex-end; z-index: 10000; transition: background 0.3s; }
.modal-overlay.active { display: flex; background: rgba(0,0,0,0.5); }
.modal-overlay.fullscreen { align-items: center; }
.modal-overlay.fullscreen .modal-content { height: auto; max-height: 92vh; width: 1000px; max-width: 92vw; border-radius: 24px; transform: scale(0.95); transition: transform 0.3s; }
.modal-overlay.fullscreen.active .modal-content { transform: scale(1); }
.modal-overlay.drawer .modal-content { width: 100%; max-width: 100%; border-radius: 24px 24px 0 0; padding-bottom: env(safe-area-inset-bottom, 0px); transform: translateY(100%); transition: transform 0.35s cubic-bezier(0.32,0.72,0,1), height 0.35s; will-change: transform, height; touch-action: none; overflow: hidden; display: flex; flex-direction: column; background: white; box-shadow: 0 -8px 40px rgba(0,0,0,0.15); }
.modal-overlay.drawer.active .modal-content { transform: translateY(0); }
.drawer-handle { width: 80px; height: 8px; border-radius: 99px; background: #94a3b8; margin: 16px auto 12px; flex-shrink: 0; cursor: grab; touch-action: none; user-select: none; }
.modal-body { flex: 1; min-height: 0; position: relative; overflow: hidden; background: #f8fafc; }
.modal-body iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: none; background: white; }
.loading-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; background: #f8fafc; z-index: 20; flex-direction: column; gap: 16px; transition: opacity 0.5s; }
.loading-overlay.hidden { opacity: 0; pointer-events: none; }
.loading-spinner { width: 44px; height: 44px; border: 4px solid #e2e8f0; border-top-color: #3b82f6; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.help-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10001;
    transition: background 0.3s;
}
.help-modal-overlay.active {
    display: flex;
    background: rgba(0, 0, 0, 0.55);
}
.help-modal {
    background: white;
    border-radius: 20px;
    width: 680px;
    max-width: 92vw;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    padding: 0;
}
.help-modal-overlay.active .help-modal {
    transform: scale(1);
}
.help-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px 16px;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 0;
    background: white;
    border-radius: 20px 20px 0 0;
    z-index: 2;
}
.help-modal-header h2 {
    font-size: 1.3rem;
    color: #0f172a;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}
.help-modal-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: #f1f5f9;
    font-size: 1.2rem;
    cursor: pointer;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}
.help-modal-close:hover {
    background: #e2e8f0;
    color: #0f172a;
}
.help-modal-body {
    padding: 20px 24px 24px;
}
.help-section {
    margin-bottom: 20px;
}
.help-section:last-child {
    margin-bottom: 0;
}
.help-section h3 {
    font-size: 1rem;
    color: #1e293b;
    margin: 0 0 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.help-section p {
    font-size: 0.9rem;
    color: #475569;
    line-height: 1.6;
    margin: 0 0 6px;
    padding-left: 24px;
}
.help-section .help-tip {
    background: #fefce8;
    border-left: 3px solid #facc15;
    padding: 8px 14px;
    border-radius: 0 8px 8px 0;
    font-size: 0.85rem;
    color: #854d0e;
    margin: 8px 0 0 24px;
    line-height: 1.5;
}
.help-section .help-shortcut {
    display: inline-block;
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    color: #475569;
    border: 1px solid #e2e8f0;
    margin: 0 2px;
}
.help-divider {
    border: none;
    border-top: 1px dashed #e2e8f0;
    margin: 16px 0;
}
.help-warning {
    background: #fff7ed;
    border-left: 3px solid #f97316;
    padding: 10px 14px;
    border-radius: 0 8px 8px 0;
    font-size: 0.85rem;
    color: #9a3412;
    margin: 10px 0 0 24px;
    line-height: 1.5;
}
@media (max-width: 740px) {
    .input-tabs { width: 100%; border-radius: 12px; padding: 4px; }
    .input-tab { flex: 1; justify-content: center; padding: 10px 12px; font-size: 0.85rem; }
    .bubble-preview-container { flex-direction: column; align-items: center; }
    .preview-box { width: 160px; height: 160px; }
    .actions-row .btn-group { width: 100%; margin-left: 0; justify-content: stretch; }
    .actions-row .btn-group button { flex: 1; }
    .help-modal {
        max-height: 90vh;
        border-radius: 16px;
    }
    .help-modal-header {
        padding: 16px 18px 12px;
    }
    .help-modal-body {
        padding: 16px 18px 20px;
    }
}

/* ========== 原有样式保持不变，追加以下内容 ========== */

/* SVG压缩工具行的布局（与图片转SVG样式一致） */
.btn-group.stacked .compress-sub-row {
    display: flex;
    gap: 10px;
    width: 100%;
    justify-content: center;
}
.btn-group.stacked .compress-sub-row button {
    flex: 1;
    min-width: 0;
    width: auto !important;
}
.btn-group.stacked .compress-link-row {
    display: block;
    text-align: center;
    font-size: 0.75rem;
    color: #94a3b8;
    padding: 4px 0 0;
}