/* 融化：黑白灰，以白为主，不和水面的颜色抢。
   所有尺寸用 calc(var(--u) * n)；--u、--btn（圆钮）、--tool（工具钮）、--cell（格子）由壳按窗口算好写进来；基础五钮和中 / EN 是固定像素。 */
:root {
  --desk: #f4f4f4;
  --desk-side: #d5d9dc;
  --paper: #ffffff;
  --paper-edge: #e6e6e6;

  /* 共用部件（弹窗、提示条）跟着这套色 */
  --bg: #f4f4f4;
  --surface: #ffffff;
  --surface-2: #e8e8e8;
  --field: #ffffff;
  --bar: #2b2b2b;
  --disc: #ffffff;
  --ink: #222222;
  --ink-2: #5c5c5c;
  --ink-3: #a0a0a0;
  --line: #3c3c3c;
  --accent: #8c8c8c;
  --danger: #2b2b2b;
  --on-dark: #ffffff;

}

html,
body {
  background-color: var(--desk-side);
  background-image: var(--paper-tex);
}

/* ---------- 画面框 ---------- */
.mt-frame {
  position: absolute;
  top: 0;
  overflow: hidden;
  background-color: var(--desk);
  background-image: var(--paper-tex);
}

.mt-page {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
}

.mt-page[hidden] {
  display: none;
}

.mt-bg {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ---------- 顶栏：标题、中 / EN、基础五钮 ---------- */
.mt-top {
  position: absolute;
  z-index: 4;
  left: 0;
  right: 0;
  top: 0;
  pointer-events: none;
}

.mt-head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 34px;
}

.mt-title {
  display: flex;
  align-items: center;
  margin: 0;
  font-size: calc(var(--u) * 6);
  font-weight: var(--title-weight);
  line-height: 1.2;
  letter-spacing: 0.12em;
  color: var(--ink);
  white-space: nowrap;
}

.mt-title::before,
.mt-title::after {
  content: '';
  display: block;
  width: calc(var(--u) * 3.2);
  height: calc(var(--u) * 0.8);
  border-radius: 999px;
  background: var(--ink-2);
}

.mt-title::before {
  margin-right: calc(var(--u) * 2);
}

.mt-title::after {
  margin-left: calc(var(--u) * 2);
}

@media (max-width: 359px) {
  .mt-title::before,
  .mt-title::after {
    display: none;
  }
}

/* 中 / EN：固定在页面右上角，小而扁的二选一分段钮，平的，没有边框和阴影。 */
.mt-lang {
  display: flex;
  height: 22px;
  border-radius: 11px;
  background: #e4e4e4;
}

.mt-lang-pos {
  position: absolute;
  z-index: 6;
  top: 6px;
  right: 8px;
}

.mt-lang-btn {
  position: relative;
  width: 36px;
  height: 22px;
  padding: 0;
  border-radius: 11px;
  font-size: 12px;
  font-weight: 900;
  line-height: 22px;
  color: var(--ink-2);
  letter-spacing: 0.04em;
}

.mt-lang-btn[aria-pressed='true'] {
  background: #2e2e2e;
  color: var(--on-dark);
}

/* 点击区用透明伪元素扩到 44 像素。 */
.mt-lang-btn::after {
  content: '';
  position: absolute;
  top: -11px;
  bottom: -11px;
  left: 0;
  right: 0;
}

.mt-lang-btn:first-child::after {
  left: -8px;
}

.mt-lang-btn:last-child::after {
  right: -8px;
}

/* ---------- 按钮 ---------- */
.mt-round {
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--btn);
  height: var(--btn);
  border-radius: 50%;
  color: var(--ink);
}

.mt-round.mt-l {
  width: var(--tool);
  height: var(--tool);
}

.mt-round:disabled {
  cursor: default;
}

