:root {
  --bg: #FFFFFF;
  --fg: #000000;
  --accent: #FF6A00;
  --line: rgba(0, 0, 0, 0.12);
  --muted: rgba(0, 0, 0, 0.55);

  --font: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --fs-title: 28px;
  --fs-body: 17px;
  --fs-label: 13px;

  --u: 8px;
  --gutter: 24px;
  --radius: 12px;
  --btn-h: 52px;
  --dur: 150ms;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  color-scheme: light;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--fg);
}

body {
  font-family: var(--font);
  font-size: var(--fs-body);
  font-weight: 300;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, button {
  font-weight: 300;
}

h1, h2, p, ol, ul {
  margin: 0;
}

[hidden] {
  display: none !important;
}

.screen {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding:
    calc(var(--u) * 6 + var(--safe-top))
    calc(var(--gutter) + var(--safe-right))
    calc(var(--gutter) + var(--safe-bottom))
    calc(var(--gutter) + var(--safe-left));
}

@supports (-webkit-touch-callout: none) {
  html {
    height: -webkit-fill-available;
  }

  .screen {
    min-height: -webkit-fill-available;
  }
}

.screen > * + * {
  margin-top: calc(var(--u) * 5);
}

.title {
  font-size: var(--fs-title);
  font-weight: 200;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.label {
  font-size: var(--fs-label);
  letter-spacing: 0.04em;
}

.muted {
  color: var(--muted);
}

.head > * + * {
  margin-top: var(--u);
}

.btn {
  display: block;
  width: 100%;
  height: var(--btn-h);
  padding: 0 calc(var(--u) * 2);
  border: 0;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: var(--fs-body);
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  transition: opacity var(--dur) ease-out;
}

.btn:active {
  opacity: 0.7;
}

.btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.btn-primary {
  background: var(--accent);
  color: #FFFFFF;
}

.btn-secondary {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--fg);
}

.btn:focus {
  outline: none;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.accent {
  color: var(--accent);
}

.btn-bracket {
  display: inline-block;
  align-self: flex-start;
  min-height: 44px;
  padding: var(--u) 0;
  border: 0;
  background: none;
  color: var(--fg);
  font-family: inherit;
  font-size: var(--fs-body);
  text-align: left;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  transition: color var(--dur) ease-out;
}

.btn-bracket::before {
  content: "[\00a0";
}

.btn-bracket::after {
  content: "\00a0]";
}

.btn-bracket:active,
.btn-bracket.is-armed {
  color: var(--accent);
}

.btn-bracket:disabled {
  opacity: 0.35;
  cursor: default;
}

.btn-bracket-small {
  font-size: var(--fs-label);
  letter-spacing: 0.04em;
}

.btn-bracket:focus {
  outline: none;
}

.btn-bracket:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-scan {
  align-self: center;
  min-height: 64px;
  padding: calc(var(--u) * 2) calc(var(--u) * 2);
  color: var(--accent);
  font-size: 24px;
  font-weight: 300;
  text-align: center;
  transition: opacity var(--dur) ease-out;
}

.btn-scan::before,
.btn-scan::after {
  content: none;
}

.btn-scan:active {
  color: var(--accent);
  opacity: 0.6;
}

.site-footer {
  text-align: center;
}

.site-footer > * + * {
  margin-top: calc(var(--u) * 1.5);
}

.site-footer nav {
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.site-footer nav > * + * {
  margin-left: calc(var(--u) * 1.5);
}

.site-footer nav a {
  display: inline-block;
  padding: var(--u) 0;
  color: var(--muted);
  text-decoration: none;
  transition: color var(--dur) ease-out;
}

.site-footer nav a:active,
.site-footer nav a[aria-current="page"] {
  color: var(--accent);
}

.site-footer nav span {
  color: var(--line);
}

.legal {
  max-width: 640px;
  margin: 0 auto;
  overflow-wrap: anywhere;
}

.legal .head {
  padding-bottom: calc(var(--u) * 3);
  border-bottom: 1px solid var(--line);
}

.legal section > * + * {
  margin-top: calc(var(--u) * 1.5);
}

.legal h2 {
  font-size: var(--fs-body);
  line-height: 1.35;
}

.legal section p,
.legal li {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.65;
}

.legal ul {
  padding-left: calc(var(--u) * 2.5);
}

.legal li + li {
  margin-top: var(--u);
}

.legal a {
  color: var(--accent);
  text-decoration: none;
}

.legal code {
  font-family: inherit;
  color: var(--fg);
}

.legal .legal-back {
  color: var(--fg);
}

.legal .site-footer {
  padding-top: calc(var(--u) * 3);
  border-top: 1px solid var(--line);
}

.page-actions {
  display: flex;
  margin-left: auto;
}

.icon-btn {
  width: 44px;
  height: 44px;
  padding: 12px;
  border: 0;
  background: none;
  color: var(--fg);
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  transition: color var(--dur) ease-out, opacity var(--dur) ease-out;
}

.icon-btn svg {
  display: block;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-btn:active {
  color: var(--accent);
}

.icon-btn:disabled {
  opacity: 0.2;
  cursor: default;
}

.icon-btn:focus {
  outline: none;
}

.icon-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.export {
  display: flex;
  flex-direction: column;
}

.export > * + * {
  margin-top: calc(var(--u) * 2);
}

.toggle {
  display: flex;
  align-items: center;
  cursor: pointer;
}

.toggle input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.toggle-track {
  position: relative;
  width: 44px;
  height: 26px;
  margin-left: calc(var(--u) * 1.5);
  border: 1px solid var(--fg);
  border-radius: 13px;
  transition: background-color var(--dur) ease-out, border-color var(--dur) ease-out;
}

.toggle-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--fg);
  transition: transform var(--dur) ease-out, background-color var(--dur) ease-out;
}

.toggle input:checked + .toggle-track {
  border-color: var(--accent);
  background: var(--accent);
}

.toggle input:checked + .toggle-track::after {
  background: #FFFFFF;
  transform: translateX(18px);
}

.toggle input:focus-visible + .toggle-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.pages > * + * {
  margin-top: calc(var(--u) * 2);
}

.page-list {
  padding: 0;
  list-style: none;
}

.page-list > li {
  display: flex;
  align-items: center;
  padding: calc(var(--u) * 2) 0;
  border-top: 1px solid var(--line);
}

.page-list > li:last-child {
  border-bottom: 1px solid var(--line);
}

.foot {
  margin-top: auto;
  padding-top: calc(var(--u) * 5);
}

.page-thumb {
  width: 48px;
  height: 64px;
  margin-right: calc(var(--u) * 2);
  object-fit: cover;
  border: 1px solid var(--line);
}

.screen-full {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
}

.stage-media {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.stage-contain {
  object-fit: contain;
}

.stage-edit {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.quad {
  overflow: visible;
  pointer-events: none;
}

.quad polygon {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-linejoin: round;
}

.handle {
  position: absolute;
  top: -22px;
  left: -22px;
  width: 44px;
  height: 44px;
  touch-action: none;
  cursor: grab;
}

.handle::after {
  content: "";
  position: absolute;
  top: 8px;
  left: 8px;
  width: 28px;
  height: 28px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  box-sizing: border-box;
  transition: transform var(--dur) ease-out;
}

.handle.is-active::after {
  transform: scale(1.15);
}

.lupe {
  position: absolute;
  top: 0;
  left: 0;
  width: 112px;
  height: 112px;
  border: 1px solid var(--line);
  border-radius: 50%;
  pointer-events: none;
}

.stage-padded {
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    calc(var(--u) * 3 + var(--safe-top))
    calc(var(--gutter) + var(--safe-right))
    0
    calc(var(--gutter) + var(--safe-left));
}

.page-view {
  display: block;
  max-width: 100%;
  max-height: 100%;
  border: 1px solid var(--line);
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
  padding:
    calc(var(--u) * 3)
    calc(var(--gutter) + var(--safe-right))
    calc(var(--u) * 3 + var(--safe-bottom))
    calc(var(--gutter) + var(--safe-left));
  background: var(--bg);
}

.bar-row {
  padding-bottom: 0;
}

.bar-buttons > .btn + .btn {
  margin-left: calc(var(--u) * 2);
}

.btn-text,
.bar-spacer {
  flex: 1 1 0;
}

.btn-text {
  padding: 0;
  border: 0;
  background: none;
  color: var(--fg);
  font-family: inherit;
  font-size: var(--fs-body);
  text-align: left;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

.shutter {
  flex: 0 0 auto;
  width: 72px;
  height: 72px;
  padding: 0;
  border: 3px solid var(--accent);
  border-radius: 50%;
  background: var(--bg);
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  transition: transform var(--dur) ease-out;
}

.shutter::after {
  content: "";
  display: block;
  width: 56px;
  height: 56px;
  margin: 5px;
  border: 1px solid var(--line);
  border-radius: 50%;
}

.shutter:active {
  transform: scale(0.94);
}

.shutter:disabled {
  opacity: 0.35;
}

.shutter:focus {
  outline: none;
}

.shutter:focus-visible,
.btn-text:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.toast {
  position: fixed;
  left: calc(var(--gutter) + var(--safe-left));
  right: calc(var(--gutter) + var(--safe-right));
  top: calc(var(--u) * 2 + var(--safe-top));
  z-index: 10;
  padding: calc(var(--u) * 2);
  border-radius: var(--radius);
  background: var(--fg);
  color: var(--bg);
  font-size: var(--fs-label);
  letter-spacing: 0.04em;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0ms !important;
    animation-duration: 0ms !important;
  }
}
