:root {
  --paper: #faf8f4;
  --surface: #ffffff;
  --ink: #1f2430;
  --ink-soft: #5b6172;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --blue-soft: #edf2fd;
  --sand: #f5eee1;
  --line: #e8e3d9;
  --danger: #c93a3a;
  --warning: #b86b08;
  --success: #1e8e5a;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --serif: Georgia, "Times New Roman", serif;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { color-scheme: light; }

body {
  margin: 0;
  padding: 12px;
  background: transparent;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button,
textarea,
input { font: inherit; }

button,
label { touch-action: manipulation; }

:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.38);
  outline-offset: 3px;
}

.widget {
  width: min(100%, 640px);
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 18px 52px -34px rgba(31, 36, 48, 0.48);
}

.widget-head {
  display: flex;
  min-height: 68px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding: 12px 18px;
  background: var(--paper);
}

.widget-brand {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
}

.widget-brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 10px;
  background: var(--blue);
}

.widget-brand-mark svg { width: 20px; height: 20px; }

.widget-brand > span:last-child { display: grid; min-width: 0; }
.widget-brand strong { font-size: 0.9rem; line-height: 1.3; }
.widget-brand small { overflow: hidden; color: var(--ink-soft); font-size: 0.68rem; text-overflow: ellipsis; white-space: nowrap; }

.widget-free {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 5px 10px;
  background: var(--sand);
  color: var(--ink-soft);
  font-size: 0.67rem;
  font-weight: 800;
}

.widget-body { padding: 22px; }

.widget h1,
.widget h2,
.widget h3,
.widget p { margin-top: 0; }

.widget h1 {
  margin-bottom: 4px;
  font-family: var(--serif);
  font-size: 1.35rem;
  line-height: 1.3;
}

.widget-intro {
  margin-bottom: 18px;
  color: var(--ink-soft);
  font-size: 0.83rem;
}

.widget-tabs {
  display: flex;
  margin-bottom: 17px;
  border-bottom: 1px solid var(--line);
}

.widget-tab {
  min-height: 45px;
  flex: 1 1 0;
  margin-bottom: -1px;
  border: 0;
  border-bottom: 3px solid transparent;
  padding: 8px 5px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 800;
}

.widget-tab.is-active {
  border-bottom-color: var(--blue);
  color: var(--blue);
}

.widget-panel label:not(.widget-dropzone):not(.widget-secondary-button) {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 800;
}

#widget-text {
  display: block;
  width: 100%;
  min-height: 118px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.9rem;
  line-height: 1.55;
}

#widget-text:focus {
  border-color: var(--blue);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

#widget-image,
#widget-qr-image {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.widget-dropzone {
  display: flex;
  min-height: 132px;
  align-items: center;
  justify-content: center;
  gap: 13px;
  border: 1.5px dashed #c9d6f5;
  border-radius: 14px;
  padding: 20px;
  background: var(--blue-soft);
  color: var(--ink-soft);
  cursor: pointer;
}

.widget-dropzone.is-dragging,
.widget-dropzone:hover { border-color: var(--blue); }

.widget-dropzone > span:last-child { display: grid; }
.widget-dropzone strong { color: var(--blue-dark); font-size: 0.9rem; }
.widget-dropzone small { font-size: 0.72rem; }

.widget-upload-icon {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: var(--surface);
  color: var(--blue);
}

.widget-upload-icon svg { width: 21px; height: 21px; }

.widget-file {
  min-height: 22px;
  margin-top: 8px;
  color: var(--ink-soft);
  font-size: 0.75rem;
  text-align: center;
}

.widget-qr-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.widget-secondary-button {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  border: 1px solid #c9d6f5;
  border-radius: 11px;
  padding: 9px 12px;
  background: var(--blue-soft);
  color: var(--blue-dark);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 800;
  text-align: center;
}

.widget-camera {
  position: relative;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  margin-bottom: 10px;
  border-radius: 12px;
  background: var(--ink);
}

.widget-camera video { width: 100%; height: 100%; object-fit: cover; }

.widget-camera-frame {
  position: absolute;
  inset: 18% 24%;
  border: 3px solid #fff;
  border-radius: 14px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.28);
}

.widget-camera p {
  position: absolute;
  right: 0;
  bottom: 8px;
  left: 0;
  margin: 0;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  text-align: center;
}

.widget-qr-value {
  display: grid;
  gap: 2px;
  margin-top: 10px;
  border-radius: 10px;
  padding: 10px 12px;
  background: #e8f6ef;
  color: #176b45;
  font-size: 0.75rem;
}

