/* ============================================
   DOMINO MOSAIC CREATOR - PREMIUM WEB SERVICE
   Professional Grade UI/UX Design
   ============================================ */

@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard/dist/web/static/pretendard.css');

/* ============================================
   CSS CUSTOM PROPERTIES
   ============================================ */

:root {
    /* Brand Colors */
    --primary: #0066FF;
    --primary-light: #3385FF;
    --primary-dark: #0052CC;
    --primary-glow: rgba(0, 102, 255, 0.4);

    --accent: #FFD000;
    --accent-light: #FFE033;
    --accent-dark: #E6BB00;
    --accent-glow: rgba(255, 208, 0, 0.4);

    /* Semantic Colors */
    --success: #00C853;
    --success-light: rgba(0, 200, 83, 0.15);
    --warning: #FF9100;
    --warning-light: rgba(255, 145, 0, 0.15);
    --error: #FF3D57;
    --error-light: rgba(255, 61, 87, 0.15);
    --info: #00B8D4;
    --info-light: rgba(0, 184, 212, 0.15);

    /* Neutrals - Dark Theme */
    --bg-base: #141414;
    --bg-surface: #0F0F12;
    --bg-elevated: #16161A;
    --bg-overlay: #1C1C21;
    --bg-hover: #242429;
    --bg-active: #2C2C33;

    /* Glass Effect */
    --glass-bg: #282828;
    --glass-border: rgba(255, 255, 255, 0.06);
    --glass-highlight: rgba(255, 255, 255, 0.03);

    /* Text Colors */
    --text-primary: #FFFFFF;
    --text-secondary: #A1A1AA;
    --text-muted: #71717A;
    --text-disabled: #52525B;

    /* Borders */
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-default: rgba(255, 255, 255, 0.1);
    --border-strong: rgba(255, 255, 255, 0.15);

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.6);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.7);
    --shadow-glow-primary: 0 0 24px var(--primary-glow);
    --shadow-glow-accent: 0 0 24px var(--accent-glow);

    /* Layout */
    --header-height: 64px;
    --sidebar-width: 306px;
    --toolbar-height: 56px;
    --stats-height: 180px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Transitions */
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-out-back: cubic-bezier(0.34, 1.56, 0.64, 1);
    --duration-fast: 150ms;
    --duration-normal: 250ms;
    --duration-slow: 400ms;

    /* Typography */
    --font-main: 'Pretendard Variable', 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

/* ============================================
   RESET & BASE
   ============================================ */

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: var(--font-main);
    background: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.5;
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
}

/* Selection */
::selection {
    background: var(--primary);
    color: white;
}

/* Focus Visible */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ============================================
   LAYOUT STRUCTURE
   ============================================ */

.app-container {
    display: grid;
    grid-template-rows: var(--header-height) 1fr;
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-areas:
        "header header"
        "sidebar main";
    height: 100vh;
    height: 100dvh;
    background:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(0, 102, 255, 0.08), transparent),
        radial-gradient(ellipse 60% 40% at 100% 100%, rgba(255, 208, 0, 0.05), transparent),
        var(--bg-base);
}

/* ============================================
   HEADER
   ============================================ */

.header {
    grid-area: header;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--glass-border);
    z-index: 300;
    /* [CHANGED] Ensure Header is above Mobile Sidebar (200) & Overlay (199) */
    position: relative;
}

.header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--primary-glow), transparent);
    opacity: 0.5;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-primary);
    transition: transform var(--duration-fast) var(--ease-out-expo);
}

.logo:hover {
    transform: scale(1.02);
}

.logo img {
    height: 44px;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
    opacity: 0;
    transform: translateX(-40px);
    animation: logoRollIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.logo img.rolling {
    animation: logoRollIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards,
        logoRotate 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes logoRollIn {
    0% {
        opacity: 0;
        transform: translateX(-40px);
    }

    30% {
        opacity: 1;
    }

    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes logoRotate {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.logo-text {
    font-size: 21.6px;
    font-weight: 600;
    letter-spacing: -0.5px;
    color: #FFFFFF;
    opacity: 0;
    transform: translateX(10px) scaleX(1.2);
    transform-origin: left;
    animation: logoTextSlide 0.5s ease-out 0.5s forwards;
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.logo-brand {
    font-size: 1.15em; /* 15% larger */
    display: inline-block;
    transform: scaleY(1.1); /* 10% taller */
    transform-origin: bottom;
}

.logo-solution {
    font-size: 0.66em;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: -0.05em; /* 15% narrower (tighter) */
}

@keyframes logoTextSlide {
    0% {
        opacity: 0;
        transform: translateX(10px) scaleX(1.2);
    }

    100% {
        opacity: 1;
        transform: translateX(0) scaleX(1.2);
    }
}

.logo-divider {
    width: 1px;
    height: 28px;
    background: linear-gradient(180deg, transparent, var(--border-default), transparent);
}

.page-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.page-title::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(0.8);
    }
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
    overflow: visible;
}

.user-info {
    display: none;
    align-items: center;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    transition: all var(--duration-fast) var(--ease-out-expo);
    flex-shrink: 1; /* Allow to shrink first */
}

.user-info:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--border-default);
}

.user-name {
    white-space: nowrap;
    font-size: 13px;
}

.user-deposit {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    font-size: 13px;
    transition: all var(--duration-fast) var(--ease-out-expo);
    flex-shrink: 0;
    white-space: nowrap;
    min-width: 170px; /* Increased to support 1,000,000C */
    width: max-content;
    justify-content: center;
    overflow: visible;
    letter-spacing: -0.2px;
}

.user-deposit:hover {
    background: var(--bg-hover);
    border-color: var(--border-default);
}

.user-deposit i {
    color: var(--accent);
    font-size: 13px;
}

.user-deposit-amount {
    font-weight: 700;
    color: var(--accent);
    display: inline !important;
    white-space: nowrap !important;
}

#displayDeposit {
    display: inline !important;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.3px;
}

.currency-unit {
    color: #FFFFFF;
    margin-left: 4px;
    font-weight: 600;
    display: inline !important;
}

.btn-charge {
    padding: 10px 18px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    color: #000;
    border: none;
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out-expo);
    text-decoration: none;
    box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
}

.btn-charge:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md), var(--shadow-glow-accent);
}

.btn-charge:active {
    transform: translateY(0);
}

.btn-auth {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out-expo);
    box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    flex-shrink: 0;
}

.btn-auth:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md), var(--shadow-glow-primary);
}

.btn-auth:active {
    transform: translateY(0);
}

.btn-auth.logged-in {
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    box-shadow: none;
    flex-shrink: 0;
    padding: 8px 12px;
}

.btn-auth.logged-in:hover {
    background: var(--bg-hover);
    box-shadow: var(--shadow-sm);
}

/* Cloud Save Buttons */
.cloud-save-btns {
    display: none;
    /* [CHANGED] Hidden by default, shown via JS after generation */
    align-items: center;
    gap: 8px;
}

.btn-cloud {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-cloud:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-hover);
    transform: translateY(-1px);
}

.btn-cloud:active {
    transform: translateY(0);
}

.btn-cloud i {
    font-size: 14px;
}

#btnCloudSave:hover {
    color: var(--success);
    border-color: var(--success);
}

#btnCloudLoad:hover {
    color: var(--primary);
    border-color: var(--primary);
}

.mobile-menu-btn {
    display: none;
    width: 44px;
    height: 44px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 18px;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out-expo);
}

.mobile-menu-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-default);
}

/* ============================================
   SIDEBAR
   ============================================ */

.sidebar {
    grid-area: sidebar;
    display: flex;
    flex-direction: column;
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--glass-border);
    overflow: hidden;
    position: relative;
}

.sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100px;
    background: linear-gradient(180deg, var(--glass-highlight), transparent);
    pointer-events: none;
}

.sidebar-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 16px 24px 16px;
    scrollbar-width: thin;
    scrollbar-color: #C0C0C0 transparent;
    scroll-behavior: smooth;
}

.sidebar-scroll::-webkit-scrollbar {
    width: 6px;
}

.sidebar-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-scroll::-webkit-scrollbar-thumb {
    background: rgba(192, 192, 192, 0.3);
    border-radius: 10px;
    transition: background 0.2s;
}

.sidebar-scroll:hover::-webkit-scrollbar-thumb {
    background: rgba(192, 192, 192, 0.6);
}

.sidebar-scroll::-webkit-scrollbar-thumb:hover {
    background: #E0E0E0;
}

/* Quick Jump Menu */
.sidebar-jump-nav {
    display: none;
    /* Hide top quick-step number strip on main page */
    justify-content: space-between;
    padding: 0 4px 16px 4px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border-subtle);
}

.jump-item {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.jump-item:hover {
    background: var(--primary-glow);
    color: white;
    border-color: var(--primary);
    transform: translateY(-2px);
}

.jump-item.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}

/* Sidebar Floating Controls */
.sidebar-floating-actions {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.sidebar:hover .sidebar-floating-actions {
    opacity: 1;
    pointer-events: auto;
}

.scroll-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-overlay);
    border: 1px solid var(--border-default);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: all 0.2s;
}

.scroll-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    transform: scale(1.1);
}

.sidebar-section {
    margin-bottom: 10px;
    animation: fadeInUp 0.4s var(--ease-out-expo) backwards;
}

.sidebar-section:nth-child(1) {
    animation-delay: 0.05s;
}

.sidebar-section:nth-child(2) {
    animation-delay: 0.1s;
}

.sidebar-section:nth-child(3) {
    animation-delay: 0.15s;
}

.sidebar-section:nth-child(4) {
    animation-delay: 0.2s;
}

.sidebar-section:nth-child(5) {
    animation-delay: 0.25s;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--accent);
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border-subtle);
    position: relative;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 40px;
    height: 2px;
    background: var(--primary);
    border-radius: 1px;
}

.section-title.accent::after {
    background: var(--accent);
}

.section-title i {
    font-size: 13px;
    color: var(--primary);
    opacity: 0.8;
}

.section-title.accent i {
    color: var(--accent);
}

/* Color Preset Toggle */
.color-preset-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text-secondary);
    transition: color var(--duration-fast) ease;
}

.color-preset-toggle:hover {
    color: var(--text-primary);
}

.color-preset-toggle input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--accent);
    cursor: pointer;
}

.color-preset-toggle .toggle-label {
    white-space: nowrap;
}

/* Color palette disabled state when preset mode is off */
.color-palette.preset-disabled .color-item {
    cursor: default;
}

.color-palette.preset-disabled .color-item:hover {
    transform: none;
}

/* Color palette enabled for selection */
.color-palette.preset-enabled .color-item {
    cursor: pointer;
}

.color-palette.preset-enabled .color-item:hover {
    transform: scale(1.12) translateY(-2px);
    z-index: 1;
}

/* Form Elements */
.form-row {
    display: flex;
    gap: 10px;
    margin-bottom: 8px;
}

.form-row.compact {
    gap: 4px;
    /* Reduced gap */
    margin-bottom: 6px;
    align-items: center;
    flex-wrap: nowrap;
    /* [FIX] Never wrap */
}

