/* ============================================
   i 4 — Fourth Anniversary
   One-page Portfolio Website
   ============================================ */

/* --- Font Face --- */
@font-face {
    font-family: 'Whoami';
    src: url('font/Whoami-Regular.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
    font-display: block;
}

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

html {
    scroll-behavior: smooth;
    scroll-snap-type: y mandatory;
    overflow-y: scroll;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #ffffff;
    color: #1a1a1a;
    overflow-x: hidden;
    zoom: 1.2; /* UI scaled up by 20% */
}

/* --- Sections --- */
.section {
    width: 100%;
    height: 100vh;
    scroll-snap-align: start;
    position: relative;
    overflow: hidden;
}

/* ============================================
   Navigation
   ============================================ */
#site-nav {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    padding: 36px 40px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

#logo {
    display: block;
    width: 56px;
    height: 56px;
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

#logo svg {
    width: 100%;
    height: 100%;
}

#nav-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-link {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: #1C1C1C;
    text-decoration: none;
    letter-spacing: -0.01em;
    line-height: 1.5;
    position: relative;
    transition: font-weight 0.3s ease;
}

.nav-link.active {
    font-weight: 600;
    color: #1C1C1C;
}

.nav-link:hover, .nav-link:active {
    color: #B2081E;
}

/* Dark nav for Who am i section (light mode still has dark nav) */
body.nav-invert #logo svg circle {
    fill: #1a1a1a;
}

body.nav-invert .nav-link {
    color: #1a1a1a;
}

body.nav-invert .nav-link::after {
    background: #1a1a1a;
}

body.dark-mode .thumb-pattern0 {
    background: #555 !important;
}
body.dark-mode .thumb-pattern1 {
    background: repeating-linear-gradient(0deg, #ccc, #ccc 2px, transparent 2px, transparent 4px) !important;
}
body.dark-mode .thumb-pattern2 {
    background: repeating-linear-gradient(90deg, #ccc, #ccc 2px, transparent 2px, transparent 4px) !important;
}
body.dark-mode .thumb-pattern3 {
    background: conic-gradient(#ccc 25%, transparent 25% 50%, #ccc 50% 75%, transparent 75%) 0 0/8px 8px !important;
}

/* ============================================
   Section 1: Main (Work)
   ============================================ */
#main-section {
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-bottom: 8vh; /* Added padding to widen the gap between pages */
}

#typography-grid {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(12px, 2vh, 28px);
    user-select: none;
    margin-top: -5vh; /* Shift typography slightly up on PC */
    /* padding-left removed for perfect center */
    /* scale removed to make it naturally larger */
    transform: scale(0.8);
}

.typo-row {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0;
    line-height: 1;
}

.letter {
    font-family: 'Whoami', 'Georgia', serif;
    color: #B2081E;
    cursor: default;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s ease;
    will-change: transform;
}

/* --- Letter sizing per row (matching reference image proportions) --- */
.row-1 .letter {
    font-size: clamp(65px, 10.5vw, 145px);
    margin: 0 clamp(12px, 2.5vw, 36px);
}

.row-2 .letter {
    font-size: clamp(56px, 9.2vw, 126px);
    margin: 0 clamp(10px, 2vw, 29px);
}

.row-3 .letter {
    font-size: clamp(50px, 8.5vw, 116px);
    margin: 0 clamp(8px, 1.8vw, 25px);
}

.row-4 .letter {
    font-size: clamp(44px, 7.5vw, 102px);
    margin: 0 clamp(8px, 1.8vw, 25px);
}

/* Letter hover — no-image letters bounce */
.letter:hover {
    z-index: 100;
}

/* Letter with image hover */
.letter-img {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    height: 1.4em;
    width: auto;
    object-fit: contain;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 10;
    -webkit-filter: grayscale(100%);
    filter: grayscale(100%);
}

.letter[data-img]:hover .letter-img {
    opacity: 1 !important;
}

.letter[data-img]:hover {
    color: transparent !important;
}

/* ============================================
   Section 2: Who am i
   ============================================ */
#who-am-i {
    background: #ffffff;
    display: flex;
    flex-direction: column;
    position: relative;
    padding-left: 0;
    padding-right: 0;
    height: 100dvh;
    max-height: 100dvh;
    overflow-y: auto;
}

