/* Characterly — White background, 3D Cards theme */

:root {
    --bg: #f6f7fb;
    --bg-soft: #ffffff;
    --bg-card: #ffffff;
    --bg-hover: #f1f3f9;
    --border: #e4e7ee;
    --border-strong: #cfd4e0;
    --text: #161826;
    --text-soft: #3a3f55;
    --text-muted: #7a8194;
    --accent: #5B2D8E;
    --accent-hover: #6f3aa8;
    --accent-soft: #ece2fa;
    --cyan: #1ed3c5;
    --green: #22b07a;
    --red: #e25c5c;
    --yellow: #e9a13a;
    --blue: #4a7df0;
    --radius: 20px;
    --radius-sm: 12px;

    --shadow-1: 0 1px 0 rgba(255,255,255,0.9) inset, 0 1px 2px rgba(20,24,40,0.04);
    --shadow-2: 0 6px 14px rgba(20,24,40,0.06), 0 2px 4px rgba(20,24,40,0.04);
    --shadow-3: 0 18px 38px rgba(20,24,40,0.10), 0 6px 12px rgba(20,24,40,0.05);
    --shadow-violet: 0 18px 40px rgba(91,45,142,0.18), 0 6px 14px rgba(91,45,142,0.10);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { background: var(--bg); }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

.app-shell { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: 248px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin: 18px 0 18px 18px;
    padding: 22px 0 18px;
    position: fixed;
    top: 0; left: 0;
    height: calc(100vh - 36px);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-2);
}
.sidebar-brand { padding: 0 22px 18px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.sidebar-brand h1 { font-size: 22px; font-weight: 800; color: var(--accent); letter-spacing: -0.6px; }
.sidebar-brand span { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }
.sidebar nav { flex: 1; padding: 4px 10px; overflow-y: auto; }
.sidebar nav a {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px; margin: 2px 0;
    border-radius: 12px;
    color: var(--text-soft);
    font-size: 14px; font-weight: 500;
    transition: all .15s ease;
}
.sidebar nav a:hover { background: var(--bg-hover); color: var(--text); }
.sidebar nav a.active { background: var(--accent); color: #fff; box-shadow: var(--shadow-violet); }
.sidebar nav a.active .nav-icon { color: var(--cyan); }
.nav-icon { width: 20px; text-align: center; font-size: 16px; }
.sidebar-footer { padding: 12px 22px; font-size: 12px; color: var(--text-muted); border-top: 1px solid var(--border); }

/* Main */
.main { flex: 1; margin-left: 284px; padding: 32px 40px 60px; min-width: 0; }

/* Headings */
h1, h2, h3, h4 { color: var(--text); font-weight: 700; }
h1 { font-size: 28px; letter-spacing: -0.5px; margin-bottom: 6px; }
h2 { font-size: 20px; margin-bottom: 4px; }
h3 { font-size: 16px; }
p { color: var(--text-soft); line-height: 1.55; }
small, .muted { color: var(--text-muted); font-size: 12.5px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 26px; flex-wrap: wrap; }
.page-head p { color: var(--text-muted); margin-top: 4px; }

/* 3D Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow-2);
    transition: transform .2s ease, box-shadow .2s ease;
    position: relative;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-3); }
.card-flat { box-shadow: var(--shadow-1); }
.card-flat:hover { transform: none; box-shadow: var(--shadow-1); }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.card-title { font-weight: 700; font-size: 15px; color: var(--text); }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 980px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.module-tile {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 26px; box-shadow: var(--shadow-2);
    display: flex; flex-direction: column; gap: 10px;
    transition: transform .2s ease, box-shadow .2s ease;
    position: relative; overflow: hidden; color: inherit;
}
.module-tile::before {
    content: ""; position: absolute; inset: 0;
    background: linear-gradient(135deg, rgba(91,45,142,0.06), rgba(30,211,197,0.05));
    opacity: 0; transition: opacity .25s ease; pointer-events: none;
}
.module-tile:hover { transform: translateY(-4px); box-shadow: var(--shadow-3); color: inherit; }
.module-tile:hover::before { opacity: 1; }
.module-tile .icon {
    width: 44px; height: 44px; border-radius: 14px;
    background: var(--accent-soft); color: var(--accent);
    display: grid; place-items: center;
    font-size: 22px; font-weight: 700; box-shadow: var(--shadow-1);
}
.module-tile h3 { font-size: 17px; color: var(--text); }
.module-tile p { font-size: 13.5px; color: var(--text-muted); }
.module-tile .open { color: var(--accent); font-weight: 600; font-size: 13px; margin-top: 6px; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 18px;
    background: var(--accent); color: #fff;
    border: 1px solid var(--accent); border-radius: 12px;
    font-size: 14px; font-weight: 600; cursor: pointer;
    box-shadow: 0 6px 16px rgba(91,45,142,0.25), inset 0 1px 0 rgba(255,255,255,0.18);
    transition: transform .15s ease, box-shadow .15s ease, background .15s;
    text-decoration: none;
}
.btn:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 10px 22px rgba(91,45,142,0.30); color: #fff; }
.btn:active { transform: translateY(0); }
.btn-secondary { background: var(--bg-soft); color: var(--accent); border: 1px solid var(--border-strong); box-shadow: var(--shadow-1); }
.btn-secondary:hover { background: var(--bg-hover); color: var(--accent); }
.btn-ghost { background: transparent; color: var(--text-soft); border-color: transparent; box-shadow: none; }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-danger { background: var(--red); border-color: var(--red); box-shadow: 0 6px 16px rgba(226,92,92,0.25); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }

/* Forms */
label { display: block; font-size: 13px; font-weight: 600; color: var(--text-soft); margin-bottom: 6px; }
input[type="text"], input[type="email"], input[type="password"], input[type="url"], input[type="number"],
input[type="file"], textarea, select {
    width: 100%; padding: 11px 14px;
    background: var(--bg-soft);
    border: 1px solid var(--border-strong); border-radius: 12px;
    color: var(--text); font-size: 14px; font-family: inherit;
    box-shadow: var(--shadow-1);
    transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(91,45,142,0.12);
}
textarea { resize: vertical; min-height: 90px; font-family: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace; }
.field { margin-bottom: 16px; }
.field-row { display: flex; gap: 14px; flex-wrap: wrap; }
.field-row > * { flex: 1; min-width: 180px; }

/* Flash */
.flash { padding: 12px 16px; border-radius: 12px; margin-bottom: 18px; font-size: 14px; background: var(--bg-soft); border: 1px solid var(--border); box-shadow: var(--shadow-1); }
.flash-success { border-color: rgba(34,176,122,0.4); color: var(--green); background: rgba(34,176,122,0.08); }
.flash-error   { border-color: rgba(226,92,92,0.4); color: var(--red); background: rgba(226,92,92,0.07); }
.flash-info    { border-color: rgba(74,125,240,0.4); color: var(--blue); background: rgba(74,125,240,0.07); }

/* Tables */
table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--bg-card); border-radius: var(--radius-sm); overflow: hidden; box-shadow: var(--shadow-1); }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13.5px; }
th { background: var(--bg-hover); font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted); font-weight: 600; }
tr:last-child td { border-bottom: none; }

