/* 碎玻璃板：偏橙的陶土做主色，背景是一整片很细的彩色玻璃碎片；玻璃板是透的；按钮是平底的奶白、有一圈清楚的深色边，选中是深李紫，没有阴影。
   按钮尺寸是固定像素（上排四钮 44 × 30、图标 17；底部刀、手、图片 56 × 44），不跟着屏幕放大；排版用 --u（一列宽的百分之一），
   --banh（标题条高）由壳按窗口算好写进来。四钮和底部工具浮在玻璃板上，不另占一条。
   按钮、纸条、弹窗都是页面元素：底色和字色成对写，强制深色时一起反相；背景碎片和玻璃板是画布，不受影响。 */
:root {
  --base: #b95a42;
  --side: #a24a35;
  --paper: #fff6ea;
  --paper-edge: #f0dfc9;
  --paper-line: #d9bfa4;
  --title: #8e2f4a;

  --btn: #fff4e6;
  --btn-2: #f6e4d4;
  --btn-edge: #a8826f;
  --btn-ink: #4a2f63;
  --sel: #4a2f63;
  --sel-ink: #fff6ea;

  /* 共用部件（弹窗、提示条）跟着这套色 */
  --bg: #a24a35;
  --surface: #fff6ea;
  --surface-2: #f0dfc9;
  --field: #fffaf3;
  --bar: #4a2f63;
  --ink: #3a2450;
  --ink-2: #6a4f7e;
  --ink-3: #a58aa6;
  --line: #c9a58e;
  --accent: #ee9ba2;
  --danger: #b3304f;
  --on-dark: #fff6ea;
  --toast-top: calc(var(--banh) + 24px);
}

html,
body {
  background-color: var(--side);
  background-image: var(--grain);
}

/* ---------- 画面框：铺满窗口，背景碎片是画布 ---------- */
.mt-frame {
  position: absolute;
  left: 0;
  top: 0;
  background-color: var(--base);
}

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

/* 内容永远是居中的一列（位置和宽度由壳写进 left / width） */
.mt-page {
  position: absolute;
  top: 0;
  height: 100%;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  padding: calc(8px + env(safe-area-inset-top)) 12px calc(10px + env(safe-area-inset-bottom));
}

.is-short .mt-page {
  padding-top: calc(6px + env(safe-area-inset-top));
  padding-bottom: calc(6px + env(safe-area-inset-bottom));
}

/* ---------- 标题条（白纸，左右各让出 66 像素，免得压到右上角的中 / EN）---------- */
.mt-head {
  position: relative;
  flex: none;
  display: flex;
  justify-content: center;
  padding: 0 66px;
}

.mt-banner {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--banh);
}

.mt-banner-bg {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  border: 2px solid var(--paper-line);
  border-radius: 11px 12px 10px 12px;
  background-color: var(--paper);
  -webkit-transform: rotate(-0.6deg);
  transform: rotate(-0.6deg);
}

.mt-title {
  position: relative;
  margin: 0;
  font-size: calc(var(--u) * 5.4);
  font-weight: var(--title-weight);
  line-height: 1;
  letter-spacing: 0.06em;
  text-align: center;
  color: var(--title);
  white-space: nowrap;
}

html[lang='en'] .mt-title {
  font-size: calc(var(--u) * 4.2);
  letter-spacing: 0.02em;
}

/* ---------- 中 / EN：在居中这一列的右上角，不贴窗口边。看得见 60 × 24，点击区向外扩 ---------- */
.mt-lang {
  position: absolute;
  z-index: 5;
  pointer-events: auto;
  top: calc(8px + env(safe-area-inset-top));
  right: 16px;
  display: flex;
}

.mt-lang-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 24px;
  padding: 0;
}

.mt-lang-btn::after {
  content: '';
  position: absolute;
  top: -8px;
  bottom: -12px;
  left: 0;
  right: 0;
}

.mt-lang-btn.is-first::after {
  left: -14px;
}

.mt-lang-btn.is-last::after {
  right: -14px;
}

.mt-lang-face {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border: 2px solid var(--btn-edge);
  background: var(--btn);
  color: var(--btn-ink);
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}

.mt-lang-btn.is-first .mt-lang-face {
  border-radius: 12px 0 0 12px;
}

.mt-lang-btn.is-last .mt-lang-face {
  border-left-width: 0;
  border-radius: 0 12px 12px 0;
}

.mt-lang-btn[aria-pressed='true'] .mt-lang-face {
  border-color: var(--sel);
  background: var(--sel);
  color: var(--sel-ink);
}