@media (min-width: 769px) {
    #who-am-i {
        height: 83.333dvh; /* Counteract zoom: 1.2 on desktop */
        max-height: 83.333dvh;
        overflow-y: hidden;
    }
}

#generative-canvas-container {
    flex: 1 1 auto;
    min-height: 350px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

#gen-canvas {
    display: block;
}

/* --- Controls --- */
#gen-controls {
    width: 100%;
    padding: 24px 3vw 24px 3vw;
    z-index: 100;
    margin-top: auto;
}

#gen-input-wrap {
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

#gen-text-input {
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    font-weight: 300;
    color: #666;
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 6px;
    padding: 8px 16px;
    width: 220px;
    height: 38px;
    resize: none;
    outline: none;
    transition: border-color 0.3s ease, background 0.3s ease, box-shadow 0.3s ease;
    letter-spacing: -0.01em;
    overflow: hidden;
}

#font-download-btn {
    display: flex;
    align-items: center;
    text-decoration: none;
    opacity: 0.65;
    transition: opacity 0.3s ease;
    flex-shrink: 0;
}

#font-download-btn:hover {
    opacity: 1;
}

#font-download-btn img {
    height: 25px;
    width: auto;
}

#gen-text-input:focus {
    border-color: rgba(178, 8, 30, 0.3);
    background: rgba(0, 0, 0, 0.02);
    box-shadow: 0 0 0 3px rgba(178, 8, 30, 0.06);
}

#gen-text-input::placeholder {
    color: #bbb;
}

#sliders-panel {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 16px;
}

.slider-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.slider-group label {
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 400;
    color: #999;
    letter-spacing: 0.02em;
    text-transform: none;
}

.color-target-selector {
    color: #999;
    text-transform: none;
    letter-spacing: 0;
}

.color-target {
    cursor: pointer;
    opacity: 0.5;
    transition: color 0.2s, opacity 0.2s;
}

.color-target.active {
    opacity: 1;
    font-weight: 600;
    color: #444;
}

.color-target-sep {
    opacity: 0.3;
}

body.dark-mode .color-target.active {
    color: #eee;
}

/* --- Custom Range Slider --- */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 2px;
    background: rgba(0, 0, 0, 0.12);
    border-radius: 1px;
    outline: none;
    cursor: pointer;
    transition: background 0.3s ease;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #999;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.2s ease;
    border: none;
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: #666;
}

input[type="range"]:active::-webkit-slider-thumb {
    background: #B2081E;
}

input[type="range"]::-moz-range-thumb {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #999;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.2s ease;
    border: none;
}

input[type="range"]::-moz-range-thumb:hover {
    background: #666;
}

input[type="range"]:active::-moz-range-thumb {
    background: #B2081E;
}

/* ============================================
   Page Load Animation
   ============================================ */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

#site-nav {
    animation: fadeIn 0.8s ease 0.2s both;
}

.typo-row {
    opacity: 1;
}

/* ============================================
   Scroll Indicator (subtle)
   ============================================ */
/* Scroll indicator removed per user request */

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 1024px) {
    #sliders-panel {
        grid-template-columns: repeat(4, 1fr);
        margin-left: 80px;
    }
    
    #gen-input-wrap {
        margin-left: 80px;
    }
}

@media (max-width: 768px) {
    #site-nav {
        padding: 24px 24px;
    }
    
    #typography-grid {
        padding-left: 40px;
    }
    
    .row-1 .letter { font-size: clamp(40px, 10vw, 80px); }
    .row-2 .letter { font-size: clamp(35px, 9vw, 70px); }
    .row-3 .letter { font-size: clamp(30px, 8vw, 60px); }
    .row-4 .letter { font-size: clamp(28px, 7.5vw, 55px); }
    .row-5 .letter { font-size: clamp(30px, 8vw, 60px); }
    
    #sliders-panel {
        grid-template-columns: repeat(3, 1fr);
        margin-left: 24px;
        gap: 8px;
    }
    
    #gen-input-wrap {
        margin-left: 24px;
    }
    
    #gen-controls {
        padding: 16px 20px 24px;
    }
}

/* ============================================
   Dark Mode Toggle Button
   ============================================ */
#dark-mode-toggle {
    position: fixed;
    top: 38px;
    right: 40px;
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 0;
}

