.ocr-layout { align-items: start; }

.ocr-workspace[hidden],
.ocr-result[hidden],
.ocr-progress[hidden] { display: none; }

.ocr-source {
  display: grid;
  grid-template-columns: minmax(180px, 280px) 1fr;
  gap: 1rem;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid var(--line);
  background: #e5d8c4;
}

.ocr-preview-wrap {
  display: grid;
  place-items: center;
  min-height: 150px;
  height: 280px;
  overflow: auto;
  background: #b8a88e;
  box-shadow: 0 7px 16px rgb(68 43 18 / .16);
}

#source-canvas {
  display: block;
  max-width: none;
  max-height: none;
  box-shadow: 0 5px 12px rgb(68 43 18 / .18);
}

.ocr-source-info { display: grid; gap: .8rem; min-width: 0; }
.ocr-source-meta { min-width: 0; }
.ocr-source-meta strong,
.ocr-source-meta span { display: block; }
.ocr-source-meta strong { overflow-wrap: anywhere; }
.ocr-source-meta span { margin-top: .25rem; color: var(--muted); font-size: .84rem; }
.ocr-preview-toolbar { display: grid; gap: .55rem; }
.ocr-toolbar-group { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.ocr-toolbar-group .button { min-height: 38px; }
.ocr-zoom-tools output { min-width: 3.4rem; text-align: center; color: var(--muted); font-size: .82rem; font-weight: 900; }
.ocr-preview-help { margin: 0; color: var(--muted); font-size: .78rem; line-height: 1.45; }

.ocr-controls { padding: 1rem; background: #fffaf1; }
.ocr-language-fieldset { margin: 0; padding: 0; border: 0; }
.ocr-language-fieldset legend { margin-bottom: .55rem; color: var(--muted); font-size: .82rem; font-weight: 900; }
.ocr-language-fieldset label { display: inline-flex; margin: 0 .4rem .45rem 0; cursor: pointer; }
.ocr-language-fieldset input { position: absolute; opacity: 0; pointer-events: none; }
.ocr-language-fieldset span {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: .35rem .78rem;
  font-size: .84rem;
  font-weight: 800;
}
.ocr-language-fieldset input:checked + span { border-color: var(--ink); background: var(--yellow); box-shadow: inset 0 0 0 1px var(--ink); }
.ocr-language-fieldset input:focus-visible + span { outline: 3px solid rgb(217 66 51 / .3); outline-offset: 2px; }
.ocr-language-fieldset input:disabled + span { opacity: .5; cursor: not-allowed; }

.ocr-model-note { margin: .25rem 0 .8rem; color: var(--muted); font-size: .8rem; }
.ocr-control-actions,
.ocr-result-actions { display: flex; gap: .55rem; flex-wrap: wrap; justify-content: space-between; }

.ocr-progress { padding: 1rem; border-top: 1px solid var(--line); background: #fff; }
.ocr-progress > div { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: .45rem; font-size: .84rem; }
.ocr-progress progress { display: block; width: 100%; height: 13px; margin-bottom: .7rem; accent-color: var(--red); }
.ocr-status { min-height: 2.7rem; }

.ocr-result { padding: 1rem; border-top: 1px solid var(--line); }
.ocr-result-heading { display: flex; justify-content: space-between; gap: 1rem; align-items: start; margin-bottom: .65rem; }
.ocr-result-heading h3 { margin: 0; }
.ocr-result-heading p { margin: .12rem 0 0; color: var(--muted); font-size: .82rem; }
.ocr-result-heading > span { flex: none; border-radius: 999px; background: var(--green); padding: .16rem .6rem; font-size: .78rem; font-weight: 900; }
#result-text {
  display: block;
  width: 100%;
  min-height: 250px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffefb;
  color: var(--ink);
  padding: .85rem;
  font: inherit;
  line-height: 1.55;
}
#result-text:focus { border-color: var(--red); outline: 3px solid rgb(217 66 51 / .15); }
.ocr-result-actions { justify-content: flex-end; margin-top: .7rem; }

@media (max-width: 620px) {
  .ocr-source { grid-template-columns: 1fr; }
  .ocr-preview-wrap { height: 240px; }
  .ocr-control-actions .button,
  .ocr-result-actions .button { flex: 1 1 auto; }
}
