:root {
  --bg: #101317;
  --fg: #f2f4f7;
  --muted: #9aa3ad;
  --accent: #ffd23f;
  --card: #1b2027;
  --line: #2a313a;
  --bad: #ff8a80;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.45 -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
.screen[hidden], [hidden] { display: none !important; }

#home { max-width: 560px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 24px) 16px 32px; }
h1 { font-size: 28px; margin: 0 0 4px; }
h2 { font-size: 19px; margin: 28px 0 8px; }
header p { color: var(--muted); margin: 0 0 24px; }
.tag { font-size: 13px; font-weight: 600; background: var(--accent); color: #111; border-radius: 6px; padding: 2px 6px; vertical-align: middle; }

button, .btn {
  font: inherit;
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  background: var(--card);
  color: var(--fg);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}
button.primary { background: var(--accent); color: #111; font-weight: 600; }
button.big { width: 100%; padding: 18px; font-size: 18px; }
button:disabled { opacity: 0.4; }

.tips { margin: 16px 0; background: var(--card); border-radius: 12px; padding: 14px 16px; }
.tips ol { margin: 8px 0 0; padding-left: 20px; color: var(--muted); }
.tips li { margin: 4px 0; }
#list { list-style: none; padding: 0; margin: 0; }
#list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
#list a { color: var(--fg); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#list small { color: var(--muted); }
#list button { padding: 8px 12px; font-size: 14px; }
.msg { color: var(--bad); min-height: 1.4em; margin: 8px 0; }

#capture, #result { position: fixed; inset: 0; background: #000; overflow: hidden; touch-action: none; }
#cam, #cam .cam, #overlay, #pano { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#cam .cam { object-fit: cover; }
.hud { position: absolute; left: 0; right: 0; display: flex; gap: 10px; justify-content: center; padding: 12px 16px; }
.hud.top { top: 0; padding-top: calc(env(safe-area-inset-top) + 10px); justify-content: space-between; align-items: center; text-shadow: 0 1px 3px #000; }
.hud.bottom { bottom: 0; padding-bottom: calc(env(safe-area-inset-bottom) + 14px); }
.hud button { background: rgba(20, 24, 30, 0.75); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.hud.bottom button { flex: 1; max-width: 160px; }
.hud button.primary { background: var(--accent); }
#count { font-weight: 700; font-size: 18px; }
#hint { color: #e6e6e6; font-size: 14px; text-align: right; }
#debug { position: absolute; left: 16px; bottom: calc(env(safe-area-inset-bottom) + 72px); font-size: 11px; color: rgba(255, 255, 255, 0.5); }
.warn { position: absolute; left: 16px; right: 16px; top: 38%; background: rgba(170, 30, 30, 0.92); padding: 14px; border-radius: 12px; text-align: center; }
.warn.move { top: calc(env(safe-area-inset-top) + 60px); background: rgba(200, 110, 0, 0.94); }

.proc { max-width: 420px; margin: 0 auto; padding: 38vh 24px 0; text-align: center; }
.bar { height: 10px; background: var(--card); border-radius: 5px; overflow: hidden; }
#barFill { height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }
.small { color: var(--muted); font-size: 14px; }

dialog { background: var(--card); color: var(--fg); border: 0; border-radius: 16px; width: min(92vw, 420px); padding: 20px; }
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog h2 { margin: 0 0 8px; }
dialog button:not(.primary), dialog .btn { background: var(--line); }
dialog label { display: block; margin: 10px 0; color: var(--muted); font-size: 14px; }
dialog input { display: block; width: 100%; margin-top: 4px; font: inherit; font-size: 16px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); }
.row { display: flex; gap: 10px; margin-top: 12px; }
.row > * { flex: 1; }

#toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 90px); transform: translateX(-50%);
  background: rgba(30, 35, 42, 0.95); padding: 10px 16px; border-radius: 10px; z-index: 10; max-width: 90vw; word-break: break-all;
}
