:root {
  --bg: #f5f7fa;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #165dff;
  --primary-weak: #e8f0ff;
  --warn-bg: #fff7e8;
  --warn-text: #b45309;
  --danger: #dc2626;
  --radius: 14px;
}

* { box-sizing: border-box; }

/* hidden 属性优先于任何 display 规则，否则 .progress{display:flex} 之类会把 [hidden] 顶掉 */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 520px;
  margin: 0 auto;
  padding: 16px 14px 40px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 2px 12px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

h1 { font-size: 20px; margin: 0; letter-spacing: 0.5px; }

.badge {
  font-size: 11px;
  color: var(--primary);
  background: var(--primary-weak);
  border-radius: 999px;
  padding: 4px 9px;
  white-space: nowrap;
}

.keybar {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.keybar input {
  flex: 1;
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font-size: 14px;
  outline: none;
}

.keybar input:focus { border-color: var(--primary); }

.hint {
  font-size: 12.5px;
  padding: 9px 12px;
  border-radius: 10px;
  margin-bottom: 12px;
}

.hint.warn { background: var(--warn-bg); color: var(--warn-text); }

.hint.ok { background: #ecfdf5; color: #047857; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

h2 {
  font-size: 15.5px;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary-weak);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
}

.meta { font-size: 12px; color: var(--muted); }

.row { display: flex; gap: 8px; }

.row + .row { margin-top: 8px; }

.grow { flex: 1; }

select {
  padding: 10px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font-size: 14px;
  color: var(--text);
  outline: none;
}

button, .btn-primary {
  border: none;
  border-radius: 10px;
  font-size: 14px;
  padding: 11px 14px;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s;
}

button:active, .btn-primary:active { opacity: 0.82; }

.btn-ghost {
  background: #f1f3f7;
  color: var(--text);
  flex: 1;
  white-space: nowrap;
}

/* 保存成功后按钮变绿，输入框再改动时恢复 */
.btn-ghost.saved {
  background: #10b981;
  color: #fff;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.28);
}

.btn-ghost.saved:hover {
  background: #0ea472;
}

/* 管理员登录面板 */
.admin-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(17, 24, 39, 0.04);
}

.admin-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}

.admin-input {
  display: block;
  width: 100%;
  padding: 11px 13px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fafc;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.admin-input::placeholder { color: #9ca3af; }

.admin-input:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(22, 93, 255, 0.12);
}

.admin-btn {
  margin-top: 2px;
  padding: 12px 14px;
  font-weight: 600;
}

/* 顶栏的管理员按钮：固定在 header 右侧，不要用 .btn-mini（那是绝对定位的小按钮） */
.btn-admin {
  flex: none;
  background: #eef1f6;
  color: var(--text);
  border-radius: 999px;
  padding: 8px 15px;
  font-size: 13px;
  white-space: nowrap;
}

.btn-admin.saved {
  background: #10b981;
  color: #fff;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.28);
}

.btn-admin.saved:hover {
  background: #0ea472;
}

.btn-primary {
  display: block;
  width: 100%;
  background: var(--primary);
  color: #fff;
  text-align: center;
  font-weight: 600;
  text-decoration: none;
  margin-top: 10px;
}

.btn-primary:disabled {
  background: #c9d6f5;
  color: #fff;
  cursor: not-allowed;
}

.btn-mini {
  position: absolute;
  right: 8px;
  bottom: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 8px;
}

/* 衣服库网格 */
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.g-card {
  position: relative;
  border: 2px solid transparent;
  border-radius: 10px;
  overflow: hidden;
  background: #f8fafc;
  cursor: pointer;
  aspect-ratio: 3 / 4;
}

.g-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.g-card.on {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22, 93, 255, 0.12);
}

.g-label {
  position: absolute;
  left: 0;
  bottom: 0;
  right: 0;
  font-size: 11px;
  padding: 3px 6px;
  color: #fff;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.6));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.g-del {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: var(--danger);
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 22px 8px;
  background: #fafbfc;
  border: 1px dashed var(--line);
  border-radius: 10px;
  margin-top: 12px;
}

/* 预览 */
.preview-box {
  margin-top: 12px;
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background: #f8fafc;
}

.preview-box img {
  width: 100%;
  display: block;
  max-height: 460px;
  object-fit: contain;
}

.selected-bar {
  background: #fafbfc;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 13.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.camera-box {
  margin-top: 12px;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
}

.camera-box video {
  width: 100%;
  display: block;
  max-height: 420px;
  object-fit: cover;
}

.camera-box .row { padding: 8px; }

.camera-box .row button { flex: 1; margin-top: 0; }

/* 进度 */
.progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--muted);
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--primary-weak);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  flex: none;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.disclaimer {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  margin-top: 18px;
}

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 12px);
  max-width: 88vw;
  background: #1f2937;
  color: #fff;
  font-size: 13px;
  line-height: 1.45;
  padding: 10px 14px;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s, transform 0.22s;
  z-index: 99;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.error { background: #b91c1c; }