/* Tags */
.tag { display: inline-block; padding: 4px 10px; background: var(--accent-soft); color: var(--accent); border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.tag-green { background: rgba(34,176,122,0.12); color: var(--green); }
.tag-red   { background: rgba(226,92,92,0.12); color: var(--red); }
.tag-blue  { background: rgba(74,125,240,0.12); color: var(--blue); }
.tag-muted { background: var(--bg-hover); color: var(--text-muted); }

/* Character/asset cards */
.character-grid, .asset-grid {
    display: grid; gap: 18px;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.character-card, .asset-card {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    overflow: hidden; box-shadow: var(--shadow-2);
    transition: transform .2s ease, box-shadow .2s ease;
    display: flex; flex-direction: column; color: inherit;
}
.character-card:hover, .asset-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-3); }
.character-card img, .asset-card img {
    width: 100%; aspect-ratio: 1/1; object-fit: cover; background: var(--bg-hover);
    border-bottom: 1px solid var(--border);
}
.character-card .meta, .asset-card .meta { padding: 14px 16px; }
.character-card .name, .asset-card .name { font-weight: 700; font-size: 14px; color: var(--text); }
.character-card .role, .asset-card .role { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.asset-card.selected { outline: 2px solid var(--accent); transform: translateY(-4px); box-shadow: var(--shadow-violet); }
.add-card {
    border: 2px dashed var(--border-strong); background: var(--bg-soft); border-radius: var(--radius);
    display: grid; place-items: center; min-height: 240px;
    color: var(--accent); font-weight: 600; font-size: 14px;
    transition: background .15s, border-color .15s, transform .15s;
}
.add-card:hover { background: var(--accent-soft); border-color: var(--accent); transform: translateY(-3px); }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.stat { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px 18px; box-shadow: var(--shadow-1); }
.stat .label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .4px; }
.stat .value { font-size: 22px; font-weight: 800; color: var(--text); margin-top: 4px; }
@media (max-width: 880px) { .stats { grid-template-columns: repeat(2, 1fr); } }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 22px; }
.tab { padding: 10px 16px; cursor: pointer; color: var(--text-muted); font-weight: 600; font-size: 14px; border-bottom: 2px solid transparent; transition: color .15s, border-color .15s; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Wardrobe layout */
.wardrobe-layout { display: grid; grid-template-columns: 320px 1fr; gap: 22px; }
.wardrobe-preview { position: sticky; top: 22px; height: fit-content; }
.wardrobe-preview img { width: 100%; border-radius: var(--radius); box-shadow: var(--shadow-2); background: var(--bg-hover); }
@media (max-width: 980px) { .wardrobe-layout { grid-template-columns: 1fr; } }

/* Selected state for radio-cards used in render mode pickers */
.card-flat:has(input[type="radio"]:checked) {
    border-color: var(--accent);
    background: var(--accent-soft);
    box-shadow: 0 0 0 3px rgba(91,45,142,0.18), var(--shadow-2);
}
.card-flat:has(input[type="radio"]:checked) strong {
    color: var(--accent);
}

.outlier-card { padding: 16px; }
.outlier-card .score { display: inline-flex; align-items: center; gap: 6px; background: var(--accent-soft); color: var(--accent); padding: 4px 10px; border-radius: 999px; font-weight: 700; font-size: 12px; }

/* Utility */
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-end { justify-content: flex-end; }
.spread { display:flex; justify-content: space-between; align-items: center; gap: 12px; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }
.hidden { display: none !important; }
.center { text-align: center; }
.empty {
    background: var(--bg-soft); border: 1px dashed var(--border-strong); border-radius: var(--radius);
    padding: 50px 20px; text-align: center; color: var(--text-muted);
}
.empty h3 { color: var(--text); margin-bottom: 6px; }

.topbar {
    display: flex; justify-content: flex-end; align-items: center; gap: 12px;
    padding: 0 0 18px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}

/* Wizard progress bar */
.wizard-progress {
    display: flex; align-items: center; gap: 10px;
    margin: 6px 0 28px; padding: 18px 22px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-2);
}
.wizard-step { display:flex; align-items:center; gap:10px; }
.step-dot {
    width: 30px; height: 30px; border-radius: 50%;
    display: grid; place-items: center; font-weight: 700; font-size: 13px;
    background: var(--bg-hover); color: var(--text-muted);
    border: 1.5px solid var(--border-strong);
}
.wizard-step.is-done .step-dot { background: var(--green); color: #fff; border-color: var(--green); }
.wizard-step.is-current .step-dot { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: var(--shadow-violet); }
.step-label { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.wizard-step.is-done .step-label, .wizard-step.is-current .step-label { color: var(--text); }
.wizard-bar { flex: 1; height: 2px; background: var(--border); border-radius: 2px; }
.wizard-step.is-done + .wizard-bar { background: var(--green); }

.scene-row { display: grid; grid-template-columns: 80px 1fr auto; gap: 14px; padding: 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--bg-card); margin-bottom: 10px; }
.scene-row .num { font-weight: 800; font-size: 20px; color: var(--accent); }
.scene-row textarea { min-height: 60px; }
.script-textarea { min-height: 360px; font-family: 'JetBrains Mono', monospace; font-size: 13.5px; line-height: 1.55; }

/* ─── Play Mode: Sims/Fashion-Icon game UI ─────────────────── */
.play-stage {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 22px;
    margin-bottom: 22px;
}
@media (max-width: 1080px) { .play-stage { grid-template-columns: 1fr; } }

.stage-pane {
    background: linear-gradient(180deg, #f9f4ff 0%, #eef6ff 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow-2);
    min-height: 520px;
    position: relative;
    overflow: hidden;
}
.stage-pane::before {
    content: ""; position: absolute; inset: 0;
    background: radial-gradient(ellipse at 50% 100%, rgba(91,45,142,0.08), transparent 60%);
    pointer-events: none;
}
.stage-character {
    display: grid; place-items: center;
    width: 100%; aspect-ratio: 9/16; max-height: 540px;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 16px 32px rgba(91,45,142,0.18), inset 0 0 0 1px rgba(255,255,255,0.6);
    background: #fff;
    margin: 0 auto;
    position: relative;
}
.stage-character img { width: 100%; height: 100%; object-fit: cover; }
.stage-character .preview-overlay {
    position: absolute; top: 12px; left: 12px;
    background: rgba(255,255,255,0.92); backdrop-filter: blur(8px);
    padding: 6px 10px; border-radius: 10px; font-size: 12px; font-weight: 600;
    box-shadow: var(--shadow-1);
}
.stage-character .preview-bubble {
    position: absolute; bottom: 16px; left: 16px; right: 16px;
    background: rgba(255,255,255,0.96); backdrop-filter: blur(10px);
    padding: 12px 14px; border-radius: 14px;
    font-size: 14px; font-weight: 600;
    box-shadow: var(--shadow-2);
    border: 1px solid var(--border);
}

/* Side panel (actions / outfits / accessories / envs) */
.play-side {
    display: flex; flex-direction: column; gap: 14px;
}
.side-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 16px; padding: 14px; box-shadow: var(--shadow-2);
}
.side-card h4 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-muted); margin-bottom: 10px; font-weight: 700; }
.side-card .scroll {
    display: flex; gap: 8px; overflow-x: auto;
    padding-bottom: 6px;
    scrollbar-width: thin;
}
.chip {
    flex: 0 0 auto;
    background: var(--bg-soft); border: 1.5px solid var(--border);
    border-radius: 12px; padding: 8px 10px;
    cursor: pointer; transition: all .15s ease;
    box-shadow: var(--shadow-1);
    display: flex; align-items: center; gap: 6px;
    font-size: 13px; font-weight: 600; color: var(--text-soft);
    min-width: 76px; justify-content: center;
}
.chip.thumb { width: 76px; height: 76px; padding: 0; overflow: hidden; }
.chip.thumb img { width: 100%; height: 100%; object-fit: cover; }
.chip:hover { transform: translateY(-2px); border-color: var(--accent); }
.chip.selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-2); }
.chip .check {
    position: absolute; top: 6px; right: 6px; width: 18px; height: 18px;
    border-radius: 50%; background: var(--accent); color: #fff;
    display: grid; place-items: center; font-size: 11px; font-weight: 700;
}
.chip { position: relative; }

