/* ══════════════════════════════════════════════════════════════════
   Art Generator — additions on top of research.css
   ══════════════════════════════════════════════════════════════════ */

/* ─────────────────────── LEFT PANE SCROLL ─────────────────────── */
.ag-pane-scroll {
    padding: 16px !important;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ─────────────────────── KIND SELECTOR (segmented) ─────────────────────── */
.ag-kind-bar {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    background: var(--slate-100);
    border: 1px solid var(--slate-200);
    border-radius: 12px;
    padding: 4px;
    gap: 3px;
}
.ag-kind {
    padding: 9px 10px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--slate-600);
    font: 600 13px 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.ag-kind:hover:not(.disabled):not(.active) {
    background: rgba(255, 255, 255, 0.6);
    color: var(--slate-900);
}
.ag-kind.active {
    background: #fff;
    color: var(--brand-700);
    font-weight: 700;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 0 0 1px var(--brand-200) inset;
}
.ag-kind.disabled { opacity: 0.4; cursor: not-allowed; }

/* ─────────────────────── CARD ─────────────────────── */
.ag-card {
    background: #fff;
    border: 1px solid var(--slate-200);
    border-radius: 12px;
    padding: 14px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}
.ag-card-accent {
    background: linear-gradient(180deg, var(--brand-50), #fff 70%);
    border-color: var(--brand-200);
}
.ag-card-head {
    display: flex;
    align-items: center;
    gap: 8px;
    font: 800 10px 'Inter', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--slate-500);
    margin-bottom: 12px;
}
.ag-card-head svg { color: var(--slate-400); }
.ag-card-accent .ag-card-head svg { color: var(--brand-500); }
.ag-card-head-spacer { flex: 1; }
.ag-card-head-hint {
    font-size: 10px;
    color: var(--brand-600);
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.ag-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 6px;
    background: var(--slate-100);
    color: var(--slate-600);
    font: 700 11px 'Inter', sans-serif;
    border-radius: 9px;
    letter-spacing: 0;
}
.ag-badge.active { background: var(--brand-100); color: var(--brand-700); }

/* ─────────────────────── FIELDS ─────────────────────── */
.ag-label {
    display: block;
    font: 800 10px 'Inter', sans-serif;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--slate-500);
    margin-bottom: 6px;
}
.ag-label-inline {
    font: 800 10px 'Inter', sans-serif;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--slate-500);
}
.ag-sub {
    font-size: 11.5px;
    color: var(--slate-500);
    margin-top: 6px;
    line-height: 1.45;
}
.ag-sub-inline { margin-top: 0; margin-left: 10px; }

.ag-control {
    display: block;
    width: 100%;
    padding: 9px 10px;
    background: #fff;
    border: 1px solid var(--slate-300);
    border-radius: 8px;
    color: var(--slate-900);
    font: inherit;
    font-size: 13.5px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.ag-control:focus {
    outline: none;
    border-color: var(--brand-500);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}
.ag-control:hover { border-color: var(--slate-400); }
.ag-textarea {
    resize: vertical;
    min-height: 92px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
}

.ag-field-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
}
.ag-field-cell { display: flex; flex-direction: column; }

@media (max-width: 900px) {
    .ag-field-row { grid-template-columns: 1fr; gap: 10px; }
}

/* ─────────────────────── VIDEO OPTIONS ROW ─────────────────────── */
.ag-video-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 14px;
    align-items: center;
}
.ag-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}
.ag-toggle input { display: none; }
.ag-toggle-visual {
    width: 38px;
    height: 22px;
    background: var(--slate-300);
    border-radius: 999px;
    position: relative;
    transition: background 0.2s;
    flex-shrink: 0;
}
.ag-toggle-visual::after {
    content: '';
    position: absolute;
    top: 2px; left: 2px;
    width: 18px; height: 18px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25);
}
.ag-toggle input:checked ~ .ag-toggle-visual { background: var(--brand-500); }
.ag-toggle input:checked ~ .ag-toggle-visual::after { transform: translateX(16px); }
.ag-toggle-label {
    font-size: 13.5px;
    color: var(--slate-800);
    font-weight: 600;
}

.ag-stepper {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    border: 1px solid var(--slate-300);
    border-radius: 8px;
    padding: 3px 6px 3px 10px;
}
.ag-stepper-label {
    font: 700 10px 'Inter', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--slate-500);
}
.ag-stepper-input {
    width: 38px;
    border: none;
    background: transparent;
    text-align: center;
    font: 700 14px 'Inter', sans-serif;
    color: var(--slate-900);
    padding: 4px 0;
    outline: none;
}
.ag-stepper-input::-webkit-inner-spin-button,
.ag-stepper-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.ag-stepper-suffix {
    font-size: 12px;
    color: var(--slate-400);
    font-weight: 600;
}

/* ─────────────────────── REF GRID ─────────────────────── */
.ag-ref-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 5px;
}
.ag-ref-slot {
    aspect-ratio: 1;
    background: var(--slate-50);
    border: 1.5px dashed var(--slate-300);
    border-radius: 7px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    color: var(--slate-400);
    padding: 0;
    transition: all 0.15s;
}
.ag-ref-slot.empty:hover {
    border-color: var(--brand-500);
    color: var(--brand-600);
    background: var(--brand-50);
}
.ag-ref-slot img { width: 100%; height: 100%; object-fit: cover; }
.ag-ref-slot-remove {
    position: absolute;
    top: 2px; right: 2px;
    background: rgba(15, 23, 42, 0.78);
    color: white;
    border: none;
    border-radius: 3px;
    width: 16px; height: 16px;
    font-size: 9px;
    cursor: pointer;
    line-height: 1;
}
.ag-ref-slot-handle {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(15, 23, 42, 0.82);
    color: #fff;
    font: 700 9px 'Inter', sans-serif;
    text-align: center;
    padding: 2px 0;
    cursor: pointer;
    letter-spacing: 0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 0.15s;
}
.ag-ref-slot-handle:hover {
    background: var(--brand-600);
}