.form-row.compact .form-input {
    padding: 8px 4px;
    /* Minimal padding */
    padding-right: 22px;
    /* Just enough for unit */
    font-size: 13px;
    width: 60px;
    /* Fixed width */
    min-width: 50px;
    /* Minimum width */
    flex: 0 1 auto;
    /* Allow shrinking if absolutely needed, but prefer width */

    /* [FIX] Hide Spin Buttons */
    -moz-appearance: textfield;
    appearance: textfield;
    /* Standard property */
}

.form-row.compact .form-input::-webkit-outer-spin-button,
.form-row.compact .form-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.form-row.compact .input-unit {
    right: 4px;
    /* Moved closer to edge */
    font-size: 10px;
}

.form-group {
    flex: 1;
    position: relative;
    display: flex;
    /* [FIX] Horizontal layout */
    align-items: center;
    /* [FIX] Vertical align */
}

.input-unit {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    color: var(--text-muted);
    pointer-events: none;
}

.form-separator {
    color: var(--text-muted);
    font-size: 14px;
    flex-shrink: 0;
}

.ratio-toggle {
    min-width: auto;
    /* Allow shrinking */
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 0 2px;
    /* Minimal padding */
    background: var(--bg-surface);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-muted);
    transition: all var(--duration-fast);
    flex-shrink: 0;
}

.ratio-toggle:hover {
    background: var(--bg-elevated);
}

.ratio-toggle input {
    display: none;
}

.ratio-toggle input:checked+.ratio-label {
    color: var(--accent);
}

.ratio-toggle input:checked~i {
    color: var(--accent);
}

.ratio-label {
    font-size: 10px;
    /* Reduced from 11px */
    font-weight: 600;
    white-space: nowrap;
}

.floor-limit-notice {
    display: none;
    margin: 2px 0 8px;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 145, 0, 0.45);
    background: var(--warning-light);
    color: #ffcc80;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.35;
}

.floor-limit-notice.show {
    display: block;
}

.floor-limit-notice.popup-active {
    display: block;
    border-color: rgba(255, 145, 0, 0.75);
    background: rgba(255, 145, 0, 0.22);
    box-shadow: 0 6px 16px rgba(255, 145, 0, 0.25);
    animation: floorLimitPopupIn 180ms var(--ease-out-back);
}

@keyframes floorLimitPopupIn {
    from {
        opacity: 0;
        transform: translateY(-4px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.floor-limit-floating-popup {
    position: fixed;
    top: calc(var(--header-height) + 10px);
    left: 50%;
    transform: translate(-50%, -20px) scale(0.95);
    width: min(96vw, 640px);
    padding: 14px 18px 14px 52px;
    border-radius: 14px;
    border: 1px solid rgba(255, 208, 0, 0.85);
    background:
        linear-gradient(135deg, rgba(255, 208, 0, 0.2) 0%, rgba(255, 145, 0, 0.22) 50%, rgba(255, 61, 87, 0.18) 100%),
        rgba(10, 12, 18, 0.94);
    color: #fff8db;
    font-size: 14px;
    font-weight: 800;
    line-height: 1.45;
    letter-spacing: -0.15px;
    text-align: left;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
    box-shadow:
        0 14px 36px rgba(0, 0, 0, 0.55),
        0 0 0 1px rgba(255, 208, 0, 0.35),
        0 0 24px rgba(255, 145, 0, 0.45);
    opacity: 0;
    pointer-events: none;
    z-index: 12050;
    overflow: hidden;
    backdrop-filter: blur(8px) saturate(160%);
    -webkit-backdrop-filter: blur(8px) saturate(160%);
    transition: opacity 160ms ease, transform 220ms var(--ease-out-back), box-shadow 220ms ease;
}

.floor-limit-floating-popup::before {
    content: '!';
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #ffe75f 0%, #ffae00 100%);
    color: #231500;
    font-size: 16px;
    font-weight: 900;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.2), 0 0 16px rgba(255, 170, 0, 0.6);
}

.floor-limit-floating-popup::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(120deg, transparent 0%, rgba(255, 255, 255, 0.2) 35%, transparent 70%);
    opacity: 0;
}

.floor-limit-floating-popup.show {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
    animation: floorLimitPopupDrop 260ms var(--ease-out-back), floorLimitPopupGlow 1400ms ease-in-out infinite 260ms;
}

.floor-limit-floating-popup.show::after {
    animation: floorLimitPopupShine 1100ms ease-out;
}

@keyframes floorLimitPopupDrop {
    from {
        opacity: 0;
        transform: translate(-50%, -20px) scale(0.93);
    }

    to {
        opacity: 1;
        transform: translate(-50%, 0) scale(1);
    }
}

@keyframes floorLimitPopupGlow {

    0%,
    100% {
        box-shadow:
            0 14px 36px rgba(0, 0, 0, 0.55),
            0 0 0 1px rgba(255, 208, 0, 0.35),
            0 0 24px rgba(255, 145, 0, 0.45);
    }

    50% {
        box-shadow:
            0 18px 40px rgba(0, 0, 0, 0.62),
            0 0 0 1px rgba(255, 227, 128, 0.7),
            0 0 34px rgba(255, 170, 0, 0.72);
    }
}

@keyframes floorLimitPopupShine {
    0% {
        opacity: 0;
        transform: translateX(-30%);
    }

    25% {
        opacity: 0.8;
    }

    100% {
        opacity: 0;
        transform: translateX(28%);
    }
}

@media (max-width: 768px) {
    .floor-limit-floating-popup {
        top: calc(var(--header-height) + 6px);
        width: min(96vw, 96vw);
        padding: 10px 12px 10px 42px;
        font-size: 12px;
        line-height: 1.38;
    }

    .floor-limit-floating-popup::before {
        left: 12px;
        width: 20px;
        height: 20px;
        font-size: 13px;
    }
}

.form-select.compact {
    margin-bottom: 6px;
    padding: 8px 10px;
    font-size: 13px;
}

.custom-gap-row {
    margin-top: 0;
    padding-top: 6px;
    border-top: 1px solid var(--border-subtle);
}

/* Grid Summary */
.grid-summary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    font-size: 10px;
    /* Reduced from 12px */
    color: var(--text-secondary);
}

.grid-summary strong {
    color: var(--accent);
    font-weight: 800;
    font-size: 13.5px;
    /* Reduced from 16px */
}

.grid-divider,
.grid-equals {
    color: var(--text-muted);
    font-weight: 500;
}

.grid-total strong {
    font-size: 15px;
    /* Reduced from 18px */
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 800;
    color: var(--accent);
    margin-bottom: 6px;
    margin-top: 12px;
}

.step-num-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background-color: var(--accent);
    color: #000;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 900;
    margin-right: 8px;
    vertical-align: middle;
    line-height: 1;
    flex-shrink: 0;
}

.form-input {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    font-variant-numeric: tabular-nums;
    transition: all var(--duration-fast) var(--ease-out-expo);
}

.form-input:hover {
    border-color: var(--border-default);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow), var(--shadow-sm);
    background: var(--bg-elevated);
}

.form-input::placeholder {
    color: var(--text-disabled);
}

.form-select {
    width: 100%;
    padding: 12px 14px;
    padding-right: 40px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out-expo);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23A1A1AA' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.form-select:hover {
    border-color: var(--border-default);
}

.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.form-checkbox {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
    border-radius: 4px;
}

.form-checkbox-label {
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

/* Info Box */
.info-box {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    background: linear-gradient(135deg, rgba(0, 102, 255, 0.08) 0%, rgba(0, 102, 255, 0.04) 100%);
    border: 1px solid rgba(0, 102, 255, 0.15);
    border-radius: var(--radius-md);
    margin-top: 14px;
}

.info-box i {
    color: var(--primary);
    font-size: 14px;
    margin-top: 1px;
    flex-shrink: 0;
}

.info-box-content {
    flex: 1;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Upload Button */
.upload-area {
    margin-bottom: 8px;
}

.upload-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    border: none;
    border-radius: var(--radius-md);
    color: #000;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-out-expo);
    box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.25);
    position: relative;
    overflow: hidden;
}

.upload-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s ease;
}

.upload-btn:hover::before {
    left: 100%;
}

.upload-btn:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg), var(--shadow-glow-accent);
}

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

.upload-btn i {
    font-size: 18px;
}

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

/* ?대?吏 誘몃━蹂닿린 */
#imagePreviewBox {
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    text-align: center;
    background: var(--bg-surface);
}

#imagePreviewImg {
    display: inline-block;
    max-width: 100%;
    height: auto;
    object-fit: contain;
}

/* Collapsible Section */
.collapsible-section {
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    overflow: hidden;
}

.collapsible-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    background: var(--bg-elevated);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all var(--duration-fast) ease;
}

.collapsible-header:hover {
    background: var(--bg-overlay);
    color: var(--text-primary);
}

.collapsible-header i:first-child {
    margin-right: 8px;
}

.collapsible-icon {
    font-size: 11px;
    transition: transform var(--duration-fast) ease;
}

.collapsible-section.open .collapsible-icon {
    transform: rotate(180deg);
}

.collapsible-content {
    padding: 8px;
    background: var(--bg-surface);
}

/* Range Slider */
.slider-group {
    margin-bottom: 10px;
}

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

.slider-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.slider-value {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    background: var(--bg-surface);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-variant-numeric: tabular-nums;
    min-width: 48px;
    text-align: center;
}

input[type="range"] {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: var(--radius-full);
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
    position: relative;
}

input[type="range"]::-webkit-slider-track {
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary) var(--value, 50%), rgba(255, 255, 255, 0.25) var(--value, 50%));
    border-radius: var(--radius-full);
    height: 6px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out-expo);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4), var(--shadow-glow-primary);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* Color Palette */
.color-palette {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.color-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out-back);
    border: 2px solid transparent;
    padding: 2px;
    gap: 2px;
}

.color-swatch {
    position: relative;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    transition: filter var(--duration-fast);
    flex-shrink: 0;
}

.color-item span {
    font-size: 8px;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1;
    word-break: keep-all;
}

.color-item:hover {
    transform: scale(1.12) translateY(-2px);
    z-index: 1;
}

.color-item.active {
    border-color: var(--text-primary);
    box-shadow: 0 0 0 3px var(--bg-surface), 0 4px 12px rgba(255, 255, 255, 0.2);
}

.color-item.active .color-swatch::after {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 13px;
    color: white;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.color-item.disabled {
    cursor: not-allowed;
}

.color-item.disabled .color-swatch {
    opacity: 0.3;
    filter: grayscale(1);
}

.color-item.disabled span {
    color: var(--text-secondary);
    opacity: 0.8;
}

.color-item.disabled:hover {
    transform: none;
}

/* 釉뚮윭??紐⑤뱶?먯꽌 ?좏깮???됱긽 ?쒖떆 */
.color-item.selected-paint {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent), 0 4px 16px var(--accent-glow);
    transform: scale(1.1);
}

