/* 小镇童话 · 课堂版
   纸色、楷体、朱砂印章。分镜板是唯一的重头戏，其余保持安静。 */

:root {
  --paper: #f6f0de;
  --surface: #fffbf0;
  --ink: #332e24;
  --ink-soft: #6b6152;
  --muted: #948a76;
  --seal: #b4452a;
  --teal: #2f6b6a;
  --teal-d: #235150;
  --line: #e2d8be;
  --yellow: #e8b23a;
  --sh: 0 1px 0 rgba(51, 46, 36, 0.06), 0 14px 34px -22px rgba(51, 46, 36, 0.55);
  --sh-sm: 0 1px 0 rgba(51, 46, 36, 0.08);
  --r: 14px;
  --display: "Kaiti SC", "STKaiti", "KaiTi", "楷体", "Songti SC", serif;
  --body: system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-padding-top: 84px; }

body {
  margin: 0;
  min-height: 100dvh;
  background-color: var(--paper);
  background-image: radial-gradient(rgba(51, 46, 36, 0.05) 0.5px, transparent 0.6px);
  background-size: 3px 3px;
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
  /* 平板上下拉刷新、橡皮筋滚动会把拖贴纸打断 */
  overscroll-behavior-y: contain;
}

button, a { touch-action: manipulation; }

h1, h2, h3 { font-family: var(--display); font-weight: 700; margin: 0; letter-spacing: 0.04em; }

a { color: var(--teal-d); }

button, input, textarea { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

::selection { background: rgba(47, 107, 106, 0.22); }

/* ---------- 顶部 ---------- */

.top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
  background: rgba(246, 240, 222, 0.97);
  position: sticky;
  top: 0;
  z-index: 20;
}
.top[hidden] { display: none; }

.top .group-name {
  font-family: var(--display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.06em;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.top .hero-chip { flex: none; }

.top .progress {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  font-size: 15px;
  letter-spacing: 0.06em;
}

.top .progress b { font-size: 22px; color: var(--seal); font-weight: 700; }

.back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-left: -8px;
  border-radius: 50%;
  font-size: 20px;
  color: var(--ink-soft);
  text-decoration: none;
}
.back:hover { background: rgba(51, 46, 36, 0.06); color: var(--ink); }

/* ---------- 按钮 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 22px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--teal);
  color: #fdfaf0;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, opacity 0.15s ease;
}
.btn:hover:not(:disabled) { background: var(--teal-d); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.is-wait { opacity: 0.5; }

.btn--ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink-soft);
}
.btn--ghost:hover:not(:disabled) { background: var(--surface); color: var(--ink); }

.btn--seal { background: var(--seal); }
.btn--seal:hover:not(:disabled) { background: #98381f; }

.btn--sm {
  min-height: 44px;
  padding: 0 16px;
  font-size: 15px;
  border-radius: 10px;
}

.link {
  border: 0;
  background: none;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--ink-soft);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--line);
  cursor: pointer;
  font-size: 15px;
}
.link:hover { color: var(--seal); text-decoration-color: currentColor; }
.link.is-armed { color: var(--seal); font-weight: 700; }

/* ---------- 进组页 ---------- */

.index-main {
  max-width: 1080px;
  margin: 0 auto;
  padding: clamp(20px, 5vw, 56px) clamp(16px, 4vw, 40px) 96px;
}

.index-main .brand {
  font-family: var(--display);
  font-size: clamp(26px, 3.6vw, 36px);
  letter-spacing: 0.14em;
  margin-bottom: clamp(18px, 3vw, 32px);
}
.index-main .brand span { color: var(--seal); }

.groups {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: clamp(14px, 2.4vw, 24px);
}

.group-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  aspect-ratio: 4 / 3.2;
  padding: 16px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--sh);
  text-decoration: none;
  color: var(--ink);
  overflow: hidden;
  transition: transform 0.12s ease, box-shadow 0.2s ease;
}
.group-tile:hover { transform: translateY(-2px); }
.group-tile .name {
  align-self: flex-start;
  max-width: 100%;
  font-family: var(--display);
  font-size: clamp(22px, 2.2vw, 28px);
  font-weight: 700;
  letter-spacing: 0.06em;
  position: relative;
  z-index: 1;
}
.group-tile .meta {
  margin-top: auto;
  position: relative;
  z-index: 1;
}
.group-tile .title {
  position: relative;
  z-index: 1;
  font-family: var(--display);
  font-size: 15px;
  line-height: 1.4;
  color: var(--ink-soft);
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.group-tile:not(.has-cover) { justify-content: center; }
.group-tile:not(.has-cover) .meta { margin-top: 12px; }
.group-tile .ticks { display: flex; gap: 5px; }
.group-tile .tick {
  flex: 1;
  max-width: 30px;
  height: 6px;
  border-radius: 3px;
  background: var(--line);
}
.group-tile .tick.on { background: var(--seal); }
.group-tile .thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.38;
}
.group-tile.has-cover .name {
  background: rgba(255, 251, 240, 0.82);
  box-shadow: 0 0 0 6px rgba(255, 251, 240, 0.82);
  border-radius: 3px;
}
.group-tile.has-cover .meta {
  background: rgba(255, 251, 240, 0.82);
  box-shadow: 0 0 0 6px rgba(255, 251, 240, 0.82);
  border-radius: 4px;
}
.group-tile.finished::after {
  content: "画完了";
  position: absolute;
  top: 12px;
  right: -30px;
  padding: 3px 34px;
  background: var(--teal);
  color: #fdfaf0;
  font-size: 12px;
  letter-spacing: 0.16em;
  transform: rotate(35deg);
  z-index: 2;
}

