/* DuctLab Review (phone) - the Dash look of the desktop GUI, made for a thumb */
:root {
  --bg: #eef3fb; --panel: #ffffff; --panel2: #f3f7fe; --ink: #1b2559; --muted: #5f6e96; --line: #dde5f3; --line2: #ebf0f9;
  --accent: #2563eb; --accent-soft: #e3ecff; --good: #16a34a; --bad: #dc2626; --unsure: #d97706;
  --tag-mag-bg: #dbeafe; --tag-mag: #1d4ed8; --tag-den-bg: #fee2e2; --tag-den: #b91c1c; --tag-com-bg: #ede9fe; --tag-com: #6d28d9;
  --tag-yes-bg: #dcfce7; --tag-yes: #15803d; --tag-no-bg: #edf1f8; --tag-no: #5f6e96;
  --shadow: 0 1px 2px rgba(27,37,89,.05), 0 6px 20px rgba(27,37,89,.07);
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --bar-h: 128px;
  color-scheme: light;
}
html[data-theme="dark"] {
  --bg: #0b1437; --panel: #111c44; --panel2: #18255a; --ink: #e8edfb; --muted: #a3b1d6; --line: #24346b; --line2: #1b2a5c;
  --accent: #3b82f6; --accent-soft: #1e3a8a; --good: #22c55e; --bad: #ef4444; --unsure: #f59e0b;
  --tag-mag-bg: #1e40af; --tag-mag: #dbeafe; --tag-den-bg: #7f1d1d; --tag-den: #fecaca; --tag-com-bg: #4c1d95; --tag-com: #e9d5ff;
  --tag-yes-bg: #064e3b; --tag-yes: #a7f3d0; --tag-no-bg: #1c2a5c; --tag-no: #a3b1d6;
  --shadow: 0 8px 24px rgba(3,8,30,.45);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--sans); -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; min-height: 100dvh; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 13px; } .mono { font-family: var(--mono); }
.boot { display: grid; place-items: center; height: 100vh; } .boot img { width: 72px; height: 72px; border-radius: 16px; opacity: .9; }

/* ---- top bar ---- */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 14px 10px; background: var(--panel); border-bottom: 1px solid var(--line); }
.top .logo { width: 30px; height: 30px; border-radius: 8px; }
.top .title { font-weight: 700; font-size: 17px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  background: var(--panel2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.chip.live { color: var(--good); } .chip.live::before { background: var(--good); }
.chip.off { color: var(--unsure); } .chip.off::before { background: var(--unsure); }
.iconbtn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel2); display: grid; place-items: center; padding: 0; }
.iconbtn svg { width: 20px; height: 20px; }
.status { padding: 8px 16px 0; font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; gap: 10px; }

