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

:root {
    --font-display: "Instrument Serif", serif;
    --font-sans: "Instrument Sans", sans-serif;

    --paper: #f5f1e8;
    --panel: #fbf8f2;
    --panel-ink: #1c1b19;
    --panel-soft: #f0e9de;

    --ink: #1c1b19;
    --ink-muted: #4b4b46;
    --ink-quiet: #6b6a63;

    --accent: #1f3a5f;
    --accent-warm: #c26b3f;
    --accent-olive: #3f6b58;

    --line: rgba(28, 27, 25, 0.12);
    --line-strong: rgba(28, 27, 25, 0.2);
    --glow: rgba(31, 58, 95, 0.18);

    --radius-xl: 26px;
    --radius-lg: 18px;
    --radius-md: 12px;
    --radius-sm: 9px;

    --shadow-sm: 0 2px 6px rgba(28, 27, 25, 0.06);
    --shadow-md: 0 14px 30px rgba(28, 27, 25, 0.12);
    --shadow-lg: 0 30px 70px rgba(28, 27, 25, 0.2);

    --transition: 0.25s ease;
}

html { font-size: 16px; }
body {
    font-family: var(--font-sans);
    background: var(--paper);
    color: var(--ink);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    letter-spacing: -0.01em;
    -webkit-font-smoothing: antialiased;
    position: relative;
    overflow-x: hidden;
}

/* ===== BACKGROUND TEXTURE ===== */
.bg-scene {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image:
        radial-gradient(circle at 12% 12%, rgba(194, 107, 63, 0.18), transparent 40%),
        radial-gradient(circle at 88% 8%, rgba(31, 58, 95, 0.16), transparent 38%),
        radial-gradient(circle at 50% 100%, rgba(63, 107, 88, 0.12), transparent 45%),
        repeating-linear-gradient(90deg, rgba(28, 27, 25, 0.04) 0 1px, transparent 1px 28px),
        repeating-linear-gradient(0deg, rgba(28, 27, 25, 0.02) 0 1px, transparent 1px 28px);
    opacity: 0.9;
}
.bg-orb, .bg-grid { display: none; }
body > *:not(.bg-scene) { position: relative; z-index: 1; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(28, 27, 25, 0.18); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(28, 27, 25, 0.3); }

/* ===== UTILITIES ===== */
.flex-1 { flex: 1; }
.row { display: flex; gap: 0.75rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.hidden { display: none !important; }
.scrollable { overflow: auto; }

/* ===== ANIMATIONS ===== */
@keyframes rise {
    from { opacity: 0; transform: translateY(18px); }
    to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
    * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ===== TOP NAV ===== */
.top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 2.25rem;
    height: 4.75rem;
    background: rgba(251, 248, 242, 0.9);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(10px);
}
.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    text-decoration: none;
    color: inherit;
}
.nav-brand .logo-icon {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: var(--ink);
    display: grid;
    place-items: center;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}