.color-item.selected-paint .color-swatch::after {
    content: '\f1fc';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 14px;
    color: white;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

/* Background Color Selection */
.bg-color-palette {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.bg-color-item {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    cursor: pointer;
    border: 2px solid transparent;
    transition: all var(--duration-fast) var(--ease-out-back);
    box-shadow: var(--shadow-xs);
}

.bg-color-item:hover {
    transform: scale(1.1);
}

.bg-color-item.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--bg-surface), var(--shadow-glow-primary);
}

/* Generate Button */
.generate-btn {
    width: 100%;
    height: 54px;
    padding: 0 16px;
    background: linear-gradient(135deg, var(--accent) 0%, #F5C800 50%, var(--accent-dark) 100%);
    background-size: 200% 100%;
    border: none;
    border-radius: var(--radius-lg);
    color: #000;
    font-size: 15px;
    font-weight: 800;
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-out-expo);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 12px;
    box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.3);
    position: relative;
    position: relative;
    overflow: hidden;
}

.generate-btn .btn-text {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 15.8px;
    /* Further reduced by 5% from 16.6px */
    font-weight: 700;
    letter-spacing: -0.5px;
    text-align: center;
    white-space: nowrap;
}

/* Step Number 8 for Generate Button */
.generate-btn .btn-text::before {
    content: '8';
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background-color: #000;
    color: #FFD400;
    border-radius: 50%;
    margin-right: 6px;
    font-weight: 900;
    font-size: 13px;
    vertical-align: middle;
    line-height: 1;
}

.btn-label-multiline {
    font-size: 15px;
    /* Increased by ~15% */
    line-height: 1.2;
    display: block;
    font-weight: 700;
    font-weight: 700;
    word-break: keep-all;
    text-align: center;
}

/* Aggressive badge hiding for all states */
.generate-btn .credit-badge,
.generate-btn span:nth-child(n+2),
.generate-btn i:nth-child(n+2),
.generate-btn [class*="badge"],
.generate-btn [id*="badge"],
.generate-btn [id*="credit"],
.generate-btn [class*="credit"] {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    width: 0 !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    position: absolute !important;
}

.generate-btn .credit-badge i {
    display: none !important;
}

@keyframes shimmer {

    0%,
    100% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }
}

@keyframes pulseHighlight {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 208, 0, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(255, 208, 0, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(255, 208, 0, 0);
    }
}

.generate-btn::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(135deg, var(--accent), transparent, var(--accent));
    border-radius: calc(var(--radius-lg) + 2px);
    z-index: -1;
    opacity: 0;
    transition: opacity var(--duration-normal);
}

.generate-btn:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-xl), var(--shadow-glow-accent);
    animation: none;
    /* Disable pulse on hover to avoid conflict */
}

.generate-btn:hover::before {
    opacity: 1;
}

.generate-btn:active {
    transform: translateY(-1px);
}

.generate-btn i {
    font-size: 20px;
}

.legal-policy-btn {
    width: 100%;
    margin-top: 10px;
    height: 42px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out-expo);
}

.legal-policy-btn:hover {
    border-color: var(--accent);
    color: var(--text-primary);
    background: var(--bg-hover);
    transform: translateY(-1px);
}

.legal-policy-btn i {
    color: var(--accent);
}

/* Project Buttons */
.project-btns {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.project-btn {
    flex: 1;
    padding: 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    cursor: not-allowed;
    transition: all var(--duration-fast) var(--ease-out-expo);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.project-btn:disabled {
    opacity: 0.5;
}

.project-btn span {
    font-size: 10px;
    color: var(--text-disabled);
}

/* ============================================
   MAIN CONTENT AREA
   ============================================ */

.main-content {
    grid-area: main;
    display: flex;
    flex-direction: column;
    background: var(--bg-base);
    position: relative;
    overflow: hidden;
}

/* Toolbar */
.toolbar {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    z-index: 10;
    pointer-events: none;
}

.toolbar>* {
    pointer-events: auto;
}

.tool-group {
    display: flex;
    gap: 6px;
    padding: 8px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-radius: var(--radius-lg);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-lg);
}

.tool-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out-expo);
    position: relative;
}

.tool-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.modal-3d-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    /* Reduced gap */
    flex-wrap: nowrap;
    /* Prevent wrapping */
}

.header-action-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 10.4px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.header-action-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.header-action-btn.active {
    background: rgba(0, 102, 255, 0.15);
    color: var(--primary-light);
    border-color: var(--primary);
}

.header-action-btn i {
    font-size: 11.2px;
}

.header-action-btn.active i {
    animation: spin 3s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.modal-3d .close-btn {
    background: none;
}

.tool-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-glow-primary);
}

.tool-btn[title]::after {
    content: attr(title);
    position: absolute;
    bottom: -32px;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 10px;
    background: var(--bg-overlay);
    border-radius: var(--radius-sm);
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--duration-fast);
}

.tool-btn:hover[title]::after {
    opacity: 1;
}

.tool-divider {
    width: 1px;
    background: var(--border-subtle);
    margin: 6px 4px;
}

#btnToolBrush {
    width: auto !important;
    min-width: fit-content;
    padding: 0 12px;
    gap: 8px;
    flex-direction: row;
    align-items: center;
    color: #000000;
    border: 1px solid var(--accent);
    background: var(--accent);
    box-shadow: 0 0 12px rgba(255, 208, 0, 0.3);
    animation: pulseBrush 2s infinite;
}

#btnToolBrush span {
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

#btnToolBrush:hover,
#btnToolBrush.active {
    background: var(--accent);
    color: #1a1a1a;
    border-color: var(--accent);
    box-shadow: 0 0 20px var(--accent-glow);
    animation: none;
}

@keyframes pulseBrush {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 208, 0, 0.4);
    }

    70% {
        box-shadow: 0 0 0 6px rgba(255, 208, 0, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(255, 208, 0, 0);
    }
}

.zoom-level {
    display: flex;
    align-items: center;
    padding: 0 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 64px;
    justify-content: center;
    font-variant-numeric: tabular-nums;
}

.view-toggle {
    display: flex;
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    padding: 4px;
}

.view-btn {
    padding: 10px 18px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out-expo);
}

.view-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

.view-btn:hover:not(.active) {
    color: var(--text-primary);
    background: var(--bg-hover);
}

/* Canvas Area */
.canvas-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
    cursor: grab;
    background:
        radial-gradient(circle at 30% 20%, rgba(0, 102, 255, 0.06) 0%, transparent 50%),
        radial-gradient(circle at 70% 80%, rgba(255, 208, 0, 0.04) 0%, transparent 50%),
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 100% 100%, 100% 100%, 40px 40px, 40px 40px;
    background-position: 0 0, 0 0, -1px -1px, -1px -1px;
}

.canvas-wrapper:active {
    cursor: grabbing;
}

.canvas-container {
    position: absolute;
    inset: 0;
    background: transparent;
    overflow: hidden;
}

#dominoCanvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* Empty State */
.empty-state {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 32px;
    color: var(--text-muted);
    text-align: center;
    padding: 48px 24px;
    background: radial-gradient(circle at center, rgba(30, 30, 45, 0.4) 0%, var(--bg-surface) 100%);
    z-index: 10;
    animation: emptyStateFadeIn 0.8s var(--ease-out-expo);
    border: none;
    transition: all 0.4s ease;
}

.empty-state::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60vmin;
    height: 60vmin;
    background-image: url('logo.png');
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    opacity: 0.05;
    pointer-events: none;
    z-index: -1;
}

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

.empty-state.drag-over {
    background: radial-gradient(circle at center, rgba(0, 102, 255, 0.08) 0%, var(--bg-surface) 100%);
    backdrop-filter: blur(4px);
}

.empty-state.drag-over .empty-state-icon {
    transform: scale(1.1) translateY(-10px);
    box-shadow: 0 20px 40px rgba(0, 102, 255, 0.3);
}

.empty-state.hidden {
    display: none;
}

/* Icon Container */
.empty-state-icon {
    display: none !important;
    position: relative;
    width: 120px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-elevated) 0%, var(--bg-surface) 100%);
    border-radius: 32px;
    margin-bottom: 8px;
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid var(--border-subtle);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.empty-state-icon > i {
    font-size: 52px;
    background: linear-gradient(135deg, var(--text-muted) 0%, var(--text-disabled) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    opacity: 0.8;
}

.empty-state-icon-overlay {
    position: absolute;
    bottom: -10px;
    right: -10px;
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 16px var(--accent-glow);
    border: 2px solid var(--bg-surface);
}

.empty-state-icon-overlay i {
    font-size: 20px;
    color: #000;
    animation: sparkle 2.5s ease-in-out infinite;
}

/* Text Content Wrapper */
.empty-state-text-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 500px;
}

/* Title */
.empty-state-title {
    font-size: 37px;
    font-weight: 800;
    line-height: 1.25;
    letter-spacing: -0.5px;
    background: linear-gradient(180deg, #FFFFFF 0%, rgba(255, 255, 255, 0.7) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
    word-break: keep-all;
}

@media (max-width: 768px) {
    .empty-state-title {
        font-size: 26px;
    }
}

/* Description */
.empty-state-desc {
    font-size: 19px;
    line-height: 1.6;
    color: var(--text-secondary);
    margin: 0;
    font-weight: 500;
    opacity: 0.9;
    word-break: keep-all;
}

.highlight-yellow {
    color: #FFD700;
    font-weight: 800;
}

/* Button */
.empty-state-btn {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 16px 36px;
    background: rgba(255, 255, 255, 0.03);
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: all 0.3s var(--ease-out-expo);
    margin-top: 12px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.empty-state-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transform: translateX(-100%);
    transition: transform 0.6s ease;
}

.empty-state-btn:hover::after {
    transform: translateX(100%);
}

.empty-state-btn:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 15px 35px var(--accent-glow);
}

.empty-state-btn:active {
    transform: translateY(-1px) scale(0.98);
}

.empty-state-btn i {
    font-size: 20px;
}

/* Hint Text */
.empty-state-hint {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: -8px;
    font-weight: 500;
}

/* Supported Formats */
.empty-state-formats {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}

.empty-state-formats span {
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.2s;
}

.empty-state-formats span:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    border-color: var(--border-default);
}

/* ============================================
   STATS PANEL
   ============================================ */

.stats-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 1px solid var(--glass-border);
    padding: 18px 24px;
    position: relative;
}

.stats-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-glow), transparent);
    opacity: 0.5;
}

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

.stats-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stats-title i {
    color: var(--primary);
}

.stats-total {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
}

.stats-total strong {
    color: var(--accent);
    font-weight: 700;
    font-size: 18px;
    margin: 0 4px;
}

.stats-content {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.stats-grid {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    font-size: 13px;
    white-space: nowrap;
    transition: all var(--duration-fast) var(--ease-out-expo);
}

.stat-item:hover {
    background: var(--bg-elevated);
    border-color: var(--border-default);
    transform: translateY(-1px);
}

.stat-dot {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    box-shadow: var(--shadow-xs);
}

.stat-name {
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-count {
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.stats-actions {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    background: var(--accent);
    /* Make it stand out with Accent Color */
    border: 1px solid var(--accent);
    border-radius: var(--radius-md);
    color: black;
    font-family: 'Pretendard', 'Malgun Gothic', Dotum, sans-serif;
    /* Gothic Font */
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out-expo);
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
}

.action-btn:hover {
    background: var(--primary);
    /* Darker blue on hover */
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md), 0 0 12px rgba(0, 78, 162, 0.4);
}

.action-btn.primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-color: transparent;
    color: white;
}

