* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

[hidden] { display: none !important; }
body.editor-active { padding: 0; overflow: hidden; background: #0f172a; }
.editor { --list-panel-width: clamp(220px, 20vw, 300px); --inspector-panel-width: clamp(300px, 25vw, 380px); height: 100dvh; min-height: 0; display: grid; grid-template-columns: var(--list-panel-width) 6px minmax(400px, 1fr) 6px var(--inspector-panel-width); grid-template-rows: auto minmax(0, 1fr) auto; gap: 0; background: #cbd5e1; }
.editor-toolbar { grid-column: 1 / -1; display: flex; align-items: center; flex-wrap: wrap; gap: 10px 18px; padding: 10px 14px; background: #0f172a; color: white; }
.editor-toolbar__commands, .editor-toolbar__fields, .editor-toolbar__actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.editor-toolbar__actions { margin-left: auto; }
.editor-toolbar label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; }
.editor-toolbar input { width: 150px; }
.editor-panel { min-height: 0; display: flex; flex-direction: column; gap: 10px; padding: 14px; overflow: hidden; background: white; }
.editor-panel--list { grid-column: 1; }
.editor-panel--inspector { grid-column: 5; overflow-y: auto; overscroll-behavior: contain; }
.editor-panel__header { position: relative; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.editor-panel__header output { color: #475569; font-size: 12px; }
.editor aside label { display: grid; gap: 4px; margin: 10px 0; font-size: 13px; }
.editor input, .editor textarea { width: 100%; padding: 7px; border: 1px solid #cbd5e1; border-radius: 4px; }
.editor textarea { min-height: 76px; resize: vertical; }
.editor button { padding: 8px 10px; border: 0; border-radius: 4px; cursor: pointer; background: #e2e8f0; }
.editor-toolbar button, #exportPackage { background: #2563eb; color: white; }
#exitEditor { background: #475569; }
.booth-search-label { margin: 0 !important; }
.show-map-labels { display: inline-flex !important; align-items: center; gap: 4px; margin: 0 !important; font-size: 12px; color: #475569; white-space: nowrap; }
.show-map-labels input { width: auto; }
.panel-divider { height: 1px; background: #cbd5e1; }
.bulk-fill { display: grid; gap: 6px; }
/* 默认单行高度；聚焦后通过 is-expanded 展开为多行并可拖拽调整大小 */
#bulkFillData { height: 33px; min-height: 0; resize: none; overflow: hidden; font-size: 13px; }
#bulkFillData.is-expanded { height: 140px; resize: vertical; overflow: auto; }
#boothList { min-height: 0; display: grid; gap: 5px; overflow: auto; padding: 2px; overscroll-behavior: contain; }
#boothList button { text-align: left; }
#boothList button.selected { background: #bfdbfe; outline: 2px solid #2563eb; }
.booth-issue-batches { position: absolute; z-index: 5; top: calc(100% + 8px); left: 0; width: min(360px, calc(100vw - 28px)); display: grid; gap: 8px; padding: 10px; border: 1px solid #93c5fd; border-radius: 6px; background: #fff; box-shadow: 0 12px 28px rgba(15, 23, 42, .22); }
.booth-issue-batches__header { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: #1e3a8a; font-size: 13px; font-weight: 600; }
.booth-issue-batches__header button { padding: 5px 7px; font-size: 12px; }
.booth-issue-batches__list { display: grid; gap: 5px; max-height: min(36dvh, 260px); overflow: auto; }
.booth-issue-batches__list button { text-align: left; }
.booth-issue-batches__list button.selected { background: #bfdbfe; outline: 2px solid #2563eb; }
.list-item--error, .map-booth.issue-error { border-left: 4px solid #dc2626; }
.list-item--warning, .map-booth.issue-warning { border-left: 4px solid #f59e0b; }
.panel-empty { margin: auto 0; color: #64748b; text-align: center; font-size: 13px; }
#inspector { display: grid; }
#inspector h2 { margin: 0 0 4px; font-size: 16px; }
.panel-resizer { position: relative; z-index: 4; min-height: 0; background: #cbd5e1; cursor: col-resize; touch-action: none; }
#listResizeHandle { grid-column: 2; }
#inspectorResizeHandle { grid-column: 4; }
.panel-resizer::after { position: absolute; inset: 0 2px; background: transparent; content: ''; }
.panel-resizer:hover, .panel-resizer:focus-visible { background: #60a5fa; outline: none; }
.canvas-shell { grid-column: 3; position: relative; min-height: 0; overflow: hidden; background: #e2e8f0; touch-action: none; cursor: grab; }
.canvas-shell.is-panning { cursor: grabbing; }
.map-stage { position: absolute; inset: 0 auto auto 0; transform-origin: 0 0; will-change: transform; }
#mapImage { display: block; max-width: none; user-select: none; pointer-events: none; }
.booth-overlay { position: absolute; inset: 0; --marker-inverse-scale: 1; }
.map-booth { position: absolute; width: 7px; height: 7px; padding: 0; border: 0; border-radius: 50%; background: #2563eb; box-shadow: 0 0 0 1px rgba(255, 255, 255, .9); cursor: grab; transform: translate(-50%, -50%) scale(var(--marker-inverse-scale)); transform-origin: center; will-change: transform; }
.map-booth.selected { background: #dc2626; z-index: 1; animation: booth-selected-flash .9s ease-in-out infinite; }
.map-booth.newly-created { background: #d4af37; z-index: 2; }
.map-booth.map-booth--peek-through { background: #fff; box-shadow: 0 0 0 1px rgba(255, 255, 255, .7); opacity: .28; animation: none; }
.map-booth:focus-visible { outline: 3px solid #facc15; outline-offset: 3px; }
.map-booth-label { position: absolute; left: 8px; top: -15px; display: grid; gap: 1px; padding: 2px 4px; border-radius: 3px; background: rgba(255, 255, 255, .68); color: #111827; font-size: 12px; font-weight: 600; line-height: 1.2; white-space: nowrap; pointer-events: none; }
.map-booth-label > span { display: block; }
.map-booth-status { width: fit-content; padding: 1px 3px; border-radius: 2px; color: white; font-size: 10px; }
.map-booth-status--error { background: #b91c1c; }
.map-booth-status--warning { background: #b45309; }
.map-controls { position: absolute; z-index: 2; right: 12px; bottom: 12px; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; max-width: calc(100% - 24px); padding: 8px; border-radius: 6px; background: rgba(15, 23, 42, .88); }
.map-controls button { color: white; background: #334155; }
.map-label-opacity { display: inline-flex; align-items: center; gap: 5px; color: white; font-size: 12px; white-space: nowrap; }
.map-label-opacity input { width: 92px; accent-color: #60a5fa; }
.map-label-opacity output { min-width: 3em; color: #dbeafe; font-variant-numeric: tabular-nums; }
.map-controls > output { min-width: 58px; padding: 7px 9px; border-radius: 4px; background: #020617; color: white; text-align: center; font-variant-numeric: tabular-nums; }
.editor-error { position: absolute; z-index: 3; top: 12px; left: 12px; right: 12px; margin: 0; padding: 10px 12px; border: 1px solid #fecaca; border-radius: 4px; background: rgba(254, 242, 242, .96); color: #b91c1c; font-size: 13px; line-height: 1.4; }
.editor-notice { position: absolute; z-index: 3; top: 12px; left: 12px; right: 12px; margin: 0; padding: 10px 12px; border: 1px solid #fde68a; border-radius: 4px; background: rgba(255, 251, 235, .96); color: #92400e; font-size: 13px; line-height: 1.4; }
@keyframes booth-selected-flash { 0%, 100% { box-shadow: 0 0 0 1px rgba(255, 255, 255, .9), 0 0 2px 1px rgba(220, 38, 38, .7); } 50% { box-shadow: 0 0 0 3px rgba(254, 202, 202, .95), 0 0 10px 4px rgba(220, 38, 38, .95); } }
@media (prefers-reduced-motion: reduce) { .map-booth.selected { animation: none; box-shadow: 0 0 0 3px rgba(254, 202, 202, .95); } }
#validation { display: grid; gap: 6px; max-height: min(30dvh, 260px); overflow: auto; padding: 10px 14px 14px; background: white; }
#validation button { text-align: left; border-left: 4px solid #f59e0b; }
#validation button.error { border-left-color: #dc2626; }
.validation-panel { grid-column: 1 / -1; min-height: 0; background: #f8fafc; }
.validation-panel__toggle { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 14px; border: 0; background: #e2e8f0; color: #0f172a; cursor: pointer; font-weight: 600; }
.validation-panel__toggle[aria-expanded="true"] { background: #cbd5e1; }
@media (max-width: 1023px) { body.editor-active { overflow: auto; } .editor { min-width: 1024px; } }

.container {
    max-width: 1400px;
    margin: 0 auto;
}

.container > header {
    text-align: center;
    margin-bottom: 30px;
}

.container > header h1 {
    color: white;
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.container > header p {
    color: rgba(255,255,255,0.8);
    font-size: 0.95rem;
}

.upload-section,
.stats-section,
.preview-section,
.json-section {
    background: white;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

.dropzone {
    border: 2px dashed #ccc;
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 20px;
}

.dropzone:hover, .dropzone.dragover {
    border-color: #3b82f6;
    background: #eff6ff;
}

.package-picker {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    background: #eff6ff;
    color: #1d4ed8;
    font-weight: 600;
    cursor: pointer;
}

.package-picker input { color: #334155; font-weight: 400; }

.dropzone-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.dropzone-text {
    color: #666;
    font-size: 1rem;
}

.dropzone-text strong {
    color: #3b82f6;
}

.dropzone-text small {
    display: block;
    margin-top: 8px;
    color: #999;
}

.file-info {
    margin-top: 16px;
    padding: 12px 16px;
    background: #f3f4f6;
    border-radius: 8px;
    font-size: 0.85rem;
    color: #555;
}

.parse-btn {
    width: 100%;
    padding: 14px 24px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s ease;
    margin-top: 16px;
}

.parse-btn:hover:not(:disabled) {
    background: #2563eb;
}

.parse-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

.loading {
    text-align: center;
    padding: 30px 20px;
    margin-top: 20px;
    background: #f8fafc;
    border-radius: 8px;
}

.spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 16px;
    border: 3px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-text {
    color: #666;
    font-size: 0.9rem;
}

.error-message {
    margin-top: 16px;
    padding: 14px 16px;
    border: 1px solid #fecaca;
    border-radius: 8px;
    background: #fef2f2;
    color: #b91c1c;
    font-size: 0.9rem;
    line-height: 1.5;
    white-space: pre-wrap;
}

.repack-result {
    margin-top: 12px;
    padding: 14px 16px;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    background: #f8fbff;
    font-size: 0.9rem;
}

.repack-issues {
    display: grid;
    gap: 4px;
    margin: 0 0 8px;
}

.repack-issue {
    margin: 0;
    font-size: 0.85rem;
    line-height: 1.5;
}

.repack-issue--error { color: #b91c1c; }

.repack-issue--warning { color: #92400e; }

.repack-preview {
    margin: 0 0 10px;
    color: #334155;
    line-height: 1.5;
}

.repack-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.repack-actions button {
    padding: 8px 14px;
    border: 1px solid #1d4ed8;
    border-radius: 6px;
    background: #1d4ed8;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
}

.repack-actions button:disabled {
    border-color: #cbd5e1;
    background: #e2e8f0;
    color: #94a3b8;
    cursor: not-allowed;
}

.warning-message {
    margin-top: 16px;
    padding: 14px 16px;
    border: 1px solid #fcd34d;
    border-radius: 8px;
    background: #fffbeb;
    color: #92400e;
    font-size: 0.9rem;
    line-height: 1.5;
    white-space: pre-wrap;
}

.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.stat-item {
    text-align: center;
    padding: 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    color: white;
}

.stat-item.quality-good {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
}

.stat-label {
    font-size: 0.85rem;
    opacity: 0.9;
    margin-top: 4px;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
}

.controls {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.control-btn {
    padding: 8px 16px;
    background: #f3f4f6;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s;
}

.control-btn:hover {
    background: #e5e7eb;
}

.control-btn.primary {
    background: #3b82f6;
    color: white;
}

.control-btn.primary:hover {
    background: #2563eb;
}

.zoom-level {
    margin-left: 8px;
    padding: 8px 12px;
    background: #f3f4f6;
    border-radius: 6px;
    font-size: 0.85rem;
    color: #666;
    font-weight: 500;
}

.canvas-container {
    position: relative;
    width: 100%;
    height: 600px;
    overflow: auto;
    background: #f1f5f9 url("data:image/svg+xml,%3Csvg width='20' height='20' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h20v20H0z' fill='none'/%3E%3Cpath d='M0 0h1v1H0zM19 0h1v1h-1zM0 19h1v1H0zM19 19h1v1h-1z' fill='%23cbd5e1' fill-opacity='.5'/%3E%3C/svg%3E");
    border-radius: 8px;
}

#previewCanvas {
    display: block;
    max-width: none;
}

.tip-text {
    margin-top: 12px;
    padding: 12px 16px;
    background: #f0fdf4;
    border-radius: 6px;
    color: #166534;
    font-size: 0.85rem;
}

.tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    pointer-events: none;
    z-index: 99999;
    max-width: 280px;
    display: none;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.json-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.json-toggle {
    padding: 8px 16px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
}

.json-toggle:hover {
    background: #2563eb;
}

.json-content {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 20px;
    border-radius: 8px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 12px;
    line-height: 1.6;
    max-height: 500px;
    min-height: 200px;
    overflow: auto;
    white-space: pre;
    word-wrap: normal;
    display: none;
    margin-top: 8px;
}

.json-content::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.json-content::-webkit-scrollbar-track {
    background: #2d2d2d;
    border-radius: 5px;
}

.json-content::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 5px;
}

.json-content::-webkit-scrollbar-thumb:hover {
    background: #777;
}

.rectify-toggle { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.rectify-preview-dialog { width: min(1100px, 92vw); border: 0; border-radius: 12px; padding: 24px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.rectify-preview-dialog::backdrop { background: rgba(0, 0, 0, .55); }
.rectify-preview-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 16px 0; }
.rectify-preview-grid figure { margin: 0; min-width: 0; }
.rectify-preview-grid figcaption { margin-bottom: 8px; font-weight: 600; }
.rectify-preview-grid img { display: block; width: 100%; max-height: 60vh; object-fit: contain; background: #f3f4f6; }
.rectify-preview-warnings { color: #92400e; white-space: pre-line; }
.rectify-preview-actions { display: flex; justify-content: flex-end; gap: 10px; }
@media (max-width: 700px) { .rectify-preview-grid { grid-template-columns: 1fr; } }