/* Pose preset buttons */
.preset-grid {
    display: grid; gap: 8px;
    grid-template-columns: repeat(2, 1fr);
}
.preset-btn {
    background: var(--bg-soft); border: 1.5px solid var(--border);
    border-radius: 12px; padding: 10px;
    text-align: left; cursor: pointer; transition: all .15s ease;
    font-size: 12.5px; font-weight: 600; color: var(--text-soft);
    box-shadow: var(--shadow-1);
    display: flex; align-items: center; gap: 8px;
}
.preset-btn:hover { transform: translateY(-2px); border-color: var(--accent); color: var(--text); }
.preset-btn.selected { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.preset-btn .emoji { font-size: 18px; }

/* Big SNAP button */
.snap-btn {
    width: 100%; padding: 16px;
    background: linear-gradient(135deg, var(--accent) 0%, #8245c2 100%);
    color: #fff; border: none; border-radius: 14px;
    font-size: 17px; font-weight: 800; letter-spacing: 0.4px;
    cursor: pointer;
    box-shadow: 0 12px 28px rgba(91,45,142,0.36), inset 0 1px 0 rgba(255,255,255,0.2);
    transition: transform .15s ease, box-shadow .15s ease;
}
.snap-btn:hover { transform: translateY(-2px); box-shadow: 0 18px 36px rgba(91,45,142,0.42); }
.snap-btn:active { transform: translateY(0); }
.snap-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Frame timeline */
.timeline {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 14px;
    box-shadow: var(--shadow-2);
}
.timeline-strip {
    display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px;
}
.frame-card {
    flex: 0 0 auto; width: 130px;
    background: var(--bg-soft); border: 1px solid var(--border);
    border-radius: 14px; overflow: hidden; box-shadow: var(--shadow-2);
    position: relative;
}
.frame-card img { width: 100%; aspect-ratio: 9/16; object-fit: cover; }
.frame-card .meta { padding: 8px 10px; font-size: 11.5px; }
.frame-card .num { position: absolute; top: 8px; left: 8px;
    background: var(--accent); color: #fff; border-radius: 50%;
    width: 22px; height: 22px; display: grid; place-items: center;
    font-size: 11px; font-weight: 800; box-shadow: var(--shadow-2);
}
.frame-card .x {
    position: absolute; top: 6px; right: 6px;
    background: rgba(255,255,255,0.92); border: 1px solid var(--border);
    width: 22px; height: 22px; border-radius: 50%;
    cursor: pointer; font-size: 12px; color: var(--red);
    display: grid; place-items: center; font-weight: 700;
}

.search-bar {
    display: flex; gap: 10px; align-items: center;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 14px; padding: 8px 14px;
    box-shadow: var(--shadow-1);
}
.search-bar input { border: none; box-shadow: none; padding: 6px 0; background: transparent; }
.search-bar input:focus { box-shadow: none; }

/* ─── App modal (replaces native confirm/alert/prompt) ───── */
.app-modal-backdrop {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(20, 24, 40, 0.42);
    backdrop-filter: blur(6px);
    display: grid; place-items: center;
    padding: 24px;
    opacity: 0; pointer-events: none;
    transition: opacity .15s ease;
}
.app-modal-backdrop.is-open { opacity: 1; pointer-events: auto; }

.app-modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 28px 60px rgba(20,24,40,0.22), 0 8px 20px rgba(20,24,40,0.10);
    width: 100%; max-width: 460px;
    padding: 26px 26px 22px;
    transform: translateY(8px) scale(0.98);
    transition: transform .18s ease;
}
.app-modal-backdrop.is-open .app-modal { transform: translateY(0) scale(1); }

.app-modal-icon {
    width: 48px; height: 48px; border-radius: 14px;
    display: grid; place-items: center;
    background: var(--accent-soft); color: var(--accent);
    font-size: 22px; font-weight: 800;
    margin-bottom: 14px;
    box-shadow: var(--shadow-1);
}
.app-modal-icon.warn { background: rgba(233,161,58,0.14); color: var(--yellow); }
.app-modal-icon.danger { background: rgba(226,92,92,0.12); color: var(--red); }
.app-modal-icon.info { background: rgba(74,125,240,0.12); color: var(--blue); }

.app-modal h3 { font-size: 18px; margin-bottom: 6px; }
.app-modal p { color: var(--text-soft); font-size: 14px; line-height: 1.5; margin-bottom: 18px; }
.app-modal .row { justify-content: flex-end; gap: 10px; }

/* ─── Toasts (replaces noisy alerts) ─── */
.app-toast-stack {
    position: fixed; right: 22px; top: 22px; z-index: 1100;
    display: flex; flex-direction: column; gap: 10px;
    pointer-events: none;
}
.app-toast {
    pointer-events: auto;
    min-width: 280px; max-width: 380px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px 16px;
    box-shadow: 0 12px 28px rgba(20,24,40,0.14);
    font-size: 13.5px;
    color: var(--text);
    display: flex; align-items: flex-start; gap: 10px;
    transform: translateX(110%); opacity: 0;
    transition: transform .22s ease, opacity .22s ease;
}
.app-toast.is-shown { transform: translateX(0); opacity: 1; }
.app-toast.toast-success { border-left: 4px solid var(--green); }
.app-toast.toast-error   { border-left: 4px solid var(--red); }
.app-toast.toast-info    { border-left: 4px solid var(--blue); }
.app-toast .x {
    margin-left: auto; cursor: pointer; color: var(--text-muted);
    background: none; border: none; font-size: 16px; line-height: 1;
}
.app-toast .x:hover { color: var(--text); }

/* Progress bar */
.progress-track {
    width: 100%; height: 8px;
    background: rgba(91,45,142,0.10);
    border-radius: 999px;
    overflow: hidden;
    box-shadow: inset 0 1px 2px rgba(20,24,40,0.05);
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent) 0%, #8245c2 60%, var(--cyan) 100%);
    background-size: 200% 100%;
    transition: width .35s ease;
    border-radius: 999px;
    animation: progress-shimmer 1.8s linear infinite;
}
@keyframes progress-shimmer {
    0% { background-position: 0% 0; }
    100% { background-position: 200% 0; }
}
.progress-fill.is-done {
    background: var(--green);
    animation: none;
}
.progress-fill.is-failed {
    background: var(--red);
    animation: none;
}

