body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    width: 100dvw;
    height: 100dvh;
    background-color: #0b0c10;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
    overflow: hidden;
    overscroll-behavior: none;
    color: #e0e6ed;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

#canvas-container {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    touch-action: none;
}

#app-root {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
}

.panel {
    position: absolute;
    top: max(12px, env(safe-area-inset-top, 12px));
    right: max(14px, env(safe-area-inset-right, 14px));
    max-height: calc(100dvh - max(94px, env(safe-area-inset-bottom, 20px) + 76px));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    pointer-events: auto;
    background: rgba(18, 22, 32, 0.84);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 16px;
    padding: 13px 14px;
    width: 326px;
    box-shadow: 0 10px 36px 0 rgba(0, 0, 0, 0.55);
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.touch-dock {
    position: absolute;
    bottom: max(14px, env(safe-area-inset-bottom, 14px));
    left: 50%;
    transform: translateX(-50%);
    max-width: calc(100dvw - 24px);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    pointer-events: auto;
    background: rgba(16, 20, 30, 0.88);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 15px;
    padding: 6px 10px;
    box-shadow: 0 10px 32px rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    gap: 5px;
    z-index: 25;
}

.touch-dock::-webkit-scrollbar {
    display: none;
}

.dock-sep {
    width: 1px;
    height: 24px;
    background: rgba(255, 255, 255, 0.18);
    margin: 0 2px;
    flex-shrink: 0;
}

.dock-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #dbe4f0;
    padding: 7px 10px;
    min-height: 36px;
    border-radius: 9px;
    font-size: 0.77rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    box-shadow: none;
    flex-shrink: 0;
    touch-action: manipulation;
}

.dock-btn.active {
    background: linear-gradient(135deg, #008CBA 0%, #00c6ff 100%);
    color: #ffffff;
    border-color: #00e5ff;
    box-shadow: 0 0 12px rgba(0, 198, 255, 0.45);
}

.dock-btn.accent {
    background: rgba(76, 175, 80, 0.25);
    border-color: #4CAF50;
    color: #b9f6ca;
}

h1 {
    font-size: 1.05rem;
    margin: 0;
    font-weight: 600;
    color: #ffffff;
    letter-spacing: 0.3px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

label {
    font-size: 0.78rem;
    font-weight: 500;
    color: #9cb2c9;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    display: flex;
    justify-content: space-between;
}

.val {
    color: #4facfe;
    font-weight: 600;
}

input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 26px;
    background: transparent;
    margin: 0;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 22px;
    width: 22px;
    border-radius: 50%;
    background: #4facfe;
    cursor: pointer;
    margin-top: -8px;
    box-shadow: 0 0 10px rgba(79, 172, 254, 0.6);
    transition: transform 0.1s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

input[type="range"]::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.22);
    border-radius: 3px;
}

.tab-btn {
    background-color: #2c2f33;
    border: 1px solid #444;
    color: #ccc;
    padding: 7px 10px;
    min-height: 35px;
    border-radius: 8px;
    cursor: pointer;
    flex: 1;
    margin: 0 2px;
    box-shadow: none;
    font-size: 0.82rem;
}

.tab-btn.active {
    background-color: #4CAF50;
    color: white;
    border-color: #4CAF50;
}

.mode-btn {
    background-color: #2c2f33;
    border: 1px solid #444;
    color: #ccc;
    padding: 6px 8px;
    min-height: 34px;
    border-radius: 8px;
    cursor: pointer;
    flex: 1;
    font-size: 0.77rem;
    box-shadow: none;
}

.mode-btn.active {
    background-color: #008CBA;
    color: white;
    border-color: #008CBA;
}

button, .file-upload-btn {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    border: none;
    border-radius: 8px;
    color: #ffffff;
    padding: 8px 12px;
    min-height: 35px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: center;
    box-shadow: 0 4px 14px rgba(0, 242, 254, 0.22);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    touch-action: manipulation;
}

button:hover, .file-upload-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(0, 242, 254, 0.35);
}

button:active, .file-upload-btn:active {
    transform: translateY(1px);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.1);
    box-shadow: none;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    box-shadow: none;
}

input[type="file"] {
    display: none;
}

/* iPad Pro 11-inch (M5) Landscape (1210x834) & Portrait (834x1210) tuning */
@media screen and (max-width: 1280px) and (max-height: 900px) {
    .panel {
        width: 308px;
        padding: 11px 12px;
        gap: 7px;
        max-height: calc(100dvh - max(84px, env(safe-area-inset-bottom, 16px) + 68px));
    }
    .dock-btn {
        padding: 6px 9px;
        min-height: 34px;
        font-size: 0.75rem;
    }
}

@media screen and (max-width: 900px) {
    .panel {
        width: 296px;
        padding: 11px 12px;
        gap: 7px;
    }
    .touch-dock {
        padding: 5px 8px;
        gap: 4px;
    }
    .dock-btn {
        padding: 6px 8px;
        min-height: 34px;
        font-size: 0.73rem;
    }
}
