:root {
  color-scheme: light;
  --ink: #182128;
  --muted: #627078;
  --paper: #f1f4f2;
  --panel: #ffffff;
  --line: #cfd7d3;
  --line-strong: #8c9a94;
  --teal: #126a72;
  --teal-dark: #0d4e55;
  --lime: #b8d43d;
  --magenta: #b94d78;
  --red: #b54135;
  --amber: #b86c16;
  --canvas: #171c20;
  --radius: 6px;
  font-family: Inter, "Noto Sans JP", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.55;
}

button,
select,
textarea,
input {
  font: inherit;
  letter-spacing: 0;
}

button,
select,
.drop-zone {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
select:focus-visible,
textarea:focus-visible,
.drop-zone:focus-within,
.region-select:focus-visible {
  outline: 3px solid rgba(18, 106, 114, 0.28);
  outline-offset: 2px;
}

.site-header {
  min-height: 58px;
  padding: 10px clamp(16px, 3vw, 42px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: #fff;
  background: var(--ink);
  border-bottom: 4px solid var(--lime);
}

.brand {
  display: grid;
  color: inherit;
  text-decoration: none;
  line-height: 1.15;
}

.brand span {
  font-size: 11px;
  color: #cbd5d0;
}

.brand strong {
  font-size: 15px;
}

.privacy-mark {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #e6ece9;
  white-space: nowrap;
}

.privacy-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 0 3px rgba(184, 212, 61, 0.18);
}

main {
  width: min(1600px, 100%);
  margin: 0 auto;
  padding: 28px clamp(16px, 3vw, 42px) 40px;
}

.intro {
  max-width: 920px;
  margin-bottom: 24px;
}

.eyebrow,
.step {
  margin: 0 0 5px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  letter-spacing: 0;
}

h1 {
  margin: 0;
  max-width: 100%;
  font-size: 42px;
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.subtitle {
  margin: 4px 0 0;
  color: var(--magenta);
  font-size: 18px;
  font-weight: 750;
}

.lead {
  margin: 10px 0 0;
  color: #435058;
  font-size: 16px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(440px, 1.45fr) minmax(280px, 0.72fr) minmax(300px, 0.82fr);
  align-items: start;
  border-top: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
  background: var(--panel);
}

.pane {
  min-width: 0;
  padding: 18px;
}

.pane + .pane {
  border-left: 1px solid var(--line);
}

.pane-head {
  min-height: 50px;
  margin-bottom: 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.pane h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
}

.pane h3 {
  margin: 0;
  font-size: 14px;
}

.count {
  flex: 0 0 auto;
  padding-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.view-tabs {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  overflow: hidden;
}

.view-tab {
  min-height: 34px;
  padding: 6px 10px;
  border: 0;
  color: var(--muted);
  background: #fff;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.view-tab + .view-tab {
  border-left: 1px solid var(--line-strong);
}

.view-tab.is-active {
  color: #fff;
  background: var(--teal-dark);
}

.canvas-shell {
  position: relative;
  width: 100%;
  min-height: 310px;
  overflow: hidden;
  border: 1px solid #30383d;
  border-radius: var(--radius);
  background: var(--canvas);
  aspect-ratio: 1200 / 760;
}

.canvas-shell canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

#overlayCanvas {
  z-index: 3;
  cursor: crosshair;
  touch-action: none;
}

.canvas-shell.is-reveal #overlayCanvas {
  pointer-events: none;
}

.canvas-empty {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-content: center;
  gap: 4px;
  padding: 20px;
  color: #d8e0dc;
  text-align: center;
  pointer-events: none;
}

.canvas-empty strong {
  color: var(--lime);
  font-size: 15px;
}

.canvas-empty span {
  font-size: 13px;
}

.image-tools {
  margin-top: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: stretch;
}

.drop-zone {
  min-width: 0;
  min-height: 56px;
  padding: 9px 12px;
  display: grid;
  align-content: center;
  gap: 2px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  background: #f8faf9;
  cursor: pointer;
}

.drop-zone.is-dragging {
  border-style: solid;
  border-color: var(--teal);
  background: #eaf4f2;
}

.drop-zone.is-received {
  border-color: var(--lime);
}

.drop-title {
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.drop-zone span:last-child {
  min-width: 0;
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.command-row,
.command-grid,
.result-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.button,
.icon-button {
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 800;
  cursor: pointer;
}

.button {
  min-height: 40px;
  padding: 8px 13px;
  font-size: 12px;
}

.button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.button-primary {
  color: #fff;
  background: var(--teal);
  border-color: var(--teal);
}

.button-secondary {
  color: var(--ink);
  background: #eef2ef;
  border-color: var(--line-strong);
}

.button-quiet {
  color: var(--muted);
  background: #fff;
  border-color: var(--line);
}

.button-danger {
  color: #fff;
  background: var(--red);
  border-color: var(--red);
}

.control-block {
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.control-block:first-of-type {
  padding-top: 0;
  border-top: 0;
}

.control-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.icon-button {
  width: 32px;
  height: 32px;
  padding: 0;
  color: var(--muted);
  background: #fff;
  border-color: var(--line);
  font-size: 20px;
  line-height: 1;
}

.hint {
  margin: 6px 0 10px;
  color: var(--muted);
  font-size: 12px;
}

.region-list,
.result-list {
  display: grid;
  gap: 8px;
}

.region-list {
  max-height: 270px;
  overflow: auto;
  padding-right: 3px;
}

.region-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
}

.region-row.is-selected {
  border-color: var(--teal);
  box-shadow: inset 4px 0 0 var(--teal);
}

.region-select {
  min-width: 0;
  padding: 9px 10px 9px 14px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  border: 0;
  color: var(--ink);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.region-index {
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--teal-dark);
  font-size: 11px;
  font-weight: 800;
}

.region-meta {
  min-width: 0;
  display: grid;
}

.region-meta strong,
.region-meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.region-meta strong {
  font-size: 12px;
}

.region-meta span {
  color: var(--muted);
  font-size: 10px;
}

.region-delete {
  border: 0;
  border-left: 1px solid var(--line);
  color: var(--muted);
  background: #fafbfa;
  font-size: 17px;
  cursor: pointer;
}

.ocr-controls label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

select {
  width: 100%;
  min-height: 40px;
  margin-bottom: 10px;
  padding: 7px 34px 7px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
  background: #fff;
}

.command-grid .button {
  flex: 1 1 120px;
}

.progress-panel {
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--lime);
  border-radius: var(--radius);
  background: #f8faf8;
}

.progress-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--teal-dark);
  font-size: 11px;
  font-weight: 800;
}

