/* ========================================
   AI Designer Canvas - Glass Theme + Mobile Fixed (FULL FILE)
   ✅ 直接整文件替换即可
   - 默认：只显示对话（sidepanel 全屏）；workspace/toolbar 隐藏（<=700px）
   - 收缩：body.panel-collapsed => 隐藏对话；显示画布全屏 + 底部工具栏贴底（<=700px）
   - Glass（VisionOS / Apple-like）：全局毛玻璃 + 浮层 + 按钮/输入框重做
   ======================================== */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root{
  /* -------------------------
     Glass tokens (Light)
     ------------------------- */
  --app-bg: radial-gradient(1200px 600px at 20% 10%, rgba(10,132,255,.20), transparent 60%),
            radial-gradient(900px 500px at 80% 20%, rgba(175,82,222,.16), transparent 55%),
            radial-gradient(900px 700px at 40% 90%, rgba(52,199,89,.12), transparent 55%),
            linear-gradient(180deg, rgba(245,247,250,1) 0%, rgba(238,242,247,1) 60%, rgba(245,247,250,1) 100%);

  --glass-bg: rgba(255,255,255,.62);
  --glass-bg-strong: rgba(255,255,255,.78);
  --glass-bg-weak: rgba(255,255,255,.42);
  --glass-border: rgba(255,255,255,.55);
  --glass-border-2: rgba(17,24,39,.10);
  --glass-highlight: rgba(255,255,255,.75);

  --glass-blur: 18px;
  --glass-blur-strong: 28px;

  --glass-shadow: 0 10px 30px rgba(0,0,0,.10);
  --glass-shadow-2: 0 18px 60px rgba(0,0,0,.14);

  /* -------------------------
     Base palette (mapped to your old vars)
     ------------------------- */
  --bg-primary: transparent;
  --bg-secondary: var(--glass-bg);
  --bg-tertiary: rgba(255,255,255,.46);
  --bg-hover: rgba(255,255,255,.52);
  --bg-active: rgba(10,132,255,.14);

  --text-primary: rgba(17,24,39,.92);
  --text-secondary: rgba(17,24,39,.64);
  --text-tertiary: rgba(17,24,39,.40);
  --text-inverse: rgba(255,255,255,.96);

  --border-light: rgba(17,24,39,.10);
  --border-medium: rgba(17,24,39,.16);

  --accent-primary: #0a84ff;
  --accent-primary-hover: #0077ee;
  --accent-primary-light: rgba(10,132,255,.14);

  --accent-secondary: #34c759;
  --accent-warning: #ff9f0a;
  --accent-danger: #ff453a;
  --accent-orange: #ff9f0a;
  --accent-purple: #af52de;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.10), 0 2px 4px -2px rgba(0,0,0,0.10);
  --shadow-lg: var(--glass-shadow);
  --shadow-xl: var(--glass-shadow-2);

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 22px;
  --radius-full: 9999px;

  --toolbar-width: 52px;
  --panel-width: 380px;
  --topbar-height: 48px;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
    /* =========================
     Open Canvas CTA tokens
     ========================= */
  --canvas-cta: var(--accent-primary);                 /* 主色 */
  --canvas-cta-bg: rgba(10,132,255,.12);               /* 背景 */
  --canvas-cta-border: rgba(10,132,255,.55);           /* 描边 */
  --canvas-cta-shadow: 0 14px 34px rgba(10,132,255,.22);
  --canvas-cta-dot: rgba(10,132,255,1);                /* 角标点 */
  --canvas-cta-ring: rgba(10,132,255,.18);             /* 外发光 */

}

/* Dark mode */
@media (prefers-color-scheme: dark){
  :root{
    --app-bg: radial-gradient(1000px 650px at 20% 10%, rgba(10,132,255,.20), transparent 60%),
              radial-gradient(800px 520px at 80% 20%, rgba(175,82,222,.18), transparent 55%),
              radial-gradient(900px 700px at 40% 90%, rgba(48,209,88,.12), transparent 55%),
              linear-gradient(180deg, rgba(10,12,16,1) 0%, rgba(13,16,22,1) 60%, rgba(10,12,16,1) 100%);

    --glass-bg: rgba(20,24,31,.55);
    --glass-bg-strong: rgba(20,24,31,.72);
    --glass-bg-weak: rgba(20,24,31,.38);
    --glass-border: rgba(255,255,255,.14);
    --glass-border-2: rgba(255,255,255,.10);
    --glass-highlight: rgba(255,255,255,.10);

    --text-primary: rgba(255,255,255,.92);
    --text-secondary: rgba(255,255,255,.70);
    --text-tertiary: rgba(255,255,255,.48);

    --border-light: rgba(255,255,255,.14);
    --border-medium: rgba(255,255,255,.20);

    --glass-shadow: 0 14px 40px rgba(0,0,0,.35);
    --glass-shadow-2: 0 28px 90px rgba(0,0,0,.48);

    --bg-tertiary: rgba(20,24,31,.45);
    --bg-hover: rgba(255,255,255,.10);
    --canvas-cta-bg: rgba(10,132,255,.18);
    --canvas-cta-border: rgba(10,132,255,.60);
    --canvas-cta-shadow: 0 18px 50px rgba(10,132,255,.30);
    --canvas-cta-ring: rgba(10,132,255,.22);

  }
}

html, body { height: 100%; overflow: hidden; }

