/* ============ 大众点评橙色系 ============ */
:root {
  --orange: #FF6A00;        /* 主色：亮橙 - header + 主按钮 + 选中态 */
  --orange-dark: #E85D00;   /* 按下态 / focus 边框 */
  --orange-light: #FFD4B8;  /* 卡片边框 + 输入框边框 */
  --orange-lighter: #FFF3E8; /* 淡色填充：选中卡片背景等 */
  --bg: #FFFBF7;            /* 整体底色：极淡暖白 */
  --text: #2a1a0a;          /* 主文字：近黑 */
  --text-muted: #8a7a5a;
  --text-hint: #c0a890;
  --danger: #c04040;
  --radius: 14px;
}

/* ============ 全局 ============ */
/* 屏蔽 Netlify 右下角横幅 */
[id*="netlify"], [class*="netlify"], [data-netlify],
[data-siteid], [data-uploaded],
div[style*="z-index: 9999"],
#netlify-badge, .netlify-badge {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html, body {
  margin: 0;
  padding: 0;
  font-family: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
  color-scheme: light;
}
#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: 70px;
}

button {
  font-family: inherit;
  border: 1.5px solid var(--orange);
  border-radius: 10px;
  padding: 11px 16px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  background: transparent;
  color: var(--orange);
  transition: transform 0.1s;
}
button:active { transform: scale(0.97); }
button.primary {
  background: var(--orange);
  color: #fff;
  border-color: var(--orange);
}
button.primary:active {
  background: var(--orange-dark);
  border-color: var(--orange-dark);
}
button.danger {
  border-color: var(--danger);
  color: var(--danger);
}
button.danger.primary {
  background: var(--danger);
  color: #fff;
}
button:disabled { opacity: 0.45; cursor: not-allowed; }

input, select, textarea {
  font-family: inherit;
  font-size: 16px;
  padding: 10px 12px;
  border: 1.5px solid var(--orange-light);
  border-radius: 10px;
  background: var(--bg);
  width: 100%;
  outline: none;
  color: var(--text);
  -webkit-text-fill-color: var(--text);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--orange);
}
/* 日历弹窗用原生控件，颜色受系统控制，尽量匹配 */
input[type="date"]::-webkit-calendar-picker-indicator {
  filter: none;
  cursor: pointer;
  opacity: 0.7;
}
/* 日历弹窗 - 通过 accent-color 影响选中色 */
input[type="date"], select {
  accent-color: var(--orange);
}
/* 覆盖浏览器默认蓝色选中态 */
select option {
  background-color: #fff;
  color: var(--text);
}
select option:checked,
select option:hover {
  background-color: var(--orange) !important;
  color: #fff !important;
}

label {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: block;
}

.card {
  background: #fff;
  border-radius: var(--radius);
  border: 1.5px solid var(--orange-light);
  padding: 14px;
  margin-bottom: 12px;
}

.hint {
  font-size: 13px;
  color: var(--text-hint);
}

.row {
  display: flex;
  gap: 8px;
}
.row > * { flex: 1; }

