/*
 * CAPCHA UI
 * Palette, typography, spacing, cards, and button states follow
 * /usr/local/src/bots/restic/web/static/style.css (Restic Explorer).
 * The CF 403 page remains an independent, unchanged canonical design.
 */
:root {
  color-scheme: dark;
  --bg-color: #0b1120;
  --secondary-bg-color: #131d31;
  --card-bg: #1e293b;
  --card-bg-active: #27374d;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --border-color: #334155;
  --border-subtle: #1e293b;
  --accent-color: #38bdf8;
  --accent-bg: rgba(56, 189, 248, 0.15);
  --badge-bg: #334155;
  --input-bg: #1e293b;
  --input-text: #f8fafc;
  --input-border: #475569;
  --btn-primary-bg: #2563eb;
  --btn-primary-text: #ffffff;
  --btn-secondary-bg: #334155;
  --btn-secondary-text: #f8fafc;
  --success-text: #34d399;
  --success-bg: rgba(16, 185, 129, 0.18);
  --warning-text: #fbbf24;
  --warning-bg: rgba(245, 158, 11, 0.18);
  --danger-text: #f87171;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --page-border: var(--border-color);
  --image-stage: var(--bg-color);
  --focus-ring: rgba(56, 189, 248, 0.32);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
html[data-theme="light"] {
  color-scheme: light;
  --bg-color: #f1f5f9;
  --secondary-bg-color: #ffffff;
  --card-bg: #ffffff;
  --card-bg-active: #f8fafc;
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --border-color: #cbd5e1;
  --border-subtle: #e2e8f0;
  --accent-color: #0284c7;
  --accent-bg: rgba(2, 132, 199, 0.12);
  --badge-bg: #e2e8f0;
  --input-bg: #ffffff;
  --input-text: #0f172a;
  --input-border: #94a3b8;
  --btn-primary-bg: #0284c7;
  --btn-primary-text: #ffffff;
  --btn-secondary-bg: #e2e8f0;
  --btn-secondary-text: #0f172a;
  --success-text: #059669;
  --success-bg: rgba(16, 185, 129, 0.14);
  --warning-text: #d97706;
  --warning-bg: rgba(245, 158, 11, 0.14);
  --danger-text: #dc2626;
  --page-border: var(--border-color);
  --image-stage: #f8fafc;
  --focus-ring: rgba(2, 132, 199, 0.22);
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { min-height: 100%; -webkit-text-size-adjust: 100%; overscroll-behavior-y: none; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-color);
  color: var(--text-primary);
  font: 14px/1.5 var(--font-sans);
  overflow-x: hidden;
}
button,input,a { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .4; cursor: default; }
button:focus-visible,input:focus-visible,a:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 3px;
}
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
.shell {
  max-width: 640px;
  width: 100%;
  padding: 0 16px;
  margin: 0 auto;
}
.top {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  margin: 0 -16px 16px;
  background: var(--secondary-bg-color);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 37px;
  height: 37px;
  flex-shrink: 0;
  border: 1px solid var(--accent-color);
  background: var(--accent-bg);
  color: var(--accent-color);
  border-radius: 9px;
  font: 700 19px/1 var(--font-mono);
}
.brand strong { display: block; font-size: 16px; line-height: 1.25; letter-spacing: -.01em; font-weight: 700; }
.brand small { display: block; font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.icon-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
}
.icon-button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-button:active { background: var(--card-bg-active); }
.panel {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.stats { padding: 16px; margin-bottom: 12px; }
.stats-head,.stats-bottom,.card-top,.actions,.below-actions,.section-title,.legend,.footer-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.eyebrow {
  display: inline-block;
  color: var(--text-muted);
  font-size: 11px;
  letter-spacing: .065em;
  font-weight: 700;
}
.big-stat { font-size: 32px; font-weight: 700; line-height: 1.35; letter-spacing: -.035em; font-variant-numeric: tabular-nums; }
.divider-word { color: var(--text-muted); font-weight: 400; }
.percent {
  padding: 4px 10px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 15px;
  color: var(--accent-color);
  background: var(--accent-bg);
  font-variant-numeric: tabular-nums;
}
.progress { margin-top: 12px; height: 7px; border-radius: 4px; background: var(--badge-bg); overflow: hidden; }
.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent-color);
  transition: width .2s ease;
}
.stats-bottom { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 5px 12px; font-size: 11px; color: var(--text-secondary); }
.dot { display: inline-block; width: 7px; height: 7px; margin-right: 4px; vertical-align: 1px; border-radius: 50%; }
.dot.good { background: var(--success-text); }
.dot.warn { background: var(--warning-text); }
.dot.plain { background: var(--text-muted); }
.main-card { padding: 16px; margin-bottom: 12px; }
.card-top { align-items: end; gap: 10px; margin-bottom: 14px; }
.card-top h1 { font-size: 22px; line-height: 1.3; margin: 3px 0 0; font-weight: 700; letter-spacing: -.02em; }
.dim { color: var(--text-secondary); font-size: 14px; font-weight: 500; }
.filename {
  color: var(--text-muted);
  font: 12px/1.4 var(--font-mono);
  white-space: nowrap;
  text-align: right;
  margin-bottom: 3px;
}
.image-box {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 207px;
  padding: 13px 9px 10px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--image-stage);
}
.image-box img { display: block; width: 340px; max-width: 100%; height: auto; object-fit: contain; }
.zoom-hint { font-size: 11px; font-weight: 500; color: var(--accent-color); }
.answer-area { margin-top: 16px; }
.answer-area label, .login label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 8px; color: var(--text-primary); }
.answer-area input, .login input {
  display: block;
  width: 100%;
  height: 48px;
  padding: 0 14px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 8px;
  color: var(--input-text);
  font-size: 18px;
  letter-spacing: .08em;
  font-weight: 600;
  text-transform: uppercase;
  appearance: none;
}
.answer-area input:focus, .login input:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px var(--focus-ring);
  outline: none;
}
.answer-area input::placeholder, .login input::placeholder {
  color: var(--text-muted);
  opacity: 1;
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0;
}
.help { margin-top: 8px; display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 11px; color: var(--text-muted); }
#saveStatus { color: var(--accent-color); white-space: nowrap; }
.actions { margin-top: 16px; gap: 9px; }
.actions button { height: 46px; padding: 0 12px; border-radius: 8px; font-size: 13px; font-weight: 700; }
.actions button:first-child { width: 32%; flex-shrink: 0; }
.actions button:last-child { flex: 1; min-width: 0; }
.primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  border: 1px solid var(--btn-primary-bg);
  font-weight: 700;
  border-radius: 8px;
}
.primary:active:not(:disabled) { filter: brightness(1.12); }
.secondary {
  background: var(--btn-secondary-bg);
  color: var(--btn-secondary-text);
  border: 1px solid var(--border-color);
  font-weight: 600;
}
.secondary:active:not(:disabled) { background: var(--card-bg-active); }
.below-actions { margin-top: 13px; gap: 8px; }
.link-button { color: var(--accent-color); background: transparent; border: 0; font-size: 12px; padding: 4px 0; font-weight: 600; }
.link-button:last-child { color: var(--text-secondary); }
.jump-panel { padding: 16px; margin-bottom: 12px; }
.section-title { margin-bottom: 15px; gap: 8px; }
.section-title h2 { margin: 0 0 2px; font-size: 15px; font-weight: 700; }
.section-title p { margin: 0; font-size: 11px; color: var(--text-muted); }
.toggle { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); white-space: nowrap; cursor: pointer; }
.toggle input { accent-color: var(--btn-primary-bg); width: 16px; height: 16px; margin: 0; }
.number-grid { display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); gap: 8px; }
.num {
  height: 42px;
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--secondary-bg-color);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.num.current { border-color: var(--accent-color); color: var(--accent-color); background: var(--accent-bg); box-shadow: inset 0 0 0 1px var(--accent-color); }
.num.labeled:not(.current) { background: var(--success-bg); color: var(--success-text); border-color: var(--success-text); }
.num.skipped:not(.current) { background: var(--warning-bg); color: var(--warning-text); border-color: var(--warning-text); }
.num:active { background: var(--card-bg-active); }
.checkmark { display: inline-block; margin-left: 2px; font-size: 11px; }
.legend { justify-content: start; flex-wrap: wrap; gap: 6px 14px; margin-top: 15px; color: var(--text-muted); font-size: 11px; }
.footer-actions { padding: 2px 0 15px; gap: 12px; }
.download {
  cursor: pointer;
  background: var(--accent-bg);
  color: var(--accent-color);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 9px 12px;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
}
.download:active { background: var(--card-bg-active); }
.footer-actions > span { color: var(--text-muted); font-size: 11px; text-align: right; }
footer { padding: 6px 0 26px; text-align: center; color: var(--text-muted); font-size: 11px; }
.login { padding: 26px 22px; max-width: 430px; margin: 50px auto 20px; }
.login-icon { font-size: 28px; margin-bottom: 13px; }
.login h1 { font-size: 21px; margin: 0 0 8px; }
.login p { margin: 0 0 18px; color: var(--text-muted); font-size: 13px; }
.login input { font-size: 15px; letter-spacing: normal; text-transform: none; }
.login button { width: 100%; height: 45px; border-radius: 8px; margin-top: 14px; }
.error { color: var(--danger-text); font-size: 12px; min-height: 14px; margin-top: 12px; }
#toast {
  position: fixed;
  z-index: 20;
  bottom: max(24px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translate(-50%, 72px);
  opacity: 0;
  background: #1e293b;
  border: 1px solid #475569;
  color: #f8fafc;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  padding: 10px 16px;
  max-width: calc(100% - 30px);
  box-shadow: 0 4px 12px rgba(0,0,0,.4);
  pointer-events: none;
  transition: opacity .16s, transform .16s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
dialog {
  padding: 12px;
  width: min(640px, calc(100% - 26px));
  max-height: 90vh;
  max-width: none;
  overflow: visible;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
}
dialog::backdrop { background: rgba(2,6,23,.85); }
dialog img { display: block; width: 100%; height: auto; }
.close-zoom {
  position: absolute;
  top: -14px;
  right: -11px;
  width: 34px;
  height: 34px;
  color: var(--btn-primary-text);
  background: var(--btn-primary-bg);
  border: 0;
  border-radius: 50%;
  font-size: 24px;
  line-height: 1;
}
@media (min-width: 680px) {
  .shell { max-width: 640px; }
  .stats, .main-card, .jump-panel { padding: 19px; }
  .num { height: 45px; }
}
@media (max-width: 360px) {
  .shell { padding: 0 12px; }
  .top { margin: 0 -12px 12px; padding: 12px; }
  .stats, .main-card, .jump-panel { padding: 13px; }
  .number-grid { gap: 6px; }
  .num { height: 39px; }
  .filename { font-size: 10px; }
  .stats-bottom { font-size: 10px; }
  .footer-actions > span { font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .progress-fill, #toast { transition: none; }
}


/* On-demand acquisition: deliberately a single manual action, no prefetch. */
.fetch-one {
  display: block;
  width: 100%;
  min-height: 46px;
  margin-top: 15px;
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  border: 1px solid var(--btn-primary-bg);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
}
.fetch-one:disabled { opacity: .65; }
.fetch-one:active:not(:disabled) { filter: brightness(1.12); }
