/* ==========================================================================
   Particle Architect — Replit-Quality Dark Theme
   Design tokens, reset, layout, components, animations, responsive
   ========================================================================== */

/* ==================== GOOGLE FONTS (loaded in HTML) ==================== */
/* Inter is loaded via <link> in index.html */

/* ==================== DESIGN TOKENS ==================== */
:root {
    /* Background */
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-elevated: #1c2128;
    --bg-surface: #21262d;
    --bg-overlay: rgba(13, 17, 23, 0.85);

    /* Borders */
    --border: rgba(255, 255, 255, 0.08);
    --border-muted: rgba(255, 255, 255, 0.04);
    --border-emphasis: rgba(255, 255, 255, 0.14);

    /* Text */
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-tertiary: #6e7681;
    --text-placeholder: #484f58;

    /* Accent */
    --accent: #58a6ff;
    --accent-emphasis: #79c0ff;
    --accent-muted: rgba(88, 166, 255, 0.15);
    --accent-subtle: rgba(88, 166, 255, 0.08);

    /* Semantic */
    --accent-green: #3fb950;
    --accent-green-muted: rgba(63, 185, 80, 0.15);
    --accent-red: #f85149;
    --accent-red-muted: rgba(248, 81, 73, 0.15);
    --accent-purple: #bc8cff;
    --accent-purple-muted: rgba(188, 140, 255, 0.15);
    --accent-yellow: #d29922;
    --accent-yellow-muted: rgba(210, 153, 34, 0.15);

    /* Layout */
    --sidebar-width: 280px;
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
    --shadow-inset: inset 0 1px 0 rgba(255, 255, 255, 0.04);

    /* Typography */
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, monospace;

    /* Transitions */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
    --duration-fast: 150ms;
    --duration-normal: 200ms;
    --duration-slow: 300ms;
}

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

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

body {
    overflow: hidden;
    background: var(--bg-primary);
    font-family: var(--font);
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-primary);
    display: flex;
    height: 100vh;
    height: 100dvh;
}

/* ==================== FOCUS STATES ==================== */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

:focus:not(:focus-visible) {
    outline: none;
}

/* ==================== SCROLLBAR ==================== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

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

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.18);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

/* ==================== DRAWER TAB PULSE — PARAMS 알림 (2026-04-26) ==================== */
.drawer-tab-pulse:not(.active)::before {
    content: '';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #ff6b35;
    box-shadow: 0 0 0 0 rgba(255, 107, 53, 0.7);
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 107, 53, 0.7);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(255, 107, 53, 0);
        transform: scale(1.2);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 107, 53, 0);
        transform: scale(1);
    }
}

.drawer-tab-pulse:not(.active) {
    color: #ff6b35 !important;
    animation: tab-glow 3s ease-in-out infinite;
}

@keyframes tab-glow {
    0%, 100% { background: rgba(255, 107, 53, 0.04); }
    50% { background: rgba(255, 107, 53, 0.12); }
}

/* PRESET 카드 스타일 (300 시나리오 그리드) */
.preset-card {
    padding: 7px 9px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10.5px;
    line-height: 1.3;
}

.preset-card:hover {
    background: rgba(0, 212, 255, 0.08);
    border-color: rgba(0, 212, 255, 0.3);
    transform: translateX(2px);
}

.preset-card-icon {
    font-size: 14px;
    flex-shrink: 0;
}

.preset-card-title {
    flex: 1;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.preset-card-stars {
    color: #ffd700;
    font-size: 9px;
    flex-shrink: 0;
}

.preset-cat-btn:hover {
    background: rgba(0, 212, 255, 0.1) !important;
    border-color: rgba(0, 212, 255, 0.3) !important;
    color: var(--text-primary) !important;
}

/* ==================== SIDEBAR ==================== */
#sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100vh;
    height: 100dvh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 20;
    position: relative;
}

/* Glass stripe on right edge */
#sidebar::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 1px;
    height: 100%;
    background: linear-gradient(180deg,
        rgba(88, 166, 255, 0.0) 0%,
        rgba(88, 166, 255, 0.12) 30%,
        rgba(88, 166, 255, 0.12) 70%,
        rgba(88, 166, 255, 0.0) 100%);
    pointer-events: none;
}

/* ==================== SIDEBAR HEADER ==================== */
#sidebar-header {
    padding: 20px 16px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-shrink: 0;
    background: var(--bg-secondary);
    position: relative;
}

#sidebar-header h1 {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 3px;
    line-height: 1.5;
    color: var(--text-primary);
    user-select: none;
}

#header-controls {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

