:root {
  --bg: #f2f2f7; --cell: #fff; --label: #000;
  --sec: rgba(60,60,67,.6); --ter: rgba(60,60,67,.3); --sep: rgba(60,60,67,.29);
  --fill: rgba(118,118,128,.12); --tint: #007aff; --tint-soft: rgba(0,122,255,.12);
  --green: #248a3d; --orange: #ff9500; --red: #ff3b30;
  --navbar: #0f2a44; --seg-on: #fff;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000; --cell: #1c1c1e; --label: #fff;
    --sec: rgba(235,235,245,.6); --ter: rgba(235,235,245,.3); --sep: rgba(84,84,88,.65);
    --fill: rgba(118,118,128,.24); --tint: #0a84ff; --tint-soft: rgba(10,132,255,.2);
    --green: #30d158; --orange: #ff9f0a; --red: #ff453a;
    --navbar: #0d1b2b; --seg-on: #636366;
  }
}
* { box-sizing: border-box; }
html, body {
  margin: 0; background-color: var(--navbar);
  background-image: linear-gradient(var(--bg), var(--bg));
  background-repeat: no-repeat; background-position: 0 260px;
}
body {
  font: 17px/1.29 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  letter-spacing: -.41px; color: var(--label); -webkit-text-size-adjust: 100%;
  min-height: 100vh;
}
button { font: inherit; letter-spacing: inherit; cursor: pointer; }
[hidden] { display: none !important; }

.nav { background: var(--navbar); color: #fff; padding: env(safe-area-inset-top) 16px 16px; }
.navrow { display: flex; justify-content: space-between; align-items: center; height: 44px; max-width: 760px; margin: 0 auto; }
.large { font-size: 34px; line-height: 41px; font-weight: 700; letter-spacing: .37px; margin: 0 auto; max-width: 760px; }
.navsub { margin: 2px auto 0; max-width: 760px; color: rgba(255,255,255,.65); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iconbtn { background: none; border: 0; color: inherit; min-width: 44px; min-height: 44px; display: grid; place-items: center; padding: 0; }

main { background: var(--bg); max-width: 760px; margin: 0 auto; padding: 20px 16px calc(40px + env(safe-area-inset-bottom)); min-height: 60vh; }

.card { background: var(--cell); border-radius: 10px; padding: 12px 16px; margin-bottom: 20px; }
.cardh, .subh { font-size: 13px; line-height: 18px; font-weight: 600; text-transform: uppercase; letter-spacing: -.08px; color: var(--sec); margin: 0 0 8px; }
.subh { margin: 20px 16px 6px; }
.preview { aspect-ratio: 800 / 480; border-radius: 6px; overflow: hidden; background: var(--fill); display: grid; place-items: center; }
.preview img { width: 100%; height: 100%; object-fit: contain; display: block; background: #fff; }
.previewEmpty { color: var(--sec); font-size: 15px; margin: 0; }

.group { background: var(--cell); border-radius: 10px; overflow: hidden; margin: 0; }
.cell { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; padding: 0 16px; position: relative; }
.cell + .cell::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: .5px solid var(--sep); }
.cell input { border: 0; background: none; text-align: right; font: inherit; color: var(--label); flex: 1; min-width: 0; padding: 11px 0; outline: none; text-transform: uppercase; }
.cell input::placeholder { color: var(--ter); }
.val { color: var(--sec); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }

.foot, .note { font-size: 13px; line-height: 18px; letter-spacing: -.08px; color: var(--sec); margin: 6px 16px 0; }
.note { margin: 8px 0 0; }

.btn { background: var(--tint); color: #fff; border: 0; border-radius: 10px; min-height: 44px; padding: 0 18px; font-weight: 600; white-space: nowrap; }
.btn:disabled { opacity: .5; }
.btn.wide { width: 100%; margin-top: 12px; }

.seg { display: flex; background: var(--fill); border-radius: 9px; padding: 2px; }
.seg button { flex: 1; min-height: 32px; border: 0; background: none; border-radius: 7px; font-size: 13px; font-weight: 500; color: var(--label); }
.seg button[aria-checked="true"] { background: var(--seg-on); font-weight: 600; box-shadow: 0 3px 8px rgba(0,0,0,.12), 0 3px 1px rgba(0,0,0,.04); }

.msg { background: var(--fill); border-radius: 10px; padding: 10px 12px; font-size: 15px; letter-spacing: -.24px; margin: 12px 0 0; }
.msg.warn { background: rgba(255,149,0,.15); }

.empty { text-align: center; color: var(--sec); padding: 48px 16px; }

.updcard { background: var(--cell); border: 1px solid var(--tint); border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,.08); margin: 12px auto 0; max-width: 728px; padding: 12px 16px; position: relative; z-index: 1; }
.updrow { display: flex; align-items: center; gap: 12px; }
.updtext { flex: 1; font-weight: 600; }
.later { display: block; margin: 6px auto 0; background: none; border: 0; color: var(--tint); font-weight: 600; min-height: 44px; }
.upderr { color: var(--red); font-size: 13px; margin: 0; text-align: center; }

.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 10; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-width: 760px; margin: 0 auto; background: var(--bg); border-radius: 10px 10px 0 0; z-index: 11; max-height: 92vh; display: flex; flex-direction: column; animation: up .32s cubic-bezier(.2,.9,.3,1); }
@keyframes up { from { transform: translateY(100%); } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }
.grabber { width: 36px; height: 5px; border-radius: 3px; background: var(--ter); margin: 6px auto 0; }
.sheethead { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; padding: 0 8px; }
.sheethead h2 { text-align: center; font-size: 17px; font-weight: 600; margin: 0; }
.close { color: var(--sec); }
.sheetbody { padding: 8px 16px 16px; overflow-y: auto; }
.flabel { display: block; font-size: 13px; color: var(--sec); margin: 12px 0 6px; }
.sheetbody input { width: 100%; background: var(--fill); border: 0; border-radius: 10px; font: inherit; color: var(--label); padding: 11px 12px; outline: none; }
.sheetbody input:focus { box-shadow: inset 0 0 0 2px var(--tint); }
.sheet-foot { padding: 0 16px calc(16px + env(safe-area-inset-bottom)); }

.preview svg { width: 100%; height: 100%; display: block; }
#previewSvg { width: 100%; height: 100%; }
button.cell { width: 100%; border: 0; background: none; color: var(--label); text-align: left; }
.chev { color: var(--ter); font-size: 22px; line-height: 1; }
.group.inset { background: var(--cell); margin-top: 16px; }
.check { color: var(--tint); font-weight: 600; }
@media (orientation: landscape) and (max-height: 500px) {
  #labSheet { max-height: 100vh; border-radius: 0; }
  #labSheet .sheetbody { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; align-items: start; }
  #labSheet .note { display: none; }
  #labSheet .group.inset { margin-top: 0; }
}
.btn.sec { background: var(--tint-soft); color: var(--tint); font-weight: 500; }