#dark-mode-toggle .circle-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: transparent;
    border: 1.1px solid #b8b8b8;
    transition: all 0.3s ease;
}

#dark-mode-toggle:hover .circle-icon {
    transform: scale(1.1);
    background-color: #000;
    border-color: #000;
}

body.dark-mode #dark-mode-toggle .circle-icon {
    background-color: transparent;
    border: 1.1px solid #666;
}

body.dark-mode #dark-mode-toggle:hover .circle-icon {
    transform: scale(1.1);
    background-color: #fff;
    border-color: #fff;
}

/* ============================================
   2D/3D Toggle & Motion Presets
   ============================================ */
#gen-mode-bar {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 14px;
}

.mode-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 400;
    color: #999;
    letter-spacing: 0.02em;
}

.mode-toggle-switch {
    position: relative;
    width: 36px;
    height: 18px;
    background: rgba(0, 0, 0, 0.12);
    border-radius: 9px;
    cursor: pointer;
    transition: background 0.3s ease;
    border: none;
    padding: 0;
}

.mode-toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #999;
    transition: transform 0.3s ease, background 0.3s ease;
}

.mode-toggle-switch.active {
    background: rgba(178, 8, 30, 0.2);
}

.mode-toggle-switch.active::after {
    transform: translateX(18px);
    background: #B2081E;
}

.motion-presets {
    display: flex;
    align-items: center;
    gap: 2px;
}

.motion-presets-label {
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 400;
    color: #999;
    letter-spacing: 0.02em;
    margin-right: 8px;
    flex-shrink: 0;
}

.motion-preset-btn {
    font-family: 'Inter', sans-serif;
    font-size: 10px;
    font-weight: 400;
    color: #999;
    background: none;
    border: 1px solid rgba(0, 0, 0, 0.16);
    border-radius: 4px;
    padding: 3px 8px;
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
}

.motion-preset-btn:hover {
    color: #444;
    border-color: rgba(0, 0, 0, 0.25);
}

.motion-preset-btn.active {
    color: #B2081E;
    border-color: rgba(178, 8, 30, 0.3);
    background: rgba(178, 8, 30, 0.04);
    font-weight: 500;
}



/* ============================================
   Three.js 3D Canvas Container
   ============================================ */
#three-canvas-container {
    flex: 1 1 auto;
    min-height: 350px;
    width: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#three-canvas-container canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

/* ============================================
   Dark Mode
   ============================================ */
body.dark-mode {
    background: #181818;
    color: #F3F3F3;
}



body.dark-mode #main-section {
    background: #181818;
}

body.dark-mode .letter {
    color: #F3F3F3;
}

body.dark-mode #logo svg .logo-path {
    fill: #F3F3F3;
}

body.dark-mode .nav-link {
    color: #F3F3F3;
}

body.dark-mode .nav-link.active {
    color: #F3F3F3;
}

body.dark-mode .nav-link:hover,
body.dark-mode .nav-link:active {
    color: #B2081E;
}

body.dark-mode #who-am-i {
    background: #181818;
}

body.dark-mode #gen-text-input {
    color: #ccc;
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.12);
}

body.dark-mode #gen-text-input:focus {
    border-color: rgba(178, 8, 30, 0.4);
    background: rgba(255, 255, 255, 0.04);
    box-shadow: 0 0 0 3px rgba(178, 8, 30, 0.1);
}

body.dark-mode #gen-text-input::placeholder {
    color: #555;
}

body.dark-mode .slider-group label {
    color: #777;
}

body.dark-mode input[type="range"] {
    background: rgba(255, 255, 255, 0.12);
}
body.dark-mode input[type="range"]::-webkit-slider-thumb {
    width: 10px;
    height: 10px;
    background: #777;
}

body.dark-mode input[type="range"]::-webkit-slider-thumb:hover {
    background: #aaa;
}

body.dark-mode input[type="range"]:active::-webkit-slider-thumb {
    background: #B2081E;
}

body.dark-mode input[type="range"]::-moz-range-thumb {
    width: 10px;
    height: 10px;
    background: #777;
    border: none;
}

body.dark-mode input[type="range"]::-moz-range-thumb:hover {
    background: #aaa;
}

body.dark-mode input[type="range"]:active::-moz-range-thumb {
    background: #B2081E;
}