.nav-brand h1 {
    font-family: var(--font-display);
    font-size: 1.45rem;
    font-weight: 400;
    letter-spacing: -0.02em;
}
.nav-actions { display: flex; align-items: center; gap: 1rem; }
.header-status {
    font-size: 0.72rem;
    padding: 0.4rem 0.85rem;
    border-radius: 999px;
    background: rgba(31, 58, 95, 0.08);
    border: 1px solid rgba(31, 58, 95, 0.2);
    color: var(--accent);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

/* ===== LAYOUT ===== */
.editor-layout {
    display: grid;
    grid-template-columns: 320px minmax(420px, 1fr) 360px;
    gap: 1.6rem;
    padding: 1.75rem 2.25rem 2.75rem;
    max-width: 1680px;
    width: 100%;
    margin: 0 auto;
    animation: rise 0.7s ease both;
}

.panel {
    display: flex;
    flex-direction: column;
    background: var(--panel);
    border-radius: var(--radius-xl);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    position: relative;
    transition: transform var(--transition), box-shadow var(--transition);
}
.panel:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.panel-assets::before, .panel-inspector::before {
    content: "";
    position: absolute;
    top: 10px;
    left: 18px;
    width: 64px;
    height: 10px;
    background: rgba(194, 107, 63, 0.25);
    border-radius: 999px;
    transform: rotate(-2deg);
}

.panel-header {
    height: 4rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.75rem;
    border-bottom: 1px solid var(--line);
}
.panel-header h2 {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 400;
    letter-spacing: -0.01em;
    color: var(--ink);
}
.panel-content { padding: 1.6rem; }

/* ===== MASCOT ===== */
.mascot-strip {
    display: grid;
    grid-template-columns: 64px 1fr;
    gap: 0.9rem;
    padding: 0.9rem 1rem;
    border-radius: var(--radius-lg);
    background: var(--panel-soft);
    border: 1px dashed rgba(28, 27, 25, 0.2);
    margin-bottom: 1.25rem;
}
.mascot-figure svg { width: 64px; height: 64px; }
.mascot-title {
    font-weight: 700;
    letter-spacing: 0.02em;
    margin-bottom: 0.3rem;
}
.mascot-text {
    font-size: 0.82rem;
    color: var(--ink-quiet);
    line-height: 1.4;
}

/* ===== COMMON INPUTS ===== */
.section-label-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.7rem; }
.section-label { display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; font-weight: 600; color: var(--ink); }
.meta-row { display: flex; align-items: center; justify-content: space-between; margin-top: 0.6rem; }
.meta-text { font-size: 0.78rem; color: var(--ink-quiet); }
.prop-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 0.5rem; }
.prop-header label { font-size: 0.85rem; color: var(--ink-muted); }
.prop-val { font-size: 0.85rem; color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 600; }
.property-group { margin-bottom: 1.35rem; }

textarea, .input-full {
    width: 100%;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 0.85rem 0.9rem;
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    line-height: 1.5;
    resize: none;
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}
textarea:focus, .input-full:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--glow);
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: rgba(28, 27, 25, 0.1);
    border-radius: 999px;
    outline: none;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 3px rgba(31, 58, 95, 0.18);
    cursor: ew-resize;
    transition: transform var(--transition);
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }

/* Drop Zone */
.drop-zone {
    border: 1px dashed rgba(28, 27, 25, 0.25);
    border-radius: var(--radius-md);
    padding: 1.5rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: rgba(255, 255, 255, 0.8);
}
.drop-zone:hover, .drop-zone.drag-over {
    border-color: var(--accent-warm);
    background: rgba(194, 107, 63, 0.08);
}
.drop-zone p { font-size: 0.85rem; color: var(--ink-muted); }
.small-zone { padding: 1rem; }

.files-grid { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.file-thumb {
    position: relative;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--line);
    transition: border-color var(--transition), transform var(--transition);
    background: #fff;
}
.file-thumb:hover { border-color: var(--accent); transform: translateY(-2px); }
.file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.remove-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(28, 27, 25, 0.92);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition);
}
.file-thumb:hover .remove-btn { opacity: 1; }

.upload-group { padding-bottom: 1.25rem; margin-bottom: 1.25rem; border-bottom: 1px solid var(--line); }
.upload-group:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

/* ===== PLAYER PANEL ===== */
.panel-player {
    background: #fefcf7;
    position: sticky;
    top: 5.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-md);
}
.player-toolbar {
    height: 3.4rem;
    background: #fff;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
}
.video-switcher {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: var(--panel-soft);
    padding: 0.25rem 0.4rem;
    border-radius: 999px;
    border: 1px solid var(--line);
}
.btn-icon {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    background: transparent;
    border: none;
    color: var(--ink-muted);
    border-radius: 999px;
    cursor: pointer;
    transition: all var(--transition);
}
.btn-icon:hover:not(:disabled) { background: rgba(31, 58, 95, 0.08); color: var(--accent); }
.btn-icon:disabled { opacity: 0.3; cursor: not-allowed; }
.btn-icon.small { width: 26px; height: 26px; }
.video-indicator { font-size: 0.82rem; font-weight: 600; min-width: 86px; text-align: center; color: var(--ink-muted); }
.player-hint {
    font-size: 0.72rem;
    color: var(--ink-quiet);
    display: flex;
    align-items: center;
    gap: 0.35rem;
    background: rgba(31, 58, 95, 0.08);
    border: 1px solid rgba(31, 58, 95, 0.18);
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
}

