:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #1f2933;
  --sub: #6b7684;
  --line: #e5e8ec;
  --brand: #4f7cff;
  --brand-soft: #eaf0ff;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 16px;
  --shadow: 0 6px 24px rgba(20, 30, 60, .08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }

.container {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

.wide { max-width: 1080px; }

.header {
  padding: 18px 0 6px;
}
.header h1 {
  margin: 0 0 6px;
  font-size: 22px;
  letter-spacing: .5px;
}
.header p {
  margin: 0;
  color: var(--sub);
  font-size: 14px;
  line-height: 1.6;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-top: 16px;
}

.notice {
  background: #fff8e6;
  border: 1px solid #ffe1a6;
  color: #7a4d05;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.7;
}

/* ---------------- 上传页 ---------------- */
.drop {
  border: 2px dashed #c7d2e4;
  border-radius: var(--radius);
  background: #fbfcff;
  padding: 28px 16px;
  text-align: center;
  cursor: pointer;
  transition: .15s;
}
.drop:active { background: var(--brand-soft); }
.drop.active { border-color: var(--brand); background: var(--brand-soft); }
.drop .icon { font-size: 34px; line-height: 1; }
.drop .tip { margin-top: 10px; font-size: 15px; }
.drop .sub { margin-top: 6px; font-size: 13px; color: var(--sub); }

.preview {
  margin-top: 14px;
  display: none;
}
.preview img {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  display: block;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: 12px;
  padding: 13px 18px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  background: var(--brand);
  color: #fff;
  transition: .15s;
  width: 100%;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.warn { background: var(--warn); }
.btn.danger { background: var(--danger); }
.btn.sm { width: auto; padding: 9px 14px; font-size: 13.5px; font-weight: 500; }

.checkbox {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  margin-top: 14px;
  font-size: 14px;
  line-height: 1.6;
  cursor: pointer;
}
.checkbox input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--brand); }

/* 未同意展示：整卡标红，一眼看出「这幅不能上大屏」 */
.pcard.danger {
  border-color: rgba(220, 38, 38, .5);
  box-shadow: 0 0 0 2px rgba(220, 38, 38, .08);
}
.pcard.danger .shot-id { background: rgba(220, 38, 38, .85); }

/* 上传页：我的画作 / 报告 */
.my-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px; font-size: 15px;
}
.my-body { display: flex; gap: 14px; }
.my-body img {
  width: 108px; height: 144px; object-fit: cover; flex: none;
  border-radius: 12px; border: 1px solid var(--line);
}
.my-info { display: flex; flex-direction: column; gap: 8px; justify-content: center; }
.my-meta { font-size: 14px; font-weight: 600; }
.my-tip { font-size: 12.5px; line-height: 1.6; color: var(--sub); }
.my-report { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.my-summary { font-size: 14px; line-height: 1.8; margin-bottom: 10px; }
.my-report details summary {
  cursor: pointer; font-size: 13px; color: var(--brand); padding: 6px 0;
}
.my-detailed { font-size: 13.5px; line-height: 1.85; color: var(--sub); }

/* 后台上传：多图缩略预览（学生页只用单图，样式单独走这里） */
#upPreview.show {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
}
#upPreview img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
}

.progress {
  margin-top: 14px;
  height: 8px;
  border-radius: 99px;
  background: #eef1f6;
  overflow: hidden;
  display: none;
}
.progress > i { display: block; height: 100%; width: 0; background: var(--brand); transition: width .2s; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: #1f2933;
  color: #fff;
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: .25s;
  z-index: 99;
  max-width: 88vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }
.toast.err { background: var(--danger); }
.toast.ok { background: var(--ok); }

/* ---------------- 大屏 ----------------
   注意：screen.html 的画廊样式全部内联在自己的 <style> 里，
   这里只保留通用底色与 .empty / .live-dot 两个共用于多页面的类。
   旧版大屏的 .stage / .wall / .screen-panel / .ai-zone / .qr-box 等规则已删除——
   它们与新版的 .stage（画廊容器）、.card（画廊卡片）、.qr-box（二维码）撞名，
   曾把整条画廊压成 opacity:0 导致大屏看不见任何画作。 */
body.screen {
  background: radial-gradient(1200px 600px at 50% -10%, #223054 0%, #101726 60%, #0c111b 100%);
  color: #eef2f9;
  min-height: 100vh;
}
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-right: 6px; }
.live-dot.off { background: #b0403f; }

.empty {
  grid-column: 1 / -1;
  text-align: center;
  color: #8fa2c2;
  padding: 60px 10px;
  font-size: 16px;
}

/* ---------------- 后台 ---------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h1 { font-size: 18px; margin: 0; }
.topbar .right { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--sub); }
/* 顶栏三个链接按钮同高、同内距，统计文字弱化，避免右侧看起来散 */
.topbar .right .btn { height: 34px; padding: 0 14px; }
.topbar .right span { font-size: 12.5px; color: var(--sub); }

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding: 14px 20px 0;
}
.toolbar .btn { width: auto; height: 34px; }
.toolbar .grow { flex: 1 1 auto; }

