/* 星海 2.5.1 组件与全站视觉精修（Neon：亮暗双主题对比度修复 + 星海动态效果升级） */
@keyframes starsea-shimmer {
  0% { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}
@keyframes phone-slide-in {
  from { opacity: 0; transform: translate3d(16px, 8px, 0) scale(.985); }
  to { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}
@keyframes toast-drop-in {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
@keyframes dlg-bloom {
  from { opacity: 0; transform: translateY(10px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes sky-nebula-drift {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(1.6%, -1.2%, 0) scale(1.03); }
}
@keyframes starsea-dot-ripple {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--cyan, #7ce2f6) 55%, transparent), 0 0 8px var(--cyan, #7ce2f6); opacity: .95; }
  70% { box-shadow: 0 0 0 6px transparent, 0 0 12px var(--gold-glow); opacity: 1; }
  100% { box-shadow: 0 0 0 0 transparent, 0 0 8px var(--cyan, #7ce2f6); opacity: .95; }
}
@keyframes starsea-star-ripple {
  0% { box-shadow: 0 0 0 0 var(--gold-glow), 0 0 10px 2px var(--gold-glow); }
  68% { box-shadow: 0 0 0 6px transparent, 0 0 14px 3px var(--gold-glow); }
  100% { box-shadow: 0 0 0 0 transparent, 0 0 10px 2px var(--gold-glow); }
}
@keyframes starsea-text-shimmer {
  0% { background-position: 140% 0; }
  100% { background-position: -140% 0; }
}
@keyframes composer-scanline {
  0% { background-position: -65% 0; }
  100% { background-position: 165% 0; }
}
@keyframes starsea-sheen {
  0% { transform: translateX(-135%) skewX(-22deg); opacity: 0; }
  20% { opacity: .55; }
  100% { transform: translateX(230%) skewX(-22deg); opacity: 0; }
}
@keyframes card-rise-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 1. 成长记录与进度条流光 */
#detail .growth-readout {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  margin-bottom: 10px;
}
.growth-readout [data-growth-level] { font: 600 22px var(--serif); color: var(--gold-2); }
.growth-readout [data-growth-progress] { font: 400 13px var(--serif); color: var(--cyan); }
.growth-bar {
  height: 5px;
  background: rgba(186,206,255,.14);
  margin-bottom: 16px;
  overflow: hidden;
}
.growth-bar > i {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--gold-2), var(--cyan));
  background-size: 200% 100%;
  box-shadow: 0 0 12px var(--gold-glow);
  animation: starsea-shimmer 4.5s linear infinite;
}
#detail .growth-ledger { display: grid; gap: 0; border-top: 1px solid var(--line); }
#detail .growth-ledger p {
  padding: 11px 6px;
  border-bottom: 1px solid var(--line-soft);
  font: 400 13.5px/1.6 var(--serif); color: var(--text-2);
  transition: background .2s var(--ease), color .2s var(--ease);
}
#detail .growth-ledger p:hover {
  background: var(--soft); color: var(--text);
}
.growth-quiet > summary {
  list-style: none; cursor: pointer;
  padding: 9px 6px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--text-3);
  font: 400 12.5px/1.5 var(--serif);
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  transition: color .2s var(--ease), background .2s var(--ease);
}
.growth-quiet > summary::-webkit-details-marker { display: none; }
.growth-quiet > summary:hover { color: var(--gold-2); background: var(--soft); }
.growth-quiet > summary::after {
  content: "▸"; font-size: 11px; color: var(--gold);
  transition: transform .2s var(--ease);
}
.growth-quiet[open] > summary::after { transform: rotate(90deg); }

/* 2. 存档列表 */
#detail .save-row {
  display: grid; grid-template-columns: 30px minmax(0,1fr) auto; align-items: center; gap: 12px;
  padding: 11px 6px;
  border-bottom: 1px solid var(--line);
  transition: background .22s var(--ease), transform .22s var(--ease);
}
#detail .save-row:hover {
  background: linear-gradient(90deg, var(--gold-dim), transparent 85%);
  transform: translateX(3px);
}
#detail .save-index {
  width: 26px; height: 26px; display: grid; place-items: center;
  color: var(--gold-2);
  background: radial-gradient(circle, var(--gold-dim), transparent 72%);
  font: 600 12px var(--serif);
}