/* ── Hover info tooltips (.info-tip) ──────────────────────── */
.info-tip{
    display:inline-flex;align-items:center;justify-content:center;
    width:18px;height:18px;border-radius:50%;
    background:rgba(91,45,142,0.10);color:var(--accent);
    font-size:11px;font-weight:700;font-style:normal;
    cursor:help;margin-left:6px;vertical-align:middle;
    transition:background .15s ease, color .15s ease;
    user-select:none;
    line-height:1;
}
.info-tip:hover,.info-tip:focus{background:var(--accent);color:#fff;outline:none}


/* ═══════════════════════════════════════════════════════════════════
   MOBILE OPTIMIZATIONS — covers phones (<=768px) and small tablets.
   - Sidebar becomes off-canvas drawer toggled by hamburger
   - Main content goes full-width
   - Multi-column grids stack to single column
   - Tables get horizontal scroll
   - Forms with field-row stack vertically
   - Touch targets sized to 44px minimum
   ═══════════════════════════════════════════════════════════════════ */

/* Hamburger button — hidden on desktop, shown on mobile */
.hamburger {
    display: none;
    position: fixed;
    top: 14px; left: 14px;
    z-index: 9050;
    width: 44px; height: 44px;
    border-radius: 12px;
    background: var(--card);
    border: 1px solid var(--border);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
    align-items: center; justify-content: center;
    cursor: pointer;
    color: var(--text);
    font-size: 20px;
}
.hamburger:active { transform: scale(0.94); }

/* Sidebar backdrop (mobile only) */
.sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(2px);
    z-index: 8000;
}
.sidebar-backdrop.open { display: block; }

