:root {
  color-scheme: dark;
  --bg: #0b0b0c;
  --panel: #202024;
  --panel-2: #39393f;
  --muted: #a7a6ad;
  --line: #34343a;
  --accent: #6b5ff1;
  --accent-2: #675de4;
  --text: #ffffff;
  --safe-bottom: env(safe-area-inset-bottom);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #050506; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
img, video { max-width: 100%; }

#app {
  min-height: 100%;
}

.phone {
  width: min(100vw, 430px);
  height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  color: var(--text);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.stage {
  flex: 1;
  min-height: 0;
  position: relative;
}

.scroller {
  height: 100%;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.feed, .profile {
  height: 100%;
  padding: 12px 12px 150px;
}
.profile { padding: 12px 16px 36px; }

.masonry {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.column { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }

.tile {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 2px;
  overflow: hidden;
  background: #202023;
  aspect-ratio: 3 / 4;
  position: relative;
}

.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.tile-shade {
  position: absolute;
  inset: auto 0 0;
  height: 42%;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.72));
  pointer-events: none;
}

.tile-name {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 10px;
  z-index: 1;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.85);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.fab {
  position: absolute;
  left: 32px;
  right: 32px;
  bottom: 18px;
  height: 48px;
  border: 0;
  border-radius: 24px;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

.fab small { display: block; font-size: 10px; line-height: 1; opacity: 0.95; }
.fab strong { display: block; font-size: 14px; font-weight: 500; line-height: 1; margin-bottom: 2px; }
.fab span { text-align: left; }

.tabbar {
  height: calc(86px + var(--safe-bottom));
  padding: 8px 28px calc(14px + var(--safe-bottom));
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
}

.icon-btn {
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  color: #a8a8ae;
  display: grid;
  place-items: center;
  padding: 0;
}

.icon-btn.active { color: var(--accent); }

.segment {
  width: 142px;
  height: 42px;
  background: #aaaaaa;
  border-radius: 22px;
  display: flex;
  padding: 0;
}

.segment button {
  flex: 1;
  border: 0;
  background: transparent;
  color: white;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
}

.segment button.active { background: #737376; }

.center-state {
  min-height: 70%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: #929197;
  text-align: center;
  padding: 24px;
}

.primary, .ghost, .pill {
  border: 0;
  border-radius: 26px;
  min-height: 48px;
}

.primary {
  background: var(--accent-2);
  color: white;
  padding: 0 18px;
}

.primary:disabled, .pill:disabled { background: #3f3d57; color: #bab8c1; }

.mask, .sheet-mask, .dialog-mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.54);
  z-index: 20;
  display: flex;
}

.sheet-mask, .source-mask { align-items: flex-end; }
.dialog-mask, .busy-mask { align-items: center; justify-content: center; }

.sheet, .source-sheet, .credits-sheet {
  width: 100%;
  background: linear-gradient(#111137, #18181c);
  border-radius: 28px 28px 0 0;
  padding: 12px 12px calc(24px + var(--safe-bottom));
  max-height: min(92dvh, calc(var(--vvh, 100dvh) - 24px));
  overflow: auto;
}

.sheet-close {
  margin-left: auto;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: white;
  width: 40px;
  height: 28px;
  padding: 0;
}

.prompt-box {
  background: var(--panel-2);
  border-radius: 14px;
  padding: 8px;
}

.ref-slot {
  width: 88px;
  height: 88px;
  border: 0;
  border-radius: 7px;
  overflow: hidden;
  background: #565660;
  color: #a7a6ad;
  padding: 0;
  display: block;
  position: relative;
}

.ref-slot img { width: 100%; height: 100%; object-fit: cover; }
.ref-slot span, .ref-slot em {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  white-space: pre-line;
  font-style: normal;
  font-size: 12px;
  line-height: 1.15;
}
.ref-slot em { color: white; font-weight: 700; text-shadow: 0 1px 4px #000; background: linear-gradient(transparent, rgba(0,0,0,.2)); }

.prompt-box textarea {
  width: 100%;
  height: 94px;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  color: white;
  margin-top: 10px;
  padding-right: 8px;
}

.counter { text-align: right; color: #b0aeb7; font-size: 14px; }

.duration-label { color: #8d8b96; font-size: 14px; margin: 16px 0 8px; }
.duration-row { display: flex; gap: 4px; }
.chip {
  width: 56px;
  height: 64px;
  border: 0;
  border-radius: 7px;
  background: #39393f;
  color: white;
}
.chip.active { background: #6a6580; }

.actions { display: flex; gap: 8px; margin-top: 24px; }
.pill {
  flex: 1;
  background: #3d3d43;
  color: #bab8c1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.pill.enabled { background: var(--accent); color: white; }
.pill small { display: block; font-size: 10px; line-height: 1.05; }
.pill b { display: block; font-size: 14px; font-weight: 500; line-height: 1.05; }

.source-sheet, .language-sheet {
  background: #101014;
  border-radius: 20px 20px 0 0;
  padding: 8px 0 calc(12px + var(--safe-bottom));
}
.source-sheet button, .language-sheet button {
  width: 100%;
  text-align: left;
  background: transparent;
  color: white;
  border: 0;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
}

.profile { overflow: auto; }

.profile-top, .history-tabs { display: flex; align-items: center; }
.profile-top { justify-content: space-between; }
.credits-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #242429;
  color: white;
  border: 0;
  border-radius: 26px;
  padding: 2px 8px 2px 2px;
}
.credits-btn b { display: block; font-size: 14px; line-height: 1; }
.credits-btn small { display: block; font-size: 10px; }
.avatar-wrap { display: flex; flex-direction: column; align-items: center; margin-top: 28px; }
.avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 1px solid #d4d4d4;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 30% 20%, #8d84ff, #241a55 62%, #111);
  font-size: 32px;
  font-weight: 700;
}
.brand { margin: 14px 0 22px; font-size: 20px; font-weight: 600; }
.history-tabs { height: 76px; }
.history-tabs button {
  flex: 1;
  background: transparent;
  border: 0;
  color: #aaaaaa;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
}
.history-tabs button.active { color: white; }
.history-tabs .split { width: 1px; height: 56px; background: var(--line); }

.history-grid {
  margin-top: 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.history-card {
  position: relative;
  aspect-ratio: 0.82;
  border-radius: 6px;
  overflow: hidden;
  background: #202023;
  border: 0;
  color: white;
  padding: 0;
  text-align: left;
}
.history-card img, .history-card video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.history-card .shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(transparent 55%, rgba(0,0,0,.7));
  pointer-events: none;
}
.history-card .meta {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  font-size: 12px;
  pointer-events: none;
}
.history-card .meta time { display: block; color: #c4c3c8; font-size: 11px; margin-top: 3px; }
.history-card .del {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 16px;
  background: rgba(0,0,0,.4);
  color: white;
}
.ring {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.play-badge {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: rgba(0,0,0,.67);
  display: grid;
  place-items: center;
}

.credits-sheet { padding: 14px 18px calc(22px + var(--safe-bottom)); }
.credits-sheet h2 { text-align: center; margin: 4px 0 8px; font-size: 25px; letter-spacing: 0.04em; }
.credits-sheet .hint { text-align: center; color: #b7b6bd; margin: 0 0 18px; }
.package-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.package {
  background: #37373d;
  color: white;
  border: 1.5px solid transparent;
  border-radius: 16px;
  min-height: 84px;
  padding: 12px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.package.active { background: #505056; border-color: white; }
.package strong {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
}
.package strong em { font-style: normal; }
.package .coin-ico {
  display: inline-flex;
  width: 18px;
  height: 18px;
  color: #f0c35a;
}
.package .coin-ico svg { width: 18px; height: 18px; }
.package span { display: block; margin-top: 14px; color: #aaa; font-size: 12px; font-weight: 400; }
.pay-section { margin-top: 16px; }
.pay-label {
  color: #b7b6bd;
  font-size: 13px;
  margin-bottom: 8px;
}
.pay-list {
  max-height: 160px;
  overflow: auto;
  display: flex;
  flex-direction: column;
}
.pay-option {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 0;
  border-bottom: 1px solid rgba(74, 74, 82, 0.2);
  background: transparent;
  color: #c4c3c8;
  padding: 10px 0;
  text-align: left;
}
.pay-option:last-child { border-bottom: 0; }
.pay-option.active { color: #ffffff; }
.pay-name {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  line-height: 1.3;
}
.pay-radio {
  width: 20px;
  height: 20px;
  flex: none;
  border-radius: 50%;
  border: 1.5px solid #aaa8b2;
  display: grid;
  place-items: center;
  background: transparent;
}
.pay-option.active .pay-radio {
  border-color: #675de4;
}
.pay-option.active .pay-radio::after {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #675de4;
}
.balance-line { text-align: center; margin: 18px 0; color: #b7b6bd; font-size: 15px; font-weight: 600; }
.balance-line b { color: white; font-size: 22px; margin-left: 8px; font-weight: 800; }
.wide { width: 100%; height: 56px; border-radius: 28px; font-size: 18px; }

.login {
  min-height: 100dvh;
  background:
    radial-gradient(80% 45% at 50% 18%, rgba(120, 92, 255, 0.45), transparent 70%),
    linear-gradient(#15110f, #26202a 46%, #08080b);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.login-panel {
  background: linear-gradient(#f7f4ff, #fcfbff);
  color: black;
  border-radius: 42px 42px 0 0;
  padding: 58px 32px calc(20px + var(--safe-bottom));
  min-height: 277px;
}
.login-panel h1 { margin: 0; text-align: center; font-size: 27px; letter-spacing: 0; }
.login-panel .primary { width: 100%; height: 57px; margin-top: 52px; border-radius: 29px; background: #6a61e8; font-size: 17px; }
.agreement { display: flex; gap: 8px; align-items: flex-start; margin-top: 28px; color: #8d8d92; font-size: 14px; line-height: 1.35; }
.agreement input { appearance: none; width: 17px; height: 17px; margin-top: 2px; border: 1.8px solid #6a61e8; border-radius: 2px; background: transparent; flex: none; }
.agreement input:checked { background: #6a61e8 url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill='white' d='M6.2 11.2 2.8 7.8l1.2-1.2 2.2 2.2 5-5 1.2 1.2z'/></svg>") center / 14px no-repeat; }
.agreement a { color: #6a61e8; text-decoration: none; }

.page {
  min-height: 100dvh;
  background: var(--bg);
  color: white;
}
.page-head {
  height: 52px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
}
.page-head h1 { font-size: 20px; margin: 0; }
.settings { padding: 12px 20px 32px; display: flex; flex-direction: column; gap: 12px; }
.setting {
  width: 100%;
  min-height: 68px;
  border: 0;
  border-radius: 8px;
  background: var(--panel);
  color: white;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  text-align: left;
}
.setting small { display: block; color: var(--muted); margin-top: 4px; }
.setting .grow { flex: 1; }

.detail { min-height: 100dvh; display: flex; flex-direction: column; padding: 6px 20px 20px 7px; }
.preview {
  flex: 1;
  min-height: 0;
  margin-top: 12px;
  border-radius: 8px;
  background: #0b0b0c;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.preview img, .preview video { width: 100%; height: 100%; object-fit: contain; background: black; }
.detail-actions { position: absolute; left: 12px; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 10px; }
.detail-actions .primary, .detail-actions .outline { height: 56px; border-radius: 28px; font-size: 17px; }
.outline { background: #191919; color: #b7b6bd; border: 1px solid #b7b6bd; }

.dialog-mask {
  padding: 24px 20px;
  overflow: auto;
}
.dialog-wrap {
  width: min(420px, 100%);
  position: relative;
  padding-top: 54px;
}
.dialog {
  width: 100%;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(149, 132, 255, 0.18), transparent 55%),
    linear-gradient(180deg, #f7f4ff 0%, #f9f8fe 48%, #ffffff 100%);
  color: black;
  border-radius: 28px;
  padding: 72px 20px 24px;
  position: relative;
  text-align: center;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
}
.dialog h2 {
  margin: 0;
  font-size: 28px;
  font-weight: 600;
  white-space: pre-line;
  line-height: 1.12;
  color: #111;
}
.dialog p {
  margin: 16px 0 0;
  color: #878787;
  font-size: 14px;
  line-height: 1.35;
}
.dialog-actions {
  margin-top: 40px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.dialog .primary,
.dialog .outline {
  width: 100%;
  height: 48px;
  border-radius: 24px;
  font-size: 16px;
  font-weight: 400;
}
.dialog .primary {
  background: #655be8;
  color: #fff;
  border: 0;
}
.dialog .outline {
  background: transparent;
  color: #37373d;
  border: 1.5px solid #34343a;
  border-radius: 26px;
  margin: 0;
}
.dialog-close {
  position: absolute;
  right: 8px;
  top: 12px;
  width: 40px;
  height: 28px;
  border: 0;
  padding: 0;
  display: grid;
  place-items: center;
  background: transparent;
  color: #4a4a52;
}
.dialog-close svg { width: 16px; height: 16px; }
.mascot {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  width: min(280px, 88%);
  height: 108px;
  z-index: 2;
  pointer-events: none;
  display: grid;
  place-items: center;
}
.mascot-glow {
  position: absolute;
  inset: 18px 12% auto;
  height: 54px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(122, 104, 255, 0.45), transparent 70%);
  filter: blur(8px);
}
.mascot-card {
  position: relative;
  min-width: 168px;
  height: 88px;
  padding: 14px 18px 12px;
  border-radius: 22px;
  background: linear-gradient(145deg, #6f63f3 0%, #4f3fd8 55%, #2d255f 100%);
  color: #fff;
  box-shadow: 0 14px 28px rgba(70, 56, 190, 0.38);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 2px;
}
.mascot-badge {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.16);
  display: grid;
  place-items: center;
  color: #fff;
}
.mascot-badge svg { width: 18px; height: 18px; }
.mascot-card strong {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.1;
}
.mascot-card small {
  font-size: 12px;
  opacity: 0.86;
}

.confirm {
  width: min(360px, calc(100% - 48px));
  background: #202024;
  color: white;
  border-radius: 16px;
  padding: 20px;
}
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; }
.confirm-actions button { background: transparent; border: 0; color: white; padding: 8px 12px; }
.danger { color: #ff6b6b !important; }

.toast {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: calc(24px + var(--safe-bottom));
  z-index: 40;
  background: rgba(0, 0, 0, 0.9);
  color: white;
  border-radius: 12px;
  padding: 12px 14px;
  text-align: center;
}

.busy {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.spinner {
  display: inline-block;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,.25);
  border-top-color: #8c83ff;
  animation: spin 0.8s linear infinite;
}
.spinner.small { width: 22px; height: 22px; border-width: 2px; border-top-color: white; }

.progress {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(#6b5ff1 calc(var(--p) * 1%), #45454b 0);
}
.progress span {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(11,11,12,.72);
  display: grid;
  place-items: center;
  font-size: 11px;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 800px) {
  body { display: grid; place-items: center; }
  #app { width: 430px; height: min(920px, 100dvh); }
  .phone { height: 100%; border-radius: 28px; box-shadow: 0 20px 80px rgba(0,0,0,.35); }
  .login, .page, .detail { height: 100%; border-radius: 28px; overflow: hidden; }
}