/* 筛选胶囊：与工具条按钮同高，视觉上成一条线 */
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 13px;
  border-radius: 999px;
  font-size: 13px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--sub);
  cursor: pointer;
  transition: .15s;
}
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.chip b { margin-left: 5px; font-weight: 600; opacity: .7; font-size: 12px; }
.chip.on b { opacity: .9; }

/* 当前大屏正在展示 */
.qr-link {
  font-size: 12px;
  color: var(--sub);
  background: #eef1f6;
  padding: 5px 10px;
  border-radius: 999px;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(218px, 1fr));
  gap: 16px;
  padding: 16px 20px 32px;
}
.pcard {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow .18s, transform .18s, border-color .18s;
}
.pcard:hover { box-shadow: 0 10px 30px rgba(20, 30, 60, .14); }
.pcard.hidden { opacity: .55; }
/* 大屏此刻正在展示这一幅 */
/* 大屏此刻正在展示这一幅：整张卡片提亮 + 描边发光，比在角落标一下更直观 */
.pcard.onair {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(79, 124, 255, .32), 0 14px 36px rgba(79, 124, 255, .28);
  transform: translateY(-2px);
}
.pcard.onair .shot img { filter: brightness(1.1) saturate(1.06); }
.pcard.onair .shot { box-shadow: inset 0 0 0 2px rgba(79, 124, 255, .35); }

.pcard .shot {
  position: relative;
  display: block;
  background: #f0f2f5;
  line-height: 0;
}
.pcard .shot img { width: 100%; aspect-ratio: 3/4; object-fit: cover; display: block; }
.pcard .shot-id {
  position: absolute;
  left: 8px; top: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: rgba(15, 23, 42, .62);
  backdrop-filter: blur(4px);
}
.pcard .shot-onair {
  position: absolute;
  right: 8px; top: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #2f6bff, #2563eb);
  box-shadow: 0 4px 14px rgba(37, 99, 235, .45);
}
.pcard .shot-ai {
  position: absolute;
  right: 8px; bottom: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #4f7cff, #8b5cf6);
}