/* ── Tablet & below (<=1024px): tighten paddings ── */
@media (max-width: 1024px) {
    .main { padding: 28px 24px 60px; margin-left: 268px; }
    .sidebar { width: 232px; }
    h1 { font-size: 24px; }
}

/* ── Phone-sized (<=768px): full off-canvas sidebar ── */
@media (max-width: 768px) {
    body { font-size: 14px; }

    /* Show hamburger, hide sidebar by default */
    .hamburger { display: flex; }

    .sidebar {
        width: 280px;
        margin: 0;
        border-radius: 0;
        border-left: none; border-top: none; border-bottom: none;
        height: 100vh;
        top: 0; left: 0;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 8500;
        padding-top: 64px;  /* room for the close button */
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-backdrop { display: none; }
    .sidebar-backdrop.open { display: block; }

    /* Main fills the screen */
    .main {
        margin-left: 0 !important;
        padding: 64px 16px 48px;
    }

    /* Headings shrink */
    h1 { font-size: 22px; letter-spacing: -0.3px; }
    h2 { font-size: 17px; }
    h3 { font-size: 15px; }
    .page-head { flex-direction: column; align-items: stretch; gap: 8px; margin-bottom: 18px; }

    /* Top bar: push content below hamburger */
    .topbar { padding-left: 56px; min-height: 44px; }

    /* Grids stack */
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr !important; gap: 12px; }
    .stats { grid-template-columns: 1fr !important; }

    /* Cards: tighter padding */
    .card { padding: 16px; border-radius: 12px; }

    /* Forms: rows stack */
    .field-row { flex-direction: column; gap: 10px; }
    .field-row > * { flex: 1 1 100% !important; min-width: 0; }

    /* Inputs: bump tap target + prevent iOS zoom on focus */
    input[type="text"], input[type="email"], input[type="password"],
    input[type="number"], input[type="url"], input[type="search"],
    select, textarea {
        font-size: 16px !important;   /* iOS won't zoom if >=16px */
        padding: 10px 12px;
        min-height: 44px;
    }
    textarea { min-height: 88px; }

    /* Buttons: bigger tap targets */
    .btn, button.btn { min-height: 44px; padding: 10px 16px; font-size: 14px; }
    .btn-sm { min-height: 38px; padding: 8px 12px; font-size: 13px; }
    .btn-ghost { min-height: 38px; }

    /* Tables: horizontal scroll wrapper */
    table { font-size: 12.5px; }
    table thead th, table tbody td { padding: 8px 10px !important; }
    /* Make any table inside a card scroll horizontally without breaking layout */
    .card table { display: block; overflow-x: auto; white-space: nowrap; }
    .card table thead, .card table tbody, .card table tr { display: table; width: 100%; table-layout: auto; }

    /* Help bubble: smaller, slightly less intrusive */
    .help-bubble { width: 46px; height: 46px; font-size: 20px; right: 16px; bottom: 16px; }
    .help-menu  { right: 16px; bottom: 74px; width: 230px; max-width: calc(100vw - 32px); }

    /* Modal sizing */
    .help-modal-back { padding: 12px; }
    .help-modal { padding: 18px; }

    /* In-app modal narrows */
    .app-modal { max-width: calc(100vw - 32px); padding: 22px; }
    .app-modal h3 { font-size: 17px; }
    .app-modal p { font-size: 14px; }

    /* Topbar email shrinks */
    .topbar span { font-size: 11.5px; }

    /* Wizard progress steps (Scene Studio): wrap & shrink */
    .progress-steps { font-size: 11px; gap: 4px; flex-wrap: wrap; }

    /* Operator console sub-nav: scroll horizontally */
    .row[style*="flex-wrap:wrap"] { gap: 6px; }
}

/* ── Very small phones (<=400px): one more squeeze ── */
@media (max-width: 400px) {
    .main { padding: 60px 12px 40px; }
    .card { padding: 14px; }
    h1 { font-size: 20px; }
    .btn { font-size: 13.5px; }
    .help-menu { min-width: calc(100vw - 28px); }
}

/* ── Landscape phones: hamburger still works, give content air ── */
@media (max-height: 500px) and (max-width: 900px) {
    .main { padding-top: 58px; }
}