progress {
  width: 100%;
  height: 8px;
  margin-top: 7px;
  accent-color: var(--teal);
}

.progress-panel p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.result-actions {
  margin-bottom: 12px;
}

.result-actions .button {
  flex: 1 1 110px;
}

.result-list {
  max-height: 720px;
  overflow: auto;
  padding-right: 3px;
}

.empty-result {
  min-height: 170px;
  padding: 24px;
  display: grid;
  place-content: center;
  gap: 4px;
  border: 1px dashed var(--line-strong);
  color: var(--muted);
  text-align: center;
}

.empty-result strong {
  color: var(--magenta);
  font-size: 13px;
}

.empty-result span {
  font-size: 12px;
}

.result-item {
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.result-item.is-selected {
  border-color: var(--magenta);
  box-shadow: inset 4px 0 0 var(--magenta);
}

.result-item-head {
  margin-bottom: 7px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.result-item-head button {
  padding: 0;
  border: 0;
  color: var(--ink);
  background: transparent;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.confidence {
  color: var(--teal-dark);
  font-size: 10px;
  font-weight: 800;
}

.confidence.is-low {
  color: var(--amber);
}

.result-item textarea {
  width: 100%;
  min-height: 70px;
  resize: vertical;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  background: #fbfcfb;
  line-height: 1.45;
}

.result-error {
  margin: 0;
  color: var(--red);
  font-size: 12px;
}

.scope-note {
  margin-top: 20px;
  padding: 14px 16px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 24px;
  border-left: 4px solid var(--teal);
  background: #e9eeeb;
}

.scope-note p {
  margin: 0;
  color: #46535a;
  font-size: 12px;
}

footer {
  min-height: 62px;
  padding: 14px clamp(16px, 3vw, 42px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  color: #cad3cf;
  background: var(--ink);
  font-size: 11px;
}

footer a {
  color: #fff;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px 18px;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: minmax(420px, 1.25fr) minmax(280px, 0.75fr);
  }

  .result-pane {
    grid-column: 1 / -1;
    border-top: 1px solid var(--line);
    border-left: 0 !important;
  }

  .result-list {
    max-height: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .empty-result {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .site-header {
    min-height: 54px;
    padding: 9px 14px;
  }

  .privacy-mark {
    font-size: 10px;
  }

  main {
    padding: 22px 12px 30px;
  }

  h1 {
    font-size: 31px;
    line-height: 1.18;
  }

  .subtitle {
    font-size: 16px;
  }

  .lead {
    font-size: 14px;
  }

  .workspace {
    display: block;
  }

  .pane {
    padding: 15px 12px;
  }

  .pane + .pane,
  .result-pane {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .pane h2 {
    font-size: 18px;
  }

  .canvas-shell {
    min-height: 210px;
  }

  .image-tools {
    grid-template-columns: 1fr;
  }

  .command-row .button {
    flex: 1 1 0;
  }

  .region-list,
  .result-list {
    max-height: none;
    overflow: visible;
  }

  .result-list {
    grid-template-columns: 1fr;
  }

  .scope-note {
    grid-template-columns: 1fr;
  }

  footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .footer-links {
    justify-content: flex-start;
  }
}

@media (max-width: 410px) {
  .brand span {
    display: none;
  }

  .privacy-mark {
    max-width: 145px;
    white-space: normal;
    text-align: right;
  }

  .pane-head {
    min-height: 46px;
  }

  .view-tab {
    padding-inline: 8px;
  }

  .canvas-shell {
    min-height: 190px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