body{
  font-family: 'Inter','Noto Sans SC',-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;
  background: var(--app-bg);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app{
  height: 100vh;
  display: flex;
  overflow: hidden;
}

.hidden-input{ display: none !important; }

/* =========================================================
   Glass surfaces (shared)
   ========================================================= */
.toolbar-left,
.workspace-topbar,
.sidepanel,
.agent-drawer,
.dropdown-menu,
.agent-mode-menu,
.agent-settings-panel,
.panel-back-btn{
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--glass-blur));
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}

/* ✅ 防止某些移动端 stacking/覆盖异常：让浮层独立层叠上下文 */
.dropdown-menu,
.agent-mode-menu,
.agent-drawer,
.agent-settings-panel,
.panel-back-btn{
  isolation: isolate;
}

.toolbar-left,
.workspace-topbar,
.sidepanel,
.agent-drawer,
.dropdown-menu,
.agent-mode-menu,
.agent-settings-panel{
  position: relative;
}

.toolbar-left::before,
.workspace-topbar::before,
.sidepanel::before,
.agent-drawer::before,
.dropdown-menu::before,
.agent-mode-menu::before,
.agent-settings-panel::before{
  content:"";
  position:absolute;
  inset:0;
  border-radius: inherit;
  pointer-events:none;
  background: linear-gradient(180deg, rgba(255,255,255,.55), transparent 42%);
  opacity: .65;
}
@media (prefers-color-scheme: dark){
  .toolbar-left::before,
  .workspace-topbar::before,
  .sidepanel::before,
  .agent-drawer::before,
  .dropdown-menu::before,
  .agent-mode-menu::before,
  .agent-settings-panel::before{
    background: linear-gradient(180deg, rgba(255,255,255,.12), transparent 42%);
    opacity: .9;
  }
}

/* =========================================================
   Left Toolbar
   ========================================================= */
.toolbar-left{
  width: var(--toolbar-width);
  border-right: 1px solid var(--border-light);
  display:flex;
  flex-direction:column;
  padding: 8px 6px;
  gap: 4px;
  z-index: 100;
  flex-shrink: 0;
  border-radius: 0;
}

.toolbar-group{ display:flex; flex-direction:column; gap:2px; }
.toolbar-divider{ height:1px; background: rgba(17,24,39,.10); margin: 6px 4px; }
@media (prefers-color-scheme: dark){ .toolbar-divider{ background: rgba(255,255,255,.12); } }
.toolbar-spacer{ flex:1; }

.tool-btn{
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  transition: transform .15s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease, color .18s ease;
  position: relative;
  touch-action: manipulation;
}
.tool-btn:hover{
  background: var(--glass-bg-weak);
  border-color: var(--glass-border);
  box-shadow: 0 6px 18px rgba(0,0,0,.08);
  transform: translateY(-1px);
  color: var(--text-primary);
}
.tool-btn.active{
  background: rgba(10,132,255,.14);
  border-color: rgba(10,132,255,.28);
  color: var(--accent-primary);
  box-shadow: 0 10px 26px rgba(10,132,255,.10);
}
.tool-btn:active{ transform: translateY(0) scale(.98); }
.tool-btn:disabled{ opacity: .4; cursor:not-allowed; }
.tool-btn svg{ width:20px; height:20px; }
.tool-btn.small{ width:32px; height:32px; }
.tool-btn.small svg{ width:16px; height:16px; }

/* Dropdown */
.tool-dropdown{ position: relative; }

.dropdown-menu{
  position: absolute;
  left: 100%;
  top: 0;
  margin-left: 4px;
  min-width: 200px;
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  box-shadow: var(--glass-shadow-2);
  padding: 6px;
  z-index: 1000;
  display: none;
  opacity: 0;
  transform: translateX(-8px);
  transition: opacity .15s, transform .15s;
  max-height: min(60vh, 520px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.dropdown-menu.show{ display:block; opacity:1; transform: translateX(0); }

.dropdown-section{
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  padding: 8px 10px 4px;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.dropdown-item{
  display:flex;
  align-items:center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
  border-radius: 14px;
  transition: background .15s, transform .15s;
  text-align:left;
  touch-action: manipulation;
}
.dropdown-item:hover{
  background: rgba(255,255,255,.40);
  transform: translateY(-1px);
}
@media (prefers-color-scheme: dark){
  .dropdown-item:hover{ background: rgba(255,255,255,.10); }
}
.dropdown-item.active{
  background: rgba(10,132,255,.14);
  color: var(--accent-primary);
}
.dropdown-item svg{ flex-shrink:0; width:16px; height:16px; }
.dropdown-item .shortcut{
  margin-left:auto;
  font-size: 11px;
  color: var(--text-tertiary);
  background: rgba(255,255,255,.28);
  padding: 2px 6px;
  border-radius: 8px;
}
@media (prefers-color-scheme: dark){
  .dropdown-item .shortcut{ background: rgba(255,255,255,.08); }
}
.dropdown-divider{ height:1px; background: rgba(17,24,39,.10); margin: 6px 0; }
@media (prefers-color-scheme: dark){ .dropdown-divider{ background: rgba(255,255,255,.12); } }

/* Brush controls */
.brush-size-control{
  display:flex;
  align-items:center;
  gap: 10px;
  padding: 8px 10px;
}
.brush-size-control input[type="range"]{
  flex: 1;
  height: 4px;
  -webkit-appearance:none;
  appearance:none;
  background: rgba(17,24,39,.14);
  border-radius: 999px;
  outline:none;
  touch-action: pan-y;
}
@media (prefers-color-scheme: dark){
  .brush-size-control input[type="range"]{ background: rgba(255,255,255,.16); }
}
.brush-size-control input[type="range"]::-webkit-slider-thumb{
  -webkit-appearance:none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-primary);
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(10,132,255,.25);
}
.brush-size-label{
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  min-width: 36px;
}

.color-picker-row{
  display:flex;
  align-items:center;
  gap: 10px;
  padding: 8px 10px;
}
.color-picker-row input[type="color"]{
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  padding:0;
  background: transparent;
}
.color-label{
  font-size: 12px;
  color: var(--text-tertiary);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.toolbar-bottom{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-light);
  margin-top: 8px;
}
.credits-badge{
  display:flex;
  align-items:center;
  gap: 4px;
  padding: 4px 10px;
  background: rgba(255,255,255,.28);
  border: 1px solid var(--glass-border);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-orange);
}

/* =========================================================
   Workspace
   ========================================================= */
.workspace{
  flex:1;
  display:flex;
  flex-direction:column;
  min-width: 400px;
  background: transparent;
  position: relative;
}

.workspace-topbar{
  height: var(--topbar-height);
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-light);
  z-index: 10;
  flex-shrink: 0;
  border-radius: 0;
}