.action-btn.primary:hover {
    box-shadow: var(--shadow-md), var(--shadow-glow-primary);
}

.action-btn i {
    font-size: 17px;
}

/* ============================================
   BRUSH PALETTE
   ============================================ */

.brush-palette {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 12px;
    padding: 12px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    display: none;
    z-index: 100;
    animation: slideDown 0.2s var(--ease-out-expo);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.brush-palette.show {
    display: grid;
    grid-template-columns: repeat(7, 32px);
    gap: 6px;
}

.brush-swatch {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 2px solid transparent;
    transition: all var(--duration-fast) var(--ease-out-back);
    box-shadow: var(--shadow-xs);
}

.brush-swatch:hover {
    transform: scale(1.15);
    z-index: 1;
}

.brush-swatch.active {
    border-color: white;
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.5);
}

/* ============================================
   MODALS
   ============================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(12px) saturate(150%);
    -webkit-backdrop-filter: blur(12px) saturate(150%);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: var(--bg-surface);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-xl);
    max-width: 420px;
    width: 100%;
    overflow: hidden;
    animation: modalSlideIn 0.3s var(--ease-out-expo);
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(16px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-elevated);
}

.modal-title {
    font-size: 17px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-title i {
    color: var(--primary);
    font-size: 18px;
}

.modal-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out-expo);
}

.modal-close:hover {
    background: var(--error-light);
    color: var(--error);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 20px 24px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    background: var(--bg-elevated);
}

.policy-modal {
    max-width: 760px;
    max-height: min(88vh, 900px);
    display: flex;
    flex-direction: column;
}

.policy-body {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.policy-section {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 14px 16px;
}

.policy-section h4 {
    margin: 0 0 10px 0;
    font-size: 15px;
    font-weight: 800;
    color: var(--accent);
}

.policy-section ul {
    margin: 0;
    padding-left: 18px;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.7;
}

.policy-note {
    margin: 4px 2px 0;
    font-size: 12px;
    color: var(--text-muted);
}

.policy-confirm-btn {
    width: auto;
    min-width: 120px;
    margin-top: 0;
    padding: 12px 22px;
}

@media (max-width: 768px) {
    .policy-modal {
        max-height: 92vh;
    }

    .policy-section ul {
        font-size: 12px;
    }
}

/* 3D Modal - Full Screen */
.modal-3d {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 2000;
    display: none;
    flex-direction: column;
}

.modal-3d.show {
    display: flex;
}

/* Mobile-only close button in h3: hidden on desktop */
.mobile-only-close {
    display: none;
}

.modal-3d-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 28px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
}

.modal-3d-header h3 {
    font-size: 17px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-3d-header h3 i {
    color: var(--primary);
}

.modal-3d-header .close-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out-expo);
}

.modal-3d-header .close-btn:hover {
    background: var(--error);
    border-color: var(--error);
    color: white;
}

.viewer-3d-container {
    flex: 1;
    background: radial-gradient(ellipse at center, #12121a 0%, #000 100%);
    position: relative;
}

.viewer-3d-container canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.modal-3d-controls {
    padding: 14px 28px;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    justify-content: center;
    gap: 32px;
}

.control-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-muted);
}

.control-pill i {
    color: var(--primary);
    font-size: 15px;
}

/* ============================================
   FULLSCREEN BRUSH MODE
   ============================================ */

.modal-brush {
    position: fixed;
    inset: 0;
    background: var(--bg-base);
    z-index: 2000; /* Increased to ensure it's above other modals */
    display: none;
    flex-direction: column;
}

.modal-brush.active {
    display: flex;
}

/* Header */
.modal-brush-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border-subtle);
    min-height: 56px;
}

.brush-header-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.brush-mode-text {
    margin-right: 4px;
}

.brush-current-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--bg-overlay);
    border-radius: var(--radius-full);
    border: 1px solid var(--border-subtle);
}

.brush-color-preview {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.brush-current-indicator.eraser-mode {
    background: var(--error-light);
    border-color: var(--error);
}

.brush-current-indicator.eraser-mode .brush-color-preview {
    background: repeating-linear-gradient(45deg,
            var(--error) 0px,
            var(--error) 2px,
            transparent 2px,
            transparent 4px) !important;
}

.brush-header-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.brush-header-btn.back {
    background: var(--bg-overlay);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}

.brush-header-btn.back:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
}

.brush-header-btn.confirm {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
}

.brush-header-btn.confirm:hover {
    filter: brightness(1.1);
}

/* Canvas Wrapper */
.brush-canvas-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #0a0a0a;
}

.brush-canvas-area {
    width: 100%;
    height: 100%;
    position: relative;
    cursor: crosshair;
    touch-action: none;
    /* 紐⑤컮???ㅽ겕濡?諛⑹? */
    user-select: none;
    -webkit-user-select: none;
}

.brush-canvas-area canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
    cursor: crosshair;
}

/* Bottom Toolbar */
.modal-brush-toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px 16px;
    background: var(--bg-elevated);
    border-top: 1px solid var(--border-subtle);
    flex-wrap: wrap;
}

.brush-tool-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.brush-tool-btn {
    min-width: 38px;
    width: auto;
    padding: 0 12px;
    height: 38px;
    border-radius: 8px;
    background: var(--bg-overlay);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 15px;
    transition: all 0.15s;
}

.brush-tool-text {
    font-size: 13px;
    font-weight: 500;
}

.brush-tool-btn:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
}

.brush-tool-btn.active {
    background: #0066FF;
    color: white;
    border-color: #0066FF;
}

.brush-tool-btn.eraser.active {
    background: #ef4444;
    border-color: #ef4444;
}

.brush-zoom-level {
    font-size: 13px;
    color: var(--text-muted);
    min-width: 45px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.brush-divider {
    width: 1px;
    height: 24px;
    background: var(--border-subtle);
    margin: 0 4px;
}

/* Color Palette Bar */
.brush-palette-bar {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 480px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.sidebar-guide-text {
    font-size: 12.1px;
    color: #ffffff;
    opacity: 0.9;
    margin-bottom: 15px;
    padding-left: 4px;
    font-weight: 500;
}

.brush-palette-bar::-webkit-scrollbar {
    display: none;
}

.brush-color-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3);
}

.brush-color-btn:hover {
    transform: scale(1.15);
    z-index: 1;
}

.brush-color-btn.active {
    border-color: white;
    box-shadow: 0 0 0 3px var(--accent), 0 4px 15px rgba(0, 0, 0, 0.6);
    transform: scale(1.3);
    z-index: 5;
}

.brush-color-btn.active::after {
    content: '';
    position: absolute;
    inset: -6px;
    border: 2px solid white;
    border-radius: 50%;
    animation: pulse-border 1.2s ease-in-out infinite;
}

@keyframes pulse-border {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* [NEW] ?곌껐/????곕윭?⑤━湲?踰꾪듉 媛뺤“ ?ㅽ???- 洹뱁븳???꾨━誘몄뾼 */
#btnFreePlacement,
#btnSave3D,
#btnDominoFall {
    background: linear-gradient(135deg, #FFD700 0%, #FFF176 25%, #FFA500 50%, #FFF176 75%, #FFD700 100%) !important;
    background-size: 200% auto !important;
    color: #1a1a1a !important;
    border: none !important;
    font-weight: 800 !important;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 20px rgba(255, 165, 0, 0.5), 0 4px 15px rgba(0, 0, 0, 0.3) !important;
    position: relative;
    padding: 5px 11px !important;
    overflow: visible !important;
    animation: essentialPulse 2s infinite, goldShimmer 3s infinite linear !important;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
}

/* ?꾩닔 諛곗? ?쒓굅 */
#btnFreePlacement::before {
    display: none !important;
}

#btnFreePlacement:hover,
#btnSave3D:hover,
#btnDominoFall:hover {
    transform: translateY(-3px) scale(1.08) !important;
    box-shadow: 0 0 35px rgba(255, 215, 0, 0.8), 0 8px 25px rgba(0, 0, 0, 0.4) !important;
    filter: brightness(1.15);
}

#btnFreePlacement.active,
#btnSave3D.active,
#btnDominoFall.active {
    background: #000000 !important;
    color: #FFD700 !important;
    border: 2px solid #FFD700 !important;
    box-shadow: inset 0 0 20px rgba(255, 215, 0, 0.4), 0 0 15px rgba(255, 215, 0, 0.2) !important;
    animation: none !important;
}

@keyframes essentialPulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}

.conn-color-item.active {
    border-color: #FFD700 !important;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.8), 0 0 0 2px #000;
    transform: scale(1.25);
    z-index: 10;
}

.conn-color-item:hover {
    transform: scale(1.2);
}

.conn-tool-item {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.6);
    transition: all 0.2s;
    font-size: 11px;
}

.conn-tool-item:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    transform: translateY(-1px);
}

.conn-tool-item.active {
    background: #00E5FF;
    color: #000;
    border-color: #00E5FF;
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.4);
}

@keyframes goldShimmer {
    0% {
        background-position: 0% 50%;
    }

    100% {
        background-position: 200% 50%;
    }
}

@keyframes badgeBounce {

    0%,
    100% {
        transform: translateX(-50%) translateY(0);
    }

    50% {
        transform: translateX(-50%) translateY(-5px);
    }
}

/* Toggle Button */
.brush-toggle {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 7px 10px;
    border-radius: 8px;
    background: var(--bg-overlay);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.15s;
    user-select: none;
}

.brush-toggle:has(input:checked) {
    background: #0066FF;
    color: white;
    border-color: #0066FF;
}

.brush-toggle input {
    display: none;
}

.brush-toggle-icon {
    font-size: 14px;
}

/* Hints Bar */
.modal-brush-hints {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding: 6px 16px;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-subtle);
    font-size: 11px;
    color: var(--text-muted);
}

.modal-brush-hints span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.modal-brush-hints kbd {
    background: var(--bg-overlay);
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 10px;
    font-family: inherit;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .modal-brush-header {
        padding: 8px 12px;
        min-height: 48px;
    }

    .brush-header-title {
        gap: 4px;
    }

    .brush-header-title i,
    .brush-mode-text {
        display: none;
    }

    .brush-current-indicator {
        padding: 3px 8px;
    }

    .brush-color-preview {
        width: 24px;
        height: 24px;
    }

    .brush-header-btn span {
        display: none;
    }

    .brush-header-btn {
        padding: 10px 12px;
    }

    .modal-brush-toolbar {
        padding: 8px;
        gap: 6px;
    }

    .brush-tool-btn {
        width: 34px;
        height: 34px;
        font-size: 14px;
    }

    .brush-color-btn {
        width: 28px;
        height: 28px;
    }

    .brush-palette-bar {
        max-width: 100%;
        padding: 0 8px;
    }

    .brush-toggle-text {
        display: none;
    }

    .modal-brush-hints {
        display: none;
    }

    .brush-divider {
        display: none;
    }

    .brush-zoom-level {
        min-width: 40px;
        font-size: 11px;
    }
}