/* ---- the event ---- */
main { padding: 10px 12px calc(var(--bar-h) + env(safe-area-inset-bottom) + 16px); }
.card { background: var(--panel); border-radius: 16px; padding: 14px; box-shadow: var(--shadow); border: 1px solid var(--line2); }
.ev-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ev-sub { font-weight: 700; font-size: 18px; }
.ev-time { font-family: var(--mono); font-size: 13px; color: var(--muted); margin-top: 4px; }
.tag { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: var(--tag-no-bg); color: var(--tag-no); }
.tag.magnetic { background: var(--tag-mag-bg); color: var(--tag-mag); } .tag.density { background: var(--tag-den-bg); color: var(--tag-den); } .tag.compound { background: var(--tag-com-bg); color: var(--tag-com); }
.tag.yes { background: var(--tag-yes-bg); color: var(--tag-yes); }
.tag.good { background: var(--good); color: #fff; } .tag.bad { background: var(--bad); color: #fff; } .tag.unsure { background: var(--unsure); color: #fff; }
.tag.cat { background: transparent; border: 1px dashed currentColor; }
.tag.cat.good { color: var(--good); } .tag.cat.bad { color: var(--bad); } .tag.cat.unsure { color: var(--unsure); }
.ql { margin: 12px -6px 4px; border-radius: 12px; overflow: hidden; background: #fff; border: 1px solid var(--line); min-height: 160px; display: grid; place-items: center; position: relative; }
.ql img { width: 100%; display: block; }
.ql .zoomhint { position: absolute; right: 8px; bottom: 8px; background: rgba(15,27,61,.6); color: #fff; font-size: 11.5px; padding: 3px 8px; border-radius: 999px; }
.ql .noimg { color: #5f6e96; font-size: 13px; padding: 30px; text-align: center; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin-top: 12px; }
.fact .k { font-size: 12px; color: var(--muted); font-weight: 500; }
.fact .v { font-size: 14.5px; font-weight: 600; }
.fact.wide { grid-column: 1 / -1; }
.was { margin-top: 10px; font-size: 13px; color: var(--muted); }
.empty { text-align: center; padding: 40px 18px; }
.empty h2 { margin: 6px 0 8px; }

/* ---- action bar ---- */
.bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 9; background: var(--panel); border-top: 1px solid var(--line);
  padding: 8px 12px calc(env(safe-area-inset-bottom) + 10px); box-shadow: 0 -6px 20px rgba(27,37,89,.06); }
.bar .tools { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.bar .tools button, .bar .tools select { height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); padding: 0 12px; font-size: 14px; font-weight: 500; }
.bar .tools .grow { flex: 1; }
.bar .tools button { white-space: nowrap; padding: 0 11px; }
.bar .tools select { max-width: 34%; min-width: 0; padding: 0 8px; }
.bar .labels { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.bar .labels button { height: 58px; border: 0; border-radius: 14px; color: #fff; font-size: 17px; font-weight: 700; letter-spacing: .01em; }
.bar .labels button:active { transform: scale(.97); filter: brightness(.95); }
.bar .labels .bad { background: var(--bad); } .bar .labels .unsure { background: var(--unsure); } .bar .labels .good { background: var(--good); }
.bar .labels button:disabled { opacity: .45; }
.note { width: 100%; margin-top: 10px; min-height: 64px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel2); padding: 10px; resize: vertical; }

/* ---- sheets (menu), viewer, pairing ---- */
.overlay { position: fixed; inset: 0; z-index: 20; background: rgba(8,14,40,.45); display: flex; align-items: flex-end; }
.sheet { width: 100%; max-height: 88vh; overflow: auto; background: var(--panel); border-radius: 20px 20px 0 0; padding: 8px 16px calc(env(safe-area-inset-bottom) + 18px); }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 10px; }
.sheet h3 { margin: 16px 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.seg { display: flex; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; min-width: 0; border: 0; background: transparent; border-radius: 9px; padding: 8px 6px; font-size: 13.5px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--panel); color: var(--accent); box-shadow: 0 1px 3px rgba(27,37,89,.12); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.btn { border: 1px solid var(--line); background: var(--panel2); border-radius: 12px; padding: 11px 14px; font-weight: 600; font-size: 15px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.block { width: 100%; }
.btn.danger { color: var(--bad); }
.info { font-size: 13.5px; color: var(--muted); }
.info b { color: var(--ink); }
.steps { margin: 6px 0 0; padding-left: 20px; font-size: 13.5px; color: var(--muted); } .steps li { margin: 4px 0; }
.meter { height: 8px; border-radius: 999px; background: var(--panel2); overflow: hidden; margin-top: 8px; } .meter > div { height: 100%; background: var(--accent); width: 0; transition: width .2s; }

.viewer { position: fixed; inset: 0; z-index: 30; background: #fff; overflow: auto; -webkit-overflow-scrolling: touch; }
.viewer img { display: block; width: 100%; height: auto; }
.viewer .vbar { position: fixed; top: calc(env(safe-area-inset-top) + 10px); right: 12px; display: flex; gap: 8px; z-index: 31; }
.viewer .vbar button { width: 44px; height: 44px; border-radius: 12px; border: 0; background: rgba(15,27,61,.75); color: #fff; font-size: 20px; font-weight: 700; }

.pair { max-width: 460px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 40px) 22px 40px; text-align: center; }
.pair img { width: 84px; height: 84px; border-radius: 20px; box-shadow: var(--shadow); }
.pair h1 { margin: 16px 0 4px; font-size: 24px; }
.pair .code { width: 100%; text-align: center; font-size: 28px; letter-spacing: .14em; font-family: var(--mono); padding: 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); margin: 20px 0 10px; }
.pair .name { width: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); margin-bottom: 14px; }
.pair .err { color: var(--bad); font-size: 14px; min-height: 20px; margin-bottom: 8px; }
.pair .help { text-align: left; margin-top: 26px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--bar-h) + env(safe-area-inset-bottom) + 18px); z-index: 40;
  background: var(--ink); color: var(--panel); padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: 90vw; box-shadow: var(--shadow); }
.toast.error { background: var(--bad); color: #fff; }

/* ---- the interactive figure ---- */
.figswitch { display: inline-flex; margin-top: 10px; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 2px; gap: 2px; }
.figswitch button { border: 0; background: transparent; border-radius: 8px; padding: 5px 12px; font-size: 13px; font-weight: 600; color: var(--muted); }
.figswitch button.on { background: var(--panel); color: var(--accent); box-shadow: 0 1px 3px rgba(27,37,89,.12); }
.figbox { margin: 8px -8px 4px; min-height: 160px; }
.figbox > .noimg { color: var(--muted); font-size: 13px; padding: 40px 10px; text-align: center; }
.dfig-wrap { position: relative; }
.dfig-canvas { display: block; touch-action: pan-y; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.dfig-tip { position: absolute; top: 4px; left: 44px; right: 50px; background: rgba(15,27,61,.86); color: #fff; font-size: 12px; line-height: 1.35;
  padding: 6px 9px; border-radius: 9px; pointer-events: auto; }
.dfig-tools { padding: 6px 8px 0; display: grid; gap: 6px; }
.dfig-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dfig-seg { display: inline-flex; background: var(--panel2); border: 1px solid var(--line); border-radius: 9px; padding: 2px; gap: 2px; }
.dfig-seg .dfig-b { border: 0; background: transparent; }
.dfig-b { height: 32px; min-width: 34px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel2); font-size: 13px; font-weight: 600; color: var(--muted); }
.dfig-b.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.dfig-seg .dfig-b.on { background: var(--panel); color: var(--accent); box-shadow: 0 1px 3px rgba(27,37,89,.12); }
.dfig-sel { height: 32px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel2); padding: 0 6px; font-size: 13px; max-width: 130px; flex: 1; }
.dfig-hint b { color: var(--ink); font-weight: 600; }
.dfig-txt { font-size: 12px; color: var(--muted); }
.dfig-grow { flex: 1; }
.dfig-hint { font-size: 11.5px; color: var(--muted); }

/* ---- correcting an event (walls, type) ---- */
.ev-head .grow { flex: 1; }
.editbtn { height: 32px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); padding: 0 11px; font-size: 13px; font-weight: 600; color: var(--accent); white-space: nowrap; }
.card.editing { border-color: #f97316; box-shadow: 0 0 0 2px rgba(249,115,22,.18), var(--shadow); }
.editp { margin-top: 10px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.edit-title { font-weight: 700; font-size: 16px; }
.wallrow { display: flex; align-items: center; gap: 5px; min-width: 0; }
.wallrow .k { flex: 0 0 34px; font-size: 13px; color: var(--muted); font-weight: 600; }
.wallrow .u { font-size: 13px; color: var(--muted); }
.wallnum { flex: 0 1 96px; width: 96px; min-width: 64px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); padding: 0 8px; font-family: var(--mono); font-size: 15px; text-align: right; }
.nudge { flex: 0 0 40px; width: 40px; height: 40px; border-radius: 10px; border: 1px solid #f97316; background: var(--panel); color: #c2410c; font-size: 20px; font-weight: 700; padding: 0; }
.nudge:active { background: #fff1e6; }
.mini { margin-left: auto; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); padding: 0 10px; font-size: 13px; font-weight: 600; }
.wallinfo { font-family: var(--mono); font-size: 12.5px; color: #c2410c; }
html[data-theme="dark"] .wallinfo, html[data-theme="dark"] .nudge { color: #fdba74; }
.k2 { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; margin-top: 4px; }
.subs { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.subl { display: flex; align-items: center; gap: 8px; min-width: 0; }
.subl .k { flex: 0 0 104px; font-size: 13px; color: var(--muted); }
.subsel { flex: 1; min-width: 0; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); padding: 0 8px; font-size: 14.5px; }
.bar .labels.two { grid-template-columns: 1fr 2fr; }
.bar .labels .cancel { background: var(--panel2); color: var(--ink); border: 1px solid var(--line); }
.row.center { justify-content: center; margin-top: 6px; }

/* ---- finding new candidates ---- */
.frow { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.frow label { display: grid; gap: 4px; }
.frow .k { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.frow input { height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel2); padding: 0 10px; font-size: 15px; width: 100%; min-width: 0; }
.sheet .k2 { margin: 12px 0 6px; }
.info.warn { color: var(--bad); }
.sheet .err { color: var(--bad); font-size: 14px; min-height: 18px; margin: 6px 0; }
.err.small { font-size: 12.5px; color: var(--bad); }
.jobs { display: grid; gap: 8px; }
.job { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--panel2); }
.job-h { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.jst { font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: var(--tag-no-bg); color: var(--tag-no); }
.jst.running, .jst.queued { background: var(--accent-soft); color: var(--accent); }
.jst.done { background: var(--tag-yes-bg); color: var(--tag-yes); }
.jst.failed { background: var(--tag-den-bg); color: var(--tag-den); }

/* ---- the figure's frame: this event / previous & next; adding a missed duct ---- */
.figrow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 10px; }
.figrow .figswitch { margin-top: 0; }
.addbtn { height: 30px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); padding: 0 10px; font-size: 13px; font-weight: 600; color: var(--good); white-space: nowrap; }
.framenote { font-size: 12px; color: var(--unsure); margin: 2px 0 4px; }
.editp.adding .edit-title { color: var(--good); }
.dfig-warn { color: var(--unsure); font-weight: 600; }
.dfig-this { background: #facc15; color: #713f12; font-weight: 600; padding: 0 5px; border-radius: 3px; white-space: nowrap; }
