/* ---------- 基础变量 ---------- */
:root {
  --bg: #F4FAF7;           /* 浅绿色背景 */
  --card: #FFFFFF;
  --line: #CCE0D6;         /* 浅绿线条 */
  --muted: #4B6B57;        /* 辅助绿 */
  --primary: #2E7D5E;      /* 主绿色 */
  --primary-weak: #D0E8DC; /* 浅绿底 */
  --radius: 14px;
  --radius-lg: 20px;
  --radius-sm: 12px;
  --shadow: 0 8px 24px rgba(0,0,0,.06);
  --sidebar-w: 5vw;
  --det-juzi: #ff4d4f;     /* 句子框红 */
  --det-char: #1677ff;     /* 字符框蓝 */
  --det-label-bg: rgba(0,0,0,.35); /* 标签底色 */
}

/* ---------- 全局 ---------- */
* {
  box-sizing: border-box;
}

/* —— A 组：URO、URO追加、Ext-A —— */
@font-face {
  font-family: "HanA";
  src: url("/static/fonts/HanaMinA.ttf") format("truetype");
  font-display: swap;
  unicode-range:
    U+4E00-9FA5,      /* URO */
    U+9FA6-9FEA,      /* URO 追加 */
    U+3400-4DB5;      /* Ext-A（如需更精确可改为 U+3400-4DBF）*/
}

/* —— B 组：Ext-B ~ Ext-F、兼容区、兼容扩展 —— */
@font-face {
  font-family: "HanB";
  src: url("/static/fonts/HanaMinB.ttf") format("truetype");
  font-display: swap;
  unicode-range:
    U+20000-2A6D6,    /* Ext-B */
    U+2A700-2B734,    /* Ext-C */
    U+2B740-2B81D,    /* Ext-D */
    U+2B820-2CEA1,    /* Ext-E */
    U+2CEB0-2EBE0,    /* Ext-F */
    U+F900-FAD9,      /* 兼容表意文字 */
    U+2F800-2FA1D;    /* 兼容扩展 */
}

html,body {
  background: var(--bg);
  color: var(--text);
  font-family:
    ui-sans-serif, -apple-system, "PingFang SC", "Microsoft YaHei", 
    "Noto Sans CJK SC", "Source Han Sans SC", system-ui, Arial, sans-serif,
    "HanB", "HanA"; ;
  height: 100%;
  margin: 0;
  overflow-y: hidden;
}

/* ---------- 侧栏 ---------- */
.sidebar {
  background: #2E7D5E;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 20px;
  left: 0;
  padding: 1vw;
  position: fixed;
  top: 0;
  bottom: 0;
  width: var(--sidebar-w);
}

.menu-btn {
  background: var(--bg);
  border: none;
  border-radius: 20%;
  box-shadow: var(--shadow);
  color: var(--primary);
  cursor: pointer;
  display: flex;
  aspect-ratio: 1;
  justify-content: center;
  width: 100%;
  align-self: center;
  align-items: center;
}

.menu-lines,
.menu-lines::before,
.menu-lines::after {
  background: var(--primary);
  content: "";
  display: block;
  height: 2px;
  width: 18px;
}

.menu-lines::before {
  position: relative;
  top: -6px;
}

.menu-lines::after {
  position: relative;
  top: 6px;
}

.sidebar-header {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-self: center;
  width: 100%;
  aspect-ratio: 1;
}

/* ---------- 顶栏 ---------- */
.topbar {
  align-items: center;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  display: flex;
  height: 8vh;
  justify-content: space-between;
  padding: 0 10px;
  position: sticky; /* 跟随内容区滚动 */
  top: 0;
  z-index: 10;
}

.topbar-left {
  color: var(--primary);
  font-size: 4vh;
  font-weight: 700;
  height: 100%;            /* 关键：继承父容器 .topbar 的高度 */
  display: flex;           /* 让内部内容垂直居中 */
  align-items: center;
  gap: 8px;
}

.topbar-right {
  height: 100%;            /* 关键：继承父容器 .topbar 的高度 */
  display: flex;           /* 让内部内容垂直居中 */
  align-items: center;
}

.topbar-left .topbar-logo {
  height: 85%;
}

.topbar-right .topbar-logo {
  margin-right: 8px;
}