.control-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    background: var(--bg-elevated);
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.control-pill i {
    font-size: 14px;
    color: var(--primary);
}

/* Payment Modal */
#modalAutoPurchase .modal-body {
    text-align: center;
    padding: 32px 24px;
}

.payment-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 36px;
}

.payment-icon.loading {
    background: linear-gradient(135deg, rgba(255, 208, 0, 0.2) 0%, rgba(255, 208, 0, 0.05) 100%);
    color: var(--accent);
    animation: pulse-icon 1.5s ease-in-out infinite;
}

@keyframes pulse-icon {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

.payment-icon.loading i {
    animation: spin 1.2s linear infinite;
}

.payment-icon.success {
    background: var(--success-light);
    color: var(--success);
}

.payment-icon.error {
    background: var(--error-light);
    color: var(--error);
}

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

.payment-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
}

.payment-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.payment-info {
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    padding: 18px;
    margin-bottom: 24px;
    border: 1px solid var(--border-subtle);
}

.payment-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    font-size: 14px;
}

.payment-row:not(:last-child) {
    border-bottom: 1px solid var(--border-subtle);
}

.payment-row .label {
    color: var(--text-secondary);
    font-weight: 500;
}

.payment-row .value {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.payment-row .value.negative {
    color: var(--error);
}

.payment-row .value.positive {
    color: var(--accent);
}

.btn-payment {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out-expo);
}

.btn-payment.primary {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    color: #000;
    box-shadow: var(--shadow-md);
}

.btn-payment.primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), var(--shadow-glow-accent);
}

.btn-payment.secondary {
    background: var(--bg-elevated);
    color: var(--text-primary);
    margin-top: 12px;
    border: 1px solid var(--border-subtle);
}

.btn-payment.secondary:hover {
    background: var(--bg-hover);
    border-color: var(--border-default);
}

/* Login Modal */
.login-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.login-input {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    transition: all var(--duration-fast) var(--ease-out-expo);
}

.login-input:hover {
    border-color: var(--border-default);
}

.login-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: var(--bg-overlay);
}

.login-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
}

.login-btn {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out-expo);
    box-shadow: var(--shadow-md);
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), var(--shadow-glow-primary);
}

.login-links {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-subtle);
}

.login-links a {
    color: var(--text-muted);
    font-size: 13px;
    text-decoration: none;
    transition: color var(--duration-fast);
}

.login-links a:hover {
    color: var(--text-primary);
}

.login-signup {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid var(--border-subtle);
    margin-top: 8px;
}

.login-signup span {
    color: var(--text-muted);
    font-size: 13px;
}

.login-signup a {
    color: var(--accent);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    margin-left: 8px;
    transition: color var(--duration-fast);
}

.login-signup a:hover {
    color: var(--accent-light);
}

/* ============================================
   TOOLTIP
   ============================================ */

.tooltip-btn {
    background: #FF9F0A; /* Orange background */
    color: #000000 !important; /* Black question mark */
    border: none;
    font-size: 11px; /* Adjust icon size inside circle */
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    transition: all 0.2s var(--ease-out-expo);
    margin-left: 6px;
    vertical-align: middle;
    box-shadow: 0 0 10px rgba(255, 159, 10, 0.4);
    flex-shrink: 0; /* Prevent squishing */
}

.tooltip-btn:hover {
    background: #FFB340; /* Lighter orange */
    transform: scale(1.15) rotate(10deg);
    box-shadow: 0 0 15px rgba(255, 159, 10, 0.6);
}

.tooltip-btn i {
    color: #000000 !important; /* Force black icon color */
    opacity: 1 !important;
}

.tooltip-content {
    display: none;
    background: #1e293b; /* Darker blue-grey background */
    border: 1px solid #FF9F0A; /* Orange border */
    border-radius: var(--radius-md);
    padding: 14px;
    margin-top: 10px;
    margin-bottom: 15px;
    font-size: 13px;
    line-height: 1.7;
    color: #e2e8f0; /* Light text color */
    box-shadow: 0 4px 20px rgba(255, 159, 10, 0.2); /* Orange glow */
    animation: fadeInUp 0.2s var(--ease-out-expo);
    word-break: keep-all;
    position: relative;
    z-index: 500;
}

/* Tooltip arrow effect */
.tooltip-content::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 20px;
    width: 10px;
    height: 10px;
    background: #1e293b;
    border-left: 1px solid #FF9F0A;
    border-top: 1px solid #FF9F0A;
    transform: rotate(45deg);
}

.tooltip-content.show {
    display: block;
}

/* ============================================
   TOAST NOTIFICATION
   ============================================ */

.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* [NEW] 3D 酉곗뼱 紐⑤뱶?먯꽌???좎뒪???꾩튂 ?щ같移?(?곷떒 以묒븰) */
body.modal-3d-open .toast-container {
    top: 85px;
    /* ?ㅻ뜑 諛붾줈 ?꾨옒 */
    bottom: auto;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    align-items: center;
}

body.modal-3d-open .toast {
    animation: toastInCentral 0.4s var(--ease-out-expo) !important;
    transform: none !important;
    min-width: 450px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--accent);
    /* 寃쎄퀬??媛뺤“ */
}

@keyframes toastInCentral {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.toast {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    min-width: 320px;
    max-width: 420px;
    animation: toastIn 0.3s var(--ease-out-expo);
}

.toast.toast-out {
    animation: toastOut 0.2s var(--ease-out-expo) forwards;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(24px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastOut {
    to {
        opacity: 0;
        transform: translateX(24px);
    }
}

/* [NEW] 3D 紐⑤뱶???щ씪吏??좊땲硫붿씠??*/
body.modal-3d-open .toast.toast-out {
    animation: toastOutCentral 0.2s var(--ease-out-expo) forwards !important;
}

@keyframes toastOutCentral {
    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

.toast-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.toast.success .toast-icon {
    background: var(--success-light);
    color: var(--success);
}

.toast.error .toast-icon {
    background: var(--error-light);
    color: var(--error);
}

.toast.warning .toast-icon {
    background: var(--warning-light);
    color: var(--warning);
}

.toast.info .toast-icon {
    background: var(--info-light);
    color: var(--info);
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
}

.toast-message {
    font-size: 13px;
    color: var(--text-secondary);
}

.toast-close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--duration-fast);
    flex-shrink: 0;
}

.toast-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* ============================================
   SCROLLBAR
   ============================================ */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--border-default);
    border-radius: var(--radius-full);
    border: 2px solid transparent;
    background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-strong);
    background-clip: content-box;
}

/* ============================================
   LOADING OVERLAY
   ============================================ */

#loadingOverlay {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: opacity 0.3s ease;
}

#loadingOverlay .loading-card {
    background: var(--bg-elevated);
    background: linear-gradient(145deg, var(--bg-overlay) 0%, var(--bg-surface) 100%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    padding: 40px 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
    box-shadow:
        var(--shadow-xl),
        0 0 40px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 var(--glass-highlight);
    max-width: 480px;
    width: 90%;
    position: relative;
    overflow: hidden;
    animation: loadingCardEntry 0.5s var(--ease-out-back);
}

@keyframes loadingCardEntry {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

#loadingOverlay .loading-visual {
    position: relative;
    width: 100px;
    height: 100px;
}

#loadingOverlay .premium-spinner {
    position: relative;
    width: 100%;
    height: 100%;
}

#loadingOverlay .premium-spinner span {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 4px solid transparent;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: premiumSpin 2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

#loadingOverlay .premium-spinner span:nth-child(1) {
    animation-delay: -0.45s;
    opacity: 0.3;
    width: 60%;
    height: 60%;
    top: 20%;
    left: 20%;
}

#loadingOverlay .premium-spinner span:nth-child(2) {
    animation-delay: -0.3s;
    opacity: 0.6;
    width: 80%;
    height: 80%;
    top: 10%;
    left: 10%;
}

#loadingOverlay .premium-spinner span:nth-child(3) {
    animation-delay: -0.15s;
    opacity: 0.8;
}

#loadingOverlay .premium-spinner span:nth-child(4) {
    border-top-color: var(--primary);
}

@keyframes premiumSpin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

#loadingOverlay .spinner-logo {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#loadingOverlay .spinner-logo img {
    width: 24px;
    height: 24px;
    filter: drop-shadow(0 0 8px var(--accent-glow));
    animation: logoPulse 2s ease-in-out infinite;
}

@keyframes logoPulse {

    0%,
    100% {
        transform: scale(1);
        filter: drop-shadow(0 0 8px var(--accent-glow));
    }

    50% {
        transform: scale(1.1);
        filter: drop-shadow(0 0 15px var(--accent-glow));
    }
}

#loadingOverlay .loading-content {
    text-align: center;
}

#loadingOverlay .loading-title {
    font-size: 20px;
    font-weight: 800;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #FFF 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

#loadingOverlay .loading-text {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    max-width: 300px;
    white-space: pre-line;
}

#loadingOverlay .loading-footer {
    width: 100%;
}

#loadingOverlay .loading-bar {
    height: 4px;
    background: var(--bg-active);
    border-radius: var(--radius-full);
    width: 100%;
    overflow: hidden;
}

#loadingOverlay .loading-bar-fill {
    height: 100%;
    width: 40%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: var(--radius-full);
    animation: loadingBarMove 2s infinite ease-in-out;
}

@keyframes loadingBarMove {
    0% {
        transform: translateX(-100%);
        width: 20%;
    }

    50% {
        width: 50%;
    }

    100% {
        transform: translateX(300%);
        width: 20%;
    }
}

/* ============================================
   RESPONSIVE - TABLET
   ============================================ */

@media (max-width: 1024px) {
    :root {
        --sidebar-width: 300px;
    }

    .header {
        padding: 0 20px;
    }

    .stats-content {
        flex-direction: column;
        gap: 14px;
    }

    .stats-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .action-btn {
        flex: 1;
        justify-content: center;
    }
}

/* ============================================
   RESPONSIVE - MOBILE
   ============================================ */

