/* =========================================
   TOOL UI SYSTEM
   ========================================= */
:root {
    /* Surface Colors */
    --bg-app: #000000;
    --bg-panel: rgba(20, 20, 20, 0.9);
    --bg-input: rgba(40, 40, 40, 0.6);
    --border: #333333;

    /* Text Colors */
    --text-primary: #ffffff;
    --text-secondary: #a1a1aa;
    --text-muted: #52525b;

    /* Accent Colors (Monochrome) */
    --accent: #ffffff;
    --accent-glow: rgba(255, 255, 255, 0.2);
    --success: #ffffff;

    /* Syntax Highlighting Colors (Grayscale) */
    --syntax-tag: #ffffff;
    --syntax-attr: #a1a1aa;
    --syntax-string: #71717a;
    --syntax-comment: #404040;
    --syntax-plain: #d4d4d8;

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

    /* Spacing & Radius */
    --radius-md: 8px;
    --radius-lg: 16px;
}

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

html {
    height: 100%;
}

body {
    background-color: var(--bg-app);
    color: var(--text-primary);
    font-family: var(--font-sans);
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Accessibility */
.skip-link {
    position: absolute;
    top: -100px;
    left: 20px;
    background: var(--accent);
    color: #000;
    padding: 12px 24px;
    border-radius: 6px;
    z-index: 9999;
    text-decoration: none;
    font-weight: 600;
    transition: top 0.2s ease;
}

.skip-link:focus {
    top: 20px;
}

*:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* =========================================
   LANDING PAGE
   ========================================= */
#landing-view {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: transform 0.8s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.5s ease;
    padding: 20px;
}

#landing-view.hidden {
    transform: translateY(-100%);
    pointer-events: none;
}

.scanlines {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0) 50%, rgba(0, 0, 0, 0.1) 50%, rgba(0, 0, 0, 0.1));
    background-size: 100% 4px;
    pointer-events: none;
    z-index: 5;
    opacity: 0.6;
}

.grid-mask-wrapper {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    --x: 50%;
    --y: 50%;
    -webkit-mask-image: radial-gradient(circle 300px at var(--x) var(--y), black 0%, transparent 100%);
    mask-image: radial-gradient(circle 300px at var(--x) var(--y), black 0%, transparent 100%);
}

.landing-grid {
    position: absolute;
    inset: -50%;
    width: 200%;
    height: 200%;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.15) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.15) 1px, transparent 1px);
    background-size: 60px 60px;
    transform: perspective(500px) rotateX(60deg);
    animation: grid-move 20s linear infinite;
    pointer-events: none;
}

@keyframes grid-move {
    0% {
        transform: perspective(500px) rotateX(60deg) translateY(0);
    }

    100% {
        transform: perspective(500px) rotateX(60deg) translateY(60px);
    }
}

.landing-content {
    position: relative;
    z-index: 10;
    text-align: center;
    max-width: 600px;
    width: 100%;
}