.brand{ display:flex; align-items:center; gap:8px; }
.logo{
  width: 28px;
  height: 28px;
  border-radius: var(--radius-md);
  background: rgba(10,132,255,.14);
  color: var(--accent-primary);
  display:flex;
  align-items:center;
  justify-content:center;
}
.logo svg{ width: 18px; height: 18px; }

.title-wrapper{ display:flex; align-items:center; gap:4px; cursor:pointer; }
.title{
  font-weight: 600;
  font-size: 14px;
  padding: 6px 10px;
  border-radius: 12px;
  outline:none;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  color: var(--text-primary);
  background: transparent;
}
.title:hover{ background: rgba(255,255,255,.22); }
@media (prefers-color-scheme: dark){
  .title:hover{ background: rgba(255,255,255,.08); }
}
.title:focus{
  background: rgba(255,255,255,.18);
  border-color: rgba(10,132,255,.35);
  box-shadow: 0 0 0 4px rgba(10,132,255,.14);
}

.topbar-actions{ display:flex; align-items:center; gap:8px; }
.quick-links{ display:flex; gap:8px; margin-right: 16px; }

.quick-link{
  padding: 6px 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--glass-border);
  background: rgba(255,255,255,.44);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-decoration:none;
  display:flex;
  align-items:center;
  gap: 6px;
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  box-shadow: 0 10px 26px rgba(0,0,0,.08);
  transition: transform .15s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.quick-link:hover{
  background: rgba(255,255,255,.62);
  border-color: rgba(255,255,255,.70);
  box-shadow: 0 16px 42px rgba(0,0,0,.12);
  transform: translateY(-1px);
}
.quick-link:active{ transform: translateY(0) scale(.98); }

.zoom-controls{
  display:flex;
  align-items:center;
  gap: 2px;
  padding: 6px 8px;
  background: rgba(255,255,255,.28);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-full);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}
.zoom-btn{
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 16px;
  font-weight: 700;
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  transition: transform .15s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease;
  touch-action: manipulation;
}
.zoom-btn:hover{
  background: var(--glass-bg-weak);
  border-color: var(--glass-border);
  box-shadow: 0 6px 18px rgba(0,0,0,.08);
  transform: translateY(-1px);
  color: var(--text-primary);
}
.zoom-btn:active{ transform: translateY(0) scale(.98); }
.zoom-label{
  min-width: 44px;
  text-align:center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
}

.workspace-body{ flex:1; position:relative; overflow:hidden; }
.canvas-host{ width:100%; height:100%; position:relative; background: transparent; }
.stage{ width:100%; height:100%; display:block; cursor: default; }
.stage.grabbing{ cursor: grabbing; }

.empty-hint{
  position:absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%);
  text-align:center;
  pointer-events:none;
  opacity:.75;
}
.empty-hint.hidden{ display:none; }
.empty-icon{ margin-bottom: 16px; color: var(--text-tertiary); }
.empty-title{
  font-size: 18px;
  font-weight: 800;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.empty-desc{ font-size: 13px; color: var(--text-tertiary); }

/* =========================================================
   Right Panel
   ========================================================= */
.sidepanel{
  width: var(--panel-width);
  max-width: 50vw;
  border-left: 1px solid var(--border-light);
  display:flex;
  flex-direction:column;
  z-index: 100;
  flex-shrink:0;
  border-radius: 0;
}

.panel-header{
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
}

.panel-actions-top{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap: 6px;
}

.panel-action-btn{
  width: 34px;
  height: 34px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-tertiary);
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  transition: transform .15s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease, color .18s ease;
  touch-action: manipulation;
}
/* =========================
   ✅ Open Canvas 强调样式
   - 只在“默认对话模式”提示用户：这是打开画板
   - 进入 panel-collapsed 后就不再呼吸提示，避免打扰
   ========================= */