.canvas-container {
    padding: 4rem 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        linear-gradient(180deg, rgba(28, 27, 25, 0.04), transparent),
        repeating-linear-gradient(90deg, rgba(28, 27, 25, 0.05) 0 1px, transparent 1px 24px),
        repeating-linear-gradient(0deg, rgba(28, 27, 25, 0.05) 0 1px, transparent 1px 24px);
    position: relative;
    border-radius: var(--radius-xl);
}
.canvas-wrapper {
    position: relative;
    width: 100%;
    max-width: 330px;
    aspect-ratio: 9/16;
    border-radius: 28px;
    overflow: hidden;
    border: 10px solid #f4efe6;
    box-shadow: var(--shadow-lg);
    background: #000;
}
#preview-canvas { width: 100%; height: 100%; display: block; cursor: grab; }
#preview-canvas:active { cursor: grabbing; }

.player-footer {
    height: 4rem;
    background: #fff;
    border-top: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
}
.export-stats { display: flex; align-items: center; gap: 0.75rem; font-size: 0.82rem; color: var(--ink-muted); }
.export-stats strong { color: var(--ink); font-weight: 600; }
.divider { color: var(--line-strong); }

/* ===== BUTTONS ===== */
.btn-primary, .btn-secondary, .btn-vibrant {
    padding: 0.78rem 1.5rem;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition);
    border: none;
    letter-spacing: -0.01em;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}
.btn-primary {
    background: var(--ink);
    color: #fff;
    box-shadow: 0 12px 24px rgba(28, 27, 25, 0.2);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); }
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-secondary {
    background: #fff;
    color: var(--ink);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
}
.btn-secondary:hover { background: var(--panel); border-color: var(--line-strong); }

.btn-vibrant {
    background: var(--accent);
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    box-shadow: 0 12px 24px rgba(31, 58, 95, 0.28);
}
.btn-vibrant:hover { transform: translateY(-2px); }

.btn-full { width: 100%; justify-content: center; }
.btn-text-small {
    background: transparent;
    border: none;
    color: var(--accent);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    padding: 0.25rem 0;
    transition: color var(--transition);
}
.btn-text-small:hover { color: var(--accent-warm); }

/* ===== INSPECTOR ===== */
.template-actions { display: flex; gap: 0.45rem; align-items: center; }
.select-tiny, .select-small, .select-full {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    color: var(--ink);
    outline: none;
    font-family: var(--font-sans);
}
.select-tiny { padding: 0.25rem 0.45rem; font-size: 0.75rem; }
.select-small { padding: 0.35rem 0.55rem; font-size: 0.82rem; }
.select-full { width: 100%; padding: 0.55rem; font-size: 0.88rem; }

.inspector-tabs {
    display: flex;
    border-bottom: 2px solid var(--line);
    padding: 0 1.25rem;
    gap: 1rem;
    background: #fff;
}
.inspect-tab {
    flex: none;
    padding: 1.1rem 0.4rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--ink-quiet);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    transition: all var(--transition);
    margin-bottom: -2px;
}
.inspect-tab:hover { color: var(--ink); }
.inspect-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.inspect-panel { display: none; }
.inspect-panel.active { display: block; animation: rise 0.45s ease both; }
.separator { height: 1px; background: var(--line); margin: 2rem 0; }

.segment-control {
    display: flex;
    background: #fff;
    border-radius: 999px;
    padding: 4px;
    border: 1px solid var(--line);
}
.segment {
    flex: 1;
    padding: 0.55rem 0;
    background: transparent;
    border: none;
    border-radius: 999px;
    color: var(--ink-quiet);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition);
}
.segment:hover { color: var(--ink); }
.segment.active {
    background: var(--panel-soft);
    color: var(--accent);
    box-shadow: var(--shadow-sm);
}

.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 0.4rem;
}
.toggle-row input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--accent); }

.color-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.color-item { display: flex; flex-direction: column; gap: 0.3rem; }
.color-item span { font-size: 0.72rem; color: var(--ink-quiet); }
input[type="color"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 34px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: #fff;
    padding: 2px;
    transition: border-color var(--transition);
}
input[type="color"]:hover { border-color: var(--accent); }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 3px; }

