/* 项目样式：底栏做成 2000 年前后论坛的样子（方框、纯色、每个按钮一种亮色），海报和标题仍是旋转炫彩。
   没有圆角，没有黑框。页面尺寸全部来自 js/shell/shell.js 写进来的变量：--u --banner --tab --row --fs --fs-s --pad --modal-w。 */

/* 两侧和中间都是白的。 */
html,
body {
  background: #ffffff;
}

:root {
  /* 画图和样式共用的一张色表（art/palette.js 读这里）：大红大紫大绿，纯色。 */
  --c-red: #ff2020;
  --c-orange: #ff8800;
  --c-yellow: #ffee00;
  --c-green: #00c800;
  --c-cyan: #00e0ff;
  --c-blue: #2a2aff;
  --c-purple: #9400d3;
  --c-pink: #ff00cc;
  --c-white: #ffffff;
  --c-black: #111111;
  --c-gray: #3a3a3a;

  /* 覆盖模板的色调：白底、黑边、一个紫色做强调。 */
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #ececec;
  --field: #ffffff;
  --bar: var(--c-purple);
  --disc: #ffffff;
  --ink: #111111;
  --ink-2: #444444;
  --ink-3: #8a8a8a;
  --line: #111111;
  --accent: var(--c-yellow);
  --danger: var(--c-red);
  --on-dark: #ffffff;

  --fs: 14px;
  --fs-s: 14px;
  --text: var(--fs);
  --text-small: var(--fs-s);
  --radius: 0;
  --radius-sm: 0;
  --border-w: 3px;
  --modal-w: 300px;
  --thumb: 46px;
  --pad: 6px;
}

/* ===== 画面框：一列，从上到下是标题、按钮、海报、底栏 ===== */
.mt-frame {
  position: absolute;
  z-index: 2;
  top: 0;
  overflow: hidden;
  background: #ffffff;
}

