/* 在我的画布上种花：配色橄榄棕 + 灰绿 + 粉灰米。
   标题条下面是整块舞台，画布铺满它；纸是桌上的一个物体，缩放平移作用在整个舞台。
   时间钮 + 五钮、4 个工具按钮、竖拉条、文字设置窗都悬浮在舞台上，底色实心、不透明，容器不接指针，只有本体接。横竖屏同一套悬浮做法。 */
:root {
  color-scheme: only light;
  --page: #cdbfb2;
  --paper: #ece2d9;
  --paper-edge: #d8c9bb;
  --olive: #766e55;
  --olive-deep: #5a5440;
  --cream: #e6dfc4;
  --ink: #4a4733;
  --title: #5f6241;
  --sage: #c4d5c0;
  --green-deep: #4f6b4a;
  --thumb: #2f4a2c;
  --stone: #b9b09a;
  --plum: #6a4745;
  --on-bar: #f6efdc;
  --dock: #6b6349;

  --bg: #cdbfb2;
  --surface: #efe6dc;
  --surface-2: #ddd0c3;
  --field: #f6efe8;
  --bar: #5a5440;
  --ink-2: #5f6241;
  --ink-3: #9b9078;
  --line: #766e55;
  --accent: #a9bfa4;
  --on-dark: #f6efdc;
}

html,
body {
  background: var(--page);
  color: var(--ink);
}

/* 壳：标题条 / 舞台（时间钮、五钮、工具都悬浮在舞台上） */
.app {
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--page);
}

.titlebar {
  position: relative;
  z-index: var(--z-float);
  padding: 10px 56px 0;
  text-align: center;
}

.title-line {
  display: flex;
  align-items: center;
  justify-content: center;
}

.title {
  margin: 0 8px;
  color: var(--title);
  font-weight: 900;
  font-size: 20px;
  line-height: 28px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.titlebar::after {
  content: "";
  display: block;
  height: 4px;
  margin: 6px -50px 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='4'%3E%3Crect width='14' height='4' rx='2' fill='%237d7f58'/%3E%3C/svg%3E");
  background-repeat: repeat-x;
  background-position: 4px 0;
}

.lang-chip {
  position: absolute;
  top: 13px;
  right: 8px;
  display: flex;
  height: 22px;
  border: 2px solid var(--title);
  border-radius: 7px 6px 7px 6px;
  color: var(--title);
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
}

.lang-chip::before {
  content: "";
  position: absolute;
  left: -8px;
  right: -8px;
  top: -11px;
  bottom: -11px;
}

.lang-zh,
.lang-en {
  display: block;
  padding: 0 6px;
}

html[lang^="zh"] .lang-zh,
html[lang="en"] .lang-en {
  background: var(--title);
  color: var(--page);
}

/* 时间钮 + 五钮：悬浮在舞台顶部，一行，整组居中；这一条不接指针，空隙里按下去落在画布上 */
.ctrl {
  position: absolute;
  left: 0;
  right: 0;
  top: 6px;
  z-index: var(--z-float);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  padding: 0 8px;
  pointer-events: none;
  -webkit-transform-origin: 50% 0;
  transform-origin: 50% 0;
}

.ctrl .time-btn,
.ctrl .basic-group {
  pointer-events: auto;
}

.time-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  justify-self: end;
  width: 32px;
  height: 32px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--sage);
  color: var(--ink);
}

.time-btn::before {
  content: "";
  position: absolute;
  left: -6px;
  right: -6px;
  top: -6px;
  bottom: -6px;
}

.basic-group {
  display: flex;
  flex: none;
  border: 2px solid var(--olive);
  border-radius: 10px 9px 10px 9px;
  background: var(--cream);
}

.basic-group .tool {
  position: relative;
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 28px;
  color: var(--ink);
}

.basic-group .tool::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -8px;
  bottom: -8px;
}

.basic-group .tool + .tool {
  border-left: 2px solid var(--olive);
}

.basic-group .tool .icon {
  display: block;
  width: 18px;
  height: 18px;
}

.basic-group .tool .icon svg {
  width: 100%;
  height: 100%;
  stroke-width: 4.6;
}

.basic-group .tool[disabled] {
  opacity: 0.4;
  cursor: default;
}

.tool-label {
  display: none;
}