body.dark-mode .mode-toggle {
    color: #777;
}

body.dark-mode .mode-toggle-switch {
    background: rgba(255, 255, 255, 0.12);
}

body.dark-mode .mode-toggle-switch::after {
    background: #777;
}

body.dark-mode .mode-toggle-switch.active {
    background: rgba(178, 8, 30, 0.3);
}

body.dark-mode .mode-toggle-switch.active::after {
    background: #B2081E;
}

body.dark-mode .motion-presets-label {
    color: #777;
}

body.dark-mode .motion-preset-btn {
    color: #666;
    border-color: rgba(255, 255, 255, 0.08);
}

body.dark-mode .motion-preset-btn:hover {
    color: #aaa;
    border-color: rgba(255, 255, 255, 0.18);
}

body.dark-mode .motion-preset-btn.active {
    color: #B2081E;
    border-color: rgba(178, 8, 30, 0.35);
    background: rgba(178, 8, 30, 0.08);
}


body.dark-mode #font-download-btn {
    filter: invert(1);
}

/* Dark mode scroll indicator removed */

/* Dark mode responsive */
@media (max-width: 1024px) {
    #gen-mode-bar {
        margin-left: 80px;
    }
}

@media (max-width: 768px) {
    #gen-mode-bar {
        margin-left: 24px;
        flex-wrap: wrap;
        gap: 10px;
    }
    
    #dark-mode-toggle {
        top: 24px;
        right: 24px;
    }
}

/* ============================================
   Custom Artistic Color Picker
   ============================================ */
.color-picker-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

.custom-color-picker {
    display: flex;
    gap: 12px;
    width: 100%;
    height: 180px;
}

.cp-area-wrap {
    flex-grow: 1;
    height: 100%;
    position: relative;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    overflow: hidden;
    background: #f5f5f5;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.cp-hue-wrap {
    width: 18px;
    height: 100%;
    position: relative;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    overflow: hidden;
    background: #f5f5f5;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.cp-area {
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

.cp-hue {
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

.cp-handle {
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 2;
}

.cp-hue-handle {
    position: absolute;
    left: -2px;
    right: -2px;
    height: 6px;
    border-radius: 3px;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transform: translateY(-50%);
    pointer-events: none;
    z-index: 2;
}

/* Tone Preset Buttons */
.tone-btn {
    background: #f5f5f5;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 6px;
    padding: 5px 14px;
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 400;
    color: #666;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tone-btn:hover {
    background: #eee;
    color: #444;
}

.tone-btn.active {
    background: #B2081E;
    color: #fff;
    border-color: #B2081E;
    font-weight: 500;
    box-shadow: 0 2px 6px rgba(178, 8, 30, 0.2);
}

body.dark-mode .tone-btn {
    background: #2a2a2a;
    border-color: rgba(255, 255, 255, 0.1);
    color: #999;
}

body.dark-mode .tone-btn:hover {
    background: #333;
    color: #ccc;
}

body.dark-mode .tone-btn.active {
    background: #B2081E;
    color: #fff;
    border-color: #B2081E;
}

/* ============================================
   Color & Material Panel
   ============================================ */
#color-material-panel {
    display: flex;
    gap: 20px;
    width: 100%;
}

.color-section {
    flex: 0.4;
    display: flex;
    flex-direction: column;
}

.material-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

.panel-label {
    font-size: 11px;
    font-weight: 500;
    color: #666;
    margin-bottom: 12px;
    display: block;
}

#hex-code-display {
    cursor: text;
    user-select: all;
    -webkit-user-select: all;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    border-radius: 4px;
    padding: 2px 4px;
    font-size: 10px;
    /* Light mode styles */
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.08);
    color: #999;
}

body.dark-mode #hex-code-display {
    background: rgba(128, 128, 128, 0.15);
    border: 1px solid rgba(128, 128, 128, 0.2);
    color: #fff;
    opacity: 0.85;
}

.material-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px 8px;
    margin-bottom: 4px;
}

.mat-preset-item, .pattern-item {
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 0;
}

.mat-thumb {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: 1px solid rgba(0,0,0,0.05);
}

.mat-preset-item span, .pattern-item span {
    font-family: 'Inter', sans-serif;
    font-size: 9px;
    color: #666;
    transition: color 0.2s ease;
}

