/* Luna v2 — Design System. Dark theme, mobile-first, CSS custom properties. */

:root {
    --primary: #c8a97a;
    --bg: #0a0a0a;
    --surface: #1a1a1a;
    --surface-2: #242424;
    --text: #e0e0e0;
    --text-muted: #888;
    --accent: #c8a97a;
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --border: #2a2a2a;
    --radius: 12px;
    --radius-sm: 8px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', monospace;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);

    /* Transitions for real-time theme changes */
    transition: --primary 0.3s, --bg 0.3s, --surface 0.3s, --text 0.3s, --accent 0.3s;
}

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

html {
    overscroll-behavior-y: contain;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
    padding-left: var(--safe-left);
    padding-right: var(--safe-right);
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}

/* Prevent iOS input zoom */
input, textarea, select { font-size: 16px; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Layout Shell --- */

#app {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    max-width: 100%;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.app-header .logo {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.02em;
}

.app-header .status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

.app-header .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
}

.app-header .credits-badge {
    background: var(--surface-2);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 13px;
    color: var(--primary);
    font-weight: 600;
}

.app-header .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    cursor: pointer;
}

/* --- Content Area --- */

.app-content {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* --- Block Grid --- */

.blocks-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

@media (min-width: 768px) {
    .blocks-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
        gap: 16px;
    }
}

/* --- Block Base --- */

.block {
    background: linear-gradient(145deg, var(--surface), rgba(26,26,26,0.8));
    border-radius: 16px;
    border: 1px solid rgba(200, 169, 122, 0.1);
    overflow: hidden;
    transition: border-color 0.3s, transform 0.2s, box-shadow 0.3s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.block:hover {
    border-color: rgba(200, 169, 122, 0.25);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 12px;
    border-bottom: 1px solid rgba(200, 169, 122, 0.08);
}

.block-header h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.01em;
}

.block-body {
    padding: 16px 20px 20px;
}

/* Tappable blocks */
.block-tappable {
    cursor: pointer;
}

.block-tappable:active {
    transform: scale(0.98);
}

.block-tap-hint {
    font-size: 11px;
    color: var(--primary);
    opacity: 0.6;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.block-tappable:hover .block-tap-hint {
    opacity: 1;
}

.block-tap-cta {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    transition: color 0.2s;
}

.block-tap-cta:hover {
    color: var(--primary);
}

.block-tap-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px dashed rgba(200, 169, 122, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--primary);
    margin-bottom: 8px;
    transition: all 0.2s;
}

.block-tap-cta:hover .block-tap-icon {
    border-color: var(--primary);
    background: rgba(200, 169, 122, 0.1);
}

/* Block animations */
.block-enter {
    animation: blockEnter 0.4s ease-out;
}

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

.block-exit {
    animation: blockExit 0.3s ease-in forwards;
}

@keyframes blockExit {
    to { opacity: 0; transform: translateY(10px); height: 0; margin: 0; padding: 0; overflow: hidden; }
}

/* --- Chat Block (Full Height) --- */

.block-chat {
    display: flex;
    flex-direction: column;
}

.block-chat.prominent {
    grid-column: 1 / -1;
    min-height: 400px;
    border: 1px solid rgba(200, 169, 122, 0.15);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 200px;
    max-height: 60vh;
}

.chat-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
}

.chat-msg.user {
    align-self: flex-end;
    background: var(--primary);
    color: #0a0a0a;
    border-bottom-right-radius: 4px;
}

.chat-msg.assistant {
    align-self: flex-start;
    background: var(--surface-2);
    color: var(--text);
    border-bottom-left-radius: 4px;
}

.chat-msg.assistant .model-tag {
    font-size: 10px;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.chat-input-area {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.chat-input {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    resize: none;
    outline: none;
    min-height: 42px;
    max-height: 120px;
}

.chat-input:focus {
    border-color: var(--primary);
}

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

.chat-send {
    background: var(--primary);
    color: #0a0a0a;
    border: none;
    border-radius: var(--radius-sm);
    padding: 0 16px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    min-height: 42px;
    transition: opacity 0.15s;
}

.chat-send:hover { opacity: 0.85; }
.chat-send:disabled { opacity: 0.4; cursor: not-allowed; }

.chat-cost-hint {
    font-size: 11px;
    color: var(--text-muted);
    padding: 0 16px 8px;
    text-align: right;
}

/* Chat option buttons */
.chat-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 4px;
    align-self: flex-start;
    max-width: 95%;
    animation: optionsFadeIn 0.4s ease-out;
}

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

.chat-option-btn {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 20px;
    font-size: 15px;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1.3;
}

.chat-option-btn:hover {
    background: var(--primary);
    color: #0a0a0a;
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(200, 169, 122, 0.2);
}

.chat-option-btn:active {
    transform: scale(0.97);
}

/* Multi-select: selected state */
.chat-option-btn.selected {
    background: var(--primary);
    color: #0a0a0a;
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(200, 169, 122, 0.3);
}

/* Confirm button for multi-select */
.chat-option-confirm {
    background: var(--primary);
    color: #0a0a0a;
    border: none;
    border-radius: 12px;
    padding: 12px 28px;
    font-size: 15px;
    font-weight: 700;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    margin-top: 4px;
}

.chat-option-confirm:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.chat-option-confirm.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
}