/* AI Director modal */
.ag-director-card {
    width: min(820px, 96vw);
    max-height: 92vh;
    display: flex !important;
    flex-direction: column;
}
.ag-director-body { padding: 22px !important; overflow-y: auto; }
.ag-dir-mode-bar {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
    background: var(--slate-100);
    border: 1px solid var(--slate-200);
    border-radius: 10px;
    padding: 4px;
    margin-bottom: 18px;
}
.ag-dir-mode {
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: 7px;
    color: var(--slate-600);
    font: 600 13px 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.15s;
}
.ag-dir-mode:hover:not(.active) { background: rgba(255,255,255,0.6); color: var(--slate-900); }
.ag-dir-mode.active {
    background: #fff;
    color: var(--brand-700);
    font-weight: 700;
    box-shadow: 0 1px 3px rgba(15,23,42,0.08), inset 0 0 0 1px var(--brand-200);
}
.ag-dir-pane[hidden] { display: none !important; }
.ag-dir-cost-summary {
    padding: 12px 14px;
    background: linear-gradient(135deg, var(--brand-50), #fff);
    border: 1px solid var(--brand-200);
    border-radius: 10px;
    font: 600 13px 'Inter', sans-serif;
    color: var(--brand-700);
    margin-top: 14px;
    font-variant-numeric: tabular-nums;
}
.ag-dir-foot {
    display: flex !important;
    justify-content: space-between;
    padding: 14px 22px;
}

/* Director live progress panel */
.ag-dir-progress {
    margin-top: 14px;
    padding: 14px;
    background: var(--slate-50);
    border: 1px solid var(--slate-200);
    border-radius: 10px;
}
.ag-dir-progress-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.ag-dir-progress-head strong { font: 700 13px 'Inter', sans-serif; color: var(--slate-900); }
.ag-dir-progress-status { font: 600 12px 'Inter', sans-serif; color: var(--brand-700); }
.ag-dir-progress-bar {
    height: 6px;
    background: var(--slate-200);
    border-radius: 99px;
    overflow: hidden;
    margin-bottom: 12px;
}
.ag-dir-progress-bar > div {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--brand-500), var(--brand-700));
    transition: width 0.6s ease;
}
.ag-dir-progress-beats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 6px;
    margin-bottom: 10px;
}
.ag-beat-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    background: #fff;
    border: 1px solid var(--slate-200);
    border-radius: 8px;
    font: 600 11px 'Inter', sans-serif;
}
.ag-beat-num {
    width: 18px; height: 18px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--slate-100); color: var(--slate-700);
    border-radius: 50%;
    font: 700 10px 'Inter', sans-serif;
}
.ag-beat-label { flex: 1; color: var(--slate-700); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ag-beat-state { font: 600 10px 'Inter', sans-serif; color: var(--slate-500); }
.ag-beat-state[data-state="running"] { color: var(--brand-600); }
.ag-beat-state[data-state="done"]    { color: #16a34a; }
.ag-beat-state[data-state="failed"]  { color: #dc2626; }
.ag-dir-progress-final { margin-top: 10px; }

/* Inpaint modal */
.ag-inpaint-card {
    width: min(820px, 96vw);
    max-height: 92vh;
    display: flex !important;
    flex-direction: column;
}
.ag-inpaint-body { padding: 18px !important; overflow-y: auto; }
.ag-inpaint-canvas-wrap {
    background: repeating-conic-gradient(#ddd 0% 25%, #fff 0% 50%) 50% / 16px 16px;
    border: 1px solid var(--slate-200);
    border-radius: 10px;
    padding: 8px;
    text-align: center;
    margin-bottom: 12px;
}
.ag-inpaint-canvas {
    cursor: crosshair;
    max-width: 100%;
    border-radius: 4px;
    background: #000;
}
.ag-inpaint-toolbar {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 10px;
    padding: 10px 12px;
    background: var(--slate-50);
    border-radius: 8px;
}
.ag-inpaint-toolbar label { display: flex; align-items: center; gap: 6px; font: 600 12px 'Inter', sans-serif; color: var(--slate-700); }
.ag-inpaint-foot {
    display: flex !important;
    justify-content: space-between;
    padding: 14px 22px;
}

/* Spend dashboard */
.ag-spend-card {
    width: min(880px, 96vw);
    max-height: 92vh;
    display: flex !important;
    flex-direction: column;
}
.ag-spend-body { padding: 22px !important; overflow-y: auto; }
.ag-spend-totals {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 22px;
}
.ag-spend-stat {
    padding: 16px;
    background: linear-gradient(135deg, var(--brand-50), #fff);
    border: 1px solid var(--brand-200);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.ag-spend-label { font: 600 11px 'Inter', sans-serif; color: var(--slate-600); text-transform: uppercase; letter-spacing: 0.04em; }
.ag-spend-val { font: 800 28px 'Inter', sans-serif; color: var(--brand-700); font-variant-numeric: tabular-nums; }
.ag-spend-sub { font: 500 12px 'Inter', sans-serif; color: var(--slate-500); }

.ag-spend-section { margin-bottom: 20px; }
.ag-spend-section h4 {
    margin: 0 0 10px 0;
    font: 700 12px 'Inter', sans-serif;
    color: var(--slate-700);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.ag-spend-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.ag-spend-bars {
    position: relative;
    height: 140px;
    background: var(--slate-50);
    border: 1px solid var(--slate-200);
    border-radius: 8px;
    padding: 8px 4px 24px 4px;
}
.ag-spend-bar {
    position: absolute;
    bottom: 24px;
    height: calc(100% - 28px);
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    padding: 0 2px;
}
.ag-spend-bar-fill {
    width: 100%;
    max-width: 28px;
    background: linear-gradient(180deg, var(--brand-500), var(--brand-700));
    border-radius: 3px 3px 0 0;
    transition: height 0.4s;
}
.ag-spend-bar-label {
    position: absolute;
    bottom: -22px;
    font: 500 10px 'Inter', sans-serif;
    color: var(--slate-500);
    transform: rotate(-30deg);
    transform-origin: center;
    white-space: nowrap;
}

.ag-spend-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.ag-spend-row {
    position: relative;
    padding: 8px 12px;
    background: #fff;
    border: 1px solid var(--slate-200);
    border-radius: 6px;
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    column-gap: 10px;
    overflow: hidden;
}
.ag-spend-row-bar {
    position: absolute;
    inset: 0 auto 0 0;
    background: linear-gradient(90deg, var(--brand-100), var(--brand-50));
    z-index: 0;
    border-radius: 6px;
}
.ag-spend-row-label,
.ag-spend-row-sub,
.ag-spend-row-cost { position: relative; z-index: 1; }
.ag-spend-row-label { font: 600 12px 'Inter', sans-serif; color: var(--slate-900); }
.ag-spend-row-sub   { font: 500 11px 'Inter', sans-serif; color: var(--slate-500); grid-column: 1; }
.ag-spend-row-cost  { font: 700 13px 'Inter', sans-serif; color: var(--brand-700); grid-row: 1 / 3; align-self: center; font-variant-numeric: tabular-nums; }

/* Spend forecast block */
.ag-spend-forecast {
    background: var(--slate-50);
    border: 1px solid var(--slate-200);
    border-radius: 10px;
    padding: 14px;
}
.ag-spend-fc-grid { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.ag-spend-fc-row { display: grid; grid-template-columns: 90px 1fr auto; gap: 10px; align-items: center; }
.ag-spend-fc-label { font: 600 12px 'Inter', sans-serif; color: var(--slate-700); }
.ag-spend-fc-bar { height: 8px; background: var(--slate-200); border-radius: 99px; overflow: hidden; }
.ag-spend-fc-bar > div { height: 100%; transition: width 0.4s; border-radius: 99px; }
.ag-spend-fc-val { font: 600 12px 'Inter', sans-serif; color: var(--slate-900); font-variant-numeric: tabular-nums; }
.ag-spend-fc-projections {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 16px;
    padding-top: 10px;
    border-top: 1px solid var(--slate-200);
    font: 500 12px 'Inter', sans-serif;
    color: var(--slate-700);
}

/* Share modal */
.ag-share-card { width: min(520px, 96vw); }
.ag-share-summary {
    padding: 10px 14px; background: var(--slate-50);
    border-radius: 8px; font: 600 12px 'Inter', sans-serif; color: var(--slate-700);
    margin-bottom: 18px;
}
.ag-share-section { margin-bottom: 22px; }
.ag-share-section h4 {
    margin: 0 0 8px; font: 700 12px 'Inter', sans-serif;
    text-transform: uppercase; letter-spacing: 0.04em; color: var(--slate-700);
}
.ag-share-row { display: flex; gap: 6px; }
.ag-share-row input { flex: 1; font: 500 12px 'Inter', sans-serif; }

/* Prompt templates */
.ag-templates-card { width: min(720px, 96vw); max-height: 88vh; display: flex !important; flex-direction: column; }
.ag-templates-list { display: flex; flex-direction: column; gap: 8px; }
.ag-template-row {
    display: flex; gap: 12px; align-items: center;
    padding: 12px 14px;
    background: #fff;
    border: 1px solid var(--slate-200);
    border-radius: 10px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.ag-template-row:hover { border-color: var(--brand-300); box-shadow: 0 2px 8px rgba(30,64,175,0.08); }
.ag-template-main { flex: 1; min-width: 0; }
.ag-template-name { font: 700 13px 'Inter', sans-serif; color: var(--slate-900); margin-bottom: 2px; }
.ag-template-meta { font: 500 11px 'Inter', sans-serif; color: var(--slate-500); margin-bottom: 4px; }
.ag-template-prompt { font: 400 12px 'Inter', sans-serif; color: var(--slate-700); line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ag-template-actions { display: flex; gap: 6px; flex: none; }
.ag-template-del {
    background: transparent; border: 1px solid var(--slate-200); border-radius: 6px;
    padding: 4px 10px; cursor: pointer; color: var(--slate-500); font-size: 14px;
}
.ag-template-del:hover { background: #fef2f2; border-color: #fecaca; color: #dc2626; }

/* Library (full-screen searchable cross-session gallery) */
.ag-library-card { width: min(1200px, 96vw); height: 92vh; display: flex !important; flex-direction: column; }
.ag-library-card .modal-title { display: flex; align-items: center; gap: 10px; }
.ag-library-card .modal-title .ag-sub { font: 500 12px 'Inter', sans-serif; }
.ag-library-pills {
    display: flex; gap: 4px; align-items: center;
    padding: 10px 18px;
    border-bottom: 1px solid var(--slate-200);
    background: #fff;
    flex-wrap: wrap;
}
.ag-pill {
    padding: 5px 11px;
    background: transparent;
    border: 1px solid var(--slate-200);
    border-radius: 99px;
    font: 600 12px 'Inter', sans-serif;
    color: var(--slate-600);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.ag-pill:hover { background: var(--slate-100); color: var(--slate-900); }
.ag-pill[data-active="1"] {
    background: var(--brand-600);
    color: #fff;
    border-color: var(--brand-700);
}
.ag-library-toolbar {
    display: flex; gap: 8px; align-items: center;
    padding: 10px 18px; background: var(--slate-50);
    border-bottom: 1px solid var(--slate-200);
    flex-wrap: wrap;
}
.ag-library-toolbar .ag-control { padding: 6px 10px; font: 500 12px 'Inter', sans-serif; height: auto; }
.ag-library-toolbar #lib-search { flex: 1; min-width: 200px; }
.ag-library-toolbar #lib-from, .ag-library-toolbar #lib-to { width: 130px; }
.ag-checkbox-label { display: flex; align-items: center; gap: 5px; font: 600 12px 'Inter', sans-serif; color: var(--slate-700); cursor: pointer; }
.ag-library-batch {
    display: flex; gap: 8px; align-items: center;
    padding: 10px 18px;
    background: linear-gradient(90deg, var(--brand-50), #fff);
    border-bottom: 1px solid var(--brand-200);
    font: 600 12px 'Inter', sans-serif; color: var(--slate-700);
}
.ag-library-batch button { font-size: 12px; padding: 5px 12px; }
.ag-library-body { padding: 16px 18px !important; overflow-y: auto; flex: 1; }
.ag-library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
}
.ag-lib-day-header {
    grid-column: 1 / -1;
    font: 700 11px 'Inter', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--slate-500);
    padding: 8px 0 4px;
    border-bottom: 1px solid var(--slate-100);
    margin-top: 6px;
}
.ag-lib-day-header:first-child { margin-top: 0; }
.ag-lib-tile {
    position: relative;
    aspect-ratio: 1;
    background: var(--slate-100);
    border: 2px solid transparent;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.15s, transform 0.15s;
    display: flex;
    flex-direction: column;
}
.ag-lib-tile:hover { border-color: var(--brand-400); transform: translateY(-1px); }
.ag-lib-tile.sel { border-color: var(--brand-600); box-shadow: 0 0 0 2px var(--brand-200); }
.ag-lib-tile img, .ag-lib-tile video {
    width: 100%; height: 100%; object-fit: cover; display: block;
}
/* Video tile: poster shows by default; <video> overlays on hover */
.ag-lib-tile-poster, .ag-lib-tile-video {
    position: absolute; inset: 0;
}
.ag-lib-tile-video {
    opacity: 0;
    transition: opacity 0.18s;
    pointer-events: none;
}
.ag-lib-tile:hover .ag-lib-tile-video { opacity: 1; }
.ag-lib-vid-icon, .ag-lib-audio-icon {
    flex: 1;
    display: flex; align-items: center; justify-content: center;
    font: 700 32px 'Inter', sans-serif;
    color: var(--brand-600);
    background: linear-gradient(135deg, var(--brand-50), #fff);
}
.ag-lib-tile-check {
    position: absolute; top: 6px; left: 6px; z-index: 2;
    width: 22px; height: 22px;
    background: rgba(255,255,255,0.9);
    border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
}
.ag-lib-tile-check input { width: 14px; height: 14px; cursor: pointer; }
.ag-lib-tile-meta {
    position: absolute; top: 6px; right: 6px; z-index: 2;
    display: flex; gap: 4px;
}
.ag-lib-tile-kind, .ag-lib-tile-cost {
    background: rgba(0,0,0,0.65); color: #fff;
    padding: 2px 6px; border-radius: 3px;
    font: 600 10px 'Inter', sans-serif;
}
.ag-lib-tile-prompt {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.85));
    color: #fff;
    padding: 18px 8px 6px;
    font: 500 11px 'Inter', sans-serif;
    line-height: 1.3;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ag-library-pager {
    display: flex; gap: 12px; align-items: center; justify-content: center;
    padding: 14px 0 4px;
}

/* Variations carousel chrome on canvas */
.ag-canvas-carousel {
    position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
    display: flex; align-items: center; gap: 8px;
    background: rgba(15, 23, 42, 0.78);
    color: #fff;
    border-radius: 99px;
    padding: 4px 8px;
    z-index: 10;
}
.ag-carousel-btn {
    background: transparent;
    border: none;
    color: #fff;
    font: 700 18px 'Inter', sans-serif;
    width: 28px; height: 28px;
    border-radius: 50%;
    cursor: pointer;
    line-height: 1;
}
.ag-carousel-btn:hover { background: rgba(255,255,255,0.15); }
.ag-carousel-dots { display: flex; align-items: center; gap: 5px; padding: 0 4px; }
.ag-carousel-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: rgba(255,255,255,0.4);
    border: none;
    cursor: pointer;
    padding: 0;
    transition: background 0.15s, transform 0.15s;
}
.ag-carousel-dot:hover { background: rgba(255,255,255,0.7); }
.ag-carousel-dot.active { background: #fff; transform: scale(1.4); }
.ag-carousel-counter { font: 600 11px 'Inter', sans-serif; opacity: 0.85; padding-left: 6px; }

/* Toast notifications */
#ag-toast-host {
    position: fixed; bottom: 20px; right: 20px;
    z-index: 100000;
    display: flex; flex-direction: column; gap: 8px;
    pointer-events: none;
    max-width: 380px;
}
.ag-toast {
    pointer-events: auto;
    display: flex; gap: 10px; align-items: flex-start;
    background: #fff;
    border: 1px solid var(--slate-200);
    border-left: 4px solid var(--slate-400);
    border-radius: 8px;
    padding: 10px 14px;
    box-shadow: 0 4px 16px rgba(15,23,42,0.12);
    font: 500 13px 'Inter', sans-serif;
    color: var(--slate-800);
    transform: translateX(110%);
    opacity: 0;
    transition: transform 0.25s ease, opacity 0.25s ease;
}
.ag-toast.show    { transform: translateX(0); opacity: 1; }
.ag-toast.dismiss { transform: translateX(110%); opacity: 0; }
.ag-toast-success { border-left-color: #16a34a; }
.ag-toast-error   { border-left-color: #dc2626; }
.ag-toast-info    { border-left-color: var(--brand-500); }
.ag-toast-warn    { border-left-color: #f59e0b; }
.ag-toast-confirm { border-left-color: var(--brand-700); }
.ag-toast-icon {
    flex: none;
    width: 22px; height: 22px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: var(--slate-100); color: var(--slate-600);
    font: 700 12px 'Inter', sans-serif;
}
.ag-toast-success .ag-toast-icon { background: #dcfce7; color: #16a34a; }
.ag-toast-error   .ag-toast-icon { background: #fee2e2; color: #dc2626; }
.ag-toast-info    .ag-toast-icon { background: var(--brand-100); color: var(--brand-700); }
.ag-toast-warn    .ag-toast-icon { background: #fef3c7; color: #b45309; }
.ag-toast-confirm .ag-toast-icon { background: var(--brand-100); color: var(--brand-700); }
.ag-toast-msg { flex: 1; line-height: 1.45; word-wrap: break-word; }
.ag-toast-actions { display: flex; gap: 6px; flex: none; align-self: center; }
.ag-toast-btn {
    padding: 4px 10px;
    background: var(--slate-100);
    border: 1px solid var(--slate-200);
    border-radius: 5px;
    font: 600 11px 'Inter', sans-serif;
    color: var(--slate-700);
    cursor: pointer;
}
.ag-toast-btn:hover { background: var(--slate-200); }
.ag-toast-btn-primary { background: var(--brand-600); color: #fff; border-color: var(--brand-700); }
.ag-toast-btn-primary:hover { background: var(--brand-700); }
.ag-toast-btn-danger  { background: #dc2626; color: #fff; border-color: #b91c1c; }
.ag-toast-btn-danger:hover { background: #b91c1c; }

/* Style preset editor */
.ag-style-edit-card { width: min(720px, 96vw); max-height: 92vh; display: flex !important; flex-direction: column; }
.ag-style-list { display: flex; flex-direction: column; gap: 6px; }
.ag-style-row {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 10px 12px;
    background: #fff;
    border: 1px solid var(--slate-200);
    border-radius: 8px;
}
.ag-style-row:hover { border-color: var(--brand-300); }
.ag-style-row-main { flex: 1; min-width: 0; }
.ag-style-row-label { font: 700 13px 'Inter', sans-serif; color: var(--slate-900); margin-bottom: 2px; }
.ag-style-row-label .ag-sub { font-weight: 500; color: var(--slate-400); margin-left: 6px; font-size: 11px; }
.ag-style-row-desc { font: 500 11px 'Inter', sans-serif; color: var(--slate-500); margin-bottom: 4px; }
.ag-style-row-mod { font: 400 11px 'JetBrains Mono', monospace; color: var(--slate-700); line-height: 1.3; }
.ag-style-row-actions { display: flex; gap: 6px; flex: none; }
.ag-style-form h4 {
    margin: 0 0 12px;
    font: 700 12px 'Inter', sans-serif;
    text-transform: uppercase; letter-spacing: 0.04em; color: var(--slate-700);
}

/* Crop modal */
.ag-crop-card { width: min(560px, 96vw); }

/* Drag-drop reference upload overlay */
#ag-dragdrop-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.78);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    pointer-events: none;
}
#ag-dragdrop-overlay.show { display: flex; }
.ag-dragdrop-inner {
    border: 3px dashed rgba(255, 255, 255, 0.85);
    border-radius: 18px;
    padding: 60px 80px;
    text-align: center;
    color: #fff;
}
.ag-dragdrop-inner svg { color: rgba(255, 255, 255, 0.9); margin-bottom: 18px; }
.ag-dragdrop-title { font: 700 22px 'Inter', sans-serif; margin-bottom: 6px; }
.ag-dragdrop-sub { font: 500 13px 'Inter', sans-serif; opacity: 0.75; }

/* Keyboard shortcuts overlay */
.ag-shortcuts-card { width: min(560px, 96vw); }
.ag-shortcuts-table { width: 100%; border-collapse: collapse; }
.ag-shortcuts-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--slate-100);
    font: 500 13px 'Inter', sans-serif;
    color: var(--slate-700);
}
.ag-shortcuts-table tr:last-child td { border-bottom: none; }
.ag-shortcuts-table td:first-child { text-align: left; white-space: nowrap; width: 40%; }
.ag-shortcuts-table kbd {
    display: inline-block;
    padding: 2px 7px;
    background: var(--slate-100);
    border: 1px solid var(--slate-300);
    border-bottom-width: 2px;
    border-radius: 4px;
    font: 600 11px 'JetBrains Mono', ui-monospace, SFMono-Regular, Consolas, monospace;
    color: var(--slate-900);
    min-width: 18px;
    text-align: center;
}

/* Flash highlight for loaded fields */
.ag-flash {
    animation: ag-flash-fade 1.2s ease;
}
@keyframes ag-flash-fade {
    0%   { background: var(--brand-100); box-shadow: 0 0 0 3px var(--brand-200); }
    100% { background: inherit; box-shadow: none; }
}

/* Scene Builder */
.ag-scene-builder-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    background: linear-gradient(135deg, var(--brand-50), var(--brand-100));
    border: 1px solid var(--brand-200);
    border-radius: 6px;
    color: var(--brand-700);
    font: 700 10px 'Inter', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    cursor: pointer;
    transition: all 0.15s;
}
.ag-scene-builder-btn:hover { background: var(--brand-100); border-color: var(--brand-400); }

.ag-scene-card {
    width: min(960px, 96vw);
    max-height: 92vh;
    display: flex !important;
    flex-direction: column;
}
.ag-scene-body {
    display: grid;
    grid-template-columns: 1fr 2fr 3fr;
    gap: 20px;
    padding: 22px !important;
    overflow-y: auto;
}
@media (max-width: 900px) {
    .ag-scene-body { grid-template-columns: 1fr; }
}
.ag-scene-col-wide { grid-column: span 1; }
.ag-scene-bg-slot {
    width: 100%;
}
.ag-scene-bg-slot .ag-ref-slot.empty {
    width: 100%;
    aspect-ratio: 16/10;
    font-size: 28px;
}
.ag-scene-bg-tile {
    position: relative;
    width: 100%;
    aspect-ratio: 16/10;
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid var(--brand-400);
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
}
.ag-scene-bg-tile img { width: 100%; height: 100%; object-fit: cover; }

.ag-scene-chars-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}
.ag-scene-chars-grid .ag-ref-slot {
    aspect-ratio: 1;
    border-radius: 10px;
}

.ag-scene-preview {
    margin-top: 14px;
    padding: 12px;
    background: var(--slate-50);
    border: 1px solid var(--slate-200);
    border-radius: 10px;
}
.ag-scene-preview-box {
    font: 400 13px 'Inter', sans-serif;
    line-height: 1.55;
    color: var(--slate-800);
    min-height: 40px;
}
.ag-scene-preview-box:has(br) {}

/* @-reference autocomplete popover */
.ag-atref-popover {
    position: fixed;
    z-index: 250;
    background: #fff;
    border: 1px solid var(--slate-200);
    border-radius: 10px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18), 0 4px 10px rgba(15, 23, 42, 0.06);
    overflow: hidden;
    max-height: 320px;
    overflow-y: auto;
    padding: 4px;
}
.ag-atref-popover[hidden] { display: none; }
.ag-atref-empty {
    padding: 16px 14px;
    color: var(--slate-400);
    font-size: 12px;
    text-align: center;
}
.ag-atref-item {
    display: grid;
    grid-template-columns: 32px 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 6px 10px;
    border-radius: 7px;
    cursor: pointer;
    transition: background 0.1s;
}
.ag-atref-item:hover,
.ag-atref-item.active {
    background: var(--brand-50);
}
.ag-atref-item img {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    object-fit: cover;
    background: var(--slate-100);
}
.ag-atref-thumb-empty {
    width: 32px; height: 32px;
    border-radius: 6px;
    background: var(--slate-100);
    color: var(--slate-400);
    display: grid; place-items: center;
    font: 700 13px 'Inter', sans-serif;
}
.ag-atref-handle {
    font: 800 12.5px 'Inter', sans-serif;
    color: var(--brand-700);
}
.ag-atref-name {
    font-size: 11px;
    color: var(--slate-500);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}
.ag-atref-picked {
    font: 700 10px 'Inter', sans-serif;
    color: #16a34a;
    background: #dcfce7;
    padding: 2px 6px;
    border-radius: 4px;
}

/* ── Prompt textarea pill overlay ─────────────────────────────────────
   A mirror div is positioned identically over the textarea. The textarea's
   own glyphs are made transparent (caret stays visible); the mirror renders
   the same text but with @imageN tokens wrapped in styled "hyperlink" pills
   that show a native filename tooltip on hover. */
.ag-prompt-mirror {
    /* Sized + styled identically to the textarea via class inheritance:
       see ".ag-prompt-wrap textarea.ag-textarea" + ".ag-control" rules. */
    position: absolute;
    inset: 0;
    pointer-events: none;
    color: var(--slate-900);
    background: transparent;
    overflow: hidden;
    z-index: 1;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    border: 1px solid transparent;
    margin: 0;
    box-sizing: border-box;
    font-family: inherit;
    /* These four MUST match .ag-prompt-wrap textarea.ag-textarea exactly */
    font-size: 14.5px;
    line-height: 1.5;
    padding: 9px 10px;
    border-radius: 8px;
}
.ag-prompt-textarea {
    position: relative;
    background: transparent !important;
    color: transparent !important;
    -webkit-text-fill-color: transparent;
    caret-color: var(--brand-700);
    z-index: 2;
}
.ag-prompt-textarea::selection {
    background: rgba(37, 99, 235, 0.22);
    color: transparent;
    -webkit-text-fill-color: transparent;
}
/* Pills in the mirror: hyperlink-styled with hover tooltip via title attr */
.ag-prompt-pill {
    color: var(--brand-700);
    font-weight: 600;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-decoration-color: rgba(29, 78, 216, 0.55);
    text-underline-offset: 2px;
    pointer-events: auto;
    cursor: help;
}

/* ─────────────────────── VARIATIONS ─────────────────────── */
.ag-variations-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--slate-200);
}
.ag-var-controls {
    display: flex;
    align-items: center;
    border: 1px solid var(--slate-300);
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}
.ag-var-btn {
    width: 28px; height: 30px;
    background: var(--slate-50);
    border: none;
    color: var(--slate-700);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    line-height: 1;
}
.ag-var-btn:hover { background: var(--brand-50); color: var(--brand-600); }
.ag-var-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.ag-var-input {
    width: 40px;
    border: none;
    border-left: 1px solid var(--slate-200);
    border-right: 1px solid var(--slate-200);
    text-align: center;
    font: 700 14px 'Inter', sans-serif;
    color: var(--slate-900);
    padding: 6px 0;
    outline: none;
}
.ag-var-input::-webkit-inner-spin-button,
.ag-var-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* ─────────────────────── ACTION BAR (cost + generate) ─────────────────────── */
.ag-action-bar {
    padding: 12px 16px !important;
    display: flex !important;
    flex-direction: column;
    gap: 10px;
    background: #fff;
    border-top: 1px solid var(--slate-200);
}
.ag-action-cost {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--slate-50);
    border: 1px solid var(--slate-200);
    border-radius: 10px;
    font-size: 13px;
}
.ag-cost-label {
    color: var(--slate-500);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 10px;
}
.ag-cost-value {
    font-weight: 800;
    color: var(--slate-900);
    font-variant-numeric: tabular-nums;
    font-size: 15px;
}
.ag-cost-sep { color: var(--slate-300); }
.ag-cost-count {
    color: var(--slate-600);
    font-variant-numeric: tabular-nums;
    font-size: 13px;
    font-weight: 600;
}
.ag-btn-generate {
    display: flex;
    width: 100%;
    padding: 13px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8 60%, #1e3a8a);
    border: none;
    border-radius: 12px;
    color: white;
    font: 700 14.5px 'Inter', sans-serif;
    letter-spacing: 0.02em;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    transition: all 0.15s;
    position: relative;
    overflow: hidden;
}
.ag-btn-generate:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(37, 99, 235, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.ag-btn-generate:active { transform: translateY(0); }
.ag-btn-generate:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

/* Ready-state shine sweep (activated via .is-ready class later, Phase B) */
.ag-btn-generate.is-ready::after {
    content: '';
    position: absolute;
    top: 0; left: -60%;
    width: 40%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.35), transparent);
    animation: agShine 2.8s ease-in-out infinite;
    pointer-events: none;
}
@keyframes agShine {
    0%,15% { left: -60%; }
    50% { left: 120%; }
    100% { left: 120%; }
}

.ag-status {
    padding: 10px 12px;
    font-size: 13px;
    border-radius: 8px;
    line-height: 1.5;
    display: none;
    border: 1px solid transparent;
}
.ag-status.show { display: block; }
.ag-status.info    { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.ag-status.running { background: var(--brand-50); color: var(--brand-700); border-color: var(--brand-200); }
.ag-status.error   { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.ag-status.success { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }

/* ─────────────────────── CANVAS ─────────────────────── */
/* Side-by-side layout: stage on left, mini-gallery column on right (desktop) */
.ag-canvas-row {
    display: flex;
    flex: 1;
    align-items: stretch;
    min-height: 0;
    height: 100%;
}
/* Left column: canvas-stage + footer (count + view-full-gallery link) */
.ag-canvas-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    padding: 18px 22px 14px;
    gap: 12px;
}
.ag-canvas-stage {
    flex: 1;
    min-height: 340px;
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background:
        radial-gradient(ellipse at top, rgba(37, 99, 235, 0.06), transparent 60%),
        linear-gradient(#ffffff, #fafbff);
    min-width: 0;
    border-radius: 14px;
    border: 1px solid var(--slate-200);
    box-shadow: 0 1px 0 rgba(15,23,42,0.02), 0 8px 24px rgba(15,23,42,0.05);
}
.ag-canvas-media { border-radius: 10px; }

/* Footer below canvas: image count (left) + View full gallery link (right) */
.ag-canvas-footer {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 4px 6px 2px;
    flex-shrink: 0;
}
.ag-canvas-footer[hidden] { display: none !important; }
.ag-cf-link {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 8px 14px;
    background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
    color: #fff !important; text-decoration: none;
    border-radius: 9px;
    font: 700 12px 'Inter', sans-serif;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
    transition: all 0.15s;
    border: 1px solid rgba(37, 99, 235, 0.5);
}
.ag-cf-link:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4); }
.ag-cf-count {
    font: 700 10.5px 'Inter', sans-serif;
    color: var(--slate-500);
    text-transform: uppercase;
    letter-spacing: 0.12em;
}
.ag-canvas-empty { text-align: center; color: var(--slate-500); }
.ag-canvas-icon {
    display: inline-grid; place-items: center;
    width: 64px; height: 64px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--brand-50), var(--brand-100));
    color: var(--brand-600);
    margin-bottom: 16px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 4px 12px rgba(37, 99, 235, 0.1);
}
.ag-canvas-title { font: 700 15px 'Inter', sans-serif; color: var(--slate-700); margin-bottom: 4px; }
.ag-canvas-sub { font-size: 13px; color: var(--slate-500); }
.ag-canvas-media { max-width: 100%; max-height: 100%; border-radius: 12px; box-shadow: 0 10px 40px rgba(15, 23, 42, 0.14); background: var(--slate-100); }

/* Close (X) — top-right corner of stage when a media is shown */
.ag-canvas-close {
    position: absolute;
    top: 12px; right: 12px;
    width: 32px; height: 32px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: rgba(255, 255, 255, 0.95);
    display: grid; place-items: center;
    cursor: pointer;
    transition: all 0.15s;
    backdrop-filter: blur(8px);
    z-index: 4;
    padding: 0;
}
.ag-canvas-close:hover {
    background: rgba(15, 23, 42, 0.78);
    border-color: rgba(255, 255, 255, 0.4);
    transform: scale(1.06);
}
.ag-canvas-close[hidden] { display: none !important; }

/* Inline action toolbar (in dark preview-pane-header) — white-themed to match topbar icons */
.ag-inline-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.ag-action-btn {
    width: 32px; height: 32px;
    padding: 0;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.92);
    font: inherit; font-size: 14px; font-weight: 600;
    line-height: 1;
    display: inline-grid; place-items: center;
    cursor: pointer;
    transition: all 0.15s;
    backdrop-filter: blur(8px);
}
.ag-action-btn:hover {
    background: rgba(255, 255, 255, 0.22);
    border-color: rgba(255, 255, 255, 0.4);
    color: #fff;
    transform: translateY(-1px);
}
.ag-action-btn:active { transform: translateY(0); }

/* ─────────────────────── RIGHT-SIDE MINI GALLERY ─────────────────────── */
.ag-gallery {
    width: 116px;
    flex-shrink: 0;
    background: #fff;
    border-left: 1px solid var(--slate-200);
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.ag-gallery-header {
    padding: 10px 10px 8px;
    font: 800 9.5px 'Inter', sans-serif;
    text-transform: uppercase; letter-spacing: 0.14em;
    color: var(--slate-500);
    border-bottom: 1px solid var(--slate-100);
    text-align: center;
}
.ag-gallery-header > span { display: block; }
/* Search not used in narrow column — keep DOM but hide visually */
.ag-gallery-search { display: none; }
.ag-gallery-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 10px 8px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}
.ag-gallery-empty {
    padding: 12px 6px;
    color: var(--slate-400);
    font-size: 11px;
    text-align: center;
    line-height: 1.4;
}
.ag-gallery-thumb {
    flex-shrink: 0;
    width: 82px;
    height: 82px;
    border-radius: 8px;
    background: var(--slate-100);
    cursor: pointer;
    border: 2px solid var(--slate-200);
    overflow: hidden;
    position: relative;
    transition: all 0.15s;
}
.ag-gallery-thumb:hover { border-color: var(--brand-300); transform: translateY(-1px); }
.ag-gallery-thumb.active { border-color: var(--brand-500); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18); }
.ag-gallery-thumb img, .ag-gallery-thumb video { width: 100%; height: 100%; object-fit: cover; }
.ag-thumb-kind {
    position: absolute; top: 3px; left: 3px;
    background: rgba(15, 23, 42, 0.78);
    color: white; padding: 1px 4px; border-radius: 3px;
    font: 700 8.5px 'Inter', sans-serif;
    text-transform: uppercase; letter-spacing: 0.06em;
}
.ag-thumb-fav {
    position: absolute; bottom: 3px; right: 4px;
    color: #fbbf24; font-size: 12px;
    filter: drop-shadow(0 1px 2px rgba(15, 23, 42, 0.4));
}

/* Mobile: collapse back to canvas-on-top, gallery-as-strip */
@media (max-width: 900px) {
    .ag-canvas-row { flex-direction: column; }
    .ag-gallery {
        width: auto;
        border-left: none;
        border-top: 1px solid var(--slate-200);
    }
    .ag-gallery-row {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        min-height: 110px;
        padding: 12px;
    }
}

/* ─────────────────────── AVATAR MANAGER ─────────────────────── */
.ag-avatars-card {
    width: min(1100px, 96vw);
    height: min(800px, 92vh);
    display: flex !important;
    flex-direction: column;
}
.ag-av-head-actions { display: flex; gap: 8px; align-items: center; }
.ag-avatars-body {
    overflow-y: auto;
    padding: 18px 22px !important;
    background: var(--slate-50);
}
.ag-av-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--slate-500);
    font-size: 13.5px;
    background: #fff;
    border: 1px dashed var(--slate-300);
    border-radius: 12px;
}
.ag-av-section-title {
    font: 800 11px 'Inter', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--slate-500);
    margin-bottom: 12px;
}
.ag-av-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}
.ag-av-card {
    background: #fff;
    border: 1px solid var(--slate-200);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: all 0.15s;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04);
}
.ag-av-card:hover { transform: translateY(-2px); box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08); border-color: var(--brand-300); }
.ag-av-thumb {
    aspect-ratio: 16/10;
    background: var(--slate-100);
    overflow: hidden;
}
.ag-av-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ag-av-thumb-empty {
    width: 100%; height: 100%;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--brand-50), var(--brand-200));
    color: var(--brand-700);
    font: 800 36px 'Inter', sans-serif;
}
.ag-av-meta { padding: 12px 14px; flex: 1; }
.ag-av-name {
    font: 700 14px 'Inter', sans-serif;
    color: var(--slate-900);
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ag-av-badges { display: flex; gap: 6px; margin-bottom: 6px; flex-wrap: wrap; }
.ag-av-id { font-size: 11px; color: var(--slate-500); font-family: ui-monospace, monospace; }
.ag-av-actions {
    display: flex;
    gap: 4px;
    padding: 8px 10px;
    background: var(--slate-50);
    border-top: 1px solid var(--slate-100);
    justify-content: flex-end;
}
.ag-av-act {
    padding: 5px 10px;
    background: #fff;
    border: 1px solid var(--slate-300);
    border-radius: 6px;
    color: var(--slate-700);
    font: 600 12px 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.15s;
}
.ag-av-act:hover { background: var(--brand-50); color: var(--brand-700); border-color: var(--brand-300); }
.ag-av-danger:hover { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.ag-av-add {
    background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
    color: #fff;
    border-color: transparent;
    font-weight: 700;
}
.ag-av-add:hover { background: linear-gradient(135deg, var(--brand-600), var(--brand-800)); color: #fff; transform: translateY(-1px); }

/* Add/edit form modal */
.ag-avform-card { width: min(560px, 92vw); max-height: 90vh; display: flex !important; flex-direction: column; }
.ag-avform-body { padding: 18px 22px !important; overflow-y: auto; }
.ag-avform-thumb-row { display: flex; gap: 8px; }

.ag-av-search {
    width: 260px;
    padding: 7px 12px;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 8px;
    color: #fff;
    font: inherit;
    font-size: 13px;
}
.ag-av-search::placeholder { color: rgba(255, 255, 255, 0.6); }
.ag-av-search:focus { outline: none; background: rgba(255, 255, 255, 0.2); border-color: rgba(255, 255, 255, 0.5); }
.ag-av-loadmore { display: flex; justify-content: center; margin-top: 18px; }

/* Photo Avatar generation modal */
.ag-pa-card {
    width: min(720px, 96vw);
    max-height: 92vh;
    display: flex !important;
    flex-direction: column;
}
.ag-pa-body {
    padding: 18px 22px !important;
    overflow-y: auto;
    flex: 1;
}
.ag-pa-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
    margin-top: 12px;
}
.ag-pa-photo {
    aspect-ratio: 1;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    border: 3px solid transparent;
    position: relative;
    transition: all 0.15s;
    background: var(--slate-100);
}
.ag-pa-photo:hover { border-color: var(--brand-300); }
.ag-pa-photo.selected { border-color: var(--brand-500); box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15); }
.ag-pa-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ag-pa-check {
    position: absolute;
    top: 8px; right: 8px;
    background: var(--brand-600);
    color: #fff;
    border-radius: 50%;
    width: 26px; height: 26px;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 800;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}
.ag-pa-photo.selected .ag-pa-check { display: flex; }
.ag-pa-foot { display: flex !important; justify-content: space-between; }
.ag-pa-foot[hidden] { display: none !important; }

/* ─────────────────────── AVATAR THUMB DISPLAY ─────────────────────── */
.ag-avatar-thumb-display {
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: linear-gradient(135deg, var(--brand-50), #fff 60%);
    border: 1px solid var(--brand-200);
    border-radius: 9px;
    font: 700 12px 'Inter', sans-serif;
    color: var(--brand-700);
}
.ag-avatar-thumb-display img {
    width: 36px; height: 36px;
    object-fit: cover;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.12);
}
.ag-avatar-thumb-placeholder {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
    color: #fff;
    display: grid; place-items: center;
    font: 800 14px 'Inter', sans-serif;
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.12);
}
.ag-avatar-thumb-display > span:first-of-type { flex: 1; }
.ag-avatar-mode-badge,
.ag-avatar-type-badge {
    padding: 2px 7px;
    border-radius: 999px;
    font: 800 9px 'Inter', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.ag-avatar-type-badge {
    background: rgba(15, 23, 42, 0.08);
    color: var(--slate-600);
}
.ag-avatar-mode-badge.mode-avatar_iv {
    background: linear-gradient(135deg, #8b5cf6, #6d28d9);
    color: #fff;
}
.ag-avatar-mode-badge.mode-avatar_v {
    background: linear-gradient(135deg, #ec4899, #be185d);
    color: #fff;
}
.ag-avatar-mode-badge.mode-unlimited {
    background: linear-gradient(135deg, #f59e0b, #c2410c);
    color: #fff;
}

/* ─────────────────────── COMPARE MODE ─────────────────────── */
.ag-cs-tile { position: relative; }
.ag-cmp-checkbox {
    position: absolute;
    top: 5px; left: 5px;
    width: 20px; height: 20px;
    background: rgba(15, 23, 42, 0.6);
    border: 1.5px solid rgba(255, 255, 255, 0.6);
    border-radius: 4px;
    color: #fff;
    cursor: pointer;
    display: grid; place-items: center;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s, border-color 0.15s;
    z-index: 2;
}
.ag-cs-tile:hover .ag-cmp-checkbox { opacity: 1; }
.ag-cmp-checkbox svg { opacity: 0; }
.ag-cs-tile.ag-cmp-selected .ag-cmp-checkbox {
    opacity: 1;
    background: var(--brand-600);
    border-color: var(--brand-200);
}
.ag-cs-tile.ag-cmp-selected .ag-cmp-checkbox svg { opacity: 1; }
.ag-cs-tile.ag-cmp-selected {
    box-shadow: inset 0 0 0 3px var(--brand-500), 0 0 0 1px var(--brand-300);
}

.ag-cmp-floating {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, var(--brand-600), var(--brand-800));
    color: #fff;
    border-radius: 999px;
    padding: 6px 6px 6px 18px;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 12px 32px rgba(37, 99, 235, 0.4);
    z-index: 80;
    animation: agSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.ag-cmp-floating[hidden] { display: none; }
@keyframes agSlideUp {
    from { transform: translate(-50%, 24px); opacity: 0; }
    to   { transform: translate(-50%, 0);    opacity: 1; }
}
.ag-cmp-floating-count {
    font: 700 12px 'Inter', sans-serif;
    letter-spacing: 0.04em;
}
.ag-cmp-clear {
    background: rgba(255, 255, 255, 0.18);
    border: none;
    color: #fff;
    width: 24px; height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
}
.ag-cmp-clear:hover { background: rgba(255, 255, 255, 0.3); }
.ag-cmp-floating-go {
    background: #fff;
    color: var(--brand-700);
    border: none;
    border-radius: 999px;
    padding: 8px 18px;
    font: 800 12.5px 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.15s;
}
.ag-cmp-floating-go:hover:not(:disabled) { transform: translateX(2px); box-shadow: 0 4px 10px rgba(255,255,255,0.4); }
.ag-cmp-floating-go:disabled { opacity: 0.5; cursor: not-allowed; }

/* Compare modal */
.ag-compare-card {
    width: min(1200px, 96vw);
    height: min(800px, 92vh);
    display: flex !important;
    flex-direction: column;
}
.ag-cmp-count {
    background: var(--brand-100);
    color: var(--brand-700);
    font: 700 11px 'Inter', sans-serif;
    padding: 2px 8px;
    border-radius: 999px;
    margin-left: 4px;
}
.ag-compare-body {
    overflow: auto;
    padding: 18px !important;
    display: grid;
    gap: 14px;
    background: var(--slate-50);
}
.ag-cmp-grid-2 { grid-template-columns: 1fr 1fr; }
.ag-cmp-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.ag-cmp-grid-4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }

.ag-cmp-tile {
    background: #fff;
    border: 1px solid var(--slate-200);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04);
}
.ag-cmp-tile-media {
    flex: 1;
    background: var(--slate-100);
    overflow: hidden;
    display: grid; place-items: center;
    min-height: 200px;
}
.ag-cmp-tile-media img, .ag-cmp-tile-media video {
    max-width: 100%; max-height: 100%;
    width: auto; height: auto;
    object-fit: contain;
}
.ag-cmp-tile-meta { padding: 10px 12px; border-top: 1px solid var(--slate-100); }
.ag-cmp-tile-prompt {
    font-size: 12px;
    line-height: 1.4;
    color: var(--slate-700);
    margin-bottom: 6px;
    max-height: 4em;
    overflow: hidden;
}
.ag-cmp-tile-stats {
    display: flex;
    gap: 12px;
    font: 700 10px 'Inter', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--slate-500);
    margin-bottom: 8px;
    font-variant-numeric: tabular-nums;
}
.ag-cmp-tile-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.ag-cmp-act {
    padding: 5px 10px;
    background: var(--slate-100);
    border: 1px solid var(--slate-200);
    border-radius: 6px;
    color: var(--slate-700);
    font: 600 11px 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.15s;
}
.ag-cmp-act:hover { background: var(--brand-50); color: var(--brand-700); border-color: var(--brand-300); }

/* ─────────────────────── PROMPT HELPERS (storyboard, history) ─────────────────────── */
.ag-prompt-wrap { position: relative; }
.ag-prompt-history-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    background: var(--slate-100);
    border: 1px solid var(--slate-200);
    border-radius: 6px;
    width: 24px;
    height: 24px;
    color: var(--slate-500);
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: all 0.15s;
}
.ag-prompt-history-btn:hover { background: var(--brand-50); color: var(--brand-600); border-color: var(--brand-300); }

