/* 编辑器 / 画布 宽屏外框（参照 ASCII Magic：顶栏 + 左侧导航功能面板 + 中间画面 + 右侧参数面板，面板贴边停靠）。
   只在 ≥1101px 生效；更窄时沿用原来的浮动工具栏布局（styles.css 里编辑器的 max-width:1100px 规则）。
   结构在 ascii-editor.html 的 .app-topbar / .app-sidebar，交互在 shell.js。 */

.app-topbar,
.app-sidebar {
  display: none;
}

.app-topbar,
.app-sidebar,
.flow-help-corner,
.app-guide {
  --shell-bg: #ffffff;
  --shell-line: #f0f0f1;
  --shell-text: #27272a;
  --shell-text-2: #52525b;
  --shell-text-3: #a1a1aa;
  --shell-hover: #f4f4f5;
  --shell-active: #27272a;
  --shell-on-active: #ffffff;
  --shell-thumb: #e4e4e7;
  --shell-thumb-hover: #d4d4d8;
  font-family: "Geist", "IBM Plex Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

html[data-color-scheme="dark"] .app-topbar,
html[data-color-scheme="dark"] .app-sidebar,
html[data-color-scheme="dark"] .flow-help-corner,
html[data-color-scheme="dark"] .app-guide {
  --shell-bg: #111113;
  --shell-line: #232326;
  --shell-text: #f4f4f5;
  --shell-text-2: #a1a1aa;
  --shell-text-3: #71717a;
  --shell-hover: #232326;
  --shell-active: #f4f4f5;
  --shell-on-active: #18181b;
  --shell-thumb: #2e2e33;
  --shell-thumb-hover: #3f3f46;
}

@media (min-width: 1101px) {
  :root {
    --shell-top: 56px;
    --shell-left: 256px;
    --shell-right: 336px;
  }

  /* ——— 顶栏 ——— */
  .app-topbar {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    z-index: 35;
    display: flex;
    height: var(--shell-top);
    align-items: center;
    gap: 16px;
    padding: 0 12px 0 20px;
    border-bottom: 1px solid var(--shell-line);
    background: var(--shell-bg);
  }

  .app-brand {
    display: inline-flex;
    width: calc(var(--shell-left) - 36px);
    align-items: center;
    gap: 10px;
    color: var(--shell-text);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
    text-decoration: none;
  }

  /* 网站导航同款 Logo（assets/figma/logo-*.svg），深色模式换白字版 */
  .app-brand-logo {
    display: block;
    width: 116px;
    height: 28px;
    object-fit: contain;
  }

  html[data-color-scheme="dark"] .app-brand-logo {
    content: url("../figma/logo-dark.svg?v=20261119-logo4");
  }

  /* 模式切换：放在顶栏左侧、紧跟左侧面板之后（shell.js 挪进来），编辑器和画布下同一位置；
     画布的「文件 / 撤销重做 / 保存状态」排在它右边，中间一根竖线隔开 */
  .app-topbar .mode-switch.is-in-topbar {
    position: static;
    flex: none;
    margin-left: 12px;
    transform: none;
  }

  .app-topbar .mode-switch.is-in-topbar + .app-topbar-canvas-left {
    margin-left: -6px;
  }

  .app-topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
  }

  /* 关闭：和外观开关一样带一圈描边，更容易看到 */
  .app-topbar-close {
    display: grid;
    width: 36px;
    height: 36px;
    place-items: center;
    border: 1px solid var(--shell-line);
    border-radius: 10px;
    transition: background-color 0.15s ease, border-color 0.15s ease;
  }

  .app-topbar-close:hover,
  .app-topbar-close:focus-visible {
    border-color: var(--shell-thumb-hover);
  }

  html[data-color-scheme="dark"] .app-topbar-close {
    border-color: #2e2e33;
  }

  .app-topbar-close:hover,
  .app-topbar-close:focus-visible {
    background: var(--shell-hover);
    outline: none;
  }

  .app-topbar-close img {
    width: 16px;
    height: 16px;
  }

  html[data-color-scheme="dark"] .app-topbar-close img {
    filter: invert(1) brightness(0.8);
  }

  /* 主题开关：浅色 / 深色 / 跟随系统（和官网导航同一组 Iconly 图标） */
  .theme-switch {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    border: 1px solid var(--shell-line);
    border-radius: 10px;
  }

  .theme-switch button {
    display: grid;
    width: 30px;
    height: 28px;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--shell-text-3);
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
  }

  .theme-switch button:hover {
    color: var(--shell-text);
  }

  .theme-switch button.is-active {
    background: var(--shell-hover);
    color: var(--shell-text);
  }

  .theme-switch button:focus-visible {
    outline: 2px solid var(--shell-active);
    outline-offset: 1px;
  }

  .theme-icon {
    width: 15px;
    height: 15px;
    background-color: currentColor;
    -webkit-mask: center / contain no-repeat;
    mask: center / contain no-repeat;
  }

  .theme-icon.is-sun {
    -webkit-mask-image: url("../icons/iconly/sun.svg");
    mask-image: url("../icons/iconly/sun.svg");
  }

  .theme-icon.is-moon {
    -webkit-mask-image: url("../icons/iconly/moon.svg");
    mask-image: url("../icons/iconly/moon.svg");
  }

  .theme-icon.is-monitor {
    -webkit-mask-image: url("../icons/iconly/monitor.svg");
    mask-image: url("../icons/iconly/monitor.svg");
  }

  /* 画布在顶栏里的两组按钮（canvas.js 宽屏时挂进来）：左边从左侧面板右边线开始（文件菜单 / 撤销重做 / 保存状态），右边是模型服务 */
  .app-topbar-canvas,
  .app-topbar-canvas-left {
    display: none;
  }

  html[data-app-mode="canvas"] .app-topbar-canvas-left {
    display: flex;
    align-items: center;
  }

  .app-topbar .flow-topbar-start {
    gap: 2px;
    padding: 0;
  }

  .app-topbar .flow-file-menu {
    width: auto;
    height: 32px;
    padding: 0 8px 0 10px;
    border-color: transparent;
    background: transparent;
    font-size: 13px;
    font-weight: 500;
  }

  .app-topbar .flow-file-menu:hover,
  .app-topbar .flow-file-menu.is-open {
    border-color: transparent;
    background: var(--shell-hover);
  }

  .app-topbar .flow-file-menu.is-placeholder .flow-dd-text-value {
    color: var(--shell-text);
  }

  .app-topbar .flow-topbar-start .flow-divider {
    height: 16px;
    margin: 0 6px;
  }

  /* 「文件」左边的竖线：落在左侧面板右边线的位置，和后面两根同样式 */
  .app-topbar .flow-topbar-start .flow-file-divider {
    margin: 0 6px 0 0;
  }

  html[data-app-mode="canvas"] .app-topbar-canvas {
    display: flex;
    align-items: center;
  }

  .app-topbar .flow-topbar {
    position: static;
    display: contents;
  }

  .app-topbar .flow-topbar-group {
    position: static;
    height: 36px;
    padding: 0 2px;
    border: 0;
    background: transparent;
  }

  /* 顶栏已有问号菜单，画布自己的快捷键按钮在宽屏收起 */
  .app-topbar .flow-help-button {
    display: none;
  }

  .app-topbar .flow-topbar-end .flow-divider {
    margin: 0 6px;
  }

  .app-topbar .flow-topbar-end {
    padding-right: 4px;
  }

  /* ——— 顶栏按钮 + 问号菜单 ——— */
  .app-icon-button {
    display: grid;
    width: 36px;
    height: 36px;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--shell-text-2);
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
  }

  .app-icon-button:hover,
  .app-help.is-open .app-icon-button {
    background: var(--shell-hover);
    color: var(--shell-text);
  }

  .app-icon-button:focus-visible {
    outline: 2px solid var(--shell-active);
    outline-offset: 1px;
  }

  .app-icon-button .theme-icon {
    width: 17px;
    height: 17px;
  }

  .theme-icon.is-question {
    -webkit-mask-image: url("../icons/iconly/canvas/question.svg");
    mask-image: url("../icons/iconly/canvas/question.svg");
  }

  .app-help {
    position: relative;
  }

  /* 菜单和按钮之间留一段透明的「桥」（padding-top），鼠标移过去不会断开悬停 */
  .app-help-menu {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 5;
    display: grid;
    min-width: 148px;
    padding: 6px;
    border: 1px solid var(--shell-line);
    border-radius: 10px;
    background: var(--shell-bg);
    box-shadow: 0 12px 32px rgba(24, 24, 27, 0.12);
    opacity: 0;
    visibility: hidden;
    transform: translateY(4px);
    transition: opacity 0.14s ease, transform 0.16s cubic-bezier(0.2, 0, 0, 1), visibility 0s linear 0.16s;
  }

  .app-help-menu::before {
    position: absolute;
    right: 0;
    bottom: 100%;
    left: 0;
    height: 8px;
    content: "";
  }

  .app-help.is-open .app-help-menu {
    top: calc(100% + 6px);
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: opacity 0.14s ease, transform 0.16s cubic-bezier(0.2, 0, 0, 1), visibility 0s;
  }

  .app-help-menu a,
  .app-help-menu button {
    display: flex;
    height: 34px;
    align-items: center;
    padding: 0 10px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--shell-text-2);
    font: inherit;
    font-size: 13px;
    text-align: start;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
  }

  .app-help-menu a:hover,
  .app-help-menu button:hover,
  .app-help-menu a:focus-visible,
  .app-help-menu button:focus-visible {
    background: var(--shell-hover);
    color: var(--shell-text);
    outline: none;
  }

  html[data-app-mode="canvas"] .app-help-menu [data-only-mode="editor"],
  html:not([data-app-mode="canvas"]) .app-help-menu [data-only-mode="canvas"] {
    display: none;
  }

  html[data-color-scheme="dark"] .app-help-menu {
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  }

  /* ——— 左侧导航面板 ——— */
  .app-sidebar {
    position: fixed;
    top: var(--shell-top);
    bottom: 0;
    left: 0;
    z-index: 30;
    display: flex;
    width: var(--shell-left);
    flex-direction: column;
    border-right: 1px solid var(--shell-line);
    background: var(--shell-bg);
  }

  /* 间距按 4 的倍数：区块标题和内容 8、区块之间 24、条目之间 2；左右统一 12 的外边距 + 8 的内边距 */
  .app-sidebar-label {
    margin: 0 0 8px;
    padding: 0 8px;
    color: var(--shell-text-3);
    font-size: 12px;
    font-weight: 500;
    line-height: 16px;
  }

  .app-nav {
    display: grid;
    gap: 2px;
    padding: 20px 12px 16px;
    border-bottom: 1px solid var(--shell-line);
  }

  .app-nav-item {
    display: flex;
    height: 36px;
    align-items: center;
    gap: 10px;
    padding: 0 8px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--shell-text-2);
    font: inherit;
    font-size: 13.5px;
    font-weight: 500;
    text-align: start;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
  }

  .app-nav-item img {
    width: 18px;
    height: 18px;
    filter: brightness(0) saturate(100%) invert(34%) sepia(7%) saturate(631%) hue-rotate(202deg) brightness(91%) contrast(88%);
  }

  .app-nav-item:hover,
  .app-nav-item:focus-visible {
    background: var(--shell-hover);
    color: var(--shell-text);
    outline: none;
  }

  .app-nav-item.is-active {
    background: var(--shell-active);
    color: var(--shell-on-active);
  }

  .app-nav-item.is-active img {
    filter: brightness(0) invert(1);
  }

  html[data-color-scheme="dark"] .app-nav-item img {
    filter: brightness(0) invert(0.7);
  }

  html[data-color-scheme="dark"] .app-nav-item:hover img {
    filter: brightness(0) invert(0.92);
  }

  html[data-color-scheme="dark"] .app-nav-item.is-active img {
    filter: brightness(0);
  }

  /* 「画布」导航项：画布模式下是当前项 */
  html[data-app-mode="canvas"] .app-nav-item[data-nav-mode="canvas"] {
    background: var(--shell-active);
    color: var(--shell-on-active);
  }

  html[data-app-mode="canvas"] .app-nav-item[data-nav-mode="canvas"] img {
    filter: brightness(0) invert(1);
  }

  html[data-color-scheme="dark"][data-app-mode="canvas"] .app-nav-item[data-nav-mode="canvas"] img {
    filter: brightness(0);
  }

  /* 宽屏有左侧节点库，画布里的浮动小竖条（添加 / 上传）收起 */
  .flow-app .flow-toolrail {
    display: none;
  }

  /* 画布里没有「当前工具」 */
  html[data-app-mode="canvas"] .app-nav-item.is-active {
    background: transparent;
    color: var(--shell-text-2);
  }

  html[data-app-mode="canvas"] .app-nav-item.is-active:hover {
    background: var(--shell-hover);
  }

  html[data-app-mode="canvas"] .app-nav-item.is-active img {
    filter: brightness(0) saturate(100%) invert(34%) sepia(7%) saturate(631%) hue-rotate(202deg) brightness(91%) contrast(88%);
  }

  html[data-color-scheme="dark"][data-app-mode="canvas"] .app-nav-item.is-active img {
    filter: brightness(0) invert(0.7);
  }

  /* 导航的动画图标（shell.js 加载好后替换静态图标）：线条跟随文字颜色；
     「图片 AI」图标里有一块白色挖空，跟随当前项的底色（--nav-knock） */
  .app-nav-item {
    --nav-knock: var(--shell-bg);
  }

  .app-nav-item:hover,
  .app-nav-item:focus-visible {
    --nav-knock: var(--shell-hover);
  }

  .app-nav-item.is-active,
  html[data-app-mode="canvas"] .app-nav-item[data-nav-mode="canvas"] {
    --nav-knock: var(--shell-active);
  }

  html[data-app-mode="canvas"] .app-nav-item.is-active {
    --nav-knock: var(--shell-bg);
  }

  html[data-app-mode="canvas"] .app-nav-item.is-active:hover {
    --nav-knock: var(--shell-hover);
  }

  /* 加载好之前先放在布局里但不可见（要量第一帧图形的范围，display:none 时量不到） */
  .app-nav-item {
    position: relative;
  }

  .app-nav-anim {
    position: absolute;
    display: block;
    width: 18px;
    height: 18px;
    flex: none;
    visibility: hidden;
    /* 动画里有透明的大图形，放大后会盖到相邻导航项上，不能接收鼠标 */
    pointer-events: none;
  }

  .app-nav-item.has-anim img {
    display: none;
  }

  .app-nav-item.has-anim .app-nav-anim {
    position: static;
    visibility: visible;
  }

  .app-nav-anim svg {
    display: block;
    overflow: visible;
  }

  .app-nav-anim svg [stroke="rgb(0,0,0)"] {
    stroke: currentColor;
  }

  .app-nav-anim svg [fill="rgb(0,0,0)"] {
    fill: currentColor;
  }

  .app-nav-anim svg [fill="rgb(255,255,255)"] {
    fill: var(--nav-knock);
    transition: fill 0.15s ease;
  }

  /* 编辑器和画布各自一个滚动区（叠在一起，只显示当前模式的那个），切换后各自保留滚动位置 */
  .app-sidebar-scroll {
    position: relative;
    min-height: 0;
    flex: 1;
  }

  .app-sidebar-library {
    position: absolute;
    inset: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 20px 12px 24px;
  }

  html:not([data-app-mode="canvas"]) [data-sidebar-canvas],
  html[data-app-mode="canvas"] [data-sidebar-editor] {
    visibility: hidden;
  }

  /* 编辑器的「风格预设」「预设素材」挪进左侧后的样子（shell.js 负责挪动）*/
  .app-sidebar .ascii-panel-section {
    margin: 0 0 24px;
    padding: 0;
    border: 0;
  }

  .app-sidebar .ascii-panel-section:last-child {
    margin-bottom: 0;
  }

  .app-sidebar .ascii-panel-section h2 {
    margin: 0 0 4px;
    padding: 0 8px;
    color: var(--shell-text-3);
    font-size: 12px;
    font-weight: 500;
    line-height: 16px;
  }

  .app-sidebar .ascii-section-hint {
    margin: 0 0 12px;
    padding: 0 8px;
    color: var(--shell-text-3);
    font-size: 11.5px;
    line-height: 16px;
  }

  .app-sidebar .ascii-style-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 8px;
    padding: 0 4px;
  }

  .app-sidebar .ascii-style-group {
    margin: 8px 0 -4px;
    padding: 0 4px;
  }

  .app-sidebar .ascii-style-group:first-child {
    margin-top: 0;
  }

  .app-sidebar .ascii-style-shuffle {
    width: calc(100% - 8px);
    height: 32px;
    margin: 12px 4px 0;
  }

  .app-sidebar .ascii-preset-section h2 {
    margin-bottom: 8px;
  }

  .app-sidebar .ascii-preset-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    /* 原来的 max-height（右侧面板里固定两行）在左侧要去掉，否则图片溢出所在区域，底部的留白不起作用 */
    max-height: none;
    padding: 0 4px;
    overflow: visible;
  }

  .app-sidebar .ascii-preset-grid button {
    width: auto;
    height: 72px;
  }

  /* ——— 编辑器：画面让出两侧面板，参数面板贴边停靠 ——— */
  .ascii-editor-page .ascii-tool-rail {
    display: none;
  }

  .ascii-editor-page .ascii-stage {
    inset: var(--shell-top) var(--shell-right) 0 var(--shell-left);
  }

  .ascii-editor-page .ascii-panel {
    top: var(--shell-top);
    right: 0;
    bottom: 0;
    width: var(--shell-right);
    border-width: 0 0 0 1px;
    border-color: var(--shell-line, #f0f0f1);
    border-radius: 0;
    box-shadow: none;
  }

  /* 选择器要和 styles.css 里自动生成的深色规则同级（html[…] body.ascii-editor-page …），本文件在后面加载所以能盖过 */
  html[data-color-scheme="dark"] body.ascii-editor-page .ascii-panel {
    border-width: 0 0 0 1px;
    border-color: #232326;
    background: #111113;
  }

  /* 关闭按钮已在顶栏右侧 */
  .ascii-editor-page .ascii-panel-header a {
    display: none;
  }

  /* ——— 画布：让出顶栏和左侧面板 ——— */
  .flow-app {
    top: var(--shell-top);
    left: var(--shell-left);
  }

  .flow-app .flow-empty {
    width: min(760px, calc(100vw - var(--shell-left) - 96px));
  }

  /* 节点库 */
  .flow-lib-hint {
    margin: 0 0 16px;
    padding: 0 8px;
    color: var(--shell-text-3);
    font-size: 11.5px;
    line-height: 16px;
  }

  .flow-lib-group {
    display: grid;
    gap: 0;
    margin-bottom: 16px;
  }

  .flow-lib-group:last-child {
    margin-bottom: 0;
  }

  /* 节点库：两列小卡片（图标 + 名称，说明在悬停提示里），一屏放下全部节点和模板 */
  .flow-lib-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .flow-lib-tile {
    display: flex;
    min-width: 0;
    height: 40px;
    align-items: center;
    gap: 8px;
    padding: 0 8px;
    border: 1px solid var(--shell-line);
    border-radius: 9px;
    background: var(--shell-bg);
    text-align: start;
    cursor: grab;
    transition: border-color 0.15s ease, background-color 0.15s ease;
    /* 单独成层：Chrome 拖动时截取的预览图才会保留透明圆角，不漏出白色底角 */
    transform: translate(0, 0);
  }

  .flow-lib-tile:hover,
  .flow-lib-tile:focus-visible {
    border-color: var(--shell-thumb-hover);
    background: var(--shell-hover);
    outline: none;
  }

  .flow-lib-tile:active {
    cursor: grabbing;
  }

  .flow-lib-tile .flow-lib-icon {
    width: 24px;
    height: 24px;
    border: 0;
    border-radius: 6px;
    background: var(--shell-hover);
  }

  .flow-lib-tile .flow-lib-icon .flow-icon {
    width: 14px;
    height: 14px;
  }

  .flow-lib-tile .flow-lib-title {
    overflow: hidden;
    min-width: 0;
    font-size: 12.5px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .flow-lib-item {
    display: flex;
    min-height: 44px;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    text-align: start;
    cursor: grab;
    transition: background-color 0.15s ease;
  }

  .flow-lib-item:hover,
  .flow-lib-item:focus-visible {
    background: var(--shell-hover);
    outline: none;
  }

  .flow-lib-item:active {
    cursor: grabbing;
  }

  .flow-lib-icon {
    display: grid;
    width: 32px;
    height: 32px;
    flex: none;
    place-items: center;
    border: 1px solid var(--shell-line);
    border-radius: 8px;
    background: var(--shell-bg);
    color: var(--shell-text-2);
  }

  .flow-lib-text {
    display: grid;
    min-width: 0;
    gap: 1px;
  }

  .flow-lib-title {
    color: var(--shell-text);
    font-size: 13px;
    font-weight: 500;
  }

  .flow-lib-desc {
    overflow: hidden;
    color: var(--shell-text-3);
    font-size: 11.5px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* ≤1100px：原来的浮动布局（编辑器顶部是横排工具栏、参数面板在下方）。模式切换在编辑器里放右上角，不压工具栏；
   画布有自己的浮动按钮，横排工具栏收起 */
@media (max-width: 1100px) {
  /* 编辑器和画布都放右上角同一位置（编辑器左上角是工具栏），切换时不换边；画布的按钮组让出这块位置（canvas.css） */
  html .mode-switch.is-floating {
    top: 22px;
    right: 16px;
    left: auto;
  }

  html[data-app-mode="canvas"] .ascii-tool-rail {
    display: none;
  }
}

/* ——— 滚动条：细、圆角、跟随浅色 / 深色；只有在可滚动区域悬停时颜色才加深 ——— */
.app-sidebar-library,
.ascii-editor-page .ascii-panel-scroll,
.flow-app .flow-menu-list,
.flow-app .flow-picker-grid,
.flow-app .flow-modal,
.flow-app .flow-textarea,
.flow-dd-menu {
  --scroll-thumb: var(--shell-thumb, #e4e4e7);
  --scroll-thumb-hover: var(--shell-thumb-hover, #d4d4d8);
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) transparent;
}

html[data-color-scheme="dark"] .ascii-editor-page .ascii-panel-scroll,
html[data-color-scheme="dark"] .flow-app .flow-menu-list,
html[data-color-scheme="dark"] .flow-app .flow-picker-grid,
html[data-color-scheme="dark"] .flow-app .flow-modal,
html[data-color-scheme="dark"] .flow-app .flow-textarea,
html[data-color-scheme="dark"] .flow-dd-menu {
  --scroll-thumb: #2e2e33;
  --scroll-thumb-hover: #3f3f46;
}

.app-sidebar-library:hover,
.ascii-editor-page .ascii-panel-scroll:hover,
.flow-app .flow-menu-list:hover,
.flow-app .flow-picker-grid:hover,
.flow-app .flow-modal:hover,
.flow-app .flow-textarea:hover,
.flow-dd-menu:hover {
  scrollbar-color: var(--scroll-thumb-hover) transparent;
}

.app-sidebar-library::-webkit-scrollbar,
.ascii-editor-page .ascii-panel-scroll::-webkit-scrollbar,
.flow-app .flow-menu-list::-webkit-scrollbar,
.flow-app .flow-picker-grid::-webkit-scrollbar,
.flow-app .flow-modal::-webkit-scrollbar,
.flow-app .flow-textarea::-webkit-scrollbar,
.flow-dd-menu::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.app-sidebar-library::-webkit-scrollbar-track,
.ascii-editor-page .ascii-panel-scroll::-webkit-scrollbar-track,
.flow-app .flow-menu-list::-webkit-scrollbar-track,
.flow-app .flow-picker-grid::-webkit-scrollbar-track,
.flow-app .flow-modal::-webkit-scrollbar-track,
.flow-app .flow-textarea::-webkit-scrollbar-track,
.flow-dd-menu::-webkit-scrollbar-track {
  background: transparent;
}

/* 用透明边框把滑块收窄成 4px 并离边留空 */
.app-sidebar-library::-webkit-scrollbar-thumb,
.ascii-editor-page .ascii-panel-scroll::-webkit-scrollbar-thumb,
.flow-app .flow-menu-list::-webkit-scrollbar-thumb,
.flow-app .flow-picker-grid::-webkit-scrollbar-thumb,
.flow-app .flow-modal::-webkit-scrollbar-thumb,
.flow-app .flow-textarea::-webkit-scrollbar-thumb,
.flow-dd-menu::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: var(--scroll-thumb) padding-box;
}

.app-sidebar-library::-webkit-scrollbar-thumb:hover,
.ascii-editor-page .ascii-panel-scroll::-webkit-scrollbar-thumb:hover,
.flow-app .flow-menu-list::-webkit-scrollbar-thumb:hover,
.flow-app .flow-picker-grid::-webkit-scrollbar-thumb:hover,
.flow-app .flow-modal::-webkit-scrollbar-thumb:hover,
.flow-app .flow-textarea::-webkit-scrollbar-thumb:hover,
.flow-dd-menu::-webkit-scrollbar-thumb:hover {
  background: var(--scroll-thumb-hover) padding-box;
}

/* 编辑器参数面板原有的滚动条规则（styles.css，含深色版）优先级更高，这里用同级选择器统一成上面的样式 */
html[data-color-scheme] body.ascii-editor-page .ascii-panel-scroll {
  scrollbar-color: var(--scroll-thumb) transparent;
}

html[data-color-scheme] body.ascii-editor-page .ascii-panel-scroll:hover {
  scrollbar-color: var(--scroll-thumb-hover) transparent;
}

html[data-color-scheme] body.ascii-editor-page .ascii-panel-scroll::-webkit-scrollbar {
  width: 10px;
}

html[data-color-scheme] body.ascii-editor-page .ascii-panel-scroll::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: var(--scroll-thumb) padding-box;
}

html[data-color-scheme] body.ascii-editor-page .ascii-panel-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--scroll-thumb-hover) padding-box;
}