/* 融化钮选中：四周一圈转动的光芒，和搅拌钮一眼分得开。 */
.mt-tool-sun[aria-pressed='true']::before {
  content: '';
  position: absolute;
  left: -24%;
  top: -24%;
  width: 148%;
  height: 148%;
  border-radius: 50%;
  pointer-events: none;
  background: repeating-conic-gradient(from 0deg, rgba(120, 120, 120, 0.8) 0deg 5deg, rgba(120, 120, 120, 0) 5deg 22.5deg);
  -webkit-mask: radial-gradient(closest-side, transparent 0, transparent 63%, #000 70%, #000 88%, transparent 100%);
  mask: radial-gradient(closest-side, transparent 0, transparent 63%, #000 70%, #000 88%, transparent 100%);
  animation: mt-sun-spin 14s linear infinite;
}

@keyframes mt-sun-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .mt-tool-sun[aria-pressed='true']::before {
    animation: none;
  }
}

/* 基础钮：固定 44 × 30 的扁板，图标 16；整排永远一行，不跟着屏幕放大。没有阴影。 */
.mt-round.mt-plate,
.mt-round.mt-plate:focus {
  width: 44px;
  height: 30px;
  border-radius: 10px;
  box-shadow: none;
}

.mt-round.mt-plate:focus-visible {
  box-shadow: none;
}

.mt-plate::after {
  content: '';
  position: absolute;
  top: -7px;
  bottom: -7px;
  left: -2px;
  right: -2px;
}

.mt-basics {
  display: flex;
  justify-content: center;
  height: 30px;
  margin-top: 4px;
}

.mt-basics .mt-round + .mt-round {
  margin-left: 4px;
}

/* 返回钮只在背景里出现；它藏着时，后面的第一个钮不留左边距。 */
.mt-round.mt-only-bg {
  display: none;
}

.mt-basics .mt-only-bg + .mt-round {
  margin-left: 0;
}

.mt-head,
.mt-basics,
.mt-low,
.mt-tools,
.mt-panel,
.mt-round,
.mt-cell,
.mt-strip {
  pointer-events: auto;
}

.mt-body {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
}

/* ---------- 画框 ---------- */
.mt-mid {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
}

.mt-stagewrap {
  position: absolute;
}

.mt-stage {
  width: 100%;
  height: 100%;
  background: var(--paper);
  touch-action: none;
}

.mt-solid-note {
  position: absolute;
  left: 12px;
  right: 12px;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  text-align: center;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.35;
  pointer-events: none;
}

/* ---------- 底部：搁板 + 工具钮 ---------- */
.mt-low {
  position: absolute;
  z-index: 4;
  left: 0;
  right: 0;
  bottom: 8px;
  pointer-events: none;
}

.mt-shelf {
  display: none;
}

.mt-tools {
  display: flex;
  justify-content: center;
  padding-top: calc(var(--u) * 1.2);
}

.mt-tools .mt-tool-item + .mt-tool-item {
  margin-left: calc(var(--u) * 4.6);
}

.mt-tool-item {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.mt-tool-label {
  margin-top: calc(var(--u) * 0.9);
  padding: 0.12em 0.4em;
  border-radius: 6px;
  background: var(--paper);
  font-size: var(--tool-text);
  font-weight: 700;
  line-height: 1.2;
  color: var(--ink);
  white-space: nowrap;
}

.mt-panel {
  position: relative;
  padding: calc(var(--u) * 2.2) calc(var(--u) * 2.4) calc(var(--u) * 2);
}

.mt-panel-bg {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  border: calc(var(--u) * 0.55) solid var(--line);
  border-radius: calc(var(--u) * 2.2) calc(var(--u) * 2.1) calc(var(--u) * 2.5) calc(var(--u) * 2.2);
  background-color: var(--paper);
  pointer-events: none;
}

.mt-panel-body {
  position: relative;
}

/* 格子条 */
.mt-strip {
  display: block;
  padding-top: calc(var(--u) * 0.6);
  padding-bottom: calc(var(--u) * 0.6);
}

.mt-strip-inner {
  display: flex;
  justify-content: space-between;
  width: 100%;
  padding-left: calc(var(--u) * 0.6);
  padding-right: calc(var(--u) * 0.6);
}

.mt-strip-sep {
  flex: none;
  align-self: stretch;
  width: 2px;
  margin-top: calc(var(--u) * 0.6);
  margin-bottom: calc(var(--u) * 0.6);
  border-radius: 1px;
  background: #cfcfcf;
}

.mt-strip.is-compact .mt-cell-label {
  display: none;
}

.mt-cell {
  position: relative;
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: var(--cell);
}

.mt-face {
  position: relative;
  display: block;
  width: var(--cell);
  height: var(--cell);
}

.mt-cell-label {
  margin-top: calc(var(--u) * 1);
  font-size: var(--cell-text);
  font-weight: 700;
  line-height: 1;
  color: var(--ink-2);
  white-space: nowrap;
}

.mt-cell[aria-selected='true'] .mt-cell-label {
  color: var(--ink);
}

.mt-cell .mt-art {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ---------- 弹窗和提示条：同一套手剪纸片 ---------- */
.modal {
  border: calc(var(--u) * 0.6) solid var(--line);
  border-radius: calc(var(--u) * 1.4);
  background-color: var(--surface);
  background-image: var(--paper-tex);
}

.modal-close {
  top: 3px;
  right: 3px;
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  font-size: 18px;
}

/* 点击区用透明伪元素扩到 44 像素（向弹窗里面扩，不超出弹窗边） */
.modal-close::after {
  content: '';
  position: absolute;
  top: -3px;
  right: -3px;
  bottom: -19px;
  left: -19px;
}

/* 弹窗里的按钮：和圆钮一样，纸色底 + 内侧窄边 + 深色细轮廓；确认钮是炭灰底。 */
.btn {
  border: calc(var(--u) * 0.6) solid var(--line);
  border-radius: calc(var(--u) * 1.6);
  background: var(--paper);
  color: var(--ink);
}

.btn-primary {
  background: var(--bar);
  border-color: #111111;
  color: var(--on-dark);
}

.btn-danger {
  background: var(--danger);
  border-color: #111111;
  color: #ffffff;
}

.toast {
  border-radius: calc(var(--u) * 1.4);
}

.is-boiling .modal {
  filter: url(#boil-soft);
}

.is-boiling .boil {
  filter: url(#boil);
}

.is-boiling .boil-soft {
  filter: url(#boil-soft);
}

.is-tall .mt-top {
  top: 6px;
}

.is-tall .mt-low {
  bottom: 10px;
}

/* 竖屏：水量和稀稠并排，面板矮一点，把高度让给画框；各标签页一样高，切换时画框不跳。 */
.is-tall .mt-pane-water {
  flex-direction: row;
}

.is-tall .mt-panel {
  padding-top: calc(var(--u) * 1.2);
  padding-bottom: calc(var(--u) * 1);
}

/* ---------- 水池：工具钮藏起来，基础钮是返回、回退、重做、重新开始（竖屏靠左），面板浮在底部 ---------- */
.is-bg .mt-round.mt-only-bg {
  display: flex;
}

.is-bg .mt-round[data-role='export'] {
  display: none;
}

.is-bg .mt-basics .mt-only-bg + .mt-round {
  margin-left: 4px;
}

/* 水池里：返回单独靠左，回退、重做、重新开始三个钮居中 */
.is-tall .is-bg .mt-basics {
  position: relative;
}

.is-tall .is-bg .mt-basics .mt-only-bg {
  position: absolute;
  left: 8px;
  top: 0;
}

.is-tall .is-bg .mt-basics .mt-only-bg + .mt-round {
  margin-left: 0;
}

.is-bg .mt-tools,
.is-bg .mt-shelf {
  visibility: hidden;
}

.mt-bgpanel {
  position: absolute;
  z-index: 5;
  left: 8px;
  right: 8px;
  bottom: 6px;
  max-width: 440px;
  margin-left: auto;
  margin-right: auto;
  padding-top: calc(var(--u) * 0.8);
  padding-bottom: calc(var(--u) * 0.7);
}

.mt-bgpanel .mt-strip {
  padding-top: calc(var(--u) * 0.3);
  padding-bottom: calc(var(--u) * 0.2);
}

.mt-bgpanel .mt-cell-label {
  margin-top: calc(var(--u) * 0.5);
}

.mt-strip-tints .mt-strip-inner {
  justify-content: flex-start;
}

.mt-strip-tints .mt-cell + .mt-cell,
.mt-strip-tints .mt-strip-sep + .mt-cell {
  margin-left: 4px;
}

.mt-strip-tints .mt-strip-sep {
  margin-left: auto;
}

.mt-bgtabs {
  display: flex;
  margin-bottom: calc(var(--u) * 0.5);
}

.mt-bgtab {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  min-height: var(--tabh);
  padding-top: 0;
  padding-bottom: 0;
  border-radius: calc(var(--u) * 1.4);
  background: #e4e4e4;
  color: var(--ink-2);
  font-size: calc(var(--u) * 3.3);
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  pointer-events: auto;
}

.mt-bgtab + .mt-bgtab {
  margin-left: 4px;
}

.mt-bgtab[aria-selected='true'] {
  background: #2e2e2e;
  color: #ffffff;
}

/* 各页叠在同一格里，只显示当前页：切页时面板大小不变 */
.mt-bgpanes {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.mt-bgpane {
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  visibility: hidden;
}

.mt-bgpane.is-on {
  visibility: visible;
}

/* 自定义：圆形色钮铺满格子；还没选过颜色时中间是加号。 */
.mt-cell-custom .mt-face {
  display: flex;
  align-items: center;
  justify-content: center;
}

.mt-cell-custom .color-button {
  width: 76%;
  height: 76%;
  border-style: solid;
  border-width: calc(var(--u) * 0.55);
  background: #f2f2f2;
}

.mt-cell-custom .color-button.is-empty::before,
.mt-cell-custom .color-button.is-empty::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  background: var(--ink-2);
  border-radius: 999px;
}

.mt-cell-custom .color-button.is-empty::before {
  width: 40%;
  height: calc(var(--u) * 0.8);
  transform: translate(-50%, -50%);
}

.mt-cell-custom .color-button.is-empty::after {
  width: calc(var(--u) * 0.8);
  height: 40%;
  transform: translate(-50%, -50%);
}

.mt-cell-custom[aria-selected='true'] .color-button {
  border-width: calc(var(--u) * 1.1);
}

.mt-cell-custom[aria-selected='true'] .mt-cell-label {
  color: var(--ink);
}
/* ---------- 摆放图片：浮在水面上方，确认后才放进水里 ---------- */
.mt-place {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 3;
  width: 100%;
  height: 100%;
  touch-action: none;
}

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

.mt-place-cv {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.mt-knob {
  position: absolute;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 2px solid #2e2e2e;
  border-radius: 50%;
  background: #ffffff;
  color: #2e2e2e;
  touch-action: none;
  pointer-events: auto;
}

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

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

.mt-knob-ok {
  background: #2e2e2e;
  color: #ffffff;
}