.ag-prompt-helpers {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}
.ag-prompt-helper-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--slate-50);
    border: 1px dashed var(--slate-300);
    border-radius: 7px;
    color: var(--slate-600);
    font: 600 11px 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.15s;
}
.ag-prompt-helper-btn:hover {
    background: var(--brand-50);
    color: var(--brand-700);
    border-color: var(--brand-400);
    border-style: solid;
}

/* Prompt history popover items */
.ag-ph-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 10px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--slate-800);
    font: inherit;
    font-size: 12.5px;
    line-height: 1.4;
    cursor: pointer;
    margin-bottom: 2px;
    word-wrap: break-word;
    white-space: normal;
}
.ag-ph-item:hover { background: var(--brand-50); color: var(--brand-700); }
.ag-ph-empty {
    padding: 16px 10px;
    color: var(--slate-400);
    font-size: 12px;
    text-align: center;
}

/* ─────────────────────── STORYBOARD MODAL ─────────────────────── */
.ag-storyboard-card {
    width: min(820px, 92vw);
    max-height: 85vh;
    display: flex !important;
    flex-direction: column;
}
.ag-storyboard-body {
    padding: 18px 22px !important;
    overflow-y: auto;
    flex: 1;
}
.ag-sb-stage > .ag-label { margin-bottom: 6px; }
.ag-sb-config-row {
    display: flex;
    align-items: end;
    justify-content: space-between;
    margin-top: 14px;
    gap: 14px;
}
.ag-sb-cost-preview {
    font-size: 12px;
    color: var(--slate-500);
    text-align: right;
}
.ag-sb-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 16px;
}
.ag-sb-loading {
    text-align: center;
    padding: 40px 20px;
    color: var(--slate-500);
}
.ag-sb-loading .ag-chat-dots {
    justify-content: center;
    margin-bottom: 14px;
}
.ag-sb-review-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font: 800 11px 'Inter', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--slate-500);
}
.ag-sb-review-cost { color: var(--slate-900); font-size: 14px; font-variant-numeric: tabular-nums; }
.ag-sb-beats { display: flex; flex-direction: column; gap: 10px; }