/* 手机（≤760px）：编辑器左上角的工具栏太宽，和模式切换放不进一行——两种模式都把切换放到第二行右侧（同一位置，不换边），
   画布第一行的按钮组就不用再给它让位 */
@media (max-width: 760px) {
  html .mode-switch.is-floating {
    top: 76px;
    right: 16px;
  }
}

/* 顶栏右侧画布按钮（全部运行 / 生成记录 / 模型服务）：和「关闭」一样带一圈描边，高 36、圆角 10 */
@media (min-width: 1101px) {
  .app-topbar .flow-topbar-end {
    gap: 8px;
  }

  .app-topbar .flow-topbar-end .flow-pill-button,
  .app-topbar .flow-topbar-end .flow-history-button {
    height: 36px;
    border: 1px solid var(--shell-line);
    border-radius: 10px;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  }

  .app-topbar .flow-topbar-end .flow-pill-button {
    padding: 0 12px;
  }

  .app-topbar .flow-topbar-end .flow-history-button {
    width: 36px;
  }

  .app-topbar .flow-topbar-end .flow-pill-button:hover,
  .app-topbar .flow-topbar-end .flow-history-button:hover,
  .app-topbar .flow-topbar-end .flow-history-button.is-active {
    border-color: var(--shell-thumb-hover);
    background: var(--shell-hover);
  }

  html[data-color-scheme="dark"] .app-topbar .flow-topbar-end .flow-pill-button,
  html[data-color-scheme="dark"] .app-topbar .flow-topbar-end .flow-history-button {
    border-color: #2e2e33;
  }

  html[data-color-scheme="dark"] .app-topbar .flow-topbar-end .flow-pill-button:hover,
  html[data-color-scheme="dark"] .app-topbar .flow-topbar-end .flow-history-button:hover {
    border-color: #3f3f46;
  }
}