/* ---------- 主体 ---------- */
.hero {
  height: 92vh;
  align-items: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  padding: 10px 20px;
  max-width: 100vw;
}

.headline {
  color: #3b2618;
  font-size: 36px;
  font-weight: 800;
  letter-spacing: 0.5px;
  line-height: 1.25;
  margin: 20px 0 28px;
}

/* ---------- 提问卡片 ---------- */
.ask-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 750px;
  padding: 20px;
  text-align: left;
  margin-top: 12px;
  margin-bottom: 16px;
}

.input-wrap {
  background: #FFFEFC;
  border: 1px solid var(--line);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  padding: 14px 16px 12px 16px;
  position: relative;
  margin-bottom: 10px;
}

textarea {
  border: none;
  border-radius: 16px;
  font-size: 18px;
  height: 50px;
  line-height: 1.6;
  margin-bottom: 12px;
  min-height: 50px;
  outline: none;
  padding: 0 6px;
  resize: vertical;
  width: 100%;
}

textarea::placeholder {
  color: #9e8778;
}

/* ---------- 标签/按钮 ---------- */
.inline-actions{
  display:flex;
  align-items:center;
  gap:12px;
  flex-wrap:wrap;
}

.chip {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  font-size: 18px;
  gap: 4px;
  padding: 8px 14px 8px 8px;
  text-decoration: none;
  transition: 0.2s ease;
  align-items: center;
}

.chip-primary {
  background: var(--bg);
  border-color: #A8D5C0;
  color: var(--primary);
}

.chip.active {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(46, 125, 94, 0.2); /* 内外发光效果 */
  color: #fff;
}

.chip.active .chip-svg {
  fill: #fff;
}

.chip-icon {
  font-size: 20px;
  font-weight: 700;
  margin-right: 4px;
}

.small-chip {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  font-size: 14px;
  gap: 8px;
  padding: 8px 10px;
  transition: 0.2s;
}

.small-chip:hover {
  background: #FFFBF8;
}

.small-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.small-chip .dot {
  background: var(--primary-weak);
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px var(--primary);
  display: inline-block;
  height: 8px;
  width: 8px;
}

.square-icon {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  cursor: pointer;
  display: inline-grid;
  height: 40px;
  margin-left: auto;
  place-items: center;
  transition: 0.2s;
  width: 40px;
}

.square-icon:hover {
  transform: translateY(-1px);
}

.square-icon.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  margin-left: -2px;
}

/* 24px 图标统一 */
.icon-24 {
  fill: currentColor;
  height: 24px;
  width: 24px;
}

/* 功能按钮行 */
.feature-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-start;
  margin-top: 10px;
  flex-wrap: wrap;
  gap: 8px;
}

/* 侧栏“新对话”按钮圆形化（仅在侧栏内生效） */
.sidebar .chip-primary {
  display: grid;
  font-size: 1vw;
  padding: 0;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
}

.sidebar .chip-primary .chip-icon {
  font-size: 18px;
  margin: 0;
}

/* ---------- 工作区与右侧预览面板 ---------- */
.workspace {
  display: grid;
  grid-template-columns: 1fr;
  height: 92vh;
}

.media-panel {
  align-self: start;
  border: 1px solid var(--line);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  flex: 1;
  height: 92vh;
  margin-right: 20px;
  margin-top: 20px;
  overflow: hidden; /* 面板自身不滚动，内部 grid 滚动 */
  padding-bottom: 16px;
  padding-top: 12px;
  position: relative;
  width: auto;
}

.media-panel.hidden {
  display: none;
  width: 0px;
}

.media-header-wrap {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: flex-start; /* 头部标题靠左排成一行 */
  gap: 6px;                   /* 标题之间的间距 */
  margin-bottom: 10px;
  padding: 3px 16px 0px 16px;
  flex-wrap: nowrap;           /* 不换行 */
}

.media-header {
  color: var(--muted);
  font-size: 16px;
  font-weight: 700;
  margin-left: 5px;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-top-left-radius: 10px;   /* 仅上方圆角 */
  border-top-right-radius: 10px;
  border-bottom-left-radius: 0;   /* 下方直角 */
  border-bottom-right-radius: 0;
  padding: 10px;
}

.media-header.active {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(46, 125, 94, 0.2); /* 内外发光效果 */
  color: #fff;
}