/* Avatar chip picker (storyboard setup stage) */
.ag-sb-section-title {
    font: 800 11px 'Inter', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--slate-500);
    margin-bottom: 8px;
}
.ag-sb-avatars {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}
.ag-sb-avatars-empty {
    font-size: 12px;
    color: var(--slate-400);
    padding: 8px 12px;
    background: var(--slate-50);
    border: 1px dashed var(--slate-300);
    border-radius: 8px;
    width: 100%;
}
.ag-sb-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px 5px 5px;
    background: #fff;
    border: 1.5px solid var(--slate-300);
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.15s;
    font: 600 12px 'Inter', sans-serif;
    color: var(--slate-700);
    user-select: none;
}
.ag-sb-chip:hover { border-color: var(--brand-400); }
.ag-sb-chip.picked {
    background: linear-gradient(135deg, var(--brand-50), var(--brand-100));
    border-color: var(--brand-500);
    color: var(--brand-700);
    font-weight: 700;
}
.ag-sb-chip img {
    width: 24px; height: 24px;
    border-radius: 50%;
    object-fit: cover;
}
.ag-sb-chip-placeholder {
    width: 24px; height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
    color: #fff;
    display: grid; place-items: center;
    font: 800 11px 'Inter', sans-serif;
}
.ag-sb-chip-check {
    display: none;
    color: var(--brand-600);
    font-weight: 800;
}
.ag-sb-chip.picked .ag-sb-chip-check { display: inline; }

