/* ==========================================================================
   图表解读（/xiaolan-figure.html）
   外壳与侧栏复用 BlueSeek 标准结构（.xiaolan-shell / .xiaolan-gpt-sidebar），
   这里只定义右侧「解读结果 + 结果图」工作台。
   ========================================================================== */

.xlf-body {
  background:
    radial-gradient(circle at 10% -8%, rgba(60, 208, 198, 0.2), transparent 26rem),
    radial-gradient(circle at 94% 2%, rgba(17, 101, 216, 0.16), transparent 30rem),
    linear-gradient(180deg, #f7fafd 0%, #eef4fa 100%);
}

.xlf-body [hidden] { display: none !important; }

/* ---- 让标准外壳铺满视口（顶栏在 xiaolan-agent 页面是隐藏的） ---- */
.xlf-body .dashboard-main { gap: 0; padding: 0; min-height: 100vh; }
.xlf-body .xiaolan-shell {
  width: 100%;
  max-width: none;
  margin: 0;
  display: flex;
  flex: 1;
  min-height: 0;
}
.xlf-body .xiaolan-workspace {
  flex: 1;
  min-height: 0;
  display: flex;
  border: 0;
  border-radius: 0;
  background: #fff;
  box-shadow: none;
}
.xlf-body .xiaolan-gpt-workspace { min-height: 100vh; flex: 1; }
.xlf-body .xiaolan-gpt-layout { flex: 1 1 auto; width: 100%; min-height: 0; height: 100vh; }

.xlf-body .xiaolan-gpt-main.xlf-main {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  min-height: 0;
  padding: 18px 22px;
  background: #fff;
}

/* ---------------- 页头 ---------------- */
.xlf-page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.xlf-page-head h1 {
  margin: 0;
  font-family: "Source Serif 4", "Noto Sans SC", serif;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: 0.4px;
  color: #0f2f52;
}

.xlf-page-head p { margin: 6px 0 0; font-size: 12.8px; color: var(--muted); }

.xlf-head-tools { display: flex; align-items: center; gap: 8px; flex: none; }

.xlf-seg {
  display: flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.xlf-seg button {
  border: 0;
  background: transparent;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  color: #456181;
  cursor: pointer;
}

.xlf-seg button.is-active {
  background: #e8f1ff;
  color: #1657b8;
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(22, 87, 184, 0.16);
}

.xlf-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: #33506f;
  font-size: 12.5px;
  cursor: pointer;
}

.xlf-ghost svg { width: 15px; height: 15px; }
.xlf-ghost:hover { border-color: rgba(17, 101, 216, 0.3); color: var(--primary); }

.xlf-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------------- 工作台 ---------------- */
.xlf-board {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.24fr) minmax(400px, 0.94fr);
  gap: 16px;
}

.xlf-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(18, 47, 84, 0.07);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(17, 48, 86, 0.06);
}

.xlf-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 18px 11px;
  border-bottom: 1px solid rgba(18, 47, 84, 0.07);
}

.xlf-card-title {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  font-weight: 600;
  color: #173758;
}

.xlf-pill {
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(120, 140, 165, 0.28);
  background: rgba(120, 140, 165, 0.1);
  color: #64778f;
  font-size: 11px;
  font-weight: 600;
}

.xlf-pill.is-done {
  border-color: rgba(15, 153, 103, 0.2);
  background: rgba(15, 153, 103, 0.1);
  color: #0f8a5e;
}

.xlf-pill.is-running {
  border-color: rgba(17, 101, 216, 0.2);
  background: rgba(17, 101, 216, 0.09);
  color: var(--primary);
}

.xlf-pill.is-failed {
  border-color: rgba(221, 91, 91, 0.24);
  background: rgba(221, 91, 91, 0.1);
  color: #c34a4a;
}