.seal {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  background: var(--seal);
  color: #fbeee4;
  border-radius: 6px;
  font-family: var(--display);
  font-size: 20px;
  text-decoration: none;
  box-shadow: 0 6px 18px -8px rgba(180, 69, 42, 0.8);
  opacity: 0.55;
  transition: opacity 0.2s ease;
  z-index: 30;
}
.seal:hover, .seal:focus-visible { opacity: 1; }

/* ---------- 工作台 ---------- */

.studio-main {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px clamp(14px, 3vw, 32px) 120px;
}

.book-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 18px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
}
.book-title span { font-family: var(--display); color: var(--muted); font-size: 18px; }
.book-title input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font-family: var(--display);
  font-size: clamp(22px, 2.8vw, 30px);
  padding: 4px 0;
  outline: none;
}
.book-title input::placeholder { color: rgba(148, 138, 118, 0.6); }

.strip {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.panel {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 10px 10px 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--sh);
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.panel .num {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  background: var(--seal);
  color: #fbeee4;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.panel .author {
  font-family: var(--display);
  font-size: 16px;
  color: var(--teal-d);
  letter-spacing: 0.04em;
}

.panel-frame.ghost {
  aspect-ratio: 3 / 2;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 4px;
  background: rgba(226, 216, 190, 0.16);
}

.panel-frame.preset {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 12px;
  padding: 22px;
}
.preset-text {
  font-family: var(--display);
  font-size: clamp(16px, 1.7vw, 20px);
  line-height: 1.5;
  color: var(--ink-soft);
}
.preset-beat {
  display: block;
  font-size: 14px;
  letter-spacing: 0.1em;
  color: var(--seal);
}
.preset-ask {
  display: block;
  margin-top: 4px;
  font-size: 16px;
  line-height: 1.6;
}
.panel-frame.preset .claim { align-self: flex-start; }

.panel-body { display: flex; flex-direction: column; gap: 10px; }
.panel textarea {
  width: 100%;
  min-width: 0;
  min-height: 92px;
  padding: 4px 2px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  font-family: var(--display);
  font-size: 17px;
  line-height: 1.6;
  resize: vertical;
  outline: none;
}
.panel textarea::placeholder { color: rgba(148, 138, 118, 0.7); }
.panel textarea:focus { border-bottom-color: var(--teal); }

.name-input,
.bubble-form input {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  font-size: 17px;
  outline: none;
}
.name-input:focus,
.bubble-form input:focus { border-color: var(--teal); }

.claim-row { display: flex; align-items: center; gap: 10px; }

.art {
  position: relative;
  aspect-ratio: 3 / 2;
  background: #ece4cf;
  border-radius: 4px;
  overflow: hidden;
}
.art::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  border-radius: inherit;
  mix-blend-mode: multiply;
  background-image:
    radial-gradient(ellipse at 50% 46%, rgba(255, 255, 255, 0) 58%, rgba(120, 88, 44, 0.16) 100%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23g)' opacity='0.32'/%3E%3C/svg%3E"),
    linear-gradient(rgba(227, 198, 145, 0.26), rgba(227, 198, 145, 0.26));
  background-size: cover, 180px 180px, cover;
}