/* Review-stage beat avatar badge + dropdown */
.ag-sb-beat-head-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.ag-sb-beat-avatar {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px 2px 2px;
    background: var(--brand-50);
    border: 1px solid var(--brand-200);
    border-radius: 999px;
    font: 700 10px 'Inter', sans-serif;
    color: var(--brand-700);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
    overflow: hidden;
    max-width: 180px;
    text-overflow: ellipsis;
}
.ag-sb-beat-avatar img {
    width: 18px; height: 18px;
    border-radius: 50%;
    object-fit: cover;
}
.ag-sb-beat-avatar-ph {
    width: 18px; height: 18px;
    border-radius: 50%;
    background: var(--brand-500);
    color: #fff;
    display: inline-grid; place-items: center;
    font-size: 9px;
    font-weight: 800;
}
.ag-sb-beat-avatar.empty {
    background: var(--slate-100);
    border-color: var(--slate-200);
    color: var(--slate-500);
    padding: 3px 9px;
}
.ag-sb-beat-avselect {
    margin-top: 6px;
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--slate-200);
    border-radius: 6px;
    font: 600 11.5px 'Inter', sans-serif;
    background: #fff;
    color: var(--slate-700);
}
.ag-sb-beat {
    background: var(--slate-50);
    border: 1px solid var(--slate-200);
    border-radius: 10px;
    padding: 10px 12px;
    display: grid;
    grid-template-columns: 28px 1fr auto;
    gap: 10px;
    align-items: start;
}
.ag-sb-beat-num {
    background: var(--brand-100);
    color: var(--brand-700);
    border-radius: 6px;
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    font: 800 12px 'Inter', sans-serif;
}
.ag-sb-beat-body { display: flex; flex-direction: column; gap: 5px; }
.ag-sb-beat-label {
    font: 700 12px 'Inter', sans-serif;
    color: var(--slate-700);
}
.ag-sb-beat-prompt {
    width: 100%;
    padding: 7px 9px;
    border: 1px solid var(--slate-200);
    border-radius: 6px;
    background: #fff;
    font: 400 12.5px 'Inter', sans-serif;
    line-height: 1.4;
    color: var(--slate-800);
    resize: vertical;
    min-height: 50px;
}
.ag-sb-beat-remove {
    background: transparent;
    border: none;
    color: var(--slate-400);
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
}
.ag-sb-beat-remove:hover { color: #ef4444; }
.ag-sb-foot { display: flex !important; justify-content: space-between; }
.ag-sb-foot[hidden] { display: none !important; }

.btn-ghost {
    padding: 9px 16px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--slate-600);
    font: 600 13px 'Inter', sans-serif;
    cursor: pointer;
    border-radius: 8px;
}
.btn-ghost:hover { background: var(--slate-100); color: var(--slate-900); }

/* ─────────────────────── PRESET INSPECTOR ─────────────────────── */
.ag-info-btn {
    background: transparent;
    border: none;
    color: var(--slate-400);
    cursor: pointer;
    padding: 0 2px;
    margin-left: 4px;
    vertical-align: middle;
    transition: color 0.15s;
}
.ag-info-btn:hover { color: var(--brand-600); }

.ag-popover {
    position: fixed;
    z-index: 150;
    width: 360px;
    max-width: calc(100vw - 24px);
    background: #fff;
    border: 1px solid var(--slate-200);
    border-radius: 12px;
    box-shadow: 0 18px 48px rgba(15, 23, 42, 0.18), 0 4px 12px rgba(15, 23, 42, 0.06);
    overflow: hidden;
}
.ag-popover[hidden] { display: none; }
.ag-popover-arrow {
    position: absolute;
    top: -6px;
    left: 30px;
    width: 12px; height: 12px;
    background: #fff;
    border-top: 1px solid var(--slate-200);
    border-left: 1px solid var(--slate-200);
    transform: rotate(45deg);
}
.ag-popover-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--slate-50);
    border-bottom: 1px solid var(--slate-200);
    font: 800 11px 'Inter', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--slate-700);
    position: relative;
    z-index: 1;
}
.ag-popover-close {
    background: transparent;
    border: none;
    font-size: 18px;
    color: var(--slate-400);
    cursor: pointer;
    line-height: 1;
}
.ag-popover-close:hover { color: var(--slate-700); }
.ag-popover-body {
    padding: 14px;
    font-size: 12.5px;
    line-height: 1.6;
    color: var(--slate-700);
    max-height: 280px;
    overflow-y: auto;
    white-space: pre-wrap;
}
.ag-popover-foot {
    padding: 10px 14px;
    border-top: 1px solid var(--slate-100);
    display: flex;
    justify-content: flex-end;
}
.ag-popover-copy {
    padding: 6px 12px;
    background: var(--brand-600);
    border: none;
    color: #fff;
    border-radius: 6px;
    font: 700 12px 'Inter', sans-serif;
    cursor: pointer;
}
.ag-popover-copy:hover { background: var(--brand-700); }

/* ─────────────────────── CANVAS CONTACT SHEET ─────────────────────── */
.ag-contact-sheet {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.ag-cs-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
    overflow-y: auto;
    align-content: start;
}
.ag-cs-tile {
    aspect-ratio: 1;
    background: var(--slate-100);
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.15s;
    position: relative;
}
.ag-cs-tile:hover { border-color: var(--brand-400); transform: scale(1.03); }
.ag-cs-tile img, .ag-cs-tile video { width: 100%; height: 100%; object-fit: cover; }
.ag-cs-audio { display: grid; place-items: center; height: 100%; font-size: 30px; color: var(--brand-500); }
.ag-cs-tile .ag-thumb-fav {
    position: absolute; bottom: 4px; right: 4px;
    color: #fbbf24; font-size: 13px;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4));
}
.ag-cs-footer {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 4px;
    border-top: 1px solid var(--slate-200);
}
.ag-cs-count {
    font: 700 11px 'Inter', sans-serif;
    color: var(--slate-500);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}
.ag-cs-link {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 12px;
    background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
    color: #fff; text-decoration: none;
    border-radius: 8px;
    font: 700 12px 'Inter', sans-serif;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
    transition: all 0.15s;
}
.ag-cs-link:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(37, 99, 235, 0.4); }

/* ─────────────────────── TABS (pane header) ─────────────────────── */
.ag-tabs {
    display: flex;
    gap: 4px;
    background: var(--slate-100);
    border: 1px solid var(--slate-200);
    border-radius: 10px;
    padding: 3px;
}
.ag-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    background: transparent;
    border: none;
    border-radius: 7px;
    color: var(--slate-600);
    font: 700 12px 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
}
.ag-tab:hover:not(.active) { background: rgba(255,255,255,0.7); color: var(--slate-900); }
.ag-tab.active {
    background: #fff;
    color: var(--brand-700);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 0 0 1px var(--brand-200) inset;
}