@media (max-width: 768px) {
    :root {
        --header-height: 56px;
    }

    .app-container {
        grid-template-columns: 1fr;
        grid-template-rows: var(--header-height) 1fr;
        grid-template-areas:
            "header"
            "main";
    }

    .header {
        padding: 0 10px;
    }

    .header-right {
        gap: 6px;
    }

    .header-left {
        gap: 8px;
    }

    .logo img {
        height: 28px;
    }

    .logo-text,
    .logo-divider {
        display: none;
    }

    .page-title {
        display: none;
    }

    .btn-charge {
        display: none !important;
    }

    .user-info {
        display: flex !important;
        padding: 4px 8px;
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid var(--border-subtle);
        border-radius: var(--radius-full);
        font-size: 11px;
        margin-right: 4px !important;
    }

    .welcome-msg {
        display: none;
    }

    /* [CHANGED] Show User Deposit on Mobile - Compact */
    .user-deposit {
        display: flex !important;
        padding: 4px 8px;
        gap: 4px;
        font-size: 12px;
        flex-shrink: 1;
        white-space: nowrap;
        min-width: auto; 
        width: auto;
        justify-content: center;
        overflow: hidden;
    }

    .user-deposit>span:not(.user-deposit-amount) {
        display: none;
    }

    .user-deposit i {
        font-size: 12px;
        color: var(--accent);
    }

    .cloud-save-btns {
        gap: 2px;
    }

    .btn-cloud {
        padding: 4px 6px;
        font-size: 12px;
    }

    .btn-cloud span {
        display: none;
    }

    .mobile-menu-btn {
        display: none;
    }

    .btn-auth {
        padding: 6px 10px;
        font-size: 12px;
    }

    .btn-auth span {
        display: none;
    }

    /* Empty State Mobile */
    .empty-state {
        padding: 32px 20px;
        gap: 12px;
    }

    .empty-state-icon {
        width: 80px;
        height: 80px;
        border-radius: 20px;
    }

    .empty-state-icon>i {
        font-size: 32px;
    }

    .empty-state-icon-overlay {
        width: 30px;
        height: 30px;
        bottom: -6px;
        right: -6px;
    }

    .empty-state-icon-overlay i {
        font-size: 14px;
    }

    .empty-state-title {
        font-size: 18px;
    }

    .empty-state-desc {
        font-size: 14px;
    }

    .empty-state-btn {
        padding: 14px 28px;
        font-size: 15px;
    }

    .empty-state-hint {
        display: none;
        /* 紐⑤컮?쇱뿉???쒕옒洹??뚰듃 ?④? */
    }

    .empty-state-formats {
        gap: 6px;
    }

    .empty-state-formats span {
        padding: 3px 8px;
        font-size: 10px;
    }

    /* Sidebar as Bottom Sheet */
    .sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: auto;
        max-height: 90vh;
        border-right: none;
        border-top: 1px solid var(--border-subtle);
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        transform: translateY(100%);
        transition: transform 0.35s var(--ease-out-expo);
        z-index: 200;
        grid-area: unset;
    }

    .sidebar.open {
        transform: translateY(0);
    }

    .sidebar::before {
        content: '';
        width: 48px;
        height: 5px;
        background: var(--border-strong);
        border-radius: var(--radius-full);
        margin: 12px auto 16px;
        /* Increased bottom margin */
        /* [CHANGED] Use relative positioning to prevent overlap */
        position: relative;
        display: block;
    }

    /* [NEW] Guide Text Visibility */
    .sidebar-guide-text {
        display: block !important;
        text-align: center;
        margin-bottom: 24px;
        font-size: 14px;
        font-weight: 600;
        color: #ffffff;
        opacity: 1;
        padding: 0;
    }

    .sidebar-scroll {
        padding: 0 16px 32px;
        /* Remove top padding since handled by margin */
        -webkit-overflow-scrolling: touch;

        overscroll-behavior: contain;
    }

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

    /* ?ъ씠?쒕컮 ?대? ?앹꽦 踰꾪듉 - ?ㅽ겕濡??곸뿭 ?섎떒???쒖떆 */
    #generateBtnSidebar {
        position: static !important;
        margin-top: 16px;
        width: 100%;
        box-shadow: none;
    }

    .color-palette {
        grid-template-columns: repeat(7, 1fr);
        gap: 6px;
    }

    /* Floating Generate Button */
    .generate-btn {
        position: fixed;
        bottom: 20px;
        left: 20px;
        right: 20px;
        border-radius: var(--radius-lg);
        z-index: 150;
        box-shadow: var(--shadow-xl);
        padding: 0 10px;
        /* Optimize space further */
        gap: 6px;
    }

    .generate-btn .btn-text {
        gap: 4px;
    }

    .generate-btn .btn-text i {
        font-size: 16px;
    }

    .generate-btn .credit-badge {
        display: none !important;
        /* [FIX] 紐⑤컮?쇱뿉?쒕룄 ?④? */
        padding: 4px 8px;
        font-size: 13px;
        gap: 4px;
    }

    .btn-label-multiline {
        font-size: 14px;
        /* Increased by ~15% */
        letter-spacing: -0.5px;
        line-height: 1.15;
    }

    .sidebar.open+.sidebar-overlay+.main-content .generate-btn,
    .sidebar.open~.generate-btn {
        display: none;
    }

    /* Mobile Overlay */
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.7);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        z-index: 199;
        animation: fadeIn 0.2s ease;
    }

    .sidebar-overlay.show {
        display: block;
    }

    /* Toolbar */
    .toolbar {
        top: 12px;
        left: 12px;
        right: 12px;
    }

    .tool-group {
        padding: 6px;
        border-radius: var(--radius-md);
    }

    .tool-btn {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }

    .tool-btn[title]::after {
        display: none;
    }

    .zoom-level {
        font-size: 13px;
        padding: 0 10px;
        min-width: 50px;
    }

    .view-btn {
        padding: 8px 14px;
        font-size: 13px;
    }

    /* Stats Panel */
    .stats-panel {
        padding: 14px 16px;
        padding-bottom: 16px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .stats-header {
        margin-bottom: 12px;
    }

    .stats-grid {
        gap: 6px;
    }

    .stat-item {
        padding: 8px 12px;
        font-size: 11px;
    }

    .stat-dot {
        width: 12px;
        height: 12px;
    }

    .stats-actions {
        flex-wrap: wrap;
    }

    .action-btn {
        padding: 10px 14px;
        font-size: 15px;
        font-weight: 700;
    }

    /* Modals */
    .modal {
        max-width: 100%;
        margin: 0 16px;
        border-radius: var(--radius-lg);
    }

    .modal-3d-controls {
        flex-wrap: wrap;
        gap: 10px;
        padding: 14px 20px;
    }

    .control-pill {
        padding: 8px 14px;
        font-size: 11px;
    }

    /* Toast */
    .toast-container {
        bottom: 100px;
        left: 16px;
        right: 16px;
    }

    .toast {
        min-width: auto;
        max-width: 100%;
    }
}

/* ============================================
   RESPONSIVE - SMALL MOBILE
   ============================================ */

@media (max-width: 480px) {
    .header {
        padding: 0 12px;
    }

    .logo img {
        height: 28px;
    }

    .page-title {
        font-size: 13px;
    }

    .btn-auth {
        padding: 8px 12px;
    }

    .btn-auth span {
        display: none;
    }

    .sidebar-scroll {
        padding: 12px;
    }

    .form-row {
        flex-direction: column;
        gap: 14px;
    }

    /* [FIX] Force compact rows (like size inputs) to stay horizontal on mobile */
    .form-row.compact {
        flex-direction: row;
        gap: 4px;
        /* Reduced gap */
        align-items: center;
    }

    /* Reduce input size on mobile to fit "Maintain Ratio" */
    .form-row.compact .form-input {
        padding: 6px 4px;
        /* Reduced padding */
        padding-right: 20px;
        /* Space for unit */
        font-size: 11px;
        /* Smaller font */
    }

    .form-row.compact .input-unit {
        right: 4px;
        font-size: 10px;
    }

    .ratio-toggle {
        min-width: auto;
        /* Allow shrinking if needed */
        padding: 0 4px;
        height: 28px;
    }

    .ratio-label {
        font-size: 10px;
        /* Smaller label */
    }

    .color-palette {
        grid-template-columns: repeat(5, 1fr);
        gap: 8px;
    }

    .tool-group {
        gap: 4px;
    }

    .tool-btn {
        width: 34px;
        height: 34px;
    }

    .tool-divider {
        display: none;
    }

    .zoom-level {
        display: none;
    }

    .stats-actions {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .generate-btn {
        bottom: 16px;
        left: 16px;
        right: 16px;
        padding: 16px;
        font-size: 15.2px;
        /* Reduced by 5% from 16px */
        justify-content: center;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */

/* Cursor Styles */
.cursor-brush {
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linejoin="round" style="background:white; border-radius:50%;"><path d="M18 13.5c0 2.2-2.5 4.5-5 4.5s-5-2.3-5-4.5c0-3 5-7.5 5-7.5s5 4.5 5 7.5z"/><path d="M13 18v3"/><path d="M13 3v2"/></svg>') 12 24, auto !important;
    /* Simplified Paintbrush icon fallback */
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><path fill="%23000" d="M20.71 4.63l-1.34-1.34a.996.996 0 0 0-1.41 0L9 12.29V15h2.71l8.97-8.97a1 1 0 0 0 0-1.4zM3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25z"/></svg>') 0 24, pointer !important;
}

@media print {

    .app-container,
    .modal-3d,
    .toast-container {
        display: none !important;
    }

    body::after {
        content: "이 페이지는 직접 인쇄할 수 없습니다.\n'배치도 출력' 버튼을 이용해주세요.";
        display: flex;
        justify-content: center;
        align-items: center;
        height: 100vh;
        font-size: 18px;
        text-align: center;
        white-space: pre-wrap;
        color: #333;
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.text-gradient {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* [NEW] Input Prefix (媛濡??몃줈 Label) */
.input-prefix {
    font-size: 9px;
    /* Reduced ~30% from 13px */
    color: #aaa;
    margin-right: 6px;
    white-space: nowrap;
    font-weight: 500;
    flex-shrink: 0;
}

/* Ensure input expands to fill remaining space */
.form-group .form-input {
    flex: 1;
    width: auto;
    /* Allow flex to control width */
    min-width: 0;
}

/* ============================================
   MINI 3D VIEWER
   ============================================ */

.mini-3d-viewer {
    position: absolute;
    bottom: 15px;
    right: 15px;
    width: 260px;
    height: 200px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    z-index: 100;
    display: none;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    animation: mini3dSlideIn 0.3s ease-out forwards;
}

.mini-3d-viewer.show {
    display: flex;
}

.mini-3d-viewer.closing {
    animation: mini3dSlideOut 0.3s ease-in forwards;
}

@keyframes mini3dSlideIn {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes mini3dSlideOut {
    from {
        opacity: 1;
        transform: scale(1) translateY(0);
    }

    to {
        opacity: 0;
        transform: scale(0.8) translateY(20px);
    }
}

.mini-3d-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.mini-3d-header i {
    margin-right: 6px;
    color: var(--accent-color);
}

.mini-close-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.mini-close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.mini-3d-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.mini-3d-container canvas {
    width: 100% !important;
    height: 100% !important;
}

.mini-expand-btn {
    padding: 8px;
    background: var(--accent-color);
    border: none;
    color: white;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mini-expand-btn:hover {
    background: var(--accent-hover);
}

.mini-expand-btn i {
    margin-right: 4px;
}

/* ============================================
   遺덈윭?ㅺ린 誘몃━蹂닿린 紐⑤떖
   ============================================ */
.load-preview-modal {
    max-width: 420px;
    width: 90%;
}

.load-preview-modal .modal-body {
    padding: 20px;
}

.load-preview-image {
    width: 100%;
    aspect-ratio: 16 / 10;
    background: var(--bg-base);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    border: 1px solid var(--border-subtle);
}

.load-preview-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.load-preview-image .no-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
}

.load-preview-image .no-preview i {
    font-size: 32px;
    opacity: 0.5;
}

.load-preview-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.preview-info-item {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    font-size: 13px;
}

.preview-info-item i {
    width: 16px;
    color: var(--text-muted);
}

.load-preview-modal .modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 16px 20px;
    border-top: 1px solid var(--border-subtle);
}

.load-preview-modal .btn-secondary {
    padding: 10px 20px;
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.load-preview-modal .btn-secondary:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.load-preview-modal .btn-primary {
    padding: 10px 20px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.load-preview-modal .btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md), var(--shadow-glow-primary);
}

/* 紐⑤컮?쇱뿉??誘몃땲 酉곗뼱 ?ш린 議곗젙 */
@media (max-width: 768px) {
    .mini-3d-viewer {
        width: 180px;
        height: 160px;
        bottom: 10px;
        right: 10px;
    }

    .mini-3d-header {
        padding: 8px 10px;
        font-size: 11px;
    }

    .mini-expand-btn {
        padding: 6px;
        font-size: 10px;
    }

    .load-preview-modal {
        width: 95%;
        max-width: none;
    }
}

/* --- Full Screen Edit Mode (Zen Mode) --- */
body.full-screen-edit {
    overflow: hidden;
    /* Prevent body scroll */
}

body.full-screen-edit .header,
body.full-screen-edit .sidebar,
body.full-screen-edit .stats-panel,
body.full-screen-edit .mini-3d-viewer,
body.full-screen-edit .empty-state,
body.full-screen-edit .sidebar-overlay,
body.full-screen-edit #btnToolBrush,
/* Hide original brush button since we are in it? Optional, keeping it might be confusing if active */
body.full-screen-edit .tool-group .view-toggle

/* Hide view toggle? Probably yes focus on edit */
    {
    display: none !important;
}

body.full-screen-edit .main-content {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    background-color: #09090B;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

body.full-screen-edit .toolbar {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(28, 28, 30, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50px;
    padding: 10px 20px;
    z-index: 10000;
    /* Ensure toolbar is above everything */
    width: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    white-space: nowrap;
}

body.full-screen-edit .canvas-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #09090B;
}

/* Ensure canvas container expands */
body.full-screen-edit .canvas-container {
    max-width: none;
    max-height: none;
    width: 90%;
    height: 90%;
}

/* Force show the close button */
body.full-screen-edit #btnCloseEdit {
    display: inline-flex !important;
}

/* [NEW] Brush Mode Canvas Cursor Inheritance */
#brushCanvasArea canvas {
    cursor: inherit !important;
}

/* ============================================
   TOAST NOTIFICATION OVERRIDES
   ============================================ */
@keyframes iconSpin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Base Toast Style Overrides */
.toast.info,
.toast.success,
.toast.loading {
    background-color: #FFF9C4 !important;
    /* Light Yellow Background */
    color: #191919 !important;
    /* Dark Text */
    border: 1px solid #FFE082 !important;
    /* Yellow Border for definition */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

/* Loading - Spin Animation (Clock-like) */
.toast.loading .toast-icon i {
    color: #F9A825 !important;
    /* Darker Yellow/Orange */
    animation: iconSpin 1.2s linear infinite !important;
}

/* Info & Success - Static Icons */
.toast.info .toast-icon i {
    color: #FBC02D !important;
}

.toast.success .toast-icon i {
    color: #2E7D32 !important;
}

/* Close Button */
.toast.info .toast-close,
.toast.success .toast-close,
.toast.loading .toast-close {
    color: #555 !important;
}

.toast.info .toast-close:hover,
.toast.success .toast-close:hover,
.toast.loading .toast-close:hover {
    background-color: rgba(0, 0, 0, 0.05) !important;
}

/* ============================================
   MOBILE IMAGE EDIT BUTTON (Sidebar)
   ============================================ */

.btn-open-image-edit {
    display: none;
    width: 100%;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    margin-top: 8px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-main);
}

/* PC?먯꽌???④? (紐⑤컮?쇱뿉?쒕쭔 ?몄텧) */
@media (min-width: 769px) {
    .btn-open-image-edit {
        display: none !important;
    }
}

.btn-open-image-edit:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.btn-open-image-edit i {
    font-size: 14px;
}

/* ============================================
   FULLSCREEN IMAGE EDIT MODAL (Mobile)
   ============================================ */

.modal-image-edit {
    position: fixed;
    inset: 0;
    background: var(--bg-base);
    z-index: 10000;
    display: none;
    flex-direction: column;
}

.modal-image-edit.active {
    display: flex;
}

/* Header */
.modal-image-edit-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border-subtle);
    min-height: 56px;
}

.image-edit-header-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.image-edit-header-title i {
    color: var(--accent);
}

.image-edit-header-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-family: var(--font-main);
}

.image-edit-header-btn.back {
    background: var(--bg-overlay);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}

.image-edit-header-btn.back:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
}

.image-edit-header-btn.confirm {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
}

.image-edit-header-btn.confirm:hover {
    filter: brightness(1.1);
}

/* Canvas Wrapper */
.image-edit-canvas-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #0a0a0a;
}

