/* ===== 全局 ===== */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }   /* 防 iOS 自动放大 */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(135deg, #fdf6ec 0%, #f7e6cf 50%, #efd9b4 100%);
  color: #3a2a1a;
  min-height: 100vh;
  /* 手机端用 safe-area 适配刘海屏底部小白条 */
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: #b07a3e; text-decoration: none; }
a:hover { text-decoration: underline; }
button {
  cursor: pointer; font-family: inherit; font-size: 14px;
  border: 1px solid #c8a978; background: #fff8ec; color: #6b4a25;
  padding: 8px 16px; border-radius: 6px; transition: all 0.15s;
  min-height: 36px;  /* 触屏友好 */
}
button:hover { background: #f0dfb8; }
button:active { transform: scale(0.97); }
button.primary {
  background: linear-gradient(135deg, #c8a978, #a07a4a);
  color: #fff; border-color: #8a6432;
}
button.primary:hover { background: linear-gradient(135deg, #b89868, #8a6432); }
button.danger { background: #c44; color: #fff; border-color: #a33; }
button.danger:hover { background: #a33; }
input, textarea, select {
  font-family: inherit; font-size: 16px;  /* 16px 防止 iOS 弹大键盘时自动放大 */
  border: 1px solid #d4b88a; background: #fffefa;
  padding: 10px 12px; border-radius: 6px; width: 100%; color: #3a2a1a;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: #a07a4a; box-shadow: 0 0 0 3px rgba(160, 122, 74, 0.15);
}
textarea { resize: vertical; min-height: 80px; }
label { display: block; margin-bottom: 6px; font-size: 13px; color: #6b4a25; font-weight: 500; }

/* ===== 顶部导航 ===== */
.navbar {
  background: linear-gradient(135deg, #5a3e1f, #3a2a1a);
  color: #f5e6c8; padding: 12px 20px;
  display: flex; justify-content: space-between; align-items: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  position: sticky; top: 0; z-index: 50;
}
.navbar .logo { font-size: 17px; font-weight: 600; letter-spacing: 1px; }
.navbar .logo::before { content: "💎 "; }
.nav-links { display: flex; gap: 6px; align-items: center; }
.nav-links a, .nav-links button {
  color: #f5e6c8; background: transparent; border: 1px solid transparent;
  padding: 6px 12px; border-radius: 4px; font-size: 13px;
}
.nav-links a:hover, .nav-links button:hover { background: rgba(255,255,255,0.1); text-decoration: none; }
.nav-links .badge {
  background: #c8a978; color: #3a2a1a; padding: 2px 8px; border-radius: 10px;
  font-size: 12px; margin-left: 4px;
}

/* ===== 容器 ===== */
.container { max-width: 1200px; margin: 0 auto; padding: 20px 20px 40px; }
.card {
  background: #fffefa; border: 1px solid #e8d4ae; border-radius: 10px;
  padding: 20px; box-shadow: 0 2px 8px rgba(90, 62, 31, 0.06);
  margin-bottom: 16px;
}
.card h2 { color: #5a3e1f; margin-bottom: 14px; font-size: 18px; border-bottom: 2px solid #e8d4ae; padding-bottom: 8px; }
.card h3 { color: #6b4a25; margin: 14px 0 8px; font-size: 15px; }

/* ===== 登录/注册 ===== */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #5a3e1f, #3a2a1a);
  padding: 20px;
}
.auth-card {
  background: #fffefa; border-radius: 12px; padding: 32px 28px;
  width: 100%; max-width: 400px; box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}
.auth-card h1 { text-align: center; color: #5a3e1f; margin-bottom: 6px; font-size: 22px; }
.auth-card .sub { text-align: center; color: #8a6a4a; margin-bottom: 24px; font-size: 13px; }
.auth-card .form-group { margin-bottom: 14px; }
.auth-card button { width: 100%; padding: 12px; font-size: 15px; min-height: 44px; }
.auth-card .switch { text-align: center; margin-top: 14px; font-size: 13px; color: #8a6a4a; }

/* ===== 网格列表 ===== */
.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}
.image-card {
  background: #fffefa; border: 1px solid #e8d4ae; border-radius: 8px;
  overflow: hidden; transition: transform 0.15s, box-shadow 0.15s;
  cursor: pointer; position: relative;
}
.image-card:active { transform: scale(0.98); }
.image-card img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.image-card .meta { padding: 8px 10px; }
.image-card .meta .title { font-size: 13px; font-weight: 600; color: #3a2a1a;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.image-card .meta .sub { font-size: 11px; color: #8a6a4a; margin-top: 3px; }
.image-card .status {
  position: absolute; top: 6px; right: 6px;
  padding: 2px 8px; border-radius: 10px; font-size: 10px; font-weight: 600;
}
.status.pending { background: #f0c674; color: #5a3e1f; }
.status.reviewed { background: #7ab87a; color: #fff; }
.status-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.status-badge.pending { background: #fbe6c4; color: #8a5a1a; }
.status-badge.reviewed { background: #d4ecd4; color: #2a6b2a; }

/* ===== 上传 ===== */
.upload-area {
  border: 2px dashed #c8a978; border-radius: 10px; padding: 28px 16px;
  text-align: center; background: #fffaef; transition: all 0.2s; cursor: pointer;
}
.upload-area:hover, .upload-area.dragover {
  border-color: #8a6432; background: #fcf2dc;
}
.upload-area .icon { font-size: 40px; margin-bottom: 8px; }
.upload-area .hint { color: #8a6a4a; font-size: 12px; }
.upload-area input[type=file] { display: none; }

/* ===== 详情 / 标注 ===== */
.detail-grid { display: grid; grid-template-columns: 1fr 360px; gap: 18px; }
.canvas-wrap {
  background: #2a2a2a; border-radius: 8px; padding: 6px;
  position: relative; overflow: hidden; min-height: 280px;
  display: flex; align-items: center; justify-content: center;
}
.canvas-wrap canvas { max-width: 100%; max-height: 75vh; display: block; cursor: crosshair; touch-action: none; }
.canvas-wrap.readonly canvas { cursor: default; }
.canvas-toolbar {
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
  padding: 8px; background: #3a3a3a; border-radius: 8px 8px 0 0;
}
.canvas-toolbar button {
  background: #5a5a5a; color: #fff; border: 1px solid #6a6a6a;
  padding: 6px 10px; font-size: 12px; white-space: nowrap;
}
.canvas-toolbar button:hover { background: #6a6a6a; }
.canvas-toolbar button.active { background: #c8a978; color: #2a2a2a; border-color: #c8a978; }
.canvas-toolbar .sep { width: 1px; height: 18px; background: #6a6a6a; margin: 0 4px; }
.canvas-toolbar input[type=color] { padding: 0; width: 32px; height: 32px; border: none; background: none; cursor: pointer; }
.canvas-toolbar label.color-label { color: #f5e6c8; font-size: 12px; margin: 0 4px 0 8px; }

.side-panel { display: flex; flex-direction: column; gap: 14px; }
.side-panel .panel { background: #fffefa; border: 1px solid #e8d4ae; border-radius: 8px; padding: 14px; }
.side-panel .panel h4 { color: #5a3e1f; margin-bottom: 8px; font-size: 14px; }

/* ===== 店铺 ===== */
.shop-card { display: grid; grid-template-columns: 1fr 200px; gap: 18px; }
.shop-info .row { display: flex; margin-bottom: 8px; }
.shop-info .row .lbl { width: 70px; color: #8a6a4a; font-size: 12px; flex-shrink: 0; }
.shop-info .row .val { flex: 1; color: #3a2a1a; font-size: 13px; }
.shop-qr {
  text-align: center; padding: 14px; background: #fffaef; border-radius: 8px;
  border: 1px solid #e8d4ae;
}
.shop-qr img { max-width: 100%; max-height: 180px; border-radius: 4px; }
.shop-qr .lbl { color: #8a6a4a; font-size: 12px; margin-top: 8px; }

/* ===== 模态框 ===== */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px;
}
.modal {
  background: #fffefa; border-radius: 10px; max-width: 90vw; max-height: 90vh;
  overflow: auto; padding: 18px; position: relative;
  -webkit-overflow-scrolling: touch;
}
.modal .close {
  position: absolute; top: 8px; right: 12px;
  background: rgba(255,255,255,0.9); border: 1px solid #e8d4ae; font-size: 20px; color: #6b4a25;
  width: 36px; height: 36px; padding: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  z-index: 2;
}
.modal img.preview { max-width: 100%; max-height: 80vh; display: block; margin: 0 auto; }

/* ===== 底部 Tab Bar（学员端手机） ===== */
.tabbar {
  display: none;  /* 默认隐藏，PC 不显示 */
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: #fffefa; border-top: 1px solid #e8d4ae;
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
  box-shadow: 0 -2px 8px rgba(90,62,31,0.08);
  justify-content: space-around;
}
.tabbar .tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 4px; color: #8a6a4a; font-size: 11px;
  background: none; border: none; min-height: 50px; border-radius: 0;
  cursor: pointer;
}
.tabbar .tab .icon { font-size: 22px; line-height: 1; }
.tabbar .tab.active { color: #8a6432; }
.tabbar .tab.active .icon { transform: scale(1.1); }

/* ===== PC / 移动 显隐（默认 PC 显） ===== */
.pc-only { display: inline-block; }
.mobile-only { display: none; }
.tabbar .tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 4px; color: #8a6a4a; font-size: 11px;
  background: none; border: none; min-height: 50px; border-radius: 0;
  cursor: pointer;
}
.tabbar .tab .icon { font-size: 22px; line-height: 1; }
.tabbar .tab.active { color: #8a6432; }
.tabbar .tab.active .icon { transform: scale(1.1); }

/* ===== 问答对话（气泡聊天） ===== */
.chat-box {
  display: flex; flex-direction: column; gap: 10px;
  max-height: 320px; overflow-y: auto; padding: 8px 4px;
  scroll-behavior: smooth;
}
.chat-msg { display: flex; gap: 8px; animation: chatIn 0.25s ease; }
.chat-msg.student { flex-direction: row-reverse; }
.chat-msg .avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; color: #fff;
}
.chat-msg.teacher .avatar { background: linear-gradient(135deg, #c8a978, #8a6432); }
.chat-msg.student .avatar { background: linear-gradient(135deg, #6a994e, #4a7a4a); }
.chat-msg .bubble {
  max-width: 72%; padding: 10px 14px; border-radius: 12px;
  font-size: 14px; line-height: 1.65; word-break: break-word; white-space: pre-wrap;
}
.chat-msg.teacher .bubble {
  background: #fffefa; border: 1px solid #e8d4ae;
  border-top-left-radius: 4px;
}
.chat-msg.student .bubble {
  background: #ecf7e4; border: 1px solid #c4dca8; color: #2a4a1a;
  border-top-right-radius: 4px;
}
.chat-msg .time {
  font-size: 10px; color: #b0a090; margin-top: 2px;
  display: flex; align-items: flex-end;
}
.chat-msg.teacher .time { justify-content: flex-start; }
.chat-msg.student .time { justify-content: flex-end; }
.chat-input-row {
  display: flex; gap: 8px; margin-top: 10px; align-items: center;
}
.chat-input-row textarea {
  flex: 1; min-height: 38px; max-height: 80px; resize: none;
  font-size: 14px; padding: 8px 12px;
}
.chat-input-row button {
  flex-shrink: 0; padding: 8px 16px; font-size: 13px; min-height: 38px;
}
@keyframes chatIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== 工具提示 / 杂项 ===== */
.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  background: #3a2a1a; color: #f5e6c8; padding: 10px 20px; border-radius: 6px;
  z-index: 200; box-shadow: 0 4px 12px rgba(0,0,0,0.2); font-size: 14px;
  animation: toastIn 0.2s; max-width: 90vw; text-align: center;
}
.toast.error { background: #c44; }
.toast.ok { background: #4a7a4a; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -10px); } to { opacity: 1; transform: translate(-50%, 0); } }

.empty {
  text-align: center; padding: 50px 16px; color: #8a6a4a;
}
.empty .icon { font-size: 56px; margin-bottom: 10px; opacity: 0.5; }

.row-flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: #8a6a4a; font-size: 13px; }

/* ===== 学员列表卡片（手机友好） ===== */

/* ===== 生日 banner ===== */
.birthday-banner {
  background: linear-gradient(135deg, #ffb74d 0%, #ff8a65 50%, #f06292 100%);
  color: #fff;
  border-radius: 12px;
  padding: 16px 18px;
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 16px;
  box-shadow: 0 4px 16px rgba(240, 98, 146, 0.25);
  position: relative; overflow: hidden;
}
.birthday-banner::before {
  content: ''; position: absolute; top: -20px; right: -20px;
  width: 100px; height: 100px; background: rgba(255,255,255,0.1); border-radius: 50%;
}
.birthday-banner::after {
  content: ''; position: absolute; bottom: -30px; left: 30%;
  width: 60px; height: 60px; background: rgba(255,255,255,0.08); border-radius: 50%;
}
.birthday-banner-icon { font-size: 42px; flex-shrink: 0; position: relative; z-index: 1; }
.birthday-banner-text { flex: 1; position: relative; z-index: 1; }
.birthday-banner-text .title { font-size: 18px; font-weight: 700; margin-bottom: 2px; }
.birthday-banner-text .sub { font-size: 13px; opacity: 0.95; }

.student-list { display: flex; flex-direction: column; gap: 10px; }
.student-card {
  background: #fffaef; border: 1px solid #e8d4ae; border-radius: 8px;
  padding: 12px 14px; display: flex; align-items: center; gap: 12px;
}
.student-card .avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, #c8a978, #8a6432);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 16px; flex-shrink: 0;
}
.student-card .info { flex: 1; min-width: 0; }
.student-card .info .name { font-size: 14px; font-weight: 600; color: #3a2a1a;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.student-card .info .sub { font-size: 12px; color: #8a6a4a; }
.student-card .count { font-size: 12px; color: #8a6432; font-weight: 600;
  background: #fdf6ec; padding: 4px 10px; border-radius: 12px; }

/* ============================================== */
/* ============ 手机端适配（≤ 768px）============ */
/* ============================================== */
@media (max-width: 768px) {
  /* PC-only 元素 */
  .pc-only { display: none !important; }
  .mobile-only { display: inline-block !important; }
  .nav-select {
    padding: 6px 8px; font-size: 13px; min-height: 32px;
    background: rgba(255,255,255,0.1); color: #f5e6c8; border: 1px solid rgba(255,255,255,0.2);
  }
  .nav-select option { background: #3a2a1a; color: #f5e6c8; }

  /* 顶栏紧凑 */
  .navbar { padding: 10px 14px; }
  .navbar .logo { font-size: 15px; letter-spacing: 0; }
  .nav-links a, .nav-links button { padding: 6px 8px; font-size: 12px; }
  .nav-links .me-greet { display: none; }  /* 学员端欢迎语在移动端隐藏 */

  /* 容器紧凑 */
  .container { padding: 12px 12px 80px; }  /* 底部 80px 给 tabbar 让位 */
  .card { padding: 14px; border-radius: 8px; }
  .card h2 { font-size: 16px; margin-bottom: 10px; }

  /* 学员端：网格 2 列，图片大点 */
  .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .image-card .meta { padding: 6px 8px; }
  .image-card .meta .title { font-size: 12px; }

  /* 上传区更紧凑 */
  .upload-area { padding: 20px 12px; }
  .upload-area .icon { font-size: 36px; }
  .upload-area .hint { font-size: 11px; }

  /* 详情 / 标注：单列，模态框全屏 */
  .detail-grid { grid-template-columns: 1fr; gap: 12px; }
  .modal-mask { padding: 0; }
  .modal { max-width: 100vw; max-height: 100vh; width: 100vw; height: 100vh; border-radius: 0; padding: 14px; padding-top: 50px; }
  .modal .close { top: 6px; right: 6px; }
  .canvas-wrap { min-height: 240px; }
  .canvas-wrap canvas { max-height: 50vh; }

  /* 工具栏：横滑，避免按钮挤变形 */
  .canvas-toolbar {
    flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
    padding: 6px;
    scrollbar-width: thin;
  }
  .canvas-toolbar::-webkit-scrollbar { height: 3px; }
  .canvas-toolbar::-webkit-scrollbar-thumb { background: #888; border-radius: 2px; }
  .canvas-toolbar button { flex-shrink: 0; }
  .canvas-toolbar .sep { flex-shrink: 0; }

  /* 老师端：让 navbar 横向可滑 */
  .navbar { flex-wrap: wrap; }
  .nav-links { flex-wrap: wrap; }

  /* 老师端：表格 → 卡片 */
  .card table, .card thead, .card tbody, .card tr, .card td, .card th { display: block; }
  .card thead { display: none; }
  .card tr {
    background: #fffaef; border: 1px solid #e8d4ae; border-radius: 8px;
    padding: 10px 12px; margin-bottom: 8px;
  }
  .card td { border: none; padding: 3px 0; font-size: 13px; }
  .card td::before {
    content: attr(data-label) "：";
    color: #8a6a4a; font-size: 12px; margin-right: 4px;
  }

  /* 老师端：店铺表单 + 学员端店铺模态框 */
  .shop-card { grid-template-columns: 1fr; }
  .shop-info .row { flex-direction: column; margin-bottom: 10px; }
  .shop-info .row .lbl { width: auto; margin-bottom: 2px; }

  /* 登录/注册卡片 */
  .auth-card { padding: 24px 20px; }

  /* 学员端：显示底部 tabbar */
  .tabbar { display: flex; }
  body.has-tabbar { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
}

/* 小屏额外收紧（≤ 380px，比如 iPhone SE） */
@media (max-width: 380px) {
  html { font-size: 15px; }
  .navbar { padding: 8px 10px; }
  .navbar .logo { font-size: 14px; }
  .nav-links a, .nav-links button { padding: 5px 6px; font-size: 11px; }
  .card { padding: 12px; }
  .grid { gap: 8px; }
}