.landing-title {
    font-size: clamp(3rem, 10vw, 6rem);
    font-weight: 800;
    letter-spacing: -0.04em;
    margin-bottom: 1rem;
    /* Grayscale Gradient */
    background: linear-gradient(135deg, #fff 0%, #71717a 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    opacity: 0;
    animation: fade-up 0.8s ease forwards 0.2s;
    text-shadow: 0 0 30px rgba(255, 255, 255, 0.1);
    line-height: 1.1;
}

.landing-sub {
    font-size: clamp(1rem, 4vw, 1.2rem);
    color: var(--text-secondary);
    margin-bottom: 3rem;
    opacity: 0;
    animation: fade-up 0.8s ease forwards 0.4s;
    padding: 0 10px;
}

.btn-enter {
    background: #fff;
    color: #000;
    padding: 16px 48px;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 50px;
    border: none;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    opacity: 0;
    animation: fade-up 0.8s ease forwards 0.6s;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

.btn-enter:hover,
.btn-enter:active {
    transform: scale(1.05);
    box-shadow: 0 0 40px rgba(255, 255, 255, 0.4);
}

/* 3D Scene */
.scene-3d {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    pointer-events: none;
    perspective: 1200px;
    z-index: 1;
}

.card-3d {
    position: absolute;
    width: 220px;
    height: 300px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    backdrop-filter: blur(8px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    transition: transform 0.1s ease-out;
}

.c1 {
    top: 20%;
    left: 15%;
    transform: rotateZ(-10deg) translateZ(-100px);
}

.c2 {
    top: 60%;
    right: 15%;
    transform: rotateZ(10deg) translateZ(-50px);
}

.c3 {
    top: 15%;
    right: 20%;
    transform: rotateZ(5deg) translateZ(-150px);
}

.card-inner {
    padding: 24px;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.skeleton-line {
    height: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
}

.w-50 {
    width: 50%;
}

.w-80 {
    width: 80%;
}

.skeleton-circle {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 50%;
    margin-bottom: 12px;
}

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

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

/* =========================================
   APP LAYOUT
   ========================================= */
#app-view {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transition: opacity 1s ease 0.5s;
}

#app-view.visible {
    opacity: 1;
}

header {
    /* allow header to grow on smaller screens while keeping a comfortable minimum */
    height: auto;
    min-height: 64px;

    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;

    /* responsive horizontal padding and a small vertical cushion */
    padding: clamp(0.25rem, 1.2vh, 0.75rem) clamp(1rem, 4vw, var(--space-6));

    background: rgba(10, 10, 10, 0.8);
    backdrop-filter: blur(12px);
    flex-shrink: 0;
    justify-content: space-between;
    z-index: 50;

    /* make sizing predictable when padding changes */
    box-sizing: border-box;
}

.brand {
    font-weight: 700;
    font-size: 15px;
    padding: 10px 12px;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.brand:hover {
    opacity: 0.7;
}

.brand-dot {
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 12px var(--accent);
}

main {
    display: grid;
    grid-template-columns: 320px 1fr;
    flex: 1;
    overflow: hidden;
    background-image: radial-gradient(circle at top right, #1a1a1a 0%, transparent 40%);
}

aside {
    background: var(--bg-panel);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border);
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    z-index: 20;
}

/* Header Right Section */
.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-tagline {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.02em;
}

/* Aside Header - Value Proposition */
.aside-header {
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 4px;
}

.aside-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.aside-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Control Blocks */
.control-block {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.block-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.block-icon {
    font-size: 14px;
}

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

label {
    font-size: 12px;
    letter-spacing: 0.02em;
    color: var(--text-secondary);
    font-weight: 500;
}

input[type="text"],
select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 14px 16px;
    min-height: 48px;
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: 15px;
    width: 100%;
    transition: all 0.2s ease;
    appearance: none;
}

input[type="text"]::placeholder {
    color: var(--text-muted);
}

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23a1a1aa'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 16px;
    padding-right: 44px;
    cursor: pointer;
}

input[type="text"]:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
    background: rgba(30, 30, 30, 0.9);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Generate Button - Modern Dark Glass Aesthetic */
.btn-primary {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 16px 24px;
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    width: 100%;
    margin-top: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    font-size: 0.9rem;
    letter-spacing: 0.02em;
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-primary::before {
    content: '✦';
    font-size: 0.85rem;
    opacity: 0.8;
}

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

.btn-primary:hover {
    transform: translateY(-2px);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.08) 100%);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 0 30px rgba(255, 255, 255, 0.15), 0 8px 25px rgba(0, 0, 0, 0.4);
}

.btn-primary:hover::after {
    left: 100%;
}

.btn-primary:active {
    transform: translateY(1px) scale(0.98);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* Button Loading State */
.btn-primary.loading {
    pointer-events: none;
    opacity: 0.8;
}

.btn-primary.loading .btn-text {
    opacity: 0;
}

.btn-primary.loading .btn-loading-spinner {
    display: block;
}

.btn-loading-spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    position: absolute;
}

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

/* Success State for Action Buttons */
.btn-action.success {
    background: rgba(74, 222, 128, 0.15) !important;
    border-color: rgba(74, 222, 128, 0.3) !important;
    color: #4ade80 !important;
}

.variant-selector {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.variant-option {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 12px 14px;
    border-radius: 10px;
    color: var(--text-secondary);
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 13px;
    width: 100%;
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    display: flex;
    align-items: center;
    gap: 12px;
}

.variant-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    font-size: 16px;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.variant-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.variant-info strong {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.variant-tagline {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
}

.variant-badge {
    font-size: 9px;
    padding: 3px 8px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    flex-shrink: 0;
}

.variant-badge.recommended {
    background: rgba(74, 222, 128, 0.15);
    color: #4ade80;
}

.variant-option:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateX(2px);
}

.variant-option:hover .variant-icon {
    background: rgba(255, 255, 255, 0.1);
}

.variant-option.active {
    border-color: rgba(255, 255, 255, 0.3);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.02) 100%);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.variant-option.active .variant-icon {
    background: rgba(255, 255, 255, 0.15);
}

.variant-option.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--accent);
    box-shadow: 0 0 15px var(--accent);
}