#lang-toggle {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.5px;
    padding: 4px 10px;
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all var(--duration-fast) var(--ease-in-out);
}

#lang-toggle:hover {
    background: var(--bg-surface);
    border-color: var(--border-emphasis);
    color: var(--text-primary);
}

#lang-toggle:active {
    transform: scale(0.97);
}

/* ==================== SERVER INDICATOR ==================== */
#server-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.5px;
    color: var(--text-tertiary);
}

#server-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent-red);
    box-shadow: 0 0 6px rgba(248, 81, 73, 0.5);
    flex-shrink: 0;
    transition: all var(--duration-normal) var(--ease-in-out);
}

#server-dot.online {
    background: var(--accent-green);
    box-shadow: 0 0 6px rgba(63, 185, 80, 0.5);
    animation: pulse-dot 2.5s ease-in-out infinite;
}

#server-label {
    white-space: nowrap;
}

@keyframes pulse-dot {
    0%, 100% {
        box-shadow: 0 0 6px rgba(63, 185, 80, 0.5);
    }
    50% {
        box-shadow: 0 0 10px rgba(63, 185, 80, 0.8);
    }
}

/* ==================== NEW CARD BUTTON ==================== */
#new-card-btn {
    width: calc(100% - 32px);
    margin: 12px 16px;
    padding: 10px 16px;
    background: var(--accent-subtle);
    border: 1px dashed rgba(88, 166, 255, 0.2);
    border-radius: var(--radius-md);
    color: var(--accent);
    font-family: var(--font);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-out);
    flex-shrink: 0;
}

#new-card-btn:hover {
    background: var(--accent-muted);
    border-color: rgba(88, 166, 255, 0.35);
    box-shadow: 0 0 16px rgba(88, 166, 255, 0.08);
}

#new-card-btn:active {
    transform: scale(0.98);
}

/* ==================== CARD LIST ==================== */
#card-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 8px;
    min-height: 0;
}

.sim-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 12px 14px;
    margin-bottom: 4px;
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-out);
    position: relative;
    animation: card-enter 0.25s var(--ease-out);
}

@keyframes card-enter {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.sim-card:hover {
    background: var(--bg-surface);
    border-color: var(--border-emphasis);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.sim-card.active {
    background: var(--accent-subtle);
    border-color: rgba(88, 166, 255, 0.3);
    box-shadow: 0 0 0 1px rgba(88, 166, 255, 0.1), var(--shadow-sm);
}

.sim-card .card-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 50px;
    line-height: 1.4;
}

.sim-card.active .card-name {
    color: var(--accent-emphasis);
    animation: none;
}

.sim-card .card-prompt {
    font-size: 11px;
    color: var(--text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 8px;
    line-height: 1.4;
}

.sim-card .card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: var(--text-tertiary);
}

.sim-card .card-tags {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.card-tag {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1px 6px;
    font-size: 10px;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.2px;
}

.sim-card.active .card-tag {
    background: var(--accent-muted);
    border-color: rgba(88, 166, 255, 0.2);
    color: var(--accent);
}

.sim-card .card-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity var(--duration-fast) var(--ease-in-out);
}

.sim-card:hover .card-actions {
    opacity: 1;
}

.card-action-btn {
    background: var(--bg-primary);
    border: 1px solid var(--border-emphasis);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 11px;
    width: 24px;
    height: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--duration-fast) var(--ease-in-out);
    font-family: var(--font);
}

.card-action-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-subtle);
}

.card-action-btn.delete:hover {
    color: var(--accent-red);
    border-color: var(--accent-red);
    background: var(--accent-red-muted);
}

/* ==================== CARD DETAIL PANEL ==================== */
#card-detail {
    border-top: 1px solid var(--border);
    overflow: hidden;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

#card-detail.hidden {
    display: none;
}

#detail-divider {
    padding: 8px 16px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1.5px;
    color: var(--text-tertiary);
    text-align: center;
    text-transform: uppercase;
    background: linear-gradient(90deg,
        transparent,
        rgba(88, 166, 255, 0.06),
        transparent);
    border-bottom: 1px solid var(--border-muted);
}

/* ==================== SECTION TITLES (collapsible) ==================== */
.section-title {
    padding: 10px 16px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1px;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid var(--border-muted);
    transition: all var(--duration-fast) var(--ease-in-out);
    text-transform: uppercase;
}

.section-title:hover {
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-primary);
}

.toggle-icon {
    font-size: 8px;
    transition: transform var(--duration-normal) var(--ease-out);
    display: inline-flex;
    color: var(--text-tertiary);
}