.art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: zoom-in;
}

.panel-text {
  margin: 8px 2px 0;
  font-family: var(--display);
  font-size: 16px;
  line-height: 1.5;
}

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag {
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink-soft);
  font-size: 12px;
}
.stickers { display: flex; flex-direction: column; gap: 8px; }
.chips, .palette { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 14px;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.chip:hover { border-color: var(--teal); }
.chip.on { background: rgba(47, 107, 106, 0.12); border-color: var(--teal); color: var(--teal-d); }
.chip:disabled { opacity: 0.45; cursor: default; }
.palette.is-full::after {
  content: "贴满了，点贴纸上的 × 换一张";
  flex-basis: 100%;
  font-size: 13px;
  color: var(--muted);
  padding: 2px 2px 0;
}

/* 构图：把贴纸拖进这个框，位置就是提示词里的方位 */
.compose {
  position: relative;
  aspect-ratio: 3 / 2;
  margin-top: 2px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: repeating-linear-gradient(45deg, rgba(226, 216, 190, 0.18) 0 10px, transparent 10px 20px);
  overflow: hidden;
}
.compose-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.08em;
  pointer-events: none;
}
/* 这一页在哪儿：地方照缩略图，选中一张就是这一页的地方 */
.shot { display: flex; flex-direction: column; gap: 6px; }
.shot-k { font-size: 13px; color: var(--muted); }
.place-cards { display: flex; gap: 6px; }
.place-card {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  text-align: left;
}
.place-card img {
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  border-radius: 6px;
  display: block;
}
.place-card.on { border-color: var(--teal); box-shadow: inset 0 0 0 1px var(--teal); }
.place-card.is-wait { border-style: dashed; }
.place-name {
  font-size: 12px;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.place-wait { font-size: 11px; color: var(--muted); }
.frame-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.frame-row .chip { min-height: 36px; padding: 0 12px; font-size: 13px; }
/* 画好的页改了地方或远近：旧图留着对照，只把图压淡一点 */
.is-stale .art img { opacity: 0.45; }
.shot-note { margin: 4px 0 0; font-size: 13px; color: var(--accent, #b4643c); }
.shot-tip { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-soft); }
/* 画完了的那本书：地方卡和远近只剩展示，不能点 */
.place-card.is-fixed { cursor: default; }
.frame-row .chip.is-fixed { cursor: default; }
/* 「这一格还有谁」：客人缩略图 + 两个选择 */
.guest-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.guest-row .chip { min-height: 36px; padding: 0 12px; font-size: 13px; }
.guest-thumb { width: 36px; height: 27px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.ghost-note { font-size: 13px; color: var(--muted); }

.psticker {
  position: absolute;
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 4px 8px 4px 12px;
  border: 1px solid rgba(47, 107, 106, 0.4);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--sh-sm);
  font-size: 14px;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.psticker.dragging { cursor: grabbing; box-shadow: var(--sh); }
.psticker.ghost { position: fixed; z-index: 50; opacity: 0.9; }
body.is-dragging, body.is-dragging .chip, body.is-dragging .psticker { cursor: grabbing; }
.psticker-x {
  border: none;
  background: none;
  width: 32px;
  height: 32px;
  padding: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.psticker-x:hover { color: var(--seal); }

.bubble {
  position: absolute;
  z-index: 3;
  max-width: 52%;
  padding: 6px 10px;
  transform: translate(-50%, -50%);
  background: #fffdf6;
  color: #332e24;
  border: 2px solid #332e24;
  border-radius: 12px;
  font-family: var(--display);
  font-size: 16px;
  line-height: 1.4;
  cursor: grab;
  touch-action: none;
  user-select: none;
  max-width: 60%;
  padding: 8px 12px;
}
.bubble::after {
  content: "";
  position: absolute;
  left: 14px;
  bottom: -7px;
  width: 10px;
  height: 10px;
  background: #fffdf6;
  border-right: 2px solid #332e24;
  border-bottom: 2px solid #332e24;
  transform: rotate(45deg);
}
.bubble.dragging { cursor: grabbing; }
.show .bubble { font-size: clamp(14px, 1.3vw, 22px); }
.panel .claim { min-height: 52px; padding: 0 26px; font-size: 17px; }

.bubble-form { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.bubble-form input { flex: 1; min-width: 0; }
.bubble-form .btn { flex: none; }

.hero-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  max-width: 46vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hero-chip:hover { border-color: var(--teal); color: var(--teal-d); }
.hero-chip.is-fixed { cursor: default; }
.hero-chip[hidden] { display: none; }
.hero-chip.is-fixed:hover { border-color: var(--line); color: var(--ink-soft); }
.hero-chip .hero-emoji { font-size: 16px; line-height: 1; flex: none; }
.tag-pic {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex: none;
}
.tag-pic img { width: 100%; height: 100%; object-fit: contain; display: block; }
.tag-emoji { font-size: 15px; line-height: 1; }
.card .tag-pic { width: 72px; height: 72px; }
.card .tag-pic img { border-radius: 10px; }
.chip .tag-pic { margin-right: 5px; }
.swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  margin-right: 5px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}
.hero-chip.busy { opacity: 0.75; cursor: progress; }

.sheet {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(28, 25, 20, 0.45);
}
.sheet[hidden] { display: none; }
.sheet-card {
  width: min(560px, 100%);
  max-height: 90dvh;
  overflow: auto;
  padding: 18px;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 30px 80px -40px rgba(0, 0, 0, 0.6);
}
.sheet-card h2 { font-size: 20px; letter-spacing: 0.08em; margin-bottom: 12px; }

.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  cursor: pointer;
}
.card-name { font-size: 13px; color: var(--ink-soft); }
.card.on { border-color: var(--seal); background: rgba(180, 69, 42, 0.07); box-shadow: 0 0 0 1px var(--seal); }

.tweaks { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.tweak { display: flex; flex-direction: column; gap: 6px; }
.tweak-k { font-size: 13px; color: var(--muted); }
.tweak-row { display: flex; flex-wrap: wrap; gap: 6px; }

.sheet-row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.story-list { display: flex; flex-direction: column; gap: 8px; }
.story-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 72px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  text-align: left;
  cursor: pointer;
}
.story-item:hover { border-color: var(--seal); }
.story-title { font-family: var(--display); font-size: 19px; color: var(--ink); }
.story-line { font-size: 14px; line-height: 1.5; color: var(--muted); }

.panel.busy .busy {
  display: grid;
}
.panel .busy {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(255, 251, 240, 0.94);
  border-radius: 6px;
  z-index: 4;
}
.panel .busy span {
  font-family: var(--display);
  font-size: 20px;
  color: var(--seal);
  letter-spacing: 0.12em;
  animation: breathe 1.6s ease-in-out infinite;
}
@keyframes breathe { 50% { opacity: 0.35; } }

.studio-foot {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px clamp(14px, 3vw, 32px) calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--paper) 65%, rgba(246, 240, 222, 0));
  display: flex;
  justify-content: center;
  z-index: 15;
}
.studio-foot .btn { min-width: 220px; }
/* 输入时收起底栏，键盘弹出也不会盖住正在写的那一格 */
body.typing .studio-foot { display: none; }

.done-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 18px;
  margin-bottom: 18px;
  background: var(--surface);
  border: 1px dashed var(--teal);
  border-radius: var(--r);
  font-family: var(--display);
  font-size: 19px;
}
.done-banner .btn { min-height: 42px; }