/* 舞台：标题条下面的整块页面，左右到边、下到底。画布铺满它，纸和纸外面的花都画在画布里；画布本身没有边框，
   显示尺寸 = 绘制尺寸，手指落点和花的位置一一对应。 */
.stage {
  position: relative;
  min-height: 0;
  background: var(--page);
}

.garden {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  border: 0;
  touch-action: none;
}

/* 悬浮工具坞：3 个按钮，居中，贴画布底部。涂鸦块：实心、不描边、每块形状略不一样（照设计稿底栏）。 */
.dock {
  position: absolute;
  left: 50%;
  bottom: 12px;
  z-index: var(--z-float);
  display: flex;
  align-items: flex-end;
  -webkit-transform: translateX(-50%);
  transform: translateX(-50%);
  padding: 8px 10px 7px;
  border: 0;
  border-radius: 24px 18px 26px 16px / 18px 24px 16px 22px;
  background: var(--dock);
}

.dock-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 58px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--on-bar);
}

.dock-btn + .dock-btn {
  margin-left: 6px;
}

.dock-face {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 16px 11px 15px 13px / 12px 15px 11px 16px;
  background: var(--cream);
}

.dock-btn.is-text .dock-face { background: #d9c3a6; border-radius: 13px 15px 11px 16px / 16px 11px 15px 12px; }
.dock-btn.is-water .dock-face { background: var(--sage); border-radius: 14px 12px 17px 11px / 11px 16px 12px 15px; }
.dock-btn.is-shovel .dock-face { background: var(--stone); border-radius: 11px 16px 13px 17px / 15px 12px 16px 11px; }

/* 选中：整块抬起，名字变成一小块奶油底的药丸；不用描边 */
.dock-btn.is-on .dock-face {
  -webkit-transform: translateY(-3px);
  transform: translateY(-3px);
}

.dock-name {
  margin-top: 3px;
  padding: 0 7px;
  border-radius: 9px 7px 9px 7px;
  font-size: 11px;
  line-height: 15px;
  white-space: nowrap;
}

.dock-btn.is-on .dock-name {
  background: var(--cream);
  color: var(--ink);
}

/* 季节：左上角（标题栏里），一个开关，两行字，亮的那行是现在用的；不放在画布上 */
.season {
  position: absolute;
  left: 8px;
  top: 4px;
  z-index: calc(var(--z-float) + 1);
  display: flex;
  flex-direction: column;
  padding: 2px;
  border: 0;
  border-radius: 12px 9px 13px 10px / 10px 13px 9px 12px;
  background: var(--dock);
  color: var(--on-bar);
}

.season::before {
  content: "";
  position: absolute;
  left: -6px;
  right: -6px;
  top: -4px;
  bottom: -4px;
}

.season-opt {
  display: block;
  padding: 0 6px;
  border-radius: 9px 7px 9px 8px / 7px 9px 8px 9px;
  font-size: 11px;
  line-height: 17px;
  white-space: nowrap;
  text-align: center;
}

.season-opt.is-on {
  background: var(--cream);
  color: var(--ink);
}

/* 竖拉条：选中工具后出现在画布一侧，悬浮、实心。轨道、填充、把手都自绘，原生 range 透明叠在上面只接交互。 */
.size-rail {
  position: absolute;
  left: 12px;
  top: 50%;
  -webkit-transform: translateY(-50%);
  transform: translateY(-50%);
  z-index: var(--z-float);
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 42px;
  height: 180px;
  padding: 10px 0 8px;
  border: 0;
  border-radius: 18px 14px 20px 15px / 16px 20px 14px 18px;
  background: var(--dock);
}

.size-rail.is-off {
  display: none;
}

.size-name {
  flex: none;
  color: var(--on-bar);
  font-size: 11px;
  line-height: 13px;
}

.size-track {
  position: relative;
  flex: none;
  width: 14px;
  height: 140px;
  margin-top: 8px;
  border-radius: 7px;
  background: var(--green-deep);
}

.size-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 42%;
  border-radius: 7px;
  background: var(--sage);
}

.size-thumb {
  position: absolute;
  left: 50%;
  bottom: calc(42% - 9px);
  width: 24px;
  height: 18px;
  margin-left: -12px;
  border: 3px solid var(--on-bar);
  border-radius: 9px;
  background: var(--thumb);
}

.size-rail input[type="range"] {
  position: absolute;
  left: -14px;
  top: 0;
  width: 42px;
  height: 100%;
  margin: 0;
  opacity: 0;
  -webkit-appearance: none;
  appearance: none;
  touch-action: none;
  cursor: pointer;
}