/* ───────── 使用说明（shell.js openGuide）：原生 <dialog>，左边分类、右边内容 ───────── */
.app-guide {
  width: min(760px, calc(100vw - 32px));
  /* 固定高度：切换分类时窗口不跟着内容变高变矮，内容超出就在右侧区域里滚动 */
  height: min(600px, calc(100vh - 48px));
  max-height: none;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--shell-line);
  border-radius: 16px;
  background: var(--shell-bg);
  color: var(--shell-text);
  box-shadow: 0 24px 64px rgba(24, 24, 27, 0.18), 0 2px 8px rgba(24, 24, 27, 0.06);
  font-family: "Geist", "IBM Plex Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.app-guide[open] {
  display: flex;
  flex-direction: column;
  animation: app-guide-in 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.app-guide::backdrop {
  background: rgba(24, 24, 27, 0.32);
  animation: app-guide-fade 0.16s ease-out;
}

html[data-color-scheme="dark"] .app-guide {
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
}

html[data-color-scheme="dark"] .app-guide::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

@keyframes app-guide-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

@keyframes app-guide-fade {
  from {
    opacity: 0;
  }
}

.app-guide-head {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 12px 16px 24px;
  border-bottom: 1px solid var(--shell-line);
}

.app-guide-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.app-guide-head p {
  margin: 2px 0 0;
  color: var(--shell-text-3);
  font-size: 12px;
}