@keyframes canvasCtaPulse{
  0%,100% { transform: translateY(0) scale(1); box-shadow: var(--canvas-cta-shadow); }
  50%     { transform: translateY(-1px) scale(1.03); box-shadow: 0 20px 60px rgba(10,132,255,.28); }
}

/* 默认（非 collapsed）：强调 */
body:not(.panel-collapsed) .panel-action-btn--open{
  border-color: var(--canvas-cta-border);
  background: var(--canvas-cta-bg);
  color: var(--canvas-cta);
  box-shadow: var(--canvas-cta-shadow);
  animation: canvasCtaPulse 1.8s ease-in-out infinite;
}

/* hover：更明显 */
body:not(.panel-collapsed) .panel-action-btn--open:hover{
  background: rgba(10,132,255,.16);
  border-color: rgba(10,132,255,.75);
}

/* 角标点：提示“这里可打开画板” */
body:not(.panel-collapsed) .panel-action-btn--open::after{
  content:"";
  position:absolute;
  right: 7px;
  top: 7px;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--canvas-cta-dot);
  box-shadow: 0 0 0 3px var(--canvas-cta-ring);
}

/* 进入画板模式：回归正常（或你也可以让它 is-active） */
body.panel-collapsed .panel-action-btn--open{
  animation: none;
}
body.panel-collapsed .panel-action-btn--open::after{
  display:none;
}

.panel-action-btn:hover{
  background: var(--glass-bg-weak);
  border-color: var(--glass-border);
  color: var(--text-primary);
  box-shadow: 0 6px 18px rgba(0,0,0,.08);
  transform: translateY(-1px);
}
.panel-action-btn.is-active{
  background: rgba(10,132,255,.14);
  border-color: rgba(10,132,255,.28);
  color: var(--accent-primary);
  box-shadow: 0 10px 26px rgba(10,132,255,.10);
}
.panel-action-btn:active{ transform: translateY(0) scale(.98); }

.panel-content{
  flex:1;
  overflow-y:auto;
  padding: 18px;
}

/* AI welcome */
.ai-welcome{ display:flex; gap: 12px; margin-bottom: 20px; }
.ai-avatar{
  width: 48px;
  height: 48px;
  border-radius: 9999px;
  background-image: url("https://img.moki.wang/happy.png");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.ai-intro{ flex:1; }
.ai-title{
  font-size: 18px;
  font-weight: 900;
  margin-bottom: 2px;
  color: var(--text-primary);
}
.ai-subtitle{ font-size: 13px; color: var(--text-secondary); }

/* Templates */
.templates-section{ margin-bottom: 20px; }

.template-card{
  display:flex;
  align-items:center;
  gap: 12px;
  padding: 12px;
  background: rgba(255,255,255,.46);
  border-radius: 18px;
  margin-bottom: 10px;
  cursor:pointer;
  transition: transform .15s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease;
  border: 1px solid var(--glass-border);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  box-shadow: 0 10px 26px rgba(0,0,0,.08);
}
@media (prefers-color-scheme: dark){
  .template-card{ background: rgba(20,24,31,.45); }
}
.template-card:hover{
  background: rgba(255,255,255,.58);
  border-color: rgba(255,255,255,.70);
  box-shadow: 0 16px 42px rgba(0,0,0,.12);
  transform: translateY(-1px);
}
@media (prefers-color-scheme: dark){
  .template-card:hover{ background: rgba(20,24,31,.62); }
}

.template-info{ flex:1; min-width:0; }
.template-title{
  font-weight: 800;
  font-size: 14px;
  margin-bottom: 2px;
  color: var(--text-primary);
}
.template-desc{
  font-size: 12px;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow:hidden;
  text-overflow: ellipsis;
}
.template-thumb{
  width: 80px;
  height: 56px;
  border-radius: 14px;
  display:flex;
  align-items:center;
  justify-content:center;
  flex-shrink:0;
  overflow:hidden;
  background: rgba(255,255,255,.22);
  border: 1px solid var(--glass-border);
}
@media (prefers-color-scheme: dark){
  .template-thumb{ background: rgba(255,255,255,.06); }
}

.templates-toggle{
  display:flex;
  align-items:center;
  justify-content:center;
  gap: 6px;
  width: 100%;
  padding: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-tertiary);
  font-size: 12px;
  cursor:pointer;
  border-radius: 14px;
  transition: background .15s, border-color .15s;
  touch-action: manipulation;
}
.templates-toggle:hover{
  background: rgba(255,255,255,.22);
  border-color: var(--glass-border);
  color: var(--text-secondary);
}
@media (prefers-color-scheme: dark){
  .templates-toggle:hover{ background: rgba(255,255,255,.06); }
}

/* Chat area */
.chat-area{ flex:1; min-height: 100px; }
.chat-messages{
  display:flex;
  flex-direction:column;
  gap: 16px;
  max-height: none;
  overflow: visible;
}

/* 兼容你两套 DOM：.msg-* 以及 .chat-* */
.chat-message{ display:flex; gap: 10px; align-items:flex-start; }
.chat-message.user{ flex-direction: row-reverse; }

.msg-avatar,
.chat-avatar{
  width: 32px;
  height: 32px;
  border-radius: 14px;
  background: rgba(255,255,255,.28);
  border: 1px solid var(--glass-border);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  color: var(--text-primary);
  display:flex;
  align-items:center;
  justify-content:center;
  flex-shrink:0;
  font-size: 12px;
}
.msg-avatar.ai{ background: rgba(10,132,255,.22); }
.chat-message.user .msg-avatar{ background: rgba(52,199,89,.18); }

