:root {
    --bg-color: #080808;
    --surface-glass: rgba(23, 23, 23, 0.75);
    --surface-hover: rgba(40, 40, 40, 0.85);
    --accent-color: #3e6ae1;
    --accent-glow: rgba(62, 106, 225, 0.4);
    --danger-color: #e82127;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.6);
    --border-color: rgba(255, 255, 255, 0.12);
    --radius-lg: 18px;
    --radius-md: 10px;
    --radius-sm: 6px;
    --blur-lg: blur(40px) saturate(200%);
    --transition-std: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: 'Inter', 'Noto Sans TC', 'Roboto', sans-serif;
    background-color: var(--bg-color);
    background-image:
        radial-gradient(circle at 50% 50%, rgba(62, 106, 225, 0.05) 0%, transparent 70%),
        linear-gradient(rgba(255, 255, 255, 0.01) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.01) 1px, transparent 1px);
    background-size: 100% 100%, 60px 60px, 60px 60px;
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

:lang(zh-TW) {
    word-break: keep-all;
    overflow-wrap: break-word;
    letter-spacing: 0.02em;
    font-feature-settings: "palt";
}

::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.app-header {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    height: 64px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    background: var(--surface-glass);
    backdrop-filter: var(--blur-lg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    z-index: 1000;
}

.brand-mark {
    font-size: 14px;
    font-weight: 900;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--text-primary);
}

.brand-mark span {
    color: var(--accent-color);
}

.workshop-layout {
    flex: 1;
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.stage-area {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at center, #111 0%, #080808 100%);
    padding-top: 80px;
    padding-left: 20px;
    padding-right: 20px;
    overflow: hidden;
}

canvas {
    max-width: 80%;
    max-height: 80%;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.8);
    transition: var(--transition-std);
}

@media (max-width: 1200px) {
    canvas {
        max-width: 60%;
    }
}

#mobile-warning {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 9999;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    text-align: center;
}

@media (max-width: 768px) {
    #mobile-warning {
        display: flex;
    }

    .app-header,
    .workshop-layout,
    .garage-dock,
    .bottom-toolbar {
        display: none !important;
    }
}

.garage-dock {
    position: absolute;
    width: 280px;
    background: var(--surface-glass);
    backdrop-filter: var(--blur-lg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    z-index: 100;
    max-height: calc(100vh - 160px);
    overflow-y: auto;
    transition: var(--transition-std);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.garage-dock.collapsed {
    width: 48px;
    height: 48px;
    padding: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.dock-start {
    top: 104px;
    left: 20px;
}

.dock-end {
    top: 104px;
    right: 20px;
}

.dock-header {
    font-size: 10px;
    font-weight: 800;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.dock-trigger {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 20px;
    height: 20px;
    cursor: pointer;
    opacity: 0.5;
    transition: 0.3s;
}

.dock-trigger:hover {
    opacity: 1;
}

.dock-section {
    margin-bottom: 24px;
}

.garage-dock.collapsed .dock-body {
    display: none !important;
    pointer-events: none;
}

.garage-dock.collapsed .dock-trigger {
    position: relative;
    top: auto;
    right: auto;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
}

.dock-trigger svg {
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.dock-start .dock-trigger svg {
    transform: rotate(180deg);
}

.dock-start.collapsed .dock-trigger svg {
    transform: rotate(0deg);
}

.dock-end .dock-trigger svg {
    transform: rotate(0deg);
}

.dock-end.collapsed .dock-trigger svg {
    transform: rotate(180deg);
}

.bottom-toolbar {
    position: absolute;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface-glass);
    backdrop-filter: var(--blur-lg);
    border: 1px solid var(--border-color);
    border-radius: 40px;
    padding: 8px 16px;
    display: flex;
    gap: 12px;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition-std);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.bottom-toolbar.visible {
    opacity: 1;
    visibility: visible;
    bottom: 40px;
}

.action-btn {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 10px 18px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: var(--transition-std);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.action-btn:hover {
    background: var(--surface-hover);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid transparent;
    color: var(--text-primary);
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-std);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn:hover {
    background: var(--surface-hover);
    color: white;
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-danger {
    color: var(--danger-color);
    background: rgba(232, 33, 39, 0.05);
}

.btn-danger:hover {
    background: var(--danger-color);
    color: white;
    border-color: var(--danger-color);
}

.btn-main {
    background: var(--accent-color);
    border: none;
}

.btn-main:hover {
    background: var(--accent-hover);
    box-shadow: 0 0 20px var(--accent-glow);
}

.btn-block {
    width: 100%;
}

select,
input[type="text"] {
    width: 100%;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    outline: none;
    font-family: inherit;
    font-size: 14px;
    transition: var(--transition-std);
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

select:focus,
input:focus {
    border-color: var(--accent-color);
}

.control-label {
    display: block;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.paint-controls {
    background: rgba(255, 255, 255, 0.05);
    padding: 16px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
}

input[type="color"] {
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 50%;
    overflow: hidden;
    -webkit-appearance: none;
    appearance: none;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
}

input[type="range"] {
    width: 100%;
    height: 2px;
    background: #333;
    border-radius: 1px;
    -webkit-appearance: none;
    appearance: none;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: var(--accent-color);
    border-radius: 50%;
    cursor: pointer;
}

.switch-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 12px 0;
}

.switch {
    position: relative;
    width: 36px;
    height: 18px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #333;
    transition: .4s;
    border-radius: 18px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 12px;
    width: 12px;
    left: 3px;
    bottom: 3px;
    background: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background: var(--accent-color);
}

input:checked+.slider:before {
    transform: translateX(18px);
}

.toast-container {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    pointer-events: none;
}

.toast {
    background: rgba(30, 30, 30, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    color: white;
    padding: 12px 24px;
    border-radius: 40px;
    font-size: 13px;
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#loadingOverlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(20px);
    display: none;
    justify-content: center;
    align-items: center;
    color: white;
    flex-direction: column;
    z-index: 2000;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

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

.image-preview-card {
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-md);
    padding: 14px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    margin-bottom: 10px;
    transition: 0.3s;
}

.image-preview-card:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.2);
}

.image-preview-card.active {
    border-color: var(--accent-color);
    background: rgba(62, 106, 225, 0.1);
}