.section-title.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

/* ==================== PARAM SECTIONS ==================== */
#physics-params,
#env-params,
#material-params,
#hazard-params,
#visual-params,
#material-select-params,
#contribute-params {
    padding: 10px 16px 14px;
    overflow: hidden;
    transition: max-height var(--duration-slow) var(--ease-out),
                opacity var(--duration-normal) var(--ease-in-out),
                padding var(--duration-slow) var(--ease-out);
}

#physics-params.collapsed,
#env-params.collapsed,
#material-params.collapsed,
#hazard-params.collapsed,
#visual-params.collapsed,
#material-select-params.collapsed,
#contribute-params.collapsed {
    max-height: 0 !important;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    overflow: hidden;
}

/* ==================== PARAMETER GROUPS ==================== */
.param-group {
    display: grid;
    grid-template-columns: 78px 1fr 48px;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.param-group label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.param-value {
    font-size: 11px;
    font-weight: 500;
    text-align: right;
    color: var(--text-tertiary);
    font-variant-numeric: tabular-nums;
    font-family: var(--font-mono);
    letter-spacing: -0.3px;
}

/* ==================== RANGE INPUTS ==================== */
.param-group input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: var(--bg-surface);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease-in-out);
}

.param-group input[type="range"]:hover {
    background: rgba(255, 255, 255, 0.12);
}

.param-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 2px solid var(--bg-secondary);
    box-shadow: 0 0 0 0 rgba(88, 166, 255, 0);
    transition: all var(--duration-fast) var(--ease-in-out);
}

.param-group input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 0 0 4px rgba(88, 166, 255, 0.2);
}

.param-group input[type="range"]:active::-webkit-slider-thumb {
    transform: scale(1.05);
    box-shadow: 0 0 0 6px rgba(88, 166, 255, 0.25);
}

/* Firefox range */
.param-group input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 2px solid var(--bg-secondary);
    transition: all var(--duration-fast) var(--ease-in-out);
}

.param-group input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 0 0 4px rgba(88, 166, 255, 0.2);
}

.param-group input[type="range"]::-moz-range-track {
    background: var(--bg-surface);
    height: 4px;
    border-radius: 2px;
    border: none;
}

/* ==================== SELECT INPUTS ==================== */
select,
#visual-params select {
    width: 100%;
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 6px 10px;
    font-size: 12px;
    font-family: var(--font);
    font-weight: 500;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-in-out);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b949e' d='M3 4.5L6 8l3-3.5H3z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 28px;
}

select:hover,
#visual-params select:hover {
    border-color: var(--border-emphasis);
    background-color: var(--bg-surface);
}

select:focus,
#visual-params select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

select option {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

/* ==================== COLOR INPUTS ==================== */
.param-group input[type="color"] {
    width: 100%;
    height: 28px;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    cursor: pointer;
    border-radius: var(--radius-md);
    padding: 2px;
    transition: border-color var(--duration-fast) var(--ease-in-out);
}

.param-group input[type="color"]:hover {
    border-color: var(--border-emphasis);
}

.param-group input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.param-group input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: var(--radius-sm);
}

/* ==================== TEXT INPUTS ==================== */
.text-input {
    width: 100%;
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 8px 10px;
    font-size: 12px;
    font-family: var(--font);
    border-radius: var(--radius-md);
    resize: vertical;
    transition: all var(--duration-fast) var(--ease-in-out);
}

.text-input:hover {
    border-color: var(--border-emphasis);
}

.text-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

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

textarea.text-input {
    min-height: 64px;
    line-height: 1.5;
}

/* ==================== MATERIAL INFO ==================== */
.info-box {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 8px 10px;
    margin: 6px 0 10px;
    font-size: 11px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
    color: var(--text-secondary);
}

.info-row span:first-child {
    font-family: var(--font-mono);
    font-style: italic;
    min-width: 24px;
    color: var(--accent);
    font-weight: 500;
}

/* ==================== CONTRIBUTE SECTION ==================== */
.contribute-desc {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.6;
}

#contrib-submit-btn {
    width: 100%;
    padding: 10px 16px;
    margin-top: 10px;
    background: var(--accent-subtle);
    border: 1px solid rgba(88, 166, 255, 0.2);
    color: var(--accent);
    font-family: var(--font);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all var(--duration-normal) var(--ease-out);
}

#contrib-submit-btn:hover {
    background: var(--accent-muted);
    border-color: rgba(88, 166, 255, 0.35);
    box-shadow: 0 0 12px rgba(88, 166, 255, 0.08);
}

