/* Operate: images and their reference lineage lead; controls inherit the host tokens.
   A quiet dotted work surface, 4px rhythm, 14px body and raised editing panel.
   Preserve the host navigation and type. Image content supplies the color. */
#view-assets { --ac-paper: #141516; --ac-panel: #222325; --ac-edge: #45474b; --ac-ink: #f0f1f2; --ac-muted: #b0b4bc; color: var(--ac-ink); }
.ac-header { display:flex; flex-wrap:wrap; align-items:center; gap:12px; padding:16px 20px; background:var(--ac-paper); border-bottom:1px solid var(--ac-edge); }
.ac-header h1 { font-size:18px; margin:0 auto 0 0; }
#view-assets button, #view-assets select { font:inherit; font-size:13px; color:var(--ac-ink); border:1px solid var(--ac-edge); border-radius:8px; background:var(--ac-panel); padding:8px 12px; cursor:pointer; }
#view-assets button:hover { border-color:var(--ac-muted); }
#view-assets button:focus-visible, #view-assets select:focus-visible, #view-assets textarea:focus-visible, .ac-node:focus-visible { outline:2px solid var(--color-primary-hover); outline-offset:3px; }
#view-assets button:disabled { opacity:.5; cursor:not-allowed; }
.ac-save { font-size:12px; color:var(--ac-muted); }
.ac-stage { position:relative; flex:1; min-height:320px; overflow:hidden; touch-action:none; background-color:var(--ac-paper); background-image:radial-gradient(var(--ac-edge) .7px,transparent .7px); background-size:24px 24px; }
.ac-world { position:absolute; left:0; top:0; transform-origin:0 0; }
.ac-group { position:absolute;box-sizing:border-box;border:1px solid var(--group-color);border-radius:16px;background:color-mix(in srgb,var(--group-color) 15%,transparent);cursor:grab; }
.ac-group.selected { outline:2px solid var(--group-color);outline-offset:3px; }
.ac-group-layout { display:flex;gap:8px;padding:0 16px 10px; }
#view-assets .ac-group-layout button[aria-pressed="true"] { border-color:var(--ac-ink);background:var(--group-color); }
.ac-group header { display:flex;align-items:center;gap:12px;padding:10px 16px;cursor:grab;color:var(--ac-ink); }
.ac-group header strong { flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:320px; }
.ac-group header span,.ac-group p { font-size:12px;color:var(--ac-muted); }
.ac-group p { margin:4px 16px;pointer-events:none; }
#view-assets .ac-group button { padding:4px 8px;background:var(--ac-panel); }
.ac-node { z-index:1; }
#view-assets #ac-membership { max-width:180px; }
#view-assets #ac-group-type { width:auto;max-width:160px; }
.ac-edges { position:absolute; left:0; top:0; width:1px; height:1px; overflow:visible; pointer-events:none; }
.ac-edge { fill:none; stroke:var(--ac-edge); stroke-width:1.5; transition:stroke 180ms; }
.ac-edge-group.highlighted .ac-edge, .ac-edge-group:hover .ac-edge { stroke:var(--ac-ink); }
.ac-edge-group.working .ac-edge { stroke:var(--color-primary-hover); opacity:.45; }
.ac-edge-flow { fill:none; stroke:var(--color-primary-hover); stroke-width:2; stroke-dasharray:6 14; animation:ac-line-flow 1.1s linear infinite; }
.ac-edge-preview { fill:none; stroke:var(--ac-ink); stroke-width:1.5; stroke-dasharray:5 5; }
@keyframes ac-line-flow { to { stroke-dashoffset:-40; } }
.ac-edge-hit { fill:none; stroke:transparent; stroke-width:18; pointer-events:stroke; cursor:pointer; }
.ac-node { position:absolute; width:264px; border:1px solid var(--ac-edge); border-radius:12px; background:var(--ac-panel); user-select:none; }
.ac-node.selected { border-color:var(--color-primary-hover); }
.ac-node.referenced { outline:2px solid var(--ac-ink); outline-offset:5px; }
.ac-node.working { border-color:var(--color-primary-hover); }
.ac-result-state { padding:8px 12px; font-size:12px; color:var(--ac-muted); max-height:80px; overflow:auto; white-space:pre-line; overflow-wrap:anywhere; }
.ac-result-state.error, .ac-editor-note.error { color:var(--color-destructive); }
.ac-node-head { display:flex; align-items:center; gap:8px; padding:10px 12px; cursor:grab; }
.ac-node-head strong { font-size:13px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; flex:1; }
#view-assets .ac-delete { padding:2px 8px; border:0; background:transparent; }
.ac-node-media { height:210px; display:flex; flex-wrap:wrap; overflow:auto; align-items:center; justify-content:center; background:var(--ac-paper); border-radius:0 0 12px 12px; }
.ac-node-media img { width:100%; height:100%; object-fit:contain; cursor:grab; }
.ac-node-media.multi img { width:50%; height:50%; }
/* Image bytes and intrinsic dimensions are preserved; zoom belongs to the canvas. */
.ac-node.image-node { border:0;border-radius:0;background:transparent; }
.ac-node.image-node.selected { border:0; }
.ac-node.image-node.selected .ac-node-media { outline:1px solid var(--color-primary-hover);outline-offset:4px; }
.ac-node.image-node .ac-node-head { position:absolute;bottom:100%;left:0;right:0;background:var(--ac-panel);border-radius:8px;padding:6px 8px;opacity:0;z-index:2; }
.ac-node.image-node:hover .ac-node-head,.ac-node.image-node:focus-within .ac-node-head,.ac-node.image-node.selected .ac-node-head { opacity:1; }
.ac-node.image-node .ac-node-media { height:auto;display:flex;flex-wrap:nowrap;overflow:visible;background:none;border-radius:0;align-items:flex-start; }
.ac-node.image-node .ac-node-media img { display:block;width:auto;height:auto;max-width:none;max-height:none;flex:none;object-fit:initial; }
#view-assets .ac-node .ac-port { top:calc(var(--node-mid,135px) - 12px); }
.ac-node-status { padding:14px; color:var(--ac-muted); font-size:13px; line-height:1.7; white-space:pre-wrap; overflow-wrap:anywhere; max-height:210px; overflow:auto; }
.ac-node-status.error { color:var(--color-destructive); }
#view-assets .ac-port { position:absolute; top:123px; width:24px; min-width:24px; height:24px; min-height:24px !important; padding:0; border-radius:50%; border:3px solid var(--ac-paper); background:var(--ac-muted); }
.ac-port.in { left:-13px; } .ac-port.out { right:-13px; }
#view-assets .ac-port.armed { background:var(--color-primary-hover); }
.ac-empty { position:absolute; left:50%; top:35%; transform:translate(-50%,-50%); width:min(440px,85%); text-align:center; pointer-events:none; }
.ac-empty h2 { font-size:24px; margin:0 0 12px; } .ac-empty p { color:var(--ac-muted); line-height:1.8; }
.ac-bottom { position:absolute; bottom:16px; left:16px; right:16px; display:flex; align-items:center; gap:8px; pointer-events:none; }
.ac-bottom>* { pointer-events:auto; } .ac-help { margin-left:auto; font-size:12px; color:var(--ac-muted); max-width:380px; }
.ac-tools { display:flex; align-items:center; gap:4px; padding:6px; border:1px solid var(--ac-edge); border-radius:12px; background:var(--ac-panel); }
#view-assets .ac-tools button { padding:8px; border:0; background:transparent; display:inline-flex; align-items:center; justify-content:center; min-width:36px; }
#view-assets .ac-tools button[aria-pressed="true"] { background:var(--ac-edge); }
.ac-tools #ac-zoom-label { min-width:44px; text-align:center; font-size:12px; font-variant-numeric:tabular-nums; }
.ac-tool-separator { height:16px; width:1px; background:var(--ac-edge); flex-shrink:0; margin:0 4px; }
.ac-stage.pan-mode, .ac-stage.pan-mode .ac-node, .ac-stage.pan-mode .ac-node-head, .ac-stage.pan-mode img { cursor:grab; }
.ac-editor { position:absolute; right:20px; bottom:80px; width:min(720px,calc(100% - 40px)); box-sizing:border-box; max-height:calc(100% - 100px); overflow:auto; padding:16px; border:1px solid var(--ac-edge); border-radius:16px; background:var(--ac-panel); z-index:5; }
.ac-editor.expanded { width:calc(100% - 40px); top:20px; bottom:80px; display:flex; flex-direction:column; }
.ac-editor.expanded .ac-prompt { flex:1; max-height:none; }
.ac-editor[hidden] { display:none; }
.ac-editor-top { display:flex; justify-content:space-between; align-items:center; gap:12px; margin-bottom:12px; }
.ac-editor-top h2 { font-size:14px; font-weight:500; color:var(--ac-muted); margin:0 auto 0 0; }
#view-assets .ac-editor-top button { display:inline-flex; align-items:center; justify-content:center; padding:6px; border:0; background:transparent; }
.ac-reference-actions { display:flex; align-items:center; flex-wrap:wrap; gap:6px; }
#view-assets .ac-reference-actions button { display:inline-flex; align-items:center; gap:4px; padding:4px 8px; border:0; background:var(--ac-paper); color:var(--ac-muted); }
#view-assets #ac-template { margin-left:auto; max-width:180px; padding:5px 8px; border:0; background:transparent; color:var(--ac-muted); }
.ac-ref-list { display:flex; flex-wrap:wrap; gap:12px; margin:12px 0 16px; }
.ac-ref-list:empty { margin:0; }
.ac-ref { position:relative; width:56px; height:56px; }
#view-assets .ac-ref-insert { position:relative; display:block; width:56px; height:56px; min-height:56px; padding:0; border-radius:8px; overflow:hidden; cursor:grab; }
.ac-ref img { width:100%; height:100%; object-fit:cover; }
.ac-ref-number { position:absolute; left:3px; top:3px; display:grid; place-items:center; width:17px; height:17px; font-size:11px; border-radius:50%; background:#17181bd9; color:var(--ac-ink); }
.ac-ref-at { position:absolute; right:3px; bottom:3px; font-size:12px; background:#17181bd9; border-radius:4px; padding:0 3px; }
#view-assets .ac-ref-remove { position:absolute; right:-8px; top:-8px; width:22px; height:22px; min-height:22px; padding:3px; display:grid; place-items:center; border-radius:50%; background:var(--ac-panel); opacity:0; }
.ac-ref:hover .ac-ref-remove, .ac-ref:focus-within .ac-ref-remove { opacity:1; }
.ac-ref-remove svg { width:12px; height:12px; }
.ac-editor label { display:block; font-size:12px; color:var(--ac-muted); margin-bottom:6px; }
.ac-prompt { min-height:130px; max-height:260px; overflow:auto; margin-top:12px; padding:4px 2px 12px; font-size:16px; line-height:1.9; white-space:pre-wrap; overflow-wrap:anywhere; outline:none; cursor:text; user-select:text; touch-action:pan-y; }
.ac-prompt:empty::before { content:attr(aria-placeholder); color:var(--ac-muted); pointer-events:none; }
.ac-prompt[aria-disabled="true"] { opacity:.65; cursor:wait; }
.ac-prompt.drop-target, .dragging-reference .ac-prompt { outline:1px dashed var(--ac-muted); outline-offset:4px; border-radius:4px; background:var(--ac-paper); }
.ac-mention { display:inline-flex; align-items:center; vertical-align:baseline; gap:4px; height:25px; padding:0 5px; margin:0 2px; border:1px solid var(--ac-edge); border-radius:6px; font-size:14px; line-height:1; white-space:nowrap; user-select:all; cursor:grab; }
.ac-mention img { width:18px; height:18px; object-fit:cover; border-radius:3px; pointer-events:none; }
.ac-controls { position:relative; display:flex; gap:8px; flex-wrap:wrap; align-items:center; margin-top:8px; }
#view-assets #ac-model { flex:1; min-width:100px; max-width:280px; width:auto; padding-left:0; border:0; background:transparent; }
.ac-params { position:static; }
.ac-params summary { display:flex; align-items:center; gap:6px; min-height:36px; padding:4px; cursor:pointer; font-size:13px; list-style:none; }
.ac-params summary::-webkit-details-marker { display:none; }
.ac-params summary::after { content:''; width:5px; height:5px; border-right:1px solid var(--ac-muted); border-bottom:1px solid var(--ac-muted); transform:rotate(45deg); margin-left:4px; }
.ac-params-panel { position:absolute; bottom:calc(100% + 8px); right:0; width:min(340px,100%); box-sizing:border-box; padding:16px; border:1px solid var(--ac-edge); background:var(--ac-paper); border-radius:12px; display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; z-index:2; }
.ac-params-panel select { width:100%; min-width:0; }
.ac-params-panel p { grid-column:1/-1; color:var(--ac-muted); font-size:12px; margin:0; }
.ac-controls { align-items:flex-start; }
.ac-params { flex:1 0 100%;order:2; }
.ac-params summary { pointer-events:none; }
.ac-params-panel { position:static;width:100%;border:0;padding:8px 0;background:none; }
.ac-source-info p { font-size:13px;color:var(--ac-muted);line-height:1.7; }
.ac-source-info h3 { font-size:14px; }
.ac-source-info>button { display:block;margin-top:8px;max-width:100%;white-space:normal;text-align:left; }
#view-assets .ac-generate { background:var(--ac-ink); color:var(--ac-paper); margin-left:auto; font-weight:600; padding:8px 12px; }
.ac-picker { padding:12px 0; border-bottom:1px solid var(--ac-edge); }
.ac-picker[hidden] { display:none; }
.ac-picker-head { display:flex; align-items:center; justify-content:space-between; gap:8px; font-size:12px; }
#view-assets .ac-picker-head button { display:inline-flex; border:0; padding:4px; }
#ac-picker-list { display:flex; gap:8px; overflow:auto; padding:8px 0; max-height:160px; }
#view-assets #ac-picker-list button { position:relative; flex:0 0 88px; width:88px; padding:4px; text-align:left; }
#ac-picker-list img { width:78px; height:64px; object-fit:cover; border-radius:4px; display:block; }
#ac-picker-list span { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:11px; margin-top:4px; }
#ac-picker-list small { position:absolute; top:6px; left:6px; font-size:10px; padding:2px; border-radius:3px; background:var(--ac-paper); }
.ac-sr-only { position:absolute !important; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }
.ac-editor-note { color:var(--ac-muted); font-size:12px; line-height:1.7; margin:12px 0 0; }
.ac-lightbox { background:var(--ac-paper); color:var(--ac-ink); border:1px solid var(--ac-edge); border-radius:12px; max-width:90vw; max-height:90vh; }
.ac-lightbox::backdrop { background:#000b; } .ac-lightbox img { display:block; max-width:80vw; max-height:70vh; object-fit:contain; }
.ac-lightbox form { display:flex; flex-wrap:wrap; gap:8px; justify-content:end; padding-top:12px; }
@media(max-width:700px) { .ac-header { padding:12px; gap:8px; } .ac-header h1 { width:100%; } .ac-save { display:none; } .ac-editor, .ac-editor.expanded { right:8px; width:calc(100% - 16px); padding:12px; box-sizing:border-box; bottom:80px; max-height:calc(100% - 96px); } .ac-help { display:none; } .ac-controls { gap:4px; } #view-assets #ac-model { max-width:45%; } .ac-params summary { font-size:12px; } .ac-params summary svg { display:none; } .ac-editor-top { gap:6px; } .ac-prompt { font-size:15px; min-height:100px; max-height:200px; } #view-assets .ac-generate { padding:8px; } .ac-ref-remove { opacity:1 !important; } .ac-bottom { left:8px; right:8px; } .ac-tools { gap:0; } }
@media(prefers-reduced-motion:reduce) { #view-assets * { scroll-behavior:auto; transition:none; animation:none; } }
.ac-node.image-node .ac-node-head { display:none !important; }
.ac-node-media img { user-select:none; -webkit-user-drag:none; }
.ac-context { position:fixed; z-index:1000; min-width:160px; padding:6px; background:var(--ac-paper,#202124); color:var(--ac-ink,#eee); border:1px solid var(--ac-edge,#555); border-radius:10px; box-shadow:0 12px 32px #0005; }
.ac-context[hidden] { display:none; }
.ac-group-name { position:absolute;right:12px;top:-30px;max-width:260px;padding:4px 10px;border-radius:5px;background:var(--group-color);color:#fff;cursor:text;white-space:nowrap;overflow:hidden;text-overflow:ellipsis; }
.ac-group-toolbar { position:absolute;left:50%;bottom:calc(100% + 44px);transform:translateX(-50%);display:flex;align-items:center;gap:8px;padding:8px;background:var(--ac-panel);border-radius:12px;white-space:nowrap;z-index:3;width:max-content; }
#view-assets .ac-group-toolbar input[type=color] { display:block;box-sizing:border-box;flex:0 0 48px;width:48px;height:48px;min-width:48px;padding:0;border:0;border-radius:8px;background:var(--group-color);cursor:pointer;appearance:none; }
.ac-group-toolbar input[type=color]::-webkit-color-swatch-wrapper { padding:0; }
.ac-group-toolbar input[type=color]::-webkit-color-swatch { border:0;border-radius:8px; }
.ac-group-toolbar input[type=color]::-moz-color-swatch { border:0;border-radius:8px; }
#view-assets .ac-group-toolbar select { box-sizing:border-box;flex:0 0 auto;width:auto;min-width:104px;max-width:none;height:38px;padding:6px 28px 6px 12px;line-height:24px;appearance:auto;text-overflow:clip; }
#view-assets .ac-group-toolbar select[data-group-setting="storyGrid"] { min-width:142px; }
#view-assets .ac-group-toolbar select[data-group-setting="layout"] { min-width:132px; }
#view-assets .ac-group-toolbar button { flex-shrink:0;min-height:38px; }
.ac-story-cells { position:absolute;display:grid;gap:4px;pointer-events:none; }
.ac-story-cells > div { position:relative;background:var(--ac-panel);outline:1px solid var(--ac-edge); }
.ac-story-cells span,.ac-shot-number { position:absolute;bottom:6px;left:6px;background:#0009;color:#fff;padding:2px 5px;font-size:13px;pointer-events:none; }
.ac-story-node { overflow:hidden; }
.ac-story-node .ac-node-media,.ac-story-node .ac-node-media img { width:100% !important;height:100% !important;object-fit:cover; }
.ac-photo-tools { position:absolute;top:16px;left:50%;transform:translateX(-50%);display:flex;gap:6px;padding:6px;background:var(--ac-panel);border-radius:12px;z-index:5; }
.ac-photo-tools[hidden] { display:none; }
.ac-photo-tools details { position:relative; }
.ac-photo-tools summary { cursor:pointer;padding:8px 12px;font-size:13px; }
.ac-photo-tools details > div { position:absolute;right:0;top:100%;min-width:160px;padding:6px;background:var(--ac-panel);border-radius:8px; }
.ac-photo-tools details button { display:block;width:100%;text-align:left; }
#view-assets .ac-context button { display:block; width:100%; text-align:left; border:0; padding:9px 14px; background:transparent; color:inherit; }
#view-assets .ac-context button:hover { background:#8882; }
#view-assets .ac-editor, #view-assets .ac-editor.expanded { right:auto;bottom:auto;top:auto;width:min(720px,calc(100% - 16px));max-height:min(580px,calc(100% - 32px)); }
#view-assets .ac-editor.expanded { width:min(960px,calc(100% - 16px)); }
#view-assets .ac-photo-tools { left:auto;top:auto;transform:none;max-width:calc(100% - 16px);flex-wrap:wrap; }
