/* Artifis Storyboard — app stylesheet */
:root {
    --bg: #0f1115;
    --bg-soft: #14171d;
    --bg-card: #1a1e26;
    --bg-card-2: #232833;
    --bg-input: #1a1e26;
    --border: #2a2f3a;
    --border-strong: #3a414f;
    --text: #e6e8ee;
    --text-dim: #a8aebd;
    --muted: #6f7689;
    --accent: #f59e0b;
    --accent-2: #fbbf24;
    --accent-text: #1a1410;
    --danger: #ef4444;
    --danger-bg: #2a1414;
    --ring: 0 0 0 2px rgba(245, 158, 11, .35);
    --shadow-card: 0 1px 0 rgba(255,255,255,.04), 0 8px 24px rgba(0,0,0,.35);
    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 14px;
    --space: 16px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Liberation Sans", sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: light) {
    :root {
        --bg: #f6f7f9;
        --bg-soft: #eef0f4;
        --bg-card: #ffffff;
        --bg-card-2: #f6f7f9;
        --bg-input: #ffffff;
        --border: #e4e6eb;
        --border-strong: #cdd1d9;
        --text: #1c1f26;
        --text-dim: #4b5160;
        --muted: #7b8194;
        --accent: #d97706;
        --accent-2: #f59e0b;
        --accent-text: #ffffff;
        --shadow-card: 0 1px 0 rgba(0,0,0,.02), 0 6px 18px rgba(15, 23, 42, .08);
    }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
input, textarea, select, button { font: inherit; color: inherit; }
textarea { resize: vertical; }
kbd {
    font-family: var(--mono);
    font-size: 11px;
    padding: 1px 5px;
    border-radius: 4px;
    background: var(--bg-card-2);
    border: 1px solid var(--border);
}
.muted { color: var(--muted); }

/* ===== App header ===== */
.app-header {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px;
    padding: 10px 22px;
    background: rgba(15, 17, 21, .85);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}
@media (prefers-color-scheme: light) {
    .app-header { background: rgba(255, 255, 255, .85); }
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-link { display: flex; align-items: center; gap: 8px; font-weight: 600; letter-spacing: .2px; }
.brand-link svg { color: var(--accent); }
.crumb-sep { color: var(--muted); }
.crumb { color: var(--text-dim); max-width: 50vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.header-actions { display: flex; align-items: center; gap: 10px; }

.toolbar { display: flex; align-items: center; gap: 8px; }
.export-group { display: inline-flex; align-items: center; gap: 6px; padding: 4px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); }
.export-group .btn { padding: 6px 10px; }
.select-compact {
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    border: 1px solid var(--border);
}

/* User menu */
.user-menu { position: relative; }
.user-menu summary { list-style: none; cursor: pointer; }
.user-menu summary::-webkit-details-marker { display: none; }
.avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--accent); color: var(--accent-text);
    font-weight: 700;
}
.user-menu-panel {
    position: absolute; right: 0; top: calc(100% + 8px);
    width: 240px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 10px;
    z-index: 40;
}
.user-info { padding: 6px 6px 10px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.user-name { font-weight: 600; }
.user-email { color: var(--muted); font-size: 12px; }
.link-button {
    background: none; border: 0; padding: 6px 8px;
    color: inherit; cursor: pointer; border-radius: var(--radius-sm); width: 100%;
    text-align: left;
}
.link-button:hover { background: var(--bg-card-2); }

/* ===== Buttons ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 6px;
    height: 36px; padding: 0 14px;
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 500;
    transition: background .12s, border-color .12s, transform .04s;
}
.btn:hover { background: var(--bg-card-2); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.btn-primary:hover { background: var(--accent-2); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--bg-card-2); }
.btn-block { width: 100%; }
.btn-small { height: 28px; padding: 0 10px; font-size: 13px; }
.btn-danger-ghost { background: transparent; color: var(--danger); border-color: transparent; }
.btn-danger-ghost:hover { background: var(--danger-bg); }

/* ===== Main ===== */
.app-main { padding: 24px 28px 80px; max-width: 1480px; margin: 0 auto; }

/* ===== Projects list ===== */
.page-head {
    display: flex; align-items: end; justify-content: space-between;
    gap: 16px; margin-bottom: 24px;
}
.page-head h1 { margin: 0 0 4px; font-size: 24px; font-weight: 700; }
.page-head p { margin: 0; }
.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}
.project-card {
    display: flex; flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: transform .15s, border-color .15s, box-shadow .15s;
}
.project-card:hover { transform: translateY(-2px); border-color: var(--border-strong); box-shadow: var(--shadow-card); }
.project-cover {
    position: relative;
    aspect-ratio: 16/9;
    background: var(--bg-card-2);
    overflow: hidden;
    display: flex; align-items: center; justify-content: center;
}
.project-cover[data-ar="9:16"] { aspect-ratio: 9/16; }
.project-cover[data-ar="1:1"] { aspect-ratio: 1/1; }
.project-cover[data-ar="4:3"] { aspect-ratio: 4/3; }
.project-cover[data-ar="2.39:1"] { aspect-ratio: 2.39/1; }
.project-cover[data-ar="1.85:1"] { aspect-ratio: 1.85/1; }
.project-cover[data-ar="3:2"] { aspect-ratio: 3/2; }
.project-cover img { width: 100%; height: 100%; object-fit: cover; }
.empty-thumb { color: var(--muted); font-size: 12px; }
.project-info { padding: 14px 16px 16px; }
.project-title { font-weight: 600; margin-bottom: 6px; }
.project-meta { color: var(--muted); font-size: 12px; display: flex; gap: 8px; flex-wrap: wrap; }