/* CTA Hint */
.cta-hint {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    margin-top: 8px;
}

/* --- Preview Area --- */
.canvas-area {
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    overflow: hidden;
    background: #080808;
}

/* Live Preview Header */
.preview-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: rgba(0, 0, 0, 0.6);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(10px);
}

.live-indicator {
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    animation: pulse-live 2s ease-in-out infinite;
    box-shadow: 0 0 8px #4ade80;
}

@keyframes pulse-live {

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

    50% {
        opacity: 0.6;
        transform: scale(0.9);
    }
}

.preview-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.preview-wrapper {
    flex: 1;
    background: #000;
    overflow: auto;
    position: relative;
    display: flex;
    flex-direction: column;
    box-shadow:
        inset 0 0 100px rgba(0, 0, 0, 0.8),
        inset 0 0 0 1px rgba(255, 255, 255, 0.03);
    border-radius: 0;
    margin: 0;
}

#preview-target {
    flex: 1;
    width: 100%;
    contain: content;
    min-height: 400px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0.7;
    }

    to {
        opacity: 1;
    }
}

/* Preview generation animation */
#preview-target.generating {
    animation: pulse-generate 0.5s ease;
}

@keyframes pulse-generate {
    0% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.7;
        transform: scale(0.995);
    }

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

/* Logic for Hiding Code Panel */
.canvas-area.code-hidden .code-panel {
    display: none;
}

.canvas-area.code-hidden .preview-wrapper {
    height: 100%;
    /* Full height when code is hidden */
}

.canvas-area.code-visible .preview-wrapper {
    height: calc(100% - 320px);
}

/* --- Code Panel --- */
.code-panel {
    height: 320px;
    background: #050505;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    font-family: var(--font-mono);
    position: relative;
}

.code-header {
    padding: 0 16px;
    height: 40px;
    border-bottom: 1px solid #1f1f23;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #111;
}

.left-controls {
    display: flex;
    gap: 12px;
    align-items: center;
}

.right-actions {
    display: flex;
    gap: 8px;
}

/* Grayscale Window Controls */
.window-controls {
    display: flex;
    gap: 6px;
}

.win-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.win-red {
    background: #3f3f46;
}

/* Dark Gray */
.win-yellow {
    background: #52525b;
}

/* Medium Gray */
.win-green {
    background: #71717a;
}

/* Light Gray */

.code-title {
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

/* Action Buttons */
.btn-action {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 11px;
    cursor: pointer;
    font-family: var(--font-sans);
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    -webkit-tap-highlight-color: transparent;
}

.btn-action:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.btn-action.copied {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    color: #fff;
}

/* Floating View Code Button */
.btn-floating-code {
    position: absolute;
    bottom: 24px;
    right: 24px;
    background: rgba(14, 14, 17, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
    padding: 10px 20px;
    border-radius: 50px;
    cursor: pointer;
    z-index: 10;
    backdrop-filter: blur(12px);
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 13px;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    -webkit-tap-highlight-color: transparent;
}

.btn-floating-code:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent);
    box-shadow: 0 0 20px var(--accent-glow);
    transform: translateY(-2px);
}

.canvas-area.code-visible .btn-floating-code {
    display: none;
}

.code-content {
    flex: 1;
    overflow: auto;
    padding: 20px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--syntax-plain);
    white-space: pre-wrap;
    tab-size: 2;
}

.token-tag {
    color: var(--syntax-tag);
}

.token-attr {
    color: var(--syntax-attr);
}

.token-string {
    color: var(--syntax-string);
}

.token-comment {
    color: var(--syntax-comment);
    font-style: italic;
}

/* --- Footer --- */
.app-footer {
    height: auto;
    min-height: 44px;
    padding: 10px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 10, 0.95);
    color: var(--text-muted);
    font-size: 11px;
    z-index: 50;
    backdrop-filter: blur(10px);
    font-family: var(--font-sans);
    letter-spacing: 0.01em;
    flex-shrink: 0;
}

.footer-content {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: space-between;
    width: 100%;
    max-width: 1200px;
}