/* 看图 */

.viewer {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  grid-template-rows: auto 1fr auto;
  background: rgba(28, 25, 20, 0.94);
  padding: 18px;
  color: #f4edda;
}
.viewer.open { display: grid; }
.viewer img {
  max-width: 100%;
  max-height: 100%;
  margin: auto;
  object-fit: contain;
  border-radius: 4px;
}
.viewer .vbar { display: flex; align-items: center; gap: 12px; font-family: var(--display); }
.viewer .vbar .link { color: #d9cfb8; }
.viewer button {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid rgba(244, 237, 218, 0.3);
  background: transparent;
  color: #f4edda;
  cursor: pointer;
}
.viewer button:hover { background: rgba(244, 237, 218, 0.12); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%) translateY(8px);
  background: var(--ink);
  color: #fdf7ec;
  padding: 10px 18px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  text-align: center;
  word-break: break-word;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 80;
  width: max-content;
  max-width: min(92vw, 420px);
  box-sizing: border-box;
}
.toast.is-on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 老师端 ---------- */

.admin-main { max-width: 960px; margin: 0 auto; padding: 22px clamp(14px, 3vw, 32px) 80px; }

.sec {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 18px;
  margin-bottom: 18px;
}
.sec h2 { font-size: 18px; letter-spacing: 0.1em; margin-bottom: 12px; display: flex; align-items: center; gap: 10px; }
.sec h2 .spacer { flex: 1; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 560px; }
th, td { padding: 9px 8px; text-align: left; border-bottom: 1px solid var(--line); font-size: 15px; }
th { color: var(--muted); font-weight: 500; font-size: 13px; letter-spacing: 0.1em; }
td input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  outline: none;
}
td input:focus { border-color: var(--teal); }