/* 气泡：iMessage / visionOS */
.msg-content,
.chat-content{
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 18px;
  background: rgba(255,255,255,.46);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 10px 26px rgba(0,0,0,.08);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-primary);
}
@media (prefers-color-scheme: dark){
  .msg-content,
  .chat-content{ background: rgba(20,24,31,.45); }
}

/* 用户气泡 */
.chat-message.user .msg-content,
.chat-message.user .chat-content{
  background: linear-gradient(180deg, rgba(10,132,255,.92), rgba(10,132,255,.74));
  border-color: rgba(255,255,255,.35);
  color: rgba(255,255,255,.96);
  box-shadow: 0 14px 36px rgba(10,132,255,.22);
}

/* chat-content 内 p / media */
.chat-content p{ white-space: pre-wrap; }
.chat-media{ margin-top: 10px; }
.chat-media-caption{ font-size: 12px; color: var(--text-tertiary); margin-bottom: 6px; }
.chat-content img,
.chat-content video{
  max-width: 100%;
  border-radius: 0;
  display:block;
}

/* Files section */
.files-section{
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
  display: none;
}
.files-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom: 12px;
}
.files-title{ font-weight: 800; font-size: 13px; }

.files-clear{
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-tertiary);
  font-size: 12px;
  cursor:pointer;
  padding: 6px 10px;
  border-radius: 999px;
  transition: background .15s, border-color .15s;
  touch-action: manipulation;
}
.files-clear:hover{
  background: rgba(255,255,255,.22);
  border-color: var(--glass-border);
  color: var(--text-secondary);
}
@media (prefers-color-scheme: dark){
  .files-clear:hover{ background: rgba(255,255,255,.06); }
}

.files-list{ display:flex; flex-direction:column; gap: 10px; }

.file-card{
  background: rgba(255,255,255,.46);
  border-radius: 18px;
  overflow:hidden;
  border: 1px solid var(--glass-border);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  box-shadow: 0 10px 26px rgba(0,0,0,.08);
}
@media (prefers-color-scheme: dark){
  .file-card{ background: rgba(20,24,31,.45); }
}
.file-thumb{
  width:100%;
  height:auto;
  object-fit: contain;
  display:block;
  background: transparent;
}
.file-thumb-video{
  width:100%;
  height:auto;
  background: transparent;
  display:block;
}

.file-info{ padding: 10px 12px; }
.file-name{
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 8px;
  word-break: break-all;
}
.file-actions{ display:flex; flex-wrap:wrap; gap: 8px; }

.file-action-btn{
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: rgba(255,255,255,.44);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 700;
  cursor:pointer;
  text-decoration:none;
  display:inline-flex;
  align-items:center;
  gap: 6px;
  box-shadow: 0 10px 26px rgba(0,0,0,.08);
  transition: transform .15s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease;
  touch-action: manipulation;
}
.file-action-btn:hover{
  background: rgba(255,255,255,.62);
  border-color: rgba(255,255,255,.70);
  box-shadow: 0 16px 42px rgba(0,0,0,.12);
  transform: translateY(-1px);
}
.file-action-btn:active{ transform: translateY(0) scale(.98); }

.file-action-btn.nowm{
  color: #34c759;
  border-color: rgba(52,199,89,.45);
}
.file-action-btn.hd{
  color: #af52de;
  border-color: rgba(175,82,222,.45);
}
.file-action-btn.canvas{
  color: #ff9f0a;
  border-color: rgba(255,159,10,.45);
}

/* Footer input */
.panel-footer{
  padding: 12px;
  border-top: 1px solid var(--border-light);
  background: transparent;
}

.input-wrapper{
  background: rgba(255,255,255,.52);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  border-radius: 22px;
  padding: 12px 14px;
  border: 1px solid var(--glass-border);
  box-shadow: 0 10px 26px rgba(0,0,0,.08);
  transition: box-shadow .18s, border-color .18s, background .18s;
}
@media (prefers-color-scheme: dark){
  .input-wrapper{ background: rgba(20,24,31,.55); }
}
.input-wrapper:focus-within{
  border-color: rgba(10,132,255,.35);
  box-shadow: 0 0 0 4px rgba(10,132,255,.14), 0 18px 60px rgba(0,0,0,.12);
}

.message-input{
  width:100%;
  border:none;
  background: transparent;
  font-size: 14px;
  line-height: 1.5;
  resize:none;
  outline:none;
  font-family: inherit;
  color: var(--text-primary);
  min-height: 24px;
  max-height: 260px;
}
.message-input::placeholder{ color: var(--text-tertiary); }

.input-actions{
  display:flex;
  align-items:center;
  gap: 8px;
  margin-top: 10px;
}

.input-action-btn{
  width: 34px;
  height: 34px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-tertiary);
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  transition: transform .15s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease, color .18s ease;
  touch-action: manipulation;
}
.input-action-btn:hover{
  background: var(--glass-bg-weak);
  border-color: var(--glass-border);
  color: var(--text-primary);
  box-shadow: 0 6px 18px rgba(0,0,0,.08);
  transform: translateY(-1px);
}
.input-action-btn:active{ transform: translateY(0) scale(.98); }