#contrib-submit-btn:active {
    transform: scale(0.98);
}

#contrib-status {
    font-size: 11px;
    margin-top: 8px;
    color: var(--accent-green);
    min-height: 16px;
    font-weight: 500;
}

/* ==================== AI CHAT ==================== */
#chat-section {
    border-top: 1px solid var(--border-muted);
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

#chat-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    height: 100%;
}

#chat-container.collapsed {
    display: none;
}

#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 6px 8px;
    scroll-behavior: smooth;
}

/* 2026-04-26: 사용자 보고 — 좌측 채팅 너무 크고 공백 많음.
   캔버스 공간 최대화 위해 컴팩트화 */
.chat-msg {
    margin-bottom: 4px;
    padding: 6px 9px;
    border-radius: var(--radius-md);
    font-size: 10.5px;
    line-height: 1.45;
    max-width: 96%;
    /* AI 답변이 너무 길면 3줄까지만 보이고 펼치기 (컴팩트 배너) */
    max-height: calc(1.45em * 3 + 12px);
    overflow: hidden;
    position: relative;
    transition: max-height 0.2s ease;
    animation: msg-enter 0.2s var(--ease-out);
    word-wrap: break-word;
    cursor: pointer;
}

.chat-msg.expanded {
    max-height: 800px;
}

/* 3줄 후 fade-out 효과 (펼치기 힌트) */
.chat-msg:not(.expanded)::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 16px;
    background: linear-gradient(180deg, transparent, var(--bg-secondary));
    pointer-events: none;
}

.chat-msg.expanded::after {
    display: none;
}

/* 사용자 메시지(짧음) 는 펼침 효과 없음 */
.chat-msg.user {
    max-height: none;
    overflow: visible;
}
.chat-msg.user::after {
    display: none;
}

@keyframes msg-enter {
    from {
        opacity: 0;
        transform: translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-msg.user {
    background: var(--accent-subtle);
    border: 1px solid rgba(88, 166, 255, 0.15);
    color: var(--text-primary);
    margin-left: auto;
    border-bottom-right-radius: var(--radius-sm);
}

.chat-msg.assistant {
    background: var(--accent-green-muted);
    border: 1px solid rgba(63, 185, 80, 0.15);
    color: var(--text-primary);
    border-bottom-left-radius: var(--radius-sm);
}

.chat-msg.streaming-message {
    border-style: dashed;
    white-space: pre-wrap;
    word-break: break-word;
}

.streaming-cursor {
    color: var(--accent-green);
    animation: blink 0.8s step-end infinite;
    font-size: 0.9em;
}

.chat-msg.system {
    background: var(--accent-purple-muted);
    border: 1px solid rgba(188, 140, 255, 0.12);
    color: var(--accent-purple);
    font-size: 11px;
    text-align: center;
    max-width: 100%;
    font-weight: 500;
}

@keyframes blink {
    50% { opacity: 0; }
}

#chat-input-area {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--border-muted);
    background: var(--bg-secondary);
}

#chat-input {
    flex: 1;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    font-family: var(--font);
    font-size: 12px;
    color: var(--text-primary);
    outline: none;
    transition: all var(--duration-fast) var(--ease-in-out);
}

#chat-input::placeholder {
    color: var(--text-placeholder);
}

#chat-input:hover {
    border-color: var(--border-emphasis);
}

#chat-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

#chat-send-btn {
    background: var(--accent);
    border: none;
    border-radius: var(--radius-md);
    color: var(--bg-primary);
    width: 36px;
    height: 36px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-in-out);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#chat-send-btn:hover {
    background: var(--accent-emphasis);
    box-shadow: 0 2px 8px rgba(88, 166, 255, 0.3);
}

#chat-send-btn:active {
    transform: scale(0.93);
}

/* ==================== WELCOME SUGGESTIONS ==================== */
.welcome-suggestions {
    padding: 16px;
    text-align: center;
}

.welcome-title {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 12px;
}

.suggestion-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.suggestion-chip {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font);
}

.suggestion-chip:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    transform: translateY(-1px);
}

.suggestion-chip:active {
    transform: translateY(0) scale(0.97);
}

/* ==================== MAIN CONTENT ==================== */
#main-content {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-primary);
}

/* ==================== TOP BAR ==================== */
#top-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    pointer-events: none;
    background: linear-gradient(180deg,
        rgba(13, 17, 23, 0.7) 0%,
        rgba(13, 17, 23, 0) 100%);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

#stats {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

#stats span {
    margin-right: 0;
}

#particle-count {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--text-primary);
    font-size: 13px;
}