/* Multi-mode label hint */
.chat-options.multi-mode::before {
    content: "Puoi selezionarne più di una";
    display: block;
    width: 100%;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

/* Thinking/streaming indicator */
.luna-thinking {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    color: var(--text-muted);
    font-size: 14px;
}

.luna-thinking-orb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, var(--primary), rgba(200,169,122,0.2));
    animation: orbPulse 2s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes orbPulse {
    0%, 100% { transform: scale(1); opacity: 0.7; box-shadow: 0 0 0 0 rgba(200,169,122,0.3); }
    50% { transform: scale(1.15); opacity: 1; box-shadow: 0 0 20px 4px rgba(200,169,122,0.2); }
}

.luna-thinking-text {
    animation: thinkFade 2s ease-in-out infinite;
}

@keyframes thinkFade {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* Search/tool activity indicator */
.luna-searching {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: rgba(200, 169, 122, 0.05);
    border: 1px solid rgba(200, 169, 122, 0.1);
    border-radius: 12px;
    margin: 8px 0;
    color: var(--primary);
    font-size: 13px;
    animation: searchSlide 0.3s ease-out;
}

@keyframes searchSlide {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

.luna-searching-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(200,169,122,0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Old typing indicator — keep as fallback */
.typing-indicator {
    display: inline-flex;
    gap: 4px;
    padding: 8px 12px;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* --- Credits Block --- */

.credits-balance {
    font-size: 40px;
    font-weight: 800;
    color: var(--primary);
    text-align: center;
    padding: 20px 0 4px;
    line-height: 1;
}

.credits-label {
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* --- Stats Block --- */

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

.stat-card {
    background: rgba(200, 169, 122, 0.05);
    border: 1px solid rgba(200, 169, 122, 0.1);
    border-radius: 12px;
    padding: 16px 12px;
    text-align: center;
    transition: background 0.2s;
}

.stat-card:hover {
    background: rgba(200, 169, 122, 0.1);
}

.stat-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
}

.stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 6px;
    font-weight: 500;
}

/* --- Bots Block --- */

.bot-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bot-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: rgba(200, 169, 122, 0.05);
    border: 1px solid rgba(200, 169, 122, 0.08);
    border-radius: 12px;
    transition: background 0.2s;
}

.bot-item:hover {
    background: rgba(200, 169, 122, 0.1);
}

.bot-item .bot-name {
    font-weight: 600;
    font-size: 14px;
}

.bot-item .bot-status {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 12px;
}

.bot-status.active { background: #22c55e20; color: var(--success); }
.bot-status.paused { background: #f59e0b20; color: var(--warning); }
.bot-status.error { background: #ef444420; color: var(--error); }

/* --- Gallery Block --- */

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
}

.gallery-grid img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.2s;
}

.gallery-grid img:hover {
    transform: scale(1.02);
}

/* --- Text Block --- */

.text-content {
    font-size: 15px;
    line-height: 1.8;
    color: var(--text);
}

.text-content strong {
    color: var(--primary);
}

.text-content h1, .text-content h2, .text-content h3 {
    color: var(--primary);
    margin: 16px 0 8px;
}

.text-content p { margin-bottom: 12px; }

.text-content code {
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 13px;
}

/* --- Buttons --- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    border: none;
    transition: opacity 0.15s, transform 0.1s;
    min-height: 44px;
    min-width: 44px;
}

.btn:hover { opacity: 0.85; }
.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--primary);
    color: #0a0a0a;
}

.btn-secondary {
    background: var(--surface-2);
    color: var(--text);
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}

.btn-full { width: 100%; }

/* --- Landing Page --- */

.landing {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    padding: 32px 24px;
    text-align: center;
}

.landing-logo {
    font-size: 48px;
    margin-bottom: 16px;
}

.landing h1 {
    font-size: 32px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.03em;
    margin-bottom: 12px;
}

.landing .subtitle {
    font-size: 16px;
    color: var(--text-muted);
    max-width: 400px;
    margin-bottom: 32px;
    line-height: 1.6;
}

.landing .google-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #fff;
    color: #333;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: box-shadow 0.2s;
    min-height: 48px;
}

.landing .google-btn:hover {
    box-shadow: 0 4px 12px rgba(255,255,255,0.1);
}

.landing .google-btn svg {
    width: 20px;
    height: 20px;
}

.landing footer {
    position: absolute;
    bottom: 24px;
    font-size: 12px;
    color: var(--text-muted);
}

.landing footer a {
    color: var(--text-muted);
    text-decoration: underline;
}

/* --- Onboarding --- */

.onboarding-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.onboarding-overlay .app-header {
    background: transparent;
    border-bottom: 1px solid rgba(200, 169, 122, 0.1);
}

.onboarding-overlay .block-chat {
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
    border: none;
    background: transparent;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.onboarding-overlay .chat-messages {
    max-height: none;
    flex: 1;
    padding: 32px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.onboarding-overlay .chat-msg {
    max-width: 100%;
    text-align: center;
    border-radius: 16px;
}

.onboarding-overlay .chat-msg.assistant {
    background: transparent;
    border: none;
    font-size: 18px;
    line-height: 1.7;
    color: var(--text);
    padding: 8px 0;
    align-self: center;
}

.onboarding-overlay .chat-msg.user {
    background: var(--primary);
    color: #0a0a0a;
    font-size: 15px;
    font-weight: 600;
    padding: 10px 24px;
    border-radius: 24px;
    align-self: center;
}

.onboarding-overlay .chat-input-area {
    background: transparent;
    border-top: 1px solid rgba(200, 169, 122, 0.1);
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
    padding: 16px;
}

.onboarding-overlay .chat-options {
    max-width: 100%;
    justify-content: center;
    padding: 8px 0;
}

.onboarding-overlay .chat-option-btn {
    background: rgba(200, 169, 122, 0.1);
    border: 1px solid rgba(200, 169, 122, 0.25);
    color: var(--primary);
    padding: 14px 24px;
    font-size: 15px;
    font-weight: 500;
    border-radius: 24px;
}

.onboarding-overlay .chat-option-btn:hover {
    background: var(--primary);
    color: #0a0a0a;
    box-shadow: 0 4px 20px rgba(200, 169, 122, 0.3);
}

.onboarding-overlay .chat-option-btn.selected {
    background: var(--primary);
    color: #0a0a0a;
    box-shadow: 0 2px 12px rgba(200, 169, 122, 0.3);
}

.onboarding-overlay .chat-option-confirm {
    border-radius: 24px;
    box-shadow: 0 4px 20px rgba(200, 169, 122, 0.3);
}

/* Input area during onboarding */
.onboarding-overlay .chat-input-area {
    opacity: 1;
}

.onboarding-overlay .chat-input {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(200, 169, 122, 0.2);
}

.onboarding-overlay .chat-send {
    background: var(--primary);
    color: #0a0a0a;
}

/* Luna thinking in onboarding — centered */
.onboarding-overlay .luna-thinking {
    justify-content: center;
    padding: 24px;
}

.onboarding-overlay .luna-thinking-orb {
    width: 32px;
    height: 32px;
}

.onboarding-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Welcome screen — primo impatto */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    padding: 32px;
    text-align: center;
    animation: welcomeFadeIn 1s ease-out;
}

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

.welcome-orb {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #f0d89a, var(--primary), #8a6d3b);
    animation: welcomeOrbFloat 3s ease-in-out infinite;
    box-shadow: 0 0 60px rgba(200, 169, 122, 0.4), 0 0 120px rgba(200, 169, 122, 0.1);
    margin-bottom: 24px;
}

@keyframes welcomeOrbFloat {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-12px) scale(1.05); }
}

.welcome-title {
    font-size: 42px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.03em;
    margin-bottom: 8px;
    animation: welcomeSlideUp 0.8s ease-out 0.3s both;
}

.welcome-sub {
    font-size: 17px;
    color: var(--text-muted);
    margin-bottom: 32px;
    animation: welcomeSlideUp 0.8s ease-out 0.5s both;
}

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

.welcome-bar {
    width: 200px;
    height: 3px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 16px;
    animation: welcomeSlideUp 0.8s ease-out 0.7s both;
}

.welcome-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    animation: welcomeBarFill 2.2s ease-in-out forwards;
}