/* Ready dot on Chat tab */
.ag-ready-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-left: 4px;
    background: var(--slate-400);
    box-shadow: 0 0 0 2px rgba(148, 163, 184, 0.18);
    transition: all 0.25s;
}
.ag-ready-dot.tone-red    { background: #ef4444; box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2); }
.ag-ready-dot.tone-yellow { background: #f59e0b; box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2); animation: agPulse 1.6s ease-in-out infinite; }
.ag-ready-dot.tone-green  { background: #22c55e; box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.25); animation: agPulseStrong 1.4s ease-in-out infinite; }
@keyframes agPulse {
    0%,100% { box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2); }
    50%     { box-shadow: 0 0 0 5px rgba(245, 158, 11, 0.1); }
}
@keyframes agPulseStrong {
    0%,100% { box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.25); }
    50%     { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.12); }
}

/* ─────────────────────── CHAT PANE ─────────────────────── */
.ag-chat-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: var(--slate-50);
    padding: 16px !important;
    gap: 12px;
}
.ag-chat-pane[hidden] { display: none !important; }

.ag-chat-intro {
    text-align: center;
    padding: 28px 12px;
    color: var(--slate-500);
    background: #fff;
    border: 1px dashed var(--slate-200);
    border-radius: 12px;
}
.ag-chat-intro-icon {
    display: inline-grid; place-items: center;
    width: 56px; height: 56px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--brand-50), var(--brand-100));
    color: var(--brand-600);
    margin-bottom: 12px;
}
.ag-chat-intro-title {
    font: 800 14px 'Inter', sans-serif;
    color: var(--slate-800);
    margin-bottom: 6px;
}
.ag-chat-intro-sub {
    font-size: 12.5px;
    color: var(--slate-500);
    line-height: 1.55;
    max-width: 340px;
    margin: 0 auto;
}

.ag-chat-messages {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.ag-chat-msg {
    display: grid;
    grid-template-columns: 38px 1fr;
    gap: 10px;
    align-items: flex-start;
}
.ag-chat-msg.role-user { grid-template-columns: 1fr 38px; }
.ag-chat-msg.role-user .ag-chat-msg-bubble { background: var(--brand-600); color: #fff; border-color: var(--brand-700); }
.ag-chat-msg.role-user .ag-chat-msg-avatar { order: 2; background: var(--brand-700); color: #fff; }
.ag-chat-msg.role-user .ag-chat-msg-bubble { order: 1; }

.ag-chat-msg-avatar {
    width: 38px; height: 38px;
    background: var(--slate-200);
    color: var(--slate-700);
    border-radius: 50%;
    display: grid; place-items: center;
    font: 800 10px 'Inter', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    flex-shrink: 0;
}
.ag-chat-msg.role-assistant .ag-chat-msg-avatar {
    background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
    color: #fff;
}
.ag-chat-msg-bubble {
    background: #fff;
    border: 1px solid var(--slate-200);
    border-radius: 12px;
    padding: 10px 13px;
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--slate-800);
    word-wrap: break-word;
    white-space: pre-wrap;
}

/* Thinking dots */
.ag-chat-thinking .ag-chat-msg-bubble {
    padding: 14px 16px;
}
.ag-chat-dots {
    display: inline-flex;
    gap: 4px;
}
.ag-chat-dots span {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--slate-400);
    animation: agDot 1.2s ease-in-out infinite;
}
.ag-chat-dots span:nth-child(2) { animation-delay: 0.18s; }
.ag-chat-dots span:nth-child(3) { animation-delay: 0.36s; }
@keyframes agDot {
    0%,100% { opacity: 0.3; transform: translateY(0); }
    50%     { opacity: 1;   transform: translateY(-3px); }
}

/* ─────────────────────── CHAT INPUT ─────────────────────── */
.ag-chat-input-row {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid var(--slate-200);
    align-items: flex-end;
}
.ag-chat-input-row[hidden] { display: none !important; }
.ag-chat-textarea {
    flex: 1;
    padding: 9px 12px;
    background: var(--slate-50);
    border: 1px solid var(--slate-300);
    border-radius: 10px;
    color: var(--slate-900);
    font: inherit;
    font-size: 13.5px;
    resize: none;
    line-height: 1.4;
    min-height: 44px;
    max-height: 140px;
}
.ag-chat-textarea:focus {
    outline: none;
    background: #fff;
    border-color: var(--brand-500);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.ag-chat-send {
    width: 40px; height: 40px;
    background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
    border: none;
    border-radius: 10px;
    color: #fff;
    cursor: pointer;
    display: grid; place-items: center;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25);
    transition: all 0.15s;
}
.ag-chat-send:hover { transform: translateY(-1px); box-shadow: 0 6px 14px rgba(37, 99, 235, 0.35); }

/* ─────────────────────── PENDING DIFF CARD ─────────────────────── */
.ag-pending-diff {
    margin: 0 16px 8px;
    background: #fff;
    border: 1px solid #fde68a;
    border-left: 3px solid #f59e0b;
    border-radius: 10px;
    padding: 12px 14px;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.1);
    animation: agSlideIn 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}
.ag-pending-diff[hidden] { display: none; }
@keyframes agSlideIn {
    from { transform: translateY(-6px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}
.ag-pending-diff-head {
    display: flex;
    align-items: center;
    gap: 6px;
    font: 800 10px 'Inter', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #b45309;
    margin-bottom: 6px;
}
.ag-pending-diff-head svg { color: #f59e0b; }
.ag-pending-diff-summary {
    font-size: 13px;
    color: var(--slate-800);
    margin-bottom: 8px;
    line-height: 1.45;
}
.ag-pending-diff-fields {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 10px;
}
.ag-pending-diff-row {
    display: grid;
    grid-template-columns: 110px 18px 1fr;
    gap: 6px;
    font-size: 12px;
    align-items: center;
}
.ag-pending-diff-key {
    color: var(--slate-500);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 10px;
}
.ag-pending-diff-arrow { color: var(--slate-400); text-align: center; }
.ag-pending-diff-val {
    color: var(--slate-900);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ag-pending-diff-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}
.ag-pd-btn {
    padding: 6px 14px;
    border-radius: 7px;
    font: 700 12px 'Inter', sans-serif;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s;
}
.ag-pd-dismiss {
    background: #fff;
    color: var(--slate-600);
    border-color: var(--slate-300);
}
.ag-pd-dismiss:hover { background: var(--slate-50); color: var(--slate-900); }
.ag-pd-apply {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.3);
}
.ag-pd-apply:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(245, 158, 11, 0.4); }

/* ─────────────────────── LIGHTBOX OPEN/CLOSE ZOOM (1.5s) ─────────────────────── */
/* research.css's .lightbox uses opacity for show/hide. We add a content-scale
   transition so opens have a cinematic 1.5s zoom-in and closes a quick zoom-out. */
.lightbox .lightbox-content {
    transform: scale(0.85);
    opacity: 0;
    transition: transform 1.5s cubic-bezier(0.16, 1, 0.3, 1), opacity 1.2s ease-out;
}
.lightbox.active .lightbox-content {
    transform: scale(1);
    opacity: 1;
}
.lightbox.fading-out .lightbox-content {
    transform: scale(0.95);
    opacity: 0;
    transition: transform 0.42s ease-in, opacity 0.35s ease-in;
}

/* Same treatment for the ref-picker modal */
.modal .modal-card {
    transform: scale(0.88);
    opacity: 0;
    transition: transform 1.5s cubic-bezier(0.16, 1, 0.3, 1), opacity 1.2s ease-out;
}
.modal.show .modal-card {
    transform: scale(1);
    opacity: 1;
}
/* (modal close: simply removes .show; the inverse transition runs because .show toggles) */

/* Lightbox minimize button (top-right of lightbox-content) */
.ag-lb-min-btn {
    position: absolute;
    top: 22px;
    right: 22px;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.10);
    border: 1px solid rgba(255, 255, 255, 0.22);
    color: rgba(255, 255, 255, 0.95);
    cursor: pointer;
    display: grid; place-items: center;
    backdrop-filter: blur(8px);
    transition: all 0.15s;
    z-index: 3;
}
.ag-lb-min-btn:hover {
    background: rgba(255, 255, 255, 0.20);
    transform: translateY(-1px);
}

/* ─────────────────────── QUEUE PANEL ─────────────────────── */
.ag-queue-panel {
    position: fixed;
    bottom: 18px;
    right: 18px;
    width: 360px;
    max-height: 60vh;
    background: #fff;
    border: 1px solid var(--slate-200);
    border-radius: 14px;
    box-shadow: 0 18px 48px rgba(15, 23, 42, 0.18), 0 4px 12px rgba(15, 23, 42, 0.06);
    z-index: 90;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px) scale(0.94);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease-out;
}
.ag-queue-panel.show {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
}
.ag-queue-panel.collapsed { max-height: 52px; }
.ag-queue-panel.collapsed .ag-queue-list { display: none; }
.ag-queue-panel.collapsed .ag-queue-collapse svg { transform: rotate(180deg); }

.ag-queue-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: linear-gradient(135deg, var(--brand-700), var(--brand-900));
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.ag-queue-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font: 800 11px 'Inter', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}
.ag-queue-count {
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    min-width: 22px;
    text-align: center;
}
.ag-queue-collapse {
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.2);
    width: 26px; height: 26px;
    border-radius: 7px;
    display: grid; place-items: center;
    color: #fff;
    cursor: pointer;
}
.ag-queue-collapse svg { transition: transform 0.2s; }

.ag-queue-list {
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: var(--slate-50);
}

.ag-queue-row {
    display: grid;
    grid-template-columns: 44px 1fr;
    gap: 10px;
    padding: 10px;
    background: #fff;
    border: 1px solid var(--slate-200);
    border-left: 3px solid var(--slate-300);
    border-radius: 9px;
    cursor: pointer;
    transition: all 0.15s;
}
.ag-queue-row:hover {
    border-color: var(--brand-300);
    transform: translateX(-2px);
    box-shadow: -2px 4px 10px rgba(15, 23, 42, 0.08);
}
.ag-queue-row.tone-queued    { border-left-color: var(--slate-400); }
.ag-queue-row.tone-running   { border-left-color: var(--brand-500); }
.ag-queue-row.tone-succeeded { border-left-color: #22c55e; background: linear-gradient(90deg, #f0fdf4, #fff 30%); }
.ag-queue-row.tone-failed    { border-left-color: #ef4444; background: linear-gradient(90deg, #fef2f2, #fff 30%); }

.ag-queue-thumb {
    width: 44px;
    height: 44px;
    border-radius: 7px;
    object-fit: cover;
    background: var(--slate-100);
}
.ag-queue-thumb-empty {
    width: 44px;
    height: 44px;
    border-radius: 7px;
    background: var(--slate-100);
    display: grid;
    place-items: center;
    font-size: 20px;
    opacity: 0.6;
}

.ag-queue-body { min-width: 0; }
.ag-queue-row-head {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 2px;
}
.ag-queue-model {
    font: 700 11px 'Inter', sans-serif;
    color: var(--slate-700);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ag-queue-var {
    background: var(--brand-100);
    color: var(--brand-700);
    padding: 1px 5px;
    border-radius: 4px;
    font: 700 10px 'Inter', sans-serif;
}
.ag-queue-elapsed {
    font: 700 10px 'Inter', sans-serif;
    color: var(--slate-400);
    font-variant-numeric: tabular-nums;
}
.ag-queue-prompt {
    font-size: 11px;
    color: var(--slate-500);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 6px;
}
.ag-queue-bar {
    width: 100%;
    height: 4px;
    background: var(--slate-200);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 4px;
}
.ag-queue-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--brand-500), var(--brand-700));
    border-radius: 999px;
    transition: width 0.4s ease-out;
}
.ag-queue-row.tone-succeeded .ag-queue-bar-fill { background: #22c55e; }
.ag-queue-row.tone-failed    .ag-queue-bar-fill { background: #ef4444; }
.ag-queue-status {
    font-size: 11px;
    color: var(--slate-500);
    font-weight: 600;
}
.ag-queue-row.tone-succeeded .ag-queue-status { color: #15803d; }
.ag-queue-row.tone-failed    .ag-queue-status { color: #b91c1c; }

/* ─────────────────────── GENERATION LIGHTBOX ADDITIONS ─────────────────────── */
/* The base .lightbox / .lb-ring / .lb-core / .lb-phases / .lb-ticker styles
   live in research.css; this block only adds art-generator-specific chrome
   (badges at top, ref thumbnails at bottom, the image reveal animation). */

.ag-lb-badges {
    position: absolute;
    top: 28px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    padding: 0 24px;
    z-index: 2;
}
.ag-lb-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.10);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 999px;
    color: rgba(255, 255, 255, 0.95);
    font: 700 11px 'Inter', sans-serif;
    letter-spacing: 0.03em;
    backdrop-filter: blur(10px);
    font-variant-numeric: tabular-nums;
}
.ag-lb-badge-cost {
    background: rgba(34, 197, 94, 0.2);
    border-color: rgba(134, 239, 172, 0.5);
    color: #dcfce7;
}

/* Reveal of the generated image inside the orbital at completion */
.ag-lb-reveal {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 128px;
    height: 128px;
    object-fit: cover;
    border-radius: 50%;
    opacity: 0;
    transform: scale(0.6);
    transition: opacity 0.6s ease-out, transform 0.7s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6), 0 0 0 3px rgba(255, 255, 255, 0.2);
    z-index: 2;
    pointer-events: none;
}
.ag-lb-reveal.show {
    opacity: 1;
    transform: scale(1);
}
.lightbox.complete .ag-lb-reveal.show {
    animation: agRevealPulse 1.8s ease-in-out infinite;
}
@keyframes agRevealPulse {
    0%, 100% { box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6), 0 0 0 3px rgba(255, 255, 255, 0.2); }
    50%      { box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6), 0 0 0 5px rgba(96, 165, 250, 0.5); }
}