/* 让多个 media-header 同排且不换行 */
.media-header {
  white-space: nowrap;
}

/* 关闭按钮在最右侧 */
#closePanel {
  margin-left: auto;
}

.media-grid {
  align-content: start;
  align-items: start;
  display: grid;
  flex: 1; /* 占满剩余高度 */
  gap: 14px;
  min-height: 0; /* 允许子元素在 flex 容器中正确滚动 */
  overflow-y: auto; /* 只让下方网格区域滚动 */
}

.media-grid.hidden {
  display: none;
}

.show-tapian {
  grid-template-columns: repeat(4, 1fr);
  padding: 7px 16px 18px 20px;
}

.show-det {
  padding: 10px 24px
}

.media-item {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  position: relative; /* 为 ::before 和绝对定位图片做容器 */
}

/* 兼容性：用内边距方案确保高度，避免旧浏览器不识别 aspect-ratio 导致重叠 */
.media-item::before {
  content: "";
  display: block;
  padding-top: 100%;
}

.media-item img {
  display: block;
  left: 50%;
  height: 95%;
  width: 95%;
  object-fit: contain; /* 保持比例 */
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
}

/* 面板打开时，主区域 + 右侧面板并排 */
.content.panel-open .workspace {
  align-items: center;
  grid-template-columns: 55% 45%;
}

.content {
  margin-left: var(--sidebar-w); /* 与侧栏同宽 */
  min-height: 100vh;
  padding: 0 0;
}

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
  :root {
    --sidebar-w: 220px;
  }

  .content.panel-open .workspace {
    grid-template-columns: 55% 45%;
  }

  .media-panel {
    width: 300px;
  }
}

@media (max-width: 640px) {
  :root {
    --sidebar-w: 100%;
  }

  .ask-card {
    padding: 18px;
  }

  .content {
    margin-left: 0;
    margin-top: 8vh;
    height: 92vh;
  }

  .content.panel-open .workspace {
    grid-template-columns: 1fr;
  }

  .headline {
    font-size: 28px;
  }

  .media-panel {
    border-top: 1px solid var(--line);
    padding-left: 0;
    padding-top: 12px;
    width: auto;
  }

  .sidebar {
    align-items: center;
    border-bottom: 1px solid var(--line);
    border-right: none;
    bottom: auto;
    flex-direction: row;
    height: 8vh;
    position: fixed;
    width: 100%;
    padding: 1.5vh;
  }

  .square-icon {
    height: 40px;
    width: 40px;
  }
}

/* ---------- 功能层 ---------- */
/* ---- 图片放大预览 ---- */
.lightbox {
  align-items: center;
  background: rgba(0,0,0,0.8);
  display: flex;
  height: 100%;
  justify-content: center;
  left: 0;
  position: fixed;
  top: 0;
  width: 100%;
  z-index: 9999;
}

.lightbox img {
  border-radius: 8px;
  box-shadow: 0 0 20px rgba(0,0,0,0.5);
  max-height: 90%;
  max-width: 90%;
  object-fit: contain;
}

.lightbox.hidden {
  display: none;
}

/* 右上角关闭按钮 */
.media-panel .close-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 24px;
  position: absolute;
  right: 20px;
  transition: color 0.2s;
}

.media-panel .close-btn:hover {
  color: var(--primary);
}

/* 右下角“＋”按钮 */
.media-item .add-btn {
  background: var(--primary);
  border: none;
  border-radius: 50%;
  box-shadow: var(--shadow);
  color: #fff;
  cursor: pointer;
  display: grid;
  font-size: 20px;
  height: 34px;
  line-height: 1;
  place-items: center;
  position: absolute;
  right: 8px;
  bottom: 8px;
  transition: transform 0.15s ease, opacity 0.2s ease, box-shadow 0.15s ease;
  width: 34px;
  z-index: 1; /* 确保盖在图片上 */
  opacity: 0.95;
}

.media-item .add-btn:hover {
  box-shadow: 0 6px 16px rgba(0,0,0,.12);
  opacity: 1;
  transform: translateY(-1px);
}

/* 选中预览条（位于 input-wrap 内部） */
.chosen-bar {
  margin-bottom: 10px; /* 与 textarea 保持间距 */
}

.chosen-bar.hidden {
  display: none;
}