/* ---------- 音效开关：这一列的左上角，和中 / EN 同高同款，亮着是开 ---------- */
.mt-sound {
  position: absolute;
  z-index: 5;
  pointer-events: auto;
  top: calc(8px + env(safe-area-inset-top));
  left: 16px;
  display: flex;
}

.mt-sound .mt-lang-btn {
  width: 44px;
}

.mt-sound .mt-lang-btn::after {
  left: -14px;
  right: -8px;
}

.mt-sound .mt-lang-face {
  border-radius: 12px;
}

/* ---------- 上排四钮：一排居中，每个 44 × 30、图标 17、平底、有清楚的边、没有阴影 ---------- */
.mt-round {
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 30px;
  padding: 0;
  border: 2px solid var(--btn-edge);
  border-radius: 9px;
  background: var(--btn);
  color: var(--btn-ink);
}

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

.mt-round .icon {
  display: block;
  width: 17px;
  height: 17px;
}

.mt-round .icon svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* 不能点（没有操作记录的回退 / 重做）：底和字都变淡，边还看得清 */
.mt-round:disabled {
  border-color: var(--paper-line);
  background: var(--btn-2);
  color: var(--ink-3);
  cursor: default;
}

/* 四钮浮在玻璃板上面，不占一列的高度 */
.mt-basics {
  position: absolute;
  z-index: 4;
  left: 0;
  right: 0;
  top: calc(8px + env(safe-area-inset-top) + var(--banh) + 16px);
  display: flex;
  justify-content: center;
  margin-top: 0;
  pointer-events: none;
}

.mt-basics .mt-round {
  pointer-events: auto;
  box-shadow: none;
}

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

.is-short .mt-basics {
  top: calc(6px + env(safe-area-inset-top) + var(--banh) + 20px);
}

/* ---------- 玻璃板：画布铺满窗口，在页面下面接指针；页面本身不挡指针，只有按钮和工具接 ---------- */
.mt-field {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.mt-mid {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  margin: 0 -6px;
}

.mt-stagewrap {
  position: absolute;
  pointer-events: none;
}

/* ---------- 底部工具：浮在玻璃板上，方的，不占一列高度 ---------- */
.mt-low {
  position: absolute;
  z-index: 4;
  left: 0;
  right: 0;
  bottom: calc(8px + env(safe-area-inset-bottom));
  display: flex;
  justify-content: center;
  margin: 0;
  pointer-events: none;
}

.is-short .mt-low {
  bottom: calc(6px + env(safe-area-inset-bottom));
}

.mt-dock {
  display: flex;
  align-items: center;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  pointer-events: auto;
}

/* 刀、手、图片：56 × 44，直角。平时底色是 --btn、边是 --btn-edge；选中底和边换成 --sel。没有阴影。 */
.mt-tool {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 56px;
  height: 44px;
  padding: 0;
  border: 2px solid var(--btn-edge);
  border-radius: 0;
  background: var(--btn);
  color: var(--btn-ink);
  box-shadow: none;
  overflow: hidden;
}

.mt-tool + .mt-tool {
  margin-left: 8px;
}

.mt-tool[aria-pressed='true'],
.mt-tool:active {
  border-color: var(--sel);
  background: var(--sel);
  color: var(--sel-ink);
}

.mt-tool .mt-art {
  position: absolute;
  left: 3px;
  top: 2px;
  width: calc(100% - 6px);
  height: calc(100% - 4px);
  pointer-events: none;
}

.mt-tool .icon {
  position: relative;
  z-index: 1;
  flex: none;
  width: 28px;
  height: 28px;
  pointer-events: none;
}

.mt-tool .icon svg {
  display: block;
  width: 28px;
  height: 28px;
}

.mt-tool[aria-pressed='true'] .mt-art {
  left: 4px;
  top: 3px;
  width: calc(100% - 8px);
  height: calc(100% - 6px);
}

/* ---------- 图库弹窗：两个标签页叠在同一块，点图开或关 ---------- */
.mt-gbody {
  display: flex;
  flex-direction: column;
}

.mt-gtabs {
  display: flex;
  flex: none;
  margin-bottom: 8px;
}

.mt-gtab {
  flex: 1 1 0;
  min-height: 36px;
  padding: 4px 6px;
  border: 2px solid var(--btn-edge);
  border-radius: 0;
  background: var(--btn);
  color: var(--btn-ink);
  font-size: 14px;
  font-weight: 900;
  line-height: 1.2;
  box-shadow: none;
}

.mt-gtab + .mt-gtab {
  margin-left: 6px;
}

.mt-gtab[aria-selected='true'] {
  border-color: var(--sel);
  background: var(--sel);
  color: var(--sel-ink);
}

html[lang='en'] .mt-gtab {
  font-size: 13px;
}

.mt-glib {
  display: grid;
}

.mt-glib-page {
  grid-area: 1 / 1;
  visibility: hidden;
  pointer-events: none;
}

.mt-glib-page.is-on {
  visibility: visible;
  pointer-events: auto;
}

.modal-gallery {
  width: auto;
  max-width: 100%;
}

.mt-ggrid {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  align-items: flex-start;
}

.mt-gcell {
  position: relative;
  flex: none;
  width: 92px;
  height: 72px;
}

.mt-gtile {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 2px solid var(--paper-line);
  border-radius: 0;
  background-color: var(--surface-2);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  box-shadow: none;
}

.mt-gtile[aria-pressed='true'] {
  border-color: var(--sel);
}

.mt-gtile.is-off::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 246, 234, 0.6);
}