#fps-counter {
    font-family: var(--font-mono);
    color: var(--text-tertiary);
    font-size: 11px;
    font-weight: 500;
}

#quality-badge {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.5px;
    cursor: pointer;
    pointer-events: auto;
    transition: all var(--duration-fast) var(--ease-in-out);
    text-transform: uppercase;
}

#quality-badge:hover {
    border-color: var(--border-emphasis);
    background: var(--bg-surface);
}

#quality-badge.low {
    color: var(--accent-yellow);
    border-color: rgba(210, 153, 34, 0.3);
    background: var(--accent-yellow-muted);
}

#quality-badge.medium {
    color: var(--accent);
    border-color: rgba(88, 166, 255, 0.3);
    background: var(--accent-muted);
}

#quality-badge.high {
    color: var(--accent-green);
    border-color: rgba(63, 185, 80, 0.3);
    background: var(--accent-green-muted);
}

#status-bar {
    display: flex;
    gap: 16px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-tertiary);
}

#status {
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 11px;
}

#structure-info {
    font-family: var(--font-mono);
    font-size: 10px;
}

/* ==================== CANVAS CONTAINER ==================== */
#canvas-container {
    flex: 1;
    position: relative;
}

/* Subtle inner shadow for depth */
#canvas-container::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.3);
    z-index: 1;
}

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

/* ==================== BOTTOM PANEL ==================== */
#bottom-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
    padding: 0 20px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
    background: linear-gradient(0deg,
        rgba(13, 17, 23, 0.7) 0%,
        rgba(13, 17, 23, 0) 100%);
}

#prompt-panel {
    display: flex;
    gap: 10px;
    pointer-events: auto;
    width: 100%;
    max-width: 640px;
    margin-bottom: 8px;
}

#prompt-input {
    flex: 1;
    background: rgba(22, 27, 34, 0.9);
    border: 1px solid var(--border-emphasis);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    outline: none;
    transition: all var(--duration-normal) var(--ease-out);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

#prompt-input::placeholder {
    color: var(--text-placeholder);
    font-weight: 400;
}

#prompt-input:hover {
    border-color: rgba(255, 255, 255, 0.18);
}

#prompt-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle), var(--shadow-md);
}

#generate-btn {
    background: var(--accent);
    border: none;
    border-radius: var(--radius-lg);
    padding: 12px 24px;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    color: var(--bg-primary);
    cursor: pointer;
    letter-spacing: 0.5px;
    transition: all var(--duration-normal) var(--ease-out);
    pointer-events: auto;
    white-space: nowrap;
}

#generate-btn:hover {
    background: var(--accent-emphasis);
    box-shadow: 0 4px 16px rgba(88, 166, 255, 0.3);
    transform: translateY(-1px);
}

#generate-btn:active {
    transform: scale(0.97) translateY(0);
    box-shadow: 0 2px 8px rgba(88, 166, 255, 0.2);
}

#controls-hint {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    font-size: 11px;
    color: var(--text-tertiary);
    opacity: 0.4;
    letter-spacing: 0.3px;
    pointer-events: none;
    white-space: nowrap;
}

/* ==================== VR BUTTON ==================== */
#VRButton {
    font-family: var(--font) !important;
    border: 1px solid var(--border-emphasis) !important;
    color: var(--text-primary) !important;
    background: var(--bg-elevated) !important;
    border-radius: var(--radius-md) !important;
    font-weight: 500 !important;
}

/* ==================== HISTORY ==================== */
#history-section { margin-top: 8px; }

#history-list-container {
    padding: 4px 8px;
    overflow: hidden;
    transition: max-height var(--duration-slow) var(--ease-out),
                opacity var(--duration-normal) var(--ease-in-out);
}

#history-list-container.collapsed {
    max-height: 0 !important;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    overflow: hidden;
}

.history-item {
    padding: 10px 12px;
    border-radius: 6px;
    background: var(--bg-elevated);
    margin-bottom: 4px;
    cursor: pointer;
    transition: all var(--duration-fast);
    border: 1px solid transparent;
}
.history-item:hover {
    background: var(--bg-surface);
    border-color: var(--border);
    transform: translateY(-1px);
}
.history-item-title {
    font-weight: 500;
    font-size: 13px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.history-item-meta {
    display: flex;
    justify-content: space-between;
    margin-top: 4px;
    font-size: 11px;
    color: var(--text-secondary);
}
.history-domain {
    background: rgba(88,166,255,0.15);
    color: var(--accent);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 10px;
    text-transform: uppercase;
}
.history-item-query {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.badge {
    background: var(--accent);
    color: var(--bg-primary);
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 8px;
    margin-left: 8px;
}

#load-more-history {
    width: 100%;
    padding: 8px 16px;
    margin-top: 4px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all var(--duration-fast) var(--ease-in-out);
}

#load-more-history:hover {
    background: var(--bg-surface);
    border-color: var(--border-emphasis);
    color: var(--text-primary);
}