.app-guide-close {
  display: grid;
  width: 32px;
  height: 32px;
  flex: none;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--shell-text-2);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.app-guide-close:hover,
.app-guide-close:focus-visible {
  background: var(--shell-hover);
  color: var(--shell-text);
  outline: none;
}

.app-guide-body {
  display: grid;
  min-height: 0;
  flex: 1;
  grid-template-columns: 168px minmax(0, 1fr);
}

.app-guide-tabs {
  display: grid;
  align-content: start;
  gap: 2px;
  padding: 12px;
  border-right: 1px solid var(--shell-line);
}

.app-guide-tab {
  height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--shell-text-2);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  text-align: start;
  cursor: pointer;
}

.app-guide-tab:hover {
  background: var(--shell-hover);
  color: var(--shell-text);
}

.app-guide-tab[aria-selected="true"] {
  background: var(--shell-active);
  color: var(--shell-on-active);
}

.app-guide-tab:focus-visible {
  outline: 2px solid #e879f9;
  outline-offset: 1px;
}

.app-guide-panel {
  min-height: 0;
  padding: 20px 24px 28px;
  overflow-y: auto;
  scrollbar-width: thin;
  font-size: 13.5px;
  line-height: 1.75;
}

.app-guide-panel h3 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 600;
}

.app-guide-panel > p {
  margin: 0 0 14px;
  color: var(--shell-text-2);
}

