@font-face{
  font-family: "Office Times Round Mono";
  src: url("../assets/fonts/OfficeTimesRoundMono-Regular.otf") format("opentype");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root{
  --bg: #f4f0e6;
  --ink: #143018;
  --olive: #3a6b3f;
  --line: #00ff88;
  --shadow: rgba(0,0,0,.08);
  --radius: 14px;
  --uploadStroke: #A79322;
}

html, body{
  height:100%;
  margin:0;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-serif, "Iowan Old Style", "Palatino", "Georgia", serif;
  overflow:hidden;
  -webkit-tap-highlight-color: transparent;
}

.app{
  position:fixed;
  inset:0;
  overflow:hidden;
}

/* Subtle risograph-like paper texture on viewer page only. */
.app::before{
  content:"";
  position:absolute;
  inset:0;
  pointer-events:none;
  z-index: 2;
  opacity:.42;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(35,35,20,.06) 0px,
      rgba(35,35,20,.06) 1px,
      transparent 1px,
      transparent 3px
    ),
    repeating-linear-gradient(
      90deg,
      rgba(35,35,20,.04) 0px,
      rgba(35,35,20,.04) 1px,
      transparent 1px,
      transparent 4px
    ),
    radial-gradient(circle at 12% 18%, rgba(80,72,36,.18) 0 0.8px, transparent 1.1px),
    radial-gradient(circle at 76% 61%, rgba(48,46,34,.14) 0 0.9px, transparent 1.2px),
    radial-gradient(circle at 42% 83%, rgba(40,38,28,.12) 0 0.9px, transparent 1.1px);
  background-size: auto, auto, 23px 23px, 29px 29px, 31px 31px;
  mix-blend-mode: normal;
}

.app::after{
  content:"";
  position:absolute;
  inset:0;
  pointer-events:none;
  z-index: 1;
  background: radial-gradient(circle at 50% 46%, rgba(255,255,255,0) 0%, rgba(118,100,66,.13) 100%);
}

canvas.webgl{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  display:block;
}

.hud{
  position:fixed;
  inset:0;
  pointer-events:none;
}

.hud .corner{
  position:absolute;
  top:14px;
  left:14px;
  pointer-events:auto;
  opacity:0;
  transform: translateY(-4px);
  transition: opacity .18s ease, transform .18s ease;
  background:transparent;
}

.hud .corner.visible{
  opacity:1;
  transform: translateY(0);
}

/* Explicit px on both the control and the <img> — tiny % changes are invisible on retina / zoomed UIs */
.hud .corner .chairBtn{
  /* Non-<button> control — nothing from UA should paint a white surface */
  width: 30px !important;
  height: 30px !important;
  min-width: 30px;
  min-height: 30px;
  max-width: 30px;
  max-height: 30px;
  padding:0;
  margin:0;
  border:none;
  border-radius:0;
  background:transparent;
  background-color:rgba(0,0,0,0);
  box-shadow:none;
  backdrop-filter:none;
  display:grid;
  place-items:center;
  cursor:pointer;
  color:inherit;
  -webkit-tap-highlight-color: transparent;
  user-select:none;
  box-sizing: border-box;
  /* Grid + replaced <img> default min-width:auto can inflate past max-width in some engines */
  overflow: hidden;
  align-content: center;
  justify-content: center;
}

.hud .corner .chairBtn:focus{
  outline:none;
}

.hud .corner .chairBtn:focus-visible{
  outline:2px solid rgba(58,107,63,0.55);
  outline-offset:3px;
  border-radius:4px;
}

.hud .corner .chairBtn:hover{ transform: translateY(-1px); }
.hud .corner .chairBtn:active{ transform: translateY(0); }

.hud .corner .chairBtnIcon{
  width: 30px !important;
  height: 30px !important;
  max-width: 30px !important;
  max-height: 30px !important;
  min-width: 0 !important;
  min-height: 0 !important;
  display:block;
  object-fit:contain;
  pointer-events:none;
  background:transparent;
  border-radius:0;
  mix-blend-mode:normal;
  box-sizing: border-box;
}

/* ID beats stale cached `.chairBtn { 44px }` from older deploys */
#homeBtn.chairBtn{
  width: 30px !important;
  height: 30px !important;
  min-width: 30px !important;
  max-width: 30px !important;
  min-height: 30px !important;
  max-height: 30px !important;
  box-sizing: border-box !important;
}

#homeBtn .chairBtnIcon{
  width: 30px !important;
  height: 30px !important;
  max-width: 30px !important;
  max-height: 30px !important;
  min-width: 0 !important;
  min-height: 0 !important;
}

.uploadCounter{
  position: fixed;
  left: calc(14px + max(0px, env(safe-area-inset-left)));
  bottom: calc(14px + max(0px, env(safe-area-inset-bottom)));
  z-index: 50;
  display: inline-flex;
  align-items: baseline;
  gap: 0.4em;
  padding: 10px 18px;
  background: #ffffff;
  border: 2px solid var(--uploadStroke);
  border-radius: 4px;
  box-sizing: border-box;
  font-family: "Office Times Round Mono", ui-monospace, monospace;
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--uploadStroke);
  pointer-events: none;
  box-shadow: 0 4px 14px var(--shadow);
}