@keyframes welcomeBarFill {
    from { width: 0%; }
    to { width: 100%; }
}

.welcome-hint {
    font-size: 13px;
    color: var(--text-muted);
    animation: welcomeSlideUp 0.8s ease-out 0.9s both;
}

/* Intro start button */
.intro-start-btn {
    background: var(--primary);
    color: #0a0a0a;
    border: none;
    border-radius: 16px;
    padding: 16px 32px;
    font-size: 17px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.2s;
    animation: welcomeSlideUp 0.8s ease-out 0.5s both;
    box-shadow: 0 4px 20px rgba(200, 169, 122, 0.3);
}

.intro-start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(200, 169, 122, 0.4);
}

.intro-start-btn:active {
    transform: scale(0.97);
}

/* Build animation — dopo l'interrogatorio */
.build-animation {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    padding: 40px 32px;
    text-align: center;
    animation: welcomeFadeIn 0.6s ease-out;
}

.build-orb {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #f0d89a, var(--primary), #8a6d3b);
    animation: buildOrbSpin 3s linear infinite;
    box-shadow: 0 0 40px rgba(200, 169, 122, 0.4), 0 0 80px rgba(200, 169, 122, 0.15);
    margin-bottom: 24px;
}

@keyframes buildOrbSpin {
    0% { transform: scale(1) rotate(0deg); box-shadow: 0 0 40px rgba(200, 169, 122, 0.4); }
    50% { transform: scale(1.1) rotate(180deg); box-shadow: 0 0 60px rgba(200, 169, 122, 0.6); }
    100% { transform: scale(1) rotate(360deg); box-shadow: 0 0 40px rgba(200, 169, 122, 0.4); }
}

