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

body {
    background: #0a0a0a;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

#canvas-wrap {
    position: relative;
    line-height: 0;
}

#wave-canvas {
    display: block;
    max-width: 100vw;
    max-height: 100vh;
}

#region-markers {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

.region-marker {
    position: absolute;
    border: 1.5px dashed rgba(126, 184, 255, 0.5);
    border-radius: 3px;
    pointer-events: none;
}

.region-marker .marker-label {
    position: absolute;
    top: -1px;
    left: -1px;
    background: rgba(126, 184, 255, 0.7);
    color: #000;
    font-size: 9px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-weight: 600;
    padding: 1px 4px;
    border-radius: 0 0 3px 0;
    line-height: 1.3;
}

#source-image {
    display: none;
}

#selection-overlay {
    position: fixed;
    border: 2px dashed rgba(126, 184, 255, 0.8);
    background: rgba(126, 184, 255, 0.1);
    pointer-events: none;
    z-index: 500;
    display: none;
    border-radius: 4px;
}

/* --- Debug Panel --- */

.debug-panel {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 280px;
    background: rgba(10, 10, 10, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 20px;
    color: #e0e0e0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 13px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 1000;
    transition: opacity 0.3s ease, transform 0.3s ease;
    max-height: 90vh;
    overflow-y: auto;
}

.debug-panel.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateX(20px);
}

.debug-panel h3 {
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    letter-spacing: 0.3px;
}

.control {
    margin-bottom: 14px;
}

.control label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    color: #aaa;
    font-size: 12px;
}

.control label span {
    color: #7eb8ff;
    font-variant-numeric: tabular-nums;
}

.control input[type="range"] {
    width: 100%;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    outline: none;
}

.control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #7eb8ff;
    cursor: pointer;
    border: 2px solid #0a0a0a;
}

.control input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #7eb8ff;
    cursor: pointer;
    border: 2px solid #0a0a0a;
}

.control button {
    width: 100%;
    padding: 8px;
    background: rgba(126, 184, 255, 0.12);
    color: #7eb8ff;
    border: 1px solid rgba(126, 184, 255, 0.25);
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s;
}

.control button:hover {
    background: rgba(126, 184, 255, 0.25);
}

.control button.active {
    background: rgba(126, 184, 255, 0.35);
    border-color: rgba(126, 184, 255, 0.6);
}

.control input[type="file"] {
    width: 100%;
    font-size: 11px;
    color: #aaa;
    margin-top: 4px;
}

.control input[type="file"]::file-selector-button {
    padding: 4px 10px;
    margin-right: 8px;
    background: rgba(126, 184, 255, 0.12);
    color: #7eb8ff;
    border: 1px solid rgba(126, 184, 255, 0.25);
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
}

.separator {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    margin: 16px 0;
}

.section-title {
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.region-info {
    font-size: 11px;
    color: #666;
    margin-top: 4px;
    line-height: 1.4;
}

.hint {
    margin-top: 12px;
    text-align: center;
    color: #555;
    font-size: 11px;
}

/* --- Region List --- */

.region-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px;
    margin-bottom: 4px;
    background: rgba(126, 184, 255, 0.06);
    border: 1px solid rgba(126, 184, 255, 0.12);
    border-radius: 5px;
    font-size: 11px;
    color: #bbb;
}

.region-item .region-label {
    display: flex;
    align-items: center;
    gap: 6px;
}

.region-item .region-num {
    background: rgba(126, 184, 255, 0.2);
    color: #7eb8ff;
    font-weight: 600;
    width: 18px;
    height: 18px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    flex-shrink: 0;
}

.region-item .region-delete {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 3px;
    width: auto;
    transition: color 0.15s, background 0.15s;
}

.region-item .region-delete:hover {
    color: #ff6b6b;
    background: rgba(255, 107, 107, 0.12);
}