/* 右侧面板中被选择的卡片高亮（单选反馈） */
.media-item.selected {
  box-shadow: 0 0 0 3px var(--primary) inset;
}

/* 单选模式：预览网格改为单列 1:1 缩略图 */
.chosen-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: 80px; /* 只显示一张 */
  margin-left: 4px;
}

/* 直接追加的预览图片样式（单选逻辑下使用 .chosen-image） */
.chosen-image {
  aspect-ratio: 1 / 1;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  display: block;
  height: 100%;
  object-fit: contain;
  width: 100%;
}

.thumb-item {
  align-items: center;
  aspect-ratio: 1 / 1; /* 保持方形 */
  display: flex;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.thumb-item img {
  height: 100%;
  object-fit: contain;
  width: 100%;
}

/* 缩略图删除按钮（×） */
.remove-thumb {
  align-items: center;
  background: var(--primary);
  border: none;
  border-radius: 50%;
  box-shadow: var(--shadow);
  color: #fff;
  cursor: pointer;
  display: flex;
  font-size: 14px;
  height: 18px;
  justify-content: center;
  line-height: 1;
  position: absolute;
  right: 6px;
  top: 6px;
  width: 18px;
}

.remove-thumb:hover {
  filter: brightness(1.05);
}

/* ---- 检测框覆盖层（HTML 元素版） ----
   说明：覆盖层尺寸与图片保持一致（图片最大占容器 95% 且居中），
        坐标使用百分比定位，缩放自适应。 */
.det-overlay {
  position: absolute;
  inset: 0;
  pointer-events: auto;
  /* 与 .media-item img 的 max-width/height 对齐，并居中 */
  max-width: 95%;
  max-height: 95%;
  left: 2.5%;
  top: 2.5%;
}

/* 公共样式 */
.det-label {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(0, -100%);
  font: 12px/1 sans-serif;
  color: #fff;
  background: var(--det-label-bg);
  padding: 2px 4px;
}

.juzi-box,
.char-box {
  position: absolute;
  box-sizing: border-box;
}

/* 句子框（红） */
.juzi-box {
  border: 2px solid var(--det-juzi);
  z-index: 1;
}
.juzi-box > .det-label {
  background: rgba(255, 77, 79, .85);
}

/* 字符框（蓝） */
.char-box {
  border: 2px solid var(--det-char);
  z-index: 2;
  transition: box-shadow .18s ease;
}
.char-box > .det-label {
  background: rgba(22, 119, 255, .85);
}
.char-box:hover {
  box-shadow: 0 0 12px rgba(22, 119, 255, .9);
}

/* 悬停脉动动画（可由 JS 添加 .hover 切换） */
@keyframes det-pulse {
  0% { box-shadow: 0 0 8px rgba(22, 119, 255, .4); }
  50% { box-shadow: 0 0 20px rgba(22, 119, 255, 1); }
  100% { box-shadow: 0 0 8px rgba(22, 119, 255, .4); }
}
.char-box.hover {
  animation: det-pulse .8s ease-in-out infinite;
}

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

/* 对话框外层容器 */
.message_body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 1000px;
  height: auto;
  overflow: auto;          /* 内容溢出时滚动 */
  scrollbar-width: none;     /* Firefox 隐藏滚动条 */
  -ms-overflow-style: none;  /* 旧版 Edge/IE 隐藏滚动条 */
  padding: 1px;
}

/* 隐藏 .message_body 的滚动条（仍可滚动） */
.message_body::-webkit-scrollbar { width: 0; height: 0; }
.message_body::-webkit-scrollbar-track { background: transparent; }
.message_body::-webkit-scrollbar-thumb { background: transparent; }

/* 单条消息容器：默认靠左 */
.message_item {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  width: 100%;
}

/* 右侧消息：行内元素右对齐 */
.message_item.right {
  justify-content: flex-end;
  flex-wrap: wrap; /* 多图时自动换行 */
  gap: 8px;
}

/* 气泡本体（用于文字消息） */
.message_item .bubble {
  max-width: 90%;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  color: #111;
  font-size: 16px;
  line-height: 1.5;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
  text-align: justify;              /* 气泡内文字两端对齐 */
}

/* 右侧气泡样式 */
.message_item.right .bubble {
  background: #e6f2ff;
  border: 1px solid #BCD8FF; /* 淡蓝色边框，增强层次 */
}

