/* Artifact Preview — inline HTML preview in chat bubbles + gallery panel */

/* ── Preview button under HTML code blocks ── */
.artifact-preview-btn{
  display:flex;align-items:center;gap:6px;
  margin-top:6px;padding:6px 14px;
  border:1px solid rgba(135,160,180,.22);border-radius:10px;
  background:rgba(255,255,255,.55);
  color:rgba(60,80,100,.78);font:500 12.5px var(--font-cn,-apple-system,system-ui,sans-serif);
  cursor:pointer;transition:background .15s,border-color .15s;
  -webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);
}
.artifact-preview-btn:active{background:rgba(255,255,255,.82);border-color:rgba(135,160,180,.38)}
.artifact-preview-btn svg{width:15px;height:15px;flex-shrink:0;stroke:currentColor;fill:none;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round}

/* ── Inline iframe preview ── */
.artifact-iframe-wrap{
  position:relative;margin-top:8px;
  border:1px solid rgba(135,160,180,.18);border-radius:14px;
  overflow:hidden;background:#fff;
  box-shadow:0 4px 16px rgba(20,30,40,.06);
}
.artifact-iframe-bar{
  display:flex;align-items:center;justify-content:space-between;
  padding:6px 12px;
  background:rgba(245,248,250,.92);border-bottom:1px solid rgba(135,160,180,.12);
  font:500 11.5px var(--font-cn);color:rgba(60,80,100,.6);
}
.artifact-iframe-bar button{
  border:0;background:none;color:rgba(60,80,100,.55);cursor:pointer;
  width:28px;height:28px;display:grid;place-items:center;border-radius:6px;
  transition:background .12s;
}
.artifact-iframe-bar button:active{background:rgba(0,0,0,.06)}
.artifact-iframe-bar button svg{width:14px;height:14px;stroke:currentColor;fill:none;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.artifact-iframe-bar .artifact-bar-actions{display:flex;gap:2px}
.artifact-iframe{
  width:100%;border:0;display:block;
  min-height:200px;max-height:480px;
  background:#fff;
}

/* ── Fullscreen overlay ── */
.artifact-fullscreen{
  position:fixed;inset:0;z-index:9999;
  display:flex;flex-direction:column;
  background:rgba(0,0,0,.85);
  -webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);
  animation:artifactFadeIn .2s ease;
}
@keyframes artifactFadeIn{from{opacity:0}to{opacity:1}}
.artifact-fullscreen-bar{
  display:flex;align-items:center;justify-content:space-between;
  padding:max(env(safe-area-inset-top),12px) 16px 10px;
  background:rgba(30,35,42,.8);
  color:rgba(255,255,255,.85);font:500 14px var(--font-cn);
}
.artifact-fullscreen-bar button{
  border:0;background:none;color:rgba(255,255,255,.7);cursor:pointer;
  width:36px;height:36px;display:grid;place-items:center;border-radius:8px;
}
.artifact-fullscreen-bar button:active{background:rgba(255,255,255,.1)}
.artifact-fullscreen-bar button svg{width:18px;height:18px;stroke:currentColor;fill:none;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.artifact-fullscreen iframe{
  flex:1;width:100%;border:0;background:#fff;
}

/* ── Gallery panel ── */
.artifact-gallery{
  position:fixed;inset:0;z-index:300;
  display:none;flex-direction:column;
  background:var(--nc-bg,rgba(241,246,249,.97));
  color:var(--nc-text,#2c3e50);
}
.artifact-gallery.open{display:flex}
.artifact-gallery-head{
  height:calc(48px + env(safe-area-inset-top));
  padding:env(safe-area-inset-top) 8px 0;
  display:grid;grid-template-columns:52px minmax(0,1fr) 52px;align-items:center;
  background:var(--nc-bg,rgba(255,255,255,.72));
  -webkit-backdrop-filter:blur(18px);backdrop-filter:blur(18px);
  border-bottom:1px solid var(--nc-line,rgba(0,0,0,.06));
}
.artifact-gallery-back{
  width:44px;height:44px;border:0;background:none;
  color:var(--nc-text,rgba(72,91,112,.68));display:grid;place-items:center;cursor:pointer;
}
.artifact-gallery-back svg{width:19px;height:19px;stroke:currentColor;fill:none;stroke-width:2.2;stroke-linecap:round;stroke-linejoin:round}
.artifact-gallery-title{text-align:center;font:600 16px var(--font-cn);color:var(--nc-text)}
.artifact-gallery-body{
  flex:1;overflow:auto;
  padding:16px 16px calc(24px + env(safe-area-inset-bottom));
}
.artifact-gallery-empty{
  padding:60px 20px;text-align:center;
  color:var(--nc-muted,rgba(80,100,120,.5));font-size:14px;line-height:1.6;
}
.artifact-gallery-list{display:flex;flex-direction:column;gap:12px}
.artifact-gallery-card{
  padding:14px 16px;
  border:1px solid var(--nc-line,rgba(0,0,0,.06));border-radius:14px;
  background:var(--nc-card,rgba(255,255,255,.65));
  cursor:pointer;transition:background .12s;
}
.artifact-gallery-card:active{background:rgba(255,255,255,.9)}
.artifact-gallery-card-title{font:600 14px var(--font-cn);margin-bottom:4px}
.artifact-gallery-card-meta{font-size:12px;color:var(--nc-muted,rgba(80,100,120,.5))}
.artifact-gallery-card-preview{
  margin-top:10px;height:120px;border-radius:8px;overflow:hidden;
  border:1px solid rgba(0,0,0,.04);background:#fff;
  pointer-events:none;
}
.artifact-gallery-card-preview iframe{
  width:200%;height:200%;border:0;
  transform:scale(.5);transform-origin:top left;
  pointer-events:none;
}

/* ── Collapsible HTML code block ── */
.artifact-code-wrap{
  position:relative;
}
.artifact-code-wrap .md-pre{
  max-height:0;overflow:hidden;margin:0;padding:0;border:0;
  opacity:0;transition:max-height .3s ease,opacity .2s,padding .3s,margin .3s;
}
.artifact-code-wrap.code-expanded .md-pre{
  max-height:2000px;opacity:1;
  padding:9px 12px;margin:.45em 0;
}
.artifact-code-toggle{
  display:flex;align-items:center;gap:5px;
  margin-top:4px;padding:4px 10px;
  border:0;border-radius:8px;
  background:rgba(0,0,0,.04);
  color:rgba(60,80,100,.5);font:400 11.5px var(--font-cn);
  cursor:pointer;transition:background .12s;
}
.artifact-code-toggle:active{background:rgba(0,0,0,.08)}
.artifact-code-toggle svg{width:12px;height:12px;stroke:currentColor;fill:none;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round;transition:transform .2s}
.artifact-code-wrap.code-expanded .artifact-code-toggle svg{transform:rotate(180deg)}