.agent-badge{
  display:inline-flex;
  align-items:center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  background: rgba(255,255,255,.28);
  border: 1px solid var(--glass-border);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  color: var(--accent-primary);
  font-size: 12px;
  font-weight: 800;
}

.send-btn{
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border:none;
  background: linear-gradient(180deg, rgba(10,132,255,1), rgba(10,132,255,.80));
  color: var(--text-inverse);
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  transition: transform .15s ease, filter .18s ease, box-shadow .18s ease;
  box-shadow: 0 16px 44px rgba(10,132,255,.22);
  touch-action: manipulation;
}
.send-btn:hover{
  filter: brightness(1.02);
  transform: translateY(-1px);
  box-shadow: 0 20px 60px rgba(10,132,255,.26);
}
.send-btn:active{ transform: translateY(0) scale(.98); }
.send-btn:disabled{
  background: rgba(120,120,130,.35);
  cursor:not-allowed;
  transform:none;
  box-shadow: none;
}

/* =========================================================
   Agent Mode Dropdown
   ========================================================= */
.agent-mode{
  position: relative;
  display:inline-flex;
  align-items:center;
}

.agent-mode-btn{ cursor:pointer; gap: 6px; }
.agent-mode-caret{ margin-left: 2px; font-size: 11px; opacity: .75; }

.agent-mode-menu{
  position:absolute;
  right: 0;
  bottom: calc(100% + 8px);
  min-width: 160px;
  border-radius: 18px;
  padding: 6px;
  display:none;
  z-index: 9999;
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow-2);
}
.agent-mode-menu.show{ display:block; }

.agent-mode-item{
  width:100%;
  border:none;
  background: transparent;
  text-align:left;
  padding: 10px 10px;
  border-radius: 14px;
  cursor:pointer;
  color: var(--text-primary);
  font-size: 13px;
  transition: background .15s, transform .15s;
  touch-action: manipulation;
}
.agent-mode-item:hover{
  background: rgba(255,255,255,.40);
  transform: translateY(-1px);
}
@media (prefers-color-scheme: dark){
  .agent-mode-item:hover{ background: rgba(255,255,255,.10); }
}
.agent-mode-item.active{
  background: rgba(10,132,255,.14);
  color: var(--accent-primary);
}

/* =========================================================
   Drawer (history / files)
   ========================================================= */
.agent-drawer{
  position: fixed;
  top: 58px;
  right: 12px;
  width: min(380px, calc(100vw - 24px));
  max-height: calc(100dvh - 70px);
  border-radius: 18px;
  z-index: 30000;
  overflow:hidden;
  display:flex;
  flex-direction:column;
}

.agent-drawer-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
}
.agent-drawer-title{
  font-weight: 900;
  font-size: 13px;
  color: var(--text-primary);
}
.agent-drawer-close{
  width: 30px;
  height: 30px;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  background: rgba(255,255,255,.28);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  cursor:pointer;
  transition: transform .15s, background .15s;
  touch-action: manipulation;
}
.agent-drawer-close:hover{
  background: rgba(255,255,255,.42);
  transform: translateY(-1px);
}
.agent-drawer-close:active{ transform: translateY(0) scale(.98); }

.agent-drawer-body{
  padding: 12px;
  overflow:auto;
  -webkit-overflow-scrolling: touch;
}

.drawer-list{ display:flex; flex-direction:column; gap: 10px; }

.drawer-item{
  border: 1px solid var(--glass-border);
  background: rgba(255,255,255,.46);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border-radius: 16px;
  padding: 10px 12px;
  box-shadow: 0 10px 26px rgba(0,0,0,.08);
}
@media (prefers-color-scheme: dark){
  .drawer-item{ background: rgba(20,24,31,.45); }
}
.drawer-item-title{
  font-size: 12px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.drawer-item-sub{
  font-size: 12px;
  color: var(--text-secondary);
  word-break: break-all;
}
.drawer-actions{
  display:flex;
  gap: 8px;
  margin-top: 10px;
  justify-content:flex-end;
  flex-wrap: wrap;
}

.drawer-btn{
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: rgba(255,255,255,.44);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  cursor:pointer;
  font-size: 12px;
  font-weight: 800;
  color: var(--text-primary);
  box-shadow: 0 10px 26px rgba(0,0,0,.08);
  transition: transform .15s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease;
  touch-action: manipulation;
}
.drawer-btn:hover{
  background: rgba(255,255,255,.62);
  border-color: rgba(255,255,255,.70);
  box-shadow: 0 16px 42px rgba(0,0,0,.12);
  transform: translateY(-1px);
}
.drawer-btn:active{ transform: translateY(0) scale(.98); }

.drawer-item-media{ margin-top: 10px; }
.drawer-item-media img,
.drawer-item-media video{
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: 260px;
  border-radius: 0;
  object-fit: contain;
  display:block;
  background: transparent;
}

/* =========================================================
   Attachments preview (拖拽/粘贴缩略图)
   ========================================================= */
#attachmentsPreview{
  display:none;
  margin-top: 10px;
}
#attachmentsList{
  display:flex;
  gap: 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 6px;
  -webkit-overflow-scrolling: touch;
}
.attachment-item{
  position: relative;
  width: 80px;
  height: 80px;
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  overflow:hidden;
  background: rgba(255,255,255,.22);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  flex: 0 0 auto;
}
@media (prefers-color-scheme: dark){
  .attachment-item{ background: rgba(255,255,255,.06); }
}
.attachment-item img{
  width:100%;
  height:100%;
  object-fit: contain;
  display:block;
  border-radius: 0;
}
.attachment-remove{
  position:absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.55);
  background: rgba(17,24,39,.72);
  color: #fff;
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  line-height: 1;
  font-size: 16px;
  padding:0;
  z-index: 2;
  touch-action: manipulation;
}
.attachment-remove:active{ transform: scale(.96); }