.empty {
    text-align: center;
    padding: 80px 24px;
    background: var(--bg-card);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-lg);
}
.empty-art { font-size: 64px; margin-bottom: 8px; }
.empty h2 { margin: 0 0 6px; font-weight: 600; }

/* ===== Auth ===== */
.auth-body {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; padding: 24px;
    background: radial-gradient(circle at 30% 20%, rgba(245, 158, 11, .12), transparent 50%), var(--bg);
}
.auth-card {
    width: 100%; max-width: 380px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-card);
}
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; color: var(--text); }
.auth-brand svg { color: var(--accent); }
.auth-brand h1 { font-size: 18px; margin: 0; font-weight: 600; }
.auth-sub { color: var(--muted); margin: 0 0 18px; }
.auth-error {
    background: var(--danger-bg);
    border: 1px solid rgba(239, 68, 68, .3);
    color: #ffd5d5;
    padding: 10px 12px; border-radius: var(--radius);
    margin-bottom: 14px; font-size: 13px;
}
@media (prefers-color-scheme: light) {
    .auth-error { color: #b91c1c; }
}
.auth-form { display: grid; gap: 12px; }
.auth-form label { display: grid; gap: 6px; }
.auth-form label span { color: var(--text-dim); font-size: 12px; }
.auth-form input {
    height: 40px; padding: 0 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
}
.auth-form input:focus { outline: none; box-shadow: var(--ring); border-color: var(--accent); }
.auth-form .btn { margin-top: 6px; height: 40px; }

/* ===== Editor ===== */
.page-editor { background: var(--bg); }
.editor-shell {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 24px;
    align-items: start;
}
.upload-rail {
    position: sticky; top: 78px;
    display: grid; gap: 12px;
}
.drop-zone {
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    padding: 28px 16px;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.drop-zone:hover, .drop-zone:focus { border-color: var(--accent); background: var(--bg-card-2); outline: none; }
.drop-zone.is-active { border-color: var(--accent); background: rgba(245, 158, 11, .07); }
.drop-icon { font-size: 28px; color: var(--accent); }
.drop-title { font-weight: 600; margin-top: 6px; }
.drop-sub { font-size: 12px; margin-top: 2px; }

.rail-stats {
    display: grid; gap: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    color: var(--text-dim);
    font-size: 12px;
}
.rail-stats strong { color: var(--text); font-weight: 600; }
.rail-tips { display: grid; gap: 4px; padding: 0 4px; }
.tip { font-size: 12px; color: var(--muted); }

.upload-progress {
    padding: 10px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.upload-progress-bar {
    height: 6px; border-radius: 3px;
    background: var(--bg-card-2);
    overflow: hidden;
    margin-bottom: 6px;
}
#uploadProgressFill {
    height: 100%; width: 0;
    background: var(--accent);
    transition: width .15s;
}

/* ===== Board ===== */
.board { min-height: 60vh; }
.board-empty {
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    padding: 80px 24px;
    text-align: center;
}
.board-empty-art { font-size: 64px; }
.board-empty h2 { margin: 8px 0 6px; font-weight: 600; }

.scene-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 20px;
}

/* ===== Scene card ===== */
.scene-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-card);
    display: flex; flex-direction: column;
    transition: border-color .15s, transform .12s;
}
.scene-card.is-dragging { opacity: .5; }
.scene-card.is-drop-target { border-color: var(--accent); transform: scale(1.01); }
.scene-card.has-color {
    border-left: 4px solid var(--color, var(--accent));
}
.scene-card[data-color="red"]    { --color: #ef4444; }
.scene-card[data-color="orange"] { --color: #f97316; }
.scene-card[data-color="amber"]  { --color: #f59e0b; }
.scene-card[data-color="green"]  { --color: #22c55e; }
.scene-card[data-color="blue"]   { --color: #3b82f6; }
.scene-card[data-color="violet"] { --color: #8b5cf6; }

.scene-card.is-sequence-start {
    position: relative; margin-top: 28px;
}
.scene-card.is-sequence-start::before {
    content: attr(data-sequence-label);
    position: absolute;
    top: -22px; left: 0;
    color: var(--text-dim);
    font-size: 11px; font-weight: 700;
    letter-spacing: 0.12em; text-transform: uppercase;
}

.scene-frame {
    position: relative;
    background: var(--bg-card-2);
    aspect-ratio: 16/9;
}
.scene-frame[data-ar="9:16"] { aspect-ratio: 9/16; }
.scene-frame[data-ar="1:1"] { aspect-ratio: 1/1; }
.scene-frame[data-ar="4:3"] { aspect-ratio: 4/3; }
.scene-frame[data-ar="2.39:1"] { aspect-ratio: 2.39/1; }
.scene-frame[data-ar="1.85:1"] { aspect-ratio: 1.85/1; }
.scene-frame[data-ar="3:2"] { aspect-ratio: 3/2; }
.scene-frame-inner {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
}
.scene-frame-inner img { width: 100%; height: 100%; object-fit: contain; background: #000; }
.scene-frame-placeholder { color: var(--muted); font-size: 12px; }

.scene-number-badge {
    position: absolute; top: 8px; left: 8px;
    background: rgba(0, 0, 0, .55);
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px; font-weight: 700; letter-spacing: .04em;
    backdrop-filter: blur(2px);
    pointer-events: none;
}
.scene-number-badge:empty { display: none; }

.scene-handle {
    position: absolute; top: 6px; right: 8px;
    width: 26px; height: 26px;
    display: inline-flex; align-items: center; justify-content: center;
    color: #fff;
    background: rgba(0, 0, 0, .35);
    border-radius: 6px;
    cursor: grab;
    user-select: none;
    opacity: 0; transition: opacity .15s;
}
.scene-card:hover .scene-handle { opacity: 1; }
.scene-handle:active { cursor: grabbing; }

.scene-actions {
    position: absolute; bottom: 8px; right: 8px;
    display: inline-flex; gap: 4px;
    opacity: 0; transition: opacity .15s;
}
.scene-card:hover .scene-actions { opacity: 1; }
.icon-btn {
    width: 28px; height: 28px;
    display: inline-flex; align-items: center; justify-content: center;
    background: rgba(0, 0, 0, .55);
    border: 0;
    color: #fff;
    border-radius: 6px;
    cursor: pointer;
}
.icon-btn:hover { background: rgba(0, 0, 0, .75); }

/* Scene body */
.scene-body { padding: 12px 14px 14px; display: grid; gap: 8px; }
.scene-row { display: flex; gap: 8px; }
.scene-title {
    flex: 1;
    background: transparent;
    border: 1px solid transparent;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    color: var(--text);
}
.scene-title::placeholder { color: var(--muted); font-weight: 500; }
.scene-title:hover, .scene-title:focus { border-color: var(--border); background: var(--bg-card-2); outline: none; }

.scene-number {
    width: 70px;
    background: transparent;
    border: 1px solid transparent;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    text-align: right;
    font-family: var(--mono);
}
.scene-number:hover, .scene-number:focus { border-color: var(--border); background: var(--bg-card-2); outline: none; }

.scene-description {
    background: var(--bg-card-2);
    border: 1px solid var(--border);
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--text);
    min-height: 60px;
    font-family: var(--font);
}
.scene-description:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.scene-description::placeholder { color: var(--muted); }

.scene-extras summary {
    list-style: none;
    cursor: pointer;
    color: var(--text-dim);
    font-size: 12px;
    padding: 4px 0;
    user-select: none;
}
.scene-extras summary::-webkit-details-marker { display: none; }
.scene-extras summary::before { content: '▸ '; color: var(--muted); }
.scene-extras[open] summary::before { content: '▾ '; }

.scene-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding-top: 8px;
}
.scene-grid .field { display: grid; gap: 4px; }
.scene-grid .field.col-2 { grid-column: span 2; }
.scene-grid .field span:not(.checkbox) { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.scene-grid input, .scene-grid select, .scene-grid textarea {
    background: var(--bg-card-2);
    border: 1px solid var(--border);
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    color: var(--text);
    width: 100%;
}
.scene-grid input:focus, .scene-grid select:focus, .scene-grid textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.scene-grid .checkbox { display: inline-flex; gap: 6px; align-items: center; text-transform: none; letter-spacing: 0; font-size: 12px; color: var(--text-dim); }
.sequence-row { display: grid; gap: 6px; }

.scene-tags { display: flex; flex-wrap: wrap; gap: 4px; padding-top: 4px; }
.scene-tag {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--bg-card-2);
    color: var(--text-dim);
    border: 1px solid var(--border);
}

/* ===== Dialog ===== */
.dialog {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    color: var(--text);
    padding: 22px;
    width: min(560px, calc(100vw - 32px));
    max-height: calc(100vh - 80px);
}
.dialog::backdrop { background: rgba(0, 0, 0, .45); backdrop-filter: blur(2px); }
.dialog-form h2 { margin: 0 0 16px; font-size: 18px; }
.dialog-form label { display: grid; gap: 6px; margin-bottom: 12px; }
.dialog-form label span { color: var(--text-dim); font-size: 12px; }
.dialog-form input, .dialog-form select, .dialog-form textarea {
    background: var(--bg-input);
    border: 1px solid var(--border);
    padding: 8px 10px;
    border-radius: var(--radius);
    color: var(--text);
    width: 100%;
}
.dialog-form input:focus, .dialog-form select:focus, .dialog-form textarea:focus {
    outline: none; border-color: var(--accent); box-shadow: var(--ring);
}
.dialog-actions { display: flex; gap: 8px; justify-content: end; margin-top: 16px; }
.dialog-actions.space-between { justify-content: space-between; }
.dialog-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.dialog-grid label { margin-bottom: 0; }
.dialog-grid .col-2 { grid-column: span 2; }

/* ===== Scene context menu ===== */
.scene-menu {
    position: fixed;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px;
    min-width: 180px;
    box-shadow: var(--shadow-card);
    z-index: 60;
}
.scene-menu button {
    display: block; width: 100%; text-align: left;
    background: transparent; border: 0; color: var(--text);
    padding: 6px 10px; border-radius: var(--radius-sm);
    cursor: pointer;
}
.scene-menu button:hover { background: var(--bg-card-2); }
.scene-menu button.danger { color: var(--danger); }
.scene-menu button.danger:hover { background: var(--danger-bg); }
.scene-menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }

/* ===== Toast ===== */
.toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
    padding: 10px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    opacity: 0; pointer-events: none;
    transition: opacity .2s, transform .2s;
    z-index: 80;
    font-size: 13px;
}
.toast.is-show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.is-error { border-color: var(--danger); color: #ffd5d5; }
@media (prefers-color-scheme: light) { .toast.is-error { color: #b91c1c; } }

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .app-main { padding: 16px; }
    .editor-shell { grid-template-columns: 1fr; }
    .upload-rail { position: static; }
    .page-head { flex-direction: column; align-items: start; }
    .toolbar { flex-wrap: wrap; }
    .dialog-grid { grid-template-columns: 1fr; }
    .dialog-grid .col-2 { grid-column: auto; }
}