.mat-preset-item:hover .mat-thumb, .pattern-item:hover .mat-thumb {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.mat-preset-item.active .mat-thumb, .pattern-item.active .mat-thumb {
    border: 1.3px solid #B2081E;
    box-shadow: 0 0 0 2px rgba(178, 8, 30, 0.1), 0 2px 5px rgba(0, 0, 0, 0.1);
}

.mat-preset-item.active span, .pattern-item.active span {
    color: #B2081E;
    font-weight: 500;
}

/* Material Thumb CSS Gradients */
.thumb-steel { background: linear-gradient(135deg, #ccc 0%, #eee 30%, #555 50%, #ddd 70%, #888 100%); }
.thumb-chrome { background: linear-gradient(180deg, #fff 0%, #e0e0e0 35%, #757575 49%, #212121 50%, #616161 55%, #bdbdbd 100%); }
.thumb-matte_steel { background: radial-gradient(circle at 40% 40%, #ccc 0%, #aaa 50%, #777 100%); }
.thumb-matte_metal { background: linear-gradient(135deg, #e0e0e0 0%, #9e9e9e 50%, #757575 100%); }
.thumb-hologram { background: linear-gradient(120deg, #ffccf9 0%, #b3e6ff 33%, #ccffcc 66%, #ffe6cc 100%); }
.thumb-frosted_glass { background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.9) 0%, rgba(200,200,200,0.4) 40%, rgba(150,150,150,0.1) 80%); box-shadow: inset 0 -2px 5px rgba(0,0,0,0.1), 0 2px 5px rgba(0,0,0,0.1); }
.thumb-liquid { background: radial-gradient(circle at 30% 30%, #fff 0%, rgba(255,255,255,0.2) 30%, transparent 100%); border: 1px solid rgba(0,0,0,0.1); }
.thumb-jelly { background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.4) 0%, #ffcdd2 30%, #e57373 100%); }
.thumb-balloon { background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.8) 0%, #ffcdd2 30%, #e57373 100%); }
.thumb-concrete { background: #999 url('data:image/svg+xml;utf8,%3Csvg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"%3E%3Cfilter id="n"%3E%3CfeTurbulence type="fractalNoise" baseFrequency="0.3" numOctaves="3" stitchTiles="stitch"/%3E%3C/filter%3E%3Crect width="200" height="200" filter="url(%23n)" opacity="0.5"/%3E%3C/svg%3E') center / 150%; }
.thumb-ceramic { background: radial-gradient(circle at 25% 25%, #ffffff 0%, #f5f5f5 30%, #e0e0e0 70%, #bdbdbd 100%); box-shadow: inset -2px -2px 6px rgba(0,0,0,0.1); }
.thumb-plastic { background: radial-gradient(circle at 30% 30%, #e0e0e0 0%, #9e9e9e 40%, #616161 100%); }
.thumb-wood { background: repeating-linear-gradient(45deg, #8d6e63 0px, #8d6e63 2px, #795548 2px, #795548 4px); }
.thumb-velvet { background: radial-gradient(circle at center, #d81b60 0%, #880e4f 100%); }
.thumb-fabric { background: repeating-linear-gradient(0deg, #bdbdbd 0px, #bdbdbd 1px, #9e9e9e 1px, #9e9e9e 2px); }
.thumb-fur { background: radial-gradient(circle at 50% 50%, #8d6e63 0%, #5d4037 100%); border: 1px dashed rgba(0,0,0,0.2); }
.thumb-foam { background: radial-gradient(circle at 50% 50%, #eeeeee 0%, #bdbdbd 100%); border: 1px dotted rgba(0,0,0,0.2); }

/* Dark mode adjustments for Color & Material */
body.dark-mode .cp-area-wrap,
body.dark-mode .cp-hue-wrap {
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: #2a2a2a;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

body.dark-mode .material-section {
}

body.dark-mode .panel-label { color: #aaa; }
body.dark-mode .mat-preset-item span { color: #888; }
body.dark-mode .mat-preset-item.active span { color: #B2081E; }

/* ============================================
   Advanced Tabs UI
   ============================================ */
#advanced-panels {
    width: 100%;
    display: flex;
    flex-direction: column;
    height: 230px;
}

.panel-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    border-bottom: 1px solid rgba(0,0,0,0.08);
    padding-bottom: 8px;
    overflow-x: auto;
    flex-shrink: 0;
}

.tab-btn {
    background: none;
    border: none;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 500;
    color: #888;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 6px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.tab-btn:hover {
    background: rgba(0,0,0,0.03);
    color: #444;
}

.tab-btn.active {
    background: #B2081E;
    color: #fff;
    box-shadow: 0 2px 6px rgba(178, 8, 30, 0.2);
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
    flex: 1;
    overflow-y: auto;
    padding-top: 8px;
    padding-bottom: 8px;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

#geometry-panel, #lighting-panel {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 16px;
}

.mod-preset-btn, .hdri-preset-btn {
    background: #f5f5f5;
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 6px;
    padding: 6px 12px;
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    color: #666;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mod-preset-btn:hover, .hdri-preset-btn:hover {
    background: #eee;
}

.mod-preset-btn.active, .hdri-preset-btn.active {
    background: #333;
    color: #fff;
    border-color: #333;
}

#box-picker .IroBox {
    height: 120px !important;
}
#box-picker svg {
    height: 120px !important;
}

/* ============================================
   Slider Tooltip
   ============================================ */
.slider-tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    color: #444;
    font-family: 'Inter', sans-serif;
    font-size: 10px;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 4px;
    pointer-events: none;
    transform: translate(-50%, -100%) translateY(-6px);
    z-index: 99999;
    opacity: 0;
    transition: opacity 0.15s ease, transform 0.1s ease;
    white-space: nowrap;
}

body.dark-mode .slider-tooltip {
    background: rgba(255, 255, 255, 0.08);
    color: #ddd;
}

.slider-tooltip.show {
    opacity: 1;
}

/* Export Button & Dropdown Styles */
.export-dropdown-container {
    position: relative;
    display: inline-block;
    margin-left: 10px;
}

.export-btn {
    background: transparent;
    border: 1px solid rgba(0, 0, 0, 0.15);
    color: #999;
    font-family: 'Inter', sans-serif;
    font-size: 12.5px;
    font-weight: 500;
    height: 38px;
    padding: 0 12px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    letter-spacing: 0.02em;
}

body.dark-mode .export-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #888;
}

.export-btn:hover {
    background: rgba(0, 0, 0, 0.04);
    color: #444;
}

body.dark-mode .export-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #eee;
}

.export-icon {
    width: 23px;
    height: 23px;
    opacity: 1;
}


.chevron-icon {
    opacity: 0.5;
}

.export-menu {
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 8px;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    padding: 8px;
    width: 200px;
    display: none;
    flex-direction: column;
    gap: 4px;
    z-index: 1000;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.export-options-group {
    display: flex;
    align-items: center;
    padding: 4px 8px;
    gap: 4px;
}

.options-label {
    font-size: 11px;
    color: #888;
    font-weight: 500;
    width: 28px;
    margin-right: 4px;
}

.opt-btn {
    background: #f5f5f5;
    border: 1px solid transparent;
    border-radius: 4px;
    font-size: 10px;
    padding: 2px 6px;
    color: #666;
    cursor: pointer;
    transition: all 0.15s ease;
    flex: 1;
}

.opt-btn:hover {
    background: #eaeaea;
}

.opt-btn.active {
    background: #fff;
    border-color: #ddd;
    color: #222;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.bg-swatches {
    display: flex;
    gap: 8px;
    align-items: center;
    flex: 1;
}

.bg-swatch {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.bg-swatch[data-bg="transparent"] {
    background: repeating-conic-gradient(#ddd 0% 25%, #fff 0% 50%) 50% / 8px 8px;
}

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

.bg-swatch.active {
    transform: scale(1.1);
    box-shadow: 0 0 0 2px #fff inset, 0 0 0 4px #333 inset, 0 2px 5px rgba(0,0,0,0.2);
}

.bg-swatch.disabled {
    opacity: 0.3;
    pointer-events: none;
    filter: grayscale(100%);
}

.export-divider {
    height: 1px;
    background: #eee;
    margin: 4px 0;
}

.dark-mode .opt-btn {
    background: #333;
    color: #aaa;
}
.dark-mode .opt-btn:hover {
    background: #444;
}
.dark-mode .opt-btn.active {
    background: #222;
    border-color: #555;
    color: #eee;
}
.dark-mode .bg-swatch.active {
    box-shadow: 0 0 0 2px #222 inset, 0 0 0 4px #eee inset, 0 2px 5px rgba(0,0,0,0.5);
}
.dark-mode .export-divider {
    background: #333;
}

.export-menu.show {
    display: flex;
    opacity: 1;
    transform: translateY(0);
}

.dark-mode .export-menu {
    background: #222;
    border-color: #333;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}

.export-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease;
}

.export-item:hover {
    background: #f0f0f0;
}

.dark-mode .export-item:hover {
    background: #333;
}

.export-item-icon {
    font-size: 18px;
}

.export-item-text {
    display: flex;
    flex-direction: column;
}

.export-item-text strong {
    font-size: 13px;
    color: #222;
}

body.dark-mode .export-item-text strong {
    color: #eee;
}

body.dark-mode .export-item-icon {
    color: #aaa;
}

.export-item-text span {
    font-size: 11px;
    color: #888;
}

body.dark-mode .export-item-text span {
    color: #bbb;
}

/* Export Overlay */
#export-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    font-family: sans-serif;
}

#export-cancel {
    position: absolute;
    top: 20px;
    left: 20px;
    background: transparent;
    border: none;
    color: white;
    font-size: 32px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
    z-index: 10000;
}
#export-cancel:hover {
    opacity: 1.0;
}

.export-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top: 4px solid #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#export-status {
    font-size: 16px;
    font-weight: 500;
    letter-spacing: 1px;
}

/* ============================================
   Mobile UI Enhancements (Based on User Feedback)
   ============================================ */
@media (max-width: 768px) {
    body {
        zoom: 1 !important;
    }
    /* 1 & 3. 탭 메뉴 2열 배치 및 상단 고정 (Sticky Header) */
    #advanced-panels {
        height: auto;
        flex: 1;
        display: flex;
        flex-direction: column;
    }
    .panel-tabs {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 6px;
        position: sticky;
        top: 0;
        z-index: 200;
        background: #ffffff;
        padding-top: 8px;
        padding-bottom: 8px;
        margin-bottom: 8px;
    }
    body.dark-mode .panel-tabs {
        background: #181818;
    }
    .tab-btn {
        text-align: center;
        padding: 8px;
        white-space: normal;
    }

    /* 2. 컬러/패턴/메테리얼 세로 배치 & 가로 스크롤 제거 */
    #color-material-panel, .color-pattern-panel {
        flex-direction: column !important;
        gap: 24px;
    }
    .color-section, .material-section {
        flex: none;
        width: 100%;
    }
    
    /* 3. 메테리얼 아이콘 4열로 축소 */
    .material-grid {
        grid-template-columns: repeat(4, 1fr) !important;
    }

    /* 4. 모션 메뉴 확실한 줄바꿈 (flex-wrap 강제) */
    #gen-mode-bar {
        flex-wrap: wrap !important;
    }
    .motion-presets {
        flex-wrap: wrap !important;
        justify-content: flex-start;
        width: 100%;
    }
    .motion-preset-btn {
        flex: 1 1 auto;
        text-align: center;
    }

    /* 5. 메인 화면 상단 겹침 방지 및 글자 확대 */
    #typography-grid {
        margin-top: 100px;
        padding-left: 0 !important;
    }
    .row-1 .letter { font-size: clamp(65px, 18vw, 130px) !important; margin: 0 clamp(8px, 1.2vw, 20px) !important; }
    .row-2 .letter { font-size: clamp(55px, 15vw, 115px) !important; margin: 0 clamp(6px, 1vw, 16px) !important; }
    .row-3 .letter { font-size: clamp(50px, 14vw, 105px) !important; margin: 0 clamp(4px, 0.8vw, 14px) !important; }
    .row-4 .letter { font-size: clamp(45px, 13vw, 95px) !important; margin: 0 clamp(4px, 0.8vw, 14px) !important; }
    
    /* Font Download Mobile override: Not a drawer, just a static section */
    #font-drawer {
        position: relative !important;
        transform: none !important;
        width: 100vw !important;
        max-width: 100vw !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        left: 50% !important;
        margin-left: -50vw !important;
        bottom: auto !important;
        margin-top: 60px !important;
        margin-bottom: 0 !important;
        margin-right: 0 !important;
    }
    
    .drawer-header {
        display: none !important;
    }
    
    .drawer-content {
        padding-top: 40px !important;
        padding-bottom: 60px !important; 
    }

    /* Smaller text sizes for mobile */
    .drawer-title-main { font-size: 26px !important; }
    .drawer-title-sub { font-size: 19px !important; }
    .drawer-desc { font-size: 12px !important; margin: 16px 0 24px 0 !important; }
}



/* ============================================
   Font Download Drawer
   ============================================ */
#font-drawer {
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 840px;
    max-width: 90vw;
    background: #B2081E;
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.15);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 200;
    display: flex;
    flex-direction: column;
    padding-bottom: env(safe-area-inset-bottom, 20px);
    transform: translateX(-50%);
    overflow: hidden;
}

#font-drawer.drawer-closed {
    transform: translateX(-50%) translateY(calc(100% - 28px));
}

#font-drawer.drawer-closed:hover {
    transform: translateX(-50%) translateY(calc(100% - 38px));
}

#font-drawer.drawer-open {
    transform: translateX(-50%) translateY(0);
}

.drawer-header {
    width: 100%;
    height: 28px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-sizing: border-box;
}

#drawer-header-icon {
    background: transparent;
    border: none;
    color: #ffffff;
    padding: 0;
    transition: color 0.2s;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}
#drawer-arrow-svg {
    width: 18px !important;
    height: 18px !important;
}
.drawer-header:hover #drawer-header-icon {
    color: rgba(255, 255, 255, 0.6);
}

.drawer-content {
    padding: 60px 24px 200px 24px;
    max-width: 840px;
    margin: 0 auto;
    width: 100%;
}

.drawer-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.drawer-title {
    font-size: 18px;
    font-weight: 700;
    color: #ffffff;
    margin: 0;
}

.drawer-asset-card {
    display: flex;
    align-items: center;
    gap: 20px;
    background: transparent;
}

.asset-thumb {
    width: 48px;
    height: 48px;
    background: #FEE9EB;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.asset-thumb-icon {
    color: #B2081E;
    font-size: 20px;
    font-weight: 600;
    font-family: serif;
}

.asset-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.asset-name-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.asset-name {
    font-size: 18px;
    font-weight: 600;
    color: #ffffff;
}

.asset-tags {
    display: flex;
    gap: 6px;
}

.asset-tag {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
}

.asset-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-download {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #ffffff;
    color: #B2081E;
    font-size: 15px;
    font-weight: 600;
    padding: 12px 24px;
    border-radius: 8px;
    text-decoration: none;
    transition: background 0.2s, transform 0.1s;
}
.btn-download:hover { background: #f2f2f2; }
.btn-download:active { transform: scale(0.98); }

body.dark-mode #font-drawer { background: #B2081E; box-shadow: 0 -10px 40px rgba(0,0,0,0.4); border-top: none; }
body.dark-mode .drawer-title { color: #ffffff; }
body.dark-mode .drawer-asset-card { background: transparent; }
body.dark-mode .asset-name { color: #ffffff; }
body.dark-mode .asset-tag { background: rgba(255,255,255,0.2); color: #ffffff; }



#hex-code-display:focus {
    outline: 1.5px solid #B2081E !important;
    background: #fff;
    color: #333;
}
body.dark-mode #hex-code-display:focus {
    color: #fff;
}

/* Custom Material Dropdown Styles */
.custom-mat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    font-size: 11px;
    color: inherit;
    cursor: pointer;
    background: transparent;
    border: none;
    text-align: left;
    width: 100%;
    transition: background 0.2s;
}
.custom-mat-item:hover {
    background: rgba(128,128,128,0.2);
}
.custom-mat-item .del-btn {
    font-size: 12px;
    opacity: 0.5;
    transition: opacity 0.2s;
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
}
.custom-mat-item .del-btn:hover {
    opacity: 1;
    color: #ff4d4d;
}

/* Dark mode adjustments for popover */
body.dark-mode #custom-mat-popover {
    background: #181818;
    border-color: rgba(255,255,255,0.1);
}
body.dark-mode #custom-mat-toggle {
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.1);
}