.cover-cell img { width: 72px; height: 48px; object-fit: cover; border-radius: 6px; display: block; }
.cover-cell .none { color: var(--muted); font-size: 13px; }

.state { font-size: 13px; color: var(--muted); white-space: nowrap; }
.state.done { color: var(--teal-d); font-weight: 600; }

.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(360px, 100%); }
.login-card h1 { font-size: 26px; margin-bottom: 18px; text-align: center; letter-spacing: 0.1em; }
.login-card input {
  width: 100%;
  min-height: 52px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  margin-bottom: 12px;
  font-size: 18px;
  outline: none;
}
.login-card input:focus { border-color: var(--teal); }
.login-card .btn { width: 100%; }
.login-card .err { color: var(--seal); font-size: 14px; min-height: 22px; margin-top: 8px; }

.groups-foot { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; align-items: center; }

/* ---------- 展示 ---------- */

.show {
  background: #1b1813;
  color: #f4edda;
  color-scheme: dark;
  margin: 0;
  min-height: 100dvh;
  overflow: hidden;
}
.show ::selection { background: rgba(232, 178, 58, 0.35); }
.show-stage {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  height: 100dvh;
  padding: 14px clamp(14px, 3vw, 40px);
}
.show-head {
  display: flex;
  align-items: baseline;
  gap: 18px;
  padding-bottom: 8px;
}
.show-head .book-title {
  font-family: var(--display);
  font-size: clamp(20px, 2.4vw, 34px);
  letter-spacing: 0.08em;
  margin: 0;
}
.show-head .group-name { color: rgba(244, 237, 218, 0.5); font-size: 15px; letter-spacing: 0.1em; }
.show-head .spacer { flex: 1; }
.show-head button {
  border: 1px solid rgba(244, 237, 218, 0.25);
  background: transparent;
  color: rgba(244, 237, 218, 0.8);
  border-radius: 10px;
  min-height: 40px;
  padding: 0 14px;
  cursor: pointer;
}
.show-head button:hover { background: rgba(244, 237, 218, 0.1); }