/* Reference-image strip at the bottom of the lightbox */
.ag-lb-refs {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    margin-top: 18px;
    flex-wrap: wrap;
}
.ag-lb-refs:empty { display: none; }
.ag-lb-refs-label {
    font: 800 9px 'Inter', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: rgba(255, 255, 255, 0.5);
    margin-right: 4px;
}
.ag-lb-refs img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 8px;
    border: 1.5px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

/* ─────────────────────── REF PICKER MODAL ─────────────────────── */
.ag-ref-card {
    width: min(1000px, 92vw);
    height: min(700px, 85vh);
    display: flex !important;
    flex-direction: column;
    overflow: hidden;
}
.ag-ref-body {
    display: grid; grid-template-columns: 240px 1fr;
    flex: 1; overflow: hidden; padding: 0 !important;
}
.ag-ref-sidebar {
    border-right: 1px solid var(--slate-200);
    padding: 16px;
    display: flex; flex-direction: column;
    overflow-y: auto;
    background: var(--slate-50);
}
.ag-ref-sidebar-title {
    font: 800 10px 'Inter', sans-serif;
    text-transform: uppercase; letter-spacing: 0.14em;
    color: var(--slate-500); margin-bottom: 10px;
}
.ag-folder-list {
    list-style: none; padding: 0; margin: 0 0 12px;
    flex: 1; overflow-y: auto;
}
.ag-folder-list li {
    padding: 9px 11px; border-radius: 8px; cursor: pointer;
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 2px; font-size: 14px; color: var(--slate-700);
}
.ag-folder-list li:hover { background: #fff; }
.ag-folder-list li.active {
    background: #fff; color: var(--brand-700);
    font-weight: 700;
    box-shadow: inset 0 0 0 1px var(--brand-300);
}
.ag-folder-list li .count { font-size: 12px; color: var(--slate-400); font-weight: 600; }
.ag-folder-new {
    display: block; width: 100%;
    padding: 9px 11px;
    background: #fff;
    border: 1px dashed var(--slate-300);
    border-radius: 8px;
    color: var(--slate-500);
    font: 600 13px 'Inter', sans-serif;
    cursor: pointer; margin-bottom: 6px; text-align: left;
}
.ag-folder-new:hover { border-color: var(--brand-400); color: var(--brand-700); background: var(--brand-50); }
.ag-ref-main { padding: 16px; display: flex; flex-direction: column; overflow: hidden; background: #fff; }
.ag-ref-main-title { font-weight: 800; margin-bottom: 10px; color: var(--slate-900); font-size: 15px; }
.ag-ref-main-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px; overflow-y: auto; flex: 1;
}
.ag-ref-card-item {
    aspect-ratio: 1; background: var(--slate-100);
    border-radius: 10px; cursor: pointer;
    overflow: hidden; position: relative;
    border: 2px solid transparent;
    transition: all 0.12s;
}
.ag-ref-card-item:hover { border-color: var(--brand-300); }
.ag-ref-card-item.selected { border-color: var(--brand-500); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12); }
.ag-ref-card-item img { width: 100%; height: 100%; object-fit: cover; }
.ag-ref-check {
    position: absolute; top: 6px; right: 6px;
    background: var(--brand-600); color: white;
    border-radius: 50%; width: 22px; height: 22px;
    font-size: 14px; font-weight: 800;
    display: none; align-items: center; justify-content: center;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}
.ag-ref-card-item.selected .ag-ref-check { display: flex; }

/* ══════════════════════════════════════════════════════════════════
   Layout polish v2 — better contrast, section hierarchy, kind theming
   ══════════════════════════════════════════════════════════════════ */

/* ─── Configure / AI Chat tabs: bolder inactive text + container contrast ─── */
.ag-tabs {
    background: var(--slate-200) !important;
    padding: 4px !important;
    box-shadow: inset 0 1px 2px rgba(15,23,42,0.04);
}
.ag-tab {
    color: var(--slate-700) !important;       /* was 600 — too dim on slate-100 */
    font-weight: 700 !important;
    font-size: 13px !important;
    padding: 8px 14px !important;
}
.ag-tab:hover:not(.active) {
    background: rgba(255,255,255,0.92) !important;
    color: var(--slate-900) !important;
}
.ag-tab.active {
    color: var(--brand-700) !important;
    box-shadow: 0 1px 4px rgba(15,23,42,0.12), 0 0 0 1.5px var(--brand-300) inset !important;
    font-weight: 800 !important;
}
.ag-tab svg { opacity: 0.95; }

/* Make the cost-mini chip pop more */
.chat-pane-meta #cost-estimate-mini {
    font: 700 12px 'Inter', sans-serif !important;
    color: var(--brand-700) !important;
    background: var(--brand-50);
    padding: 5px 10px;
    border-radius: 99px;
    border: 1px solid var(--brand-200);
}

/* ─── Stronger section card hierarchy ─── */
.ag-pane-scroll { gap: 16px !important; }  /* a touch more breathing room between cards */

.ag-card {
    border-radius: 14px;
    padding: 18px 16px 18px 16px;   /* explicit padding so callouts breathe */
    box-shadow: 0 1px 3px rgba(15,23,42,0.04), 0 1px 2px rgba(15,23,42,0.03);
    position: relative;
    /* NOTE: no overflow:hidden — clipping was killing description boxes and
       the bottom of the prompt textarea. The stripe below uses its own
       radius to stay inside the rounded corners. */
}
/* 3px color stripe along the top of every card */
.ag-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--slate-200), transparent 60%);
    border-top-left-radius: 14px;
    border-top-right-radius: 14px;
    pointer-events: none;
}

/* Per-card-type tints (auto via order — first card = config) */
.ag-pane-scroll .ag-card:nth-of-type(2)::before {
    /* Configuration card — brand stripe */
    background: linear-gradient(90deg, var(--brand-500), var(--brand-300) 50%, transparent);
}
#audio-options::before { background: linear-gradient(90deg, #a855f7, #c084fc 50%, transparent); }  /* purple for audio */
#video-options::before { background: linear-gradient(90deg, #6366f1, #818cf8 50%, transparent); }  /* indigo for video */

/* Section headers: bigger, darker, more confident */
.ag-card-head {
    font-size: 11.5px !important;
    color: var(--slate-700) !important;
    margin-bottom: 14px !important;
    letter-spacing: 0.1em !important;
    font-weight: 800;
}
.ag-card-head svg { color: var(--brand-500) !important; opacity: 0.9; }
.ag-card-accent .ag-card-head svg { color: var(--brand-600) !important; }

/* ─── Field labels: same uplift ─── */
.ag-label {
    font-size: 10.5px !important;
    color: var(--slate-700) !important;
    letter-spacing: 0.1em !important;
    font-weight: 800;
    margin-bottom: 7px !important;
}

/* ─── Style description callout (the photoreal_ref blurb under Style) ─── */
#style-description, #size-description, #voice-description {
    background: var(--brand-50);
    border-left: 3px solid var(--brand-300);
    padding: 8px 10px !important;
    border-radius: 6px;
    font-size: 12px !important;
    color: var(--slate-700) !important;
    line-height: 1.5 !important;
    margin-top: 8px !important;
}

/* ─── Estimated cost row at bottom of pane ─── */
.ag-cost-row, .ag-estimated-row {
    background: linear-gradient(135deg, var(--brand-50), #fff 70%);
    border: 1px solid var(--brand-200);
    border-radius: 12px;
    padding: 12px 16px;
}

/* The ESTIMATED row in the screenshots — it shows ESTIMATED $0.0200 */
/* Find the cost-estimate by id */
#cost-estimate {
    font: 800 22px 'Inter', sans-serif !important;
    color: var(--brand-700) !important;
    font-variant-numeric: tabular-nums;
}