/* 在 message_item 中直接放入 img 时，视为图片气泡 */
.message_item img {
  display: block;
  max-height: 200px;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
}

/* 给左/右两种方向预留不同圆角（针对文字气泡） */
.message_item .bubble {
  border-top-left-radius: 6px;
}
.message_item.right .bubble {
  border-top-right-radius: 6px;
  border-top-left-radius: 14px;
}

.bubble span {
  white-space: pre-wrap; /* 让 \n 变成可见换行，同时保留多空格/制表 */
  tab-size: 4;           /* 可选：控制 \\t 的显示宽度 */
  overflow-wrap: anywhere;
  word-break: break-word;
}

.bubble.char img {
  box-shadow: none;
}

#mediaGrid-char {
  padding: 10px 24px;
}

#mediaGrid-doc {
  padding: 10px 24px;
}

#mediaGrid-char .media-item.hidden{
  display: none;
}

.tapian-char-box {
  position: absolute;
  box-sizing: border-box;
  border: 2px solid var(--det-char);
  z-index: 2;
  transition: box-shadow .18s ease;
  box-shadow: 0 0 12px rgba(22, 119, 255, .9);
}

.doc-box {
  position: absolute;
  box-sizing: border-box;
  border: 2px solid var(--det-juzi);
  z-index: 2;
  transition: box-shadow .18s ease;
  box-shadow: 0 0 12px rgba(255, 77, 79, .85);
}

.tapian-back-btn {
  position: absolute;
  bottom: 14px;
  right: 16px;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;

  background: var(--card);
  color: var(--primary);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);

  font-size: 16px;
  font-weight: 600;
  line-height: 1;
  padding: 8px 12px;
  min-width: 40px;
  min-height: 40px;
  border-radius: 12px;
  transition: transform .15s ease, box-shadow .15s ease, background-color .2s ease, color .2s ease, border-color .2s ease;
}

.doc-back-btn {
  bottom: 36px;
  right: 28px;
}

.tapian-back-btn:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 6px 16px rgba(0,0,0,.12);
  transform: translateY(-1px);
}

.tapian-back-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(0,0,0,.10);
}

.tapian-back-btn:focus-visible {
  outline: 2px solid rgba(46,125,94,.35);
  outline-offset: 2px;
}

.tapian-back-btn.hidden {
  display: none;
}

.tapian-name {
  color: #1677ff;            /* 链接蓝 */
  cursor: pointer;           /* 可点击指针 */
}

.tapian-name:hover {
  color: #0f5bd1;            /* 悬停更深的蓝 */
  text-decoration-thickness: 2px; /* 悬停时下划线稍加粗 */
}

.tapian-name:active {
  color: #0b46a3;            /* 按下态 */
}

.tapian-name:focus-visible {
  outline: 2px solid rgba(22, 119, 255, .45); /* 可见焦点，便于无鼠标导航 */
  outline-offset: 2px;
}

#mediaGrid-doc .hidden {
  display: none;
}

.doc-name {
  color: var(--det-juzi);
  cursor: pointer;           /* 可点击指针 */
}

.doc-name:hover {
  color: #d9363e;            /* 悬停更深的红 */
  text-decoration-thickness: 2px; /* 悬停时下划线稍加粗 */
}

.doc-name:active {
  color: #a8071a;            /* 按下态 */
}

.doc-name:focus-visible {
  outline: 2px solid rgba(255, 77, 79, .45); /* 可见焦点，便于无鼠标导航 */
  outline-offset: 2px;
}

#mediaGrid-char .media-item.small img {
  top: 42%;
}

#mediaGrid-char .media-item.small span {
  position: static;
  font-size: 12px;
  text-align: center;
  white-space: pre-wrap;
  display: block;
  line-height: normal;
  margin-top: 18px;       /* 图片区域与标题之间的间距 */
  margin-bottom: 8px;       /* 图片区域与标题之间的间距 */
  background: transparent;
}

#mediaGrid-doc {
  align-items: stretch;
}

#mediaGrid-doc .media-item.small {
  display: flex;
  flex-direction: column;
}

#mediaGrid-doc .media-item.small::before {
  content: none;
}

#mediaGrid-doc .media-item.small img {
  position: static;
  transform: none;
  padding: 5% 5% 5% 5%;
  width: 100%;
}