.uploadCounter__value{
  font-variant-numeric: tabular-nums;
  min-width: 1.25em;
}

/* Scan page */
.scanRoot{
  position:fixed;
  inset:0;
  background:#000;
  display:block;
  height: 100vh;
  height: 100dvh;
}

video#video{
  width:100%;
  height:100%;
  object-fit:cover;
  transform: scaleX(-1); /* front camera feel; we correct capture below */
  pointer-events:none; /* prevent taps pausing video on iOS */
}

.frameOverlay{
  position:absolute;
  inset:0;
  pointer-events:none;
  display:grid;
  place-items:center;
}

.scanStack{
  position: relative;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap: 14px;
  pointer-events:none;
}

.frame{
  width:min(86vw, 520px);
  aspect-ratio: 3 / 2;
  border-radius: 18px;
  box-shadow: 0 0 0 2px rgba(255,255,255,.45), 0 18px 45px rgba(0,0,0,.35);
  background:
    linear-gradient(transparent, transparent) padding-box,
    radial-gradient(closest-side, rgba(180,159,41,0), transparent 70%) border-box;
  border: 1px solid rgba(255,255,255,.24);
  position:relative;
  z-index: 2;
}

.frame.hasSubject{
  background:
    linear-gradient(transparent, transparent) padding-box,
    radial-gradient(closest-side, rgba(180,159,41,.30), transparent 70%) border-box;
}

.frame:before{
  content:"";
  position:absolute;
  inset:-14px;
  border-radius: 26px;
  box-shadow: 0 0 0 9999px rgba(180,159,41,.30);
  z-index: 1;
  pointer-events:none;
}

.scanBar{
  position: relative;
  display:flex;
  align-items:center;
  justify-content:center;
  gap: 10px;
  padding: 0;
  background: none;
  pointer-events: auto;
  z-index: 5;
}

.pill{
  color:#fff;
  font-size:12px;
  letter-spacing:.02em;
  background: rgba(0,0,0,.34);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  padding:10px 12px;
  backdrop-filter: blur(10px);
  max-width: 56vw;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.scanRoot button,
.previewOverlay button{
  font-family: "Office Times Round Mono", ui-monospace, monospace;
  font-synthesis: none;
}

.primaryBtn{
  pointer-events:auto;
  appearance:none;
  border:0;
  border-radius: 999px;
  padding: 13px 20px;
  font-weight: 700;
  font-size: 14px;
  color: #2e2808;
  background: #b49f29;
  box-shadow: 0 10px 28px rgba(180,159,41,.32);
  cursor:pointer;
}

.primaryBtn:disabled{
  opacity:.55;
  cursor:not-allowed;
}

.archiveBtn{
  pointer-events:auto;
  appearance:none;
  border: 2px solid #b49f29;
  border-radius: 999px;
  padding: 11px 16px;
  font-weight: 700;
  font-size: 14px;
  color: #b49f29;
  background: #ffffff;
  box-shadow: 0 8px 24px rgba(0,0,0,.14);
  cursor:pointer;
  display:none;
}

.archiveBtn.visible{
  display:inline-block;
}

.previewOverlay{
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  place-items: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: rgba(0, 0, 0, 0.72);
  box-sizing: border-box;
}

.previewOverlay.visible{
  display: grid;
}

.previewPanel{
  width: min(92vw, 420px);
  max-height: min(88vh, 720px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 18px 16px;
  background: #1a1a1a;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
}

.previewTitle{
  margin: 0;
  text-align: center;
  font-family: "Office Times Round Mono", ui-monospace, monospace;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.75);
}

.previewImg{
  width: 100%;
  flex: 1;
  min-height: 0;
  object-fit: contain;
  border-radius: 12px;
  background: #000;
  display: block;
}

.previewActions{
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.previewRetakeBtn{
  appearance: none;
  border: 2px solid #b49f29;
  border-radius: 999px;
  padding: 12px 22px;
  font-weight: 700;
  font-size: 14px;
  color: #b49f29;
  background: transparent;
  cursor: pointer;
}

.previewOkBtn{
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 12px 28px;
  font-weight: 700;
  font-size: 14px;
  color: #2e2808;
  background: #b49f29;
  box-shadow: 0 8px 22px rgba(180, 159, 41, 0.35);
  cursor: pointer;
}

.previewRetakeBtn:disabled,
.previewOkBtn:disabled{
  opacity: 0.5;
  cursor: not-allowed;
}

.toast{
  position:fixed;
  left:50%;
  bottom: calc(16px + max(0px, env(safe-area-inset-bottom)));
  transform: translateX(-50%);
  pointer-events:none;
  color:#fff;
  background: rgba(0,0,0,.55);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  padding: 10px 12px;
  font-size: 12px;
  backdrop-filter: blur(10px);
  opacity:0;
  transition: opacity .18s ease;
}

.toast.visible{ opacity:1; }

