/* Image to Text Converter (OCR) ------------------------------------------- */
.ocr kbd {
  padding: 0.05rem 0.35rem;
  border: 1px solid var(--border-2);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--text);
  font: 600 0.78rem/1.4 var(--font-body);
}

/* Added images */
.ocr-files {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 228px;
  overflow-y: auto;
}
.ocr-files[hidden] { display: none; }
.ocr-file {
  position: relative;
  display: flex;
  align-items: stretch;
  min-width: 0;
  border: 1px solid var(--border-2);
  border-radius: 12px;
  background: var(--surface);
  transition: border-color 0.2s, background-color 0.2s;
}
.ocr-file.is-selected { border-color: rgba(139, 92, 246, 0.7); background: rgba(139, 92, 246, 0.1); }
.ocr-file.is-working { border-color: var(--cyan); }
.ocr-file-main {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  padding: 0.4rem 0.4rem 0.4rem 0.45rem;
  border: 0;
  background: none;
  color: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: 12px;
}
.ocr-file-main:focus-visible { outline: 2px solid var(--lilac); outline-offset: 2px; }
.ocr-file-main img {
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  object-fit: cover;
  background: #fff;
}
.ocr-file-text { display: flex; flex-direction: column; min-width: 0; }
.ocr-file-name { overflow: hidden; color: var(--text); font-size: 0.83rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.ocr-file-meta { color: var(--muted); font-size: 0.74rem; }
.ocr-file.is-working .ocr-file-meta { color: var(--cyan); }
.ocr-file-x {
  flex: none;
  align-self: center;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-right: 0.3rem;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.ocr-file-x:hover { color: var(--danger); background: var(--surface-2); }
.ocr-file-x:focus-visible { outline: 2px solid var(--lilac); }
.ocr-file-x .icon { width: 15px; height: 15px; }

/* Selected image: rotate and crop */
.ocr-editor { display: flex; flex-direction: column; gap: 0.6rem; }
.ocr-editor[hidden] { display: none; }
.ocr-editor-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; }
.ocr-editor-name { overflow: hidden; margin: 0; min-width: 0; flex: 1 1 140px; color: var(--text); font-size: 0.88rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.ocr-editor-actions { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.ocr-editor-actions .icon-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.ocr-stage {
  display: grid;
  place-items: center;
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: repeating-conic-gradient(rgba(var(--ink), 0.05) 0 25%, transparent 0 50%) 0 0 / 18px 18px;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.ocr-stage-inner { position: relative; overflow: hidden; max-width: 100%; line-height: 0; }
.ocr-stage canvas { display: block; max-width: 100%; max-height: 340px; width: auto; height: auto; box-shadow: 0 6px 24px -10px rgba(0, 0, 0, 0.5); }
.ocr-crop {
  position: absolute;
  border: 2px solid var(--cyan);
  box-shadow: 0 0 0 9999px rgba(5, 6, 13, 0.55);
  pointer-events: none;
}
.ocr-crop[hidden] { display: none; }
.ocr-hint { margin: 0; }

/* Languages */
.ocr-langs { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }
@media (max-width: 520px) { .ocr-langs { grid-template-columns: 1fr; } }
.ocr-optional { color: var(--muted); font-weight: 400; }
.ocr-combos { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; margin-top: -0.4rem; }
.ocr-combos-label { margin-right: 0.15rem; color: var(--muted); font-size: 0.8rem; }
.ocr-combos .chip-btn[aria-pressed="true"] { color: var(--on-soft); background: var(--grad-soft); border-color: rgba(139, 92, 246, 0.6); }
.ocr-dl {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  margin: -0.2rem 0 0;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 0.83rem;
  line-height: 1.5;
}
.ocr-dl .icon { flex: none; width: 16px; height: 16px; margin-top: 0.15rem; color: var(--lilac); }
.ocr-dl strong { color: var(--text); }
.ocr-dl.is-ready .icon { color: var(--success); }

/* Clean-up options */
.ocr-adv { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.ocr-adv summary {
  padding: 0.8rem 1rem;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius);
}
.ocr-adv summary:focus-visible { outline: 2px solid var(--lilac); outline-offset: 2px; }
.ocr-adv-body { display: flex; flex-direction: column; gap: 1.1rem; padding: 0.2rem 1rem 1.1rem; }
.ocr-checks { display: flex; flex-direction: column; gap: 0.6rem; }
.ocr-checks .check { align-items: flex-start; line-height: 1.45; }
.ocr-checks .check input { flex: none; margin-top: 0.15rem; }
.ocr-out { margin-left: 0.35rem; color: var(--lilac); font-family: var(--font-mono); font-size: 0.82rem; }
.ocr-range { width: 100%; accent-color: var(--violet); }
.field[hidden] { display: none; }

/* Progress */
.ocr-progress { display: flex; flex-direction: column; gap: 0.5rem; padding: 0.85rem 1rem; border: 1px solid rgba(139, 92, 246, 0.35); border-radius: var(--radius); background: var(--grad-soft); }
.ocr-progress[hidden] { display: none; }
.ocr-progress-top { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.ocr-progress-text { margin: 0; color: var(--text); font-size: 0.9rem; font-weight: 600; }
.ocr-progress-sub { overflow: hidden; margin: 0; color: var(--text-2); font-size: 0.8rem; text-overflow: ellipsis; white-space: nowrap; }
.ocr-bar { height: 8px; overflow: hidden; border-radius: 999px; background: rgba(var(--ink), 0.12); }
.ocr-bar span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--grad); transition: width 0.25s var(--ease); }
.ocr.is-busy .ocr-files .ocr-file-x { visibility: hidden; }

.ocr-privacy { margin: 0; }
.ocr-forget {
  padding: 0;
  border: 0;
  background: none;
  color: var(--link);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.ocr-forget[hidden] { display: none; }

/* Output */
.ocr-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 0.8rem 1.2rem; }
.ocr-boxes-toggle { padding-bottom: 0.45rem; }
.ocr-results { display: flex; flex-direction: column; gap: 1rem; }
.ocr-card {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.ocr-card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.4rem 0.75rem; }
.ocr-card-name { overflow: hidden; margin: 0; min-width: 0; flex: 1 1 160px; color: var(--text); font: 600 0.92rem/1.3 var(--font-body); text-overflow: ellipsis; white-space: nowrap; }
.ocr-conf {
  flex: none;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border-2);
  font-size: 0.76rem;
  font-weight: 700;
}
.ocr-conf.is-good { border-color: rgba(52, 211, 153, 0.45); background: rgba(52, 211, 153, 0.1); color: var(--success-text); }
.ocr-conf.is-ok { border-color: rgba(245, 158, 11, 0.45); background: rgba(245, 158, 11, 0.1); color: var(--warn-text); }
.ocr-conf.is-low { border-color: rgba(251, 113, 133, 0.45); background: rgba(251, 113, 133, 0.1); color: var(--danger-text); }
.ocr-conf.is-none { color: var(--muted); }
:root[data-theme="light"] .ocr-conf.is-good { color: #047857; }
:root[data-theme="light"] .ocr-conf.is-low { color: #be123c; }
.ocr-stat-good { color: var(--success); }
.ocr-stat-ok { color: var(--warn-text); }
.ocr-stat-low { color: var(--danger); }
.ocr-stale {
  margin: 0;
  padding: 0.5rem 0.7rem;
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 10px;
  background: rgba(245, 158, 11, 0.08);
  color: var(--warn-text);
  font-size: 0.8rem;
}

.ocr-shot { display: flex; flex-direction: column; gap: 0.4rem; margin: 0; }
.ocr-shot[hidden] { display: none; }
.ocr-shot-inner { position: relative; align-self: center; max-width: 100%; line-height: 0; border-radius: 8px; overflow: hidden; }
.ocr-shot-inner img { display: block; max-width: 100%; max-height: 420px; width: auto; height: auto; }
.ocr-boxes { position: absolute; inset: 0; width: 100%; height: 100%; }
.ocr-boxes rect { fill: rgba(34, 211, 238, 0.12); stroke: rgba(8, 145, 178, 0.85); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.ocr-boxes rect.is-low { fill: rgba(245, 158, 11, 0.32); stroke: #d97706; stroke-width: 2; }
.ocr-shot figcaption { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; color: var(--muted); font-size: 0.75rem; }
.ocr-key { display: inline-block; width: 12px; height: 12px; border-radius: 3px; border: 1.5px solid rgba(8, 145, 178, 0.85); background: rgba(34, 211, 238, 0.15); }
.ocr-key.is-low { margin-left: 0.5rem; border-color: #d97706; background: rgba(245, 158, 11, 0.35); }

.ocr-text { min-height: 150px; font-size: 0.93rem; line-height: 1.6; resize: vertical; }
.ocr-card-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; }
.ocr-card-meta { color: var(--muted); font-size: 0.78rem; }
.ocr-low-count { color: var(--warn-text); font-weight: 600; }
.ocr-card .output-actions .icon-btn[hidden] { display: none; }

.ocr-all { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; padding-top: 0.25rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.ocr-all .btn { padding-left: 1rem; padding-right: 1rem; }
@media (max-width: 520px) {
  .ocr-all .output-actions { width: 100%; }
  .ocr-all .btn { flex: 1 1 140px; justify-content: center; }
}
