.document-ai-tools {
  display: grid;
  grid-template-columns: 16.5rem 1fr;
  gap: 1rem;
  margin-top: 0.8rem;
  /* 默认撑高生成区域，避免左侧导航被遮挡 */
  min-height: 38rem;
}

/* 让右侧生成/输出两张卡片至少撑满高度 */
.document-ai-tools__right {
  min-height: 38rem;
}

.document-ai-tools__left,
.document-ai-tools__card {
  background: var(--theme-front-color, #f5f7fd);
  border: 1px solid var(--theme-header-border-color, rgba(0, 0, 0, 0.08));
  border-radius: 0.65rem;
  padding: 1rem;
}

.document-ai-tools__left h2 {
  margin: 0 0 0.35rem;
}

.document-ai-tools__left p {
  margin: 0 0 0.65rem;
  color: var(--theme-text-secondary, #666);
}

.document-ai-tools__tabs {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.document-ai-tools__tabs button {
  border: 1px solid var(--theme-header-border-color, #ddd);
  background: transparent;
  color: var(--theme-text-color, #333);
  border-radius: 0.5rem;
  height: 2.2rem;
  cursor: pointer;
}

.document-ai-tools__tabs button.is-active {
  background: var(--theme-color, #3eaf7c);
  border-color: var(--theme-color, #3eaf7c);
  color: #fff;
}

.document-ai-tools__upload-tip {
  margin: -0.15rem 0 0.55rem;
  font-size: 0.78rem;
  color: var(--theme-text-secondary, #666);
  line-height: 1.6;
}

.document-ai-tools__right {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.document-ai-tools__label {
  display: block;
  font-size: 0.82rem;
  margin-bottom: 0.35rem;
}

.document-ai-tools__textarea {
  width: 100%;
  min-height: 7rem;
  border: 1px solid #cfd4db;
  border-radius: 0.45rem;
  background: var(--theme-white, #fff);
  color: var(--theme-text-color, #333);
  padding: 0.55rem 0.65rem;
  box-sizing: border-box;
  margin-bottom: 0.8rem;
}

.document-ai-tools__upload {
  border: 1px dashed #8fa2b8;
  border-radius: 0.5rem;
  padding: 1rem;
  text-align: center;
  position: relative;
  margin-bottom: 0.8rem;
}

.document-ai-tools__upload input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.document-ai-tools__actions {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
}

.document-ai-tools__quota[hidden] {
  display: none !important;
}

.document-ai-tools__quota {
  margin-left: auto;
  padding: 0.55rem 0.75rem;
  border-radius: 0.7rem;
  border: 1px solid var(--theme-header-border-color, rgba(0, 0, 0, 0.1));
  background: var(--theme-front-color, #f5f7fd);
  min-width: 14.5rem;
}

.document-ai-tools__quota-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: #caa43b;
  margin-bottom: 0.25rem;
}

.document-ai-tools__quota-list {
  display: grid;
  gap: 0.2rem;
}

.document-ai-tools__quota-item {
  font-size: 0.78rem;
  color: rgba(202, 164, 59, 0.92);
  line-height: 1.35;
}

.document-ai-tools__quota-item strong {
  color: #d6b24a;
  font-weight: 800;
}

.document-ai-tools__online-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: var(--theme-text-secondary, #666);
}

.document-ai-tools__online-toggle input {
  width: 0.95rem;
  height: 0.95rem;
}

.document-ai-tools__sources {
  margin-top: 0.7rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.document-ai-tools__sources[hidden] {
  display: none !important;
}

.document-ai-tools__sources-title {
  width: 100%;
  font-size: 0.8rem;
  color: var(--theme-text-secondary, #666);
}

.document-ai-tools__source-item {
  display: inline-block;
  max-width: 100%;
  font-size: 0.78rem;
  color: var(--theme-link-color, #2563eb);
  border: 1px solid var(--theme-header-border-color, rgba(0, 0, 0, 0.1));
  border-radius: 999px;
  padding: 0.18rem 0.58rem;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-ai-tools__image[hidden] {
  display: none !important;
}

.document-ai-tools__image {
  margin-top: 0.7rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.document-ai-tools__image-link {
  display: inline-block;
  font-size: 0.82rem;
  color: var(--theme-link-color, #2563eb);
  text-decoration: none;
  margin-bottom: 0.55rem;
}

.document-ai-tools__image-wrap {
  position: relative;
  display: inline-block;
  max-width: 100%;
}

.document-ai-tools__image-tile {
  position: relative;
  display: block;
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--theme-header-border-color, rgba(0, 0, 0, 0.08));
  border-radius: 0.75rem;
  background: var(--theme-white, #fff);
  text-align: left;
  cursor: zoom-in;
  box-sizing: border-box;
}

.document-ai-tools__image-tile--loading {
  cursor: default;
}

.document-ai-tools__img-wait {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 0.6rem;
  border: 1px dashed rgba(148, 163, 184, 0.45);
  background: rgba(148, 163, 184, 0.08);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 0.55rem;
}

.document-ai-tools__img-wait-bar {
  width: min(240px, 82%);
  height: 0.38rem;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(148, 163, 184, 0.25);
}

.document-ai-tools__img-wait-bar > span {
  display: block;
  width: 35%;
  height: 100%;
  background: var(--theme-color, #3eaf7c);
  border-radius: inherit;
  animation: document-ai-tools-loading 1.35s ease-in-out infinite;
}

.document-ai-tools__img-wait-text {
  font-size: 0.85rem;
  color: var(--theme-text-secondary, #64748b);
}

.document-ai-tools__img-wait-text--vip {
  color: #d6b24a;
  font-weight: 700;
}

.document-ai-tools__tile-actions {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 3;
  display: none;
}

.document-ai-tools__image-tile:hover .document-ai-tools__tile-actions,
.document-ai-tools__image-tile.is-actions .document-ai-tools__tile-actions {
  display: block;
}

.document-ai-tools__tile-download {
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: rgba(2, 6, 23, 0.35);
  color: rgba(241, 245, 249, 0.95);
  border-radius: 0.5rem;
  padding: 0.25rem 0.55rem;
  font-size: 0.78rem;
  cursor: pointer;
}

.document-ai-tools__tile-download:active {
  transform: translateY(1px);
}

.document-ai-tools__image-tile.is-active {
  border-color: var(--theme-color, #3eaf7c);
  box-shadow: 0 0 0 1px rgba(62, 175, 124, 0.18);
}

.document-ai-tools__image-download {
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

.document-ai-tools__wm {
  position: absolute;
  top: 0.55rem;
  left: 0.55rem;
  z-index: 2;
  font-size: 0.82rem;
  font-weight: 700;
  color: rgba(148, 163, 184, 0.78);
  border: 1px solid rgba(148, 163, 184, 0.65);
  border-radius: 0.35rem;
  padding: 0.2rem 0.38rem;
  background: rgba(2, 6, 23, 0.14);
  transform: rotate(-12deg);
  pointer-events: none;
  user-select: none;
}

.document-ai-tools__image-img {
  display: block;
  width: 100%;
  max-width: none;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 0.6rem;
  border: 1px solid rgba(0, 0, 0, 0.08);
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: auto;
}

.document-ai-tools__image-img--preview {
  cursor: zoom-in;
}

.document-ai-tools__img-modal[hidden] {
  display: none !important;
}

.document-ai-tools__img-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
}

.document-ai-tools__img-modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
}

.document-ai-tools__img-modal-body {
  position: absolute;
  inset: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.document-ai-tools__img-modal-wrap {
  position: relative;
  max-width: 100%;
  max-height: 100%;
}

.document-ai-tools__img-modal-img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  border-radius: 0.55rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}

.document-ai-tools__img-modal-close {
  position: absolute;
  top: 0;
  right: 0;
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: #0f172a;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

.document-ai-tools__loading[hidden] {
  display: none !important;
}

.document-ai-tools__loading {
  margin-top: 0.85rem;
}

.document-ai-tools__loading-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--theme-text-color, #334155);
  margin-bottom: 0.35rem;
}

.document-ai-tools__loading-track {
  position: relative;
  width: 100%;
  height: 0.34rem;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(148, 163, 184, 0.28);
}

.document-ai-tools__loading-bar {
  display: block;
  width: 35%;
  height: 100%;
  border-radius: inherit;
  background: #3b82f6;
  animation: document-ai-tools-loading 1.35s ease-in-out infinite;
  transform-origin: left center;
}

.document-ai-tools__loading-sub {
  margin-top: 0.4rem;
  font-size: 0.88rem;
  color: var(--theme-text-secondary, #64748b);
}

@keyframes document-ai-tools-loading {
  0% {
    transform: translateX(-110%);
  }
  50% {
    transform: translateX(115%);
  }
  100% {
    transform: translateX(260%);
  }
}

.document-ai-tools__btn {
  border: 1px solid var(--theme-header-border-color, #ddd);
  border-radius: 0.45rem;
  padding: 0.42rem 0.9rem;
  background: transparent;
  cursor: pointer;
  color: var(--theme-text-color, #333);
}

.document-ai-tools__btn--primary {
  background: var(--theme-color, #3eaf7c);
  border-color: var(--theme-color, #3eaf7c);
  color: #fff;
}

.document-ai-tools__hint,
.document-ai-tools__meta {
  font-size: 0.78rem;
  color: var(--theme-text-secondary, #666);
  margin: 0.6rem 0 0;
}

.document-ai-tools__result-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.document-ai-tools__result {
  margin: 0.6rem 0 0;
  min-height: 10rem;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--theme-white, #fff);
  border: 1px solid #d7dce3;
  border-radius: 0.5rem;
  padding: 0.75rem;
  font-size: 0.88rem;
  line-height: 1.6;
}

html.dark .document-ai-tools,
html body.dark .document-ai-tools {
  color-scheme: dark;
}

html.dark .document-ai-tools__left,
html.dark .document-ai-tools__card,
html body.dark .document-ai-tools__left,
html body.dark .document-ai-tools__card {
  background: #111827;
  border-color: rgba(148, 163, 184, 0.24);
}

html.dark .document-ai-tools__left h2,
html.dark .document-ai-tools__label,
html.dark .document-ai-tools__result-head h3,
html body.dark .document-ai-tools__left h2,
html body.dark .document-ai-tools__label,
html body.dark .document-ai-tools__result-head h3 {
  color: rgba(248, 250, 252, 0.94);
}

html.dark .document-ai-tools__left p,
html.dark .document-ai-tools__hint,
html.dark .document-ai-tools__meta,
html.dark .document-ai-tools__sources-title,
html.dark .document-ai-tools__online-toggle,
html.dark .document-ai-tools__upload-tip,
html body.dark .document-ai-tools__left p,
html body.dark .document-ai-tools__hint,
html body.dark .document-ai-tools__meta,
html body.dark .document-ai-tools__sources-title,
html body.dark .document-ai-tools__online-toggle,
html body.dark .document-ai-tools__upload-tip {
  color: rgba(203, 213, 225, 0.78);
}

html.dark .document-ai-tools__source-item,
html body.dark .document-ai-tools__source-item {
  color: #93c5fd;
  border-color: rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.35);
}

html.dark .document-ai-tools__image,
html body.dark .document-ai-tools__image {
  background: transparent;
}

html.dark .document-ai-tools__image-title,
html body.dark .document-ai-tools__image-title {
  color: rgba(203, 213, 225, 0.78);
}

html.dark .document-ai-tools__image-tile,
html body.dark .document-ai-tools__image-tile {
  background: #0b1220;
  border-color: rgba(148, 163, 184, 0.28);
}

html.dark .document-ai-tools__tile-download,
html body.dark .document-ai-tools__tile-download {
  background: rgba(15, 23, 42, 0.55);
  border-color: rgba(148, 163, 184, 0.45);
  color: rgba(241, 245, 249, 0.92);
}

html.dark .document-ai-tools__img-wait,
html body.dark .document-ai-tools__img-wait {
  border-color: rgba(148, 163, 184, 0.35);
  background: rgba(148, 163, 184, 0.08);
}

html.dark .document-ai-tools__img-wait-text,
html body.dark .document-ai-tools__img-wait-text {
  color: rgba(203, 213, 225, 0.78);
}

html.dark .document-ai-tools__img-wait-text--vip,
html body.dark .document-ai-tools__img-wait-text--vip {
  color: #f3dd8a;
}

html.dark .document-ai-tools__image-tile.is-active,
html body.dark .document-ai-tools__image-tile.is-active {
  border-color: var(--theme-color, #3eaf7c);
  box-shadow: 0 0 0 1px rgba(62, 175, 124, 0.24);
}

html.dark .document-ai-tools__image-link,
html body.dark .document-ai-tools__image-link {
  color: #93c5fd;
}

html.dark .document-ai-tools__image-img,
html body.dark .document-ai-tools__image-img {
  border-color: rgba(148, 163, 184, 0.28);
}

html.dark .document-ai-tools__wm,
html body.dark .document-ai-tools__wm {
  color: rgba(203, 213, 225, 0.78);
  border-color: rgba(148, 163, 184, 0.55);
  background: rgba(15, 23, 42, 0.22);
}

html.dark .document-ai-tools__img-modal-close,
html body.dark .document-ai-tools__img-modal-close {
  background: rgba(17, 24, 39, 0.92);
  color: #e5e7eb;
}

html.dark .document-ai-tools__tabs button,
html.dark .document-ai-tools__btn,
html body.dark .document-ai-tools__tabs button,
html body.dark .document-ai-tools__btn {
  border-color: rgba(148, 163, 184, 0.3);
  background: rgba(15, 23, 42, 0.45);
  color: rgba(241, 245, 249, 0.92);
}

html.dark .document-ai-tools__tabs button.is-active,
html.dark .document-ai-tools__btn--primary,
html body.dark .document-ai-tools__tabs button.is-active,
html body.dark .document-ai-tools__btn--primary {
  background: var(--theme-color, #3eaf7c);
  border-color: var(--theme-color, #3eaf7c);
  color: #0b1220;
}

html.dark .document-ai-tools__quota,
html body.dark .document-ai-tools__quota {
  border-color: rgba(148, 163, 184, 0.28);
  background: rgba(15, 23, 42, 0.35);
}

html.dark .document-ai-tools__quota-title,
html body.dark .document-ai-tools__quota-title {
  color: #e2c466;
}

html.dark .document-ai-tools__quota-item,
html body.dark .document-ai-tools__quota-item {
  color: rgba(226, 196, 102, 0.9);
}

html.dark .document-ai-tools__quota-item strong,
html body.dark .document-ai-tools__quota-item strong {
  color: #f3dd8a;
}

html.dark .document-ai-tools__textarea,
html.dark .document-ai-tools__result,
html body.dark .document-ai-tools__textarea,
html body.dark .document-ai-tools__result {
  background: #0b1220;
  border-color: rgba(148, 163, 184, 0.28);
  color: rgba(241, 245, 249, 0.95);
  -webkit-text-fill-color: rgba(241, 245, 249, 0.95);
}

html.dark .document-ai-tools__textarea::placeholder,
html body.dark .document-ai-tools__textarea::placeholder {
  color: rgba(148, 163, 184, 0.72);
}

html.dark .document-ai-tools__upload,
html body.dark .document-ai-tools__upload {
  border-color: rgba(148, 163, 184, 0.4);
  background: rgba(15, 23, 42, 0.2);
  color: rgba(226, 232, 240, 0.92);
}

html.dark .document-ai-tools__loading-title,
html body.dark .document-ai-tools__loading-title {
  color: rgba(226, 232, 240, 0.94);
}

html.dark .document-ai-tools__loading-track,
html body.dark .document-ai-tools__loading-track {
  background: rgba(148, 163, 184, 0.2);
}

html.dark .document-ai-tools__loading-sub,
html body.dark .document-ai-tools__loading-sub {
  color: rgba(148, 163, 184, 0.9);
}

@media (max-width: 1024px) {
  .document-ai-tools {
    grid-template-columns: 1fr;
  }
  .document-ai-tools__image {
    grid-template-columns: 1fr;
  }
}

/* AI 工具页：左侧导航与首页对齐，并隐藏资源导航框 */
html body .document-ai-tools-page #space #navigator {
  transform: translateX(92px);
}

html body .document-ai-tools-page #space #navigator .navigator-frame {
  display: none !important;
}