/* ==================== SKELETON SHIMMER ==================== */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.skeleton {
    background: linear-gradient(90deg,
        var(--bg-elevated) 25%,
        var(--bg-surface) 50%,
        var(--bg-elevated) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-md);
}

/* ==================== LANDING PAGE ==================== */
#landing-page {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: #0d1117;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.6s ease, visibility 0.6s ease;
}

#landing-page.hidden {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

#landing-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

#landing-content {
    position: relative;
    z-index: 1;
    text-align: center;
    max-width: 640px;
    padding: 20px;
}

/* ========== LANDING EXTRA — 앱 소개 + 광고 (2026-04-26) ========== */
#landing-page {
    /* 스크롤 가능하게 */
    overflow-y: auto !important;
}

.landing-extra {
    margin-top: 60px;
    padding-top: 40px;
    border-top: 1px solid rgba(230, 237, 243, 0.08);
    text-align: left;
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
}

.landing-intro-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    margin-bottom: 30px;
}

.landing-intro-card {
    padding: 18px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    transition: border-color 0.2s, background 0.2s;
}

.landing-intro-card:hover {
    border-color: rgba(101, 93, 255, 0.4);
    background: rgba(101, 93, 255, 0.05);
}

.landing-intro-icon {
    font-size: 28px;
    margin-bottom: 8px;
}

.landing-intro-card h3 {
    font-size: 14px;
    font-weight: 600;
    color: #e6edf3;
    margin: 0 0 4px;
}

.landing-intro-card p {
    font-size: 12px;
    color: rgba(230, 237, 243, 0.6);
    line-height: 1.5;
    margin: 0;
}

.landing-intro-card a {
    color: #00d4ff;
    text-decoration: none;
}

.landing-intro-card a:hover {
    text-decoration: underline;
}

.landing-ad-slot {
    margin: 24px auto;
    min-height: 90px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    padding: 8px;
    text-align: center;
}

.landing-about {
    margin: 30px 0;
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

/* <details> 통합 박스 — 4 카드 + 사이트 소개 함께 접기 (2026-04-26) */
.landing-extra-details {
    margin: 20px 0 30px;
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    transition: padding 0.2s;
}

.landing-extra-details[open] {
    padding: 16px 20px;
}

.landing-extra-details > summary,
.landing-about > summary {
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
    padding: 0;
}

.landing-extra-details > summary::-webkit-details-marker,
.landing-about > summary::-webkit-details-marker { display: none; }

.landing-extra-details > summary::before,
.landing-about > summary::before {
    content: "▶";
    font-size: 11px;
    color: rgba(230, 237, 243, 0.5);
    transition: transform 0.2s;
    flex-shrink: 0;
}

.landing-extra-details[open] > summary::before,
.landing-about[open] > summary::before {
    transform: rotate(90deg);
}

.landing-extra-details > summary > h2,
.landing-about > summary > h2,
.landing-about h2 {
    font-size: 16px;
    color: #e6edf3;
    margin: 0;
    font-weight: 600;
}

.landing-extra-details[open] > summary,
.landing-about[open] > summary {
    margin-bottom: 16px;
}

.landing-extra-details .landing-intro {
    margin-top: 8px;
    margin-bottom: 16px;
}

.landing-about-content h3 {
    font-size: 14px;
    color: #e6edf3;
    margin: 16px 0 8px;
}

.landing-about-content p {
    font-size: 13px;
    color: rgba(230, 237, 243, 0.7);
    line-height: 1.7;
    margin: 0 0 8px;
}

.landing-about-content ul {
    margin: 8px 0 0;
    padding-left: 20px;
}

.landing-about-content li {
    font-size: 12px;
    color: rgba(230, 237, 243, 0.6);
    line-height: 1.8;
}

.landing-about h3 {
    font-size: 14px;
    color: #e6edf3;
    margin: 16px 0 8px;
}

.landing-about p {
    font-size: 13px;
    color: rgba(230, 237, 243, 0.7);
    line-height: 1.7;
    margin: 0 0 8px;
}

.landing-about ul {
    margin: 8px 0 0;
    padding-left: 20px;
}

.landing-about li {
    font-size: 12px;
    color: rgba(230, 237, 243, 0.6);
    line-height: 1.8;
}

.landing-footer {
    margin: 30px 0 60px;
    text-align: center;
    font-size: 12px;
    color: rgba(230, 237, 243, 0.4);
}

.landing-footer p {
    margin: 4px 0;
}

.landing-footer a {
    color: rgba(230, 237, 243, 0.6);
    text-decoration: none;
}

.landing-footer a:hover {
    color: #00d4ff;
    text-decoration: underline;
}

@media (max-width: 600px) {
    .landing-intro-grid {
        grid-template-columns: 1fr;
    }
}

.landing-title {
    font-size: 52px;
    font-weight: 700;
    color: #e6edf3;
    letter-spacing: 6px;
    margin-bottom: 10px;
    line-height: 1.15;
    text-shadow: 0 0 60px rgba(88, 166, 255, 0.3),
                 0 0 120px rgba(88, 166, 255, 0.1);
    font-family: var(--font);
}

.landing-subtitle {
    font-size: 16px;
    color: #8b949e;
    margin-bottom: 36px;
    letter-spacing: 0.5px;
    font-weight: 400;
}

.landing-input-wrapper {
    display: flex;
    gap: 8px;
    margin-bottom: 28px;
}

#landing-input {
    flex: 1;
    padding: 16px 22px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    color: #e6edf3;
    font-size: 16px;
    font-family: var(--font);
    outline: none;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: all 0.2s ease;
}

