/* ===== 主题变量 ===== */
:root {
  --as-bg: #ffffff;
  --as-panel: #ffffff;
  --as-panel-2: #f3f3f3;
  --as-text: #333333;
  --as-muted: #888888;
  --as-outline: #dddddd;
  --as-accent: #4aa3ff;
  --as-focus: #7bb0ff;

  --as-strip-w: 218px; /* 缩略区宽度 */
  --as-tabs-w: 22px; /* 竖签轨宽度 */
  --as-gap: 6px; /* viewport 和右侧间隔 */
}

/* ===== 容器 ===== */
.asset-studio {
  box-sizing: border-box;
  background: var(--as-bg);
  color: var(--as-text);
  padding: 14px;
  width: 100%;
  margin: 0 auto;
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    Arial;
  display: flex;
  flex-direction: row;
  gap: var(--as-gap);
  align-items: stretch;
}

/* ===== 视口 ===== */
.as-viewport {
  background: radial-gradient(ellipse at center, #f7f7f7 0%, #f7f7f7 20%);
  border: 1px solid var(--as-outline);
  border-radius: 6px;
  position: relative;
  overflow: hidden;
  flex: 1 1 auto;
  min-width: 0;
}

.as-btn {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: var(--as-panel);
  border: 1px solid var(--as-outline);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--as-muted);
  cursor: pointer;
}
.as-btn:hover {
  color: var(--as-text);
  border-color: var(--as-focus);
}

/* 缩略条（中） */
.as-strip {
  flex: 0 0 var(--as-strip-w);
  width: var(--as-strip-w);
  max-width: var(--as-strip-w);
  align-self: stretch;
  border: 0;
  border-radius: 6;
  margin: 0;
  background: var(--as-panel-2);
  padding: 10px;
  white-space: nowrap;
  overflow-x: auto;
  overflow-y: auto;
}

.as-thumb {
  display: inline-flex;
  flex-direction: column;
  width: 100%;
  height: 128px;
  border-radius: 6px;
  background: var(--as-panel);
  border: 2px solid transparent;
  padding: 0;
  margin-right: 10px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.as-thumb:focus {
  outline: none;
  border-color: var(--as-focus);
}

.as-thumb__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* 选中态：主题色外描边 */
.asset-studio .as-thumb.is-selected {
  box-shadow: 0 0 0 2px var(--as-accent);
}

.as-thumb__img {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--as-muted);
}
.as-thumb__cap {
  padding: 6px 8px;
  font-size: 12px;
  color: var(--as-muted);
  border-top: 1px solid var(--as-outline);
  background: rgba(0, 0, 0, 0.2);
}
.as-thumb.is-selected {
  border-color: var(--as-accent);
}

/* 右侧容器：仅负责横向并排，不再统一描边/圆角 */
.as-right {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 0;
  flex: 0 0 auto;
  width: auto; /* 宽度由子项决定 */
  border: 0;
  border-radius: 6px 0 0 6px;
  background: none;
  overflow: visible;
}

/* strip：独立面板（保留完整边框与圆角） */
.as-strip {
  box-sizing: border-box;
  flex: 0 0 var(--as-strip-w);
  width: var(--as-strip-w);
  max-width: var(--as-strip-w);
  align-self: stretch;

  border: 1px solid var(--as-outline);
  border-radius: 6px 0 0 6px;
  background: var(--as-panel-2);
  padding: 10px;

  white-space: nowrap;
  overflow-x: auto;
  overflow-y: auto;
  margin: 0;
}

/* tabs：单独的窄竖条，不画容器圆角，和 strip 贴近 */
.as-tabs {
  box-sizing: border-box;
  flex: 0 0 var(--as-tabs-w);
  width: var(--as-tabs-w);
  max-width: var(--as-tabs-w);
  align-self: stretch;

  display: flex;
  flex-direction: column;
  padding: 0;
  margin: 0 0 0 0px;
  background: transparent;
  border: 0; /* 不在容器层画边框/圆角 */
  overflow: visible;
}

/* 单个竖签：自己画左右边框；顶部/底部圆角在首末项处理 */
.as-tab {
  box-sizing: border-box;
  width: 100%;
  height: 92px;
  margin: 0;
  padding: 0;

  /* border-left: 1px solid var(--as-outline); */
  border-right: 1px solid var(--as-outline);

  border-radius: 0;

  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;

  background: transparent;
  color: var(--as-muted);

  writing-mode: vertical-rl;
  text-orientation: mixed;
  letter-spacing: 0.5px;
  text-align: center;
}

/* 中间分隔线（只画水平线） */
.as-tab + .as-tab {
  border-top: 1px solid var(--as-outline);
}

