:root {
  --cream: #fbf3e3;
  --cream-2: #fffaf0;
  --ink: #3f3a36;
  --ink-soft: #7d7365;
  --line: #efe3cd;
  --sun: #ffd93d;
  --shadow: 0 14px 30px rgba(126, 96, 48, .16);
  --radius: 22px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  position: fixed;
  inset: 0;
  font-family: "Yuanti SC", "YouYuan", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background-color: #fdf7ea;
  background-image:
    radial-gradient(rgba(255, 214, 102, .35) 2.4px, transparent 2.6px),
    radial-gradient(rgba(255, 154, 122, .22) 2.4px, transparent 2.6px),
    linear-gradient(180deg, #fdf7ea 0%, #fbf0dd 100%);
  background-size: 46px 46px, 46px 46px, 100% 100%;
  background-position: 0 0, 23px 23px, 0 0;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

svg { display: block; }
.mode-tab svg,
.btn svg,
.tool svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.mode-tab svg.solid,
.btn svg.solid,
.tool svg.solid { fill: currentColor; stroke: none; }

.app {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: calc(6px + env(safe-area-inset-top)) 0 calc(env(safe-area-inset-bottom));
}

/* 全屏时把安全区内边距收掉，页面自己贴住屏幕边缘 */
:fullscreen .app,
:-webkit-full-screen .app {
  padding-top: 6px;
}
.app:fullscreen,
.app:-webkit-full-screen { padding-top: 6px; }
::backdrop { background: transparent; }

.app[data-mode="free"]  { --accent: #ff7a59; --accent-ink: #c8462a; --accent-soft: #ffe7df; }
.app[data-mode="learn"] { --accent: #4d96ff; --accent-ink: #2a63c9; --accent-soft: #e2eeff; }
.app[data-mode="color"] { --accent: #16b5a5; --accent-ink: #0a7f74; --accent-soft: #dcf6f2; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 18px 0 14px;
  height: 68px;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { width: 42px; height: 42px; filter: drop-shadow(0 4px 0 rgba(126, 96, 48, .16)); }
.brand-logo svg { width: 100%; height: 100%; }
.brand-name {
  display: flex;
  flex-direction: column;
  font-size: 21px;
  font-weight: 800;
  letter-spacing: 1px;
  line-height: 1.05;
}
.brand-name small {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .5px;
  color: var(--ink-soft);
}

.mode-tabs {
  display: flex;
  gap: 4px;
  padding: 5px;
  margin-left: 6px;
  background: rgba(255, 255, 255, .78);
  border: 1.5px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 6px 16px rgba(126, 96, 48, .1);
}
.mode-tab {
  display: flex;
  align-items: center;
  gap: 7px;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  padding: 9px 15px;
  border-radius: 13px;
  cursor: pointer;
  transition: background .16s, color .16s, transform .1s;
}
.mode-tab svg { width: 20px; height: 20px; }
.mode-tab.is-active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .13);
}
.mode-tab:active { transform: scale(.96); }

.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: inherit;
  font-weight: 800;
  color: var(--ink);
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  padding: 10px 14px;
  min-height: 46px;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(126, 96, 48, .12);
  transition: transform .1s, box-shadow .1s, opacity .16s;
}
.btn svg { width: 21px; height: 21px; }
.btn span { white-space: nowrap; }
.btn:active { transform: translateY(3px); box-shadow: none; }
.btn[disabled] { opacity: .42; pointer-events: none; }
.btn-icon { padding: 10px; min-width: 46px; }
.btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .16);
}
.btn-soft { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }
.btn-danger { background: #ff5b5b; border-color: transparent; color: #fff; }
.btn-block { width: 100%; }
.btn.is-off { color: #b8ad9d; }

/* ---------------- 主区 ---------------- */
.main {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 14px;
  padding: 0 18px;
}

.workspace {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 0 10px;
}

/* 纸张视口：纸比视口大时可以拖着看整张 */
.paper-viewport {
  width: 100%;
  height: 100%;
  display: flex;
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-x pan-y;
  scrollbar-width: none;
}
.paper-viewport::-webkit-scrollbar { display: none; }
.paper-viewport.is-panning { cursor: grab; touch-action: none; }
.paper-viewport.is-panning .paper { touch-action: none; }

.paper {
  position: relative;
  flex: none;
  margin: auto;                 /* 溢出时自动归零，保证四个角都能拖到 */
  width: 100%;
  height: 100%;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow), 0 0 0 1.5px rgba(180, 150, 100, .18);
  touch-action: none;
  overflow: hidden;
}
.paper.is-sheeted { width: var(--sheet-w); height: var(--sheet-h); }
.layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
#inkLayer { z-index: 2; }
#lineLayer { z-index: 3; }
#guideLayer { z-index: 1; }

.tape {
  position: absolute;
  top: -10px;
  width: 92px;
  height: 26px;
  background: rgba(255, 219, 112, .78);
  box-shadow: 0 2px 5px rgba(126, 96, 48, .2);
  border-radius: 2px;
  z-index: 5;
  pointer-events: none;
}
.tape-left { left: 26px; transform: rotate(-5deg); }
.tape-right { right: 26px; transform: rotate(4deg); }

.caption {
  position: absolute;
  left: 14px;
  bottom: 14px;
  z-index: 6;
  pointer-events: none;
  background: rgba(255, 255, 255, .94);
  border: 1.5px solid var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 800;
  font-size: 15px;
  padding: 9px 15px;
  border-radius: 999px;
  box-shadow: 0 5px 14px rgba(126, 96, 48, .16);
  max-width: 78%;
}

.notice {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 7;
  transform: translate(-50%, -50%);
  background: rgba(63, 58, 54, .9);
  color: #fff;
  font-weight: 800;
  font-size: 16px;
  padding: 14px 22px;
  border-radius: 18px;
  pointer-events: none;
  animation: notice-pop 1.5s ease forwards;
}
@keyframes notice-pop {
  0% { opacity: 0; transform: translate(-50%, -42%) scale(.9); }
  18% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  76% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -58%) scale(.98); }
}