.app-guide-panel h4 {
  margin: 18px 0 6px;
  color: var(--shell-text);
  font-size: 13px;
  font-weight: 600;
}

.app-guide-panel ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
  color: var(--shell-text-2);
}

.app-guide-panel li::marker {
  color: #e879f9;
}

.app-guide-panel b {
  color: var(--shell-text);
  font-weight: 600;
}

.app-guide-panel kbd {
  display: inline-grid;
  min-width: 20px;
  height: 20px;
  place-items: center;
  margin: 0 1px;
  padding: 0 5px;
  border: 1px solid var(--shell-line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--shell-hover);
  color: var(--shell-text);
  font-family: inherit;
  font-size: 11px;
  line-height: 1;
  vertical-align: 1px;
}

@media (max-width: 640px) {
  .app-guide-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .app-guide-tabs {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--shell-line);
  }

  .app-guide-tab {
    flex: none;
  }

  .app-guide-panel {
    padding: 16px 18px 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-guide[open],
  .app-guide::backdrop {
    animation: none;
  }
}

/* 画布底部对话框、生成记录、版本历史：同样用全站的细滚动条（同上面那组规则） */
.flow-app .flow-composer-input,
.flow-app .flow-history-body,
.flow-app .flow-versions-list {
  --scroll-thumb: var(--shell-thumb, #e4e4e7);
  --scroll-thumb-hover: var(--shell-thumb-hover, #d4d4d8);
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) transparent;
}

html[data-color-scheme="dark"] .flow-app .flow-composer-input,
html[data-color-scheme="dark"] .flow-app .flow-history-body,
html[data-color-scheme="dark"] .flow-app .flow-versions-list {
  --scroll-thumb: #2e2e33;
  --scroll-thumb-hover: #3f3f46;
}

.flow-app .flow-composer-input:hover,
.flow-app .flow-history-body:hover,
.flow-app .flow-versions-list:hover {
  scrollbar-color: var(--scroll-thumb-hover) transparent;
}

.flow-app .flow-composer-input::-webkit-scrollbar,
.flow-app .flow-history-body::-webkit-scrollbar,
.flow-app .flow-versions-list::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.flow-app .flow-composer-input::-webkit-scrollbar-track,
.flow-app .flow-history-body::-webkit-scrollbar-track,
.flow-app .flow-versions-list::-webkit-scrollbar-track {
  background: transparent;
}

.flow-app .flow-composer-input::-webkit-scrollbar-thumb,
.flow-app .flow-history-body::-webkit-scrollbar-thumb,
.flow-app .flow-versions-list::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: var(--scroll-thumb) padding-box;
}