.mt-page {
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.mt-head {
  position: relative;
  flex: none;
  height: var(--banner);
}

.mt-region {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.mt-stage {
  position: relative;
  flex: none;
}

/* 点在背景上的那句：用标题同一套字（.ug-title / .ug-ch），不占标题条的位置，不盖住中间这一列。 */
.mt-hop.ug-title {
  position: fixed;
  z-index: 1;
  left: auto;
  top: auto;
  right: auto;
  bottom: auto;
  width: max-content;
  height: auto;
  overflow: visible;
  pointer-events: none;
}

.mt-hop .ug-row {
  position: relative;
  left: auto;
  right: auto;
  top: auto;
  bottom: auto;
  height: auto;
}

.mt-hop.ug-title::after {
  content: none;
}

.mt-poster {
  width: 100%;
  height: 100%;
  border: 6px solid var(--c-red);
  border-image: linear-gradient(90deg, #ff2020, #ffee00, #00c800, #2a2aff, #9400d3) 1;
  border-radius: 0;
  background: #ffffff;
  touch-action: none;
}

/* ===== 语言开关：右上角，「中」「EN」两格 ===== */
.mt-lang {
  position: absolute;
  z-index: 3;
  top: 4px;
  right: 6px;
  display: flex;
  height: 22px;
  border: 2px solid var(--c-blue);
  border-radius: 0;
  background: var(--c-yellow);
}

.mt-lang-btn {
  position: relative;
  width: 26px;
  font-size: 12px;
  font-weight: 900;
  line-height: 18px;
  color: var(--ink);
}

.mt-lang-btn + .mt-lang-btn {
  border-left: 2px solid var(--line);
}

.mt-lang-btn:first-child,
.mt-lang-btn:last-child {
  border-radius: 0;
}

.mt-lang-btn[aria-pressed="true"] {
  background: var(--bar);
  color: #ffffff;
}

.mt-lang-btn::after {
  content: "";
  position: absolute;
  left: -3px;
  right: -3px;
  top: -11px;
  bottom: -11px;
}

/* ===== 基础按钮：回退、重做、重新开始、导出 ===== */
.mt-basics {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--basics-pad, 6px) 0 4px;
}

.mt-basics .tool {
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 30px;
  margin: 0 5px;
  border: 3px solid var(--c-blue);
  border-radius: 0;
  background: var(--c-yellow);
  color: #111111;
}

.mt-basics .tool:nth-child(1) {
  background: var(--c-red);
  border-color: #cc0000;
  color: #ffffff;
}

.mt-basics .tool:nth-child(2) {
  background: var(--c-green);
  border-color: #009900;
  color: #111111;
}

.mt-basics .tool:nth-child(3) {
  background: var(--c-cyan);
  border-color: #0099aa;
  color: #111111;
}

.mt-basics .tool:nth-child(4) {
  background: var(--c-purple);
  border-color: #660099;
  color: #ffffff;
}

.mt-basics .tool > * {
  width: 16px;
  height: 16px;
}

.mt-basics .tool::after {
  content: "";
  position: absolute;
  left: -5px;
  right: -5px;
  top: -7px;
  bottom: -7px;
}

.mt-basics .tool:active {
  background: var(--accent);
}

.mt-basics .tool[disabled] {
  border-color: #bdbdbd;
  background: #f4f4f4;
  color: #bdbdbd;
  cursor: default;
}

/* ===== 底栏：第一行是四个标签，第二行是当前页，放不下就左右滑；第二行的高度固定（--pane） ===== */
[hidden] {
  display: none !important;
}

.mt-dock {
  flex: none;
  display: flex;
  flex-direction: column;
  padding: 4px var(--pad) 6px;
  border-top: 4px solid var(--c-blue);
  background: #ffff66;
}

.mt-tabs {
  flex: none;
  height: var(--tab);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}

.mt-tabs::-webkit-scrollbar {
  display: none;
}

.mt-seg {
  display: flex;
}

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

.mt-seg-btn {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: max-content;
  height: 100%;
  padding: 0 8px;
  background: #ffffff;
  color: var(--ink);
  font-size: var(--fs);
  font-weight: 700;
  white-space: nowrap;
}

.mt-seg-btn::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
}

.mt-tabs .mt-seg-btn {
  border: 3px solid transparent;
  border-radius: 0;
}

.mt-tabs .mt-seg-btn:nth-child(1) {
  background: var(--c-red);
  border-color: #cc0000;
  color: #ffffff;
}

.mt-tabs .mt-seg-btn:nth-child(2) {
  background: var(--c-orange);
  border-color: #cc6600;
  color: #111111;
}

.mt-tabs .mt-seg-btn:nth-child(3) {
  background: var(--c-green);
  border-color: #009900;
  color: #111111;
}

.mt-tabs .mt-seg-btn:nth-child(4) {
  background: var(--c-blue);
  border-color: #0000aa;
  color: #ffffff;
}

.mt-tabs .mt-seg-btn[aria-selected="true"] {
  outline: 3px solid #111111;
  outline-offset: -6px;
}

.mt-row {
  position: relative;
  flex: none;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  height: var(--pane);
  margin-top: 4px;
  overflow-y: hidden;
}

.mt-mode {
  flex: none;
  display: flex;
  height: var(--row);
  margin-right: 8px;
}

.mt-mode .mt-seg-btn {
  flex: none;
  height: var(--row);
  min-width: 44px;
  padding: 0 10px;
  border: 3px solid #cc6600;
  border-radius: 0;
  background: var(--c-orange);
  color: #111111;
}

.mt-mode .mt-seg-btn:first-child,
.mt-mode .mt-seg-btn:last-child {
  border-radius: 0;
}

.mt-mode .mt-seg-btn[aria-selected="true"] {
  background: var(--c-pink);
  border-color: #cc0099;
  color: #ffffff;
  outline: 3px solid #111111;
  outline-offset: -6px;
}

.mt-row .chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  min-width: 44px;
  min-height: 0;
  height: var(--row);
  margin: 0 6px 0 0;
  padding: 0 10px;
  border: 3px solid #0099aa;
  border-radius: 0;
  background: var(--c-cyan);
  color: #111111;
  font-size: var(--fs);
  font-weight: 700;
  white-space: nowrap;
}

.mt-row .chip::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
}