#mediaGrid-doc .media-item.small span {
  position: static;
  font-size: 12px;
  text-align: center;
  white-space: pre-wrap;
  display: block;
  line-height: normal;
  background: transparent;
  padding: 0% 5% 5% 5%;
}

.show-tapian-example {
  display: grid;
  gap: 14px;
  margin-right: 4px;
}

.show-tapian-example.hidden {
  display: none;
}

.example-header {
  padding: 2px 16px 6px 20px;
  gap: 4px;
}

.example-header button {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--muted);

  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  padding: 8px 12px;
  margin-right: 4px;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
  transition: transform .15s ease, box-shadow .15s ease, background-color .2s ease, color .2s ease, border-color .2s ease;
}

.example-header button:hover {
  background: #FFFBF8;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0,0,0,.12);
}

.example-header button:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(0,0,0,.10);
}

.example-header button:focus-visible {
  outline: 2px solid rgba(46,125,94,.35);
  outline-offset: 2px;
}

.example-header button.active {
  background: var(--primary);
  color: #fff;
  border: 1px solid var(--primary);
  box-shadow: 0 0 0 2px rgba(46, 125, 94, 0.2);
}

.think-span {
  color: var(--det-juzi);
}
.answer-span{
  color: #1677ff;
}

/* 翻译按钮 */
.fanyi-btn {
  margin-left: 14px;           /* 与文字间距 */
  padding: 0px 10px;
  font-size: 12px;
  line-height: 1.6;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
  transition: box-shadow .15s ease, transform .15s ease, background-color .2s;
  display: inline-block;       /* 使其按内容收缩 */
  text-align: center;
  flex: 0 0 auto;
  margin-top: 3px;
}

.fanyi-btn:hover {
  background: #FFFBF8;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0,0,0,.12);
}

/* 避免按钮把文字挤到下一行太窄，并让注释和按钮同行排布 */
.zhushi-span {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  margin-top: 2px; /* 行间距 */
}

.zhushi-span img{
  margin: 0 4px;
  border: none;
  border-radius: 0px;
  box-shadow: none;
}

/* 翻译结果块 */
.fanyi-result {
  display: block;                 /* 占满一行 */
  margin: 10px 6px 12px;             /* 与上下内容留间距 */
  padding: 2px 10px 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 3px solid var(--primary);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;          /* 保留换行 */
  word-break: break-word;         /* 防长段落溢出 */
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
  animation: fanyiFade .18s ease both; /* 微动画 */
}

.fanyi-result.hidden {
  display: none;
}


.det-clear-btn {
  position: absolute;
  bottom: 36px;
  right: 24px;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;

  background: var(--card);
  color: var(--primary);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);

  font-size: 16px;
  font-weight: 600;
  line-height: 1;
  padding: 8px 12px;
  min-width: 40px;
  min-height: 40px;
  border-radius: 12px;
  transition: transform .15s ease, box-shadow .15s ease, background-color .2s ease, color .2s ease, border-color .2s ease;
}

.det-clear-btn:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 6px 16px rgba(0,0,0,.12);
  transform: translateY(-1px);
}

.det-clear-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(0,0,0,.10);
}

.det-clear-btn:focus-visible {
  outline: 2px solid rgba(46,125,94,.35);
  outline-offset: 2px;
}

.det-clear-btn.hidden {
  display: none;
}

/* 翻译按钮 */
.chose-candidate-char {
  margin-left: 14px;           /* 与文字间距 */
  padding: 0px 10px;
  font-size: 12px;
  line-height: 1.6;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
  transition: box-shadow .15s ease, transform .15s ease, background-color .2s;
  display: inline-block;       /* 使其按内容收缩 */
  text-align: center;
  flex: 0 0 auto;
  margin-top: 3px;
}

.chose-candidate-char:hover {
  background: #FFFBF8;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0,0,0,.12);
}

/* 避免按钮把文字挤到下一行太窄，并让注释和按钮同行排布 */
.candidate-char {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  margin-top: 2px; /* 行间距 */
}

.candidate-char img{
  margin: 0 4px;
  border: none;
  border-radius: 0px;
  box-shadow: none;
}

