/* OCR 识别 — 与全站四套主题一致 */

.ocr-body {
  --radius: 16px;
  --max-width: 1100px;
  --transition: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', 'Noto Sans SC', system-ui, sans-serif;
  line-height: 1.65;
}
.celestial-site.ocr-body {
  background-color: transparent;
}

.ocr-body .bg-decoration {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.ocr-body .orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(88px);
  opacity: 0.55;
}

.ocr-body .orb-1 { width: 420px; height: 420px; background: var(--orb-1); top: -80px; right: -40px; }
.ocr-body .orb-2 { width: 340px; height: 340px; background: var(--orb-2); bottom: 10%; left: -60px; }
.ocr-body .orb-3 { width: 260px; height: 260px; background: var(--orb-3, var(--orb-2)); top: 40%; right: 20%; }

[data-theme='plumrain'] .ocr-body .rain-layer { opacity: 1; }
.ocr-body .rain-layer {
  position: absolute;
  inset: 0;
  opacity: 0;
  background-image: repeating-linear-gradient(180deg, transparent, transparent 4px, rgba(139, 92, 246, 0.04) 4px, rgba(139, 92, 246, 0.04) 5px);
}

.ocr-topbar, .ocr-shell, .ocr-footer, .ocr-body .theme-panel-wrap { position: relative; z-index: 1; }
.ocr-body .theme-panel-wrap { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 300; }
.ocr-body .theme-panel-toggle {
  width: 52px; height: 52px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--gradient-accent); color: var(--on-accent, #fff); box-shadow: var(--shadow);
}
.ocr-body .theme-panel {
  position: absolute; bottom: calc(100% + 0.75rem); right: 0; width: 220px; padding: 1rem;
  background: var(--surface-solid); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); opacity: 0; visibility: hidden; pointer-events: none;
  transform: translateY(12px); transition: opacity var(--transition), transform var(--transition);
}
.ocr-body .theme-panel.open { opacity: 1; visibility: visible; pointer-events: auto; transform: translateY(0); }
.ocr-body .theme-panel-title { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 0 0 0.75rem; }
.ocr-body .theme-options { display: flex; flex-direction: column; gap: 0.5rem; }
.ocr-body .theme-option {
  display: flex; align-items: center; gap: 0.65rem; width: 100%; padding: 0.55rem 0.65rem;
  border: 1px solid var(--border); border-radius: 10px; background: transparent; color: var(--text);
  font: inherit; font-size: 0.85rem; cursor: pointer; text-align: left;
}
.ocr-body .theme-option.active, .ocr-body .theme-option:hover {
  border-color: var(--btn-accent-border, var(--accent));
  background: var(--btn-accent-bg, var(--accent-soft));
}
.ocr-body .theme-swatch { width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0; }
.ocr-body .theme-swatch.spring { background: linear-gradient(135deg, #059669, #6ee7b7); }
.ocr-body .theme-swatch.plumrain { background: linear-gradient(135deg, #8b5cf6, #c4b5fd); }
.ocr-body .theme-swatch.twilight { background: linear-gradient(135deg, #ffffff, #f5f5f7 55%, #000000); }
.ocr-body .theme-swatch.autumnnight { background: linear-gradient(135deg, #000000 0%, #000000 55%, #ffffff 100%); }

.ocr-topbar { border-bottom: 1px solid var(--border); background: var(--header-bg); backdrop-filter: blur(14px); }
.ocr-topbar-inner {
  width: min(100% - 2rem, var(--max-width)); margin-inline: auto; padding: 0.75rem 0;
  display: flex; align-items: center; flex-wrap: wrap; gap: 0.75rem 1.25rem;
}
.ocr-topbar-links { display: flex; flex-wrap: wrap; align-items: center; margin-left: auto; }
.ocr-topbar-user { display: flex; align-items: center; gap: 0.65rem; font-size: 0.88rem; color: var(--muted); }
.ocr-topbar-greeting {
  color: var(--muted);
  text-decoration: none;
  padding: 0.35rem 0.5rem;
  border-radius: 8px;
  transition: color var(--transition), background var(--transition);
}
.ocr-topbar-greeting strong { color: var(--text); font-weight: 600; }
.ocr-topbar-greeting:hover {
  color: var(--accent-hover, var(--accent));
  background: var(--btn-accent-bg, var(--accent-soft));
}
.ocr-topbar-greeting:hover strong { color: var(--accent-hover, var(--accent)); }
.ocr-logout-form { margin: 0; }

.ocr-shell {
  width: min(100% - 2rem, var(--max-width)); margin-inline: auto; padding: 1.5rem 0 3rem;
}
.ocr-flash-wrap { margin-bottom: 1rem; }
.ocr-flash { padding: 0.7rem 1rem; border-radius: 12px; margin-bottom: 0.5rem; font-size: 0.9rem; }
.ocr-flash--success { background: var(--accent-soft); color: var(--accent-hover); border: 1px solid var(--btn-accent-border, var(--accent)); }
.ocr-flash--error { background: rgba(220, 38, 38, 0.1); color: #b91c1c; border: 1px solid rgba(220, 38, 38, 0.25); }

.ocr-hero { margin-bottom: 1rem; }
.ocr-hero--compact .ocr-hero-card { padding: 1rem 1.25rem; }
.ocr-hero-card {
  display: flex; align-items: center; padding: 1.35rem 1.6rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.ocr-hero-card::before {
  content: ''; position: absolute; inset: 0; background: var(--gradient-accent); opacity: 0.06; pointer-events: none;
}
.ocr-hero-card > * { position: relative; z-index: 1; }
.ocr-hero-text { display: flex; align-items: center; gap: 1rem; }
.ocr-hero-icon {
  width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; font-weight: 700; background: var(--gradient-accent); color: var(--on-accent, #fff); box-shadow: var(--shadow);
}
.ocr-hero-card h1 { font-family: 'Noto Serif SC', serif; font-size: 1.35rem; margin: 0 0 0.2rem; }

.ocr-card {
  background: var(--surface-solid); border: 1px solid var(--btn-raised-border, var(--border));
  border-radius: var(--radius); padding: 1.25rem 1.35rem; box-shadow: var(--btn-shadow, var(--shadow));
  margin-bottom: 1rem;
}
.ocr-card--wide { margin-top: 0; }
.ocr-card--error { border-color: rgba(220, 38, 38, 0.4); }
.ocr-card__title { font-family: 'Noto Serif SC', serif; font-size: 1.1rem; margin: 0 0 0.85rem; }

.ocr-muted { color: var(--muted); font-size: 0.9rem; }
.ocr-hint { font-size: 0.82rem; color: var(--muted); margin: 0.35rem 0 0; }
.ocr-error { font-size: 0.82rem; color: #b91c1c; margin: 0.35rem 0 0; }

.ocr-field { margin-bottom: 0.85rem; }
.ocr-field label { display: block; font-size: 0.88rem; font-weight: 600; margin-bottom: 0.35rem; }
.ocr-field--inline label { margin-bottom: 0.25rem; }
.ocr-input, .ocr-select {
  width: 100%; max-width: 100%; padding: 0.55rem 0.7rem; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit; font-size: 0.9rem;
}
.ocr-form-row--model .ocr-select { max-width: 420px; }

.ocr-link-btn {
  background: none; border: none; padding: 0; font: inherit; font-weight: 600;
  color: var(--accent-hover, var(--accent)); cursor: pointer; text-decoration: underline;
}

.ocr-dropzone {
  margin: 1rem 0; border: 2px dashed var(--border); border-radius: 14px;
  background: var(--bg); transition: border-color var(--transition), background var(--transition);
  min-height: 200px; display: flex; align-items: stretch; justify-content: center;
}
.ocr-dropzone.is-dragover {
  border-color: var(--btn-accent-border, var(--accent));
  background: var(--accent-soft);
}
.ocr-dropzone__inner {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 2rem 1.5rem; text-align: center; width: 100%;
}
.ocr-dropzone__icon {
  width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent-hover, var(--accent)); font-size: 1.4rem; margin-bottom: 0.75rem;
}
.ocr-dropzone__title { margin: 0 0 0.35rem; font-weight: 600; }

.ocr-preview {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1rem; align-items: start;
  padding: 1rem; width: 100%;
}
.ocr-preview--hidden { display: none; }
.ocr-preview__media {
  border-radius: 10px; overflow: hidden; border: 1px solid var(--border);
  background: var(--surface); min-height: 160px; max-height: 420px;
  display: flex; align-items: stretch; justify-content: center;
}
.ocr-pdf-viewer--upload { width: 100%; min-height: 280px; }
.ocr-pdf-viewer--upload .ocr-preview__pdf {
  min-height: 280px; height: 360px; max-height: 400px;
}
.ocr-preview__img {
  max-width: 100%; max-height: 320px; width: auto; height: auto; display: block; object-fit: contain;
}
.ocr-preview__pdf {
  width: 100%; height: 280px; border: none; display: block;
}
.ocr-preview__meta {
  display: flex; flex-direction: column; gap: 0.35rem; min-width: 140px;
}
.ocr-preview__meta strong { font-size: 0.9rem; word-break: break-all; }

.ocr-url-details {
  margin: 0.5rem 0 1rem; font-size: 0.88rem;
}
.ocr-url-details summary {
  cursor: pointer; color: var(--muted); user-select: none;
}
.ocr-url-details[open] summary { margin-bottom: 0.5rem; color: var(--accent-hover, var(--accent)); }

.ocr-form-actions { margin-top: 0.5rem; }

.ocr-btn {
  display: inline-flex; align-items: center; justify-content: center; padding: 0.55rem 1.15rem;
  border-radius: 10px; border: 1px solid var(--btn-raised-border, var(--border));
  background: var(--btn-raised-bg, var(--surface-solid)); color: var(--text);
  font: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer; text-decoration: none;
  box-shadow: var(--btn-shadow);
}
.ocr-btn:hover { border-color: var(--btn-accent-border, var(--accent)); background: var(--btn-accent-bg, var(--accent-soft)); }
.ocr-btn:disabled { opacity: 0.65; cursor: wait; }
.ocr-btn--primary { background: var(--gradient-accent); border-color: transparent; color: var(--on-accent, #fff); }
.ocr-btn--primary:hover { filter: brightness(1.06); color: var(--on-accent, #fff); }
.ocr-btn--ghost { background: transparent; box-shadow: none; }
.ocr-btn--sm { padding: 0.42rem 0.9rem; font-size: 0.85rem; }

.ocr-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; padding: 0; margin: 0;
  border: none; border-radius: 8px; background: transparent;
  color: var(--muted); cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease;
}
.ocr-icon-btn__svg { width: 1.05rem; height: 1.05rem; display: block; }
.ocr-icon-btn--danger:hover,
.ocr-icon-btn--danger:focus-visible {
  color: #dc2626; background: rgba(220, 38, 38, 0.1); outline: none;
}
.ocr-icon-btn--danger:focus-visible { box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.25); }

.ocr-task-list { list-style: none; margin: 0; padding: 0; }
.ocr-task-list__item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.35rem 0.75rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}
.ocr-task-list__item:last-child { border-bottom: none; }
.ocr-task-list__main {
  min-width: 0;
  display: flex; flex-direction: column; gap: 0.15rem;
  text-decoration: none; color: inherit;
}
.ocr-task-list__main:hover .ocr-task-list__name { color: var(--accent-hover, var(--accent)); }
.ocr-task-list__name {
  font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ocr-task-list__meta { font-size: 0.82rem; line-height: 1.3; }
.ocr-task-list__delete { margin: 0; }

.ocr-badge {
  display: inline-block; padding: 0.12rem 0.5rem; border-radius: 999px; font-size: 0.72rem; font-weight: 600;
  background: var(--accent-soft); color: var(--accent-hover); border: 1px solid var(--btn-accent-border, var(--accent));
}
.ocr-badge--done { background: rgba(52, 211, 153, 0.15); color: #059669; border-color: rgba(5, 150, 105, 0.35); }
.ocr-badge--failed { background: rgba(220, 38, 38, 0.1); color: #b91c1c; border-color: rgba(220, 38, 38, 0.3); }
.ocr-badge--running, .ocr-badge--pending { background: var(--surface); color: var(--muted); }

.ocr-page-header {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem;
}
.ocr-page-title { font-family: 'Noto Serif SC', serif; font-size: 1.5rem; margin: 0 0 0.25rem; }
.ocr-page-header__actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.ocr-inline-form { margin: 0; display: inline; }

/* 结果页：左预览右 Markdown */
.ocr-workspace {
  display: grid;
  grid-template-columns: minmax(240px, 340px) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}
.ocr-workspace__label {
  font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); margin: 0 0 0.65rem; font-weight: 600;
}
.ocr-workspace__preview,
.ocr-workspace__result {
  background: var(--surface-solid); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow);
}
.ocr-source-panel {
  border-radius: 10px; overflow: hidden; border: 1px solid var(--border);
  background: var(--bg); min-height: 200px; max-height: 70vh;
  display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start;
}
.ocr-source-panel:has(.ocr-source-img) {
  align-items: center; justify-content: center;
}
.ocr-source-img {
  max-width: 100%; max-height: 70vh; width: auto; height: auto; display: block; object-fit: contain;
}
.ocr-pdf-viewer {
  display: flex; flex-direction: column; width: 100%; min-height: 200px;
}
.ocr-source-pdf {
  width: 100%; flex: 1 1 auto;
  min-height: 360px; height: min(68vh, 560px);
  border: none; display: block; background: var(--surface);
}
.ocr-pdf-toolbar {
  display: flex; flex-wrap: wrap; gap: 0.4rem; justify-content: flex-end;
  padding: 0.5rem 0.65rem; border-top: 1px solid var(--border);
  background: var(--surface-solid);
}
.ocr-source-fallback {
  padding: 1.5rem; text-align: center;
}
.ocr-source-file-icon { font-size: 2.5rem; display: block; margin-bottom: 0.5rem; }

.ocr-result-toolbar {
  display: flex; justify-content: space-between; align-items: center; gap: 0.75rem;
  flex-wrap: wrap; margin-bottom: 0.75rem;
}
.ocr-result-toolbar .ocr-workspace__label { margin: 0; }
.ocr-result-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.ocr-pdf-placeholder {
  padding: 2rem 1rem; text-align: center; display: flex; flex-direction: column;
  align-items: center; gap: 0.65rem; width: 100%;
}
.ocr-pdf-placeholder .ocr-source-file-icon {
  font-size: 2rem; font-weight: 700; letter-spacing: 0.05em; color: var(--accent-hover, var(--accent));
}

.ocr-result-panel {
  display: none;
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); max-height: 70vh; overflow: auto;
}
.ocr-result-panel.is-active { display: block; }

.ocr-result-empty {
  padding: 1.5rem; text-align: center; color: var(--muted);
  border: 1px dashed var(--border); border-radius: 10px;
}

.ocr-result-actions .ocr-btn.is-active {
  border-color: var(--btn-accent-border, var(--accent));
  background: var(--btn-accent-bg, var(--accent-soft));
}

.ocr-markdown-body {
  padding: 1.1rem 1.25rem 1.35rem;
  font-size: 0.95rem;
  line-height: 1.75;
  color: var(--text);
}
.ocr-markdown-body > :first-child { margin-top: 0; }
.ocr-markdown-body > :last-child { margin-bottom: 0; }
.ocr-markdown-body h1, .ocr-markdown-body h2, .ocr-markdown-body h3 {
  font-family: 'Noto Serif SC', serif;
  margin: 1.25rem 0 0.65rem;
  line-height: 1.35;
}
.ocr-markdown-body h2 { font-size: 1.15rem; }
.ocr-markdown-body h3 { font-size: 1.02rem; }
.ocr-markdown-body p { margin: 0.65rem 0; }
.ocr-markdown-body ul, .ocr-markdown-body ol {
  margin: 0.65rem 0; padding-left: 1.35rem;
}
.ocr-markdown-body li { margin: 0.25rem 0; }
.ocr-markdown-body blockquote {
  margin: 0.75rem 0; padding: 0.5rem 0.85rem;
  border-left: 3px solid var(--accent); color: var(--muted);
  background: var(--surface);
}
.ocr-markdown-body img { max-width: 100%; height: auto; border-radius: 8px; }
.ocr-markdown-body table {
  width: 100%; border-collapse: collapse; margin: 0.85rem 0; font-size: 0.88rem;
}
.ocr-markdown-body th, .ocr-markdown-body td {
  border: 1px solid var(--border); padding: 0.45rem 0.6rem; vertical-align: top;
}
.ocr-markdown-body th { background: var(--surface); font-weight: 600; }
.ocr-markdown-body pre, .ocr-markdown-body .highlight {
  background: var(--surface-solid); border: 1px solid var(--border);
  border-radius: 10px; padding: 0.85rem 1rem; overflow-x: auto;
  font-size: 0.84rem; line-height: 1.55;
}
.ocr-markdown-body code {
  font-family: ui-monospace, 'Cascadia Code', 'Noto Sans SC', monospace;
  font-size: 0.88em;
  background: var(--surface);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}
.ocr-markdown-body pre code { background: transparent; padding: 0; }
.ocr-markdown-body a { color: var(--accent-hover, var(--accent)); }

.ocr-result-source {
  display: block; width: 100%; min-height: 280px; box-sizing: border-box;
  margin: 0; padding: 1rem 1.1rem; font-size: 0.86rem; line-height: 1.55;
  font-family: ui-monospace, 'Cascadia Code', monospace;
  color: var(--text); background: var(--bg); border: none; resize: vertical;
  white-space: pre; overflow: auto;
}

.ocr-footer { border-top: 1px solid var(--border); padding: 1.25rem 0; text-align: center; color: var(--muted); font-size: 0.85rem; }
.ocr-footer-inner { width: min(100% - 2rem, var(--max-width)); margin-inline: auto; }

@media (max-width: 860px) {
  .ocr-workspace { grid-template-columns: 1fr; }
  .ocr-preview { grid-template-columns: 1fr; }
  .ocr-preview__meta { flex-direction: row; flex-wrap: wrap; align-items: center; }
}

@media (max-width: 640px) {
  .ocr-topbar-links {
    width: 100%;
    margin-left: 0;
    order: 3;
  }
}