/* 时间面板：叠在画布上，在时间钮 + 五钮那一行的下面，右上角小 × */
.time-panel {
  position: absolute;
  z-index: var(--z-popover);
  left: 8px;
  right: 8px;
  top: 52px;
  max-width: 420px;
  margin: 0 auto;
  padding: 10px 14px 10px;
  border: 3px solid var(--olive);
  border-radius: 14px 12px 14px 12px;
  background: var(--surface);
  color: var(--ink);
}

.time-panel .modal-close {
  top: 3px;
  right: 3px;
}

.time-title {
  padding-right: 24px;
  color: var(--title);
  font-size: 14px;
  font-weight: 700;
  line-height: 20px;
}

/* 回弹拉条：轨道上一个居中的按钮，往左是过去、往右是未来，松手回到中间 */
.shuttle {
  position: relative;
  height: 44px;
  touch-action: none;
  cursor: pointer;
}

.shuttle-track {
  position: absolute;
  left: 20px;
  right: 20px;
  top: 50%;
  height: 6px;
  margin-top: -3px;
  border-radius: 3px;
  background: var(--olive);
}

.shuttle-mid {
  position: absolute;
  left: 50%;
  top: -6px;
  width: 4px;
  height: 18px;
  margin-left: -2px;
  border-radius: 2px;
  background: var(--olive);
}

.shuttle-thumb {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  border: 3px solid var(--surface);
  border-radius: 50%;
  background: var(--olive-deep);
  transition: left 0.18s ease-out;
}

.shuttle.is-drag .shuttle-thumb {
  transition: none;
}

.time-ends {
  display: flex;
  justify-content: space-between;
  padding: 0 4px;
  color: var(--ink-2);
  font-size: 12px;
  line-height: 16px;
}

.time-btn.is-past {
  background: var(--plum);
}

/* 图案 */
.art {
  display: block;
  flex: none;
  pointer-events: none;
}

.art-face {
  width: 32px;
  height: 32px;
}

.art-time {
  width: 22px;
  height: 22px;
}

.art-title-flower {
  width: 22px;
  height: 22px;
}

.art-flower {
  width: 56px;
  height: 56px;
}

/* 种子弹窗 */
.seed-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-gap: 8px;
}

.seed-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 44px;
  padding: 8px 4px 6px;
  border-radius: 13px 11px 13px 11px;
  background: transparent;
  color: var(--ink);
}

.seed-tile.is-on {
  background: var(--sage);
}

.seed-name {
  margin-top: 5px;
  font-size: 13px;
  line-height: 16px;
  text-align: center;
}

.seed-check {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--green-deep);
  visibility: hidden;
}

.seed-check::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 2px;
  width: 4px;
  height: 8px;
  border: solid var(--on-bar);
  border-width: 0 2px 2px 0;
  -webkit-transform: rotate(45deg);
  transform: rotate(45deg);
}

.seed-tile.is-on .seed-check {
  visibility: visible;
}

.modal-untitled .modal-body {
  padding-top: calc(var(--gap-3) + 6px);
}

html[lang="en"] .title {
  font-size: 17px;
  letter-spacing: 0;
}

/* 宽屏 / 横屏：同一套悬浮做法，画布不被挤小 */
@media (min-width: 700px) and (orientation: landscape) {
  .title { font-size: 24px; line-height: 32px; }
  .art-title-flower { width: 26px; height: 26px; }
  .dock {
    bottom: 14px;
    padding: 8px 12px 7px;
  }

  .dock-btn { width: 62px; }
  .dock-face { width: 52px; height: 52px; }
  .dock-name { font-size: 12px; }
  .art-face { width: 36px; height: 36px; }

  .size-rail {
    left: 16px;
    height: 220px;
  }

  .size-track { height: 170px; }
}

@media (min-width: 700px) and (orientation: landscape) and (max-height: 520px) {
  .titlebar { padding-top: 4px; }
  .titlebar::after { margin-top: 2px; }
  .lang-chip { top: 6px; }
  .season { top: 2px; }
  .season-opt { line-height: 15px; }
  .title { font-size: 17px; line-height: 24px; }
  .art-title-flower { width: 20px; height: 20px; }
  .ctrl { top: 4px; }

  .dock { bottom: 10px; padding: 6px 9px 5px; }
  .dock-btn { width: 50px; }
  .dock-face { width: 40px; height: 40px; }
  .art-face { width: 28px; height: 28px; }
  .dock-name { font-size: 10px; margin-top: 2px; }
  .size-rail { height: 150px; left: 10px; }
  .size-track { height: 108px; }
}