/* 3. 角色版本真实开关（保持精确 40x20 与 appearance: none） */
.content-choice { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.content-choice input.switch {
  position: relative; width: 40px; height: 20px; flex: none;
  appearance: none; margin: 0; padding: 0; border: 0; cursor: pointer;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--line-2), var(--line));
  box-shadow: inset 0 0 0 1px var(--line);
  transition: background .25s var(--ease), box-shadow .25s var(--ease);
}
.content-choice input.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px;
  border-radius: 50%; background: var(--text-3);
  transition: transform .25s var(--ease), background .25s var(--ease), box-shadow .25s var(--ease);
}
.content-choice input.switch:checked {
  background: linear-gradient(90deg, var(--gold-dim), rgba(235,197,120,.42));
  box-shadow: inset 0 0 0 1px var(--gold), 0 0 10px -2px var(--gold-glow);
}
.content-choice input.switch:checked::after {
  transform: translateX(20px); background: var(--gold-2);
  box-shadow: 0 0 12px var(--gold);
}

/* 4. 顶部错误提示条（保持顶栏下方定位） */
html body #toast {
  top: calc(var(--top) + 12px) !important;
  bottom: auto !important;
}
html body #toast.visible {
  animation: toast-drop-in .26s var(--ease) both;
}
html body #toast[data-tone="error"] {
  display: inline-flex !important; align-items: center !important; gap: 10px !important;
  padding: 10px 20px !important; margin-bottom: 16px !important;
  background: linear-gradient(90deg, rgba(68,18,34,.95), rgba(16,12,28,.96)) !important;
  backdrop-filter: blur(18px) !important;
  box-shadow: inset 2.5px 0 0 #ff7a8a, inset 0 -1px 0 rgba(255,122,138,.45), 0 14px 34px rgba(0,0,0,.52) !important;
  color: #ffd7de !important;
  font: 500 13.5px/1.4 var(--serif) !important;
}
html body #toast[data-tone="error"]::before {
  content: "" !important; width: 6px !important; height: 6px !important; flex: none !important;
  background: #ff7a8a !important; transform: rotate(45deg) !important;
  box-shadow: 0 0 10px #ff7a8a !important;
}
html[data-theme="starlight"] body #toast[data-tone="error"] {
  background: linear-gradient(90deg, rgba(255,238,241,.97), rgba(248,243,250,.98)) !important;
  box-shadow: inset 3px 0 0 #c93b4b, inset 0 -1px 0 rgba(201,59,75,.38), 0 12px 28px rgba(130,30,45,.16) !important;
  color: #7c1826 !important;
}
html[data-theme="starlight"] body #toast[data-tone="error"]::before {
  background: #c93b4b !important; box-shadow: 0 0 8px rgba(201,59,75,.45) !important;
}

/* 5. 小手机：直角无边框星海风 + 防背景透字 + 九项导航修复 + 亮暗双主题高对比 */
body .game-phone {
  border-radius: 0;
  padding: 18px 20px;
  display: flex; flex-direction: column; gap: 10px;
  color: var(--text);
  background:
    radial-gradient(ellipse at 85% 0%, rgba(124,226,246,.09), transparent 55%),
    radial-gradient(ellipse at 12% 0%, rgba(235,197,120,.1), transparent 52%),
    linear-gradient(180deg, rgba(8,14,34,.96), rgba(4,9,22,.985));
  backdrop-filter: blur(24px) saturate(1.15);
  box-shadow: inset 0 1.5px 0 var(--gold), inset 1px 0 0 var(--line), -16px 16px 46px rgba(0,0,0,.64);
  animation: phone-slide-in .28s var(--ease) both;
}
body .game-phone > header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 2px 0 6px;
}
body .game-phone > header > strong {
  font: 600 16px var(--serif); color: var(--gold-2); letter-spacing: .08em;
}
body .game-phone > nav {
  display: flex; flex-wrap: wrap; gap: 4px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
  overflow: visible;
}
body .game-phone > nav > button {
  flex: 1 0 auto;
  padding: 5px 9px;
  font: 500 12.5px/1.3 var(--serif);
  color: var(--text-3);
  white-space: nowrap;
  text-align: center;
  transition: color .2s var(--ease), background .2s var(--ease), box-shadow .2s var(--ease);
}
body .game-phone > nav > button:hover {
  color: var(--text);
  background: var(--soft);
}
body .game-phone > nav > button[aria-pressed="true"] {
  color: var(--gold-2);
  box-shadow: inset 0 -1.5px 0 var(--gold);
  background: radial-gradient(ellipse at 50% 100%, var(--gold-dim), transparent 76%);
}
body .game-phone button,
body .game-phone .phone-sessions button {
  color: var(--text);
  transition: color .2s var(--ease), background .2s var(--ease), border-color .2s var(--ease);
}
body .game-phone .phone-sessions button {
  padding: 5px 12px;
  border: 1px solid var(--line);
  background: var(--soft);
  border-radius: 0;
  font: 500 12.5px/1.3 var(--serif);
  color: var(--text-2);
}
body .game-phone .phone-sessions button[aria-pressed="true"] {
  color: var(--gold-2);
  border-color: var(--gold);
  background: linear-gradient(90deg, var(--gold-dim), transparent 95%);
  box-shadow: inset 2px 0 0 var(--gold-2);
}
body .game-phone form button[type="submit"],
body .game-phone .phone-actions button {
  margin-top: 6px;
  padding: 6px 14px;
  border: 1px solid var(--line-2);
  background: linear-gradient(120deg, var(--gold-dim), transparent 88%);
  color: var(--gold-2);
  font: 500 13px/1.3 var(--serif);
}
body .game-phone form button[type="submit"]:hover,
body .game-phone .phone-actions button:hover {
  border-color: var(--gold);
  box-shadow: 0 0 14px -4px var(--gold-glow);
}
body .game-phone input,
body .game-phone textarea,
body .game-phone select {
  width: 100%; max-width: 100%;
  color: var(--text);
  background: rgba(170,198,255,.06);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 7px 9px;
}
body .game-phone select[multiple] {
  min-height: 92px; padding: 4px;
}
body .game-phone select[multiple] option {
  padding: 5px 8px; color: var(--text); background: var(--ink-deep);
}
body .game-phone select[multiple] option:checked {
  background: var(--gold-dim); color: var(--gold-2);
}
body .game-phone .phone-content { padding: 8px 2px; }
body .game-phone footer {
  border-top: 1px solid var(--line-soft);
  padding: 10px 4px 2px; gap: 10px;
}