/* 首尾由子项收尾圆角（“最后一个 tab 画底部/右端圆角”的对应横排版本） */
.as-tab:first-child {
  border-radius: 0 6px 0 0;
  border-top: 1px solid var(--as-outline) !important ; /* 顶边保持一致视觉 */
}
.as-tabs > .as-tab:only-child {
  border-radius: 0 6px 6px 0;
}
.as-tab:last-child {
  border-radius: 0 0 6px 0;
  border-bottom: 1px solid var(--as-outline) !important ; /* 顶边保持一致视觉 */
}

/* 交互态 */
.as-tab:hover {
  background: var(--as-panel-2);
  color: var(--as-text);
}
.as-tab.is-active {
  background: var(--as-accent);
  color: #fff;
}

/* 缩略图容器：无图时也占位，不再出现 0 高度 */
.asset-studio .as-thumb__img {
  background-color: #f3f3f5;
  border-radius: 6px;
  overflow: hidden;
}

/* 两行截断（强覆盖旧的一行省略样式） */
.asset-studio .as-item .as-thumb__name {
  /* 布局与基线 */
  margin: 6px 0px 6px 0px;
  font-size: 12px;
  line-height: 1.3;
  text-align: center;
  width: 100%;

  /* —— 关键：开启多行截断 —— */
  line-clamp: 2;
  display: -webkit-box !important;
  -webkit-box-orient: vertical !important;
  -webkit-line-clamp: 2 !important;

  /* 必须隐藏溢出，且取消单行样式 */
  overflow: hidden !important;
  white-space: normal !important;
  text-overflow: clip !important;

  /* Fallback：即使 -webkit-line-clamp 不生效也会卡在两行高 */
  max-height: calc(2 * 1.3em);
  word-break: break-word;
  hyphens: auto;
  /* 确保没有被别处固定高度 */
  height: auto !important;
}

.asset-studio .as-thumb {
  position: relative; /* 让 cap 能定位在框里 */
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

/* 扩展名的小字（在按钮内部底部） */
.asset-studio .as-thumb__cap {
  position: absolute;
  left: 8px;
  bottom: 8px;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 11px;
  line-height: 1.2;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  pointer-events: none;
}

@media (max-width: 640px) {
  /* 顶部 Tabs：横向一条，可横向滚动，不再受 48px 影响 */
  .as-tabs {
    order: 1;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap; /* 不换行 */
    width: 100% !important; /* 覆盖桌面端的固定宽 */
    flex: 0 0 auto !important; /* 覆盖桌面端的 flex-basis */
    margin: 0;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    border: 0; /* 容器不画边框，交给子项 */
    background: transparent;
    max-width: 100%;
  }

  .as-tab {
    /* 横向渲染 & 尺寸固定，不被压缩也不拉伸 */
    writing-mode: horizontal-tb;
    text-orientation: initial;
    height: var(--as-tabs-w);
    padding: 0 12px;

    width: auto; /* 覆盖桌面端的 width:100% */
    min-width: 88px; /* 给触控足够命中区，可按需调 */
    flex: 0 0 auto; /* 关键：不缩放不换行 */
    white-space: nowrap; /* 文本不折行 */

    /* 边框改为横排样式 */
    border: 1px solid var(--as-outline);
    border-left: 0; /* 左侧由相邻项来画分隔 */
    border-right: 0;
    border-radius: 0;
  }

  /* 横排分隔线：放在相邻项之间 */
  .as-tab + .as-tab {
    border-left: 1px solid var(--as-outline);
    border-top: 1px solid var(--as-outline); /* 顶边保持一致视觉 */
    border-right: 1px solid var(--as-outline);
  }

  /* 首尾由子项收尾圆角（“最后一个 tab 画底部/右端圆角”的对应横排版本） */
  .as-tab:first-child {
    border-radius: 6px 0 0 0;
    border-left: 1px solid var(--as-outline) !important ; /* 顶边保持一致视觉 */
  }
  .as-tabs > .as-tab:only-child {
    border-radius: 6px 6px 0 0;
  }
  .as-tab:last-child {
    border-radius: 0 6px 0 0;
    border-right: 1px solid var(--as-outline) !important ; /* 顶边保持一致视觉 */
  }

  /* strip 横向、不吃剩余高度（保持你现有设置即可） */
  .as-strip {
    order: 2;
    width: 100%;
    max-width: none;
    min-height: 120px;

    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 10px;

    flex: 0 0 auto;
    white-space: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    border-radius: 0 0 6px 6px;
  }
  .as-thumb {
    width: 100%;
    aspect-ratio: 4 / 3; /* 让按钮自己定高 */
    height: auto;
    position: relative; /* 供 __img 绝对定位 */
  }
  .as-item {
    width: 188px;
  }
  /* viewport 吃满剩余高度 */
  .asset-studio {
    flex-direction: column;
    gap: 12px;
    min-height: 100vh;
  }
  .as-right {
    order: 1;
    width: 100%;
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    /* gap: 8px; */
  }
  .as-viewport {
    order: 3;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 320px;
    height: auto;
  }

  /* 建议用绝对定位让背景图填满按钮盒子 */
  .as-thumb__img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
  }
}