/* ===== DIALOGS & MODALS ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(28, 27, 25, 0.45);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s ease;
}
.modal-overlay.hidden { display: none; opacity: 0; pointer-events: none; }
.render-dialog {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    padding: 2.4rem;
    width: 460px;
    box-shadow: var(--shadow-lg);
    transform: translateY(0);
    transition: transform 0.4s ease;
}
.modal-overlay.hidden .render-dialog { transform: translateY(30px); }
.render-dialog h3 {
    font-family: var(--font-display);
    font-size: 1.45rem;
    font-weight: 400;
    margin-bottom: 0.7rem;
    color: var(--ink);
    letter-spacing: -0.02em;
}

.progress-track { width: 100%; height: 6px; background: rgba(28, 27, 25, 0.08); border-radius: 3px; overflow: hidden; margin-bottom: 0.75rem; }
.progress-fill { height: 100%; width: 0%; background: var(--accent); transition: width 0.3s ease; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.75rem; }

.dl-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--panel-soft);
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    border: 1px solid var(--line);
}
.dl-item a { color: var(--accent); text-decoration: none; font-weight: 600; }
.dl-item a:hover { opacity: 0.8; }

/* ===== PREMIUM / GLASSMORPHIC ===== */
.glass-modal { background: rgba(17, 16, 15, 0.88); }
.glass-panel {
    background: rgba(25, 24, 22, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    color: #fff;
}

.paywall-panel { text-align: center; position: relative; overflow: hidden; }
.paywall-panel::before {
    content: "";
    position: absolute;
    inset: -40% -20% auto;
    height: 220px;
    background: radial-gradient(ellipse, rgba(194, 107, 63, 0.24) 0%, rgba(31, 58, 95, 0.12) 55%, transparent 70%);
    z-index: 0;
    pointer-events: none;
}
.paywall-icon {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: rgba(194, 107, 63, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    position: relative;
    z-index: 1;
    border: 1px solid rgba(194, 107, 63, 0.35);
}
.paywall-panel h3 {
    font-size: 1.6rem;
    font-weight: 600;
    color: #fff;
    position: relative;
    z-index: 1;
}
.price-tag {
    font-size: 2.6rem;
    font-weight: 800;
    color: #fff;
    margin: 1.5rem 0;
    position: relative;
    z-index: 1;
    letter-spacing: -0.03em;
}
.price-tag span { font-size: 1rem; color: rgba(255, 255, 255, 0.7); font-weight: 500; }

/* ===== TOASTS ===== */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    pointer-events: none;
}
.toast {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-lg);
    background: #fff;
    border: 1px solid var(--line);
    color: var(--ink);
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: var(--shadow-md);
    pointer-events: auto;
    animation: rise 0.4s ease both;
    max-width: 380px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.toast.success { border-left: 4px solid #3f6b58; }
.toast.error { border-left: 4px solid #b42318; }
.toast.info { border-left: 4px solid var(--accent); }

/* ===== EMAIL VERIFICATION BANNER ===== */
.verification-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.6rem 1.25rem;
    font-size: 0.82rem;
    font-weight: 600;
    background: rgba(194, 107, 63, 0.12);
    border-bottom: 1px solid rgba(194, 107, 63, 0.3);
    color: var(--accent-warm);
}
.verification-banner a { color: #9a4f2d; text-decoration: underline; cursor: pointer; font-weight: 700; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1400px) {
    .editor-layout { grid-template-columns: 300px 1fr 320px; gap: 1.2rem; padding: 1.5rem; }
}
@media (max-width: 1100px) {
    .editor-layout { grid-template-columns: 1fr 1fr; }
    .panel-player { grid-column: 1 / -1; margin-bottom: 1rem; position: relative; top: auto; }
}
@media (max-width: 768px) {
    .editor-layout { grid-template-columns: 1fr; padding: 1rem; }
    .top-nav { padding: 0.75rem 1.25rem; }
    .nav-actions .header-status { display: none; }
    .canvas-container { padding: 3rem 1.5rem; }
    .mascot-strip { grid-template-columns: 1fr; text-align: center; }
    .mascot-figure { margin: 0 auto; }
}
