/* Barcode Studio — functional, mobile-first styling */

:root {
  --bg: #f2f3f5;
  --card: #ffffff;
  --border: #d7dade;
  --text: #23272e;
  --muted: #6b7280;
  --accent: #2f6fdd;
  --accent-text: #ffffff;
  --ok: #1e7e34;
  --warn: #c05600;
  --bad: #c62828;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --card: #1e2430;
    --border: #333b49;
    --text: #e6e8eb;
    --muted: #9aa2ad;
    --accent: #5b8def;
    --ok: #4caf50;
    --warn: #ffa040;
    --bad: #ef6560;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 12px 16px 4px;
}
header h1 { font-size: 1.25rem; margin: 0; }
.tagline { color: var(--muted); font-size: .85rem; }

main {
  display: grid;
  gap: 12px;
  padding: 8px 12px 24px;
  max-width: 1280px;
  margin: 0 auto;
}
.col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
@media (min-width: 960px) {
  main { grid-template-columns: 1fr 1fr; align-items: start; }
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}
h2 { font-size: .95rem; margin: 14px 0 6px; }
.card > h2:first-child, .card > .toolbar:first-child { margin-top: 0; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
}
.toolbar.wrap { flex-wrap: wrap; }
.right { margin-left: auto; }

button {
  font: inherit;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;      /* comfortable touch targets */
  min-height: 44px;
  cursor: pointer;
}
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button:disabled { opacity: .45; cursor: default; }
button:not(:disabled):active { transform: translateY(1px); }

.opt { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; }
input[type="radio"], input[type="checkbox"] { width: 18px; height: 18px; }

#stage {
  position: relative;
  min-height: 220px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0d0f13;
}
#stage video, #stage canvas { width: 100%; height: auto; display: block; }
#stage-hint {
  position: absolute;
  color: #9aa0a6;
  text-align: center;
  font-size: .95rem;
  padding: 12px;
}

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .87rem; }
th, td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  word-break: break-word;
}
th { color: var(--muted); font-weight: 600; white-space: nowrap; }
td:first-child { color: var(--muted); white-space: nowrap; }
#results-table tbody tr { cursor: pointer; }
#results-table tbody tr.selected { background: color-mix(in srgb, var(--accent) 14%, transparent); }
#results-table td:first-child { color: var(--text); font-weight: 600; }

textarea {
  width: 100%;
  font: 13px/1.5 var(--mono);
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  resize: vertical;
}
textarea.replace { caret-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--bg)); }

#verify { margin: 6px 0; font-size: .9rem; min-height: 1.2em; }
#verify.ok { color: var(--ok); }
#verify.warn { color: var(--warn); }
#verify.bad { color: var(--bad); }
.small { font-size: .8rem; }
.muted { color: var(--muted); }

#reencode-out { text-align: center; margin-top: 8px; }
#reencode-out img {
  max-width: min(380px, 100%);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  image-rendering: pixelated;
}

footer { text-align: center; padding: 8px 0 20px; }
footer a { color: var(--muted); }

#toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: .9rem;
  opacity: 0;
  transition: opacity .25s;
  pointer-events: none;
  max-width: 90vw;
}
#toast.show { opacity: .95; }

.spin {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--muted);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin .8s linear infinite;
  vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }
