/* =========================================================
   折耳根小班二维码系统 · 手机端优先样式
   主题：折耳根绿 · 圆角 · 柔和阴影 · 灵动微动画
   ========================================================= */

:root {
  --green-900: #0f5a3f;
  --green-700: #0f7b57;
  --green-500: #16a34a;
  --green-400: #34c778;
  --green-50: #ecfdf3;
  --leaf: #4ade80;

  --ink: #1c2422;
  --ink-soft: #5b6964;
  --line: #e7ece9;

  --bg: #f3f7f4;
  --card: #ffffff;

  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;

  --shadow-card: 0 6px 20px rgba(15, 90, 63, 0.08);
  --shadow-soft: 0 2px 10px rgba(15, 90, 63, 0.06);
  --shadow-pop: 0 16px 40px rgba(15, 90, 63, 0.18);

  --maxw: 480px;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
button { font-family: inherit; }

.app {
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 0 16px calc(env(safe-area-inset-bottom, 0) + 32px);
}

/* ---------- Hero 头部 ---------- */
.hero {
  padding: calc(env(safe-area-inset-top, 0) + 28px) 4px 18px;
  text-align: center;
}
.hero--sm { padding-top: calc(env(safe-area-inset-top, 0) + 20px); padding-bottom: 12px; }

.hero-badge {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--green-50);
  color: var(--green-700);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 14px;
}

.hero-title {
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, var(--green-700), var(--green-400));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero-sub { margin: 0; color: var(--ink-soft); font-size: 15px; }

/* ---------- 卡片列表（展示端） ---------- */
.cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 18px 18px;
  border: none;
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: var(--shadow-card);
  text-align: left;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
  position: relative;
  overflow: hidden;
}
.card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(52, 199, 120, 0.10), transparent 60%);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.card:hover { transform: translateY(-1px); box-shadow: var(--shadow-pop); }
.card:hover::after { opacity: 1; }
.card:active { transform: scale(0.985); }

.card-emoji {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  font-size: 24px;
  border-radius: 14px;
  background: var(--green-50);
}
.card-title {
  flex: 1 1 auto;
  font-size: 16.5px;
  font-weight: 700;
  color: var(--ink);
}
.card-arrow {
  flex: 0 0 auto;
  color: var(--green-400);
  font-size: 22px;
  font-weight: 600;
  transform: translateX(-2px);
  transition: transform 0.18s ease;
}
.card:hover .card-arrow { transform: translateX(2px); }

/* 「我还没加入小班」虚线幽灵卡 */
.card--ghost {
  background: transparent;
  border: 1.6px dashed var(--green-400);
  box-shadow: none;
}
.card--ghost .card-emoji { background: rgba(74, 222, 128, 0.12); }
.card--ghost .card-title { color: var(--green-700); }

/* 锁定（不可查看）的卡片：置灰 */
.card--locked {
  opacity: 0.45;
  filter: grayscale(0.6);
}
.card--locked .card-title { color: var(--ink-soft); }

/* 已选中的小班：高亮描边 */
.card--mine {
  border: 2px solid var(--green-500);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.12), var(--shadow-card);
}

/* 卡片右侧小标签 */
.card-tag {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--green-50);
  color: var(--green-700);
}
.card-tag--lock { background: transparent; padding: 0; font-size: 16px; }

/* hero 警告提示 */
.hero-warn {
  margin: 12px 16px 0;
  padding: 10px 14px;
  background: #fff7e6;
  color: #92600a;
  border-radius: var(--radius-md);
  font-size: 13px;
  line-height: 1.6;
  border: 1px solid #ffe7ba;
}
.hero-warn b { color: #d46b08; }
.hero-warn--admin {
  background: var(--green-50);
  color: var(--green-700);
  border-color: rgba(22, 163, 74, 0.2);
}
.hero-warn--admin b { color: var(--green-900); }

/* 锁定占位 */
.qr-placeholder--lock {
  font-size: 56px;
  background: #f3f7f4;
}

/* ---------- 详情面板（底部弹层） ---------- */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  visibility: hidden;
}
.sheet.open { visibility: visible; }

.sheet-mask {
  position: absolute;
  inset: 0;
  background: rgba(15, 30, 24, 0.45);
  opacity: 0;
  transition: opacity 0.25s ease;
  backdrop-filter: blur(2px);
}
.sheet.open .sheet-mask { opacity: 1; }

.sheet-panel {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  max-height: 90vh;
  max-height: 90dvh;
  overflow-y: auto;
  background: var(--card);
  border-radius: 26px 26px 0 0;
  padding: 10px 20px calc(env(safe-area-inset-bottom, 0) + 28px);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: var(--shadow-pop);
}
.sheet.open .sheet-panel { transform: translateY(0); }

.sheet-handle {
  width: 40px; height: 5px;
  border-radius: 999px;
  background: var(--line);
  margin: 6px auto 14px;
}
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.sheet-title {
  margin: 0;
  font-size: 20px; font-weight: 800;
  color: var(--green-900);
}
.sheet-close {
  width: 34px; height: 34px;
  border: none; border-radius: 50%;
  background: var(--bg);
  color: var(--ink-soft);
  font-size: 16px; cursor: pointer;
  transition: background 0.15s ease;
}
.sheet-close:active { background: var(--line); }

