/* ============================================================
   拉菲 · Live2D 互动预览
   ============================================================ */

:root {
  --ink: #07050e;
  --lav: #c9b7f0;
  --lav-dim: #8d7ec0;
  --pink: #f2b8dd;
  --paper: #f3eefc;
  --line: rgba(201, 183, 240, 0.16);
  --serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 背景 ---------- */
.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(120% 90% at 70% 10%, #1d1029 0%, transparent 60%),
    radial-gradient(90% 80% at 15% 90%, #121a2c 0%, transparent 62%),
    linear-gradient(160deg, #08050f 0%, #0b0716 50%, #05030b 100%);
}

/* ---------- 舞台 ---------- */
.backdrop {
  position: fixed;
  inset: -8%;
  z-index: 0;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  filter: blur(64px) saturate(1.1) brightness(.38);
  opacity: .55;
  transform: scale(1.04);
  transition: opacity .6s ease;
}

.bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(36% 52% at 50% 46%, rgba(150, 170, 220, .16), transparent 72%);
}

.stage {
  position: fixed;
  inset: 0;
  z-index: 1;
}
.stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: pointer;
  transition: filter .8s ease;
}
.stage canvas.is-grabbing { cursor: grabbing; }

body[data-theme="warm"] .stage canvas {
  filter: saturate(1.12) contrast(1.04) brightness(1.06) sepia(.1) hue-rotate(-6deg);
}
body[data-theme="night"] .stage canvas {
  filter: saturate(.85) brightness(.82) contrast(1.08) hue-rotate(8deg);
}

/* ---------- 压暗层 ---------- */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(5, 3, 11, .62) 0%, rgba(6, 4, 12, .18) 14%, rgba(6, 4, 12, 0) 30%),
    linear-gradient(to top, rgba(5, 3, 11, .88) 0%, rgba(6, 4, 12, .4) 16%, rgba(6, 4, 12, 0) 34%),
    radial-gradient(120% 90% at 50% 45%, transparent 55%, rgba(4, 2, 9, .55) 100%);
}

/* ---------- 顶部 ---------- */
.top {
  position: fixed;
  z-index: 4;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: clamp(18px, 2.6vw, 34px) clamp(18px, 3vw, 42px);
  pointer-events: none;
}

.ident__kicker {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 9.5px;
  letter-spacing: .3em;
  color: rgba(201, 183, 240, .55);
}
.ident__kicker .dot {
  width: 3px; height: 3px; border-radius: 50%;
  background: rgba(201, 183, 240, .5);
}

.ident__name {
  margin: 8px 0 0;
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-family: var(--serif);
  font-size: clamp(22px, 2.4vw, 30px);
  font-weight: 500;
  letter-spacing: .14em;
  color: rgba(255, 255, 255, .92);
  text-shadow: 0 6px 30px rgba(0, 0, 0, .55);
}
.ident__latin {
  font-family: var(--sans);
  font-size: 9.5px;
  letter-spacing: .44em;
  font-weight: 300;
  color: rgba(255, 255, 255, .34);
}

.tools { display: flex; align-items: center; gap: 8px; pointer-events: auto; }