.footer-credits {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.footer-badge {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 500;
}

.footer-divider {
    color: var(--text-muted);
    opacity: 0.5;
}

.footer-links {
    display: flex;
    gap: 16px;
    align-items: center;
}

.footer-link {
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 11px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}

.footer-link:hover {
    color: var(--text-primary);
}

.github-link {
    background: rgba(255, 255, 255, 0.05);
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: all 0.2s ease;
}

.github-link:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.github-icon {
    color: #fbbf24;
}

/* --- Contact Modal --- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    padding: 20px;
}

.modal.visible {
    opacity: 1;
    pointer-events: auto;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
}

.modal-content {
    position: relative;
    background: #111;
    border: 1px solid var(--border);
    padding: 24px;
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    text-align: center;
}

.modal.visible .modal-content {
    transform: scale(1);
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.modal-role {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 24px;
    display: block;
}

.modal-links {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.modal-btn-link {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    -webkit-tap-highlight-color: transparent;
}

.modal-btn-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border-color: var(--accent);
    box-shadow: 0 0 15px var(--accent-glow);
    transform: translateX(2px);
}

.btn-close-modal {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    padding: 10px 30px;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.btn-close-modal:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.btn-header-contact {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    padding: 8px 20px;
    border-radius: 50px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    -webkit-tap-highlight-color: transparent;
    backdrop-filter: blur(4px);
}

.btn-header-contact:hover {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 20px var(--accent-glow);
    color: #000;
    /* Invert text for white button */
    transform: translateY(-1px);
}

/* =========================================
   RESPONSIVE DESIGN (Mobile/Tablet)
   ========================================= */
@media (max-width: 900px) {
    body {
        height: auto;
        min-height: 100dvh;
        overflow-y: auto;
    }

    .card-3d {
        display: none;
    }

    .header-tagline {
        display: none;
    }

    header {
        position: sticky;
        top: 0;
        padding: 8px 16px;
        min-height: 56px;
    }

    main {
        display: flex;
        flex-direction: column-reverse;
        /* Preview first on mobile */
        overflow: visible;
        background: none;
    }

    aside {
        width: 100%;
        border-right: none;
        border-top: 1px solid var(--border);
        padding: 20px 16px;
        overflow: visible;
        height: auto;
        background: var(--bg-app);
        order: 2;
    }

    .aside-header {
        padding-bottom: 12px;
        margin-bottom: 0;
    }

    .aside-title {
        font-size: 1.2rem;
    }

    .canvas-area {
        height: auto;
        overflow: visible;
        order: 1;
    }

    .preview-header {
        padding: 10px 16px;
    }

    .preview-wrapper {
        height: auto;
        min-height: 45vh;
        overflow: visible;
    }

    #preview-target {
        min-height: 45vh;
    }

    .code-panel {
        height: auto;
        min-height: 250px;
        border-top: 1px solid var(--border);
    }

    #app-view {
        height: auto;
        min-height: 100vh;
    }

    /* Larger touch targets */
    input[type="text"],
    select {
        min-height: 52px;
        font-size: 16px;
    }

    .variant-option {
        padding: 14px;
        font-size: 14px;
    }

    .btn-primary {
        font-size: 16px;
        min-height: 52px;
        position: sticky;
        bottom: 16px;
        margin-top: 20px;
        z-index: 100;
    }

    .btn-floating-code {
        bottom: 16px;
        right: 16px;
        font-size: 12px;
        padding: 8px 16px;
    }

    .control-block {
        padding: 14px;
    }

    /* Footer mobile */
    .app-footer {
        padding: 12px 16px;
    }

    .footer-content {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    .footer-credits {
        justify-content: center;
    }

    .footer-links {
        justify-content: center;
    }
}

@media (max-width: 600px) {
    .landing-title {
        font-size: 2.5rem;
    }

    .landing-sub {
        font-size: 1rem;
    }

    .btn-enter {
        padding: 14px 32px;
        width: 100%;
        max-width: 220px;
    }

    .brand {
        font-size: 14px;
        padding: 8px;
    }

    .btn-header-contact {
        padding: 6px 14px;
        font-size: 11px;
    }

    .aside-subtitle {
        font-size: 0.8rem;
    }

    .control-block {
        padding: 12px;
        gap: 12px;
    }

    .variant-icon {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    .variant-badge {
        display: none;
    }

    .code-header {
        padding: 0 12px;
        flex-wrap: wrap;
        height: auto;
        padding: 8px 12px;
        gap: 8px;
    }

    .right-actions {
        flex-wrap: wrap;
        gap: 6px;
    }

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

    .footer-divider {
        display: none;
    }

    .github-link {
        width: 100%;
        justify-content: center;
    }
}