/* =========================================================
   Settings button + panel (你说很丑的那个)
   ========================================================= */
.agent-settings-btn{
  width: 36px;
  height: 36px;
  border-radius: 14px;
  border: 1px solid var(--glass-border);
  background: rgba(255,255,255,.44);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  box-shadow: 0 10px 26px rgba(0,0,0,.10);
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  margin-right: 8px;
  flex: 0 0 auto;
  touch-action: manipulation;
  transition: transform .15s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease;
  color: var(--text-primary);
}
.agent-settings-btn:hover{
  background: rgba(255,255,255,.62);
  border-color: rgba(255,255,255,.70);
  transform: translateY(-1px);
}
.agent-settings-btn:active{ transform: translateY(0) scale(.98); }
.agent-settings-btn svg{ width: 18px; height: 18px; }

.agent-settings-panel{
  position: fixed;
  width: 320px;
  border-radius: 18px;
  padding: 12px;
  z-index: 20000;
  display:none;
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow-2);
}
.agent-settings-title{ font-weight: 900; margin-bottom: 10px; color: var(--text-primary); }

.agent-settings-item{
  display:flex;
  gap: 10px;
  align-items:flex-start;
  padding: 10px 10px;
  border-radius: 16px;
  cursor:pointer;
  user-select:none;
  touch-action: manipulation;
  background: rgba(255,255,255,.30);
  border: 1px solid rgba(255,255,255,.35);
}
.agent-settings-item:hover{ background: rgba(255,255,255,.42); }
@media (prefers-color-scheme: dark){
  .agent-settings-item{
    background: rgba(255,255,255,.06);
    border-color: rgba(255,255,255,.12);
  }
  .agent-settings-item:hover{ background: rgba(255,255,255,.10); }
}
.agent-settings-item input{ margin-top: 2px; }

.agent-settings-actions{
  display:flex;
  gap: 8px;
  justify-content:flex-end;
  margin-top: 10px;
}
.agent-settings-actions button{
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: rgba(255,255,255,.44);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  cursor:pointer;
  font-weight: 800;
  color: var(--text-primary);
  touch-action: manipulation;
  transition: transform .15s, background .15s, box-shadow .15s;
  box-shadow: 0 10px 26px rgba(0,0,0,.08);
}
.agent-settings-actions button:hover{
  background: rgba(255,255,255,.62);
  transform: translateY(-1px);
  box-shadow: 0 16px 42px rgba(0,0,0,.12);
}
.agent-settings-actions button:active{ transform: translateY(0) scale(.98); }

/* dropover outline */
.sidepanel.is-dropover{
  outline: 2px dashed rgba(10,132,255,.75);
  outline-offset: -6px;
}

/* =========================================================
   Collapse: only canvas (hide sidepanel)
   ========================================================= */
body.panel-collapsed .sidepanel{ display:none !important; }

.panel-back-btn{
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 40000;
  display:none;
  align-items:center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 999px;
  cursor:pointer;
  font-size: 13px;
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow-2);
  -webkit-backdrop-filter: blur(var(--glass-blur-strong));
  backdrop-filter: blur(var(--glass-blur-strong));
  touch-action: manipulation;
}
.panel-back-btn:hover{ transform: translateY(-1px); }
.panel-back-btn:active{ transform: translateY(0) scale(.98); }
body.panel-collapsed .panel-back-btn{ display:inline-flex; }

/* =========================================================
   Scrollbar
   ========================================================= */
::-webkit-scrollbar{ width: 6px; height: 6px; }
::-webkit-scrollbar-track{ background: transparent; }
::-webkit-scrollbar-thumb{
  background: rgba(17,24,39,.18);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover{ background: rgba(17,24,39,.28); }
@media (prefers-color-scheme: dark){
  ::-webkit-scrollbar-thumb{ background: rgba(255,255,255,.18); }
  ::-webkit-scrollbar-thumb:hover{ background: rgba(255,255,255,.28); }
}

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 900px){
  .sidepanel{ width: 320px; max-width:none; }
  .quick-links{ display:none; }
}

/* =========================================================
   Mobile (<=700px) FINAL
   默认：只对话（sidepanel 全屏）
   收缩：只画布（workspace 全屏 + 底部工具栏）
   ========================================================= */
