:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #334155;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --primary: #2563eb;
  --primary-press: #1d4ed8;
  --ok: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 14px;
}

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

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  overscroll-behavior: none;
}

/* 顶部条 */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: calc(env(safe-area-inset-top, 0) + 10px) 14px 10px;
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--surface-2);
}
#title { font-weight: 600; font-size: 17px; flex: 1; text-align: center; }
.icon-btn {
  background: none; border: none; color: var(--text);
  font-size: 22px; width: 36px; height: 36px; border-radius: 10px;
}
.icon-btn:active { background: var(--surface-2); }

/* 网络/同步条 */
#netbar {
  padding: 6px 14px; font-size: 13px; text-align: center;
  background: var(--warn); color: #1a1205;
}

/* 主体 */
#app { padding: 14px; padding-bottom: calc(env(safe-area-inset-bottom, 0) + 14px); }
.screen { display: flex; flex-direction: column; gap: 14px; }
h2 { margin: 4px 0 0; font-size: 20px; }
h3 { margin: 0 0 12px; }

label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }

input[type="text"], input[type="url"] {
  width: 100%;
  padding: 13px 14px;
  background: var(--surface);
  border: 1px solid var(--surface-2);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 16px;
}
input:focus { outline: none; border-color: var(--primary); }

button {
  font-size: 16px;
  padding: 13px 16px;
  border: 1px solid var(--surface-2);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
}
button:active { transform: scale(0.98); }
button.primary { background: var(--primary); border-color: var(--primary); }
button.primary:active { background: var(--primary-press); }
button.small { padding: 10px 14px; font-size: 14px; }

.row { display: flex; gap: 8px; align-items: stretch; }
.row input { flex: 1; }
.hint { color: var(--muted); font-size: 13px; margin: 0; }
.warn { color: var(--warn); font-size: 14px; margin: 4px 0 0; }

/* 列表 */
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.list li {
  background: var(--surface);
  border: 1px solid var(--surface-2);
  border-radius: var(--radius);
  padding: 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.folder-item { cursor: pointer; }
.folder-item .meta { color: var(--muted); font-size: 13px; }
.rec-vin { font-family: ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0.5px; font-size: 15px; }
.rec-sub { color: var(--muted); font-size: 12px; margin-top: 3px; }
.del-btn { color: var(--danger); background: none; border: none; font-size: 14px; padding: 6px 8px; }

/* 扫码 */
#reader { width: 100%; border-radius: var(--radius); overflow: hidden; background: #000; min-height: 260px; }
#reader video { border-radius: var(--radius); }
.feedback {
  text-align: center; font-weight: 600; font-size: 17px;
  padding: 14px; border-radius: var(--radius);
  font-family: ui-monospace, Menlo, monospace; letter-spacing: 1px;
  transition: background 0.15s;
}
.feedback.idle { background: var(--surface); color: var(--muted); font-family: inherit; letter-spacing: normal; font-weight: 500; }
.feedback.ok { background: var(--ok); color: #052e10; }
.feedback.dup { background: var(--warn); color: #1a1205; }
.feedback.err { background: var(--danger); color: #fff; }

.cam-controls { display: flex; gap: 10px; align-items: center; }
.cam-controls .zoom-wrap { flex: 1; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.cam-controls .zoom-wrap input[type="range"] { flex: 1; accent-color: var(--primary); }
#torchBtn.active { background: var(--warn); border-color: var(--warn); color: #1a1205; }

.scan-actions { display: flex; gap: 8px; }
.scan-actions button { flex: 1; }

.recent { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.recent li {
  background: var(--surface); border-radius: 10px; padding: 10px 12px;
  font-family: ui-monospace, Menlo, monospace; font-size: 14px;
  display: flex; justify-content: space-between; align-items: center;
}
.recent li.dup { border-left: 3px solid var(--warn); }

/* 弹窗 */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50;
}
.modal-box {
  background: var(--surface); border-radius: 18px; padding: 20px; width: 100%; max-width: 380px;
  display: flex; flex-direction: column; gap: 12px;
}
.modal-actions { display: flex; gap: 8px; }
.modal-actions button { flex: 1; }

[hidden] { display: none !important; }