.celebrate { position: absolute; inset: 0; z-index: 8; pointer-events: none; overflow: hidden; }
.celebrate i {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--sz);
  height: var(--sz);
  background: var(--c);
  clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  animation: bit-fly var(--dur) cubic-bezier(.2, .7, .4, 1) forwards;
}
@keyframes bit-fly {
  0% { opacity: 0; transform: translate(0, 0) scale(.3) rotate(0deg); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(1) rotate(var(--rot)); }
}

/* ---------------- 右侧面板 ---------------- */
.panel {
  flex: none;
  width: 296px;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-right: 2px;
}
.panel::-webkit-scrollbar { display: none; }

.card {
  background: rgba(255, 255, 255, .9);
  border: 1.5px solid var(--line);
  border-radius: 20px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 8px 18px rgba(126, 96, 48, .08);
}
.card h2 {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: .5px;
  color: var(--ink);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-head h2 { margin-bottom: 10px; }
.card .chalk { width: 24px; height: 24px; }
.card .chalk svg { width: 100%; height: 100%; fill: var(--sun); }
.card-note p { margin: 0; font-size: 13px; line-height: 1.7; color: var(--ink-soft); }
.muted { margin: 8px 0 0; font-size: 12.5px; line-height: 1.6; color: var(--ink-soft); }
.pill {
  font-size: 12px;
  font-weight: 800;
  color: var(--accent-ink);
  background: var(--accent-soft);
  padding: 5px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.idea-text {
  margin: 2px 0 12px;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.5;
  color: var(--accent-ink);
  min-height: 51px;
}

.paper-colors { display: flex; gap: 9px; flex-wrap: wrap; }
.paper-swatch {
  width: 40px;
  height: 40px;
  border-radius: 13px;
  border: 2px solid var(--line);
  cursor: pointer;
  padding: 0;
  box-shadow: inset 0 0 0 2px #fff;
}
.paper-swatch.is-active { border-color: var(--accent); transform: scale(1.06); }

.art-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.art-grid.is-empty { grid-template-columns: 1fr; }

/* 跟学分类 chips：横向可滑，选中的高亮 */
.cat-chips {
  display: flex;
  gap: 6px;
  margin: -2px 0 11px;
  overflow-x: auto;
  overscroll-behavior: contain;
  touch-action: pan-x;
  padding-bottom: 3px;
  scrollbar-width: none;
}
.cat-chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--ink-soft);
  font: inherit;
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: .3px;
  padding: 6px 11px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .14s, color .14s, border-color .14s, transform .1s;
}
.chip:active { transform: scale(.95); }
.chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .12);
}
.chip b { font-size: 11px; font-weight: 700; opacity: .65; margin-left: 3px; }

