:root {
  --bg: #14161c;
  --panel: #1e2129;
  --line: #2c303b;
  --text: #eceef3;
  --muted: #9097a6;
  --accent: #d6a84a;
  --ok: #4fbf7a;
  --bad: #e0605a;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
header, section { max-width: 640px; margin: 0 auto; padding: 12px 16px; }
header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
h1 { font-size: 18px; margin: 0; }
h2 { font-size: 16px; margin: 0; flex: 1; }
h3 { margin: 0 0 12px; font-size: 16px; }
.total b { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
button {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  font: inherit;
  cursor: pointer;
}
button:disabled { opacity: 0.45; }
button.primary { background: var(--accent); border-color: var(--accent); color: #1a1407; font-weight: 600; }
button.danger { color: var(--bad); }
button.on { border-color: var(--accent); color: var(--accent); }
input, select {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  font: inherit;
}
.toggle { display: flex; gap: 6px; align-items: center; margin-left: auto; }
.min input { width: 64px; }

#viewport {
  position: relative;
  aspect-ratio: 3 / 4;
  max-height: 62vh;
  width: 100%;
  margin: 0 auto;
  background: #000;
  border-radius: 14px;
  overflow: hidden;
}
#video { width: 100%; height: 100%; object-fit: cover; display: block; }
#guide {
  position: absolute;
  left: 50%;
  top: 46%;
  height: 80%;
  aspect-ratio: 63 / 88;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(255, 255, 255, 0.75);
  border-radius: 12px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
}
#guide span { font-size: 12px; color: rgba(255, 255, 255, 0.7); padding: 6px; }
#status {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 10px;
  text-align: center;
  background: rgba(0, 0, 0, 0.65);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 14px;
}
#status.ok { color: var(--ok); }
#status.bad { color: var(--bad); }
#status.busy { color: var(--accent); }
#start { position: absolute; left: 50%; top: 46%; transform: translate(-50%, -50%); font-size: 17px; padding: 14px 22px; }

#last { display: flex; gap: 12px; background: var(--panel); border-radius: 14px; margin-top: 4px; }
#last img { width: 96px; border-radius: 6px; align-self: flex-start; }
#last .info { flex: 1; min-width: 0; }
.name { font-weight: 600; }
.price { color: var(--accent); font-weight: 600; font-size: 17px; }
.warn { color: var(--bad); font-size: 12px; }

.list-head select { padding: 6px; }
#list { list-style: none; padding: 0; margin: 8px 0 0; }
#list li {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  opacity: 0.6;
}
#list li.worth { opacity: 1; }
#list img { width: 40px; height: 56px; object-fit: cover; border-radius: 4px; background: var(--panel); }
#list .info { flex: 1; min-width: 0; }
#list .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#list .right { text-align: right; }

dialog {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 14px;
  width: min(92vw, 520px);
  max-height: 80vh;
  padding: 16px;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
#search-input { width: 100%; }
#search-results { list-style: none; padding: 0; max-height: 50vh; overflow: auto; }
#search-results li { padding: 10px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.variants { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.variants li { cursor: pointer; text-align: center; border: 2px solid transparent; border-radius: 8px; padding: 4px; }
.variants li.on { border-color: var(--accent); }
.variants img { width: 100%; border-radius: 6px; }
