/* The chat + canvas layout shared by montage.html and ads.html (assets/chat-ui.js), on top of ui.css and shell.css,
   the same look as the workspace: the chat column with its thread and composer, the canvas with the results, and a
   drag handle between them. */
.app>.main.chat-main{display:grid;grid-template-columns:var(--chatw,420px) minmax(0,1fr);direction:ltr}
.chat-main>.chat,.chat-main>.canvas{direction:rtl;min-width:0;min-height:0}
.chat-main>.grip{position:absolute;top:0;bottom:0;left:calc(var(--chatw,420px) - 5px);width:10px;z-index:25;cursor:col-resize;touch-action:none;outline:0}
.chat-main>.grip::after{content:"";position:absolute;top:0;bottom:0;left:4px;width:2px;border-radius:2px;background:transparent;transition:background-color .15s .08s}
.chat-main>.grip:hover::after,.chat-main>.grip:focus-visible::after,.chat-main>.grip.on::after{background:var(--primary)}
.app.resizing{cursor:col-resize;user-select:none}
.app.resizing .canvas{pointer-events:none}

/* ---------- chat ---------- */
.chat{display:flex;flex-direction:column;background:var(--surface);border-right:1px solid var(--line)}
.chat-head{height:var(--head-h);display:flex;align-items:center;gap:8px;padding:0 14px 0 12px;border-bottom:1px solid var(--line);flex:none}
.chat-head .ttl{flex:1;min-width:0;font-weight:600;font-size:15px;border:0;background:transparent;padding:6px 8px;border-radius:var(--r-sm);text-overflow:ellipsis;color:var(--ink);transition:background-color var(--t-fast),box-shadow var(--t-fast)}
.chat-head .ttl:not([readonly]):hover{background:var(--soft)}
.chat-head .ttl:not([readonly]):focus{background:var(--surface);box-shadow:inset 0 0 0 1px var(--primary),var(--ring)}
.chat-head .ttl[readonly]{cursor:default}
.chat-head .beta{font-size:11.5px;font-weight:600;color:var(--primary-ink);background:var(--primary-soft);border-radius:var(--r-full);padding:2px 10px;white-space:nowrap}
.thread{flex:1;overflow-y:auto;padding:24px 20px 12px;display:flex;flex-direction:column;gap:22px;scroll-behavior:smooth}
.msg{display:flex;gap:12px;align-items:flex-start;max-width:100%;animation:msgIn .32s var(--ease) both}
@keyframes msgIn{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
.msg .av{width:28px;height:28px;border-radius:9px;flex:none;display:grid;place-items:center;background:var(--surface);box-shadow:0 0 0 1px var(--line),var(--sh-xs);margin-top:1px}
.msg .av img{width:16px}
.msg .body{min-width:0;flex:1}
.msg.bot .bubble{white-space:pre-wrap;font-size:14.5px;line-height:1.85;color:var(--ink)}
.msg.user{justify-content:flex-end}
.msg.user .body{display:flex;flex-direction:column;align-items:flex-end;flex:initial;max-width:86%}
.msg.user .bubble{background:var(--soft);color:var(--ink);border-radius:18px;padding:10px 15px;white-space:pre-wrap;font-size:14.5px;line-height:1.7}
.msg .files{display:flex;flex-wrap:wrap;gap:6px;justify-content:flex-end;margin-bottom:6px}
.msg .files span{display:inline-flex;align-items:center;gap:8px;font-size:12.5px;font-weight:600;background:var(--surface);border-radius:var(--r-md);padding:5px 10px 5px 6px;box-shadow:0 0 0 1px var(--line),var(--sh-xs)}
.msg .files img{width:34px;height:34px;border-radius:var(--r-xs);object-fit:cover}
.msg .files svg{width:16px;height:16px;flex:none;color:var(--stone)}
.typing{display:inline-flex;gap:5px;padding:10px 0}
.typing i{width:7px;height:7px;border-radius:50%;background:var(--ghost);animation:bl 1.1s infinite ease-in-out}
.typing i:nth-child(2){animation-delay:.15s}.typing i:nth-child(3){animation-delay:.3s}
@keyframes bl{0%,100%{opacity:.35;transform:translateY(0)}50%{opacity:1;transform:translateY(-2px)}}
.card{margin-top:12px;background:var(--surface);border-radius:var(--r-xl);padding:16px;border:1px solid var(--line);box-shadow:var(--sh-sm)}
.card h4{margin:0 0 12px;font-size:14.5px;font-weight:600}
.card .acts{display:flex;flex-wrap:wrap;gap:8px;margin-top:14px}
.quick{display:flex;flex-wrap:wrap;gap:6px;margin-top:12px}
.quick button{height:32px;padding:0 13px;border-radius:var(--r-full);border:0;background:var(--surface);box-shadow:inset 0 0 0 1px var(--sand),var(--sh-xs);font-size:13px;font-weight:500;color:var(--ink-2);transition:background-color var(--t-fast),box-shadow var(--t-fast),color var(--t-fast)}
.quick button:hover{background:var(--soft);color:var(--ink);box-shadow:inset 0 0 0 1px var(--line-strong)}
.quick button.main{background:var(--primary-soft);color:var(--primary-ink);box-shadow:inset 0 0 0 1.5px var(--primary);font-weight:600}
.quick button.main:hover{background:var(--primary-soft-2)}
.quick.used{opacity:.5;pointer-events:none}
.sum{display:grid;grid-template-columns:auto 1fr;gap:6px 14px;font-size:13.5px;margin:0}
.sum dt{color:var(--stone)}
.sum dd{margin:0;font-weight:500;min-width:0;overflow-wrap:anywhere}
.bar{height:6px;border-radius:99px;background:var(--soft-2);overflow:hidden;margin:10px 0 6px}
.bar i{display:block;height:100%;width:0;background:var(--grad);border-radius:99px;transition:width .5s var(--ease)}

/* ---------- composer ---------- */
.dock{padding:12px 16px 14px;flex:none}
.composer{position:relative;background:var(--surface);border-radius:var(--r-xl);box-shadow:0 0 0 1px var(--sand),var(--sh-sm);transition:box-shadow var(--t)}
.composer:focus-within{box-shadow:0 0 0 1px var(--primary),var(--ring),var(--sh-sm)}
.composer textarea{display:block;width:100%;border:0;outline:0;background:transparent;resize:none;min-height:48px;max-height:180px;padding:13px 16px 4px;line-height:1.8;font-size:14.5px}
.composer textarea::placeholder{color:var(--faint)}
.c-tray{display:flex;flex-wrap:wrap;gap:6px;padding:10px 12px 0}
.c-tray:empty{display:none}
.c-file{position:relative;display:inline-flex;align-items:center;gap:8px;max-width:100%;height:42px;padding:0 10px 0 6px;border-radius:var(--r-md);background:var(--app);box-shadow:inset 0 0 0 1px var(--line);font-size:12.5px;font-weight:600}
.c-file img,.c-file .vid{width:30px;height:30px;border-radius:var(--r-xs);object-fit:cover;flex:none;background:#1C1C22;display:grid;place-items:center;color:#fff}
.c-file .vid svg{width:14px;height:14px}
.c-file .nm{max-width:160px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.c-file small{color:var(--stone);font-weight:500}
.c-file .x{width:20px;height:20px;border-radius:50%;border:0;background:var(--surface);box-shadow:0 1px 4px rgba(0,0,0,.18);font-size:13px;line-height:1;display:grid;place-items:center;color:var(--ink-2)}
.c-file .x:hover{color:var(--bad)}
.c-row{display:flex;align-items:center;gap:6px;padding:4px 8px 8px}
.c-btn{width:32px;height:32px;border-radius:var(--r-sm);border:0;background:transparent;display:grid;place-items:center;color:var(--stone);transition:background-color var(--t-fast),color var(--t-fast)}
.c-btn:hover{background:var(--soft);color:var(--ink)}
.c-btn svg{width:18px;height:18px}
.c-extra{display:flex;align-items:center;gap:6px;flex-wrap:wrap;min-width:0}
.c-pill{height:30px;display:inline-flex;align-items:center;gap:6px;padding:0 11px;border-radius:var(--r-full);border:0;background:var(--soft);color:var(--ink-2);font-size:12.5px;font-weight:600;white-space:nowrap}
.c-pill select{border:0;background:transparent;font-weight:600;outline:0;cursor:pointer}
.send{margin-inline-start:auto;width:34px;height:34px;border-radius:var(--r-md);border:0;background:var(--primary);color:#fff;display:grid;place-items:center;flex:none;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.15),0 2px 6px -2px rgba(114,50,242,.6);transition:background-color var(--t-fast),transform var(--t-fast)}
.send:hover:not(:disabled){background:var(--primary-h)}
.send:active:not(:disabled){transform:scale(.96)}
.send:disabled{background:var(--soft-2);color:var(--faint);box-shadow:none;cursor:default}
.send svg{width:17px;height:17px}
.dock .hint{font-size:12px;color:var(--faint);text-align:center;margin-top:8px;line-height:1.5}

/* ---------- canvas ---------- */
.canvas{display:flex;flex-direction:column;background:var(--app) radial-gradient(circle at 1px 1px,rgba(20,20,26,.065) 1px,transparent 0) 0 0/22px 22px}
.canvas-head{height:var(--head-h);display:flex;align-items:center;gap:12px;padding:0 16px 0 18px;border-bottom:1px solid var(--line);background:rgba(255,255,255,.88);backdrop-filter:saturate(1.6) blur(10px);flex:none;position:relative;z-index:2}
.canvas-head b{font-size:15px;font-weight:600}
.ch-end{margin-inline-start:auto;display:flex;gap:8px;align-items:center;flex:none}
.stage{flex:1;overflow-y:auto;padding:24px 24px 48px}
.stage-empty{height:100%;display:grid;place-items:center;text-align:center;color:var(--stone);padding:24px}
.stage-empty div{display:grid;gap:8px;justify-items:center;max-width:360px;font-size:14px;line-height:1.7}
.stage-empty svg{width:56px;height:56px;padding:14px;margin-bottom:6px;border-radius:16px;color:var(--stone);background:var(--surface);box-shadow:0 0 0 1px var(--line),var(--sh-sm)}
.stage-empty b{color:var(--ink);font-size:16px;font-weight:600}
.tile{background:var(--surface);border-radius:var(--r-xl);padding:8px;box-shadow:0 0 0 1px rgba(20,20,26,.06),var(--sh-sm)}
.mtabs{display:none}

@media (max-width:900px){
  .app>.main.chat-main{grid-template-columns:minmax(0,1fr)}
  .chat-main>.grip{display:none}
  .chat-main>.chat,.chat-main>.canvas{grid-area:1/1}
  .chat-main[data-view="chat"]>.canvas,.chat-main[data-view="canvas"]>.chat{display:none}
  .mtabs{display:flex;gap:2px;background:var(--soft);border-radius:var(--r-md);padding:3px;flex:none}
  .mtabs button{height:30px;padding:0 11px;border:0;border-radius:var(--r-sm);background:transparent;font-size:12.5px;font-weight:600;white-space:nowrap;color:var(--ink-3)}
  .mtabs button[aria-selected="true"]{background:var(--surface);color:var(--ink);box-shadow:var(--sh-sm)}
  .chat-head .beta{display:none}
  .canvas-head .mtabs{margin-inline-start:0}
  .chat-head,.canvas-head{padding:0 10px}
  .thread{padding:20px 14px 10px}
  .dock{padding:10px 12px 12px}
  .stage{padding:16px 14px 32px}
}