/* 小屏、平板竖屏微调 */
@media (max-width: 359px) {
  .lang-chip { top: 7px; }
  .titlebar::after { margin-top: 4px; }
  .season { left: 6px; }
  .dock { bottom: 10px; padding: 6px 7px 5px; }
  .dock-btn { width: 46px; }
  .dock-btn + .dock-btn { margin-left: 4px; }
  .dock-face { width: 38px; height: 38px; }
  .art-face { width: 26px; height: 26px; }
  .dock-name { font-size: 10px; }
  .size-rail { height: 150px; left: 8px; width: 38px; }
  .size-track { height: 108px; }
}

@media (min-width: 600px) and (orientation: portrait) {
  .title { font-size: 28px; line-height: 36px; }
  .lang-chip { top: 17px; }
  .art-title-flower { width: 30px; height: 30px; }
  .dock-btn { width: 64px; }
  .dock-face { width: 54px; height: 54px; }
  .art-face { width: 36px; height: 36px; }
}

/* 整页抖动：滤镜挂在整页容器上，容器外的弹窗、悬浮层单独再挂同一个（相位由 boil.js 轮换） */
html[data-boil="0"] #app,
html[data-boil="0"] .modal-overlay,
html[data-boil="0"] .popover {
  -webkit-filter: url(#kk-boil-0);
  filter: url(#kk-boil-0);
}

html[data-boil="1"] #app,
html[data-boil="1"] .modal-overlay,
html[data-boil="1"] .popover {
  -webkit-filter: url(#kk-boil-1);
  filter: url(#kk-boil-1);
}

html[data-boil="2"] #app,
html[data-boil="2"] .modal-overlay,
html[data-boil="2"] .popover {
  -webkit-filter: url(#kk-boil-2);
  filter: url(#kk-boil-2);
}

/* 文字种子：纸上的输入框（字体、字号和纸上的一样，每个字显示它自己的棕色） */
.paper-input,
.paper-input-mirror {
  position: absolute;
  z-index: var(--z-content);
  margin: 0;
  padding: 0;
  border: 2px solid transparent;
  font-weight: 700;
  white-space: pre;
  box-sizing: content-box;
}

.paper-input {
  z-index: calc(var(--z-content) + 1);
  min-width: 2em;
  border-style: dashed;
  border-color: var(--olive);
  background: transparent;
  color: transparent;
  caret-color: var(--thumb);
  resize: none;
  overflow: hidden;
  -webkit-user-select: text;
  user-select: text;
}

.paper-input-mirror {
  pointer-events: none;
}

/* 虚线框的四条边按住拖动移动，右下角的钮拖动缩放；框本身不接指针，只有边和钮接 */
.paper-input-frame {
  position: absolute;
  z-index: calc(var(--z-content) + 2);
  box-sizing: border-box;
  pointer-events: none;
}

.paper-edge {
  position: absolute;
  pointer-events: auto;
  touch-action: none;
  cursor: move;
}

.paper-edge.is-top,
.paper-edge.is-bottom {
  left: 0;
  right: 0;
  height: 18px;
}

.paper-edge.is-top { top: -12px; }
.paper-edge.is-bottom { bottom: -12px; }

.paper-edge.is-left,
.paper-edge.is-right {
  top: 0;
  bottom: 0;
  width: 18px;
}

.paper-edge.is-left { left: -12px; }
.paper-edge.is-right { right: -12px; }

.paper-grip {
  position: absolute;
  right: -14px;
  bottom: -14px;
  width: 26px;
  height: 26px;
  border-radius: 9px 7px 10px 7px / 7px 10px 7px 9px;
  background: var(--olive);
  pointer-events: auto;
  touch-action: none;
  cursor: nwse-resize;
}

.paper-grip::before {
  content: '';
  position: absolute;
  top: -9px;
  right: -9px;
  bottom: -9px;
  left: -9px;
}

.paper-grip::after {
  content: '';
  position: absolute;
  top: 6px;
  right: 6px;
  bottom: 6px;
  left: 6px;
  background-image: linear-gradient(135deg, transparent 44%, var(--on-bar) 44%, var(--on-bar) 56%, transparent 56%);
}

/* 文字设置窗：悬浮、可拖走，一个把手加一排字体（放不下时左右滑动） */
.text-window {
  position: fixed;
  z-index: var(--z-float);
  display: flex;
  align-items: center;
  box-sizing: border-box;
  width: calc(420px * var(--k, 1));
  max-width: calc(100% - 16px);
  padding: calc(4px * var(--k, 1)) calc(8px * var(--k, 1)) calc(4px * var(--k, 1)) calc(2px * var(--k, 1));
  border-radius: 18px 14px 20px 15px / 16px 20px 14px 18px;
  background: var(--dock);
}

.text-window[hidden] {
  display: none;
}

.text-grip {
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: calc(32px * var(--k, 1));
  min-height: calc(44px * var(--k, 1));
  border: 0;
  background: transparent;
  touch-action: none;
  cursor: grab;
}

.text-grip-dots {
  display: block;
  width: calc(12px * var(--k, 1));
  height: calc(20px * var(--k, 1));
  background-image: radial-gradient(circle, var(--on-bar) calc(1.6px * var(--k, 1)), transparent calc(2.2px * var(--k, 1)));
  background-size: calc(6px * var(--k, 1)) calc(7px * var(--k, 1));
}

.text-fonts {
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior: contain;
  touch-action: pan-x;
  scrollbar-width: none;
  clip-path: inset(0);
}

.text-fonts::-webkit-scrollbar {
  display: none;
}

.text-fonts-row {
  display: flex;
  align-items: center;
  width: -webkit-max-content;
  width: max-content;
}

.text-window .chip {
  min-height: calc(36px * var(--k, 1));
  margin-right: calc(6px * var(--k, 1));
  padding: 0 calc(12px * var(--k, 1));
  border: 0;
  border-radius: 13px 11px 14px 11px / 11px 14px 11px 13px;
  background: var(--cream);
  color: var(--ink);
  font-size: calc(14px * var(--k, 1));
}

.text-window .chip.is-on {
  background: var(--sage);
  color: var(--ink);
}

.text-window .chip::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -4px;
  bottom: -4px;
}

.text-window .chip {
  position: relative;
}

.chip-wrap {
  display: inline-flex;
  align-items: center;
  flex: none;
}

.chip-wrap .chip {
  margin-right: 0;
}

.chip-del {
  flex: none;
  width: calc(30px * var(--k, 1));
  height: calc(36px * var(--k, 1));
  margin-right: calc(6px * var(--k, 1));
  border: 0;
  background: transparent;
  color: var(--on-bar);
  font-size: calc(18px * var(--k, 1));
  line-height: calc(36px * var(--k, 1));
}

/* 摆放图片：图的框角上的三个圆钮（✓ 确认、× 取消、旋转缩放） */
.place-knob {
  position: absolute;
  z-index: var(--z-float);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 2px solid var(--olive-deep);
  border-radius: 50%;
  background: var(--cream);
  color: var(--olive-deep);
  touch-action: none;
}

.place-knob[hidden] {
  display: none;
}

.place-knob::before {
  content: '';
  position: absolute;
  top: -8px;
  right: -8px;
  bottom: -8px;
  left: -8px;
  border-radius: 50%;
}

.place-knob .icon,
.place-knob .icon svg {
  display: block;
  width: 16px;
  height: 16px;
}

.place-knob-ok {
  background: var(--olive-deep);
  color: var(--on-bar);
}

.place-knob-rot {
  cursor: grab;
}

/* 摆放图片时：工具坞和竖拉条先收起来，基础钮不能点 */
.stage.is-placing .dock,
.stage.is-placing .size-rail {
  visibility: hidden;
}

.stage.is-placing .ctrl .time-btn,
.stage.is-placing .ctrl .basic-group {
  opacity: 0.45;
  pointer-events: none;
}

/* 导入图片：选「设为画布大小」还是「插入图片」时的预览 */
.import-preview-box {
  display: flex;
  justify-content: center;
}

.modal-x-space + .import-preview-box {
  margin-left: calc(var(--touch) - var(--gap-3));
}

.import-preview {
  max-width: 100%;
  max-height: 46vh;
  width: auto;
  height: auto;
  border-radius: 10px 8px 10px 8px;
}