.mt-row .chip.is-on,
.mt-pen.is-on,
.mt-anim.is-on {
  outline: 3px solid #111111;
  outline-offset: -6px;
}

/* 加号：和小框一样高的方块。 */
.mt-row .mt-plus {
  position: relative;
  flex: none;
  width: var(--thumb);
  height: var(--thumb);
  min-width: 0;
  min-height: 0;
  margin: 0 8px 0 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border: 3px solid var(--c-green);
}

.mt-plus .mt-ic {
  width: 60%;
  height: 60%;
}

.mt-plus::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
}

/* 一个小框：主体是选中，右上角的 × 是删除。 */
.mt-card {
  position: relative;
  flex: none;
  display: flex;
  margin-right: 8px;
  height: var(--thumb);
}

.mt-img {
  position: relative;
  flex: none;
  width: var(--thumb);
  height: var(--thumb);
  margin: 0;
  padding: 0;
  border: 3px solid var(--c-purple);
  border-radius: 0;
  background: #ffffff;
}

.mt-img canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.mt-row .chip.mt-textface {
  height: var(--thumb);
  margin: 0;
  padding: 0 26px 0 12px;
}

.mt-face.is-on {
  outline: 3px solid #111111;
  outline-offset: -6px;
}

.mt-x {
  position: absolute;
  right: 0;
  top: 0;
  z-index: 1;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: var(--c-red);
  color: #ffffff;
  font-size: 18px;
  font-weight: 900;
  line-height: 22px;
  text-align: center;
}

.mt-x::after {
  content: "";
  position: absolute;
  left: -8px;
  right: 0;
  top: 0;
  bottom: -8px;
}

.mt-deco {
  width: 40px;
  height: 24px;
}

.mt-row .chip.mt-decochip {
  padding: 0 8px;
}

.mt-rect {
  flex: none;
  display: block;
  width: 28px;
  height: 14px;
  margin-right: 6px;
  background: var(--c-red);
}

.mt-pen-mark {
  flex: none;
  width: 34px;
  height: 10px;
  margin-right: 6px;
  border-radius: 5px;
  background: linear-gradient(90deg, var(--c-red), var(--c-orange), var(--c-yellow), var(--c-green), var(--c-cyan), var(--c-blue), var(--c-purple), var(--c-pink));
}

.mt-dice,
.mt-anim {
  position: relative;
  flex: none;
  width: auto;
  min-width: 44px;
  min-height: 0;
  height: var(--row);
  margin: 0 8px 0 0;
  padding: 0 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs);
  font-weight: 700;
  white-space: nowrap;
}

.mt-dice {
  border: 3px solid #cc0099;
  background: var(--c-pink);
  color: #ffffff;
}

.mt-anim {
  margin-left: auto;
  margin-right: 0;
  border: 3px solid #0099aa;
  background: var(--c-cyan);
  color: #111111;
}

.mt-dice-name {
  margin-left: 6px;
}

.mt-dice .mt-ic {
  width: 18px;
  height: 18px;
}

.mt-dice::after,
.mt-anim::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
}

.mt-frame[data-short="1"] .mt-basics {
  padding-top: 2px;
  padding-bottom: 2px;
}

.mt-frame[data-short="1"] .mt-dock {
  padding-top: 2px;
  padding-bottom: 4px;
}

.mt-frame[data-short="1"] .ug-title {
  left: 8px;
  right: 72px;
}

/* ===== 文字设置：选中文字时暂时占掉底栏的两行，高度和平时一样 ===== */
.mt-take {
  flex: none;
  display: flex;
  flex-direction: column;
}

.mt-takeparts {
  flex: none;
  height: var(--tab);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}

.mt-parts .mt-seg-btn {
  border: 3px solid #cc6600;
  border-radius: 0;
  background: var(--c-orange);
  color: #111111;
}

.mt-parts .mt-seg-btn[aria-selected="true"] {
  background: var(--c-pink);
  border-color: #cc0099;
  color: #ffffff;
  outline: 3px solid #111111;
  outline-offset: -6px;
}

.mt-group {
  flex: none;
  display: flex;
  align-items: center;
}