/* ─── Kind selector tiles: active state matches Generate button gradient ─── */
.ag-kind-bar {
    background: var(--slate-200) !important;
    padding: 5px !important;
    box-shadow: inset 0 1px 2px rgba(15,23,42,0.04);
}
.ag-kind {
    color: var(--slate-700) !important;
    font-weight: 700 !important;
}
.ag-kind svg { transition: color 0.15s; }
.ag-kind:hover:not(.disabled):not(.active) {
    background: rgba(255,255,255,0.92) !important;
    color: var(--slate-900) !important;
}
/* Active tiles — same gradient + shadow as Generate button, color-coded by media kind */
.ag-kind.active {
    color: #ffffff !important;
    font-weight: 800 !important;
    box-shadow: 0 2px 8px rgba(15,23,42,0.18), 0 0 0 1px rgba(255,255,255,0.3) inset !important;
}
.ag-kind.active svg { color: #ffffff !important; }
.ag-kind[data-kind="image"].active {
    background: linear-gradient(135deg, var(--brand-500), var(--brand-700)) !important;
    box-shadow: 0 4px 12px rgba(37,99,235,0.32), 0 0 0 1px rgba(255,255,255,0.25) inset !important;
}
.ag-kind[data-kind="video"].active {
    background: linear-gradient(135deg, #6366f1, #4338ca) !important;
    box-shadow: 0 4px 12px rgba(79,70,229,0.32), 0 0 0 1px rgba(255,255,255,0.25) inset !important;
}
.ag-kind[data-kind="audio"].active {
    background: linear-gradient(135deg, #a855f7, #7e22ce) !important;
    box-shadow: 0 4px 12px rgba(168,85,247,0.32), 0 0 0 1px rgba(255,255,255,0.25) inset !important;
}

/* ─── AGToast.input — branded input dialog (replaces native prompt) ─── */
.ag-input-modal-overlay {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
    display: flex; align-items: center; justify-content: center;
    z-index: 100001;
    opacity: 0;
    transition: opacity 0.2s;
}
.ag-input-modal-overlay.show { opacity: 1; }
.ag-input-modal {
    width: min(440px, 92vw);
    background: #fff;
    border-radius: 14px;
    padding: 22px 22px 18px;
    box-shadow: 0 16px 48px rgba(15, 23, 42, 0.3), 0 4px 12px rgba(15, 23, 42, 0.1);
    transform: translateY(8px);
    transition: transform 0.2s;
}
.ag-input-modal-overlay.show .ag-input-modal { transform: translateY(0); }
.ag-input-modal-title {
    font: 700 16px 'Inter', sans-serif;
    color: var(--slate-900);
    margin-bottom: 6px;
}
.ag-input-modal-desc {
    font: 500 13px 'Inter', sans-serif;
    color: var(--slate-600);
    margin-bottom: 14px;
    line-height: 1.45;
}
.ag-input-modal-input {
    display: block; width: 100%;
    padding: 11px 13px;
    background: #fff;
    border: 1.5px solid var(--slate-300);
    border-radius: 9px;
    color: var(--slate-900);
    font: 500 14px 'Inter', sans-serif;
    transition: border-color 0.15s, box-shadow 0.15s;
    margin-bottom: 16px;
}
.ag-input-modal-input:focus {
    outline: none;
    border-color: var(--brand-500);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}
.ag-input-modal-actions {
    display: flex; gap: 8px; justify-content: flex-end;
}
.ag-input-modal-btn {
    padding: 8px 18px;
    border-radius: 8px;
    font: 700 13px 'Inter', sans-serif;
    cursor: pointer;
    border: 1px solid var(--slate-200);
    background: #fff;
    color: var(--slate-700);
    transition: background 0.15s, border-color 0.15s;
}
.ag-input-modal-cancel:hover { background: var(--slate-50); border-color: var(--slate-300); }
.ag-input-modal-ok {
    background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
    color: #fff;
    border-color: var(--brand-700);
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.2);
}
.ag-input-modal-ok:hover { box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3); transform: translateY(-1px); }

/* ─── Top header credits row: tighten label-value spacing by half ─── */
.report-header-row { gap: 5px !important; }                /* was 10px */
.rh-label { min-width: 0 !important; padding-right: 2px; }  /* was min-width:78px — that was the visible gap */

/* ─── Constrain inner topbar content to 1200px on wide screens ─── */
/* The dark gradient background still spans full width; only the logo +
   icons + center content max out at 1200px so they don't sprawl. */
.topbar {
    padding: 24px max(28px, calc((100vw - 1200px) / 2)) !important;
}

/* ══════════════════════════════════════════════════════════════════
   LEFT PANE — cohesive design pass
   Goal: cards read as one unified configuration surface, not random pieces
   ══════════════════════════════════════════════════════════════════ */

/* Pane scroll container = the unified background */
.ag-pane-scroll {
    padding: 14px !important;
    gap: 12px !important;
    background: linear-gradient(180deg, #f8fafc, #fff 200px);
}

/* Cards inside the pane: lighter borders, cohesive background tint */
.ag-pane-scroll .ag-card {
    background: #ffffff;
    border: 1px solid var(--slate-200) !important;
    border-radius: 12px !important;
    padding: 16px !important;
    box-shadow: 0 1px 2px rgba(15,23,42,0.04) !important;
    transition: border-color 0.18s, box-shadow 0.18s;
}
.ag-pane-scroll .ag-card:hover {
    border-color: var(--slate-300) !important;
    box-shadow: 0 2px 6px rgba(15,23,42,0.06) !important;
}

/* The accent stripe — only shown on the configuration card now (not every card),
   because too many stripes feels visually noisy. Per-section identity via the
   header icon color instead. */
.ag-pane-scroll .ag-card::before { display: none; }
.ag-pane-scroll .ag-card:nth-of-type(2) {
    border-top: 3px solid var(--brand-500) !important;
}
body[data-active-kind="video"] .ag-pane-scroll .ag-card:nth-of-type(2) {
    border-top-color: #6366f1 !important;
}
body[data-active-kind="audio"] .ag-pane-scroll .ag-card:nth-of-type(2) {
    border-top-color: #a855f7 !important;
}

/* Section header: tighter, more confident */
.ag-pane-scroll .ag-card-head {
    font-size: 11px !important;
    color: var(--slate-700) !important;
    margin-bottom: 12px !important;
    letter-spacing: 0.1em !important;
    font-weight: 800 !important;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--slate-100);
}
.ag-pane-scroll .ag-card-head svg {
    color: var(--brand-600) !important;
    width: 14px; height: 14px;
}
body[data-active-kind="video"] .ag-pane-scroll .ag-card-head svg { color: #6366f1 !important; }
body[data-active-kind="audio"] .ag-pane-scroll .ag-card-head svg { color: #a855f7 !important; }

/* References card: drop the warm tint, match neutral palette */
.ag-card:has(.ag-ref-grid),
.ag-card:has(#ref-count-badge) {
    background: #ffffff !important;
}
.ag-card:has(.ag-ref-grid)::before,
.ag-card:has(#ref-count-badge)::before { display: none !important; }

/* Audio + Video options: subtle tint matching kind, drop the gradient */
#audio-options { background: linear-gradient(180deg, #fdf4ff, #fff 80%) !important; border-color: #e9d5ff !important; }
#video-options { background: linear-gradient(180deg, #eef2ff, #fff 80%) !important; border-color: #c7d2fe !important; }

/* Style description callouts: cleaner inline note style */
#style-description, #size-description, #voice-description {
    background: var(--slate-50) !important;
    border-left: 2px solid var(--brand-400) !important;
    padding: 8px 10px !important;
    border-radius: 6px;
    font-size: 11.5px !important;
    color: var(--slate-700) !important;
    line-height: 1.5 !important;
    margin-top: 6px !important;
}
body[data-active-kind="video"] #style-description,
body[data-active-kind="video"] #size-description,
body[data-active-kind="video"] #voice-description { border-left-color: #6366f1 !important; }
body[data-active-kind="audio"] #style-description,
body[data-active-kind="audio"] #size-description,
body[data-active-kind="audio"] #voice-description { border-left-color: #a855f7 !important; }

/* Estimated cost + Generate row pinned at the bottom — designed as ONE unit */
.ag-pane-scroll > .ag-card:nth-last-of-type(2),
.ag-pane-scroll > .ag-card:last-of-type {
    /* Will style the prompt + generate row group */
}

/* The Estimated $0.0200 row — currently a plain row, give it a card-footer feel */
.ag-cost-row, [class*="estimated"] {
    background: linear-gradient(180deg, #fff, #f8fafc) !important;
    border-radius: 12px !important;
}

/* Generate button — slightly smaller padding to pair tightly with cost row */
#btn-generate, .ag-generate-btn {
    padding: 13px 22px !important;
    border-radius: 12px !important;
    font-size: 14.5px !important;
    letter-spacing: 0.01em;
}

/* Field labels inside cards: match the new section header weight */
.ag-pane-scroll .ag-label {
    font-size: 10px !important;
    color: var(--slate-600) !important;
    letter-spacing: 0.1em !important;
    font-weight: 800;
    margin-bottom: 6px !important;
}

/* Form controls inside the pane: matching radius and softer shadow */
.ag-pane-scroll .ag-control {
    border-radius: 8px !important;
    border: 1px solid var(--slate-300) !important;
    background: #fff !important;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.ag-pane-scroll .ag-control:hover { border-color: var(--slate-400) !important; }
.ag-pane-scroll .ag-control:focus {
    border-color: var(--brand-500) !important;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12) !important;
    outline: none;
}
body[data-active-kind="video"] .ag-pane-scroll .ag-control:focus {
    border-color: #6366f1 !important;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.12) !important;
}
body[data-active-kind="audio"] .ag-pane-scroll .ag-control:focus {
    border-color: #a855f7 !important;
    box-shadow: 0 0 0 3px rgba(168,85,247,0.12) !important;
}

/* Tabs (Configure / AI Chat) — slightly more padding so they don't feel cramped */
.chat-pane-header { padding: 10px 14px !important; }

/* ══════════════════════════════════════════════════════════════════
   SETTINGS MODAL
   ══════════════════════════════════════════════════════════════════ */
.ag-settings-card { width: min(680px, 96vw); max-height: 90vh; display: flex !important; flex-direction: column; }
.ag-settings-body { padding: 22px !important; overflow-y: auto; }
.ag-settings-section { margin-bottom: 28px; }
.ag-settings-section:last-child { margin-bottom: 0; }
.ag-settings-section h4 {
    font: 700 14px 'Inter', sans-serif;
    color: var(--slate-900);
    margin: 0 0 6px 0;
}
.ag-settings-help {
    font: 500 12.5px 'Inter', sans-serif;
    color: var(--slate-600);
    line-height: 1.55;
    margin: 0 0 14px;
}
.ag-settings-help code {
    background: var(--slate-100);
    padding: 1px 6px;
    border-radius: 4px;
    font: 600 11.5px 'JetBrains Mono', monospace;
    color: var(--brand-700);
}
.ag-settings-tokens { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.ag-settings-token-row {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px;
    background: var(--slate-50);
    border: 1px solid var(--slate-200);
    border-radius: 8px;
}
.ag-settings-token-row.revoked { opacity: 0.55; background: #fff; }
.ag-settings-token-main { flex: 1; min-width: 0; }
.ag-settings-token-label {
    font: 700 13px 'Inter', sans-serif;
    color: var(--slate-900);
    margin-bottom: 2px;
    display: flex; align-items: center; gap: 8px;
}
.ag-settings-token-label code {
    font: 600 11px 'JetBrains Mono', monospace;
    color: var(--slate-500);
    background: #fff;
    padding: 1px 6px;
    border-radius: 4px;
    border: 1px solid var(--slate-200);
}
.ag-settings-token-meta { font: 500 11px 'Inter', sans-serif; color: var(--slate-500); }
.ag-settings-token-revoke {
    padding: 5px 12px;
    background: #fff;
    border: 1px solid var(--slate-200);
    border-radius: 6px;
    color: var(--slate-700);
    font: 700 11px 'Inter', sans-serif;
    cursor: pointer;
}
.ag-settings-token-revoke:hover { background: #fef2f2; border-color: #fecaca; color: #dc2626; }
.ag-settings-token-form {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 8px;
    align-items: center;
}
.ag-settings-token-form .btn-primary {
    background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
    color: #fff;
    border: none;
    padding: 8px 14px;
    border-radius: 8px;
    font: 700 12px 'Inter', sans-serif;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(37,99,235,0.2);
}
.ag-settings-stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 10px;
}
.ag-settings-stat {
    background: var(--slate-50);
    border: 1px solid var(--slate-200);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
}
.ag-settings-stat-label {
    font: 700 10px 'Inter', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--slate-500);
    margin-bottom: 4px;
}
.ag-settings-stat-value {
    font: 700 16px 'Inter', sans-serif;
    color: var(--slate-900);
    font-variant-numeric: tabular-nums;
}
.ag-settings-about {
    background: var(--slate-50);
    border-radius: 10px;
    padding: 14px 16px;
    display: flex; flex-direction: column; gap: 6px;
}
.ag-settings-about > div {
    display: flex; gap: 10px; align-items: baseline;
    font: 500 12.5px 'Inter', sans-serif;
}
.ag-settings-about span {
    min-width: 90px;
    text-transform: uppercase;
    font-weight: 800;
    font-size: 10px;
    letter-spacing: 0.08em;
    color: var(--slate-500);
}
.ag-settings-about b { color: var(--slate-900); font-weight: 600; }
.ag-settings-about a { color: var(--brand-700); text-decoration: none; }
.ag-settings-about a:hover { text-decoration: underline; }

/* When in video/audio mode, recolor the cost-mini chip too */
body[data-active-kind="video"] .chat-pane-meta #cost-estimate-mini {
    color: #4f46e5 !important;
    background: #eef2ff;
    border-color: #c7d2fe;
}
body[data-active-kind="audio"] .chat-pane-meta #cost-estimate-mini {
    color: #9333ea !important;
    background: #faf5ff;
    border-color: #e9d5ff;
}

/* ─── Scene card prompt textarea (the big prompt field) ─── */
.ag-prompt-wrap textarea.ag-textarea {
    font-size: 14.5px !important;
    line-height: 1.5;
    background: linear-gradient(180deg, #fff, #fafbff);
    border-color: var(--slate-300);
}
.ag-prompt-wrap textarea.ag-textarea:focus {
    background: #fff;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.14), 0 1px 2px rgba(15,23,42,0.05);
}

/* ─── Variations row + prompt helpers a touch more polish ─── */
.ag-prompt-helpers .ag-prompt-helper-btn {
    font-weight: 700;
    color: var(--slate-700);
}
.ag-prompt-helper-btn:hover {
    background: var(--brand-50) !important;
    color: var(--brand-700) !important;
}

/* ─── References card: warm tint ─── */
.ag-card:has(.ag-ref-grid),
.ag-card:has(#ref-count-badge) {
    background: linear-gradient(180deg, #fffaf5, #fff 60%);
}
.ag-card:has(.ag-ref-grid)::before,
.ag-card:has(#ref-count-badge)::before {
    background: linear-gradient(90deg, #f97316, #fb923c 50%, transparent);
}

/* ─── Generate button row: hero treatment ─── */
.ag-generate-btn, #btn-generate {
    background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
    color: #fff;
    font: 800 15px 'Inter', sans-serif;
    border: none;
    border-radius: 12px;
    padding: 14px 24px;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(37,99,235,0.25), 0 1px 2px rgba(15,23,42,0.05);
    transition: transform 0.15s, box-shadow 0.15s;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.ag-generate-btn:hover, #btn-generate:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(37,99,235,0.35), 0 1px 2px rgba(15,23,42,0.05);
}
.ag-generate-btn:disabled, #btn-generate:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}
body[data-active-kind="video"] #btn-generate {
    background: linear-gradient(135deg, #6366f1, #4338ca);
    box-shadow: 0 4px 14px rgba(79,70,229,0.25), 0 1px 2px rgba(15,23,42,0.05);
}
body[data-active-kind="audio"] #btn-generate {
    background: linear-gradient(135deg, #a855f7, #7e22ce);
    box-shadow: 0 4px 14px rgba(168,85,247,0.25), 0 1px 2px rgba(15,23,42,0.05);
}