#landing-input::placeholder {
    color: #6e7681;
}

#landing-input:focus {
    border-color: #58a6ff;
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15),
                0 4px 20px rgba(88, 166, 255, 0.1);
}

#landing-start {
    padding: 16px 28px;
    background: #58a6ff;
    border: none;
    border-radius: 14px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    font-size: 16px;
    font-family: var(--font);
    letter-spacing: 0.5px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

#landing-start:hover {
    background: #79c0ff;
    box-shadow: 0 4px 20px rgba(88, 166, 255, 0.4);
    transform: translateY(-1px);
}

#landing-start:active {
    transform: translateY(0) scale(0.98);
}

.landing-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.landing-chip {
    padding: 10px 18px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    color: #8b949e;
    cursor: pointer;
    font-size: 14px;
    font-family: var(--font);
    transition: all 0.2s ease;
    white-space: nowrap;
}

.landing-chip:hover {
    background: #58a6ff;
    color: white;
    border-color: #58a6ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(88, 166, 255, 0.3);
}

.landing-chip:active {
    transform: translateY(0) scale(0.97);
}

/* ==================== LOADING OVERLAY ==================== */
#loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary, #0d1117);
    gap: 16px;
}

#loading-overlay p {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.5px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border, rgba(255,255,255,0.08));
    border-top-color: var(--accent, #58a6ff);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ==================== MOBILE TOGGLE ==================== */
#mobile-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 210;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: all var(--duration-fast) var(--ease-in-out);
}

#mobile-toggle:hover {
    background: var(--bg-surface);
    border-color: var(--border-emphasis);
}

#sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 190;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

#sidebar-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
}

/* ==================== AI OFFLINE BANNER ==================== */
.ai-offline-banner {
    background: var(--accent-yellow-muted);
    border: 1px solid rgba(210, 153, 34, 0.3);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    margin: 8px 12px;
    font-size: 11px;
    font-weight: 500;
    color: var(--accent-yellow);
    text-align: center;
    animation: msg-enter 0.3s var(--ease-out);
}

/* ==================== CHAT ERROR MESSAGE ==================== */
.chat-msg.error {
    background: var(--accent-red-muted);
    border: 1px solid rgba(248, 81, 73, 0.2);
    color: var(--accent-red);
    font-size: 12px;
    max-width: 92%;
}

/* ==================== WORKFLOW STEPS (Replit-style) ==================== */
.workflow-container {
    padding: 12px;
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    border-left: 3px solid var(--accent);
    max-width: 100%;
}

.workflow-step {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    font-size: 13px;
    transition: opacity 0.3s ease;
}

.workflow-step + .workflow-step {
    border-top: 1px solid var(--border-muted);
}