.xlf-stamp { font-size: 11.5px; color: #8b9cb2; }

.xlf-notes {
  margin: 0;
  padding: 10px 18px;
  border-bottom: 1px solid rgba(18, 47, 84, 0.06);
  background: rgba(246, 250, 255, 0.7);
  font-size: 12px;
  color: #7c8fa6;
}

.xlf-hint {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 12px 18px 0;
  padding: 9px 12px;
  border: 1px solid rgba(231, 152, 28, 0.28);
  border-radius: 10px;
  background: rgba(231, 152, 28, 0.08);
  color: #96651a;
  font-size: 12.4px;
  line-height: 1.55;
}

.xlf-hint svg { width: 14px; height: 14px; flex: none; margin-top: 2px; }

.xlf-idle {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
}

.xlf-idle-icon { color: rgba(17, 101, 216, 0.35); }
.xlf-idle-icon svg { width: 54px; height: 54px; }
.xlf-idle strong { font-size: 13.6px; color: #2c4a6a; }
.xlf-idle p { margin: 0; max-width: 320px; font-size: 12.4px; line-height: 1.7; color: #7d8fa6; }

.xlf-loading {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 26px;
}

.xlf-loading p { margin: 0; font-size: 12.8px; color: #7d8fa6; }

.xlf-spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid rgba(17, 101, 216, 0.16);
  border-top-color: var(--primary);
  animation: xlf-spin 1s linear infinite;
}

@keyframes xlf-spin { to { transform: rotate(360deg); } }

.xlf-skel { display: grid; gap: 8px; width: min(400px, 100%); }

.xlf-skel i {
  display: block;
  height: 9px;
  border-radius: 6px;
  background: linear-gradient(90deg, #eef3f9, #e3ebf5, #eef3f9);
  background-size: 200% 100%;
  animation: xlf-sh 1.6s ease-in-out infinite;
}

.xlf-skel i:nth-child(2) { width: 86%; }
.xlf-skel i:nth-child(3) { width: 68%; }

@keyframes xlf-sh {
  0% { background-position: 0 0; }
  100% { background-position: 200% 0; }
}

.xlf-doc {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 6px 22px 18px;
}

.xlf-doc h2 {
  margin: 18px 0 9px;
  font-family: "Source Serif 4", "Noto Sans SC", serif;
  font-size: 15px;
  font-weight: 600;
  color: #0f2f52;
}

.xlf-doc h2:first-child { margin-top: 14px; }

.xlf-doc p {
  margin: 0 0 9px;
  font-size: 13.4px;
  line-height: 1.92;
  color: #29465f;
}

.xlf-doc p .xlf-idx { margin-right: 6px; color: #8ba0b8; }
.xlf-doc strong { font-weight: 600; color: #11365c; }
.xlf-doc sup { font-size: 0.72em; }

.xlf-error {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 26px;
  text-align: center;
}

.xlf-error strong { color: #c34a4a; font-size: 13.6px; }
.xlf-error p { margin: 0; max-width: 420px; font-size: 12.4px; line-height: 1.7; color: #7d8fa6; }

/* ---------------- 底部操作 ---------------- */
.xlf-foot {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 10px 16px;
  border-top: 1px solid rgba(18, 47, 84, 0.07);
  background: rgba(250, 252, 255, 0.82);
}

.xlf-foot-note { font-size: 11.6px; color: #8b9cb2; }
.xlf-foot-actions { display: flex; align-items: center; gap: 8px; }

.xlf-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: #2f4f70;
  font-size: 12.5px;
  cursor: pointer;
}

.xlf-btn svg { width: 14px; height: 14px; }
.xlf-btn:hover:not(:disabled) { border-color: rgba(17, 101, 216, 0.3); color: var(--primary); }
.xlf-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.xlf-btn-primary {
  border-color: rgba(22, 87, 184, 0.18);
  background: #e8f1ff;
  color: #1657b8;
  font-weight: 600;
}

.xlf-btn-primary:hover:not(:disabled) {
  border-color: rgba(22, 87, 184, 0.3);
  background: #dcebff;
  color: #1657b8;
}

.xlf-download-wrap { position: relative; }

.xlf-menu {
  position: absolute;
  right: 0;
  bottom: 44px;
  z-index: 20;
  min-width: 150px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 16px 34px rgba(17, 48, 86, 0.14);
}

.xlf-menu button {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #2f4f70;
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
}

.xlf-menu button:hover { background: rgba(17, 101, 216, 0.07); }

/* ---------------- 结果图 ---------------- */
.xlf-figure-tools { display: flex; align-items: center; gap: 2px; }

.xlf-iconbtn {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #7d8fa6;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

.xlf-iconbtn:hover:not(:disabled) { background: rgba(17, 101, 216, 0.07); color: var(--primary); }
.xlf-iconbtn:disabled { opacity: 0.4; cursor: not-allowed; }

.xlf-figure-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 16px;
  overflow: auto;
  background: linear-gradient(0deg, rgba(245, 249, 254, 0.6), rgba(255, 255, 255, 0)), #fff;
}

.xlf-figure-stage.is-dragover { background: rgba(17, 101, 216, 0.06); }

.xlf-figure {
  max-width: 100%;
  max-height: 100%;
  border-radius: 6px;
  transform-origin: center center;
  transition: transform 0.16s ease;
}

.xlf-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: min(330px, 100%);
  padding: 26px 20px;
  border: 1.5px dashed rgba(17, 101, 216, 0.28);
  border-radius: 14px;
  background: rgba(246, 250, 255, 0.7);
  text-align: center;
}

.xlf-dropzone svg { width: 46px; height: 46px; color: rgba(17, 101, 216, 0.42); }
.xlf-dropzone strong { font-size: 13.4px; color: #2c4a6a; }
.xlf-dropzone p { margin: 0 0 6px; font-size: 12px; color: #7d8fa6; }

.xlf-chart-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 13px;
  border: 1px solid rgba(22, 87, 184, 0.22);
  border-radius: 10px;
  background: #e8f1ff;
  color: #1657b8;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.xlf-chart-btn:hover { background: #dcebff; border-color: rgba(22, 87, 184, 0.32); }
.xlf-chart-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.xlf-spark { font-size: 13px; }

.xlf-figure-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 16px 10px;
  border-top: 1px solid rgba(18, 47, 84, 0.07);
}

.xlf-figure-caption {
  min-width: 0;
  font-size: 12px;
  color: #7d8fa6;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.xlf-note-row {
  display: grid;
  gap: 6px;
  padding: 0 16px 12px;
}

.xlf-note-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #6c829d;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}

.xlf-note-toggle svg { width: 13px; height: 13px; transition: transform 0.16s ease; }
.xlf-note-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }

.xlf-note {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fbfdff;
  color: #29465f;
  font-size: 12.4px;
  line-height: 1.7;
  resize: vertical;
}

.xlf-note:focus { outline: 2px solid rgba(17, 101, 216, 0.16); border-color: rgba(17, 101, 216, 0.32); }

/* ---------------- toast ---------------- */
.xlf-toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%);
  z-index: 60;
  padding: 9px 16px;
  border-radius: 10px;
  background: rgba(17, 48, 86, 0.92);
  color: #fff;
  font-size: 12.6px;
  box-shadow: 0 14px 30px rgba(17, 48, 86, 0.24);
}

/* ---------------- 操作引导 ---------------- */
.xlf-page-title { display: flex; align-items: center; gap: 12px; }

.xlf-tour-replay {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px 4px 8px;
  border: 1px solid #cfe9d8;
  border-radius: 999px;
  background: #ecf8f0;
  color: #2b7a4b;
  font-size: 12px;
  cursor: pointer;
}

.xlf-tour-replay svg { width: 13px; height: 13px; }
.xlf-tour-replay:hover { color: #22623c; border-color: #b7ddc6; background: #e1f3e8; }

.xlf-tour { position: fixed; inset: 0; z-index: 2147483000; }
.xlf-tour[hidden] { display: none; }

.xlf-tour-spot {
  position: absolute;
  z-index: 1;
  border-radius: 12px;
  outline: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 0 9999px rgba(9, 20, 35, 0.58);
  transition: left 0.22s ease, top 0.22s ease, width 0.22s ease, height 0.22s ease;
  pointer-events: none;
}

.xlf-tour-card {
  position: fixed;
  z-index: 2;
  width: 360px;
  max-width: calc(100vw - 32px);
  padding: 18px 20px 16px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 24px 60px rgba(8, 20, 40, 0.3);
  transition: left 0.22s ease, top 0.22s ease;
}

.xlf-tour-card h2 {
  margin: 0 32px 8px 0;
  color: #0f2f52;
  font-size: 16px;
  font-weight: 600;
}

.xlf-tour-card p {
  margin: 0 0 18px;
  color: #5b7391;
  font-size: 13px;
  line-height: 1.75;
}

.xlf-tour-close {
  position: absolute;
  top: 10px;
  right: 12px;
  padding: 4px;
  border: 0;
  background: transparent;
  color: #93a7bd;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.xlf-tour-close:hover { color: #2f4f70; }

.xlf-tour-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.xlf-tour-step { color: #93a7bd; font-size: 12px; }

.xlf-tour-actions { display: flex; align-items: center; gap: 6px; }

.xlf-tour-skip {
  padding: 6px 10px;
  border: 0;
  background: transparent;
  color: #6c829d;
  font-size: 13px;
  cursor: pointer;
}

.xlf-tour-skip:hover { color: #2f4f70; }

.xlf-tour-next {
  padding: 8px 18px;
  border: 0;
  border-radius: 9px;
  background: #1657b8;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.xlf-tour-next:hover { background: #124a9e; }

/* ---------------- responsive ---------------- */
@media (max-width: 1280px) {
  .xlf-body .xiaolan-gpt-layout { height: auto; min-height: 100vh; }
  .xlf-board { grid-template-columns: minmax(0, 1fr); }
  .xlf-card { min-height: 520px; }
  .xlf-figure-stage { min-height: 340px; }
}

@media (max-width: 900px) {
  .xlf-page-head { flex-direction: column; align-items: flex-start; }
  .xlf-body .xiaolan-gpt-main.xlf-main { padding: 14px; }
}

/* ---- 侧栏历史项：标准结构只有图标 + 标题，这里补一行时间 ---- */
.xlf-body .xiaolan-gpt-history-item {
  grid-template-columns: 16px minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 8px;
  row-gap: 1px;
  align-items: center;
}

.xlf-body .xiaolan-gpt-history-item .xiaolan-history-item-icon {
  grid-column: 1;
  grid-row: 1 / span 2;
  width: 16px;
  height: 16px;
}

.xlf-body .xiaolan-gpt-history-item strong {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.xlf-body .xiaolan-gpt-history-item time {
  grid-column: 2;
  grid-row: 2;
  color: rgba(21, 53, 91, 0.62);
  font-size: 11.5px;
  line-height: 1.4;
}

.xlf-body .xiaolan-gpt-history-item.is-active time { color: rgba(17, 101, 216, 0.7); }

/* ---------------- 选图弹窗 ---------------- */
.xlf-modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 35, 60, 0.38);
  backdrop-filter: blur(2px);
}

.xlf-modal-card {
  display: flex;
  flex-direction: column;
  width: min(880px, 100%);
  max-height: min(720px, 88vh);
  overflow: hidden;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 30px 70px rgba(15, 40, 70, 0.24);
}

.xlf-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 12px;
  border-bottom: 1px solid rgba(18, 47, 84, 0.07);
  font-size: 14px;
  color: #173758;
}

.xlf-modal-close {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #7d8fa6;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.xlf-modal-close:hover { background: rgba(17, 101, 216, 0.08); color: var(--primary); }

.xlf-picker-tabs {
  display: flex;
  gap: 4px;
  padding: 10px 18px 0;
  border-bottom: 1px solid rgba(18, 47, 84, 0.06);
}

.xlf-picker-tabs button {
  padding: 8px 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: #5f7696;
  font-size: 13px;
  cursor: pointer;
}

.xlf-picker-tabs button.is-active {
  border-bottom-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

.xlf-picker-body {
  flex: 1;
  min-height: 0;
  padding: 14px 18px 18px;
  overflow: auto;
}

.xlf-picker-select {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 12.6px;
  color: #5f7696;
}

.xlf-picker-select select {
  min-width: 320px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: #29465f;
  font-size: 12.6px;
}

.xlf-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.xlf-picker-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border: 1px solid rgba(18, 47, 84, 0.08);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  text-align: left;
}

.xlf-picker-item:hover,
.xlf-picker-item.is-active {
  border-color: rgba(17, 101, 216, 0.35);
  box-shadow: 0 8px 18px rgba(17, 48, 86, 0.08);
}

.xlf-picker-item img {
  width: 100%;
  height: 96px;
  object-fit: contain;
  border-radius: 6px;
  background: #f6f9fd;
}

.xlf-picker-item span {
  font-size: 11.6px;
  color: #29465f;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.xlf-picker-item small {
  font-size: 10.8px;
  color: #8b9cb2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.xlf-picker-empty {
  padding: 28px 0;
  text-align: center;
  font-size: 12.6px;
  color: #8b9cb2;
}

.xlf-picker-local {
  display: grid;
  gap: 12px;
  padding: 18px 0;
  text-align: center;
}

.xlf-picker-local p { margin: 0; font-size: 12.6px; color: #7d8fa6; }

.xlf-picker-kb-note {
  margin: 0 0 10px;
  font-size: 12.6px;
  color: #7d8fa6;
}