.image-edit-canvas-area {
    width: 100%;
    height: 100%;
    position: relative;
    cursor: default;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.image-edit-canvas-area canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

/* Bottom Toolbar */
.modal-image-edit-toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px 16px;
    background: var(--bg-elevated);
    border-top: 1px solid var(--border-subtle);
    flex-wrap: wrap;
}

.image-edit-tool-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.image-edit-tool-btn {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: var(--bg-overlay);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.image-edit-tool-btn:hover,
.image-edit-tool-btn:active {
    background: var(--bg-surface);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.image-edit-tool-btn .image-edit-btn-label {
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
}

/* If button has label, make it wider */
.image-edit-tool-btn:has(.image-edit-btn-label) {
    width: auto;
    padding: 0 12px;
}

.image-edit-zoom-level {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    min-width: 44px;
    text-align: center;
    padding: 0 4px;
}

.image-edit-divider {
    width: 1px;
    height: 24px;
    background: var(--border-subtle);
    margin: 0 4px;
}

/* Hints Bar */
.modal-image-edit-hints {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 8px 16px;
    background: var(--bg-overlay);
    border-top: 1px solid var(--border-subtle);
    font-size: 11px;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.modal-image-edit-hints span {
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

/* ============================================
   GUIDE MODAL
   ============================================ */
.guide-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 10px 0;
}

.guide-step {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.step-badge {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 14px;
    box-shadow: 0 4px 10px var(--primary-glow);
    margin-top: -2px;
}

.step-text {
    font-size: 14.5px;
    line-height: 1.6;
    color: var(--text-primary);
}

.step-text strong {
    color: var(--accent);
    font-weight: 700;
}

.modal-guide-fixed {
    width: 500px !important;
    height: 700px !important;
    max-width: none !important;
    display: flex;
    flex-direction: column;
}

.guide-image-container {
    flex: 1;
    width: 100%;
    overflow: hidden;
    background: #000;
}

.guide-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.guide-footer-content {
    padding: 20px 24px;
    background: var(--bg-elevated);
    border-top: 1px solid var(--border-subtle);
}

/* Custom Alert Styles (Browser-like) */
.custom-alert-modal {
    max-width: 420px;
    background: #ffffff !important;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    border: none;
}

.custom-alert-body {
    padding: 24px 24px 20px;
    color: #333;
}

.custom-alert-title {
    font-size: 13px;
    color: #666;
    margin-bottom: 12px;
    font-family: sans-serif;
}

.custom-alert-message {
    font-size: 16px;
    line-height: 1.5;
    margin-bottom: 24px;
    color: #000;
    font-weight: 500;
}

.custom-alert-actions {
    display: flex;
    justify-content: flex-end;
}

.custom-alert-btn {
    background: #955ea0;
    /* Purple style from user image */
    color: #fff;
    border: none;
    padding: 8px 28px;
    border-radius: 20px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
}

.custom-alert-btn:hover {
    background: #824d8d;
    box-shadow: 0 0 0 4px rgba(149, 94, 160, 0.3);
}

.custom-alert-btn:active {
    transform: scale(0.96);
}

/* ============================================
   DETONATOR SELECTOR (3D HEADER)
   ============================================ */
.detonator-header-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-right: 6px;
    padding-right: 10px;
    border-right: 1px solid var(--border-subtle);
    position: relative;
    /* For absolute dropdown */
}

.i4-det-color-wrap {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-right: 6px;
    padding: 4px 8px;
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    background: var(--bg-elevated);
}

.i4-det-color-label {
    font-size: 10px;
    font-weight: 800;
    color: var(--text-secondary);
    white-space: nowrap;
}

.i4-det-color-options {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.i4-det-color-item {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, 0.45);
    padding: 0;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.i4-det-color-item:hover {
    transform: scale(1.12);
}

.i4-det-color-item[data-color="#FFFFFF"] {
    border-color: rgba(255, 255, 255, 0.8);
}

.i4-det-color-item[data-color="#1A1A1A"] {
    border-color: rgba(255, 255, 255, 0.55);
}

.i4-det-color-item.active {
    transform: scale(1.15);
    border-color: #00E5FF;
    box-shadow: 0 0 0 1.5px #00E5FF, 0 0 8px rgba(0, 229, 255, 0.45);
}

#i4DetColorInput {
    width: 22px;
    height: 18px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
}

#i4DetColorInput::-webkit-color-swatch-wrapper {
    padding: 0;
}

#i4DetColorInput::-webkit-color-swatch {
    border: 1px solid var(--border-default);
    border-radius: 4px;
}

#i4DetColorInput::-moz-color-swatch {
    border: 1px solid var(--border-default);
    border-radius: 4px;
}

.banner-label {
    font-size: 10.4px;
    font-weight: 900;
    color: #1a1a1a;
    background: linear-gradient(135deg, #FFD700 0%, #FFF176 25%, #FFA500 50%, #FFF176 75%, #FFD700 100%);
    background-size: 200% auto;
    padding: 5px 11px;
    border-radius: 8px;
    text-transform: uppercase;
    letter-spacing: 0.2px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: visible;
    box-shadow: 0 0 15px rgba(255, 165, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.2);
    animation: essentialPulse 2s infinite, goldShimmer 3s infinite linear;
    border: none;
    cursor: pointer;
    /* Change cursor for PC */
}

.banner-label::before {
    display: none !important;
}

/* ?곷떒 踰꾪듉 ?쒕쾲 ?숆렇?쇰? ?ㅽ???*/
.step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    background: #000;
    color: #fff;
    border-radius: 50%;
    font-size: 9px;
    font-weight: 900;
    margin-right: 5px;
    flex-shrink: 0;
}

.banner-options {
    display: none;
    /* Hidden by default on all devices now */
    gap: 8px;
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    background: var(--bg-overlay);
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--border-default);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), var(--shadow-glow-primary);
    z-index: 1000;
    flex-direction: column;
    /* Vertical dropdown */
    min-width: 160px;
    max-height: min(70vh, 360px);
    overflow-y: auto;
    overflow-x: hidden;
}

/* Show when expanded */
.detonator-header-selector.detonator-expanded .banner-options {
    display: flex;
    animation: fadeInDown 0.2s ease-out;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.banner-opt-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.banner-opt-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-default);
    color: var(--text-primary);
}