/* 二维码区 */
.qr-area {
  display: grid; place-items: center;
  padding: 14px;
  border-radius: var(--radius-lg);
  background: var(--green-50);
  margin-bottom: 10px;
}
.qr-area img {
  width: 260px; height: 260px;
  object-fit: contain;
  border-radius: var(--radius-md);
  cursor: zoom-in;
  animation: pop-in 0.3s ease;
}
@keyframes pop-in {
  from { opacity: 0; transform: scale(0.9); }
  to   { opacity: 1; transform: scale(1); }
}
.qr-placeholder {
  width: 260px; height: 260px;
  display: grid; place-items: center;
  text-align: center;
  color: var(--ink-soft);
  font-size: 14px;
  background: repeating-linear-gradient(45deg, #fff, #fff 10px, #f1f6f3 10px, #f1f6f3 20px);
  border-radius: var(--radius-md);
}
.qr-tip {
  text-align: center;
  color: var(--ink-soft);
  font-size: 13px;
  margin: 0 0 18px;
}

/* 富文本说明展示 */
.desc {
  font-size: 15.5px;
  line-height: 1.7;
  color: var(--ink);
  word-break: break-word;
}
.desc :first-child { margin-top: 0; }
.desc :last-child { margin-bottom: 0; }
.desc h1, .desc h2, .desc h3 { color: var(--green-900); margin: 0.6em 0 0.3em; }
.desc a { color: var(--green-700); word-break: break-all; }
.desc img { border-radius: var(--radius-sm); margin: 8px 0; }

/* ---------- 二维码大图 ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center;
  background: rgba(0, 0, 0, 0.82);
  padding: 30px;
  visibility: hidden; opacity: 0;
  transition: opacity 0.25s ease;
}
.lightbox.open { visibility: visible; opacity: 1; }
.lightbox img {
  width: 86%; max-width: 360px;
  border-radius: var(--radius-md);
  background: #fff;
}
.lightbox-tip {
  position: absolute; bottom: 8%; left: 0; right: 0;
  color: rgba(255, 255, 255, 0.85);
  text-align: center; font-size: 14px;
}

/* =========================================================
   表单与按钮通用
   ========================================================= */
.form-card {
  margin-top: 14px;
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 22px 20px;
  box-shadow: var(--shadow-card);
}
.field { display: block; margin-bottom: 16px; }
.field-label {
  display: block;
  font-size: 13px; font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 8px;
}
.input {
  width: 100%;
  padding: 14px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--bg);
  font-size: 16px;
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  appearance: none;
}
select.input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%230f7b57' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}
.input:focus {
  outline: none;
  border-color: var(--green-400);
  box-shadow: 0 0 0 3px rgba(52, 199, 120, 0.18);
  background: #fff;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  padding: 13px 20px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 15.5px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn--block { width: 100%; }
.btn--sm { padding: 9px 14px; font-size: 14px; }
.btn--primary {
  background: linear-gradient(135deg, var(--green-700), var(--green-400));
  color: #fff;
  box-shadow: 0 8px 18px rgba(15, 122, 87, 0.25);
}
.btn--ghost {
  background: var(--green-50);
  color: var(--green-700);
}

.alert {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: 14px;
  margin-bottom: 16px;
}
.alert--error { background: #fdecec; color: #c0392b; }

.back-link {
  text-align: center;
  margin-top: 18px;
  font-size: 14px;
}
.back-link a { color: var(--green-700); text-decoration: none; }

/* =========================================================
   管理后台
   ========================================================= */
.admin { margin-top: 14px; }

.panel {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-card);
}
.panel-title {
  margin: 0 0 14px;
  font-size: 16px; font-weight: 800;
  color: var(--green-900);
}
.panel-actions { margin-top: 14px; }

/* 二维码当前预览 + 上传 */
.qr-current {
  display: flex; gap: 14px; align-items: center;
  flex-wrap: wrap;
}
.qr-current-img {
  width: 110px; height: 110px;
  flex: 0 0 auto;
  border-radius: var(--radius-md);
  background: var(--green-50);
  display: grid; place-items: center;
  overflow: hidden;
}
.qr-current-img img { width: 100%; height: 100%; object-fit: cover; }
.qr-empty { font-size: 12px; color: var(--ink-soft); text-align: center; padding: 6px; }

.qr-actions { flex: 1 1 160px; display: flex; flex-direction: column; gap: 8px; }

.upload-box {
  display: flex; align-items: center; gap: 12px;
  padding: 16px;
  border-radius: var(--radius-md);
  border: 2px dashed var(--green-400);
  background: var(--green-50);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.upload-box:active { transform: scale(0.99); }
.upload-plus {
  flex: 0 0 auto;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: #fff;
  color: var(--green-700);
  font-size: 26px; font-weight: 300;
  box-shadow: var(--shadow-soft);
}
.upload-text { font-size: 14.5px; font-weight: 600; color: var(--green-700); }

/* Quill 适配 */
#editor { min-height: 200px; }
.ql-toolbar.ql-snow {
  border: 1px solid var(--line) !important;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  background: #fafdfb;
  overflow-x: auto;
  white-space: nowrap;
}
.ql-container.ql-snow {
  border: 1px solid var(--line) !important;
  border-top: none !important;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  font-size: 15.5px;
}
.ql-snow .ql-tooltip { left: 10px !important; }

.admin-footer { margin-top: 10px; text-align: center; }
.admin-footer .back-link { display: block; margin-top: 14px; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%; bottom: 12%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(15, 30, 24, 0.92);
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  max-width: 88%;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: #c0392b; }

/* ---------- 小屏微调 ---------- */
@media (max-width: 360px) {
  .hero-title { font-size: 23px; }
  .qr-area img, .qr-placeholder { width: 220px; height: 220px; }
}