.mt-fontbtn {
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: calc(var(--row) * 1.5);
  height: var(--row);
  margin: 0 6px 0 0;
  padding: 0 8px;
  border: 3px solid var(--c-purple);
  border-radius: 0;
  background: #ffffff;
  color: #111111;
  font-size: calc(var(--row) * 0.5);
  line-height: 1;
  white-space: nowrap;
}

.mt-fontbtn::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
}

.mt-fontbtn[data-font="rand"] {
  font-size: var(--fs);
  font-weight: 700;
}

.mt-fontbtn[disabled] {
  border-color: #bdbdbd;
  color: #8a8a8a;
}

.mt-fontbtn.is-on,
.mt-sw.is-on {
  outline: 3px solid #111111;
  outline-offset: -6px;
}

.mt-sw {
  position: relative;
  flex: none;
  width: var(--row);
  height: var(--row);
  margin: 0 6px 0 0;
  padding: 0;
  border: 3px solid #111111;
  border-radius: 0;
  background: #ffffff;
  color: #111111;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.mt-sw::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
}

.mt-sw[data-sw="rand"],
.mt-sw[data-sw="none"] {
  width: auto;
  min-width: var(--row);
  padding: 0 6px;
}

.mt-sw[data-sw="rainbow"] {
  background: linear-gradient(90deg, var(--c-red), var(--c-orange), var(--c-yellow), var(--c-green), var(--c-blue), var(--c-purple));
}

.mt-sw[data-sw="red"] { background: var(--c-red); }
.mt-sw[data-sw="orange"] { background: var(--c-orange); }
.mt-sw[data-sw="yellow"] { background: var(--c-yellow); }
.mt-sw[data-sw="green"] { background: var(--c-green); }
.mt-sw[data-sw="cyan"] { background: var(--c-cyan); }
.mt-sw[data-sw="blue"] { background: var(--c-blue); }
.mt-sw[data-sw="purple"] { background: var(--c-purple); }
.mt-sw[data-sw="pink"] { background: var(--c-pink); }
.mt-sw[data-sw="white"] { background: var(--c-white); }
.mt-sw[data-sw="black"] { background: var(--c-black); }

.mt-sw.is-on[data-sw="black"],
.mt-sw.is-on[data-sw="purple"],
.mt-sw.is-on[data-sw="blue"] {
  outline-color: #ffffff;
}