.pcard .meta { padding: 10px 12px 4px; font-size: 13px; color: var(--sub); display: flex; flex-direction: column; gap: 7px; }
.pcard .meta .time { font-size: 12px; color: #9aa4b2; }
.badges { display: flex; gap: 5px; flex-wrap: wrap; }
.badge {
  font-size: 11.5px;
  line-height: 1.5;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef1f6;
  color: var(--sub);
  white-space: nowrap;
}
.badge.ok { background: #e7f7ee; color: var(--ok); }
.badge.brand { background: var(--brand-soft); color: var(--brand); }
.badge.off { background: #fdeaea; color: var(--danger); }
.badge.warn { background: #fff4e2; color: var(--warn); }

/* 操作区：主操作独占一行，次要操作两列等宽网格 —— 按钮数量变化时大小也一致 */
.pcard .ops { display: flex; flex-direction: column; gap: 8px; padding: 0 12px 12px; margin-top: auto; }
.pcard .ops > .btn { width: 100%; padding: 10px 14px; font-size: 14px; }
.pcard .ops-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.pcard .ops-row .btn {
  width: 100%;
  min-width: 0;
  padding: 9px 8px;
  font-size: 13px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* 只剩一个次要按钮时让它独占一行，避免出现半格 */
.pcard .ops-row .btn:only-child { grid-column: 1 / -1; }
.pcard .ops .btn:disabled { opacity: .5; cursor: not-allowed; }
/* 删除是破坏性操作，用颜色跟其它次要操作区分开 */
.btn.ghost.danger-text { color: var(--danger); border-color: #f3c6c6; }
.btn.ghost.danger-text:hover { background: #fdeaea; border-color: var(--danger); }

/* ---------------- 渲染后的 AI 文本（Markdown） ---------------- */
.md h3 { font-size: 17px; margin: 12px 0 6px; }
.md h4 { font-size: 15px; margin: 10px 0 4px; }
.md p { margin: 4px 0; }
.md ul { margin: 4px 0; padding-left: 20px; }
.md li { margin: 3px 0; }
.md hr { border: 0; border-top: 1px solid rgba(255, 255, 255, .15); margin: 12px 0; }
.ai-preview hr { border-top: 1px solid var(--line); }
.md strong { font-weight: 700; }
.md em { font-style: normal; opacity: .75; }

/* 后台预览面板：详细报告 + 汇总寄语 */
.ai-fields { flex: 1; min-width: 0; }
.ai-field { margin-bottom: 12px; }
.ai-field label {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--sub);
  margin-bottom: 6px;
}
.ai-field label .btn { padding: 2px 8px; font-size: 11px; }
.ai-detail {
  max-height: 260px;
  overflow-y: auto;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.8;
}
.dim { color: var(--sub); }

.ai-preview {
  margin-top: 12px;
  max-height: 40vh;
  overflow-y: auto;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.8;
}

/* ---------------- 后台 AI 结果弹窗 ----------------
   不用 [hidden] 的默认 display:none —— 这里显式写了 display:flex，
   会盖掉浏览器默认规则导致弹窗永远关不掉（大屏页就踩过这个坑），
   所以直接靠 :not([hidden]) 控制，不依赖 UA 样式。 */
.ai-modal { display: none; position: fixed; inset: 0; z-index: 60; }
.ai-modal:not([hidden]) { display: flex; align-items: center; justify-content: center; }
.ai-modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .48);
  backdrop-filter: blur(3px);
}
.ai-modal-box {
  position: relative;
  width: min(880px, calc(100vw - 40px));
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(15, 23, 42, .35);
  padding: 20px 22px;
  animation: aiPop .22s ease;
}
@keyframes aiPop { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }

.ai-modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.ai-modal-head strong { font-size: 17px; }
.ai-modal-head .btn { margin-left: auto; }

.ai-modal-body { display: flex; gap: 16px; align-items: flex-start; }
.ai-left { width: 148px; min-width: 148px; }
.ai-left img {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--line);
  display: block;
}
.ai-left-tip { margin-top: 6px; font-size: 12px; color: var(--sub); text-align: center; }
.ai-right { flex: 1; min-width: 0; }

.ai-modal textarea {
  width: 100%;
  min-height: 132px;
  resize: vertical;
  padding: 12px 14px;
  font-size: 15px;
  line-height: 1.85;
  font-family: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.ai-modal textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
.counter { margin-left: auto; font-size: 12px; color: var(--sub); }
.counter.warn { color: var(--warn); font-weight: 600; }
.ai-hint { margin-top: 6px; font-size: 12px; line-height: 1.7; color: var(--sub); }
.ai-hint.warn { color: var(--warn); }

.ai-modal-note {
  margin: 14px 0;
  font-size: 12px;
  line-height: 1.7;
  color: var(--warn);
  background: #fff8e6;
  border: 1px solid #ffe1a6;
  border-radius: 10px;
  padding: 8px 10px;
}
.ai-modal-ops { display: flex; gap: 8px; flex-wrap: wrap; }
.ai-modal-ops .btn { flex: 1; min-width: 110px; }

@media (max-width: 720px) {
  .ai-modal-body { flex-direction: column; }
  .ai-left { width: 108px; min-width: 108px; }
}

/* ---------------- AI 接入设置弹窗 ---------------- */
.set-note {
  font-size: 12.5px;
  line-height: 1.8;
  color: var(--sub);
  background: #f4f7ff;
  border: 1px solid #dce6ff;
  border-radius: 10px;
  padding: 9px 12px;
}
.set-note code, .set-hint code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
  background: rgba(79, 124, 255, .1);
  color: var(--brand);
  padding: 1px 5px;
  border-radius: 5px;
}

.set-section { margin-top: 18px; }
.set-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 10px;
  padding-left: 9px;
  border-left: 3px solid var(--brand);
}
.set-title em { font-style: normal; }

.set-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.set-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.set-field.wide { grid-column: 1 / -1; }
.set-field > span {
  font-size: 12.5px;
  color: var(--sub);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
/* 值来自哪：后台改过 / .env / 系统默认 */
.set-field em.src {
  font-style: normal;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  background: #eef1f6;
  color: var(--sub);
}
.set-field em.src.db { background: var(--brand-soft); color: var(--brand); }
.set-field em.src.env { background: #e7f7ee; color: var(--ok); }

.set-field input, .set-field textarea {
  width: 100%;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.7;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.set-field textarea { resize: vertical; }
.set-field input:focus, .set-field textarea:focus {
  outline: 2px solid var(--brand-soft);
  border-color: var(--brand);
}
.set-field textarea#setSystem {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.75;
}

.set-hint { margin-top: 10px; font-size: 12px; line-height: 1.7; color: var(--sub); }
.set-hint.warn { color: var(--warn); }

.set-result {
  margin-top: 14px;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 13.5px;
  line-height: 1.75;
  background: #f8fafc;
  border: 1px solid var(--line);
  word-break: break-all;
}
.set-result.ok { background: #e7f7ee; border-color: #b6e6c8; color: #106b33; }
.set-result.err { background: #fdeaea; border-color: #f7bcbc; color: var(--danger); }

@media (max-width: 720px) {
  .set-grid { grid-template-columns: 1fr; }
}

.login { max-width: 360px; margin: 12vh auto; }
.login input {
  width: 100%;
  padding: 13px 14px;
  font-size: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin: 12px 0;
}
.login .err { color: var(--danger); font-size: 14px; min-height: 20px; }