/* 小手机亮色主题（starlight）：彻底修复深底配暗字对比度 */
html[data-theme="starlight"] body .game-phone {
  color: var(--text);
  background:
    radial-gradient(ellipse at 85% 0%, rgba(18,117,154,.1), transparent 56%),
    radial-gradient(ellipse at 12% 0%, rgba(159,110,13,.11), transparent 54%),
    linear-gradient(180deg, rgba(247,250,255,.97), rgba(232,240,252,.985));
  box-shadow: inset 0 1.5px 0 var(--gold), inset 1px 0 0 var(--line-2), -12px 14px 40px rgba(24,42,88,.2);
}
html[data-theme="starlight"] body .game-phone article,
html[data-theme="starlight"] body .game-phone .phone-thread li,
html[data-theme="starlight"] body .game-phone .phone-beat {
  background: rgba(36,56,118,.06);
  color: var(--text);
  border: 1px solid var(--line-soft);
}
html[data-theme="starlight"] body .game-phone .phone-sent,
html[data-theme="starlight"] body .game-phone .phone-thread li.phone-sent {
  background: rgba(168,118,18,.13);
  border-color: rgba(159,110,13,.24);
}
html[data-theme="starlight"] body .game-phone .phone-suggestion,
html[data-theme="starlight"] body .game-phone .phone-beat[data-status="active"] {
  background: rgba(168,118,18,.15);
}
html[data-theme="starlight"] body .game-phone .phone-pre {
  background: rgba(36,56,118,.08);
  color: var(--text);
  border: 1px solid var(--line);
}
html[data-theme="starlight"] body .game-phone input,
html[data-theme="starlight"] body .game-phone textarea,
html[data-theme="starlight"] body .game-phone select {
  background: rgba(255,255,255,.82);
  border-color: var(--line-2);
  color: var(--text);
}
html[data-theme="starlight"] body .game-phone select[multiple] option {
  background: #f4f7fd; color: var(--text);
}
html[data-theme="starlight"] body .game-phone .phone-reply {
  border-left-color: var(--line-2);
}

/* 6. 互动桌宠菜单与反馈气泡：星海雾玻 + 亮暗主题 */
.starsea-pet .pet-actions,
.starsea-pet .pet-feedback {
  background: linear-gradient(180deg, rgba(9,16,38,.94), rgba(5,10,24,.96));
  backdrop-filter: blur(18px);
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 var(--gold-dim), 0 10px 26px rgba(0,0,0,.45);
  padding: 7px 9px;
  transition: background .22s var(--ease), border-color .22s var(--ease);
}
.starsea-pet .pet-actions button {
  color: var(--text-2); padding: 2px 5px;
  transition: color .2s var(--ease), transform .2s var(--ease);
}
.starsea-pet .pet-actions button:hover { color: var(--gold-2); transform: translateY(-1px); }
html[data-theme="starlight"] .starsea-pet .pet-actions,
html[data-theme="starlight"] .starsea-pet .pet-feedback {
  background: linear-gradient(180deg, rgba(248,251,255,.96), rgba(233,241,253,.97));
  color: var(--text);
  border-color: var(--line-2);
  box-shadow: inset 0 1px 0 var(--gold-dim), 0 10px 24px rgba(24,42,88,.18);
}

