.import-tabs {
  margin: 4px 0 6px;
}

.ocr-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 10px 0 4px;
  text-align: center;
}

.ocr-loading[hidden] {
  display: none;
}

.ocr-stage {
  position: relative;
  width: 240px;
  height: 320px;
  border-radius: 14px;
  overflow: visible;
}

.ocr-tiles {
  position: absolute;
  inset: 0;
}

.ocr-tile {
  position: absolute;
  background-repeat: no-repeat;
  background-color: rgba(127, 140, 130, 0.15);
  animation: ocr-split 3.6s cubic-bezier(0.65, 0, 0.35, 1) infinite;
  animation-delay: var(--delay, 0ms);
  will-change: transform;
}

.ocr-tile::after {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0;
  animation: ocr-tint 3.6s ease-in-out infinite;
  animation-delay: var(--delay, 0ms);
}

.ocr-tile.orange::after {
  background: rgba(255, 145, 75, 0.55);
}

.ocr-tile.blue::after {
  background: rgba(75, 160, 235, 0.68);
}

.ocr-scan {
  position: absolute;
  left: -6px;
  right: -6px;
  top: 0;
  height: 3px;
  border-radius: 3px;
  background: linear-gradient(90deg, transparent, #8be3b6, transparent);
  box-shadow: 0 0 18px 5px rgba(139, 227, 182, 0.55);
  animation: ocr-scan 3.6s linear infinite;
}

.ocr-status {
  margin: 14px 0 0;
  font-weight: 600;
  font-size: calc(14px * var(--font-scale, 1));
}

.ocr-dots::after {
  content: '';
  display: inline-block;
  width: 1.2em;
  text-align: left;
  animation: ocr-dots 1.2s steps(4, end) infinite;
}

.ocr-loading small {
  color: var(--muted);
  font-size: calc(11px * var(--font-scale, 1));
  max-width: 320px;
  line-height: 1.6;
}

#ocr-count {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: calc(11px * var(--font-scale, 1));
}

/* Text and Markdown imports: a pen writes four lines on a sheet of paper, about 1 second. */
.write-loading { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 0 4px; }
.write-loading[hidden] { display: none; }
.write-art { width: 200px; height: 150px; overflow: visible; }
/* A tonal sheet that reads as paper in both themes, with clear contrast for the ink. */
.write-paper {
  fill: var(--m3-surface-container-highest, #fff);
  stroke: var(--m3-outline-variant, rgba(0, 0, 0, .15)); stroke-width: 1;
}
.write-ink {
  fill: none; stroke: var(--m3-primary, var(--accent)); stroke-width: 2.4; stroke-linecap: round;
  stroke-dasharray: 1; stroke-dashoffset: 1;
}
.write-loading:not([hidden]) .write-ink { animation: write-line .24s linear both; }
.write-loading:not([hidden]) .write-ink:nth-of-type(2) { animation-delay: .27s; }
.write-loading:not([hidden]) .write-ink:nth-of-type(3) { animation-delay: .52s; animation-duration: .26s; }
.write-loading:not([hidden]) .write-ink:nth-of-type(4) { animation-delay: .8s; animation-duration: .15s; }
.write-pen { fill: var(--m3-tertiary, #9c2f2a); }
.write-pen-tip { fill: var(--m3-on-surface, #1e0e2e); }
/* The pen's tip is at (0,0), so each step moves it to where the ink is being drawn. */
.write-loading:not([hidden]) .write-pen { animation: write-pen .95s linear both; }

@keyframes write-line { to { stroke-dashoffset: 0; } }
@keyframes write-pen {
  0%   { transform: translate(48px, 32px); }
  25%  { transform: translate(104px, 32px); }
  28%  { transform: translate(48px, 50px); }
  52%  { transform: translate(96px, 50px); }
  55%  { transform: translate(48px, 68px); }
  80%  { transform: translate(104px, 68px); }
  83%  { transform: translate(48px, 86px); }
  97%  { transform: translate(80px, 86px); }
  100% { transform: translate(92px, 74px); }
}
@media (prefers-reduced-motion: reduce) {
  .write-ink { stroke-dashoffset: 0; animation: none !important; }
  .write-pen { animation: none !important; transform: translate(80px, 86px); }
}

@keyframes ocr-split {
  0%, 18% {
    transform: none;
    box-shadow: inset 0 0 0 0 rgba(229, 57, 53, 0);
  }
  30% {
    transform: none;
    box-shadow: inset 0 0 0 1.5px rgba(229, 57, 53, 0.95);
  }
  45%, 72% {
    transform: translate(calc(var(--dx) * 16px), calc(var(--dy) * 16px)) scale(0.93);
    box-shadow: inset 0 0 0 1.5px rgba(229, 57, 53, 0.95);
  }
  90%, 100% {
    transform: none;
    box-shadow: inset 0 0 0 0 rgba(229, 57, 53, 0);
  }
}

@keyframes ocr-tint {
  0%, 40% { opacity: 0; }
  52%, 72% { opacity: 1; }
  88%, 100% { opacity: 0; }
}

@keyframes ocr-scan {
  0% { top: 0; opacity: 1; }
  25% { top: 100%; opacity: 1; }
  26%, 100% { top: 100%; opacity: 0; }
}

@keyframes ocr-dots {
  0% { content: ''; }
  25% { content: '.'; }
  50% { content: '..'; }
  75% { content: '...'; }
}