.widget-qr-value span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.widget-hint {
  margin-top: 15px;
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--sand);
  color: var(--ink-soft);
  font-size: 0.72rem;
}

.widget-hint strong { color: var(--ink); }

.widget-primary-button {
  display: flex;
  min-height: 50px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  margin-top: 14px;
  border: 0;
  border-radius: 999px;
  padding: 11px 18px;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 850;
}

.widget-primary-button:hover:not(:disabled) { background: var(--blue-dark); }
.widget-primary-button:disabled { cursor: not-allowed; opacity: 0.5; }

.widget-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin-top: 13px;
  border-radius: 11px;
  padding: 12px;
  background: var(--blue-soft);
}

.widget-loader span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--blue);
  animation: pulse 1.2s infinite ease-in-out;
}

.widget-loader span:nth-child(2) { animation-delay: 0.16s; }
.widget-loader span:nth-child(3) { animation-delay: 0.32s; }
.widget-loader p { margin: 0 0 0 5px; color: var(--ink-soft); font-size: 0.74rem; font-weight: 700; }

@keyframes pulse { 0%,80%,100% { opacity: .35; transform: scale(.65); } 40% { opacity: 1; transform: scale(1); } }

.widget-error {
  margin-top: 12px;
  border: 1px solid #efb5b5;
  border-radius: 10px;
  padding: 10px 12px;
  background: #fbebeb;
  color: #942b2b;
  font-size: 0.76rem;
}

.widget-result { --status: var(--warning); }
.widget-result.is-danger { --status: var(--danger); }
.widget-result.is-success { --status: var(--success); }

.widget-result-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding-bottom: 18px;
}

.widget-result-dot {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  margin-top: 0.48rem;
  border-radius: 50%;
  background: var(--status);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--status) 14%, transparent);
}

.widget-result h2 {
  margin-bottom: 9px;
  font-family: var(--serif);
  font-size: 1.3rem;
  line-height: 1.3;
}

.widget-result-chips { display: flex; flex-wrap: wrap; gap: 6px; }

.widget-result-chips span {
  border-radius: 999px;
  padding: 4px 9px;
  background: var(--blue-soft);
  color: var(--blue-dark);
  font-size: 0.68rem;
  font-weight: 800;
}

#widget-risk-chip {
  background: color-mix(in srgb, var(--status) 12%, white);
  color: var(--status);
}

.widget-result-section {
  border-top: 1px solid var(--line);
  padding: 15px 0;
}

.widget-result-section h3 {
  margin-bottom: 4px;
  font-size: 0.82rem;
}

.widget-result-section p {
  margin-bottom: 0;
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.widget-memory {
  margin-top: 10px;
  border-radius: 13px;
  padding: 15px 17px;
  background: var(--sand);
}

.widget-memory strong {
  color: var(--ink-soft);
  font-size: 0.66rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.widget-memory p {
  margin: 5px 0 0;
  font-family: var(--serif);
  font-size: 1rem;
  font-style: italic;
}

.widget-result-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 15px;
  margin-top: 16px;
}

.widget-result-actions .widget-primary-button {
  width: auto;
  min-height: 44px;
  margin: 0;
  padding-inline: 17px;
  font-size: 0.8rem;
}

.widget-result-actions a {
  color: var(--ink-soft);
  font-size: 0.74rem;
  font-weight: 800;
}

.widget-result-note {
  margin: 14px 0 0;
  border-top: 1px solid var(--line);
  padding-top: 10px;
  color: var(--ink-soft);
  font-size: 0.66rem;
}

.widget-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px 14px;
  border-top: 1px solid var(--line);
  padding: 10px 18px;
  background: var(--paper);
  color: var(--ink-soft);
  font-size: 0.65rem;
}

.widget-footer a { color: var(--ink-soft); }

[hidden] { display: none !important; }

@media (max-width: 480px) {
  body { padding: 8px; }
  .widget { border-radius: 15px; }
  .widget-head { padding-inline: 14px; }
  .widget-brand small { display: none; }
  .widget-body { padding: 18px; }
  .widget-tab { font-size: 0.76rem; }
  .widget-qr-actions { grid-template-columns: 1fr; }
  .widget-upload-icon { display: none; }
  .widget-dropzone { text-align: center; }
  .widget-result-actions { display: grid; }
  .widget-result-actions .widget-primary-button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
