:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --panel: #ffffff;
  --line: #d9dee7;
  --text: #18202f;
  --muted: #637083;
  --accent: #1b6f6a;
  --accent-strong: #14524f;
  --danger: #b42318;
  --ok: #027a48;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

.shell {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr);
  gap: 16px;
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 16px;
}

.workspace,
.result-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.workspace {
  padding: 18px;
}

.topbar,
.result-head,
.actions,
.settings {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar {
  justify-content: space-between;
  margin-bottom: 16px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  font-size: 16px;
}

p,
.status,
.result-head span {
  color: var(--muted);
}

.settings {
  display: grid;
  grid-template-columns: 1.3fr 1fr auto;
  margin-bottom: 16px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
}

.status {
  min-width: 112px;
  min-height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
}

.status.ok {
  color: var(--ok);
  border-color: #8fd9b6;
  background: #ecfdf3;
}

.status.error {
  color: var(--danger);
  border-color: #f5b5ae;
  background: #fff3f1;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 16px;
}

.tab {
  min-height: 42px;
  border: 0;
  border-right: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  cursor: pointer;
}

.tab:last-child {
  border-right: 0;
}

.tab.active {
  background: #e7f4f2;
  color: var(--accent-strong);
  font-weight: 750;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.dropzone {
  min-height: 260px;
  border: 1px dashed #9aa7b7;
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfe;
  cursor: pointer;
}

.dropzone.single {
  grid-column: 1 / -1;
}

.dropzone input {
  min-width: 0;
}

.image-source-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.camera-button {
  white-space: nowrap;
}

.dropzone img {
  display: none;
  width: 100%;
  height: 185px;
  margin-top: 10px;
  border-radius: 6px;
  object-fit: contain;
  background: #eef2f6;
}

.dropzone img.has-image {
  display: block;
}

.options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.check {
  min-height: 40px;
  grid-template-columns: auto 1fr;
  align-items: center;
  align-self: end;
  color: var(--text);
}

.check input {
  width: 18px;
  min-height: 18px;
}

.actions {
  margin-top: 16px;
}

button {
  min-height: 42px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  padding: 9px 14px;
  cursor: pointer;
  font-weight: 750;
}

button:hover {
  background: var(--accent-strong);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.secondary,
.icon-button {
  background: #fff;
  color: var(--accent);
}

.secondary:hover,
.icon-button:hover {
  background: #e7f4f2;
}

.icon-button {
  width: 42px;
  padding: 0;
  font-size: 20px;
}

.result-panel {
  display: grid;
  grid-template-rows: auto auto 1fr;
  min-height: 420px;
  overflow: hidden;
}

.verify-result {
  display: grid;
  gap: 3px;
  margin: 14px 16px 0;
  border: 1px solid;
  border-radius: 8px;
  padding: 14px 16px;
}

.verify-result strong {
  font-size: 18px;
}

.verify-result span {
  font-size: 13px;
}

.verify-result.success {
  color: var(--ok);
  border-color: #8fd9b6;
  background: #ecfdf3;
}

.verify-result.error {
  color: var(--danger);
  border-color: #f5b5ae;
  background: #fff3f1;
}

.result-head {
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
}

pre {
  margin: 0;
  padding: 16px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
  line-height: 1.45;
}

.camera-dialog {
  width: min(680px, calc(100% - 24px));
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  background: var(--panel);
  color: var(--text);
}

.camera-dialog::backdrop {
  background: rgb(15 23 42 / 65%);
}

.camera-head,
.camera-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.camera-head {
  justify-content: space-between;
  margin-bottom: 12px;
}

.camera-dialog video,
.camera-dialog canvas {
  width: 100%;
  max-height: 65vh;
  border-radius: 8px;
  object-fit: contain;
  background: #0f172a;
}

.camera-actions {
  justify-content: flex-end;
  margin-top: 12px;
}

.close-button {
  width: 42px;
  padding: 0;
  font-size: 24px;
}

.camera-error {
  margin-bottom: 12px;
  border: 1px solid #f5b5ae;
  border-radius: 6px;
  padding: 10px;
  background: #fff3f1;
  color: var(--danger);
}

.hidden {
  display: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .settings,
  .options,
  .image-grid {
    grid-template-columns: 1fr;
  }

  .result-panel {
    min-height: 360px;
  }
}

@media (max-width: 620px) {
  .image-source-actions {
    grid-template-columns: 1fr;
  }
}
