/* ===== Global Reset & Theme ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Segoe UI', 'Noto Sans TC', -apple-system, sans-serif;
    font-size: 13px;
    line-height: 1.4;
    user-select: none;
    -webkit-user-select: none;
}

/* ===== Canvas ===== */
#main-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: default;
}

#main-canvas.panning {
    cursor: grab;
}

#main-canvas.panning-active {
    cursor: grabbing;
}

#main-canvas.crosshair {
    cursor: crosshair;
}

/* ===== Text Edit Overlay ===== */
#text-edit-overlay {
    position: absolute;
    display: none;
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--text-primary);
    font-family: 'Segoe UI', sans-serif;
    resize: none;
    outline: none;
    overflow: hidden;
    z-index: 1000;
    padding: 2px 4px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--bg-active);
}

/* ===== Common UI ===== */
button {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 4px 10px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.15s;
}
button:hover {
    background: var(--bg-hover);
}
button:active {
    background: var(--bg-active);
}

select, input[type="number"], input[type="text"] {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 3px 6px;
    border-radius: 3px;
    font-size: 12px;
    outline: none;
}
select:focus, input:focus {
    border-color: var(--accent);
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    outline: none;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--text-primary);
    cursor: pointer;
}

label {
    color: var(--text-secondary);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== Tooltip ===== */
[data-tooltip] {
    position: relative;
}
[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 8px;
    background: #111;
    color: #ddd;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 11px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 9999;
}
[data-tooltip]:hover::after {
    opacity: 1;
}

/* ===== Loading Screen ===== */
#loading-screen {
    position: fixed;
    inset: 0;
    background: #1e1e1e;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    transition: opacity 0.4s ease;
}
#loading-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}
.loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}
.loading-logo {
    font-family: 'Consolas', monospace;
    font-size: 36px;
    font-weight: 700;
    color: hsl(210, 35%, 50%);
    letter-spacing: 4px;
}
.loading-bar {
    width: 160px;
    height: 3px;
    background: #333;
    border-radius: 2px;
    overflow: hidden;
}
.loading-fill {
    height: 100%;
    width: 0%;
    background: hsl(210, 35%, 50%);
    border-radius: 2px;
    transition: width 0.3s ease;
}
.loading-text {
    font-size: 12px;
    color: #707070;
    letter-spacing: 1px;
}