.step-icon {
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.step-title {
    font-weight: 600;
    color: var(--text-primary);
    min-width: 100px;
    white-space: nowrap;
}

.step-detail {
    color: var(--text-secondary);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.step-running .step-title { color: var(--accent); }
.step-running .step-icon { animation: pulse 1.5s ease-in-out infinite; }
.step-done .step-title { color: var(--accent-green); }
.step-error .step-title { color: var(--accent-red); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ==================== RIGHT PARAMETER DRAWER ==================== */
.right-drawer {
    position: fixed;
    top: 0;
    right: -360px;
    width: 360px;
    height: 100vh;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    z-index: 150;
    overflow-y: auto;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 16px;
}

.right-drawer.open {
    right: 0;
}

#right-drawer-toggle {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 64px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-right: none;
    border-radius: 8px 0 0 8px;
    cursor: pointer;
    z-index: 151;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 14px;
    transition: all 0.2s;
}

#right-drawer-toggle:hover {
    background: var(--accent);
    color: white;
}

.right-drawer.open ~ #right-drawer-toggle {
    right: 360px;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
    .landing-title {
        font-size: 38px;
        letter-spacing: 4px;
    }

    #landing-content {
        padding: 16px;
    }

    body {
        flex-direction: column;
    }

    #sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        bottom: 0;
        width: 85%;
        min-width: 85%;
        max-width: 340px;
        height: 100vh;
        height: 100dvh;
        max-height: none;
        z-index: 200;
        transition: left 0.3s ease;
        border-right: 1px solid var(--border);
        border-bottom: none;
        order: unset;
    }

    #sidebar.open {
        left: 0;
    }

    #sidebar::after {
        display: none;
    }

    #mobile-toggle {
        display: flex;
    }

    #sidebar-backdrop {
        display: block;
    }

    #main-content {
        order: 1;
        flex: 1;
        min-height: 100vh;
        min-height: 100dvh;
    }

    #sidebar-header h1 {
        font-size: 11px;
        letter-spacing: 2px;
    }

    #sidebar-header h1 br {
        display: none;
    }

    #prompt-panel {
        max-width: 100%;
    }

    #prompt-input {
        font-size: 14px;
        padding: 10px 14px;
    }

    #generate-btn {
        padding: 10px 16px;
        font-size: 12px;
    }

    #top-bar {
        padding: 8px 12px;
        padding-left: 56px;
    }

    #bottom-panel {
        padding: 0 12px 12px;
    }

    .param-group {
        grid-template-columns: 72px 1fr 44px;
        gap: 6px;
    }

    .param-group label {
        font-size: 10px;
    }

    #card-detail {
        max-height: none;
    }

    .right-drawer {
        width: 300px;
        right: -300px;
    }

    .right-drawer.open ~ #right-drawer-toggle {
        right: 300px;
    }
}

@media (max-width: 480px) {
    :root {
        --sidebar-width: 100%;
    }

    .landing-title {
        font-size: 32px;
        letter-spacing: 3px;
    }

    .landing-subtitle {
        font-size: 14px;
        margin-bottom: 24px;
    }

    .landing-input-wrapper {
        flex-direction: column;
    }

    #landing-start {
        width: 100%;
    }

    .landing-chip {
        font-size: 12px;
        padding: 8px 14px;
    }

    #sidebar-header {
        padding: 12px 12px 10px;
    }

    #sidebar-header h1 {
        font-size: 10px;
    }

    .section-title {
        padding: 8px 12px;
        font-size: 10px;
    }

    #physics-params,
    #env-params,
    #material-params,
    #hazard-params,
    #visual-params,
    #material-select-params,
    #contribute-params,
    #history-list-container {
        padding: 8px 12px 10px;
    }

    #chat-container {
        height: auto;
        flex: 1;
        min-height: 160px;
    }

    .right-drawer {
        width: 85%;
        right: -85%;
    }

    .right-drawer.open ~ #right-drawer-toggle {
        right: 85%;
    }

    /* Touch-friendly: larger tap targets for mobile */
    input[type="range"] {
        height: 32px;
        -webkit-appearance: none;
        appearance: none;
    }

    input[type="range"]::-webkit-slider-thumb {
        width: 24px;
        height: 24px;
    }

    .param-group label {
        min-height: 32px;
        display: flex;
        align-items: center;
    }

    .suggestion-chip,
    .landing-chip {
        min-height: 40px;
        padding: 10px 16px;
    }

    #chat-input {
        min-height: 40px;
        font-size: 14px;
    }

    #chat-send-btn,
    #chat-image-btn {
        min-width: 40px;
        min-height: 40px;
    }

    .drawer-tab {
        min-height: 40px;
        font-size: 11px;
    }
}

/* ==================== UTILITY CLASSES ==================== */
.hidden {
    display: none !important;
}

.collapsed {
    /* Used by JS toggle logic — actual hide is per-element above */
}

/* ==================== PRINT ==================== */
@media print {
    #sidebar {
        display: none;
    }
    #main-content {
        width: 100%;
    }
}