.build-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 24px;
}

.build-steps {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 28px;
}

.build-step {
    font-size: 14px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 10px;
}

.build-step::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border);
    flex-shrink: 0;
}

.build-step.active {
    color: var(--primary);
    font-weight: 600;
    animation: buildStepPulse 1.5s ease-in-out infinite;
}

.build-step.active::before {
    background: var(--primary);
    box-shadow: 0 0 8px rgba(200, 169, 122, 0.5);
}

@keyframes buildStepPulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

.build-step.pending {
    opacity: 0.4;
}

.build-bar {
    width: 240px;
    height: 3px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.build-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #f0d89a);
    border-radius: 3px;
    animation: buildBarFill 8s ease-in-out forwards;
}

@keyframes buildBarFill {
    0% { width: 5%; }
    30% { width: 35%; }
    60% { width: 65%; }
    80% { width: 85%; }
    100% { width: 98%; }
}

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

/* --- Space Welcome Tour --- */

.space-welcome {
    display: flex;
    justify-content: center;
    padding: 24px 16px;
    animation: welcomeFadeIn 0.6s ease-out;
}

.space-welcome-card {
    background: var(--surface);
    border: 1px solid rgba(200, 169, 122, 0.2);
    border-radius: 16px;
    padding: 32px;
    text-align: center;
    max-width: 500px;
    width: 100%;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.space-welcome-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.space-welcome-card h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

.space-welcome-card p {
    color: var(--text-muted);
    font-size: 15px;
    line-height: 1.5;
}

.space-welcome-blocks {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 16px;
}

.space-welcome-tag {
    background: rgba(200, 169, 122, 0.1);
    border: 1px solid rgba(200, 169, 122, 0.2);
    color: var(--primary);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

/* Empty space state */
.empty-space {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 50vh;
    text-align: center;
    padding: 32px;
    color: var(--text-muted);
}

.empty-space-orb {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, var(--primary), rgba(200,169,122,0.2));
    animation: orbPulse 2s ease-in-out infinite;
    margin-bottom: 16px;
}

.empty-space h2 {
    font-size: 18px;
    color: var(--text);
    margin-bottom: 8px;
}

/* --- Loading --- */

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    color: var(--text-muted);
}

/* --- Settings --- */

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

.settings-section h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.settings-row label {
    font-size: 14px;
}

.settings-input {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    outline: none;
    width: 200px;
}

.settings-input:focus {
    border-color: var(--primary);
}

/* --- Toast Notifications --- */

.toast {
    position: fixed;
    bottom: calc(20px + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface-2);
    color: var(--text);
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    z-index: 10000;
    animation: toastIn 0.3s ease-out;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* --- Utility --- */

.hidden { display: none !important; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.p-16 { padding: 16px; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