.show-chosen-hanzi {
  padding: 0.4rem 1.3rem;
  border: 1px solid #d4e3d7;   /* 淡绿色边框 */
  border-radius: 12px;
  background-color: #f7faf8;   /* 浅绿色背景 */
  font-size: 0.95rem;
  color: #333;
  line-height: 1.5;
  display: flex;              /* 横向排列 */
  justify-content: space-between;
  align-items: center;
}

.show-chosen-hanzi .chosen-hanzi {
  font-weight: bold;
  color: #2b7a3d;   /* 深绿色，突出显示所选汉字 */
  font-size: 1.1rem;
}

.show-chosen-hanzi.hidden {
  display: none;
}

.clear-hanzi-btn {
  background: none;
  border: none;
  color: #999;
  font-size: 1.2rem;
  cursor: pointer;
  transition: color 0.2s;
}

.clear-hanzi-btn:hover {
  color: #2b7a3d;   /* hover 时变红，提示删除 */
}

.floating-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background-color: #2E7D5E;
  color: white;
  border: none;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  font-size: 36px;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0,0,0,0.3);
  z-index: 1000;
  padding-top: 10px;
  padding-left: 8px;
}
.floating-btn:hover {
  background-color: #256b51;
}
.floating-btn.hidden {
  display: none;
}

.ask-card.hidden {
  display: none;
}

.askCard-show-btn.hidden {
  display: none;
}

/* top-right collapse button inside ask-card */
.collapse-btn {
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0px 10px;
  border-radius: 8px;
  transition: background-color .2s ease, color .2s ease, transform .1s ease;
  z-index: 2;
}
.collapse-btn:hover {
  color: var(--primary);
  background: rgba(46, 125, 94, .08);
  transform: translateY(-1px);
}
.collapse-btn:active {
  transform: translateY(0);
}
.collapse-btn:focus-visible {
  outline: 2px solid rgba(46,125,94,.35);
  outline-offset: 2px;
}
.collapse-btn.hidden {
  display: none;
}

/* Expand button shown only when the form is collapsed */
.askCard-show-btn {
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  border: 1px solid var(--primary);
  box-shadow: var(--shadow);
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  padding: 4px 10px;
  min-width: 36px;
  min-height: 36px;
  border-radius: 12px;
  transition: transform .15s ease, box-shadow .15s ease, background-color .2s ease, color .2s ease, border-color .2s ease;
  margin: 10px;
}
/* When ask-card is collapsed, reveal the expand button right after it */
.ask-card.collapsed + .askCard-show-btn {
  display: inline-flex !important;     /* override any .hidden utility */
}
.askCard-show-btn:hover {
  filter: brightness(1.02);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0,0,0,.12);
}
.askCard-show-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(0,0,0,.10);
}
.askCard-show-btn:focus-visible {
  outline: 2px solid rgba(46,125,94,.35);
  outline-offset: 2px;
}

/* Responsive refinements */
@media (max-width: 640px) {
  .collapse-btn {
    top: 6px;
    right: 6px;
  }
  .askCard-show-btn {
    font-size: 18px;
    min-width: 40px;
    min-height: 40px;
    padding: 8px 12px;
  }
}

/* 基础：确保移动端视口正确 */
@viewport { width: device-width; }
@-ms-viewport { width: device-width; }
/* <head> 里也加上：<meta name="viewport" content="width=device-width, initial-scale=1"> */

/* 仅在手机宽度下处理（可按你项目断点调整） */
@media (max-width: 640px) {
  /* 展开时隐藏 hero，让 media-panel 占满 workspace（甚至全屏） */
  .content.panel-open .hero {
    display: none !important;
  }
  .workspace {
    height: 84vh;
  }
  .hero {
    height: 84vh;
  }
  .media-header {
    font-size: 10px;
  }
  .media-panel {
    height: 84vh;
    margin-right: 10px;
    margin-left: 10px;
  }
  .show-tapian {
    grid-template-columns: repeat(2, 1fr);
  }
  .floating-btn {
    bottom: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
    padding-top: 3px;
    padding-left: 7px;
  }
  .juzi-box {
    border: 1px solid var(--det-juzi);
  }
  .det-label {
    font: 8px/1 sans-serif;
  }
  .char-box {
    border: 1px solid var(--det-char);
  }
  .menu-btn {
    height: 120%;
    width: auto;
  }
  .sidebar-header {
    height: 120%;
    width: auto;
  }
  .sidebar .chip-primary {
    font-size: 2vh;
  }
}