.tool-group {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(10, 7, 20, .42);
  border: 1px solid var(--line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.tool {
  appearance: none;
  border: 0;
  background: transparent;
  color: rgba(243, 238, 252, .6);
  font-family: inherit;
  font-size: 11px;
  letter-spacing: .1em;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: color .25s, background .25s, transform .15s;
  white-space: nowrap;
}
.tool:hover { color: #fff; background: rgba(201, 183, 240, .12); }
.tool:active { transform: scale(.94); }
.tool.is-active {
  color: #1a1024;
  background: linear-gradient(180deg, #efe6ff, #cbb6f5);
}
.tool--toggle {
  border: 1px solid var(--line);
  background: rgba(10, 7, 20, .42);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding: 7px 13px;
}
.tool--toggle.is-active { color: #1a1024; background: linear-gradient(180deg, #efe6ff, #cbb6f5); }

.tool--icon {
  width: 32px; height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(10, 7, 20, .42);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  font-size: 15px;
  line-height: 1;
}
.tool--icon:hover { background: rgba(201, 183, 240, .16); }

/* ---------- 动作条 ---------- */
.bar {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: clamp(16px, 2.6vh, 28px);
  transform: translateX(-50%);
  max-width: calc(100vw - 28px);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(26, 20, 42, .72), rgba(12, 9, 23, .82));
  border: 1px solid var(--line);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .06);
  backdrop-filter: blur(20px) saturate(1.3);
  -webkit-backdrop-filter: blur(20px) saturate(1.3);
  animation: rise 1s cubic-bezier(.2,.7,.2,1) .2s both;
}

.bar__scroll {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
  max-width: min(72vw, 720px);
}
.bar__scroll::-webkit-scrollbar { display: none; }

.mo {
  appearance: none;
  border: 0;
  background: transparent;
  color: rgba(243, 238, 252, .62);
  font-family: inherit;
  font-size: 12px;
  letter-spacing: .1em;
  padding: 9px 15px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: color .2s, background .2s, transform .15s;
  position: relative;
}
.mo:hover { color: #fff; background: rgba(201, 183, 240, .12); }
.mo:active { transform: scale(.95); }
.mo.is-playing {
  color: #fff;
  background: linear-gradient(180deg, rgba(201, 183, 240, .34), rgba(154, 122, 220, .22));
  box-shadow: 0 0 0 1px rgba(201, 183, 240, .35), 0 6px 22px rgba(150, 110, 230, .35);
}

.bar__divider {
  width: 1px; height: 20px; margin: 0 4px;
  background: linear-gradient(to bottom, transparent, var(--line), transparent);
}
.bar__zoom { display: flex; gap: 2px; }


/* ---------- 动作面板 ---------- */
.bar__open {
  appearance: none;
  border: 0;
  background: transparent;
  color: rgba(243, 238, 252, .82);
  font-family: inherit;
  font-size: 12px;
  letter-spacing: .12em;
  padding: 8px 12px 8px 10px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background .2s, color .2s;
}
.bar__open:hover { background: rgba(201, 183, 240, .14); color: #fff; }
.bar__open-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--pink);
  box-shadow: 0 0 10px var(--pink);
}
.bar__count {
  font-size: 10px;
  letter-spacing: 0;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(201, 183, 240, .16);
  color: rgba(243, 238, 252, .7);
  font-variant-numeric: tabular-nums;
}
.bar__chev { opacity: .5; transition: transform .3s ease; }
.bar.is-open .bar__chev { transform: rotate(180deg); }

.sheet {
  position: fixed;
  inset: 0;
  z-index: 9;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(4, 2, 9, .5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity .3s ease, visibility .3s;
}
.sheet.is-open { opacity: 1; visibility: visible; }

.sheet__panel {
  width: min(760px, 100%);
  max-height: 58vh;
  display: flex;
  flex-direction: column;
  margin: 0 12px calc(72px + env(safe-area-inset-bottom, 0px));
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(26, 20, 42, .985), rgba(11, 8, 21, .99));
  border: 1px solid var(--line);
  box-shadow: 0 -10px 60px rgba(0, 0, 0, .6), inset 0 1px 0 rgba(255, 255, 255, .06);
  transform: translateY(16px) scale(.99);
  transition: transform .32s cubic-bezier(.2,.7,.2,1);
}
.sheet.is-open .sheet__panel { transform: translateY(0) scale(1); }

.sheet__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid rgba(201, 183, 240, .1);
}
.sheet__title {
  font-family: var(--serif);
  font-size: 14px;
  letter-spacing: .18em;
  color: rgba(255, 255, 255, .9);
}
.sheet__hint {
  font-size: 10.5px;
  letter-spacing: .1em;
  color: rgba(243, 238, 252, .32);
}
.sheet__close {
  margin-left: auto;
  appearance: none;
  border: 0;
  background: rgba(201, 183, 240, .1);
  color: rgba(243, 238, 252, .7);
  width: 26px; height: 26px;
  border-radius: 50%;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.sheet__close:hover { background: rgba(201, 183, 240, .22); color: #fff; }

.sheet__list--models { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
.sheet__list--models .mo { min-height: 52px; padding: 10px; font-size: 12.5px; letter-spacing: .02em; flex-direction: column; gap: 3px; }
.sheet__list--models .mo small { display: block; margin-top: 3px; font-size: 9.5px; letter-spacing: .1em; opacity: .45; }

.sheet__list {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 14px 16px 18px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 8px;
}
.sheet__list::-webkit-scrollbar { width: 6px; }
.sheet__list::-webkit-scrollbar-thumb { background: rgba(201, 183, 240, .22); border-radius: 3px; }

.sheet__group {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 2px 4px;
  font-size: 10.5px;
  letter-spacing: .18em;
  color: rgba(243, 238, 252, .44);
}
.sheet__group:first-child { padding-top: 2px; }
.sheet__group i {
  font-style: normal;
  font-size: 9.5px;
  letter-spacing: 0;
  padding: 1px 5px;
  border-radius: 999px;
  background: rgba(201, 183, 240, .12);
  color: rgba(243, 238, 252, .38);
}
.sheet__group::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, rgba(201, 183, 240, .16), transparent);
}

.sheet .mo {
  width: 100%;
  min-height: 38px;
  padding: 6px 8px;
  font-size: 12px;
  line-height: 1.35;
  letter-spacing: .04em;
  background: rgba(201, 183, 240, .07);
  border: 1px solid rgba(201, 183, 240, .08);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
  white-space: normal;
  word-break: break-word;
}

/* 移动端 */
@media (max-width: 760px) {
  .sheet .mo { min-height: 40px; padding: 6px 10px; font-size: 12.5px; letter-spacing: .02em; }
}
.sheet .mo:hover { background: rgba(201, 183, 240, .16); }
.sheet .mo.is-playing {
  color: #1a1024;
  background: linear-gradient(180deg, #efe6ff, #cbb6f5);
  border-color: transparent;
  box-shadow: 0 6px 22px rgba(150, 110, 230, .4);
}

/* ---------- 提示 ---------- */
.tip {
  position: fixed;
  z-index: 4;
  left: 50%;
  bottom: clamp(78px, 10vh, 98px);
  transform: translateX(-50%);
  margin: 0;
  font-size: 11px;
  letter-spacing: .16em;
  color: rgba(243, 238, 252, .42);
  text-align: center;
  white-space: nowrap;
  transition: opacity .8s ease;
  pointer-events: none;
  text-shadow: 0 2px 14px rgba(0, 0, 0, .7);
}
.tip b { color: rgba(243, 238, 252, .7); font-weight: 500; }
.tip.is-hidden { opacity: 0; }

/* ---------- 动作提示气泡 ---------- */
.toast {
  position: fixed;
  z-index: 6;
  top: clamp(74px, 9vh, 96px);
  left: 50%;
  transform: translate(-50%, -8px);
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 11.5px;
  letter-spacing: .16em;
  color: rgba(255, 255, 255, .9);
  background: rgba(18, 12, 30, .62);
  border: 1px solid rgba(201, 183, 240, .18);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .35s ease, transform .35s ease;
}
.toast.is-show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 加载 ---------- */
.loader {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: radial-gradient(80% 60% at 50% 45%, #0d0818 0%, #05030b 100%);
  transition: opacity .9s ease, visibility .9s;
}
.loader.is-hidden { opacity: 0; visibility: hidden; }
.loader__inner { text-align: center; }
.loader__ring { position: relative; display: inline-block; }
.loader__ring svg { transform: rotate(-90deg); }
.loader__track { fill: none; stroke: rgba(201, 183, 240, .12); stroke-width: 1.5; }
.loader__bar {
  fill: none;
  stroke: var(--lav);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-dasharray: 327;
  stroke-dashoffset: 327;
  transition: stroke-dashoffset .3s ease;
  filter: drop-shadow(0 0 6px rgba(201, 183, 240, .5));
}
.loader__percent {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 22px;
  color: rgba(243, 238, 252, .82);
  font-variant-numeric: tabular-nums;
}
.loader__percent::after {
  content: "%";
  font-size: 10px;
  margin-left: 2px;
  opacity: .45;
  align-self: center;
  margin-top: 8px;
}
.loader__title {
  margin: 24px 0 6px;
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: .32em;
  color: rgba(243, 238, 252, .82);
}
.loader__sub {
  margin: 0;
  font-size: 11px;
  letter-spacing: .14em;
  color: rgba(243, 238, 252, .3);
}

/* ---------- 错误 ---------- */
.fatal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgba(6, 4, 13, .92);
  padding: 24px;
}
.fatal[hidden] { display: none; }
.fatal__box {
  max-width: 440px;
  padding: 30px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(16, 12, 28, .7);
  text-align: center;
}
.fatal__box h2 { font-family: var(--serif); font-weight: 500; margin: 0 0 12px; letter-spacing: .1em; }
.fatal__box p { font-size: 12.5px; line-height: 1.9; color: rgba(243, 238, 252, .6); margin: 0 0 20px; }

/* ---------- 页脚 ---------- */
.footnote {
  position: fixed;
  z-index: 3;
  left: clamp(18px, 3vw, 42px);
  bottom: clamp(16px, 2.4vh, 24px);
  margin: 0;
  font-size: 9.5px;
  letter-spacing: .12em;
  color: rgba(243, 238, 252, .18);
  pointer-events: none;
}

@keyframes rise {
  from { opacity: 0; transform: translate(-50%, 14px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- 响应式 ---------- */
@media (max-width: 760px) {
  .top {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 14px 14px 0;
  }
  .tools {
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 6px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .tools::-webkit-scrollbar { display: none; }
  .tools > * { flex: 0 0 auto; }
  .ident__kicker { font-size: 8.5px; letter-spacing: .24em; }
  .bar { bottom: 12px; padding: 5px; gap: 2px; }
  .bar__zoom, .bar__divider { display: none; }
  .sheet__panel { margin: 0 8px calc(66px + env(safe-area-inset-bottom, 0px)); max-height: 62vh; }
  .sheet__list--models { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
.sheet__list--models .mo { min-height: 52px; padding: 10px; font-size: 12.5px; letter-spacing: .02em; flex-direction: column; gap: 3px; }
.sheet__list--models .mo small { display: block; margin-top: 3px; font-size: 9.5px; letter-spacing: .1em; opacity: .45; }

.sheet__list { grid-template-columns: repeat(2, 1fr); padding: 12px 12px 16px; }
  .sheet__hint { display: none; }
  .mo { padding: 8px 11px; font-size: 11.5px; }
  .tip {
    bottom: 76px;
    font-size: 10px;
    letter-spacing: .08em;
    white-space: normal;
    max-width: 80vw;
    line-height: 1.8;
  }
  .footnote { display: none; }
  .ident__name { font-size: 20px; }
  .tool-group .tool { padding: 6px 9px; font-size: 10.5px; }
}