/* ===== 海报上的原地输入框：字透明（字画在海报上），光标反色，位置和转角跟着那段字 ===== */
.mt-editor {
  position: absolute;
  z-index: 3;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border: 0;
  outline: 0;
  resize: none;
  overflow: hidden;
  background: transparent;
  color: transparent;
  -webkit-text-fill-color: transparent;
  caret-color: #ffffff;
  mix-blend-mode: difference;
  text-align: center;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  -webkit-user-select: text;
  user-select: text;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.mt-editor::selection {
  background: rgba(255, 255, 255, 0.6);
}

/* 文字的光标和选区画在海报上的字里，输入框只管接键盘：看不见，也不接手指。 */
.mt-editor.is-canvas {
  pointer-events: none;
  caret-color: transparent;
  mix-blend-mode: normal;
}

.mt-editor.is-canvas::selection {
  background: transparent;
}

.mt-hop .ug-ch.is-hidden {
  visibility: hidden;
}

/* ===== 弹窗：统一大小、黑边、白底；按钮沿用模板的位置 ===== */
.modal {
  width: var(--modal-w);
  border: 4px solid var(--c-purple);
  border-radius: 0;
  background: #ffff66;
}

.modal-overlay {
  background: rgba(0, 0, 0, 0.5);
}

.modal-close {
  color: var(--ink);
}

.btn {
  border-radius: 0;
  border: 3px solid #0000aa;
  background: var(--c-cyan);
  color: #111111;
  font-weight: 700;
}

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

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

.btn.is-off,
.btn[disabled] {
  border-color: #bdbdbd;
  background: #f4f4f4;
  color: #8a8a8a;
  opacity: 1;
}

.range::-webkit-slider-thumb {
  background: var(--c-yellow);
}

.range::-moz-range-thumb {
  background: var(--c-yellow);
}

/* ===== 标题：旋转炫彩大字 =====
   一个字一个 .ug-ch，字体、字色、阴影色、歪斜角度和大小各不相同（变量 --c --sh --r --s 由 art/banner.js 写入）。
   data-act 是当前这一幕：pose 停住；spin 逐字旋转；flip 逐字翻转；pulse 逐字放大缩小；swirl 绕圈。
   每一幕里每个字按 --i / --n 错开出场，整行的颜色一直在彩虹里流动。 */
.ug-title {
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
}

.ug-title::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 5px;
  background: linear-gradient(90deg, #ff2020 0, #ff2020 16px, #ffee00 16px, #ffee00 32px, #00c800 32px, #00c800 48px, #2a2aff 48px, #2a2aff 64px, #9400d3 64px, #9400d3 80px);
  background-size: 80px 5px;
}

.ug-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.ug-row {
  position: absolute;
  left: 0;
  right: 0;
  top: var(--banner-top, 0px);
  bottom: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  white-space: nowrap;
  -webkit-animation: ug-hue 4s linear infinite;
  animation: ug-hue 4s linear infinite;
}

.ug-title[data-act="pose"] .ug-row {
  -webkit-animation: none;
  animation: none;
}

.ug-word {
  display: flex;
  align-items: center;
}

.ug-gap {
  width: 0.4em;
}

.ug-ch {
  position: relative;
  display: inline-block;
  font-size: calc(1em * var(--s));
  line-height: 1.1;
  color: var(--c);
  text-shadow: 0.05em 0.05em 0 var(--sh), 0.09em 0.09em 0 var(--sh);
  -webkit-text-stroke: 0.05em #111111;
  paint-order: stroke fill;
  -webkit-transform: rotate(var(--r));
  transform: rotate(var(--r));
}

.ug-ch:nth-child(3n + 1) {
  top: -0.05em;
}

.ug-ch:nth-child(3n) {
  top: 0.06em;
  margin-left: 0.04em;
}

.ug-ch:nth-child(4n) {
  margin-right: 0.05em;
}

.ug-title[data-act="spin"] .ug-ch {
  -webkit-animation: ug-spin 1.5s ease-in-out both;
  animation: ug-spin 1.5s ease-in-out both;
  animation-delay: calc(var(--i) / var(--n) * 1.2s);
}

.ug-title[data-act="flip"] .ug-ch {
  -webkit-animation: ug-flip 1.5s ease-in-out both;
  animation: ug-flip 1.5s ease-in-out both;
  animation-delay: calc(var(--i) / var(--n) * 1.2s);
}

.ug-title[data-act="pulse"] .ug-ch {
  -webkit-animation: ug-pulse 1.2s ease-in-out both;
  animation: ug-pulse 1.2s ease-in-out both;
  animation-delay: calc(var(--i) / var(--n) * 1.4s);
}

.ug-title[data-act="swirl"] .ug-ch {
  -webkit-animation: ug-swirl 1.6s linear both;
  animation: ug-swirl 1.6s linear both;
  animation-delay: calc(var(--i) / var(--n) * 1.2s);
}

@-webkit-keyframes ug-hue {
  to { -webkit-filter: hue-rotate(360deg); filter: hue-rotate(360deg); }
}

@keyframes ug-hue {
  to { -webkit-filter: hue-rotate(360deg); filter: hue-rotate(360deg); }
}

@keyframes ug-spin {
  from { transform: rotate(var(--r)); }
  to { transform: rotate(calc(var(--r) + 720deg)); }
}

@keyframes ug-flip {
  from { transform: rotate(var(--r)) rotateY(0deg); }
  to { transform: rotate(var(--r)) rotateY(720deg); }
}

@keyframes ug-pulse {
  0% { transform: rotate(var(--r)) scale(1); }
  50% { transform: rotate(calc(var(--r) * -2)) scale(1.6); }
  100% { transform: rotate(var(--r)) scale(1); }
}

@keyframes ug-swirl {
  from { transform: rotate(var(--r)) rotate(0deg) translateX(0.25em) rotate(0deg); }
  to { transform: rotate(var(--r)) rotate(360deg) translateX(0.25em) rotate(-360deg); }
}