/* 7. 通用弹窗（教学 / 历史任务 / 存档 / 成长）与生图工作台双主题增强 */
#detail[open] {
  backdrop-filter: blur(22px);
  box-shadow: inset 0 1px 0 var(--gold-dim), 0 28px 80px rgba(0,0,0,.55);
  animation: dlg-bloom .26s var(--ease) both;
}
html[data-theme="starlight"] #detail[open] {
  box-shadow: inset 0 1px 0 rgba(159,110,13,.3), 0 22px 64px rgba(24,42,88,.22);
}
#detail [data-history-tasks] .actions,
#detail .actions { display: flex; flex-wrap: wrap; gap: 10px; }
.image-studio-body summary { color: var(--text-2); transition: color .2s var(--ease); }
.image-studio-body summary:hover { color: var(--gold-2); }
.image-studio-body pre {
  color: var(--text-2); background: var(--soft);
  padding: 10px 12px; border: 1px solid var(--line-soft);
}
.image-preview {
  border: 1px solid var(--line-soft);
  transition: border-color .25s var(--ease), box-shadow .25s var(--ease);
}
.image-preview:hover { border-color: var(--line-2); }
html[data-theme="starlight"] .image-result img { background: rgba(36,56,118,.08); }

/* 8. 奶龙质感星海微动效：星云呼吸 + 脉冲星点 + 流光扫线 + 光泽掠过 + 卡片入场 */
.sky-b { animation: sky-nebula-drift 28s ease-in-out infinite; }
.btn, .tab { transition: color .2s var(--ease), background .22s var(--ease), border-color .22s var(--ease), transform .18s var(--ease), box-shadow .22s var(--ease); }
.btn:active { transform: translateY(1px); }
.ibtn:active { transform: translateY(0) scale(.93); }

/* 8.1 侧轨当前页星芒涟漪 + 顶栏极细星轨高光 */
.rail-btn[aria-current="page"]::after {
  animation: starsea-star-ripple 3.2s ease-out infinite;
}
.topbar {
  box-shadow: inset 0 -1px 0 var(--line-soft);
}

/* 8.2 主按钮星金光泽掠过（Sheen Sweep） */
.btn-primary,
.primary {
  position: relative;
  overflow: hidden;
}
.btn-primary::after,
.primary::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 44%;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(255,244,214,.32), transparent);
  transform: translateX(-135%) skewX(-22deg);
  opacity: 0;
}
.btn-primary:hover::after,
.primary:hover::after {
  animation: starsea-sheen .78s var(--ease) 1;
}

/* 8.3 游玩页底部输入框：顶部星光扫线 + 生成态脉冲星点与流光文字 */
.composer::after {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 0; height: 1px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent 8%, var(--line-2) 38%, var(--gold-dim) 54%, transparent 92%);
  background-size: 220% 100%;
  opacity: .55;
  transition: opacity .28s var(--ease);
}
.composer:focus-within::after {
  opacity: 1;
  background: linear-gradient(90deg, transparent 6%, var(--gold-2) 40%, var(--cyan) 58%, transparent 94%);
  background-size: 220% 100%;
  animation: composer-scanline 3.4s linear infinite;
}
.composer:focus-within label::before {
  animation: starsea-star-ripple 2.4s ease-out infinite;
}
#generation-label:not(:empty) {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: linear-gradient(95deg, var(--text-2) 25%, var(--gold-2) 48%, var(--cyan) 56%, var(--text-2) 78%);
  background-size: 240% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: starsea-text-shimmer 2.8s linear infinite;
}
#generation-label:not(:empty)::before {
  content: "";
  width: 6px; height: 6px; flex: none;
  border-radius: 50%;
  background: var(--cyan);
  animation: starsea-dot-ripple 2s ease-out infinite;
}

/* 8.4 行动选项与事件卡细腻交互 */
.choice {
  transition: transform .2s var(--ease), background .22s var(--ease), color .2s var(--ease), box-shadow .22s var(--ease);
}
.choice:hover, .choice:focus-visible { transform: translateX(4px); }
.choice:hover b { text-shadow: 0 0 10px var(--gold-glow); }
.ev-card {
  animation: card-rise-in .32s var(--ease) both;
  transition: transform .24s var(--ease), box-shadow .24s var(--ease), border-color .24s var(--ease);
}
.ev-card:hover { transform: translateY(-2px); }