/* ——— 左侧面板：分组间距 + 滚动体验（2026-11-19）———
   间距按 4 的倍数：分组标题和内容 8、分组之间 28、提示和第一组 20。
   滚动：顶部滚动后出现渐进模糊 + 底色渐隐（不再生硬地切掉内容），底部还有内容时出现渐隐提示；
   滚动条平时隐藏，悬停或滚动时才显示。遮罩层固定不动、不接收点击，透明度按滚动距离在 24px 内从 0 到 1。 */
@media (min-width: 1101px) {
  .flow-lib-hint {
    margin: 0 0 20px;
  }

  .flow-lib-group {
    margin-bottom: 28px;
  }

  .flow-lib-group .app-sidebar-label {
    margin-bottom: 10px;
  }

  .flow-lib-group > .flow-lib-item + .flow-lib-item {
    margin-top: 2px;
  }

  .app-sidebar-library {
    padding-bottom: 32px;
  }

  .app-sidebar-fade {
    position: absolute;
    right: 10px;
    left: 0;
    z-index: 2;
    height: 40px;
    pointer-events: none;
  }

  .app-sidebar-fade.is-top {
    top: 0;
  }

  .app-sidebar-fade.is-bottom {
    bottom: 0;
  }

  .app-sidebar-fade > i {
    position: absolute;
    right: 0;
    left: 0;
    display: block;
  }

  .app-sidebar-fade.is-top > i {
    top: 0;
    opacity: var(--fade-top, 0);
  }

  .app-sidebar-fade.is-bottom > i {
    bottom: 0;
    opacity: var(--fade-bottom, 0);
  }

  /* 三层：24px 的 1px 模糊、16px 的 4px 模糊、40px 底色渐隐 */
  .app-sidebar-fade > .f-blur1 {
    height: 24px;
    -webkit-backdrop-filter: blur(1px);
    backdrop-filter: blur(1px);
  }

  .app-sidebar-fade > .f-blur2 {
    height: 16px;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
  }

  .app-sidebar-fade.is-top > .f-blur1,
  .app-sidebar-fade.is-top > .f-blur2 {
    -webkit-mask-image: linear-gradient(to bottom, #000, transparent);
    mask-image: linear-gradient(to bottom, #000, transparent);
  }

  .app-sidebar-fade.is-bottom > .f-blur1,
  .app-sidebar-fade.is-bottom > .f-blur2 {
    -webkit-mask-image: linear-gradient(to top, #000, transparent);
    mask-image: linear-gradient(to top, #000, transparent);
  }

  .app-sidebar-fade > .f-tint {
    height: 40px;
  }

  .app-sidebar-fade.is-top > .f-tint {
    background: linear-gradient(to bottom, var(--shell-bg), transparent);
  }

  .app-sidebar-fade.is-bottom > .f-tint {
    background: linear-gradient(to top, var(--shell-bg), transparent);
  }

  /* 滚动条：平时透明，悬停或正在滚动时显示 */
  .app-sidebar-library {
    --scroll-thumb: transparent;
  }

  .app-sidebar-library:hover,
  .app-sidebar-library.is-scrolling {
    --scroll-thumb: var(--shell-thumb, #e4e4e7);
    scrollbar-color: var(--scroll-thumb) transparent;
  }
}

/* ——— 问号菜单里的「语言」分组：分隔线 + 小标题 + 两个单选项（选中项右侧品牌色对勾）——— */
@media (min-width: 1101px) {
  .app-help-sep {
    height: 1px;
    margin: 6px 4px;
    background: var(--shell-line);
  }

  .app-help-label {
    margin: 2px 0 2px;
    padding: 0 10px;
    color: var(--shell-text-3);
    font-size: 11.5px;
    line-height: 20px;
  }

  .app-help-langs {
    display: grid;
  }

  .app-help-menu [data-lang-choice] {
    justify-content: space-between;
    gap: 12px;
  }

  .app-help-menu [data-lang-choice][aria-checked="true"] {
    color: var(--shell-text);
    font-weight: 500;
  }

  .app-help-menu [data-lang-choice][aria-checked="true"]::after {
    width: 14px;
    height: 14px;
    background: #e879f9;
    content: "";
    -webkit-mask: url("../icons/iconly/canvas/check.svg") center / contain no-repeat;
    mask: url("../icons/iconly/canvas/check.svg") center / contain no-repeat;
  }

  html.is-lang-switching body {
    cursor: progress;
  }
}

/* 使用说明弹窗：在对话框里或遮罩上滚动时，不带着后面的页面一起滚 */
.app-guide:modal {
  overscroll-behavior: contain;
}

.app-guide::backdrop {
  overflow: hidden;
  overscroll-behavior: contain;
}

/* 节点库名称完整显示（s11）：原来每格文字宽只有 63px，「反推提示词」刚好塞满，换字体 / 缩放 / 英文就被省略号截掉。
   现在收紧图标间距多给几像素；还放不下时折成两行（中文词组尽量不拆开），同一行两格自动等高 */
@media (min-width: 1101px) {
  .flow-lib-tile {
    height: auto;
    min-height: 40px;
    gap: 6px;
    padding: 6px 6px 6px 8px;
  }

  .flow-lib-tile .flow-lib-title {
    overflow: visible;
    min-width: 0;
    line-height: 15px;
    text-overflow: clip;
    white-space: normal;
    text-wrap: balance;
    word-break: keep-all;
    /* 英文长单词（background）按音节加连字符断行，而不是硬拆成「backgroun / d」；页面切英文时 html 的 lang 会设为 en */
    hyphens: auto;
    overflow-wrap: anywhere;
  }

  .flow-lib-desc {
    display: -webkit-box;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }
}

/* 节点库格子（s13）：左右内边距和图标间距各收 2px，给文字多留 4px，「反推提示词」这类五个字的中文名一行放得下；英文长名仍可换行 */
@media (min-width: 1101px) {
  .flow-lib-tile {
    gap: 4px;
    padding-inline: 6px 4px;
  }
}