.mt-gplus {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 2px solid var(--btn-edge);
  border-radius: 0;
  background: var(--btn);
  color: var(--ink);
  box-shadow: none;
}

.mt-gplus .icon {
  width: 28px;
  height: 28px;
}

.mt-gplus:active {
  border-color: var(--sel);
  background: var(--sel);
  color: var(--sel-ink);
}

.mt-gdel {
  position: absolute;
  z-index: 2;
  top: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: rgba(255, 246, 234, 0.92);
  color: var(--danger);
  box-shadow: none;
}

.mt-gdel .icon {
  width: 12px;
  height: 12px;
}

.mt-gdel::after {
  content: '';
  position: absolute;
  left: -11px;
  top: -2px;
  right: -2px;
  bottom: -20px;
}

.mt-pin {
  position: absolute;
  z-index: 1;
  left: 2px;
  top: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: rgba(255, 246, 234, 0.88);
}

.mt-pin::after {
  content: '';
  position: absolute;
  left: -8px;
  top: -4px;
  right: -8px;
  bottom: -12px;
}

.mt-pin .mt-pin-art {
  display: block;
  width: 22px;
  height: 22px;
}


/* ---------- 弹窗：导出、确认 ---------- */
.modal {
  border: 2px solid var(--line);
  border-radius: 14px;
  background-color: var(--surface);
}

/* 标题在条里左右、上下都居中；标题行不为右上角的 × 留位（× 绝对定位在面板角上）。 */
.modal-head {
  justify-content: center;
  padding: calc(var(--u) * 2) 12px;
  border-bottom: 0;
}

.modal-title {
  flex: 0 1 auto;
  text-align: center;
  font-weight: 900;
  color: var(--ink);
}

/* 关闭：面板角上的小 ×（视觉框 20 像素、字形 18 像素、没有底色和边框；离面板右上角约 6 像素：弹窗边框 2 像素 + 这里的 4 像素），
   点击区是 ui.css 里的伪元素，向左下扩到 44 像素。 */
.modal-close {
  --close-off: 4px;
  top: var(--close-off);
  right: var(--close-off);
  color: var(--ink-2);
}

/* 点击区：伪元素只到弹窗内边距框的边（再往外点不到），向左下扩到总共 44 像素。 */
.modal-close::before {
  top: calc(var(--close-off) * -1);
  right: calc(var(--close-off) * -1);
  left: calc(var(--close-off) - 24px);
  bottom: calc(var(--close-off) - 24px);
}

/* 没有标题的弹窗：第一块是文字（问题、素材来源、小标题）时，× 和它在同一行，只在它右侧让出 × 的宽度；
   第一块是预览、按钮排、进度条这类整行的东西时，才往下让出 × 的高度。 */
.modal-untitled .modal-body > .modal-text:first-child,
.modal-untitled .modal-body > .export-sources:first-child,
.modal-untitled .modal-stack > .modal-text:first-child,
.modal-untitled .modal-stack > .export-sources:first-child {
  padding-right: 28px;
}

.modal-untitled .modal-body > :first-child:not(.modal-stack):not(.modal-text):not(.export-sources),
.modal-untitled .modal-stack > :first-child:not(.modal-text):not(.export-sources) {
  margin-top: 22px;
}

.modal-body {
  padding: calc(var(--u) * 1.4) calc(var(--u) * 3) calc(var(--u) * 3);
}

/* 弹窗里的按钮：和主页的钮一样平底、有清楚的边、没有阴影；确认钮是深李紫底。 */
.btn {
  border: 2px solid var(--btn-edge);
  border-radius: 10px;
  background: var(--btn);
  color: var(--ink);
}

.btn-primary {
  border-color: var(--sel);
  background: var(--sel);
  color: var(--sel-ink);
}

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

.toast {
  border-radius: 10px;
}

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

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

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