:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --panel: #ffffff;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --line: #d2d2d7;
  --soft: #fbfbfd;
  --accent: #0071e3;
  --accent-strong: #0066cc;
  --warning: #a45b00;
  --danger: #b00020;
  --ok: #0a7f35;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1180px, calc(100vw - 32px));
  height: 64px;
  margin: 0 auto;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: #1d1d1f;
  color: #fff;
  font-weight: 700;
}

.topbar nav {
  display: flex;
  gap: 18px;
  color: var(--muted);
  font-size: 13px;
}

.topbar a {
  color: inherit;
  text-decoration: none;
}

.brand-link {
  display: inline-flex;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(340px, 0.94fr) minmax(380px, 1.06fr);
  gap: 20px;
  width: min(1180px, calc(100vw - 32px));
  margin: 18px auto 34px;
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(210, 210, 215, 0.8);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.controls {
  padding: 28px;
}

.output {
  padding: 28px;
}

.title-row,
.output-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  max-width: 560px;
  font-size: clamp(34px, 5vw, 56px);
  line-height: 1.04;
  font-weight: 700;
}

h2 {
  font-size: 22px;
}

h3 {
  font-size: 15px;
  margin-bottom: 8px;
}

p {
  color: var(--muted);
  margin-top: 12px;
  line-height: 1.55;
  font-size: 17px;
}

.eyebrow {
  margin: 0 0 8px;
  color: #0071e3;
  font-size: 13px;
  font-weight: 700;
}

.badge,
.status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge {
  background: #f5f5f7;
  color: #1d1d1f;
  border: 1px solid var(--line);
}

.status {
  background: #e2e8f0;
  color: #424245;
}

.status.ready {
  background: #dcfce7;
  color: var(--ok);
}

.status.warn {
  background: #fef3c7;
  color: var(--warning);
}

.status.error {
  background: #fee2e2;
  color: var(--danger);
}

.drop-zone {
  display: grid;
  place-items: center;
  min-height: 210px;
  margin: 28px 0;
  padding: 28px;
  border: 1px dashed #b7b7bd;
  border-radius: 8px;
  background: linear-gradient(#fff, #fbfbfd);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease;
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--accent);
  background: #f5f9ff;
}

.drop-zone input {
  display: none;
}

.drop-icon {
  display: inline-grid;
  place-items: center;
  width: 70px;
  height: 70px;
  margin-bottom: 18px;
  border-radius: 8px;
  background: #1d1d1f;
  box-shadow: inset 0 -1px 0 rgba(255,255,255,0.16);
}

.drop-icon span {
  display: block;
  width: 28px;
  height: 36px;
  border-radius: 4px;
  background: linear-gradient(180deg, #ffffff, #d6d6d8);
  position: relative;
}

.drop-icon span::after {
  content: "";
  position: absolute;
  right: 0;
  top: 0;
  border-top: 9px solid #1d1d1f;
  border-left: 9px solid transparent;
}

.drop-zone strong {
  display: block;
  font-size: 16px;
}

.drop-zone small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

.capture-help {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
  margin: -16px 0 24px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  text-align: center;
}

.link-button {
  width: auto;
  height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--accent);
  box-shadow: none;
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}

.link-button::before {
  content: none;
}

.link-button:hover {
  background: transparent;
  box-shadow: none;
  filter: none;
  transform: none;
}

.video-panel {
  flex-basis: 100%;
  display: grid;
  justify-items: center;
  padding-top: 10px;
}

.video-panel[hidden] {
  display: none;
}

.video-panel video {
  width: min(100%, 260px);
  height: min(420px, 118vw);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #000;
  object-fit: contain;
}

.field-grid {
  display: grid;
  gap: 14px;
}

.field-grid.two-cols {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

label span {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 700;
}

input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid #c7c7cc;
  border-radius: 6px;
  color: var(--ink);
  font-size: 14px;
}

input:focus {
  outline: 2px solid rgba(15, 118, 110, 0.18);
  border-color: var(--accent);
}

.password-row {
  display: grid;
  grid-template-columns: 1fr 76px;
  gap: 8px;
}

button {
  position: relative;
  overflow: hidden;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.48), rgba(255, 255, 255, 0.08)),
    linear-gradient(135deg, rgba(0, 149, 255, 0.96), rgba(0, 93, 230, 0.92));
  color: white;
  font-weight: 800;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.65),
    inset 0 -1px 0 rgba(0, 28, 90, 0.28),
    0 12px 30px rgba(0, 113, 227, 0.28);
  cursor: pointer;
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

button::before {
  content: "";
  position: absolute;
  inset: 1px 1px auto;
  height: 48%;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.58), rgba(255, 255, 255, 0));
  pointer-events: none;
}