/* 纸张大小 */
.sheet-sizes { display: flex; gap: 7px; }
.sheet-btn {
  flex: 1;
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--ink-soft);
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  padding: 9px 0;
  border-radius: 13px;
  cursor: pointer;
  transition: background .14s, color .14s, border-color .14s, transform .1s;
}
.sheet-btn:active { transform: scale(.96); }
.sheet-btn.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.art-card {
  border: 2px solid transparent;
  background: #fff;
  border-radius: 14px;
  padding: 5px 5px 4px;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
  box-shadow: 0 3px 10px rgba(126, 96, 48, .1);
  transition: transform .12s, border-color .12s;
}
.art-card svg { width: 100%; height: auto; max-height: 78px; object-fit: contain; display: block; border-radius: 9px; background: #fffdfa; }
.art-card img { width: 100%; height: auto; max-height: 78px; object-fit: contain; display: block; border-radius: 9px; background: #fffdfa; }
.art-card span {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.art-card:active { transform: scale(.96); }
.art-card.is-active { border-color: var(--accent); box-shadow: 0 5px 14px rgba(126, 96, 48, .18); }

.step-card { padding: 12px 13px; }

.step-head { display: flex; align-items: center; justify-content: space-between; }
.step-badge {
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  background: var(--accent);
  padding: 5px 11px;
  border-radius: 999px;
}
.step-count { font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.step-label { margin: 10px 0; font-size: 16.5px; font-weight: 800; line-height: 1.5; }
.progress { height: 9px; border-radius: 99px; background: #f0e7d6; overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; border-radius: 99px; background: var(--accent); transition: width .3s ease; }
.step-actions { display: flex; gap: 8px; margin: 12px 0 8px; }
.step-actions .btn { flex: 1; padding: 11px 8px; }
.step-actions .btn svg { width: 19px; height: 19px; }

.ref-frame {
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 4px;
}
.ref-frame svg { width: 100%; height: auto; max-height: 200px; object-fit: contain; display: block; }

/* ---------------- 底部工具坞 ---------------- */
.dock {
  flex: none;
  height: 96px;
  margin: 10px 18px 8px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, .86);
  border: 1.5px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.tools { display: flex; align-items: center; gap: 7px; }
.tool {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 60px;
  height: 72px;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  background: #fff;
  color: var(--ink-soft);
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.tool svg { width: 24px; height: 24px; }
.tool.is-active {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .14);
}
.tool:active { transform: scale(.95); }
.color-only { display: none; }
.app[data-mode="color"] .color-only { display: flex; }
.free-only { display: none; }
.app[data-mode="free"] .free-only { display: flex; }

.tool-divider { width: 1.5px; height: 46px; background: var(--line); margin: 0 3px; }

.sizes { display: flex; gap: 6px; align-items: center; }
.sizes button {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}
.sizes i {
  width: var(--dot);
  height: var(--dot);
  border-radius: 50%;
  background: #b8ad9d;
}
.sizes button.is-active { background: var(--accent-soft); border-color: transparent; }
.sizes button.is-active i { background: var(--accent-ink); }

.palette-wrap { flex: 1; min-width: 0; position: relative; }
.palette {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  align-items: center;
  padding: 4px 2px 10px;
  scrollbar-width: none;
  touch-action: pan-x;
  scroll-behavior: smooth;
}
.palette::-webkit-scrollbar { display: none; }
.palette-wrap.is-clipped::after {
  content: "";
  position: absolute;
  right: 0;
  top: 2px;
  bottom: 10px;
  width: 40px;
  pointer-events: none;
  border-radius: 0 14px 14px 0;
  background: linear-gradient(to right, rgba(255, 255, 255, 0), rgba(255, 255, 255, .95));
}
.palette-wrap.is-clipped .swatch:last-child { margin-right: 26px; }
.swatch {
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 3px solid #fff;
  background: var(--c);
  cursor: pointer;
  padding: 0;
  box-shadow: 0 0 0 1.5px rgba(63, 58, 54, .14), 0 3px 7px rgba(126, 96, 48, .18);
  position: relative;
  transition: transform .12s;
}
.swatch.is-active { transform: scale(1.14); box-shadow: 0 0 0 3px var(--accent), 0 4px 10px rgba(126, 96, 48, .24); }
.swatch.is-active::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 46%;
  width: 12px;
  height: 7px;
  border-left: 2.5px solid #fff;
  border-bottom: 2.5px solid #fff;
  transform: translate(-50%, -50%) rotate(-45deg);
}
.swatch[data-light="1"].is-active::after { border-color: rgba(63, 58, 54, .55); }

/* ---------------- 浮层 ---------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 128px;
  transform: translateX(-50%);
  z-index: 40;
  background: rgba(63, 58, 54, .93);
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  padding: 12px 20px;
  border-radius: 999px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .22);
  animation: toast-in .22s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } }

.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(58, 44, 26, .42); backdrop-filter: blur(3px); }
.modal-card {
  position: relative;
  width: min(420px, 88vw);
  background: var(--cream-2);
  border-radius: 28px;
  padding: 26px 24px 20px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(58, 44, 26, .34);
  animation: modal-in .26s cubic-bezier(.2, .9, .3, 1.3);
}
@keyframes modal-in { from { opacity: 0; transform: scale(.86); } }
.modal-icon { width: 54px; height: 54px; margin: 0 auto 6px; }
.modal-icon svg { width: 100%; height: 100%; fill: var(--sun); }
.modal-card h2 { margin: 0 0 6px; font-size: 21px; }
.modal-card p { margin: 0 0 18px; color: var(--ink-soft); font-size: 15px; line-height: 1.6; }
.modal-card .how { text-align: left; font-size: 14px; line-height: 1.75; color: var(--ink); margin: 0 0 16px; }
.modal-card .how b { color: var(--accent-ink); }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }

/* ---------------- 适配 ---------------- */
@media (max-width: 1120px) {
  .top-actions { gap: 6px; }
  .top-actions .btn { padding: 10px 12px; }
  .top-actions .btn-ghost span { display: none; }
}

@media (max-width: 1000px) {
  .panel { width: 252px; }
  .brand-name small { display: none; }
  .btn span { display: none; }
  .btn { padding: 10px 12px; }
  .btn-primary span { display: inline; }
}

@media (max-width: 860px), (orientation: portrait) {
  .main { flex-direction: column; gap: 10px; }
  .panel { width: auto; max-height: 30%; overflow-x: auto; }
  .panel-view { display: flex; gap: 10px; align-items: flex-start; }
  .panel-view[hidden] { display: none; }
  .card { min-width: 240px; margin-bottom: 0; }
  .workspace { padding: 0; }
  .mode-tab span { display: none; }
  .mode-tab { padding: 9px 12px; }
  .brand-name { display: none; }
  .dock { height: 88px; }
}

@media (max-height: 600px) {
  .topbar { height: 56px; }
  .dock { height: 82px; margin-top: 6px; }
  .tool { height: 62px; width: 54px; font-size: 11px; }
  .swatch { width: 38px; height: 38px; }
}

/* ---------------- 保存作品弹层 ---------------- */
.save-sheet {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(63, 58, 54, .55);
  backdrop-filter: blur(3px);
}
.save-sheet[hidden] { display: none; }
.save-card {
  background: #fffdfa;
  border-radius: 24px;
  padding: 16px;
  max-width: min(92vw, 640px);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  box-shadow: 0 20px 50px rgba(63, 58, 54, .3);
}
.save-card img {
  max-width: 100%;
  max-height: 62vh;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 4px 16px rgba(126, 96, 48, .18);
  -webkit-touch-callout: default;
  touch-action: manipulation;
}
.save-tip {
  margin: 0;
  font-size: 13.5px;
  color: #7d7365;
  text-align: center;
  line-height: 1.6;
}
.save-tip b { color: var(--ink); }
.save-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.save-actions .btn { min-width: 132px; min-height: 50px; font-size: 16px; }

/* 弹层在 .app 外面，拿不到 --accent，这里显式给色 */
.save-actions .btn-primary {
  background: #ff7a59;
  border-color: #ff7a59;
  color: #fff;
}
.save-actions .btn-primary:active { background: #f06a49; }

/* ---------------- 抽屉：侧栏 + 底部工具栏 ---------------- */

.panel-handle {
  position: absolute;
  right: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 84px;
  border-radius: 16px;
  border: 1.5px solid var(--line);
  background: rgba(255, 255, 255, .95);
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 7;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(126, 96, 48, .18);
  -webkit-tap-highlight-color: transparent;
}
.panel-handle svg, .dock-handle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform .24s ease;
}
.panel { transition: width .24s ease, opacity .18s ease, padding .24s ease; }
.app.is-nopanel .main { gap: 0; }
.app.is-nopanel .panel {
  width: 0;
  padding: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
}
.app.is-nopanel .panel-handle svg { transform: rotate(180deg); }

.dock { position: relative; transition: height .24s ease, padding .24s ease, margin .24s ease; }
.dock-handle {
  position: absolute;
  top: -13px;
  left: 50%;
  transform: translateX(-50%);
  width: 58px;
  height: 22px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: rgba(255, 255, 255, .96);
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 7;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(126, 96, 48, .16);
  -webkit-tap-highlight-color: transparent;
}
.dock-handle svg { width: 16px; height: 16px; }
.app.is-nodock .dock { height: 14px; padding: 0; }
.app.is-nodock .dock > *:not(.dock-handle) { display: none; }
.app.is-nodock .dock-handle svg { transform: rotate(180deg); }
/* 侧栏收起后画布顶到屏幕边，把手往里收一点，别贴边被切 */
.app.is-nopanel .panel-handle { right: 3px; }

/* 锁横屏：整个界面被转 90°，禁掉页面滚动 */
html.rot-locked,
html.rot-locked body { overflow: hidden; height: 100%; }

/* 形状按钮做得窄一点，给调色板让出位置 */
.tool[data-shape] { width: 52px; }
.tool[data-shape] span { font-size: 11px; }

/* ---------------- 折叠组：形状 / 粗细 ---------------- */
.pop-group { position: relative; display: flex; align-items: center; }
.pop-menu {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  padding: 9px 10px;
  background: #fffdfa;
  border: 1.5px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 12px 28px rgba(126, 96, 48, .2);
  z-index: 20;
}
.pop-menu[hidden] { display: none; }
.pop-item {
  width: 58px;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 7px 4px;
  border-radius: 12px;
  cursor: pointer;
}
.pop-item svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.pop-item.is-active { background: var(--accent-soft); color: var(--accent-ink); }
.pop-item:active { transform: scale(.95); }

.size-trigger {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}
.size-trigger i {
  width: var(--dot);
  height: var(--dot);
  border-radius: 50%;
  background: #b8ad9d;
}
#sizes { gap: 6px; }
#sizes button {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}
#sizes button.is-active { background: var(--accent-soft); border-color: transparent; }
#sizes button.is-active i { background: var(--accent-ink); }
#sizes i {
  width: var(--dot);
  height: var(--dot);
  border-radius: 50%;
  background: #b8ad9d;
}

/* 粗细触发钮上的圆点再深一点，白底上才看得清 */
.size-trigger i { background: #8d8375; }

/* 锁横屏：整个 App 转 90° 顶满屏幕（内联 --rot-w/--rot-h 由 JS 写入） */
.app.rot90 {
  position: fixed;
  top: 0;
  left: var(--rot-w, 100vw);
  width: var(--rot-h, 100vw);
  height: var(--rot-w, 100vh);
  transform: rotate(90deg);
  transform-origin: 0 0;
}

/* 跟学：画布上的「隐藏原稿」开关 */
.guide-toggle {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 8;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 15px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: rgba(255, 255, 255, .94);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(126, 96, 48, .16);
}
.guide-toggle svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.guide-toggle[hidden] { display: none; }
.guide-toggle[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; }

/* 看步骤：一排卡片 */
.cards { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.cards .cd { margin: 0; flex: 1 1 120px; max-width: 180px; }
.cards .cd svg { width: 100%; height: auto; display: block; background: #fffdfa; border-radius: 12px; }
.cards .cd figcaption { font-size: 11.5px; color: #7d7365; margin-top: 4px; line-height: 1.45; }
.guide-steps { right: auto; left: 12px; }

/* 步骤卡弹层：宽一点、去掉大星星图标 */
.modal.is-wide .modal-card { width: min(860px, 94vw); max-height: 90vh; overflow-y: auto; }
.modal.no-icon .modal-icon { display: none; }
.modal.is-wide #modalTitle { font-size: 19px; margin-bottom: 8px; }
