:root {
  --paper: #f7f4ef;
  --card: #fffdf9;
  --ink: #28201c;
  --muted: #6e6058;
  --line: #e7ded4;
  --copper: #8d422b;
  --pale: #f7eae0;
  font: 15px/1.55 "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; color: inherit; }
button, summary { cursor: pointer; }
button:focus-visible, summary:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--copper);
  outline-offset: 3px;
}
.wrap { width: min(1120px, calc(100% - 40px)); margin-inline: auto; }
main.wrap { padding-bottom: 32px; }
.subtle:hover { background: var(--pale); }
.subtle { padding: 5px 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--card); font-size: 12px; }
.overview { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 12px; padding: 14px 0 12px; border-bottom: 1px solid var(--line); }
.overview h1 { margin: 0; font-size: clamp(19px, 3vw, 25px); line-height: 1.25; }
.overview-stats { grid-area: 1 / 3; display: flex; align-items: baseline; justify-content: flex-end; gap: 20px; }
.add-lesson-row { grid-area: 1 / 2; }
#add-lesson { min-height: 36px; white-space: nowrap; }
#lesson-list > .lesson:first-child { margin-top: 12px; }
.metric { white-space: nowrap; }
.metric > span, .metric small { color: var(--muted); font-size: 12px; }
.metric strong { margin-left: 7px; font: 680 22px/1 system-ui; font-variant-numeric: tabular-nums; }
.stage-group { margin-top: 20px; scroll-margin-top: 12px; }
.stage-heading { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.stage-group h2 { flex: 1; min-width: 0; margin: 0; font-size: 17px; overflow-wrap: anywhere; }
.stage-heading button { flex: none; min-height: 34px; }
.stage-group h2 small { margin-left: 6px; color: var(--muted); font-size: 11px; font-weight: 400; }
.lesson { margin: 0 0 7px; border: 1px solid var(--line); border-radius: 9px; background: var(--card); }
.lesson > summary { display: flex; align-items: center; gap: 9px; padding: 8px 11px; border-radius: 8px; }
.lesson > summary { list-style: none; }
.lesson > summary::-webkit-details-marker { display: none; }
.lesson > summary:hover { background: #fcf5ed; }
.lesson[open] { border-color: #dcc5b4; }
.lesson[open] > summary { border-bottom: 1px solid var(--line); border-radius: 8px 8px 0 0; }
.lesson-no { min-width: 30px; text-align: center; border-radius: 6px; padding: 4px; background: #f4eee6; color: var(--copper); font: 650 12px/1.5 system-ui; }
.lesson-title { flex: 1; min-width: 0; font-size: 13px; }
.lesson-counts { flex: none; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.lesson-counts strong { font-weight: inherit; }
.lesson-counts.has-works { padding: 2px 7px; border-radius: 6px; background: var(--pale); color: var(--copper); }
.lesson-counts.has-works strong { font-size: 15px; font-weight: 750; }
.badge { padding: 2px 6px; border-radius: 5px; background: #f2ece5; color: var(--muted); font-size: 11px; }
.lesson-body { padding: 10px; }
.lesson-edit { display: grid; place-items: center; flex: none; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--muted); }
.lesson-edit:hover { background: var(--pale); color: var(--copper); }
.piece { background: #faf6f0; border: 1px solid #efe5da; border-radius: 8px; padding: 10px; }
.piece + .piece { margin-top: 8px; }
.piece-header { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; }
.piece h3 { flex: 1; margin: 0; color: var(--copper); font-size: 13px; }
.photo-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 9px;
  margin-top: 8px;
  padding: 2px 2px 5px;
}
.photo-row:empty { display: none; }
.photo-card { min-width: 0; }
.photo-frame {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  color: var(--muted);
  cursor: zoom-in;
  font-size: 12px;
}
.photo-frame:disabled { cursor: default; }
.photo-frame img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: contain; }
.photo-meta { margin-top: 7px; }
.photo-meta > span { font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.photo-action { display: block; width: 100%; min-height: 34px; margin-top: 5px; padding: 3px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--card); color: var(--copper); font-size: 13px; }
.photo-action:hover { background: var(--paper); }
.photo-note { margin: 2px 0 0; color: var(--muted); font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.edit { width: 100%; min-width: 0; padding: 3px 5px; border: 1px solid var(--line); border-radius: 5px; background: var(--card); font-size: 12px; }
.description { display: block; margin-top: 8px; padding: 7px 8px; resize: vertical; }
.photo-editor { width: min(400px, calc(100% - 32px)); max-height: calc(100dvh - 32px); padding: 20px; border: 1px solid var(--line); border-radius: 12px; color: inherit; background: var(--card); }
.photo-editor::backdrop { background: #21191699; }
.photo-editor form { display: grid; gap: 14px; }
.photo-editor h2 { margin: 0; font-size: 17px; }
.photo-editor label { display: grid; gap: 5px; font-size: 13px; }
.photo-editor .edit { padding: 7px 9px; font-size: 16px; }
.photo-editor textarea { resize: vertical; }
.photo-editor-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: center; gap: 8px; }
.photo-editor-actions .subtle { min-height: 44px; font-size: 15px; }
.photo-editor-actions [data-remove] { grid-column: 1 / -1; justify-self: start; padding: 6px 0; border: 0; color: #a13227; background: transparent; font-size: 13px; }
.photo-editor-actions [data-remove]:hover { text-decoration: underline; }
.photo-editor-actions .photo-save { border-color: var(--copper); background: var(--copper); color: #fff; }
.course-group-mode { min-width: 0; margin: 0; padding: 0; border: 0; }
.course-group-mode legend { margin-bottom: 5px; font-size: 13px; }
.course-group-mode > div { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.course-group-mode label { display: flex; align-items: center; justify-content: center; min-height: 40px; border: 1px solid var(--line); border-radius: 7px; cursor: pointer; }
.course-group-mode label:has(input:checked) { border-color: var(--copper); background: var(--pale); }
.course-group-mode input { margin: 0; accent-color: var(--copper); }
#image-viewer { width: min(900px, calc(100% - 40px)); max-height: calc(100dvh - 40px); padding: 0; border: 0; border-radius: 10px; background: var(--card); }
#image-viewer::backdrop { background: #211916b8; }
.viewer-content { display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; gap: 6px; padding: 6px 12px 10px; }
.viewer-content img { display: block; width: auto; height: auto; max-width: 100%; max-height: min(680px, calc(100dvh - 184px)); object-fit: contain; }
.viewer-content form { justify-self: end; }
.viewer-content button { width: 44px; height: 44px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: var(--card); font-size: 23px; line-height: 1; }
.viewer-navigation { display: flex; align-items: center; gap: 12px; }
#image-caption { max-width: 100%; padding: 0 6px; font-size: 13px; text-align: center; overflow-wrap: anywhere; }
.viewer-content #viewer-full { width: auto; height: 36px; padding: 0 12px; border-radius: 8px; font-size: 12px; }
.work-photos { display: grid; gap: 8px; }
.work-photo { display: grid; grid-template-columns: 62px minmax(0, 1fr) auto; align-items: center; gap: 6px; }
.work-photo img { width: 62px; height: 58px; object-fit: contain; border: 1px solid var(--line); border-radius: 5px; }
.work-photo button { min-height: 40px; }
.work-photo span { color: var(--copper); font-size: 12px; text-align: center; }
.portfolio { margin-top: 24px; padding-top: 14px; border-top: 1px solid var(--line); }
.portfolio h2 { margin: 0; font-size: 18px; }
.portfolio .photo-row { min-height: 0; }
.portfolio .photo-row:empty { display: grid; }
.portfolio .photo-row:empty::before { content: "暂无作品"; color: var(--muted); font-size: 13px; }
.migration { margin-top: 12px; }
.upload-status { margin: 5px 0; color: var(--muted); font-size: 12px; }
.upload-status button { margin-left: 6px; min-height: 34px; }
#group-confirm p { margin: 0; }
#back-top { position: fixed; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); z-index: 1; min-height: 44px; color: var(--copper); box-shadow: 0 2px 10px #28201c18; }
#notice { position: fixed; z-index: 2; right: 18px; bottom: 14px; max-width: min(410px, calc(100% - 36px)); padding: 10px 15px; border-radius: 8px; background: var(--ink); color: #fff9f2; font-size: 13px; }
@media (max-width: 640px) {
  .viewer-content img { max-height: 52dvh; }
  .wrap { width: calc(100% - 22px); }
  .overview { grid-template-columns: minmax(0, 1fr) auto; border-bottom: 0; padding-bottom: 0; }
  .overview-stats { grid-area: 1 / 2; gap: 8px; }
  .add-lesson-row { grid-area: 2 / 1 / 3 / -1; padding-top: 10px; border-top: 1px solid var(--line); }
  #add-lesson { width: 100%; min-height: 44px; }
  .metric strong { margin-left: 3px; font-size: 19px; }
  .lesson > summary { gap: 6px; padding-inline: 7px; }
  .photo-row {
    grid-auto-flow: row;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
  }
}