.banner-opt-btn.active {
    background: rgba(0, 102, 255, 0.1);
    border-color: var(--primary);
    color: white;
    box-shadow: 0 0 10px rgba(0, 102, 255, 0.2);
}

.opt-num {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    font-size: 10px;
    font-weight: 800;
    color: var(--text-muted);
}

.banner-opt-btn.active .opt-num {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.opt-text {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

/* ============================================
   UPGRADE MODAL (PREMIUM)
   ============================================ */

.upgrade-overlay {
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.upgrade-modal {
    max-width: 840px;
    width: 95%;
    background: #121214;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    padding: 0;
    overflow: hidden;
    box-shadow: 0 32px 64px rgba(0, 0, 0, 0.8);
    position: relative;
    animation: modalSlideUp 0.5s var(--ease-out-expo);
}

@keyframes modalSlideUp {
    from { opacity: 0; transform: translateY(30px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.upgrade-close {
    position: fixed;
    top: 30px;
    right: 30px;
    width: 48px;
    height: 48px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1.5px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9999 !important; /* Extremely high to be above everything else */
    pointer-events: auto !important;
    transition: all 0.3s cubic-bezier(0.19, 1, 0.22, 1);
}

.upgrade-close:hover {
    background: rgba(255, 61, 87, 0.1);
    color: var(--error);
    border-color: var(--error-light);
    transform: rotate(90deg);
}

.upgrade-shell {
    padding: 48px 40px;
}

.upgrade-header {
    text-align: center;
    margin-bottom: 32px;
}

.upgrade-kicker {
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--primary);
    margin-bottom: 12px;
}

.upgrade-header h2 {
    font-size: 28px;
    font-weight: 800;
    color: white;
    letter-spacing: -0.5px;
    margin-bottom: 12px;
}

.upgrade-header p {
    font-size: 15px;
    color: var(--text-secondary);
    max-width: 500px;
    margin: 0 auto;
    line-height: 1.6;
}

.upgrade-pill-row {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 40px;
}

.upgrade-pill {
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 700;
}

.upgrade-pill.active {
    background: rgba(0, 102, 255, 0.15);
    color: var(--primary-light);
    border: 1px solid rgba(0, 102, 255, 0.2);
}

.upgrade-pill.neutral {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}

.upgrade-plan-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.upgrade-plan {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 32px 24px;
    display: flex;
    flex-direction: column;
    transition: all 0.3s var(--ease-out-expo);
    position: relative;
}

.upgrade-plan:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-default);
    transform: translateY(-4px);
}

.upgrade-plan.featured {
    background: linear-gradient(180deg, rgba(0, 102, 255, 0.08) 0%, rgba(0, 102, 255, 0.02) 100%);
    border: 1px solid var(--primary-glow);
    box-shadow: 0 0 40px rgba(0, 102, 255, 0.1);
}

.upgrade-featured-badge {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: white;
    font-size: 11px;
    font-weight: 800;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    box-shadow: 0 4px 12px rgba(0, 102, 255, 0.3);
}

.upgrade-plan-tag {
    font-size: 11px;
    font-weight: 800;
    color: var(--text-muted);
    margin-bottom: 8px;
    display: block;
}

.featured-tag {
    color: var(--primary-light);
}

.upgrade-plan h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 16px;
}

.upgrade-price {
    display: flex;
    align-items: baseline;
    gap: 4px;
    margin-bottom: 16px;
}

.upgrade-price strong {
    font-size: 24px;
    font-weight: 800;
    color: white;
}

.upgrade-price span {
    font-size: 13px;
    color: var(--text-muted);
}

.upgrade-plan > p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 24px;
    min-height: 40px;
}

.upgrade-focus-chip {
    background: rgba(255, 208, 0, 0.1);
    border: 1px solid rgba(255, 208, 0, 0.2);
    padding: 10px 12px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
}

.upgrade-focus-chip i {
    color: var(--accent);
    font-size: 14px;
}

.upgrade-focus-chip span {
    font-size: 12px;
    font-weight: 700;
    color: var(--accent-light);
}

.upgrade-promo-box {
    background: var(--accent);
    color: #000;
    padding: 14px 12px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 800;
    text-align: center;
    margin-bottom: 24px;
    box-shadow: 0 8px 16px rgba(255, 208, 0, 0.2);
    line-height: 1.4;
    word-break: keep-all;
}

.upgrade-feature-list {
    list-style: none;
    margin-bottom: 28px;
    flex: 1;
}

.upgrade-feature-list li {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 12.5px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.upgrade-feature-list i {
    color: var(--success);
    font-size: 12px;
    margin-top: 3px;
}

.upgrade-plan-note {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 12px;
}

.upgrade-plan-btn {
    width: 100%;
    padding: 14px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.upgrade-plan-btn.ghost {
    background: transparent;
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
}

.upgrade-plan-btn.ghost:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.upgrade-plan-btn.primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(0, 102, 255, 0.3);
}

.upgrade-plan-btn.primary:hover {
    background: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 102, 255, 0.4);
}

.upgrade-plan-btn.dark {
    background: #242429;
    color: white;
}

.upgrade-plan-btn.dark:hover {
    background: #2c2c33;
}

@media (max-width: 768px) {
    .upgrade-shell {
        padding: 32px 20px;
    }
    .upgrade-plan-grid {
        grid-template-columns: 1fr;
    }
    .upgrade-header h2 {
        font-size: 22px;
    }
}

@media (max-width: 1024px) {
    .detonator-header-selector {
        margin-right: 8px;
        padding-right: 8px;
        gap: 8px;
    }

    .i4-det-color-wrap {
        margin-right: 8px;
    }

    .banner-label {
        display: none;
    }
}

@media (max-width: 768px) {
    .modal-3d-header {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 10px 12px;
        overflow: visible;
    }

    /* Title row: h3 + close button side by side */
    .modal-3d-header h3 {
        display: flex;
        align-items: center;
        gap: 8px;
        font-size: 13px;
        width: 100%;
        justify-content: space-between;
    }

    /* Show mobile close button */
    .mobile-only-close {
        display: flex !important;
    }

    /* Move close button next to title on mobile */
    .modal-3d-header .close-btn {
        position: static;
        width: 32px;
        height: 32px;
        font-size: 14px;
        flex-shrink: 0;
    }

    /* Actions area: horizontal scroll strip */
    .modal-3d-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        justify-content: center;
        width: 100%;
        order: 2;
        overflow: visible;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
    }

    /* Hide the close button inside actions (it's now in h3 row) */
    .modal-3d-actions>.close-btn {
        display: none !important;
    }

    /* Tool dividers: hide on mobile to save space */
    .modal-3d-actions>.tool-divider {
        display: none !important;
    }

    /* Inline tool-divider with style attribute: hide */
    .modal-3d-actions>div[class="tool-divider"] {
        display: none !important;
    }

    /* Detonator selector: toggle on mobile */
    .detonator-header-selector {
        border-right: none;
        padding-right: 0;
        margin-right: 0;
        gap: 6px;
        width: 100%;
        flex-wrap: wrap;
        justify-content: center;
        padding-bottom: 6px;
        border-bottom: 1px solid var(--border-subtle);
        margin-bottom: 2px;
    }

    .i4-det-color-wrap {
        justify-content: center;
        margin: 0;
        padding: 4px 8px;
    }

    .i4-det-color-options {
        gap: 4px;
    }

    .i4-det-color-item {
        width: 14px;
        height: 14px;
    }

    /* Show banner-label on mobile (overrides 1024px hide) */
    .banner-label {
        display: flex !important;
        cursor: pointer;
        user-select: none;
        position: relative;
        padding-right: 24px !important;
    }

    /* Dropdown arrow indicator on mobile */
    .banner-label::after {
        content: '▼' !important;
        display: inline-block !important;
        font-size: 8px;
        position: absolute;
        right: 8px;
        top: 50%;
        transform: translateY(-50%);
        transition: transform 0.2s ease;
    }

    .detonator-expanded .banner-label::after {
        transform: translateY(-50%) rotate(180deg);
    }

    /* Hide options by default on mobile */
    .banner-options {
        display: none !important;
        grid-template-columns: 1fr 1fr;
        gap: 4px;
        width: 100%;
        max-height: 44vh;
        overflow-y: auto;
        overflow-x: hidden;
    }

    /* Show options when expanded */
    .detonator-expanded .banner-options {
        display: grid !important;
    }

    .banner-opt-btn {
        padding: 6px 8px;
        gap: 4px;
        font-size: 11px;
        justify-content: center;
    }

    .opt-num {
        width: 16px;
        height: 16px;
        font-size: 9px;
    }

    .opt-text {
        font-size: 10px;
    }

    /* Action buttons: compact icon+text on mobile */
    .modal-3d-actions .header-action-btn {
        padding: 5px 8px;
        gap: 3px;
        font-size: 8.8px;
        border-radius: 6px;
        flex-shrink: 0;
    }

    .modal-3d-actions .header-action-btn i {
        font-size: 10.4px;
    }

    .modal-3d-actions .header-action-btn span {
        font-size: 8px;
        white-space: nowrap;
    }

    .modal-3d-actions .header-action-btn .step-num {
        width: 12px;
        height: 12px;
        font-size: 7.2px;
        margin-right: 2px;
    }

    /* Connection palette: responsive on mobile */
    .connection-palette {
        flex-wrap: wrap !important;
        gap: 6px !important;
        padding: 4px 8px !important;
        margin-right: 0 !important;
        justify-content: center !important;
        width: 100% !important;
    }

    /* 3D controls footer: more compact */
    .modal-3d-controls {
        padding: 10px 16px;
        gap: 12px;
    }

    .control-pill {
        padding: 6px 10px;
        font-size: 10px;
        gap: 6px;
    }

    .control-pill i {
        font-size: 13px;
    }
}

/* 3D Viewer Canvas Cursor */
#mini3dContainer canvas,
.modal-content canvas {
    cursor: default !important;
}

/* Step Number 9 for Edit Button */
#stepNineBadge,
.step-nine-badge {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 20px !important;
    height: 20px !important;
    background-color: #000 !important;
    color: #FFD700 !important;
    border-radius: 50% !important;
    font-weight: 900 !important;
    font-size: 12px !important;
    line-height: 1 !important;
    margin-left: 8px !important;
    flex-shrink: 0 !important;
    border: 1px solid #FFD700 !important;
    font-family: sans-serif !important;
    vertical-align: middle !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    top: 0 !important;
    left: 0 !important;
    transform: none !important;
    order: 99 !important;
}

/* PRO Badge */
.pro-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: #000;
    color: #FFD700;
    border-radius: 50%;
    font-size: 7px;
    font-weight: 900;
    margin-left: 4px;
    border: 0.8px solid #FFD700;
    flex-shrink: 0;
    vertical-align: middle;
    transition: all 0.2s;
    letter-spacing: -0.2px;
    line-height: 1;
    font-family: sans-serif;
}

.tool-btn:hover .pro-badge,
.action-btn:hover .pro-badge {
    transform: scale(1.1);
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
}