/* 8.5 首页菜单星轨微光 + 亮色主题死角对比度修复（人物卷选中页签/数值/首页菜单） */
.home-menu .home-entry::after {
  content: "";
  position: absolute;
  left: 0; top: 14px; bottom: 14px; width: 2px;
  background: linear-gradient(180deg, transparent, var(--gold-2), transparent);
  transform: scaleY(0);
  transform-origin: center;
  transition: transform .26s var(--ease);
}
.home-menu .home-entry:hover::after,
.home-menu .home-entry:focus-visible::after { transform: scaleY(1); }

html[data-theme="starlight"] .gemini-archive-body .arc-tabs .tab[aria-selected="true"] {
  color: var(--text) !important;
  background: radial-gradient(ellipse at 50% 100%, rgba(159,110,13,.16), transparent 76%);
}
html[data-theme="starlight"] .gemini-archive-dialog .numeric-kv b,
html[data-theme="starlight"] .gemini-archive-dialog .numeric-kv-list > div:not(.numeric-kv) > dd {
  color: var(--text) !important;
}
html[data-theme="starlight"] .home-menu .home-entry {
  color: var(--text);
}
html[data-theme="starlight"] .home-menu .home-entry:hover,
html[data-theme="starlight"] .home-menu .home-entry:focus-visible {
  color: var(--gold);
}
html[data-theme="starlight"] .journey {
  background: linear-gradient(90deg, rgba(248,251,255,.72), rgba(240,246,255,.38) 62%, transparent 90%);
}
html[data-theme="starlight"] .journey .label {
  color: #7c5106;
}
html[data-theme="starlight"] .journey-title {
  color: #162348 !important;
  -webkit-text-fill-color: #162348;
  background: none !important;
  text-shadow: 0 1px 12px rgba(255,255,255,.78);
}
html[data-theme="starlight"] #generation-label:not(:empty) {
  background: linear-gradient(95deg, var(--text-2) 25%, var(--gold) 50%, var(--cyan) 58%, var(--text-2) 78%);
  background-size: 240% 100%;
  -webkit-background-clip: text;
  background-clip: text;
}

/* 8.6 全域星海细滚动条 */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--line-2), var(--gold-dim));
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--gold); }

@media (max-width: 760px) {
  body .game-phone {
    left: 10px; right: 10px; width: auto;
    top: calc(var(--top) + 8px); bottom: 14px;
    padding: 14px 14px 12px;
  }
  body .game-phone > nav > button { padding: 5px 6px; font-size: 12px; }
  #detail .save-row { gap: 8px; padding: 10px 2px; }
}
@media (prefers-reduced-motion: reduce) {
  .sky-b, .growth-bar > i, body .game-phone, #detail[open], html body #toast.visible,
  .rail-btn[aria-current="page"]::after, .composer:focus-within::after,
  .composer:focus-within label::before, #generation-label:not(:empty),
  #generation-label:not(:empty)::before, .ev-card, .btn-primary:hover::after,
  .primary:hover::after {
    animation: none !important;
  }
  .btn, .tab, .ibtn, .choice, .ev-card, .home-menu .home-entry::after,
  #detail .save-row, .starsea-pet .pet-actions button {
    transition: none !important;
  }
}
html[data-motion="reduce"] .sky-b,
html[data-motion="reduce"] .growth-bar > i,
html[data-motion="reduce"] .rail-btn[aria-current="page"]::after,
html[data-motion="reduce"] .composer:focus-within::after,
html[data-motion="reduce"] .composer:focus-within label::before,
html[data-motion="reduce"] #generation-label:not(:empty),
html[data-motion="reduce"] #generation-label:not(:empty)::before,
html[data-motion="reduce"] .ev-card {
  animation: none !important;
}

/* 2.6.0 M3: 状态栏头像跟随立绘 · 取景缩放与破框展示 */
.stage-core.is-sprite-follow img {
  transform: scale(var(--avatar-scale, 1));
  transform-origin: center top;
}
.stage-core.is-breakout {
  overflow: visible !important;
  margin-top: 20px;
}
.stage-core.is-breakout img {
  position: absolute;
  inset: auto auto -4% 50%;
  width: 112%;
  height: 112%;
  object-fit: contain;
  transform: translateX(-50%) scale(calc(1 + (var(--avatar-scale, 1) - 1) * 0.35));
  transform-origin: center bottom;
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 84%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 0%, #000 84%, transparent 100%);
  filter: drop-shadow(0 8px 18px rgba(4, 10, 26, 0.55));
  pointer-events: none;
}
html body dialog#detail .gal-assets [hidden] {
  display: none !important;
}
