:root {
  --bg: #0f1216;
  --surface: #181d24;
  --surface-2: #20262f;
  --border: #2b323c;
  --text: #e7ecf2;
  --muted: #95a1b1;
  --accent: #5b8cff;
  --accent-d: #3f6fe0;
  --ok: #2fbf71;
  --warn: #e0a429;
  --bad: #e0584b;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

/* The `hidden` attribute must always win, even over author display rules
   like `.btn { display: inline-flex }` (otherwise hidden buttons stay visible). */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(1200px 600px at 70% -10%, #1b2330, var(--bg));
  color: var(--text);
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 18, 22, 0.7);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.brand .logo { color: var(--accent); font-size: 22px; }
.brand em { color: var(--muted); font-style: normal; font-weight: 400; }

.status { font-size: 12px; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--border); }
.status--unknown { color: var(--muted); }
.status--ok { color: var(--ok); border-color: rgba(47, 191, 113, 0.4); }
.status--bad { color: var(--bad); border-color: rgba(224, 88, 75, 0.4); }

.stepper {
  display: flex;
  gap: 8px;
  list-style: none;
  margin: 22px auto 6px;
  padding: 0 18px;
  max-width: 720px;
  flex-wrap: wrap;
}
.stepper li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  flex: 1;
  min-width: 90px;
}
.stepper li span {
  width: 24px; height: 24px;
  display: grid; place-items: center;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 12px;
}
.stepper li.active { color: var(--text); }
.stepper li.active span { background: var(--accent); border-color: var(--accent); color: #fff; }
.stepper li.done span { background: var(--ok); border-color: var(--ok); color: #06281a; }

.wrap { max-width: 720px; margin: 12px auto 60px; padding: 0 18px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow);
}
.card h1 { margin: 0 0 6px; font-size: 22px; }
.card h3 { margin: 0 0 10px; font-size: 15px; color: var(--muted); font-weight: 600; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: 12px; }

.field { display: flex; flex-direction: column; gap: 6px; margin: 18px 0; }
.field > span { font-size: 14px; }
.field input[type="text"], .field input[type="file"] {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 14px;
}
.checkbox { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; cursor: pointer; }
.checkbox input { margin-top: 2px; width: 16px; height: 16px; accent-color: var(--accent); }

.req { color: var(--bad); font-size: 11px; font-weight: 600; }
.opt { color: var(--muted); font-size: 11px; font-weight: 600; }

.actions { display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap; }

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 11px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .05s ease, background .15s ease, opacity .15s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn:hover { background: #283039; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-d); }
.btn--ghost { background: transparent; }
.btn--camera, .btn--shoot, .btn--retake { font-weight: 500; }
.btn.is-loading { position: relative; color: transparent; }
.btn.is-loading::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.4); border-top-color: #fff;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Capture widget */
.capture { margin: 18px 0; }
.capture-preview {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: grid;
  place-items: center;
}
.capture-preview .preview, .capture-preview .video, .capture-preview .canvas {
  width: 100%; height: 100%; object-fit: cover;
}
/* The still preview shows the whole image (no crop), so the user can tell when
   it is framed wrong and open the adjust tool. */
.capture-preview .preview { object-fit: contain; }
.capture-preview .placeholder { color: var(--muted); font-size: 14px; }
.capture-controls { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* Verify */
.thumbs { display: flex; gap: 14px; flex-wrap: wrap; margin: 16px 0; }
.thumbs figure { margin: 0; }
.thumbs img {
  width: 150px; height: 112px; object-fit: cover;
  border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2);
}
.thumbs figcaption { font-size: 12px; color: var(--muted); margin-top: 4px; text-align: center; }

.result {
  margin-top: 22px;
  border-top: 1px solid var(--border);
  padding-top: 18px;
}
.result-head { display: flex; align-items: center; gap: 12px; font-size: 15px; }
.badge {
  font-size: 12px; font-weight: 700; letter-spacing: .04em;
  padding: 4px 10px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.badge--ok { background: rgba(47,191,113,.15); color: var(--ok); border-color: rgba(47,191,113,.4); }
.badge--bad { background: rgba(224,88,75,.15); color: var(--bad); border-color: rgba(224,88,75,.4); }
.badge--warn { background: rgba(224,164,41,.15); color: var(--warn); border-color: rgba(224,164,41,.4); }

.reasons { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 14px 0; }
.reasons li { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }

.scores { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-top: 8px; }
.score { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.score b { display: block; font-size: 18px; }
.score span { font-size: 12px; color: var(--muted); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 14px 0; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--bad); color: #fff; padding: 12px 18px; border-radius: 10px;
  font-size: 14px; box-shadow: var(--shadow); max-width: 90%; z-index: 50;
}
.toast.toast--info { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }

/* Image adjust editor (crop / zoom / rotate) */
.editor {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0, 0, 0, 0.66);
  display: grid; place-items: center; padding: 18px;
}
.editor-dialog {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; width: min(480px, 100%);
}
.editor-dialog h3 { margin: 0 0 12px; font-size: 16px; color: var(--text); }
.editor-stage {
  background: #0b0e12; border: 1px solid var(--border); border-radius: 10px;
  overflow: hidden; display: grid; place-items: center;
}
/* The canvas IS the crop frame; what fits inside is what gets sent. */
#editor-canvas { width: 100%; aspect-ratio: 4 / 3; display: block; cursor: grab; touch-action: none; }
#editor-canvas:active { cursor: grabbing; }
.editor-controls { display: flex; align-items: center; gap: 10px; margin: 12px 0; flex-wrap: wrap; }
.editor-zoom { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); flex: 1; min-width: 140px; }
.editor-zoom input[type="range"] { flex: 1; accent-color: var(--accent); }
.editor-hint { font-size: 12px; color: var(--muted); margin: 0 0 8px; }