@media (max-width: 700px){
  :root{ --mobile-toolbar-h: 56px; }

  .app{ height: 100dvh; flex-direction: column; }

  /* 默认：画布与左侧工具栏隐藏（只看对话） */
  .workspace{ display:none !important; }
  .toolbar-left{ display:none !important; }

  /* sidepanel 全屏固定 */
  .sidepanel{
    position: fixed !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100dvh !important;
    max-width: none !important;

    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;

    transform: none !important;
    transition: none !important;

    z-index: 10050 !important;

    display:flex !important;
    flex-direction:column !important;
    background: var(--glass-bg-strong) !important;
    -webkit-backdrop-filter: blur(var(--glass-blur-strong)) !important;
    backdrop-filter: blur(var(--glass-blur-strong)) !important;
  }

  /* 手机端：只让消息区滚动，避免输入框被顶走 */
  .panel-content{
    overflow: hidden !important;
    flex: 1 !important;
    min-height: 0 !important;
    padding: 12px !important;
  }
  .chat-area{ flex: 1 !important; min-height: 0 !important; }
  .chat-messages{
    height: 100% !important;
    overflow: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  textarea, input, button{ font-size: 16px !important; }

  /* 画布本体禁手势滚动（只针对 canvas），不影响 dropdown */
  #stage{ touch-action: none; }

  /* 收缩：显示画布 + 底部工具栏贴底 */
  body.panel-collapsed .sidepanel{ display:none !important; }

  body.panel-collapsed .workspace{
    display:flex !important;
    position: fixed !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100dvh !important;
    min-width: 0 !important;
    background: transparent !important;

    /* ✅ 关键：把画布层级压低，避免遮住二级菜单 */
    z-index: 1000 !important;

    padding-bottom: calc(var(--mobile-toolbar-h) + env(safe-area-inset-bottom)) !important;
  }

  /* ✅ 进一步兜底：stage/canvas 不要自带更高 z-index 覆盖浮层 */
  body.panel-collapsed .workspace-body,
  body.panel-collapsed .canvas-host,
  body.panel-collapsed .stage,
  body.panel-collapsed #stage{
    position: relative !important;
    z-index: 0 !important;
  }

  body.panel-collapsed .toolbar-left{
    display:flex !important;
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: env(safe-area-inset-bottom) !important;
    height: var(--mobile-toolbar-h) !important;
    width: 100% !important;

    /* ✅ 关键：工具栏比画布高很多 */
    z-index: 900000 !important;

    flex-direction: row !important;
    align-items: center !important;

    overflow-x: auto !important;
    overflow-y: visible !important;

    border-right: none !important;
    border-top: 1px solid var(--glass-border) !important;

    padding: 6px 8px !important;
    gap: 8px !important;

    -webkit-overflow-scrolling: touch !important;

    background: var(--glass-bg-strong) !important;
    -webkit-backdrop-filter: blur(var(--glass-blur-strong)) !important;
    backdrop-filter: blur(var(--glass-blur-strong)) !important;
    box-shadow: 0 -10px 40px rgba(0,0,0,.10) !important;
  }

  body.panel-collapsed .toolbar-group{
    flex-direction: row !important;
    gap: 8px !important;
  }

  body.panel-collapsed .toolbar-divider{
    width: 1px !important;
    height: 26px !important;
    margin: 0 8px !important;
  }

  body.panel-collapsed .toolbar-spacer{ display:none !important; }
  body.panel-collapsed .toolbar-bottom{ display:none !important; }

  /* ✅ 手机端 dropdown 二级菜单：固定到 viewport 顶层，强制盖过画布 */
  body.panel-collapsed .tool-dropdown{ position: relative !important; }

  body.panel-collapsed .tool-dropdown .dropdown-menu{
    position: fixed !important;

    left: 12px !important;
    right: 12px !important;
    bottom: calc(var(--mobile-toolbar-h) + env(safe-area-inset-bottom) + 10px) !important;
    top: auto !important;

    margin-left: 0 !important;
    min-width: 0 !important;
    width: auto !important;

    /* ✅ 关键：比 toolbar 还高，彻底避免被画布盖住 */
    z-index: 900100 !important;

    max-height: min(60vh, 520px) !important;
    overflow: auto !important;
    -webkit-overflow-scrolling: touch !important;

    touch-action: pan-y !important;

    /* ✅ iOS/部分安卓：用 3d transform 让 fixed/层叠更稳定 */
    transform: translate3d(0, 8px, 0) !important;
    opacity: 0 !important;
    display: none !important;
    will-change: transform, opacity !important;

    background: var(--glass-bg-strong) !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: 18px !important;
    box-shadow: var(--glass-shadow-2) !important;

    /* ✅ 防止被任何父容器“裁剪”（某些机型/浏览器会这样） */
    clip-path: inset(0 round 18px) !important;
  }

  body.panel-collapsed .tool-dropdown .dropdown-menu.show{
    display:block !important;
    opacity:1 !important;
    transform: translate3d(0, 0, 0) !important;
  }

  body.panel-collapsed .dropdown-menu,
  body.panel-collapsed .dropdown-menu *{ pointer-events: auto !important; }

  body.panel-collapsed .dropdown-menu input,
  body.panel-collapsed .dropdown-menu button,
  body.panel-collapsed .dropdown-menu select{ touch-action: manipulation !important; }

  body.panel-collapsed .dropdown-menu input[type="range"]{ touch-action: pan-y !important; }

  body.panel-collapsed .dropdown-menu{
    -webkit-user-select: none !important;
    user-select: none !important;
  }

  /* Drawer 全屏 */
  .agent-drawer{
    top: 0 !important;
    right: 0 !important;
    left: 0 !important;
    width: 100% !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
  }

  .panel-back-btn{
    top: 10px !important;
    right: 10px !important;
  }
}

/* 额外兜底：浮动工具栏（文字/图片）永远在最上层，可点击 */
.text-edit-toolbar,
.image-edit-toolbar{
  z-index: 65000 !important;
  pointer-events: auto !important;
}
