:root {
  --bg: #111827;
  --panel: #1f2937;
  --panel-2: #374151;
  --text: #f9fafb;
  --muted: #9ca3af;
  --accent: #38bdf8;
  --accent-press: #0ea5e9;
  --ok: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  overscroll-behavior-y: contain;
}

.screen {
  max-width: 560px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 16px calc(env(safe-area-inset-bottom) + 16px);
  min-height: 100dvh;
}
.hidden { display: none !important; }

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0 8px;
  position: sticky;
  top: 0;
  background: linear-gradient(var(--bg) 78%, transparent);
  z-index: 5;
}
.sku-label { color: var(--muted); font-size: 13px; letter-spacing: .08em; text-transform: uppercase; }
.sku {
  font-size: clamp(24px, 7vw, 34px);
  font-weight: 800;
  letter-spacing: .02em;
  font-variant-numeric: tabular-nums;
}
.icon-btn {
  background: var(--panel);
  border: none;
  color: var(--text);
  font-size: 20px;
  width: 44px; height: 44px;
  border-radius: 12px;
}

/* Counters */
.counters { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 14px; }
.chip {
  background: var(--panel);
  color: var(--muted);
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.chip-ok { color: var(--ok); }
.chip-warn { color: #111827; background: var(--warn); font-weight: 700; }

/* Install banner */
.install-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 14px;
}

/* Blocks */
.block {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}
.block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-weight: 600;
}
.block-head small { color: var(--muted); font-weight: 400; }

/* Buttons */
.btn {
  border: none;
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  background: var(--panel-2);
  width: 100%;
  cursor: pointer;
  touch-action: manipulation;
}
.btn:active { transform: translateY(1px); }
.btn-photo { background: #1e3a5f; }
.btn-rec { background: #4c1d24; }
.btn-rec.recording { background: var(--danger); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .7; } }
.btn-primary { background: var(--accent); color: #06283d; }
.btn-primary:active { background: var(--accent-press); }
.btn-primary:disabled { background: var(--panel-2); color: var(--muted); }
.btn-ghost { background: transparent; border: 1px solid var(--panel-2); }
.btn-danger { background: var(--danger); }
.btn-big { padding: 18px; font-size: 19px; margin-top: 4px; }
.btn-mini { width: auto; padding: 8px 12px; font-size: 14px; }

/* Thumbs */
.thumbs { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.thumbs:empty { display: none; }
.thumb {
  position: relative;
  width: 92px; height: 92px;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .badge {
  position: absolute; top: 4px; left: 4px;
  background: rgba(0,0,0,.6); color: #fff;
  font-size: 11px; padding: 1px 6px; border-radius: 6px;
}
.thumb .del {
  position: absolute; top: 4px; right: 4px;
  background: rgba(0,0,0,.65); color: #fff;
  border: none; width: 24px; height: 24px; border-radius: 999px;
  font-size: 15px; line-height: 1;
}

/* Audio */
.rec-timer { color: var(--danger); font-variant-numeric: tabular-nums; font-weight: 700; }
.audio-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.audio-list:empty { display: none; }
.audio-item { display: flex; align-items: center; gap: 8px; }
.audio-idx { color: var(--muted); font-size: 14px; width: 20px; text-align: right; }
.audio-item audio { flex: 1; height: 40px; min-width: 0; }

/* Weight */
.weight-row { display: flex; align-items: center; gap: 10px; }
.weight-input {
  flex: 1;
  background: var(--panel-2);
  border: none;
  color: var(--text);
  font-size: 18px;
  padding: 12px 14px;
  border-radius: 10px;
}
.weight-unit { color: var(--muted); font-size: 18px; }

/* Stepper */
.stepper { display: flex; gap: 8px; margin-bottom: 12px; }
.stepper .btn { font-size: 15px; padding: 12px 8px; }

/* Messages */
.msg { min-height: 22px; margin-top: 10px; font-size: 15px; text-align: center; }
.msg.ok { color: var(--ok); }
.msg.err { color: var(--danger); }
.msg.info { color: var(--accent); }

/* Settings form */
.form { display: flex; flex-direction: column; gap: 14px; padding-top: 8px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.form label.check { flex-direction: row; align-items: center; gap: 10px; color: var(--text); font-size: 15px; }
.form input[type=url], .form input[type=text], .form input[type=number] {
  background: var(--panel);
  border: 1px solid var(--panel-2);
  color: var(--text);
  font-size: 16px;
  padding: 12px 14px;
  border-radius: 10px;
}
.form input[type=checkbox] { width: 22px; height: 22px; }
.form-actions { display: flex; flex-direction: column; gap: 10px; }
.form hr { border: none; border-top: 1px solid var(--panel-2); margin: 6px 0; }
.form h3 { margin: 0; }
.hint { color: var(--muted); font-size: 12px; }

/* Queue list */
.queue-list { display: flex; flex-direction: column; gap: 8px; }
.queue-item {
  background: var(--panel);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.queue-item .q-status { font-size: 12px; }
.q-pending { color: var(--warn); }
.q-uploading { color: var(--accent); }
.q-error { color: var(--danger); }
.q-done { color: var(--ok); }
.queue-empty { color: var(--muted); font-size: 14px; }

/* Modal */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  z-index: 20;
}
.modal-box {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 20px;
  width: 100%; max-width: 360px;
}
.modal-box h3 { margin: 0 0 14px; }
.modal-box input {
  width: 100%;
  background: var(--panel-2);
  border: none; color: var(--text);
  font-size: 20px; padding: 12px 14px; border-radius: 10px;
  margin-bottom: 14px;
}
.modal-actions { display: flex; gap: 10px; }