.frame {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
}
.frame img {
  max-width: 100%;
  max-height: 100%;
  filter: sepia(0.07) saturate(0.97);
  object-fit: contain;
  border-radius: 3px;
  box-shadow: 0 30px 80px -40px rgba(0, 0, 0, 0.9);
  background: #2a251d;
  transition: opacity 0.18s ease;
}
.frame img.loading { opacity: 0.25; }
.frame .tap {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 30%;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: transparent;
}
.frame .tap:focus-visible { outline: 2px solid var(--yellow); outline-offset: -6px; }
.frame .tap.prev { left: 0; }
.frame .tap.next { right: 0; }
.frame .tap:hover { background: linear-gradient(to right, rgba(244, 237, 218, 0.06), transparent); }

.caption {
  font-family: var(--display);
  font-size: clamp(20px, 2.6vw, 34px);
  line-height: 1.5;
  text-align: center;
  padding: 10px 8px 2px;
  letter-spacing: 0.05em;
}
.caption .by {
  display: block;
  font-family: var(--body);
  font-size: 14px;
  letter-spacing: 0.1em;
  color: rgba(244, 237, 218, 0.45);
  margin-top: 2px;
}

.show-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: rgba(244, 237, 218, 0.55);
  font-variant-numeric: tabular-nums;
  padding-bottom: 6px;
  font-size: 14px;
}
.dots { display: flex; gap: 6px; }
.dots i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(244, 237, 218, 0.25);
}
.dots i.on { background: var(--yellow); }

.show-empty { display: grid; place-items: center; min-height: 100dvh; font-family: var(--display); font-size: 24px; }

/* ---------- 宽屏 ---------- */

@media (min-width: 760px) {
  .top { padding: 16px 28px; }
  .studio-main { padding-top: 26px; }
}

/* 平板竖着拿：图按宽度撑满，说明紧贴图下，页码留在底部 */
@media (orientation: portrait) and (min-width: 600px) {
  .show-stage { grid-template-rows: auto auto 1fr auto; }
  .frame { align-items: flex-start; }
}

/* 横着拿的平板：写作格左边写字、右边拖贴纸，一屏放得下，不用来回滚 */
@media (min-width: 900px) and (orientation: landscape) {
  .panel.is-writing .panel-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    align-items: start;
    gap: 10px 20px;
  }
  .panel.is-writing .panel-body > textarea { grid-column: 1; grid-row: 1; align-self: stretch; }
  .panel.is-writing .panel-body > .stickers { grid-column: 2; grid-row: 1 / span 2; }
  .panel.is-writing .panel-body > .draw { grid-column: 1; grid-row: 2; }
}

/* ---------- 平板：手掌大小、手指点按、横竖都撑满 ---------- */

@media (min-width: 700px) {
  body { font-size: 17px; }
  .top { min-height: 64px; }
  .top .group-name { font-size: 24px; }
  .top .progress { font-size: 16px; }
  .top .progress b { font-size: 24px; }
  .back { width: 48px; height: 48px; }
  .hero-chip { min-height: 40px; font-size: 14px; }
  .panel textarea { font-size: 18px; min-height: 130px; }
  .name-input, .bubble-form input { font-size: 18px; min-height: 52px; }
  .panel .claim { min-height: 56px; padding: 0 30px; font-size: 18px; }
  .story-title { font-size: 20px; }
  .story-line { font-size: 14px; }
  .sheet-card { width: min(620px, 100%); padding: 22px; }
  .show-head button { min-height: 44px; padding: 0 16px; font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* 就地确认：点重画、删掉这类动作后在原地长出一条，不用浏览器原生弹窗 */
.confirm {
  display: flex;
  flex: 1 1 100%;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.confirm-text { flex: 1 1 100%; font-size: 14px; line-height: 1.45; color: var(--ink-soft); }
.confirm .btn,
.confirm .link { flex: none; }
.studio-foot .confirm { margin: 0 0 10px; }
.row-actions { flex-wrap: wrap; }