/* ============ 顶部 ============ */
.header {
  background: var(--orange);
  padding: 12px 16px 8px;
  position: sticky;
  top: 0;
  z-index: 10;
  color: #fff;
}
.header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}
.header h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
}
.header .sub {
  font-size: 13px;
  opacity: 0.85;
  line-height: 1.2;
  margin-top: 2px;
}
.header .stats {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.header .stat {
  flex: 1;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  padding: 6px 4px;
  text-align: center;
  backdrop-filter: blur(4px);
}
.header .stat .n { font-size: 20px; font-weight: 700; color: #fff; line-height: 1.2; }
.header .stat .l { font-size: 11px; opacity: 0.9; color: #fff; line-height: 1.2; }

/* ============ 主内容区 ============ */
.content { padding: 14px; }
.page { display: none; }
.page.active { display: block; }

/* ============ 底部 tabbar ============ */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 1.5px solid var(--orange-light);
  display: flex;
  justify-content: space-around;
  padding: 2px 0 calc(env(safe-area-inset-bottom, 6px) + 2px);
  z-index: 20;
  max-width: 480px;
  margin: 0 auto;
}
.tabbar .tab {
  flex: 1;
  text-align: center;
  padding: 6px 0;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
}
.tabbar .tab.active {
  color: var(--orange);
  font-weight: 600;
}
.tabbar .tab .icon {
  font-size: 26px;
  display: block;
  margin-bottom: 2px;
}

/* ============ 录入页 ============ */
.camera-btn-wrap {
  position: relative;
  width: 100%;
  height: 180px;
}
.camera-btn {
  width: 100%;
  height: 100%;
  border: 2px dashed var(--orange);
  border-radius: var(--radius);
  background: var(--orange-lighter);
  color: var(--orange);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  text-decoration: none;
  font-size: inherit;
}
.camera-btn .big { font-size: 48px; }
.camera-btn:active { border-style: solid; background: var(--orange-light); }

/* 最近照片选择按钮（在相机按钮下方） */
.recent-photo-btn {
  width: 100%;
  margin-top: 10px;
  padding: 8px 12px;
  background: transparent;
  border: 1.5px dashed var(--orange);
  border-radius: 8px;
  color: var(--orange);
  font-size: 13px;
  cursor: pointer;
}
.recent-photo-btn:active { background: var(--orange-lighter); }

/* 密码框容器：右侧绝对定位放操作按钮 */
.password-input-wrap {
  position: relative;
  display: block;
}
.password-input-wrap input {
  padding-right: 72px; /* 给右侧两个按钮留空间 */
}
.password-input-wrap .pw-action {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: #999;
  padding: 4px;
  line-height: 1;
  height: 28px;
  width: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.password-input-wrap #apikey-toggle { right: 4px; }
.password-input-wrap #apikey-clear { right: 32px; }
.password-input-wrap .pw-action:active { color: var(--orange); }

.preview-img {
  max-width: 100%;
  max-height: 220px;
  border-radius: var(--radius);
  border: 1.5px solid var(--orange-light);
  display: block;
}
/* 预览图容器（带 × 清除按钮） */
.preview-wrap {
  position: relative;
  display: inline-block;
  width: 100%;
}
.preview-wrap .preview-img {
  width: 100%;
  height: auto;
}
.preview-clear {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 16px;
  line-height: 24px;
  text-align: center;
  cursor: pointer;
  border: none;
  padding: 0;
  z-index: 3;
}

.ocr-result {
  background: var(--bg);
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 15px;
  white-space: pre-wrap;
  border: 1.5px solid var(--orange-light);
  width: 100%;
  min-height: 80px;
}

.tag {
  display: inline-block;
  border: 1px solid var(--orange-light);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  margin-right: 4px;
  color: var(--orange-dark);
  background: var(--orange-lighter);
}

/* ============ 错题列表 ============ */
.mistake-item {
  background: #fff;
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 10px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1.5px solid var(--orange-light);
}
.mistake-item.selected {
  border-color: var(--orange);
  background: var(--orange-lighter);
}
.mistake-item img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--orange-light);
  flex-shrink: 0;
}
.mistake-item .info { flex: 1; min-width: 0; }
.mistake-item .info .meta {
  font-size: 12px;
  color: var(--text-hint);
  margin-bottom: 4px;
}
.mistake-item .info .text {
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-all;
}
.mistake-item .check {
  width: 22px;
  height: 22px;
  border: 1.5px solid var(--orange);
  border-radius: 6px;
  flex-shrink: 0;
  cursor: pointer;
  margin-top: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: transparent;
  background: transparent;
}
.mistake-item.selected .check {
  background: var(--orange);
  border-color: var(--orange);
  color: #fff;
}
.mistake-item.done { opacity: 0.5; }

/* 批量栏 */
#batch-bar, .batch-bar {
  background: var(--orange-lighter);
  border: 1.5px dashed var(--orange);
  border-radius: var(--radius);
  padding: 10px;
  margin-bottom: 10px;
}

/* ============ 奖章 ============ */
.medal {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: linear-gradient(135deg, #FF8833, #FF6A00);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  margin: 20px auto;
  border: 3px solid var(--orange-light);
}
.medal.empty {
  background: transparent;
  border-color: var(--orange-light);
  border-style: dashed;
  font-size: 28px;
  color: var(--text-hint);
}

/* ============ Loading ============ */
.loading {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255, 251, 247, 0.92);
  z-index: 100;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
}
.loading.show { display: flex; }
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--orange-light);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ Toast ============ */
.toast {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: var(--text);
  color: var(--bg);
  padding: 12px 22px;
  border-radius: 14px;
  z-index: 200;
  font-size: 15px;
  font-weight: 500;
  max-width: 80%;
  text-align: center;
  display: none;
}
.toast.show { display: block; }

/* ============ 自定义确认弹窗 ============ */
.confirm-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(42, 26, 10, 0.4);
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.confirm-modal.show { display: flex; }
.confirm-modal .modal-box {
  background: #fff;
  border: 1.5px solid var(--orange-light);
  border-radius: var(--radius);
  padding: 20px;
  max-width: 360px;
  width: 100%;
  position: relative;
}
/* 右上角关闭按钮 */
.confirm-modal .modal-close {
  position: absolute;
  top: 8px;
  right: 12px;
  font-size: 22px;
  line-height: 1;
  color: var(--text-hint);
  cursor: pointer;
  user-select: none;
  padding: 4px 8px;
}
.confirm-modal .modal-close:active {
  color: var(--text-muted);
}
.confirm-modal .modal-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}
.confirm-modal .modal-body {
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: 16px;
  line-height: 1.6;
}
.confirm-modal .modal-actions {
  display: flex;
  gap: 10px;
}
.confirm-modal .modal-actions button { flex: 1; }

/* ============ 温馨提示卡 ============ */
.card[style*="background"] {
  background: #fff !important;
}

/* ============ 备份卡警告图标放大 ============ */
.backup-warn {
  display: flex;
  gap: 6px;
  line-height: 1.6;
}
.backup-warn .warn-icon {
  font-size: 20px;
  flex-shrink: 0;
  line-height: 1.6;
  margin-right: 2px;
}
.backup-warn .warn-text {
  flex: 1;
  line-height: 1.6;
}