button:hover {
  filter: brightness(1.06);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.74),
    inset 0 -1px 0 rgba(0, 28, 90, 0.24),
    0 16px 38px rgba(0, 113, 227, 0.34);
  transform: translateY(-1px);
}

button:disabled {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.38), rgba(255, 255, 255, 0.08)),
    linear-gradient(135deg, rgba(142, 142, 147, 0.78), rgba(99, 99, 102, 0.68));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    0 8px 20px rgba(99, 99, 102, 0.16);
  cursor: not-allowed;
  transform: none;
  filter: saturate(0.75);
}

#toggleToken {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(245, 245, 247, 0.58));
  color: #1d1d1f;
  border: 1px solid rgba(210, 210, 215, 0.9);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 8px 22px rgba(0, 0, 0, 0.05);
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.notice {
  display: grid;
  gap: 4px;
  margin-top: 18px;
  padding: 12px;
  border-radius: 6px;
  background: #f5f5f7;
  color: #424245;
  font-size: 13px;
  line-height: 1.45;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 20px 0;
}

.summary-grid div {
  min-height: 76px;
  padding: 12px;
  border: 1px solid #e5e5ea;
  border-radius: 8px;
  background: var(--soft);
}

.summary-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.summary-grid strong {
  display: block;
  margin-top: 10px;
  overflow-wrap: anywhere;
  font-size: 15px;
}

.log-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.log-title {
  padding: 10px 12px;
  background: #f5f5f7;
  font-size: 13px;
  font-weight: 800;
}

pre {
  min-height: 170px;
  max-height: 260px;
  overflow: auto;
  margin: 0;
  padding: 12px;
  color: #0f172a;
  background: #ffffff;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.guide {
  margin-top: 18px;
  padding: 14px;
  border-radius: 8px;
  background: var(--soft);
  border: 1px solid var(--line);
}

.guide p {
  margin-top: 12px;
  font-size: 14px;
}

a {
  color: var(--accent);
  font-weight: 700;
}

ol {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.65;
}

.doc-shell {
  width: min(980px, calc(100vw - 32px));
  margin: 28px auto 56px;
}

.doc-hero {
  padding: 42px 0 28px;
}

.doc-hero h1 {
  max-width: 760px;
}

.doc-hero p:not(.eyebrow) {
  max-width: 720px;
}

.doc-card {
  margin-top: 18px;
  padding: 26px;
  border: 1px solid rgba(210, 210, 215, 0.76);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.78)),
    var(--panel);
  box-shadow: var(--shadow);
}

.doc-card h2 {
  margin-bottom: 12px;
}

.doc-card p {
  font-size: 15px;
}

.doc-card ol {
  margin-top: 12px;
}

.doc-card pre {
  min-height: 0;
  max-height: none;
  margin-top: 14px;
  border: 1px solid rgba(210, 210, 215, 0.84);
  border-radius: 8px;
  background: #111113;
  color: #f5f5f7;
}

.doc-card code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.doc-card :not(pre) > code {
  padding: 2px 6px;
  border-radius: 5px;
  background: #f5f5f7;
  color: #1d1d1f;
}

.check-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.6;
}

.doc-table {
  width: 100%;
  margin-top: 14px;
  border-collapse: collapse;
  overflow: hidden;
  border: 1px solid rgba(210, 210, 215, 0.9);
  border-radius: 8px;
  color: #424245;
  font-size: 14px;
}

.doc-table th,
.doc-table td {
  padding: 12px;
  border-bottom: 1px solid rgba(210, 210, 215, 0.75);
  text-align: left;
  vertical-align: top;
}

.doc-table th {
  background: #f5f5f7;
  color: #1d1d1f;
  font-size: 13px;
}

.doc-table tr:last-child td {
  border-bottom: 0;
}

.result-box {
  display: grid;
  gap: 6px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid rgba(0, 113, 227, 0.2);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(245, 249, 255, 0.74)),
    #f5f9ff;
  color: #424245;
  font-size: 14px;
  line-height: 1.55;
}

.result-box strong {
  color: #1d1d1f;
}

figure {
  margin: 18px 0 0;
}

figure img {
  display: block;
  width: 100%;
  border: 1px solid rgba(210, 210, 215, 0.84);
  border-radius: 8px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.12);
}

figcaption {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
    width: min(100vw - 20px, 720px);
    margin: 10px auto;
  }

  .summary-grid,
  .actions,
  .field-grid.two-cols {
    grid-template-columns: 1fr;
  }

  .doc-shell {
    width: min(100vw - 20px, 720px);
    margin-top: 10px;
  }

  .doc-card {
    padding: 18px;
  }
}
