:root {
  --orange: #fe6201;
  --cream: #f4efe6;
  --ink: #1a0d08;
  --muted: rgba(244, 239, 230, 0.55);
  --dialogue-cq: 2.25cqh;
  --hist-cq: 2.05cqh;
}
* { box-sizing: border-box; }
html, body {
  height: 100%;
  margin: 0;
  background: #fff;
  color: #1a120c;
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif;
  overflow: hidden;
  transition: background-color 0.72s ease;
}
button, textarea, input, select { font-family: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
body { display: grid; place-items: center; }
.stage {
  position: relative;
  aspect-ratio: 2752 / 1536;
  width: min(100vw, calc(100vh * 2752 / 1536));
  height: min(100vh, calc(100vw * 1536 / 2752));
  container-type: size;
  overflow: hidden;
  background: #fff;
  transition: background-color 0.72s ease;
}

/* ===== 4-Stage Boot Animation (Scheme A: Center Keke+Hearts -> Room Bloom+Zoom -> Glide Top-Left -> UI Stagger) ===== */
body.boot-dark,
body.boot-dark .stage {
  background: #0f0b09;
}
body.boot-active .room-viewport {
  contain: none;
  z-index: 60;
  transform-origin: center center;
  will-change: transform, opacity;
}
body.boot-init .room-viewport {
  opacity: 0;
}
body.boot-hide-ui .winbar,
body.boot-hide-ui .room-meta,
body.boot-hide-ui .room-controls,
body.boot-hide-ui .cmd-dock,
body.boot-hide-ui .portrait-slot,
body.boot-hide-ui .live-actions,
body.boot-hide-ui .column,
body.boot-hide-ui .log,
body.boot-hide-ui .output-zone,
body.boot-hide-ui .composer {
  opacity: 0;
  pointer-events: none;
}
body.boot-hide-ui .room-meta,
body.boot-hide-ui .room-controls,
body.boot-hide-ui .cmd-dock,
body.boot-hide-ui .portrait-slot,
body.boot-hide-ui .live-actions,
body.boot-hide-ui .column,
body.boot-hide-ui .log,
body.boot-hide-ui .output-zone,
body.boot-hide-ui .composer {
  transform: translateY(10px);
}
body.boot-reveal .winbar,
body.boot-reveal .room-meta,
body.boot-reveal .room-controls,
body.boot-reveal .cmd-dock,
body.boot-reveal .portrait-slot,
body.boot-reveal .live-actions,
body.boot-reveal .column,
body.boot-reveal .log,
body.boot-reveal .output-zone,
body.boot-reveal .composer {
  transition:
    opacity 0.54s cubic-bezier(.2, .85, .3, 1),
    transform 0.56s cubic-bezier(.2, .85, .3, 1);
}
body.boot-reveal .room-meta,
body.boot-reveal .room-controls { transition-delay: 0ms; }
body.boot-reveal .cmd-dock { transition-delay: 60ms; }
body.boot-reveal .portrait-slot { transition-delay: 100ms; }
body.boot-reveal .live-actions { transition-delay: 140ms; }
body.boot-reveal .column,
body.boot-reveal .log,
body.boot-reveal .output-zone,
body.boot-reveal .composer { transition-delay: 120ms; }
body.boot-reveal .winbar { transition-delay: 100ms; }

.boot-skip {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 3.4vh;
  background: transparent;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}
body.boot-active .boot-skip {
  opacity: 1;
  pointer-events: auto;
}
body.boot-reveal .boot-skip {
  opacity: 0;
  pointer-events: none;
}
.boot-skip span {
  font-family: Consolas, "Microsoft YaHei UI", monospace;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: rgba(255, 244, 226, 0.42);
  padding: 5px 14px;
  border: 1px solid rgba(254, 98, 1, 0.28);
  background: rgba(15, 11, 9, 0.55);
  user-select: none;
}
body:not(.boot-dark) .boot-skip span {
  color: rgba(20, 16, 13, 0.45);
  background: rgba(255, 255, 255, 0.72);
}
.stage.size-s { --dialogue-cq: 1.9cqh; --hist-cq: 1.75cqh; }
.stage.size-m { --dialogue-cq: 2.25cqh; --hist-cq: 2.05cqh; }
.stage.size-l { --dialogue-cq: 2.7cqh; --hist-cq: 2.4cqh; }
.plate { display: none; }
.crest {
  position: absolute;
  left: 1.6%;
  bottom: 4.8%;
  width: 6.2%;
  aspect-ratio: 1;
  height: auto;
  z-index: 30;
  padding: 0;
  background: none;
}
.crest img { width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none; }
.crest:hover, .crest:focus, .crest.on { outline: none; box-shadow: none; }

.orbit {
  position: absolute;
  left: 4.7%;
  bottom: 10.35%;
  width: 0;
  height: 0;
  z-index: 32;
  --fan-r: 12.6cqh;
}
.orbit.sub {
  left: 4.7%;
  bottom: 10.35%;
  --sub-step: 7.4cqh;
}
#fan > .seal:nth-child(1) { --a: -90deg; }
#fan > .seal:nth-child(2) { --a: -45deg; }
#fan > .seal:nth-child(3) { --a: 0deg; }
#subfan > .seal:nth-child(1) { --i: 1; }
#subfan > .seal:nth-child(2) { --i: 2; }
#subfan > .seal:nth-child(3) { --i: 3; }
#subfan > .seal:nth-child(4) { --i: 4; }
.seal {
  position: absolute;
  left: 0;
  top: 0;
  width: 5.8cqh;
  margin-left: -2.9cqh;
  margin-top: -3.2cqh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15cqh;
  color: #1a120c;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.9);
  font-weight: 800;
  font-size: 1.15cqh;
  letter-spacing: 0.08em;
  white-space: nowrap;
  background: none;
  transform-origin: center center;
  transform: translate(0, 0) scale(.4);
  opacity: 0;
  pointer-events: none;
  transition: transform .42s cubic-bezier(.2, .8, .2, 1), opacity .2s ease;
}
.orbit.open > .seal {
  opacity: 1;
  pointer-events: auto;
  transform: translate(calc(var(--fan-r) * cos(var(--a))), calc(var(--fan-r) * sin(var(--a)))) scale(1);
}
.orbit.sub > .seal {
  width: 5.2cqh;
  margin-left: -2.6cqh;
  margin-top: -2.9cqh;
  font-size: 1.08cqh;
  transform: translate(0, 0) scale(.4);
}
.orbit.sub.open > .seal {
  transform: translate(calc(var(--fan-r) + var(--sub-step) * var(--i)), 0) scale(1);
}
.seal svg { width: 5.8cqh; height: 5.8cqh; display: block; filter: drop-shadow(0 2px 0 #000); }
.orbit.sub .seal svg { width: 5.2cqh; height: 5.2cqh; }
.seal-edge { fill: #d9d4cc; }
.seal-fill { fill: #17191c; }
.seal:hover .seal-fill, .seal.on .seal-fill { fill: #fe6201; }
.seal:hover, .seal.on { color: #fe6201; }
.seal:hover .seal-edge, .seal.on .seal-edge { fill: #fff; }

.fan-page {
  position: absolute;
  left: 26%;
  top: 14%;
  width: min(32vw, 440px);
  max-height: 62%;
  z-index: 28;
  overflow: auto;
  padding: 1.4cqh 1.4cqw 1.6cqh;
  background: #140e0b;
  color: var(--cream);
  border: 3px solid #fe6201;
  box-shadow: 8px 8px 0 #7a2e00;
  transform-origin: 0 0;
  transform: rotate(-68deg) scale(.42);
  opacity: 0;
  pointer-events: none;
  transition: transform .48s cubic-bezier(.2, .85, .2, 1), opacity .32s ease;
}
.fan-page.show {
  transform: rotate(0deg) scale(1);
  opacity: 1;
  pointer-events: auto;
}
.fan-page h2 { margin: 0 0 1cqh; color: #fe6201; font-size: 2cqh; letter-spacing: 0.16em; }
.fan-page h3 { margin: 1cqh 0 0.4cqh; color: #fe6201; font-size: 1.5cqh; letter-spacing: 0.12em; }
.fan-page .x {
  position: sticky;
  top: 0;
  float: right;
  color: #fe6201;
  font-size: 2.2cqh;
  font-weight: 900;
}
.sheet { display: none; }
.sheet.open { display: block; }
.mode-opts, .seg { display: flex; flex-direction: column; }
.mode-opts button, .seg button, .ghost, .danger {
  text-align: left;
  font-weight: 800;
  letter-spacing: 0.12em;
  padding: 0.7cqh 1cqw;
  color: var(--cream);
  border-bottom: 1px solid rgba(244,239,230,.16);
}
.mode-opts button[aria-selected="true"], .seg button[aria-pressed="true"] {
  background: #fe6201;
  color: #111;
}
.ghost, .danger {
  margin-top: 1cqh;
  border: 2px solid var(--cream);
  clip-path: polygon(4% 0, 100% 0, 96% 100%, 0 100%);
}
.field { display: grid; gap: 0.35cqh; margin: 0.8cqh 0; font-weight: 700; }
.field input, .field select {
  border: 1px solid rgba(244,239,230,.25);
  background: #1b1613;
  color: var(--cream);
  padding: 0.45cqh 0.7cqw;
}
.note { color: var(--muted); font-size: 1.4cqh; line-height: 1.45; }
.save-row { display: flex; justify-content: space-between; gap: 1cqw; }
.content.empty { color: var(--muted); }

.desk {
  position: absolute;
  left: 1.6%;
  right: 1.6%;
  top: 2.2%;
  bottom: 2.6%;
  z-index: 4;
  display: grid;
  grid-template-columns: minmax(0, 35%) minmax(0, 1fr);
  gap: 1.8%;
  pointer-events: none;
}
.desk > * { pointer-events: auto; min-height: 0; min-width: 0; }
.left-col {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  gap: 1.2cqh;
  pointer-events: none;
}
.left-col > * { pointer-events: auto; }
.room-panel {
  flex: 0 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
}
.room-box {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.9cqh;
  width: 100%;
}
.room-viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 1.24 / 1;
  max-height: 49cqh;
  display: flex;
  align-items: center;
  justify-content: center;
  contain: layout paint;
}
.room-canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  will-change: contents;
}
.room-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6cqw;
  padding: 0 0.2cqw;
  flex: 0 0 auto;
}
.room-head {
  display: flex;
  align-items: center;
  gap: 0.45cqw;
  flex: 0 0 auto;
}
.room-dot {
  width: 0.9cqh;
  height: 0.9cqh;
  background: #fe6201;
  border: 2px solid #1a120c;
  flex: 0 0 auto;
}
.room-dot.sleeping { background: #5a6ea8; }
.room-dot.working { background: #fe6201; animation: pulse 1.1s ease-in-out infinite; }
.room-dot.reading { background: #2c8a57; animation: pulse 1.2s ease-in-out infinite; }
.room-status {
  font-size: 1.5cqh;
  font-weight: 800;
  color: #1a120c;
  letter-spacing: 0.05em;
  background: #fff;
  border: 2px solid #1a120c;
  padding: 0.22cqh 0.65cqw;
  box-shadow: 2px 2px 0 #1a120c;
}
.room-controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5cqw;
  flex: 0 0 auto;
}
.room-controls button {
  background: #fff;
  color: #1a120c;
  border: 2px solid #1a120c;
  box-shadow: 2px 2px 0 #1a120c;
  font-size: 1.45cqh;
  font-weight: 800;
  padding: 0.52cqh 0.2cqw;
  letter-spacing: 0.06em;
  transition: transform .08s ease, background .12s ease;
}
.room-controls button:hover {
  background: #fff2e6;
  transform: translate(-1px, -1px);
}
.room-controls button.on {
  background: #fe6201;
  color: #1a0d08;
}
.room-tip {
  margin: 0;
  text-align: right;
  font-size: 1.3cqh;
  font-weight: 700;
  color: rgba(26, 18, 12, 0.58);
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.left-bottom {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  pointer-events: none;
}

/* Left Vertical P5 Command Dock: fills bottom-left whitespace evenly with direct 1-click access */
.cmd-dock {
  position: absolute;
  left: 0;
  width: 33%;
  top: 5.5%;
  bottom: 1.5%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1.6cqh;
  pointer-events: auto;
}
.cmd-wrap {
  position: relative;
  flex: 1 1 0;
  display: flex;
  align-items: stretch;
}
.cmd-shadow {
  position: absolute;
  inset: 0;
  background: #14100d;
  pointer-events: none;
  transition: transform 0.16s cubic-bezier(.2, .9, .3, 1.15), background 0.14s ease;
}
.cmd-btn {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  padding: 2.5px 2.5px 2.5px 6px;
  background: #14100d;
  color: #14100d;
  border: 0;
  display: flex;
  align-items: stretch;
  transition: transform 0.16s cubic-bezier(.2, .9, .3, 1.15);
}
.cmd-face {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 0.7cqw;
  padding: 0 0.85cqw 0 0.7cqw;
  background: #fff;
  color: #14100d;
  overflow: hidden;
  transition: background 0.14s ease, color 0.14s ease;
}
.cmd-face::after {
  content: "";
  position: absolute;
  top: -20%;
  bottom: -20%;
  left: -45%;
  width: 34%;
  background: rgba(255, 255, 255, 0.48);
  transform: skewX(-24deg) translateX(0);
  pointer-events: none;
  transition: transform 0.36s cubic-bezier(.2, .85, .3, 1);
}

.cmd-past .cmd-shadow,
.cmd-past .cmd-btn,
.cmd-past .cmd-face {
  clip-path: polygon(0 0, 100% 4%, 96% 100%, 2% 96%);
}
.cmd-past .cmd-btn { transform: rotate(-2deg); }
.cmd-past .cmd-shadow { transform: rotate(-2deg) translate(4px, 4px); }

.cmd-memory .cmd-shadow,
.cmd-memory .cmd-btn,
.cmd-memory .cmd-face {
  clip-path: polygon(2% 4%, 98% 0, 100% 96%, 0 100%);
}
.cmd-memory .cmd-btn { transform: rotate(1.3deg) translateX(3px); }
.cmd-memory .cmd-shadow { transform: rotate(1.3deg) translate(7px, 4px); }

.cmd-settings .cmd-shadow,
.cmd-settings .cmd-btn,
.cmd-settings .cmd-face {
  clip-path: polygon(0 3%, 98% 0, 95% 100%, 2% 97%);
}
.cmd-settings .cmd-btn {
  background: #fe6201;
  transform: rotate(-1.6deg);
}
.cmd-settings .cmd-shadow {
  background: #fe6201;
  transform: rotate(-1.6deg) translate(4px, 4px);
}
.cmd-settings .cmd-face {
  background: #18120e;
  color: #fffaf4;
}

.cmd-wrap:hover .cmd-face {
  background: #fe6201;
  color: #14100d;
}
.cmd-wrap:hover .cmd-face::after {
  transform: skewX(-24deg) translateX(460%);
}
.cmd-wrap:hover .cmd-btn { background: #14100d; }
.cmd-wrap:hover .cmd-shadow { background: #14100d; }
.cmd-past:hover .cmd-btn { transform: rotate(-3.2deg) translate(4px, -2px) scale(1.02); }
.cmd-past:hover .cmd-shadow { transform: rotate(-1.6deg) translate(8px, 6px); }
.cmd-memory:hover .cmd-btn { transform: rotate(2.4deg) translate(7px, -2px) scale(1.02); }
.cmd-memory:hover .cmd-shadow { transform: rotate(1deg) translate(11px, 6px); }
.cmd-settings:hover .cmd-btn { transform: rotate(-2.8deg) translate(4px, -2px) scale(1.02); }
.cmd-settings:hover .cmd-shadow { transform: rotate(-1.2deg) translate(8px, 6px); }
.cmd-wrap:active .cmd-btn { transform: translate(2px, 2px) scale(0.98); }

.cmd-ico {
  width: 3.2cqh;
  height: 3.2cqh;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  color: #fe6201;
  transition: transform 0.28s cubic-bezier(.2, .9, .3, 1.2), color 0.14s ease;
}
.cmd-ico svg { width: 100%; height: 100%; display: block; }
.cmd-ico.cmd-gear img { width: 118%; height: 118%; object-fit: contain; display: block; }
.cmd-wrap:hover .cmd-ico { color: #14100d; transform: scale(1.12); }
.cmd-settings:hover .cmd-ico.cmd-gear { transform: rotate(55deg) scale(1.12); }
.cmd-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.1;
  min-width: 0;
}
.cmd-text strong {
  font-size: 2.0cqh;
  font-weight: 900;
  letter-spacing: 0.12em;
}
.cmd-text small {
  margin-top: 0.2cqh;
  font-family: Consolas, monospace;
  font-size: 1.05cqh;
  font-weight: 900;
  letter-spacing: 0.14em;
  opacity: 0.56;
}
.cmd-wrap:hover .cmd-text small { opacity: 0.85; }

/* P5 Comic Cut-in Portrait Slot with Offset Orange Halftone Silhouette */
.portrait-slot {
  position: absolute;
  left: 38%;
  right: 0;
  top: 2%;
  bottom: 31%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
}
.portrait-card {
  position: relative;
  width: 100%;
  height: 100%;
  pointer-events: auto;
  cursor: pointer;
  overflow: visible;
  transition: filter 0.35s ease;
}
.portrait-card[data-state="sleeping"] {
  filter: brightness(0.84) saturate(0.84);
}
.portrait-bg {
  position: absolute;
  left: 3.5%;
  right: 3.5%;
  top: 22%;
  bottom: 0;
  z-index: 0;
  background-color: #15100d;
  background-image:
    linear-gradient(122deg, transparent 0 18%, rgba(255, 250, 244, 0.045) 18% 44%, transparent 44% 100%),
    radial-gradient(rgba(255, 250, 244, 0.12) 1px, transparent 1px);
  background-size: 100% 100%, 10px 10px;
  border: 3px solid #14100d;
  box-shadow: 5px 5px 0 #fe6201;
  transform: skewX(-6deg);
  overflow: hidden;
  transition: box-shadow 0.2s ease;
}
.portrait-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(122deg, transparent 0 15.5%, #fe6201 15.5% 17%, transparent 17% 84.5%, rgba(254, 98, 1, 0.55) 84.5% 85.4%, transparent 85.4% 100%);
  pointer-events: none;
}
.portrait-bg::after {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1.5px solid rgba(255, 250, 244, 0.2);
  pointer-events: none;
}
.pbg-slash {
  position: absolute;
  left: -6%;
  top: 0;
  width: 14%;
  height: 100%;
  background: linear-gradient(180deg, rgba(254, 98, 1, 0.22) 0%, rgba(254, 98, 1, 0.04) 65%, transparent 100%);
  border-right: 1px solid rgba(254, 98, 1, 0.35);
  pointer-events: none;
}
.pbg-dots {
  position: absolute;
  right: 0;
  top: 0;
  width: 34%;
  height: 62%;
  background-image: radial-gradient(rgba(254, 98, 1, 0.42) 1.35px, transparent 1.35px);
  background-size: 6px 6px;
  -webkit-mask-image: radial-gradient(circle at 100% 0%, #000 18%, transparent 78%);
  mask-image: radial-gradient(circle at 100% 0%, #000 18%, transparent 78%);
  pointer-events: none;
}
.pbg-corner {
  position: absolute;
  width: 11px;
  height: 11px;
  pointer-events: none;
}
.pbg-corner.tl {
  left: 9px;
  top: 9px;
  border-top: 2.5px solid #fe6201;
  border-left: 2.5px solid #fe6201;
}
.pbg-corner.br {
  right: 9px;
  bottom: 9px;
  border-right: 2.5px solid #fe6201;
  border-bottom: 2.5px solid #fe6201;
}
.pbg-marks {
  position: absolute;
  right: 11px;
  top: 9px;
  font-family: Consolas, monospace;
  font-size: 1.15cqh;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: #fe6201;
  opacity: 0.85;
  line-height: 1;
  pointer-events: none;
}
.pbg-tag {
  position: absolute;
  left: 11px;
  bottom: 10px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: Consolas, monospace;
  font-size: 1.08cqh;
  font-weight: 900;
  letter-spacing: 0.14em;
  color: rgba(255, 250, 244, 0.72);
  line-height: 1;
  pointer-events: none;
}
.pbg-led {
  width: 5px;
  height: 5px;
  background: #fe6201;
  display: inline-block;
  box-shadow: 0 0 6px rgba(254, 98, 1, 0.7);
}
.portrait-card.speaking .pbg-led {
  animation: pulse 0.9s ease-in-out infinite;
}
.portrait-card[data-state="sleeping"] .pbg-led {
  background: #6c84c8;
  box-shadow: none;
}
.portrait-card.speaking .portrait-bg {
  box-shadow: 7px 7px 0 #fe6201;
}
.portrait-canvas {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

/* Irregular P5 Comic Action Buttons: Call & Screen Share */
.live-actions {
  position: absolute;
  left: 38%;
  right: 0;
  bottom: 1.5%;
  height: 22.5%;
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  gap: 0.9cqw;
  align-items: stretch;
  padding: 0 2.5%;
  pointer-events: auto;
}
.live-wrap {
  position: relative;
  display: flex;
  align-items: stretch;
}
.live-btn-bg {
  position: absolute;
  inset: 0;
  background: #fe6201;
  pointer-events: none;
  transition: transform 0.18s cubic-bezier(.2, .9, .3, 1.15), background 0.16s ease;
}
.live-call .live-btn-bg {
  clip-path: polygon(5% 6%, 100% 0, 93% 94%, 0 100%);
  transform: translate(4px, 4px) rotate(-2deg);
}
.live-share .live-btn-bg {
  clip-path: polygon(6% 0, 100% 7%, 95% 100%, 0 92%);
  transform: translate(4px, 4px) rotate(1.8deg);
}
.live-btn {
  position: relative;
  z-index: 1;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5cqw;
  padding: 0 0.6cqw;
  background: #18120e;
  color: #fffaf4;
  border: 0;
  overflow: hidden;
  transition: transform 0.18s cubic-bezier(.2, .9, .3, 1.2), background 0.14s ease, color 0.14s ease;
}
.live-btn::before {
  content: "";
  position: absolute;
  inset: 2.5px;
  border: 1.5px solid rgba(255, 250, 244, 0.2);
  pointer-events: none;
  transition: border-color 0.14s ease;
}
.live-btn::after {
  content: "";
  position: absolute;
  top: -30%;
  bottom: -30%;
  left: -55%;
  width: 36%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.65), transparent);
  transform: skewX(-28deg) translateX(0);
  pointer-events: none;
  transition: transform 0.42s cubic-bezier(.2, .85, .3, 1);
}
.live-call .live-btn {
  clip-path: polygon(5% 6%, 100% 0, 93% 94%, 0 100%);
  transform: rotate(-2deg);
}
.live-share .live-btn {
  clip-path: polygon(6% 0, 100% 7%, 95% 100%, 0 92%);
  transform: rotate(1.8deg);
}
.live-ico {
  width: 2.15cqh;
  height: 2.15cqh;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fe6201;
  flex: 0 0 auto;
  transition: color 0.14s ease, transform 0.2s ease;
}
.live-ico svg { width: 100%; height: 100%; display: block; overflow: visible; }
.live-ico .wave { opacity: 0.35; transition: opacity 0.16s ease; }
.live-label {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.08;
}
.live-label strong {
  font-size: 1.55cqh;
  font-weight: 900;
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.live-label small {
  margin-top: 0.15cqh;
  font-family: Consolas, monospace;
  font-size: 0.92cqh;
  font-weight: 900;
  letter-spacing: 0.14em;
  color: #fe6201;
  transition: color 0.14s ease;
}

/* Rich Multi-Layer Hover Dynamics */
.live-wrap:hover .live-btn {
  background: #fe6201;
  color: #14100d;
}
.live-call:hover .live-btn {
  transform: rotate(-4deg) translate(-2px, -3px) scale(1.04);
}
.live-share:hover .live-btn {
  transform: rotate(3.4deg) translate(-2px, -3px) scale(1.04);
}
.live-call:hover .live-btn-bg {
  background: #14100d;
  transform: translate(7px, 6px) rotate(1.2deg);
}
.live-share:hover .live-btn-bg {
  background: #14100d;
  transform: translate(7px, 6px) rotate(-1.4deg);
}
.live-wrap:hover .live-btn::before {
  border-color: rgba(20, 16, 13, 0.38);
}
.live-wrap:hover .live-btn::after {
  transform: skewX(-28deg) translateX(460%);
}
.live-wrap:hover .live-ico,
.live-wrap:hover .live-label small {
  color: #14100d;
}
.live-call:hover .live-ico {
  animation: phoneRing 0.42s ease-in-out 2;
}
.live-call:hover .live-ico .wave {
  opacity: 1;
}
.live-share:hover .live-ico .beam {
  animation: sharePulse 0.65s ease-in-out infinite;
}
.live-wrap:active .live-btn {
  transform: translate(2px, 2px) scale(0.97);
}
@keyframes phoneRing {
  0%, 100% { transform: rotate(0deg) scale(1.1); }
  25% { transform: rotate(-14deg) scale(1.14); }
  75% { transform: rotate(14deg) scale(1.14); }
}
@keyframes sharePulse {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}
.column {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1.2cqh;
  min-height: 0;
}

/* Active state for Screen Share button */
.live-share.sharing .live-btn {
  background: #fe6201;
  color: #14100d;
}
.live-share.sharing .live-btn-bg {
  background: #14100d;
  transform: translate(6px, 5px) rotate(-1.2deg);
}
.live-share.sharing .live-ico,
.live-share.sharing .live-label small {
  color: #14100d;
}
.live-share.sharing .live-ico .beam {
  animation: sharePulse 0.75s ease-in-out infinite;
}

/* Toggleable Screen Share Live Preview HUD */
.share-hud {
  position: absolute;
  top: 2.2cqh;
  right: 0.9cqw;
  z-index: 24;
  display: none;
  flex-direction: column;
  width: 17.5cqw;
  background: #18120e;
  color: #fffaf4;
  border: 2.5px solid #14100d;
  border-left: 5px solid #fe6201;
  box-shadow: 5px 5px 0 #fe6201;
  overflow: hidden;
}
.share-hud.active {
  display: flex;
  animation: cardPop 0.18s cubic-bezier(.2, .9, .3, 1) both;
}
.share-hud.collapsed {
  width: auto;
}
.share-hud-bar {
  display: flex;
  align-items: center;
  gap: 0.45cqw;
  padding: 0.48cqh 0.55cqw;
  background: #18120e;
  user-select: none;
}
.share-hud-dot {
  width: 0.55cqw;
  height: 0.55cqw;
  min-width: 7px;
  min-height: 7px;
  border-radius: 50%;
  background: #fe6201;
  box-shadow: 0 0 8px rgba(254, 98, 1, 0.9);
  animation: shareBlink 1.3s ease-in-out infinite;
  flex: 0 0 auto;
}
@keyframes shareBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
.share-hud-title {
  font-size: 1.28cqh;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: #fffaf4;
  white-space: nowrap;
}
.share-hud-size {
  font-family: Consolas, monospace;
  font-size: 1.12cqh;
  font-weight: 800;
  color: rgba(255, 250, 244, 0.62);
  white-space: nowrap;
}
.share-hud-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.3cqw;
}
.share-hud-btn {
  padding: 0.2cqh 0.45cqw;
  background: rgba(255, 250, 244, 0.1);
  color: #fffaf4;
  border: 1.5px solid rgba(255, 250, 244, 0.28);
  font-size: 1.12cqh;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.2;
  white-space: nowrap;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.share-hud-btn:hover {
  background: #fe6201;
  color: #14100d;
  border-color: #fe6201;
}
.share-hud-btn.stop {
  padding: 0.16cqh 0.44cqw;
  font-size: 1.3cqh;
}
.share-hud-body {
  position: relative;
  background: #0f0b09;
  border-top: 2px solid rgba(254, 98, 1, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  height: 13.5cqh;
  overflow: hidden;
}
.share-hud.collapsed .share-hud-body {
  display: none;
}
.share-hud-body img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}
.log {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  overflow-x: hidden;
  overflow-y: auto;
  background: transparent;
  color: #14100d;
  padding: 3.2cqh 1.1cqw 0.8cqh 0.6cqw;
}
.hist-card {
  position: relative;
  box-sizing: border-box;
  width: fit-content;
  max-width: 74%;
  min-width: 132px;
  margin: 2.1cqh 0 0.7cqh;
  padding: 1.35cqh 1.4cqw 1.1cqh 1.35cqw;
  background: #fff;
  color: #14100d;
  align-self: flex-start;
  border: 2.5px solid #14100d;
  border-left: 5px solid #fe6201;
  box-shadow: 4px 4px 0 #14100d;
}
.hist-card::after {
  content: "";
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 9px;
  height: 9px;
  background: #fe6201;
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
  pointer-events: none;
}
.hist-card.you {
  align-self: flex-end;
  max-width: 68%;
  background: #181310;
  color: #f7f3ec;
  border: 2.5px solid #14100d;
  border-right: 5px solid #fe6201;
  box-shadow: 4px 4px 0 #fe6201;
}
.hist-card.you::after {
  right: auto;
  left: 3px;
  clip-path: polygon(0 0, 0 100%, 100% 100%);
}
.hist-card.fresh {
  animation: histIn 0.38s cubic-bezier(.22, 1, .36, 1) both;
}
@keyframes histIn {
  from { opacity: 0; transform: translateY(18px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.hist-tag {
  position: absolute;
  top: -1.95cqh;
  left: 0.75cqw;
  padding: 0.22cqh 0.75cqw;
  background: #14100d;
  color: #fff;
  border-left: 4px solid #fe6201;
  box-shadow: 2px 2px 0 rgba(20, 16, 13, 0.22);
  font-size: 1.5cqh;
  font-weight: 900;
  letter-spacing: 0.1em;
  line-height: 1.2;
  transform: rotate(-3deg) skewX(-11deg);
  pointer-events: none;
  user-select: none;
}
.hist-card.you .hist-tag {
  left: auto;
  right: 0.75cqw;
  background: #fe6201;
  color: #14100d;
  border: 2px solid #14100d;
  box-shadow: 2px 2px 0 #14100d;
  transform: rotate(3deg) skewX(-11deg);
}
.hist-card .txt {
  display: block;
  max-width: 100%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-weight: 700;
  font-size: var(--hist-cq);
  line-height: 1.5;
}
.output-zone {
  position: relative;
  flex: 0 0 26%;
  min-height: 18.5cqh;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 2.8cqh 1.1cqw 0.8cqh 0.4cqw;
  background: transparent;
  overflow: visible;
}
.thinking-dots {
  display: none;
  align-items: center;
  gap: 0.75cqw;
  padding-left: 1.4cqw;
}
.thinking-dots.show {
  display: inline-flex;
}
.thinking-dots span {
  width: 1.25cqh;
  height: 1.25cqh;
  background: #fe6201;
  border: 2px solid #14100d;
  box-shadow: 2px 2px 0 #14100d;
  animation: dotWave 1.1s ease-in-out infinite;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.16s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.32s; }
@keyframes dotWave {
  0%, 60%, 100% { transform: skewX(-14deg) translateY(0) scale(0.9); opacity: 0.45; }
  30% { transform: skewX(-14deg) translateY(-0.7cqh) scale(1.12); opacity: 1; }
}
.output-bubble {
  position: relative;
  display: none;
  width: fit-content;
  min-width: 46%;
  max-width: 98%;
  min-height: 12.5cqh;
  padding-left: var(--tail-w, 7.2cqw);
  background: transparent;
  color: #fffaf4;
  transform-origin: left center;
  overflow: visible;
  cursor: pointer;
  will-change: transform, opacity;
}
.output-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  overflow: visible;
  pointer-events: none;
}
.output-bubble.show {
  display: block;
  animation: bubblePop 0.28s cubic-bezier(.18, .94, .3, 1.1) both;
}
.output-bubble.leaving {
  animation: bubbleOut 0.38s cubic-bezier(.22, 1, .36, 1) forwards;
}
@keyframes bubblePop {
  from { opacity: 0; transform: translateX(-14px) translateY(6px) scale(0.92); }
  to { opacity: 1; transform: translateX(0) translateY(0) scale(1); }
}
@keyframes bubbleOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(-26px) scale(0.96); }
}
.output-nameplate {
  position: absolute;
  top: -2.4cqh;
  left: calc(var(--tail-w, 7.2cqw) + 1.3cqw);
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 0.55cqw;
  padding: 0.38cqh 1.15cqw 0.4cqh 1.05cqw;
  background: #fe6201;
  color: #14100d;
  border: 3px solid #14100d;
  box-shadow: 4px 4px 0 #14100d;
  transform: rotate(-5.2deg) skewX(-12deg);
  pointer-events: none;
  user-select: none;
}
.output-nameplate .np-main {
  font-size: 2.35cqh;
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1.1;
}
.output-nameplate .np-sub {
  padding: 0.14cqh 0.42cqw;
  background: #14100d;
  color: #fff;
  font-size: 1.2cqh;
  font-weight: 900;
  letter-spacing: 0.14em;
  line-height: 1.15;
}
.output-scroll {
  position: relative;
  z-index: 2;
  max-height: 13.8cqh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2.55cqh 2.6cqw 2.0cqh 1.9cqw;
  background: transparent;
  border: 0;
}
.output-scroll::-webkit-scrollbar { width: 6px; }
.output-scroll::-webkit-scrollbar-track { background: transparent; }
.output-scroll::-webkit-scrollbar-thumb { background: #fe6201; }
.output-text {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-weight: 700;
  font-size: var(--dialogue-cq);
  line-height: 1.52;
  color: #fffaf4;
}
.output-cont {
  position: absolute;
  right: 1.2cqw;
  bottom: 1.35cqh;
  z-index: 4;
  font-size: 1.45cqh;
  line-height: 1;
  color: #fe6201;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}
.output-cont.show {
  opacity: 1;
  animation: contBounce 0.9s ease-in-out infinite;
}
@keyframes contBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(3px); }
}
.composer {
  position: relative;
  display: flex;
  align-items: center;
  gap: 1.2%;
  flex: 0 0 auto;
  padding-right: 0.3cqw;
}
.voice-bar {
  position: absolute;
  left: 0;
  right: 0.3cqw;
  bottom: calc(100% + 0.9cqh);
  z-index: 26;
  display: none;
  align-items: center;
  gap: 0.85cqw;
  padding: 0.72cqh 1.0cqw;
  background: #18120e;
  color: #fffaf4;
  border: 2.5px solid #14100d;
  border-left: 5px solid #fe6201;
  box-shadow: 4px 4px 0 #fe6201;
  user-select: none;
}
.voice-bar.open {
  display: flex;
  animation: cardPop 0.16s cubic-bezier(.2, .9, .3, 1) both;
}
.voice-rec-dot {
  width: 0.65cqw;
  height: 0.65cqw;
  min-width: 8px;
  min-height: 8px;
  border-radius: 50%;
  background: #fe6201;
  box-shadow: 0 0 8px rgba(254, 98, 1, 0.95);
  animation: shareBlink 0.95s ease-in-out infinite;
  flex: 0 0 auto;
}
.voice-bar.processing .voice-rec-dot {
  background: #ffd166;
  box-shadow: 0 0 8px rgba(255, 209, 102, 0.9);
}
.voice-bar-status {
  font-size: 1.45cqh;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: #fffaf4;
  white-space: nowrap;
}
.voice-eq {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.32cqw;
  height: 2.4cqh;
  min-width: 6cqw;
}
.voice-eq span {
  display: block;
  width: 0.28cqw;
  min-width: 3px;
  height: 20%;
  background: #fe6201;
  transition: height 0.06s ease;
}
.voice-bar.processing .voice-eq span {
  background: rgba(255, 250, 244, 0.35);
}
.voice-bar-time {
  font-family: Consolas, monospace;
  font-size: 1.35cqh;
  font-weight: 800;
  color: rgba(255, 250, 244, 0.72);
  white-space: nowrap;
}
.voice-bar-actions {
  display: flex;
  align-items: center;
  gap: 0.45cqw;
}
.voice-bar-btn {
  padding: 0.34cqh 0.72cqw;
  background: rgba(255, 250, 244, 0.12);
  color: #fffaf4;
  border: 1.5px solid rgba(255, 250, 244, 0.3);
  font-size: 1.28cqh;
  font-weight: 900;
  letter-spacing: 0.06em;
  transform: skewX(-8deg);
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.voice-bar-btn.done {
  background: #fe6201;
  color: #14100d;
  border-color: #fe6201;
}
.voice-bar-btn:hover {
  filter: brightness(1.08);
}
.input-shell {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  border: 2.5px solid #14100d;
  background: #fff;
  box-shadow: 3px 3px 0 #14100d;
  transition: box-shadow 0.14s ease;
}
.input-shell:focus-within {
  box-shadow: 3px 3px 0 #fe6201;
}
#say {
  position: relative;
  left: auto;
  top: auto;
  width: 100%;
  height: 2.8em;
  min-height: 2.8em;
  z-index: 1;
  border: 0;
  box-shadow: none;
  outline: none;
  resize: none;
  background: #fff;
  color: #14100d;
  font-weight: 700;
  font-size: 2.15cqh;
  letter-spacing: 0.04em;
  line-height: 1.45;
  padding: 0.55em 0.75em;
  text-align: left;
  overflow: hidden;
}
#say::placeholder { color: rgba(36, 25, 16, 0.45); }
.voice-btn {
  flex: 0 0 auto;
  align-self: stretch;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.6cqw;
  min-width: 40px;
  border-left: 2px dashed rgba(20, 16, 13, 0.18);
  background: #fbfaf7;
  color: #14100d;
  transition: background 0.12s ease, color 0.12s ease;
}
.voice-btn svg {
  width: 2.35cqh;
  height: 2.35cqh;
  display: block;
}
.voice-btn:hover {
  background: #fff1e4;
  color: #fe6201;
}
.voice-btn.listening {
  background: #fe6201;
  color: #14100d;
  border-left-color: #14100d;
  animation: voicePulse 1.1s ease-in-out infinite;
}
@keyframes voicePulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.14); }
}
.send {
  position: relative;
  left: auto;
  top: auto;
  flex: 0 0 15%;
  width: 15%;
  height: auto;
  align-self: stretch;
  min-height: 3.4em;
  z-index: 1;
  background: #fe6201;
  color: #14100d;
  font-weight: 900;
  font-size: 2.5cqh;
  letter-spacing: 0.14em;
  border: 2.5px solid #14100d;
  box-shadow: 3px 3px 0 #14100d;
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.12s ease;
}
.send:hover { filter: brightness(1.05); transform: translate(-1px, -1px); box-shadow: 4px 4px 0 #14100d; }
.send:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 #14100d; }
.line {
  margin: 0;
  width: 100%;
  text-align: center;
  font-size: var(--dialogue-cq);
  font-weight: 800;
  line-height: 1.45;
  color: #1a120c;
  white-space: pre-wrap;
}
.line.thinking { color: #6d645c; letter-spacing: 0.2em; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%,100%{opacity:.4} 50%{opacity:1} }
.caret { display: inline-block; width: 0.12em; height: 0.9em; margin-left: 2px; background: #fe6201; vertical-align: text-bottom; animation: blink .8s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.cont { position: absolute; right: 6%; bottom: 10%; color: #fe6201; opacity: 0; }
.cont.show { opacity: 1; }
.hist-item { margin: 0 0 0.7cqh; text-align: left; font-size: 2.05cqh; font-weight: 700; line-height: 1.45; }
.hist-item .who { color: #241910; font-weight: 900; }
.hist-item:not(.you) .who { color: #fe6201; }
.hist-item .txt { white-space: pre-wrap; }

#historyBody { scrollbar-color: #fe6201 #f3f3f3; }
#historyBody::-webkit-scrollbar { width: 10px; }
#historyBody::-webkit-scrollbar-track { background: transparent; }
#historyBody::-webkit-scrollbar-thumb { background: #fe6201; border-radius: 0; }

.veil { position: absolute; inset: 0; z-index: 20; background: rgba(0,0,0,.28); opacity: 0; pointer-events: none; }
.veil.open { opacity: 1; pointer-events: auto; }
.sleep {
  position: absolute; inset: 0; z-index: 40; display: none;
  align-items: center; justify-content: center; background: rgba(0,0,0,.55);
}
.sleep.show { display: flex; }
.sleep-card { text-align: center; }
.sleep-card p { font-weight: 900; font-size: 3cqh; letter-spacing: 0.18em; }
.wake { background: #fe6201; color: #111; font-weight: 900; letter-spacing: 0.16em; padding: 0.8cqh 1.6cqw; }
.toast {
  position: absolute; left: 50%; bottom: 6%; transform: translateX(-50%);
  z-index: 45; background: #111; color: var(--cream); border: 2px solid #fe6201;
  padding: 0.6cqh 1.2cqw; opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.toast.show { opacity: 1; }
.winbar { position: fixed; top: 0; right: 0; z-index: 50; display: flex; }
.winbar button { width: 42px; height: 32px; color: #1a120c; }
.winbar button:hover { background: rgba(20, 16, 13, 0.08); }
#win-close:hover { background: #fe6201; color: #111; }
.stage.busy textarea, .stage.asleep textarea { pointer-events: none; }

/* ===== Full-Stage Slash Transition ===== */
.screen-wipe {
  position: absolute;
  inset: 0;
  z-index: 60;
  overflow: hidden;
  pointer-events: none;
  display: none;
}
.screen-wipe.run {
  display: block;
}
.wipe-slash {
  position: absolute;
  top: -12%;
  bottom: -12%;
  left: -18%;
  width: 136%;
  transform: translate3d(-118%, 0, 0) skewX(-16deg);
  will-change: transform;
}
.wipe-slash.dark {
  background: #18120e;
  border-right: 10px solid #fe6201;
}
.wipe-slash.orange {
  width: 24%;
  background: #fe6201;
}
.screen-wipe.run .wipe-slash.dark {
  animation: wipeAcross 0.44s cubic-bezier(.72, 0, .28, 1) forwards;
}
.screen-wipe.run .wipe-slash.orange {
  animation: wipeTrail 0.44s cubic-bezier(.72, 0, .28, 1) 0.04s forwards;
}
@keyframes wipeAcross {
  0% { transform: translateX(-118%) skewX(-16deg); }
  45% { transform: translateX(0%) skewX(-16deg); }
  55% { transform: translateX(0%) skewX(-16deg); }
  100% { transform: translateX(118%) skewX(-16deg); }
}
@keyframes wipeTrail {
  0% { transform: translateX(-220%) skewX(-16deg); }
  100% { transform: translateX(620%) skewX(-16deg); }
}

/* ===== Subpages Common (Bright White + Black/Orange P5) ===== */
.subpage {
  position: absolute;
  inset: 0;
  z-index: 36;
  display: none;
  flex-direction: column;
  background-color: #fbfaf7;
  background-image:
    linear-gradient(135deg, rgba(254, 98, 1, 0.08) 0, rgba(254, 98, 1, 0.08) 12%, transparent 12.1%),
    radial-gradient(rgba(20, 16, 13, 0.09) 1.1px, transparent 1.1px);
  background-size: 100% 100%, 22px 22px;
  color: #14100d;
  padding: 4.4cqh 3.2cqw 3.2cqh;
  overflow: hidden;
}
.subpage.open {
  display: flex;
}
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.6cqw;
  padding-bottom: 1.8cqh;
  margin-bottom: 2.2cqh;
  border-bottom: 3px solid #14100d;
  flex: 0 0 auto;
}
.page-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.9cqw;
}
.page-kicker {
  display: inline-block;
  padding: 0.35cqh 0.85cqw;
  background: #14100d;
  color: #fff;
  border-left: 5px solid #fe6201;
  font-size: 1.55cqh;
  font-weight: 900;
  letter-spacing: 0.16em;
  transform: skewX(-12deg);
}
.page-kicker.orange {
  background: #fe6201;
  color: #14100d;
  border: 2.5px solid #14100d;
  box-shadow: 3px 3px 0 #14100d;
}
.page-title {
  margin: 0;
  font-size: 3.1cqh;
  font-weight: 900;
  letter-spacing: 0.1em;
  color: #14100d;
}
.page-count {
  padding: 0.25cqh 0.65cqw;
  background: #fff;
  border: 2px solid #14100d;
  box-shadow: 2px 2px 0 #14100d;
  font-size: 1.4cqh;
  font-weight: 800;
  color: #14100d;
}
.gallery-filters {
  display: inline-flex;
  align-items: center;
  gap: 0.65cqw;
  margin-right: auto;
  margin-left: 1.2cqw;
}
.gallery-filters button {
  padding: 0.55cqh 1.15cqw;
  background: #fff;
  color: #14100d;
  border: 2.5px solid #14100d;
  box-shadow: 3px 3px 0 #14100d;
  font-size: 1.55cqh;
  font-weight: 900;
  letter-spacing: 0.08em;
  transform: skewX(-10deg);
  transition: transform 0.1s ease, background 0.12s ease, box-shadow 0.1s ease;
}
.gallery-filters button:hover {
  background: #fff2e6;
  transform: skewX(-10deg) translate(-1px, -1px);
}
.gallery-filters button.on {
  background: #fe6201;
  color: #14100d;
  box-shadow: 3px 3px 0 #14100d;
}
.page-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.85cqw;
  padding-right: 4.5cqw;
}
.page-btn {
  padding: 0.65cqh 1.25cqw;
  background: #fff;
  color: #14100d;
  border: 2.5px solid #14100d;
  box-shadow: 3px 3px 0 #14100d;
  font-size: 1.55cqh;
  font-weight: 900;
  letter-spacing: 0.08em;
  transform: skewX(-10deg);
  transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.12s ease;
}
.page-btn:hover {
  transform: skewX(-10deg) translate(-1px, -1px);
  box-shadow: 4px 4px 0 #fe6201;
}
.page-btn:active {
  transform: skewX(-10deg) translate(2px, 2px);
  box-shadow: 1px 1px 0 #14100d;
}
.page-btn.accent {
  background: #fe6201;
  color: #14100d;
}
.page-btn.accent:disabled {
  opacity: 0.6;
  cursor: wait;
}
.page-btn.back {
  background: #18120e;
  color: #fff;
  box-shadow: 3px 3px 0 #fe6201;
}
.page-btn.back span {
  margin-left: 0.35cqw;
  font-size: 1.15cqh;
  color: #fe6201;
}

/* ===== Memory Gallery ===== */
.gallery-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.6cqh 0.6cqw 1.6cqh 0.2cqw;
}
.gallery-wrap::-webkit-scrollbar { width: 8px; }
.gallery-wrap::-webkit-scrollbar-track { background: transparent; }
.gallery-wrap::-webkit-scrollbar-thumb { background: #fe6201; }
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2.2cqh 1.6cqw;
}
.mem-card {
  position: relative;
  display: flex;
  flex-direction: column;
  text-align: left;
  min-height: 21cqh;
  padding: 1.5cqh 1.35cqw 1.3cqh;
  background: #fff;
  color: #14100d;
  border: 2.5px solid #14100d;
  box-shadow: 5px 5px 0 #14100d;
  transition: transform 0.14s cubic-bezier(.2, .9, .3, 1), box-shadow 0.14s ease, border-color 0.14s ease;
  animation: cardPop 0.28s cubic-bezier(.2, .9, .3, 1) both;
}
.mem-card:hover {
  transform: translate(-3px, -3px);
  box-shadow: 8px 8px 0 #fe6201;
}
.mem-card::after {
  content: "";
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 12px;
  height: 12px;
  background: #fe6201;
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
}
@keyframes cardPop {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.mem-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6cqw;
  margin-bottom: 1.0cqh;
  padding-bottom: 0.7cqh;
  border-bottom: 2px dashed rgba(20, 16, 13, 0.16);
}
.mem-no {
  font-family: Consolas, "Courier New", monospace;
  font-size: 1.45cqh;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: rgba(20, 16, 13, 0.52);
}
.mem-badges {
  display: inline-flex;
  align-items: center;
  gap: 0.4cqw;
}
.mem-layer {
  padding: 0.18cqh 0.55cqw;
  background: #14100d;
  color: #fff;
  font-size: 1.25cqh;
  font-weight: 900;
  letter-spacing: 0.08em;
  transform: skewX(-10deg);
}
.mem-layer.wiki {
  background: #fe6201;
  color: #14100d;
  border: 1.5px solid #14100d;
}
.mem-rev {
  font-family: Consolas, monospace;
  font-size: 1.15cqh;
  font-weight: 800;
  color: rgba(20, 16, 13, 0.55);
}
.mem-card-title {
  margin: 0 0 0.75cqh;
  font-size: 2.15cqh;
  font-weight: 900;
  line-height: 1.3;
  color: #14100d;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.mem-card-excerpt {
  margin: 0 0 auto;
  flex: 0 0 auto;
  font-size: 1.55cqh;
  font-weight: 600;
  line-height: 1.55;
  color: rgba(20, 16, 13, 0.72);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: pre-wrap;
}
.mem-card-foot {
  margin-top: 1.1cqh;
  font-size: 1.3cqh;
  font-weight: 800;
  color: #fe6201;
  letter-spacing: 0.06em;
}
.gallery-empty {
  grid-column: 1 / -1;
  padding: 8cqh 2cqw;
  text-align: center;
  background: #fff;
  border: 2.5px dashed rgba(20, 16, 13, 0.3);
  font-size: 2.0cqh;
  font-weight: 800;
  color: rgba(20, 16, 13, 0.5);
}

/* Memory Reader Modal */
.mem-reader-backdrop {
  position: absolute;
  inset: 0;
  z-index: 42;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(20, 16, 13, 0.48);
  padding: 4cqh 6cqw;
}
.mem-reader-backdrop.open {
  display: flex;
}
.mem-reader {
  width: min(76cqw, 820px);
  max-height: 82cqh;
  display: flex;
  flex-direction: column;
  background: #fff;
  color: #14100d;
  border: 3px solid #14100d;
  box-shadow: 9px 9px 0 #fe6201;
  padding: 2.4cqh 2.4cqw 2.0cqh;
  animation: cardPop 0.2s cubic-bezier(.2, .9, .3, 1) both;
}
.reader-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1cqw;
  margin-bottom: 1.2cqh;
}
.reader-meta {
  display: flex;
  align-items: center;
  gap: 0.65cqw;
}
.reader-no {
  font-family: Consolas, monospace;
  font-size: 1.6cqh;
  font-weight: 900;
  color: rgba(20, 16, 13, 0.55);
}
.reader-layer {
  padding: 0.25cqh 0.7cqw;
  background: #14100d;
  color: #fff;
  font-size: 1.35cqh;
  font-weight: 900;
  transform: skewX(-10deg);
}
.reader-layer.wiki {
  background: #fe6201;
  color: #14100d;
  border: 2px solid #14100d;
}
.reader-rev {
  font-family: Consolas, monospace;
  font-size: 1.35cqh;
  font-weight: 800;
  color: rgba(20, 16, 13, 0.6);
}
.reader-close {
  width: 4.2cqh;
  height: 4.2cqh;
  background: #14100d;
  color: #fff;
  font-size: 2.6cqh;
  font-weight: 900;
  line-height: 1;
  box-shadow: 3px 3px 0 #fe6201;
}
.reader-close:hover { background: #fe6201; color: #14100d; }
.reader-title {
  margin: 0 0 1.4cqh;
  padding-bottom: 1.1cqh;
  border-bottom: 2.5px solid #14100d;
  font-size: 2.7cqh;
  font-weight: 900;
  line-height: 1.3;
}
.reader-body {
  flex: 1 1 auto;
  min-height: 12cqh;
  overflow-y: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 1.95cqh;
  font-weight: 600;
  line-height: 1.72;
  color: #1a120c;
  padding-right: 0.8cqw;
}
.reader-body::-webkit-scrollbar { width: 7px; }
.reader-body::-webkit-scrollbar-thumb { background: #fe6201; }
.reader-foot {
  margin-top: 1.6cqh;
  padding-top: 1.2cqh;
  border-top: 2px dashed rgba(20, 16, 13, 0.2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1cqw;
}
.reader-file {
  font-family: Consolas, monospace;
  font-size: 1.35cqh;
  color: rgba(20, 16, 13, 0.5);
}
.reader-del {
  padding: 0.55cqh 1.1cqw;
  background: #fff;
  color: #b22222;
  border: 2px solid #b22222;
  font-size: 1.45cqh;
  font-weight: 900;
  letter-spacing: 0.06em;
}
.reader-del.arm {
  background: #b22222;
  color: #fff;
}

/* ===== Archive Save-Slot Page ===== */
.archive-layout {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 35%) minmax(0, 1fr);
  gap: 2.0cqw;
}
.slot-list {
  display: flex;
  flex-direction: column;
  gap: 1.35cqh;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.4cqh 0.9cqw 1.2cqh 0.2cqw;
}
.slot-list::-webkit-scrollbar { width: 7px; }
.slot-list::-webkit-scrollbar-thumb { background: #fe6201; }
.save-slot {
  position: relative;
  width: 100%;
  text-align: left;
  padding: 1.3cqh 1.2cqw 1.2cqh 1.35cqw;
  background: #fff;
  color: #14100d;
  border: 2.5px solid #14100d;
  border-left: 7px solid #14100d;
  box-shadow: 4px 4px 0 #14100d;
  transition: transform 0.14s cubic-bezier(.2, .9, .3, 1), box-shadow 0.14s ease, background 0.14s ease;
  animation: cardPop 0.26s cubic-bezier(.2, .9, .3, 1) both;
}
.save-slot:hover {
  transform: translateX(4px);
  box-shadow: 5px 5px 0 #fe6201;
}
.save-slot.on {
  background: #18120e;
  color: #fffaf4;
  border-left-color: #fe6201;
  box-shadow: 6px 6px 0 #fe6201;
  transform: translateX(6px);
}
.slot-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5cqw;
  margin-bottom: 0.65cqh;
}
.slot-code {
  display: inline-block;
  padding: 0.15cqh 0.55cqw;
  background: #14100d;
  color: #fff;
  font-family: Consolas, monospace;
  font-size: 1.3cqh;
  font-weight: 900;
  letter-spacing: 0.1em;
  transform: skewX(-10deg);
}
.save-slot.on .slot-code,
.save-slot.current .slot-code {
  background: #fe6201;
  color: #14100d;
}
.slot-time {
  font-family: Consolas, monospace;
  font-size: 1.25cqh;
  font-weight: 700;
  color: rgba(20, 16, 13, 0.55);
}
.save-slot.on .slot-time {
  color: rgba(255, 250, 244, 0.68);
}
.slot-preview {
  font-size: 1.65cqh;
  font-weight: 800;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.archive-viewer {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #fff;
  border: 2.5px solid #14100d;
  box-shadow: 6px 6px 0 #14100d;
  overflow: hidden;
}
.viewer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1cqw;
  padding: 1.25cqh 1.6cqw;
  background: #18120e;
  color: #fffaf4;
  border-bottom: 3px solid #fe6201;
  flex: 0 0 auto;
}
.viewer-title-row {
  display: flex;
  align-items: center;
  gap: 0.85cqw;
}
.viewer-slot-tag {
  padding: 0.2cqh 0.65cqw;
  background: #fe6201;
  color: #14100d;
  font-family: Consolas, monospace;
  font-size: 1.45cqh;
  font-weight: 900;
  letter-spacing: 0.1em;
  transform: skewX(-10deg);
}
.viewer-time {
  font-size: 1.55cqh;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.viewer-readonly {
  padding: 0.2cqh 0.6cqw;
  border: 1.5px solid rgba(255, 250, 244, 0.35);
  font-size: 1.25cqh;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: rgba(255, 250, 244, 0.78);
}
.viewer-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 2.2cqh 1.8cqw 2.0cqh;
  background: #fbfaf7;
}
.viewer-body::-webkit-scrollbar { width: 8px; }
.viewer-body::-webkit-scrollbar-thumb { background: #fe6201; }
.viewer-empty {
  margin: auto;
  font-size: 1.85cqh;
  font-weight: 800;
  color: rgba(20, 16, 13, 0.45);
}
.viewer-files {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6cqw;
  margin-top: 0.8cqh;
}
.viewer-img {
  max-width: 18cqw;
  max-height: 16cqh;
  object-fit: cover;
  border: 2px solid #14100d;
  display: block;
}
.viewer-file-pill {
  padding: 0.2cqh 0.55cqw;
  background: rgba(254, 98, 1, 0.16);
  border: 1.5px solid #fe6201;
  font-size: 1.3cqh;
  font-weight: 800;
}
.archive-hint {
  font-size: 1.35cqh;
  font-weight: 700;
  color: rgba(20, 16, 13, 0.52);
  letter-spacing: 0.04em;
  margin-right: 0.4cqw;
}

/* Right-click Context Menu for Archive Save Slots */
.slot-ctx {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 48;
  display: none;
  flex-direction: column;
  min-width: 13.5cqw;
  background: #fff;
  border: 2.5px solid #14100d;
  box-shadow: 5px 5px 0 #fe6201;
  overflow: hidden;
  animation: cardPop 0.14s cubic-bezier(.2, .9, .3, 1) both;
}
.slot-ctx.open {
  display: flex;
}
.slot-ctx-head {
  padding: 0.55cqh 0.9cqw;
  background: #18120e;
  color: #fe6201;
  font-family: Consolas, monospace;
  font-size: 1.35cqh;
  font-weight: 900;
  letter-spacing: 0.1em;
}
.slot-ctx-del {
  text-align: left;
  padding: 0.85cqh 0.95cqw;
  background: #fff;
  color: #b22222;
  font-size: 1.55cqh;
  font-weight: 900;
  letter-spacing: 0.06em;
  transition: background 0.12s ease, color 0.12s ease;
}
.slot-ctx-del:hover {
  background: #fff0ee;
}
.slot-ctx-del.arm {
  background: #b22222;
  color: #fff;
}

/* Pixel Keke Mascot on Memory Gallery & Archive Pages */
.gallery-wrap { padding-bottom: 13cqh; }
.viewer-body { padding-bottom: 12cqh; }
.page-mascot {
  position: absolute;
  right: 2.2cqw;
  bottom: 1.4cqh;
  z-index: 38;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}
.page-mascot.in-viewer {
  right: 1.4cqw;
  bottom: 0.8cqh;
  z-index: 6;
}
.mascot-canvas {
  width: 8.6cqw;
  height: 14.5cqh;
  display: block;
  cursor: pointer;
  pointer-events: auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.mascot-tip {
  margin-bottom: -1.1cqh;
  padding: 0.3cqh 0.7cqw;
  background: #18120e;
  color: #fffaf4;
  border: 2px solid #14100d;
  border-left: 4px solid #fe6201;
  box-shadow: 3px 3px 0 #fe6201;
  font-size: 1.3cqh;
  font-weight: 800;
  letter-spacing: 0.05em;
  white-space: nowrap;
  transform: skewX(-8deg) translateY(4px);
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}
.page-mascot:hover .mascot-tip,
.page-mascot.say .mascot-tip {
  opacity: 1;
  transform: skewX(-8deg) translateY(0);
}

/* ===== Settings Subpage ===== */
.settings-grid {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 44%) minmax(0, 1fr);
  gap: 2.0cqw;
  align-items: stretch;
  align-content: start;
  overflow-y: auto;
  padding: 0.4cqh 0.4cqw 2.4cqh 0.2cqw;
}
.settings-col {
  display: flex;
  flex-direction: column;
  gap: 2.2cqh;
  min-height: 0;
}
.set-card {
  display: flex;
  flex-direction: column;
  padding: 2.0cqh 1.8cqw 2.0cqh;
  background: #fff;
  color: #14100d;
  border: 2.5px solid #14100d;
  box-shadow: 6px 6px 0 #14100d;
  animation: cardPop 0.26s cubic-bezier(.2, .9, .3, 1) both;
}
.set-card.link-card {
  justify-content: flex-start;
  border-left: 6px solid #fe6201;
}
.set-card.rest-card {
  background: #18120e;
  color: #fffaf4;
  box-shadow: 6px 6px 0 #fe6201;
}
.set-card-head {
  display: flex;
  align-items: center;
  gap: 0.75cqw;
  margin-bottom: 1.0cqh;
}
.set-tag {
  display: inline-block;
  padding: 0.2cqh 0.6cqw;
  background: #14100d;
  color: #fff;
  font-family: Consolas, monospace;
  font-size: 1.45cqh;
  font-weight: 900;
  letter-spacing: 0.08em;
  transform: skewX(-12deg);
}
.set-tag.orange {
  background: #fe6201;
  color: #14100d;
  border: 2px solid #14100d;
}
.set-card h2 {
  margin: 0;
  font-size: 2.35cqh;
  font-weight: 900;
  letter-spacing: 0.08em;
}
.set-desc {
  margin: 0 0 1.4cqh;
  font-size: 1.5cqh;
  font-weight: 600;
  line-height: 1.5;
  color: rgba(20, 16, 13, 0.65);
}
.set-card.rest-card .set-desc {
  color: rgba(255, 250, 244, 0.72);
}
.set-pills {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.7cqw;
}
.set-pills.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.set-pills button {
  text-align: center;
  padding: 1.05cqh 0.4cqw;
  background: #fff;
  color: #14100d;
  border: 2.5px solid #14100d;
  box-shadow: 3px 3px 0 #14100d;
  font-size: 1.75cqh;
  font-weight: 900;
  letter-spacing: 0.1em;
  transition: transform 0.08s ease, box-shadow 0.1s ease, background 0.12s ease;
}
.set-pills button:hover {
  background: #fff3e8;
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 #fe6201;
}
.set-pills button[aria-selected="true"],
.set-pills button[aria-pressed="true"] {
  background: #fe6201;
  color: #14100d;
  box-shadow: 3px 3px 0 #14100d;
}
.set-form {
  display: flex;
  flex-direction: column;
  gap: 0.7cqh;
  margin-top: 0.4cqh;
}
.set-field {
  display: flex;
  flex-direction: column;
  gap: 0.55cqh;
  margin-top: 0.8cqh;
  font-size: 1.6cqh;
  font-weight: 900;
  color: #14100d;
}
.set-field input,
.set-field select {
  width: 100%;
  padding: 0.95cqh 0.95cqw;
  background: #fbfaf7;
  color: #14100d;
  border: 2.5px solid #14100d;
  box-shadow: 3px 3px 0 #14100d;
  font-size: 1.65cqh;
  font-weight: 700;
  outline: none;
  transition: box-shadow 0.12s ease, background 0.12s ease;
}
.set-field input:focus,
.set-field select:focus {
  background: #fff;
  box-shadow: 3px 3px 0 #fe6201;
}
.set-note {
  margin: 0.15cqh 0 0;
  font-size: 1.4cqh;
  font-weight: 600;
  line-height: 1.45;
  color: rgba(20, 16, 13, 0.6);
}
.set-note.warn {
  color: #c84b00;
  font-weight: 800;
}
.set-note:empty {
  display: none;
}
.set-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1.0cqw;
  margin-top: auto;
  padding-top: 2.0cqh;
  border-top: 2px dashed rgba(20, 16, 13, 0.18);
}
.set-btn {
  padding: 0.95cqh 1.6cqw;
  border: 2.5px solid #14100d;
  box-shadow: 3px 3px 0 #14100d;
  font-size: 1.65cqh;
  font-weight: 900;
  letter-spacing: 0.08em;
  transform: skewX(-8deg);
  transition: transform 0.08s ease, box-shadow 0.1s ease;
}
.set-btn.secondary {
  background: #fff;
  color: #14100d;
}
.set-btn.primary {
  background: #fe6201;
  color: #14100d;
}
.set-btn:hover {
  transform: skewX(-8deg) translate(-1px, -1px);
  box-shadow: 4px 4px 0 #14100d;
}
.set-btn:active {
  transform: skewX(-8deg) translate(2px, 2px);
  box-shadow: 1px 1px 0 #14100d;
}
.set-danger {
  align-self: flex-start;
  padding: 0.95cqh 1.8cqw;
  background: #fe6201;
  color: #14100d;
  border: 2.5px solid #fffaf4;
  box-shadow: 4px 4px 0 rgba(255, 250, 244, 0.28);
  font-size: 1.7cqh;
  font-weight: 900;
  letter-spacing: 0.1em;
  transform: skewX(-8deg);
  transition: transform 0.08s ease, filter 0.12s ease;
}
.set-danger:hover {
  filter: brightness(1.06);
  transform: skewX(-8deg) translate(-1px, -1px);
}

/* Audio & Mixer Card inside Settings */
.settings-grid::-webkit-scrollbar { width: 8px; }
.settings-grid::-webkit-scrollbar-thumb { background: #fe6201; }
.set-card.audio-card {
  border-left: 6px solid #fe6201;
}
.mix-reset {
  margin-left: auto;
  padding: 0.3cqh 0.7cqw;
  background: #fff;
  color: #14100d;
  border: 2px solid #14100d;
  box-shadow: 2px 2px 0 #14100d;
  font-size: 1.3cqh;
  font-weight: 900;
  letter-spacing: 0.08em;
  transform: skewX(-8deg);
  transition: transform 0.08s ease, box-shadow 0.1s ease, background 0.12s ease;
}
.mix-reset:hover {
  background: #fff3e8;
  transform: skewX(-8deg) translate(-1px, -1px);
  box-shadow: 3px 3px 0 #fe6201;
}
.mix-list {
  display: flex;
  flex-direction: column;
  gap: 1.15cqh;
  margin-top: 0.35cqh;
}
.mix-row {
  display: grid;
  grid-template-columns: auto 6.8cqw minmax(0, 1fr) 3.4cqw;
  align-items: center;
  gap: 0.75cqw;
  transition: opacity 0.14s ease;
}
.mix-row.master {
  padding-bottom: 1.0cqh;
  border-bottom: 2px dashed rgba(20, 16, 13, 0.18);
}
.mix-row.muted,
.mix-list.all-muted .mix-row:not(.master) {
  opacity: 0.48;
}
.mix-mute {
  width: 3.6cqw;
  text-align: center;
  padding: 0.32cqh 0.3cqw;
  background: #fe6201;
  color: #14100d;
  border: 2px solid #14100d;
  box-shadow: 2px 2px 0 #14100d;
  font-family: Consolas, monospace;
  font-size: 1.22cqh;
  font-weight: 900;
  letter-spacing: 0.06em;
  transform: skewX(-8deg);
  transition: background 0.12s ease, color 0.12s ease, transform 0.08s ease;
}
.mix-mute:hover {
  transform: skewX(-8deg) translate(-1px, -1px);
}
.mix-mute[aria-pressed="true"] {
  background: #14100d;
  color: #fffaf4;
  box-shadow: 2px 2px 0 rgba(20, 16, 13, 0.35);
}
.mix-label {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.mix-label strong {
  font-size: 1.55cqh;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: #14100d;
}
.mix-label small {
  font-family: Consolas, monospace;
  font-size: 1.02cqh;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: rgba(20, 16, 13, 0.46);
}
.mix-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 1.15cqh;
  margin: 0;
  background: linear-gradient(
    to right,
    #fe6201 0%,
    #fe6201 var(--pct, 80%),
    #efe9df var(--pct, 80%),
    #efe9df 100%
  );
  border: 2px solid #14100d;
  box-shadow: 2px 2px 0 #14100d;
  cursor: pointer;
  outline: none;
}
.mix-row.muted .mix-slider,
.mix-list.all-muted .mix-row:not(.master) .mix-slider {
  background: linear-gradient(
    to right,
    #7a7169 0%,
    #7a7169 var(--pct, 80%),
    #efe9df var(--pct, 80%),
    #efe9df 100%
  );
}
.mix-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 1.25cqw;
  height: 2.2cqh;
  background: #14100d;
  border: 2px solid #fffaf4;
  box-shadow: 2px 2px 0 #fe6201;
  transform: skewX(-10deg);
  cursor: pointer;
  transition: transform 0.08s ease, background 0.1s ease;
}
.mix-slider:hover::-webkit-slider-thumb,
.mix-slider:focus-visible::-webkit-slider-thumb {
  background: #fe6201;
  border-color: #14100d;
  box-shadow: 2px 2px 0 #14100d;
  transform: skewX(-10deg) scale(1.08);
}
.mix-val {
  text-align: right;
  font-family: Consolas, monospace;
  font-size: 1.45cqh;
  font-weight: 900;
  letter-spacing: 0.02em;
  color: #14100d;
}

/* ===== Shared Additions: Attachment Strip, Push/PIN Settings & Remote Unlock Gate ===== */
.mobile-stage-toggle {
  display: none;
}
.attach-btn {
  display: none;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  color: #14100d;
  border-radius: 2px;
  transition: color 0.14s ease, background 0.14s ease;
}
.attach-btn svg {
  width: 21px;
  height: 21px;
  display: block;
}
.attach-btn:hover,
.attach-btn:active {
  color: #fe6201;
  background: rgba(254, 98, 1, 0.1);
}
.attach-strip {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 6px);
  z-index: 8;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  pointer-events: auto;
}
.attach-strip[hidden] {
  display: none;
}
.attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 200px;
  padding: 4px 8px;
  background: #14100d;
  color: #fffaf4;
  border: 2px solid #fe6201;
  box-shadow: 2px 2px 0 #14100d;
  font-size: 12px;
  font-weight: 800;
}
.attach-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attach-chip button {
  color: #fe6201;
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
  padding: 0 2px;
}

.set-card.mobile-card {
  border-left: 6px solid #14100d;
}
.set-pin-form {
  margin-top: 1.2cqh;
  padding-top: 1.1cqh;
  border-top: 2px dashed rgba(20, 16, 13, 0.16);
}
.pin-gate {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 11, 9, 0.82);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.pin-gate.open {
  opacity: 1;
  pointer-events: auto;
}
.pin-card {
  width: min(100%, 360px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 22px 20px 20px;
  background: #fff;
  color: #14100d;
  border: 3px solid #14100d;
  box-shadow: 7px 7px 0 #fe6201;
}
.pin-card h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0.08em;
}
.pin-card .set-desc {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
}
.pin-card input {
  width: 100%;
  padding: 11px 12px;
  font-size: 16px;
  font-weight: 700;
  background: #fffaf4;
  border: 2.5px solid #14100d;
  box-shadow: 3px 3px 0 #14100d;
  outline: none;
}
.pin-card input:focus {
  border-color: #fe6201;
}
.pin-card .set-btn {
  width: 100%;
  padding: 11px 14px;
  font-size: 15px;
}

.mobile-del-slot,
.mobile-archive-back {
  display: none;
}

/* ===== iOS / Mobile Portrait Responsive Layout (<= 820px) ===== */
@media (max-width: 820px) {
  :root {
    --dialogue-cq: 15px;
    --hist-cq: 14.5px;
  }
  .stage.size-s { --dialogue-cq: 13.5px; --hist-cq: 13px; }
  .stage.size-m { --dialogue-cq: 15px; --hist-cq: 14.5px; }
  .stage.size-l { --dialogue-cq: 17px; --hist-cq: 16.5px; }

  html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    -webkit-text-size-adjust: 100%;
    touch-action: manipulation;
  }
  body {
    display: block;
  }
  .winbar {
    display: none !important;
  }
  .stage {
    position: fixed;
    inset: 0;
    aspect-ratio: auto;
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
  }
  .desk {
    position: relative;
    left: auto;
    right: auto;
    top: auto;
    bottom: auto;
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr) auto auto;
    gap: 6px 8px;
    padding: 8px 10px 8px;
    pointer-events: auto;
  }

  /* Flatten wrappers via display:contents so Top Room is full-width and Bottom Avatar sits beside Output Bubble */
  .left-col,
  .left-bottom,
  .column {
    display: contents;
  }
  .live-actions,
  .share-hud {
    display: none !important;
  }

  /* Row 1: Full-width spacious Isometric Pixel Room */
  .room-panel {
    grid-column: 1 / -1;
    grid-row: 1;
    min-width: 0;
  }
  .room-box {
    gap: 6px;
  }
  .room-viewport {
    aspect-ratio: auto;
    height: 174px;
    max-height: 24dvh;
  }
  .room-meta {
    gap: 6px;
    padding: 0;
  }
  .room-dot {
    width: 8px;
    height: 8px;
  }
  .room-status {
    font-size: 12px;
    padding: 2px 8px;
    border-width: 1.5px;
    box-shadow: 2px 2px 0 #1a120c;
  }
  .room-tip {
    display: none;
  }
  .mobile-stage-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    padding: 2px 10px;
    background: #14100d;
    color: #fffaf4;
    border: 1.5px solid #14100d;
    box-shadow: 2px 2px 0 #fe6201;
    font-size: 11.5px;
    font-weight: 800;
    letter-spacing: 0.06em;
  }
  .room-controls {
    gap: 6px;
  }
  .room-controls button {
    font-size: 12px;
    padding: 5px 4px;
    border-width: 1.5px;
    box-shadow: 2px 2px 0 #1a120c;
  }

  /* Row 2: Full-width sleek horizontal P5 Command Dock */
  .cmd-dock {
    position: relative;
    left: auto;
    right: auto;
    top: auto;
    bottom: auto;
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    flex-direction: row;
    gap: 8px;
    height: 36px;
  }
  .cmd-past .cmd-btn,
  .cmd-memory .cmd-btn,
  .cmd-settings .cmd-btn {
    transform: none;
    padding: 2px 2px 2px 5px;
  }
  .cmd-past .cmd-shadow,
  .cmd-memory .cmd-shadow,
  .cmd-settings .cmd-shadow {
    transform: translate(3px, 3px);
  }
  .cmd-face {
    justify-content: center;
    gap: 6px;
    padding: 0 8px;
  }
  .cmd-ico {
    width: 17px;
    height: 17px;
  }
  .cmd-text {
    flex-direction: row;
    align-items: baseline;
    gap: 4px;
  }
  .cmd-text strong {
    font-size: 13.5px;
    letter-spacing: 0.08em;
  }
  .cmd-text small {
    display: none;
  }

  /* Compact Hero Mode: folds only the top room so chat + bottom avatar stay super roomy */
  body.mobile-stage-compact .room-viewport,
  body.mobile-stage-compact .room-controls {
    display: none;
  }
  body.mobile-stage-compact .cmd-dock {
    height: 32px;
  }

  /* Row 3: Full-width Dialogue History */
  .log {
    grid-column: 1 / -1;
    grid-row: 3;
    min-height: 0;
    padding: 4px 2px 6px;
    gap: 10px;
    -webkit-overflow-scrolling: touch;
  }
  .hist-card {
    max-width: 90%;
    padding: 10px 12px 9px;
    border-width: 2px;
    box-shadow: 3px 3px 0 #14100d;
  }
  .hist-card.you {
    box-shadow: 3px 3px 0 #fe6201;
  }
  .hist-card .hist-tag {
    font-size: 10px;
    padding: 1px 6px;
    margin-bottom: 4px;
  }
  .hist-card .txt {
    font-size: var(--hist-cq);
    line-height: 1.55;
  }

  /* Row 4, Col 1: Compact Keke Avatar aligned directly alongside her Output Bubble */
  .portrait-slot {
    position: relative;
    left: auto;
    right: auto;
    top: auto;
    bottom: auto;
    grid-column: 1;
    grid-row: 4;
    align-self: end;
    width: 88px;
    height: 86px;
    min-height: 86px;
    pointer-events: auto;
  }
  .portrait-bg {
    left: 2%;
    right: 2%;
    top: 16%;
    border-width: 2px;
    box-shadow: 3px 3px 0 #fe6201;
  }
  .portrait-bg::after {
    inset: 3px;
    border-width: 1px;
  }
  .pbg-corner {
    width: 7px;
    height: 7px;
  }
  .pbg-corner.tl {
    left: 5px;
    top: 5px;
    border-top-width: 2px;
    border-left-width: 2px;
  }
  .pbg-corner.br {
    right: 5px;
    bottom: 5px;
    border-right-width: 2px;
    border-bottom-width: 2px;
  }
  .pbg-marks,
  .pbg-tag {
    display: none;
  }

  /* Row 4, Col 2: P5 Output Bubble popping out right beside Keke's compact portrait */
  .output-zone {
    grid-column: 2;
    grid-row: 4;
    align-self: end;
    min-width: 0;
    height: auto;
    min-height: 86px;
    padding: 10px 0 0;
    align-items: flex-end;
  }
  .output-bubble {
    --tail-w: 14px;
    width: 100%;
    max-width: 100%;
    max-height: 26dvh;
    min-height: 74px;
  }
  .output-nameplate {
    top: -12px;
    left: 22px;
    padding: 2px 8px;
    gap: 4px;
  }
  .output-nameplate .np-main {
    font-size: 12px;
  }
  .output-nameplate .np-sub {
    font-size: 9px;
    padding: 1px 4px;
  }
  .output-scroll {
    padding: 16px 12px 12px 14px;
  }
  .output-text {
    font-size: var(--dialogue-cq);
    line-height: 1.54;
  }
  .output-cont {
    right: 10px;
    bottom: 5px;
    font-size: 10.5px;
  }

  /* Row 5: Full-width Touch-friendly Composer (16px textarea stops iOS Safari auto-zoom) */
  .composer {
    position: relative;
    grid-column: 1 / -1;
    grid-row: 5;
    height: auto;
    min-height: 44px;
    gap: 6px;
    padding-top: 2px;
  }
  .input-shell {
    min-height: 42px;
    padding: 2px 3px;
    gap: 2px;
    border-width: 2.5px;
    box-shadow: 3px 3px 0 #fe6201;
  }
  .attach-btn {
    display: inline-flex;
    width: 32px;
    height: 32px;
  }
  .attach-btn svg {
    width: 19px;
    height: 19px;
  }
  #say {
    font-size: 16px;
    line-height: 1.3;
    padding: 8px 2px;
    min-height: 38px;
    max-height: 104px;
  }
  .voice-btn {
    width: 32px;
    height: 32px;
  }
  .voice-btn svg {
    width: 18px;
    height: 18px;
  }
  .send {
    min-width: 58px;
    height: 42px;
    padding: 0 10px;
    font-size: 14.5px;
    border-width: 2.5px;
    box-shadow: 3px 3px 0 #14100d;
  }
  .voice-bar {
    padding: 0 10px;
    gap: 8px;
  }
  .voice-bar-status,
  .voice-bar-time,
  .voice-bar-btn {
    font-size: 12px;
  }

  /* Mobile Subpages: Fullscreen Safe-Area White P5 Canvas */
  .subpage {
    padding: calc(10px + env(safe-area-inset-top, 0px)) 12px calc(12px + env(safe-area-inset-bottom, 0px));
    gap: 10px;
  }
  .page-head {
    flex-wrap: wrap;
    gap: 8px;
    padding-bottom: 10px;
  }
  .page-kicker {
    font-size: 10.5px;
    padding: 2px 7px;
  }
  .page-title {
    font-size: 20px;
  }
  .page-count {
    font-size: 11px;
    padding: 2px 7px;
  }
  .page-actions {
    margin-left: auto;
    gap: 6px;
  }
  .page-btn {
    padding: 6px 12px;
    font-size: 13px;
    border-width: 2px;
    box-shadow: 3px 3px 0 #14100d;
  }
  .page-btn.back span {
    display: none;
  }
  .page-mascot {
    display: none !important;
  }

  /* Memory Gallery Mobile */
  .gallery-filters {
    order: 3;
    width: 100%;
    gap: 6px;
  }
  .gallery-filters button {
    flex: 1 1 0;
    padding: 6px 8px;
    font-size: 13px;
  }
  .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding-bottom: 20px;
  }
  .mem-card {
    min-height: 132px;
    padding: 10px 10px 9px;
    border-width: 2px;
    box-shadow: 4px 4px 0 #14100d;
  }
  .mem-no, .mem-layer, .mem-rev {
    font-size: 10px;
  }
  .mem-card-title {
    font-size: 14px;
    margin: 6px 0 4px;
  }
  .mem-card-excerpt {
    font-size: 12px;
  }
  .mem-card-foot {
    font-size: 11px;
    margin-top: 6px;
  }
  .mem-reader {
    width: calc(100vw - 20px);
    max-height: 82dvh;
    padding: 16px 14px 14px;
  }
  .reader-title {
    font-size: 18px;
  }
  .reader-body {
    font-size: 14.5px;
    line-height: 1.65;
  }
  .reader-foot {
    flex-wrap: wrap;
    gap: 8px;
  }
  .reader-file, .reader-del {
    font-size: 12px;
  }

  /* Archive Page Mobile: Vertical Scrollable Save-Slot List -> Dedicated Fullscreen Viewer */
  .archive-hint {
    display: none;
  }
  .archive-layout {
    display: block;
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
  }
  .slot-list {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    gap: 12px;
    padding: 4px 8px 24px 2px;
    -webkit-overflow-scrolling: touch;
  }
  .save-slot {
    flex: 0 0 auto;
    width: 100%;
    padding: 13px 14px 12px;
    border-width: 2.5px;
    box-shadow: 5px 5px 0 #14100d;
  }
  .save-slot::after {
    content: "点击查看 →";
    display: block;
    margin-top: 8px;
    text-align: right;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.08em;
    color: #fe6201;
  }
  .save-slot.on::after {
    color: #14100d;
  }
  .slot-code,
  .slot-tag {
    font-size: 11px;
    padding: 2px 8px;
  }
  .slot-time {
    font-size: 11px;
  }
  .slot-preview {
    font-size: 13.5px;
    line-height: 1.5;
    margin-top: 6px;
  }
  .archive-viewer {
    display: none;
    width: 100%;
    height: 100%;
  }
  .archive-page.mobile-viewing .slot-list {
    display: none;
  }
  .archive-page.mobile-viewing .archive-viewer {
    display: flex;
    flex-direction: column;
    animation: mobileViewerIn 0.22s cubic-bezier(.2, .9, .3, 1) both;
  }
  @keyframes mobileViewerIn {
    from { opacity: 0; transform: translateX(18px); }
    to { opacity: 1; transform: translateX(0); }
  }
  .viewer-head {
    padding: 10px 10px;
    gap: 8px;
    flex-wrap: nowrap;
  }
  .mobile-archive-back {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    padding: 4px 9px;
    background: #14100d;
    color: #fffaf4;
    border: 2px solid #14100d;
    box-shadow: 2px 2px 0 #fe6201;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.04em;
  }
  .viewer-title-row {
    min-width: 0;
    flex: 1 1 auto;
    gap: 6px;
  }
  .viewer-slot-tag {
    font-size: 11px;
    flex: 0 0 auto;
  }
  .viewer-time {
    font-size: 11.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .viewer-readonly {
    display: none;
  }
  .mobile-del-slot {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    padding: 4px 8px;
    background: #fff;
    color: #c83300;
    border: 2px solid #c83300;
    font-size: 11.5px;
    font-weight: 900;
  }
  .mobile-del-slot[hidden] {
    display: none;
  }
  .viewer-body {
    padding: 12px 10px 20px;
    gap: 10px;
    -webkit-overflow-scrolling: touch;
  }

  /* Settings Page Mobile: Single Column Flex Stack & 2-Row Audio Mixer (Zero Overlap, Zero Clipping) */
  .settings-grid {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 4px 8px 36px 4px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }
  .settings-col {
    display: flex;
    flex-direction: column;
    flex: 0 0 auto;
    min-height: auto;
    gap: 14px;
    min-width: 0;
    height: auto;
  }
  .set-card {
    flex: 0 0 auto;
    min-width: 0;
    padding: 14px 14px 14px;
    gap: 10px;
    border-width: 2.5px;
    box-shadow: 4px 4px 0 #14100d;
  }
  .set-card-head {
    gap: 8px;
    margin-bottom: 4px;
  }
  .set-tag {
    font-size: 11px;
    padding: 2px 7px;
  }
  .set-card-head h2 {
    font-size: 16px;
  }
  .set-desc {
    font-size: 13px;
    margin-bottom: 6px;
  }
  .set-note {
    font-size: 12px;
  }
  .set-pills button {
    padding: 10px 4px;
    font-size: 14px;
    border-width: 2px;
    box-shadow: 2px 2px 0 #14100d;
  }
  .set-field span {
    font-size: 13px;
  }
  .set-field input,
  .set-field select {
    font-size: 16px;
    padding: 9px 10px;
  }
  .set-actions {
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 12px;
  }
  .set-btn,
  .set-danger {
    font-size: 14px;
    padding: 10px 14px;
  }
  .mix-reset {
    font-size: 12px;
    padding: 4px 10px;
  }
  .mix-list {
    gap: 14px;
    margin-top: 4px;
  }
  .mix-row {
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr) auto;
    grid-template-areas:
      "mute label val"
      "slider slider slider";
    align-items: center;
    gap: 7px 10px;
  }
  .mix-row.master {
    padding-bottom: 12px;
  }
  .mix-mute {
    grid-area: mute;
    width: 46px;
    font-size: 11.5px;
    padding: 5px 2px;
  }
  .mix-label {
    grid-area: label;
    flex-direction: row;
    align-items: baseline;
    gap: 6px;
    min-width: 0;
  }
  .mix-label strong {
    font-size: 13.5px;
  }
  .mix-label small {
    font-size: 10px;
  }
  .mix-val {
    grid-area: val;
    min-width: 40px;
    text-align: right;
    font-size: 13px;
  }
  .mix-slider {
    grid-area: slider;
    min-width: 0;
    width: 100%;
    height: 14px;
  }
  .mix-slider::-webkit-slider-thumb {
    width: 20px;
    height: 24px;
  }

  /* Sleep & Toast Mobile */
  .sleep-card {
    width: min(90vw, 320px);
    padding: 24px 20px;
  }
  .sleep-card p {
    font-size: 18px;
  }
  .wake {
    font-size: 15px;
    padding: 10px 22px;
  }
  .toast {
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    font-size: 13px;
    padding: 8px 14px;
    max-width: calc(100vw - 32px);
  }
  .boot-skip {
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  }
}
