textarea {
  width: 100%;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-medium);
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  font: inherit;
  font-size: 0.9375rem;
  padding: 14px 16px;
  resize: vertical;
  min-height: 220px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea:focus {
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--md-sys-color-primary) 22%, transparent);
}

.loading-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: var(--md-sys-shape-corner-medium);
  background: var(--md-sys-color-surface);
  border: 1px solid var(--md-sys-color-outline-variant);
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.875rem;
}

.loading-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(47, 136, 217, 0.22);
  border-top-color: var(--md-sys-color-primary);
  border-radius: 50%;
  animation: qrReaderSpin 0.7s linear infinite;
  flex: 0 0 auto;
}

@keyframes qrReaderSpin {
  to {
    transform: rotate(360deg);
  }}

.file-input {
  display: block;
  width: 100%;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-medium);
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  font: inherit;
  font-size: 0.9375rem;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.file-input:focus {
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--md-sys-color-primary) 22%, transparent);
}

#camera-wrap {
  scroll-margin-top: 80px;
}

#image-panel {
  position: relative;
}

.file-input--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;
}

.image-file-name {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-medium);
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  font-size: 0.9375rem;
  word-break: break-all;
}

.preview-wrap {
  margin-top: 14px;
}

.preview-label {
  margin-bottom: 8px;
}

.reader-surface {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 240px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-medium);
  background: var(--md-sys-color-surface);
  overflow: hidden;
}

.reader-surface {
  background: #000;
  min-height: 320px;
}

.reader-surface video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#result-output {
  min-height: 160px;
}

.result-note {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: var(--md-sys-shape-corner-medium);
  background: var(--md-sys-color-surface);
  border: 1px solid var(--md-sys-color-outline-variant);
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.875rem;
  line-height: 1.5;
}

.mode-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.camera-stage {
  position: relative;
  border-radius: var(--md-sys-shape-corner-medium);
  overflow: hidden;
}

.camera-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(rgba(0, 0, 0, 0.18), rgba(0, 0, 0, 0.18));
}

.camera-overlay__frame {
  width: min(68vw, 220px);
  height: min(68vw, 220px);
  border: 3px solid rgba(255, 255, 255, 0.95);
  border-radius: 20px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.18);
  background: transparent;
}

.camera-guide {
  margin: 10px 0 0;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.875rem;
  line-height: 1.5;
}

.result-section--flash {
  animation: resultFlash 0.9s ease;
}

.result-section--reveal {
  animation: resultReveal 0.45s ease;
}

@keyframes resultFlash {
  0% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--md-sys-color-primary) 0%, transparent);
    border-color: transparent;
  }
  20% {
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--md-sys-color-primary) 18%, transparent);
    border-color: color-mix(in srgb, var(--md-sys-color-primary) 32%, transparent);
  }
  100% {
    box-shadow: var(--md-sys-elevation-1);
    border-color: transparent;
  }}

@keyframes resultReveal {
  from {
    opacity: 0.65;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }}

.success-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(12px);
  z-index: 30;
  padding: 12px 16px;
  border-radius: 999px;
  background: var(--md-sys-color-on-surface);
  color: var(--md-sys-color-surface);
  box-shadow: var(--md-sys-elevation-2);
  font-size: 0.875rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
}

.success-toast.is-visible {
  animation: toastInOut 2s ease forwards;
}

@keyframes toastInOut {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(12px);
  }
  12%,
  78% {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(8px);
  }}

.parsed-result {
  margin-top: 16px;
  padding: 16px;
  border-radius: var(--md-sys-shape-corner-medium);
  background: var(--md-sys-color-surface);
  border: 1px solid var(--md-sys-color-outline-variant);
}

.parsed-result__title {
  margin: 0 0 12px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--md-sys-color-on-surface);
}

.parsed-result__body {
  display: grid;
  gap: 10px;
}

.parsed-result__row {
  display: grid;
  gap: 4px;
}

.parsed-result__label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--md-sys-color-on-surface-variant);
}

.parsed-result__value {
  font-size: 0.9375rem;
  color: var(--md-sys-color-on-surface);
  word-break: break-word;
}

.parsed-result__value code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.875em;
}

.debug-sample-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
}

.debug-sample-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--md-sys-color-on-surface);
}

.debug-sample-select {
  min-width: 200px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-medium);
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  font: inherit;
  font-size: 0.9375rem;
  padding: 10px 12px;
}

@media (max-width: 600px) {
  .result-actions {
    width: 100%;
  }

  .result-actions .btn,
  .result-actions .btn-link,
  .mode-selector .btn {
    width: 100%;
  }

  .camera-overlay__frame {
    width: min(72vw, 200px);
    height: min(72vw, 200px);
  }

  .debug-sample-select {
    width: 100%;
    min-width: 0;
  }

  .debug-sample-wrap {
    align-items: stretch;
  }}
