



:root {
  --paper: #0d0e11; --card: #16181d; --card2: #1c1f26; --rule: #262a33; --text: #eef1f6; --muted: #98a2b3;
  --amber: #f59e0b; --green: #22c55e; --red: #ef4444; --top: 0px; --dock: 0px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body.bc {
  margin: 0; background: var(--paper); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  padding-bottom: calc(var(--dock) + env(safe-area-inset-bottom));
}
a { color: var(--amber); }
button, input, textarea { font: inherit; color: inherit; }
code { font: 0.92em/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.bc-sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }


.bc-head { min-width: 0; }
.bc-head h1 { margin: 0; font-size: 24px; line-height: 1.2; letter-spacing: -0.01em; }
.bc-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

.bc-main { max-width: 1240px; margin: 0 auto; padding: 12px 16px 24px; display: grid; gap: 12px; }
.bc-side { display: grid; gap: 12px; align-content: start; min-width: 0; }
.bc-list { min-width: 0; display: grid; gap: 12px; align-content: start; }
.bc-card { background: var(--card); border: 1px solid var(--rule); border-radius: 14px; padding: 14px; min-width: 0; }
.bc-card h2, .bc-unexpected h2 { margin: 0 0 10px; font-size: 15px; }


.bc-status { position: sticky; top: calc(var(--top) + 8px); z-index: 10; padding: 12px 14px; box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35); }
.bc-count { margin: 0; font-size: 15px; color: var(--muted); }
.bc-count b { font-size: 26px; color: var(--text); font-variant-numeric: tabular-nums; }
.bc-count-w { margin-left: 4px; }
.bc-bar { height: 8px; margin: 8px 0 10px; border-radius: 99px; background: #262a33; overflow: hidden; }
.bc-bar i { display: block; height: 100%; width: 0; background: var(--amber); border-radius: inherit; transition: width 0.3s ease; }
.bc-status.is-done .bc-bar i { background: var(--green); }
.bc-stats { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.bc-stat { font-size: 13px; padding: 3px 9px; border-radius: 99px; border: 1px solid var(--rule); color: var(--muted); }
.bc-stat b { color: var(--text); font-variant-numeric: tabular-nums; }
.bc-stat.miss b { color: var(--amber); }
.bc-stat.ok b { color: var(--green); }
.bc-stat.bad { border-color: rgba(239, 68, 68, 0.6); color: #fca5a5; }
.bc-stat.bad b { color: var(--red); }
.bc-filter { display: inline-flex; padding: 3px; gap: 3px; border-radius: 11px; background: var(--paper); border: 1px solid var(--rule); }
.bc-filter button { appearance: none; border: 0; background: none; border-radius: 8px; padding: 6px 14px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.bc-filter button[aria-pressed="true"] { background: var(--amber); color: #111; }


.bc-scanrow { display: flex; gap: 8px; align-items: stretch; }
.bc-cam-btn {
  appearance: none; flex: none; display: inline-flex; align-items: center; gap: 6px; height: 48px; padding: 0 14px;
  border-radius: 12px; border: 0; background: var(--amber); color: #111; font-weight: 700; cursor: pointer;
}
.bc-cam-btn svg { width: 22px; height: 22px; }
.bc-cam-btn[aria-pressed="true"] { background: #fff; }
.bc-type { flex: 1; display: flex; min-width: 0; height: 48px; border-radius: 12px; border: 1px solid #3a3f4b; background: var(--paper); overflow: hidden; }
.bc-type:focus-within { border-color: var(--amber); }
.bc-type input { flex: 1; min-width: 0; border: 0; background: none; padding: 0 12px; font-size: 16px; outline: none; }
.bc-go { appearance: none; flex: none; width: 48px; border: 0; border-left: 1px solid #3a3f4b; background: var(--card2); cursor: pointer; display: grid; place-items: center; }
.bc-go svg { width: 22px; height: 22px; }
.bc-hint { margin: 8px 2px 0; font-size: 13px; color: var(--muted); }
.bc-sim { margin-top: 10px; border-top: 1px solid var(--rule); padding-top: 10px; }
.bc-sim summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text); }
.bc-sim summary small { color: var(--muted); font-weight: 400; }
.bc-sim-btns { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-top: 8px; }
.bc-sim-btns button { appearance: none; min-height: 38px; padding: 4px 6px; border-radius: 9px; border: 1px solid var(--rule); background: var(--card2); font-size: 12.5px; font-weight: 600; cursor: pointer; line-height: 1.2; }
.bc-sim-btns button[data-sim="wrong"] { border-color: rgba(239, 68, 68, 0.55); color: #fca5a5; }
.bc-sim-btns button:hover { border-color: var(--amber); }
.bc-sim-code { margin: 8px 0 0; display: flex; align-items: center; gap: 10px; min-width: 0; }
.bc-sim-code canvas { display: block; height: 36px; max-width: 58%; border-radius: 4px; image-rendering: pixelated; }
.bc-sim-code figcaption { font: 12px/1.3 ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: var(--muted); overflow-wrap: anywhere; }


.bc-samples { display: grid; gap: 8px; margin-bottom: 12px; }
.bc-sample { appearance: none; text-align: left; padding: 10px 12px; border-radius: 11px; border: 1px solid #3a3f4b; background: var(--card2); cursor: pointer; }
.bc-sample b { display: block; font-size: 14px; }
.bc-sample span { font-size: 12.5px; color: var(--muted); }
.bc-sample:hover { border-color: var(--amber); }
.bc-label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.bc-import textarea { width: 100%; min-height: 104px; resize: vertical; border-radius: 10px; border: 1px solid #3a3f4b; background: var(--paper); padding: 10px; font: 13px/1.45 ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.bc-import textarea:focus { outline: none; border-color: var(--amber); }
.bc-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.bc-btn { appearance: none; display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 10px; border: 1px solid #3a3f4b; background: var(--card2); font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none; color: var(--text); }
.bc-btn:hover { border-color: var(--amber); }
.bc-btn.primary { background: var(--amber); border-color: var(--amber); color: #111; }
.bc-btn.danger { border-color: rgba(239, 68, 68, 0.6); color: #fca5a5; }
.bc-read-note { margin: 8px 0 0; font-size: 13px; color: var(--muted); min-height: 0; }
.bc-read-note:empty { display: none; }
.bc-add, .bc-edit { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.bc-add label, .bc-edit label { display: grid; gap: 4px; font-size: 12.5px; color: var(--muted); }
.bc-add label:first-child, .bc-edit label:first-child { grid-column: 1 / -1; }
.bc-add label small, .bc-edit label small { font-size: 11px; }
.bc-add input, .bc-edit input { height: 40px; border-radius: 9px; border: 1px solid #3a3f4b; background: var(--paper); padding: 0 10px; font-size: 16px; color: var(--text); min-width: 0; }
.bc-add input:focus, .bc-edit input:focus { outline: none; border-color: var(--amber); }
.bc-add .bc-btn { grid-column: 1 / -1; justify-content: center; }
.bc-edit-btns { grid-column: 1 / -1; display: flex; gap: 8px; }
.bc-add input::-webkit-inner-spin-button, .bc-edit input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }


.bc-empty { display: flex; align-items: center; gap: 10px; margin: 0; padding: 18px; border: 1px dashed #3a3f4b; border-radius: 14px; color: var(--muted); }
.bc-empty svg { width: 28px; height: 28px; flex: none; color: var(--amber); }
.bc-alldone { margin: 0; padding: 14px 16px; border-radius: 14px; background: rgba(34, 197, 94, 0.12); border: 1px solid rgba(34, 197, 94, 0.5); color: #86efac; font-weight: 700; }
.bc-items { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.bc-item { position: relative; background: var(--card); border: 1px solid var(--rule); border-left: 4px solid var(--amber); border-radius: 14px; padding: 12px 12px 10px 14px; min-width: 0; transition: border-color 0.2s, box-shadow 0.2s; }
.bc-item.is-partial { border-left-color: #fbbf24; }
.bc-item.is-complete { border-left-color: var(--green); }
.bc-item.is-extra { box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.4); }
.bc-item.is-hit { border-color: var(--amber); box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.45); }
.bc-item.just { box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.6); }
.bc-item-head { display: flex; align-items: flex-start; gap: 4px; }
.bc-name { flex: 1; margin: 0; font-size: 15px; line-height: 1.35; min-width: 0; overflow-wrap: anywhere; }
.bc-name b { letter-spacing: 0.01em; }
.bc-icon { appearance: none; flex: none; width: 32px; height: 32px; border-radius: 8px; border: 1px solid transparent; background: none; color: var(--muted); font-size: 17px; line-height: 1; cursor: pointer; }
.bc-icon:hover { border-color: var(--rule); color: var(--text); }
.bc-meta { margin: 3px 0 8px; font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.bc-meta code { color: var(--text); font-size: 13px; }
.bc-warn { color: #fbbf24; }
.bc-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.bc-chip {
  appearance: none; display: inline-flex; align-items: center; gap: 7px; min-height: 36px; padding: 0 10px; border-radius: 9px;
  border: 1px solid #3a3f4b; background: var(--paper); font-size: 13px; cursor: pointer;
}
.bc-chip i { font-style: normal; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.bc-chip em { font-style: normal; font-weight: 700; color: var(--amber); }
.bc-chip.part { border-color: #fbbf24; }
.bc-chip.part i { color: #fbbf24; }
.bc-chip.done { border-color: rgba(34, 197, 94, 0.7); background: rgba(34, 197, 94, 0.14); }
.bc-chip.done i { color: var(--green); }
.bc-chip.over { border-color: var(--amber); }
.bc-row { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.bc-state { flex: 1; font-size: 13px; font-weight: 600; color: var(--amber); }
.bc-item.is-complete .bc-state { color: var(--green); }
.bc-mini { appearance: none; min-height: 34px; min-width: 40px; padding: 0 10px; border-radius: 9px; border: 1px solid #3a3f4b; background: var(--card2); font-size: 13px; font-weight: 700; cursor: pointer; }
.bc-mini.plus { border-color: var(--amber); color: var(--amber); }
.bc-mini:disabled { opacity: 0.4; cursor: default; }
.bc-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.bc-link { display: inline-flex; align-items: center; min-height: 36px; padding: 0 11px; border-radius: 9px; border: 1px solid #3a3f4b; font-size: 13px; font-weight: 600; text-decoration: none; color: var(--text); }
.bc-link.primary { border-color: var(--amber); color: var(--amber); }
.bc-link.quiet { color: var(--muted); }
.bc-link:hover { background: var(--card2); }
.bc-match { margin: 7px 0 0; font-size: 12px; color: var(--muted); }
.bc-unexpected { background: rgba(239, 68, 68, 0.08); border: 1px solid rgba(239, 68, 68, 0.45); border-radius: 14px; padding: 12px 14px; }
.bc-unexpected ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 13px; }
.bc-unexpected code { color: #fca5a5; }
.bc-unexpected em { font-style: normal; color: var(--muted); }
.bc-switch { display: flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; }
.bc-switch input { width: 20px; height: 20px; accent-color: var(--amber); }
.bc-small { margin: 6px 0 0; font-size: 12.5px; color: var(--muted); }



.bc-alert {
  position: fixed; z-index: 40; top: 6px; left: 8px; right: 8px; margin: 0 auto; max-width: 720px;
  display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; border-radius: 14px; background: #7f1d1d;
  border: 2px solid var(--red); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5); animation: bc-shake 0.35s ease;
}
.bc-alert-body { flex: 1; min-width: 0; margin: 0; font-size: 13px; line-height: 1.35; color: #fecaca; }
.bc-alert-body b { display: block; font-size: 15.5px; color: #fff; }
.bc-alert-link { font-weight: 700; color: #fff; white-space: nowrap; }
.bc-alert-x { appearance: none; flex: none; width: 40px; height: 40px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, 0.3); background: rgba(0, 0, 0, 0.2); font-size: 20px; cursor: pointer; }
body.has-alert .bc-status { top: calc(var(--alert-h, 72px) + 14px); }
@keyframes bc-shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }


.bc-cam {
  position: fixed; z-index: 30; top: calc(var(--top) + 8px); left: 12px; right: 12px; margin: 0 auto; max-width: 560px;
  padding: 10px; border-radius: 16px; background: #000; border: 2px solid #3a3f4b; box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6);
  display: grid; gap: 8px; justify-items: center;
}
.bc-cam-view { position: relative; width: 100%; aspect-ratio: 16 / 10; max-height: 44vh; border-radius: 10px; overflow: hidden; background: #111; }
.bc-cam-view video { width: 100%; height: 100%; object-fit: cover; display: block; }
.bc-cam-line { position: absolute; left: 8%; right: 8%; top: 50%; height: 2px; background: var(--red); box-shadow: 0 0 10px var(--red); }
.bc-cam-msg { margin: 0; font-size: 13px; color: #d1d5db; text-align: center; }
body.flash-ok .bc-cam { animation: bc-cam-ok 0.5s ease; }
@keyframes bc-cam-ok { 0% { border-color: var(--green); } 100% { border-color: #3a3f4b; } }


.bc-toasts { position: fixed; z-index: 50; left: 12px; right: 12px; bottom: calc(var(--dock) + env(safe-area-inset-bottom) + 12px); margin: 0 auto; max-width: 520px; display: grid; gap: 6px; pointer-events: none; }
.bc-toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 14px; border-radius: 12px; background: #23272f; border: 1px solid #3a3f4b; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); font-size: 14px; font-weight: 600; animation: bc-in 0.18s ease; }
.bc-toast span { flex: 1; min-width: 0; }
.bc-toast.ok { background: #14532d; border-color: var(--green); }
.bc-toast.ok span::before { content: "✓ "; color: #86efac; }
.bc-toast.dup { background: #1e293b; border-color: #60a5fa; }
.bc-toast.warn { background: #422006; border-color: var(--amber); }
.bc-toast.bad { background: #7f1d1d; border-color: var(--red); }
.bc-toast-btn { appearance: none; flex: none; min-height: 36px; min-width: 52px; padding: 0 12px; border-radius: 9px; border: 0; background: #fff; color: #111; font-weight: 800; cursor: pointer; }
@keyframes bc-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }


body.bc::after { content: ""; position: fixed; inset: 0; z-index: 60; pointer-events: none; border-radius: 0; box-shadow: inset 0 0 0 0 transparent; }
body.flash-ok::after { animation: bc-flash-ok 0.55s ease; }
body.flash-bad::after { animation: bc-flash-bad 0.7s ease; }
body.flash-warn::after { animation: bc-flash-warn 0.6s ease; }
@keyframes bc-flash-ok { 0% { box-shadow: inset 0 0 0 6px rgba(34, 197, 94, 0.9); } 100% { box-shadow: inset 0 0 0 0 rgba(34, 197, 94, 0); } }
@keyframes bc-flash-bad { 0% { box-shadow: inset 0 0 0 8px rgba(239, 68, 68, 0.95); } 100% { box-shadow: inset 0 0 0 0 rgba(239, 68, 68, 0); } }
@keyframes bc-flash-warn { 0% { box-shadow: inset 0 0 0 6px rgba(245, 158, 11, 0.9); } 100% { box-shadow: inset 0 0 0 0 rgba(245, 158, 11, 0); } }
@media (prefers-reduced-motion: reduce) { .bc-alert, .bc-toast { animation: none; } .bc-bar i { transition: none; } }

.bc-about { max-width: 1240px; margin: 0 auto; padding: 4px 16px 8px; color: var(--muted); font-size: 14px; }
.bc-about h2 { color: var(--text); font-size: 16px; margin: 8px 0; }
.bc-about p { margin: 0 0 10px; max-width: 78ch; }

@media (max-width: 899px) {
  :root { --dock: 74px; }
  .bc-scanrow {
    position: fixed; z-index: 25; left: 0; right: 0; bottom: 0; padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
    background: rgba(13, 14, 17, 0.96); border-top: 1px solid var(--rule); backdrop-filter: blur(8px);
  }
  .bc-scan .bc-hint { margin-top: 0; }
  .bc-side { display: contents; }
  .bc-main > .bc-head { order: 0; }
  .bc-main > .bc-side > .bc-status { order: 1; }
  .bc-main > .bc-side > .bc-scan { order: 2; }
  .bc-main > .bc-side > .bc-import { order: 3; }
  .bc-main > .bc-list { order: 4; }
  .bc-main.has-items > .bc-list { order: 3; }
  .bc-main.has-items > .bc-side > .bc-import { order: 4; }
  .bc-head h1 { font-size: 21px; }
}
@media (max-width: 380px) {
  .bc-cam-btn span { display: none; }
  .bc-cam-btn { padding: 0 12px; }
  .bc-sim-btns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 900px) {
  .bc-main { grid-template-columns: 380px minmax(0, 1fr); align-items: start; padding-top: 16px; }
  .bc-head { grid-column: 1 / -1; }
  .bc-side { position: sticky; top: calc(var(--top) + 16px); max-height: calc(100vh - var(--top) - 32px); overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; }
  body.has-alert .bc-side { top: calc(var(--alert-h, 72px) + 16px); max-height: calc(100vh - var(--alert-h, 72px) - 32px); }
  body.has-alert .bc-status { top: auto; }
  .bc-status { position: static; box-shadow: none; }
  .bc-toasts { left: auto; right: 24px; bottom: 24px; width: 420px; }
}