/* ====================== API docs page ====================== */
.topbar .nav { display: flex; gap: 6px; align-items: center; margin-left: auto; margin-right: 14px; }
.topbar .nav a {
  font-size: 13px; color: var(--muted); text-decoration: none;
  padding: 6px 10px; border-radius: 8px; border: 1px solid transparent;
}
.topbar .nav a:hover { color: var(--text); background: var(--surface-2); }
.topbar .nav a.active { color: var(--text); border-color: var(--border); background: var(--surface-2); }

.docs-layout { max-width: 1040px; margin: 18px auto 80px; padding: 0 18px; display: grid; grid-template-columns: 220px 1fr; gap: 26px; }
.docs-nav { position: sticky; top: 78px; align-self: start; max-height: calc(100vh - 100px); overflow: auto; font-size: 13px; }
.docs-nav h4 { margin: 14px 0 6px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.docs-nav a { display: flex; gap: 8px; align-items: center; color: var(--muted); text-decoration: none; padding: 5px 8px; border-radius: 7px; }
.docs-nav a:hover { color: var(--text); background: var(--surface); }
.docs-content { min-width: 0; }
.docs-content h1 { font-size: 26px; margin: 0 0 8px; }
.docs-content h2 { font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 30px 0 12px; }
.docs-content p { color: var(--text); line-height: 1.55; }

.doc-links { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0; }
.doc-links a { font-size: 13px; }

.code, pre.code {
  background: #0b0e12; border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px; color: #cdd6e4; overflow: auto; white-space: pre; margin: 10px 0;
}

.meth { font-family: ui-monospace, monospace; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 6px; letter-spacing: .03em; }
.meth--get { background: rgba(47,191,113,.15); color: var(--ok); border: 1px solid rgba(47,191,113,.4); }
.meth--post { background: rgba(91,140,255,.15); color: var(--accent); border: 1px solid rgba(91,140,255,.45); }

.ep { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin: 16px 0; scroll-margin-top: 80px; }
.ep-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.ep-path { font-family: ui-monospace, monospace; font-size: 14px; color: var(--text); }
.ep-summary { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.ep-desc { font-size: 14px; line-height: 1.55; margin: 12px 0; }
.ep-note { font-size: 13px; color: var(--muted); border-left: 2px solid var(--border); padding-left: 12px; margin: 10px 0; }

.try { border-top: 1px dashed var(--border); margin-top: 16px; padding-top: 14px; }
.try h5 { margin: 0 0 10px; font-size: 13px; color: var(--muted); }
.try-field { display: flex; flex-direction: column; gap: 5px; margin: 10px 0; }
.try-field label { font-size: 12px; color: var(--muted); }
.try-field .req { color: var(--bad); }
.try-field input[type="text"], .try-field input[type="file"], .try textarea {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 9px; padding: 9px 11px; font-size: 13px; font-family: inherit;
}
.try textarea { font-family: ui-monospace, monospace; font-size: 12.5px; min-height: 96px; resize: vertical; }
.try-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.try-use { font-size: 12px; }

.resp { margin-top: 14px; }
.resp-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.resp-status { font-family: ui-monospace, monospace; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.resp-status.ok { background: rgba(47,191,113,.15); color: var(--ok); }
.resp-status.err { background: rgba(224,88,75,.15); color: var(--bad); }
.resp-meta { font-size: 12px; color: var(--muted); }

@media (max-width: 820px) {
  .docs-layout { grid-template-columns: 1fr; }
  .docs-nav { position: static; max-height: none; }
}
