:root {
  color-scheme: dark;
  --bg: #0b0d12;
  --panel: rgba(20, 24, 33, 0.78);
  --panel-strong: rgba(29, 34, 46, 0.94);
  --line: rgba(255, 255, 255, 0.11);
  --text: #f4f7fb;
  --muted: #9aa5b5;
  --soft: #cdd5e3;
  --accent: #7aa8ff;
  --accent-2: #47d6b6;
  --accent-warm: #ff9cc8;
  --danger: #ff756b;
  --galgame-bg-image: url("/assets/ui/galgame-riverside-spring.png?v=1");
  --font-ui: "MiSans", "Noto Sans SC", "HarmonyOS Sans SC", "Microsoft YaHei UI", "PingFang SC", "Segoe UI Variable", system-ui, sans-serif;
  --font-title: "Noto Serif SC", "Source Han Serif SC", "STSong", "SimSun", serif;
  --font-serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", Georgia, serif;
  --control-h: 38px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --surface-soft: rgba(255, 255, 255, 0.08);
  --surface-card: rgba(18, 23, 34, 0.82);
  --focus-ring: 0 0 0 3px color-mix(in srgb, var(--accent), transparent 72%);
  font-family: var(--font-ui);
  font-weight: 400;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 82% 18%, rgba(71, 214, 182, 0.16), transparent 28rem),
    radial-gradient(circle at 18% 8%, rgba(122, 168, 255, 0.18), transparent 30rem),
    linear-gradient(135deg, #090b10 0%, #10131b 52%, #121015 100%);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

#app {
  display: grid;
  grid-template-columns: 280px minmax(520px, 1fr) minmax(380px, 460px);
  height: 100dvh;
  min-height: 720px;
}

.galgame-atmosphere {
  display: none;
}

.rail,
.stage {
  border-right: 1px solid var(--line);
  background: rgba(9, 12, 18, 0.72);
  backdrop-filter: blur(22px);
  padding: 20px;
}

.rail {
  overflow-y: auto;
  padding: 18px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.24) transparent;
  background:
    linear-gradient(180deg, rgba(18, 23, 34, 0.98), rgba(8, 11, 18, 0.99)),
    #0b0d12;
}

.stage {
  position: relative;
  overflow: hidden;
  border-right: 0;
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 12px;
  justify-content: flex-end;
  background:
    linear-gradient(180deg, rgba(19, 29, 43, 0.88), rgba(8, 10, 15, 0.94)),
    rgba(9, 12, 18, 0.72);
}

.brand {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(255, 156, 200, 0.1), rgba(71, 214, 182, 0.07)),
    rgba(16, 20, 30, 0.92);
}

.help-button {
  min-height: 32px;
  padding: 0 9px;
  border-radius: 10px;
  color: var(--soft);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.help-button:hover {
  color: #071015;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
}

.help-button:focus-visible,
.quota-row button:focus-visible,
.style-switch input:focus-visible + span {
  outline: 0;
  border-color: color-mix(in srgb, var(--accent), white 16%);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent), transparent 74%);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  color: #071015;
  background: linear-gradient(135deg, var(--accent-warm), var(--accent-2));
  font-weight: 900;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.16) inset;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 15px;
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand span {
  margin-top: 3px;
  font-size: 12px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand span,
small,
.muted {
  color: var(--muted);
}

.select-target,
.panel,
.composer,
.character-sheet {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 8px 12px rgba(0, 0, 0, 0.18);
}

.select-target {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 82px;
  padding: 13px;
  border-radius: 14px;
  color: var(--text);
  text-align: left;
  background:
    linear-gradient(135deg, rgba(122, 168, 255, 0.16), rgba(71, 214, 182, 0.07)),
    #131824;
  box-shadow: none;
  transition: border-color 0.18s ease, background 0.18s ease;
}

.select-target:hover,
.select-target:focus-visible {
  border-color: color-mix(in srgb, var(--accent), white 8%);
  outline: 0;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent), transparent 78%);
  background:
    linear-gradient(135deg, rgba(122, 168, 255, 0.2), rgba(71, 214, 182, 0.1)),
    #171d2a;
}

.mini-portrait {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  overflow: hidden;
  background: #202634;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.mini-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.panel {
  margin-top: 14px;
  padding: 14px;
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.012)),
    #111722;
  box-shadow: none;
}

.compact {
  display: grid;
  gap: 10px;
}

.compact > label:not(.check-line) {
  color: #e1e8f4;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
}

.field-hint {
  margin: -1px 0 0;
  padding: 8px 10px;
  border: 1px solid rgba(122, 168, 255, 0.14);
  border-radius: 10px;
  color: #c6d1e2;
  background: rgba(122, 168, 255, 0.07);
  font-size: 12px;
  line-height: 1.5;
}

.voice-api-panel #voiceSearch,
.voice-api-panel #acgnVoiceSelect,
.voice-api-panel #voiceAutoTranslate {
  margin-top: 2px;
}

.voice-api-panel {
  gap: 8px;
}

.voice-results {
  display: grid;
  gap: 6px;
  max-height: 220px;
  overflow: auto;
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 12px;
  background: #111722;
}

.voice-results[hidden] {
  display: none;
}

.voice-results button {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  text-align: left;
}

.voice-results button:hover,
.voice-results button:focus-visible {
  outline: 0;
  background: color-mix(in srgb, var(--accent), transparent 78%);
}

.voice-results b {
  color: var(--accent-2);
  font-size: 12px;
}

.voice-results span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--soft);
  font-size: 12px;
}

.quota-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
  margin-top: 2px;
}

.quota-row button {
  min-height: 38px;
  padding: 0 12px;
  border-radius: 10px;
  color: #071015;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 800;
}

.quota-row button:hover {
  filter: brightness(1.06);
}

.quota-row button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.quota-row span {
  min-width: 0;
  min-height: 28px;
  padding: 6px 8px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 9px;
  color: #c6d1e2;
  background: rgba(255, 255, 255, 0.045);
  font-size: 12px;
  line-height: 1.45;
}

html:not([data-voice-provider="acgn-ttson"]):not([data-voice-provider="acgn-official"]) .voice-api-panel #voiceSearch,
html:not([data-voice-provider="acgn-ttson"]):not([data-voice-provider="acgn-official"]) .voice-api-panel #acgnVoiceResults,
html:not([data-voice-provider="acgn-ttson"]):not([data-voice-provider="acgn-official"]) .voice-api-panel #acgnVoiceSelect,
html:not([data-voice-provider="acgn-ttson"]):not([data-voice-provider="acgn-official"]) .voice-api-panel .check-line:has(#voiceAutoTranslate),
html:not([data-voice-provider="acgn-ttson"]):not([data-voice-provider="acgn-official"]) .voice-api-panel .quota-row {
  display: none;
}

html[data-voice-provider="browser"] .voice-api-panel #voiceBaseUrl,
html[data-voice-provider="browser"] .voice-api-panel #voiceModel,
html[data-voice-provider="browser"] .voice-api-panel #voiceId,
html[data-voice-provider="browser"] .voice-api-panel #voiceKey {
  display: none;
}

.style-panel {
  gap: 11px;
}

.quickstart-panel {
  gap: 12px;
  border-color: color-mix(in srgb, var(--accent), transparent 72%);
  background:
    linear-gradient(135deg, rgba(122, 168, 255, 0.14), rgba(255, 156, 200, 0.08)),
    #101722;
}

.quickstart-copy {
  display: grid;
  gap: 6px;
}

.quickstart-copy strong {
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

.quickstart-copy p {
  margin: 0;
  color: var(--soft);
  font-size: 12px;
  line-height: 1.6;
}

.quickstart-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quickstart-pills span,
.empty-mode {
  display: inline-grid;
  place-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.07);
  color: var(--soft);
  font-size: 11px;
  font-weight: 800;
}

.quickstart-pills span[data-mode="live"],
.empty-mode.live {
  color: #071015;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.quickstart-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.quickstart-primary,
.quickstart-secondary {
  min-height: 38px;
  border-radius: 11px;
  font-size: 12px;
  font-weight: 800;
}

.quickstart-primary {
  color: #071015;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.quickstart-secondary {
  color: var(--soft);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.quickstart-secondary:hover,
.quickstart-secondary:focus-visible {
  outline: 0;
  color: #071015;
  background: linear-gradient(135deg, var(--accent-warm), var(--accent-2));
  border-color: transparent;
}

.self-name-panel {
  gap: 8px;
}

.self-name-panel input {
  min-height: 38px;
  border-color: color-mix(in srgb, var(--accent-warm), transparent 72%);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent-warm), transparent 90%), rgba(255, 255, 255, 0.045));
}

.self-name-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.55;
}

.style-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  padding: 5px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 13px;
  background: rgba(5, 8, 13, 0.34);
}

.style-switch label {
  position: relative;
  min-width: 0;
}

.style-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.style-switch span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 7px;
  border-radius: 9px;
  color: #c9d3e2;
  background: transparent;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.style-switch span:hover {
  background: rgba(255, 255, 255, 0.07);
}

.style-switch input:checked + span,
html[data-ui-style="workbench"] .style-switch label:nth-child(1) span,
html[data-ui-style="galgame"] .style-switch label:nth-child(2) span,
html[data-ui-style="pet-console"] .style-switch label:nth-child(3) span,
html[data-ui-style="album"] .style-switch label:nth-child(4) span {
  color: #071015;
  background: linear-gradient(135deg, var(--accent-warm), var(--accent-2));
  border-color: transparent;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.16) inset;
}

.rail .panel.compact.muted {
  padding: 12px;
  border-color: rgba(71, 214, 182, 0.16);
  color: #b8c4d3;
  background:
    linear-gradient(135deg, rgba(71, 214, 182, 0.08), rgba(122, 168, 255, 0.055)),
    #0f141e;
}

.rail .panel.compact.muted p {
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
}

.style-dock {
  display: none;
}

.galgame-tool {
  display: none;
}

.galgame-bg-picker {
  display: none;
}

.style-dock label,
.style-dock button {
  position: relative;
}

.style-dock input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.style-dock span,
.style-dock button {
  display: grid;
  place-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.86);
  background: rgba(18, 20, 34, 0.46);
  border: 1px solid rgba(255, 255, 255, 0.28);
  font-size: 12px;
  font-weight: 800;
  backdrop-filter: blur(12px);
}

.style-dock input:checked + span,
.style-dock > button[data-active="true"] {
  color: #11151d;
  background: linear-gradient(135deg, var(--accent-warm), var(--accent-2));
  border-color: transparent;
}

.galgame-frequency-control {
  display: none;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 8px;
}

.galgame-frequency-control span {
  min-height: 28px;
  padding: 0;
  border: 0;
  color: rgba(255, 255, 255, 0.72);
  background: transparent;
  backdrop-filter: none;
}

.galgame-frequency-control select {
  width: 72px;
  min-height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--text);
  background: rgba(18, 20, 34, 0.58);
  border: 1px solid rgba(255, 255, 255, 0.24);
  font-size: 12px;
  font-weight: 800;
}

.galgame-frequency-control select:focus {
  border-color: color-mix(in srgb, var(--accent), white 16%);
  box-shadow: var(--focus-ring);
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  background: #1a202b;
  color: var(--text);
  border-radius: 11px;
  padding: 10px 12px;
  outline: 0;
}

input::placeholder,
textarea::placeholder {
  color: #8f9bab;
  opacity: 1;
}

textarea {
  resize: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: color-mix(in srgb, var(--accent), white 20%);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent), transparent 76%);
}

.chat {
  min-width: 0;
  position: relative;
  display: grid;
  padding: 20px 22px;
  background:
    radial-gradient(circle at 74% 4%, rgba(255, 156, 200, 0.1), transparent 18rem),
    linear-gradient(180deg, rgba(25, 31, 46, 0.7), rgba(11, 13, 19, 0.96));
}

.chat-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(100%, 980px);
  min-height: 0;
  margin: 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(18, 23, 34, 0.72), rgba(10, 12, 18, 0.72)),
    rgba(14, 17, 25, 0.78);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  overflow: hidden;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--line);
}

.chat-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.chat-actions .ghost[data-active="true"] {
  color: #071015;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
}

.chat-character {
  display: flex;
  align-items: center;
  gap: 22px;
  min-width: 0;
}

.active-avatar {
  order: 2;
  display: block;
  width: 62px;
  height: 62px;
  overflow: hidden;
  flex: 0 0 auto;
  border: 4px solid rgba(255, 255, 255, 0.96);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 8px 12px rgba(0, 0, 0, 0.2);
}

.active-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.eyebrow {
  color: var(--accent-2);
  font-size: 11px;
  letter-spacing: 0;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  margin-top: 6px;
  font-size: 26px;
  letter-spacing: 0;
}

.presence-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.presence-row span {
  display: inline-grid;
  place-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  color: var(--soft);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
  font-weight: 700;
}

.ghost,
.tools-row button,
.create-form button,
.composer button {
  border-radius: 12px;
  padding: 11px 15px;
  color: #071015;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-weight: 800;
}

.ghost {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
}

.pet-surface {
  position: relative;
  overflow: visible;
  z-index: 1;
  height: clamp(520px, 68vh, 720px);
  min-height: 520px;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.pet-actor {
  --pet-x: 0px;
  --pet-y: 0px;
  position: absolute;
  left: 50%;
  bottom: 18px;
  z-index: 2;
  width: auto;
  height: min(620px, calc(100% - 18px));
  max-width: 98%;
  aspect-ratio: 0.72;
  transform: translate(calc(-50% + var(--pet-x)), var(--pet-y));
  cursor: grab;
  touch-action: none;
  outline: 0;
  animation: pet-idle 3.8s ease-in-out infinite;
}

.pet-actor.chibi-pet {
  bottom: 22px;
  height: min(390px, calc(100% - 80px));
  max-width: 86%;
  aspect-ratio: 1;
}

.pet-actor:focus-visible,
.live2d-stage:focus-visible {
  filter: drop-shadow(0 0 0.7rem color-mix(in srgb, var(--accent), white 25%));
}

.pet-actor[data-dragging="true"],
.live2d-stage[data-dragging="true"] {
  cursor: grabbing;
  animation: none;
}

.pet-actor[data-motion="happy"],
.live2d-stage[data-motion="happy"] {
  animation: pet-happy 1.55s ease both;
}

.pet-actor[data-motion="feed"],
.live2d-stage[data-motion="feed"] {
  animation: pet-feed 1.45s ease both;
}

.pet-actor[data-motion="jump"],
.live2d-stage[data-motion="jump"] {
  animation: pet-jump 1.55s cubic-bezier(.16, 1, .3, 1) both;
}

.pet-actor[data-motion="rest"],
.live2d-stage[data-motion="rest"] {
  animation: pet-rest 1.6s ease both;
}

.pet-actor[data-motion="land"],
.live2d-stage[data-motion="land"] {
  animation: pet-land 0.55s ease both;
}

.pet-actor[data-motion="wave"],
.live2d-stage[data-motion="wave"] {
  animation: pet-wave 1.55s ease both;
}

.pet-actor[data-motion="shy"],
.live2d-stage[data-motion="shy"] {
  animation: pet-shy 1.6s ease both;
}

.pet-actor[data-motion="spin"],
.live2d-stage[data-motion="spin"] {
  animation: pet-spin 1.8s cubic-bezier(.16, 1, .3, 1) both;
}

.pet-actor[data-motion="talk"],
.live2d-stage[data-motion="talk"] {
  animation: pet-talk 1.5s ease both;
}

.pet-actor[data-motion="surprised"],
.live2d-stage[data-motion="surprised"] {
  animation: pet-surprised 1.1s cubic-bezier(.16, 1, .3, 1) both;
}

.pet-actor[data-motion="angry"],
.live2d-stage[data-motion="angry"] {
  animation: pet-angry 1.3s ease both;
}

.pet-actor[data-motion="approach"],
.live2d-stage[data-motion="approach"] {
  animation: pet-approach 1.45s cubic-bezier(.16, 1, .3, 1) both;
}

.pet-avatar {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  user-select: none;
  pointer-events: none;
  filter: drop-shadow(0 30px 34px rgba(0, 0, 0, 0.5));
}

.pet-actor[data-speaking="true"] .pet-avatar {
  animation: pet-speaking 0.86s ease-in-out infinite;
  transform-origin: 50% 92%;
}

.pet-actor[data-emotion="happy"] .pet-avatar,
.live2d-stage[data-emotion="happy"] {
  filter: saturate(1.08) brightness(1.06) drop-shadow(0 24px 30px rgba(0, 0, 0, 0.42));
}

.pet-actor[data-emotion="shy"] .pet-avatar,
.live2d-stage[data-emotion="shy"] {
  filter:
    saturate(1.12)
    brightness(1.04)
    sepia(0.08)
    drop-shadow(0 24px 30px rgba(255, 156, 200, 0.24));
  transform: rotate(-1.2deg);
}

.pet-actor[data-emotion="sad"] .pet-avatar,
.live2d-stage[data-emotion="sad"] {
  filter: saturate(0.82) brightness(0.9) drop-shadow(0 24px 30px rgba(0, 0, 0, 0.46));
  transform: translateY(8px);
}

.pet-actor[data-emotion="angry"] .pet-avatar,
.live2d-stage[data-emotion="angry"] {
  filter: contrast(1.08) saturate(1.12) drop-shadow(0 24px 30px rgba(255, 117, 107, 0.24));
  transform: rotate(1deg);
}

.pet-actor[data-emotion="surprised"] .pet-avatar,
.live2d-stage[data-emotion="surprised"] {
  filter: brightness(1.08) saturate(1.05) drop-shadow(0 24px 30px rgba(122, 168, 255, 0.26));
  transform: translateY(-8px);
}

.pet-avatar.opaque-pet {
  mix-blend-mode: multiply;
  border-radius: 8px;
}

.pet-empty {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-content: center;
  gap: 8px;
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

.pet-empty[hidden] {
  display: none;
}

.pet-empty strong {
  color: var(--text);
  font-size: 18px;
}

.pet-empty span {
  max-width: 220px;
  line-height: 1.6;
}

.live2d-stage {
  --pet-x: 0px;
  --pet-y: 0px;
  position: absolute;
  left: 50%;
  bottom: 26px;
  z-index: 3;
  display: grid;
  place-items: center;
  gap: 10px;
  width: min(340px, 88%);
  aspect-ratio: 0.78;
  transform: translate(calc(-50% + var(--pet-x)), var(--pet-y));
  cursor: grab;
  touch-action: none;
  outline: 0;
  color: var(--text);
  text-align: center;
}

.live2d-stage canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.live2d-stage[hidden] {
  display: none;
}

.live2d-stage strong {
  font-size: 28px;
}

.live2d-stage span {
  max-width: 230px;
  color: var(--muted);
  line-height: 1.6;
}

.pet-shadow {
  position: absolute;
  left: 50%;
  bottom: 2%;
  width: 54%;
  height: 8%;
  transform: translateX(-50%);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.34);
  filter: blur(10px);
}

.pet-bubble {
  position: absolute;
  left: 50%;
  top: 14px;
  z-index: 4;
  max-width: min(300px, 88%);
  transform: translateX(-50%);
  padding: 14px 16px;
  border-radius: 18px;
  color: var(--text);
  background: rgba(19, 23, 32, 0.9);
  border: 1px solid var(--line);
  box-shadow: 0 10px 14px rgba(0, 0, 0, 0.24);
  line-height: 1.65;
}

.pet-bubble[hidden],
.pet-toolbar[hidden] {
  display: none;
}

.pet-bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -9px;
  width: 16px;
  height: 16px;
  transform: translateX(-50%) rotate(45deg);
  background: rgba(19, 23, 32, 0.9);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.pet-toolbar {
  position: absolute;
  left: 50%;
  bottom: 30px;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: calc(100% - 32px);
  transform: translateX(-50%);
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(15, 18, 26, 0.9);
  box-shadow: 0 10px 14px rgba(0, 0, 0, 0.24);
}

.pet-toolbar button {
  min-width: 54px;
  min-height: 40px;
  border-radius: 12px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-weight: 800;
}

.pet-toolbar button:hover {
  background: color-mix(in srgb, var(--accent), transparent 74%);
}

.messages {
  overflow-y: auto;
  min-height: 0;
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 42px 42px;
  background-position: center;
}

.empty-state {
  margin: auto;
  max-width: 460px;
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 28px 30px;
  border: 1px solid color-mix(in srgb, var(--accent-warm), transparent 78%);
  border-radius: 16px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent-warm), transparent 90%), transparent),
    rgba(255, 255, 255, 0.04);
  text-align: center;
  color: var(--muted);
  line-height: 1.8;
}

.empty-state strong {
  color: var(--text);
  font-size: 17px;
}

.empty-mode {
  margin-bottom: 2px;
}

.empty-state span {
  max-width: 38ch;
}

.starter-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 6px;
}

.starter-actions button {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  color: var(--soft);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 12px;
  font-weight: 700;
}

.starter-actions button:hover {
  color: #071015;
  background: linear-gradient(135deg, var(--accent-warm), var(--accent-2));
  border-color: transparent;
}

.galgame-choices {
  display: flex;
  flex-wrap: wrap;
  align-self: stretch;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
}

.galgame-choices button {
  min-height: 38px;
  padding: 0 16px;
  border-radius: 999px;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.24);
  font-size: 13px;
  font-weight: 800;
}

.galgame-choices button:hover {
  color: #161019;
  background: rgba(255, 255, 255, 0.88);
}

.bubble {
  max-width: min(720px, 82%);
  padding: 14px 16px;
  border-radius: 18px;
  line-height: 1.7;
  white-space: pre-wrap;
}

.bubble.user {
  align-self: flex-end;
  background: color-mix(in srgb, var(--accent), #10131b 50%);
}

.bubble.assistant {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
}

.message-row {
  display: grid;
  gap: 7px;
}

.message-row.user {
  justify-items: end;
}

.message-row.assistant {
  justify-items: start;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 20px;
}

.message-speaker {
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.message-state {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 12px;
  margin: 0;
  border-width: 1px 0 0;
  border-radius: 0;
  background: rgba(10, 12, 18, 0.82);
  box-shadow: none;
}

@keyframes pet-idle {
  0%, 100% {
    margin-bottom: 0;
  }
  50% {
    margin-bottom: 8px;
  }
}

@keyframes pet-happy {
  0%, 100% {
    transform: translate(calc(-50% + var(--pet-x)), var(--pet-y)) rotate(0deg);
  }
  30% {
    transform: translate(calc(-50% + var(--pet-x) - 16px), calc(var(--pet-y) - 28px)) rotate(-6deg) scale(1.02);
  }
  65% {
    transform: translate(calc(-50% + var(--pet-x) + 16px), calc(var(--pet-y) - 16px)) rotate(6deg) scale(1.02);
  }
}

.galgame-log-head > div {
  display: grid;
  gap: 2px;
}

.galgame-log-head span {
  color: rgba(49, 90, 132, 0.62);
  font-size: 11px;
  font-weight: 800;
}

.galgame-log-tools {
  padding: 10px 14px 0;
}

.galgame-log-tools input {
  width: 100%;
  min-height: var(--control-h);
  border: 1px solid rgba(107, 141, 180, 0.22);
  border-radius: 999px;
  padding: 0 14px;
  color: #20324c;
  background: rgba(255, 255, 255, 0.74);
  outline: none;
}

.galgame-log-tools input:focus {
  border-color: color-mix(in srgb, var(--accent), white 18%);
  box-shadow: var(--focus-ring);
}

.galgame-log-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.galgame-log-item-head span {
  display: inline-flex;
  gap: 6px;
}

.galgame-log-item-head button {
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  color: #2b5378;
  background: rgba(255, 255, 255, 0.76);
  font-size: 11px;
  font-weight: 900;
}

.save-slot-dialog {
  width: min(780px, calc(100vw - 32px));
  max-height: min(760px, calc(100dvh - 40px));
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.52);
  border-radius: 18px;
  color: #20324c;
  background:
    radial-gradient(circle at 24% 0%, color-mix(in srgb, var(--accent), transparent 82%), transparent 18rem),
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(240, 246, 255, 0.78));
  box-shadow: 0 28px 68px rgba(18, 31, 54, 0.34);
}

.save-slot-dialog::backdrop {
  background: rgba(20, 26, 40, 0.38);
}

.save-slot-dialog form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.save-slot-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.save-slot-head strong {
  display: block;
  margin-top: 3px;
  color: #1c2d44;
  font-size: 20px;
}

.save-slot-head button {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  color: #244260;
  background: rgba(255, 255, 255, 0.72);
  font-weight: 900;
}

.save-slot-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  overflow: auto;
  padding: 2px;
}

.save-slot-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(92, 127, 165, 0.18);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.62);
}

.save-slot-card.empty {
  opacity: 0.74;
}

.save-slot-index {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(135deg, #5579aa, #efa6c7);
  font-size: 13px;
  font-weight: 900;
}

.save-slot-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.save-slot-copy b {
  color: #557093;
  font-size: 11px;
}

.save-slot-copy strong {
  overflow: hidden;
  color: #20324c;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.save-slot-copy span {
  overflow: hidden;
  color: rgba(35, 52, 76, 0.68);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.save-slot-actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.save-slot-actions button {
  min-height: 34px;
  border-radius: 999px;
  color: #244260;
  background: rgba(255, 255, 255, 0.74);
  font-size: 12px;
  font-weight: 900;
}

.save-slot-actions button:first-child {
  color: #071015;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.save-slot-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

@media (max-width: 720px) {
  .save-slot-grid {
    grid-template-columns: 1fr;
  }
}

@keyframes pet-feed {
  0%, 100% {
    transform: translate(calc(-50% + var(--pet-x)), var(--pet-y)) scale(1);
  }
  45% {
    transform: translate(calc(-50% + var(--pet-x)), calc(var(--pet-y) + 18px)) scale(1.08, 0.94);
  }
}

@keyframes pet-jump {
  0%, 100% {
    transform: translate(calc(-50% + var(--pet-x)), var(--pet-y));
  }
  45% {
    transform: translate(calc(-50% + var(--pet-x)), calc(var(--pet-y) - 82px)) scale(1.03);
  }
}

@keyframes pet-rest {
  0%, 100% {
    transform: translate(calc(-50% + var(--pet-x)), var(--pet-y)) rotate(0deg);
  }
  50% {
    transform: translate(calc(-50% + var(--pet-x) + 8px), calc(var(--pet-y) + 28px)) rotate(5deg) scale(0.98);
  }
}

@keyframes pet-land {
  0%, 100% {
    transform: translate(calc(-50% + var(--pet-x)), var(--pet-y)) scale(1);
  }
  45% {
    transform: translate(calc(-50% + var(--pet-x)), calc(var(--pet-y) + 8px)) scale(1.08, 0.92);
  }
}

@keyframes pet-wave {
  0%, 100% {
    transform: translate(calc(-50% + var(--pet-x)), var(--pet-y)) rotate(0deg);
  }
  25% {
    transform: translate(calc(-50% + var(--pet-x) - 20px), calc(var(--pet-y) - 16px)) rotate(-10deg) scale(1.02);
  }
  55% {
    transform: translate(calc(-50% + var(--pet-x) + 20px), calc(var(--pet-y) - 16px)) rotate(10deg) scale(1.02);
  }
  78% {
    transform: translate(calc(-50% + var(--pet-x) - 10px), calc(var(--pet-y) - 8px)) rotate(-6deg);
  }
}

@keyframes pet-shy {
  0%, 100% {
    transform: translate(calc(-50% + var(--pet-x)), var(--pet-y)) scale(1);
    filter: none;
  }
  50% {
    transform: translate(calc(-50% + var(--pet-x) - 24px), calc(var(--pet-y) + 16px)) rotate(-5deg) scale(0.97);
    filter: saturate(1.22) brightness(1.08);
  }
}

@keyframes pet-spin {
  0% {
    transform: translate(calc(-50% + var(--pet-x)), var(--pet-y)) rotate(0deg) scale(1);
  }
  50% {
    transform: translate(calc(-50% + var(--pet-x)), calc(var(--pet-y) - 12px)) rotate(180deg) scale(1.04);
  }
  100% {
    transform: translate(calc(-50% + var(--pet-x)), var(--pet-y)) rotate(360deg) scale(1);
  }
}

@keyframes pet-talk {
  0%, 100% {
    transform: translate(calc(-50% + var(--pet-x)), var(--pet-y)) scale(1);
  }
  24% {
    transform: translate(calc(-50% + var(--pet-x)), calc(var(--pet-y) - 10px)) rotate(-1.2deg) scale(1.01);
  }
  54% {
    transform: translate(calc(-50% + var(--pet-x)), calc(var(--pet-y) - 4px)) rotate(1deg) scale(1.006);
  }
  78% {
    transform: translate(calc(-50% + var(--pet-x)), calc(var(--pet-y) - 8px)) rotate(-0.6deg) scale(1.008);
  }
}

@keyframes pet-speaking {
  0%, 100% {
    transform: translateY(0) scale(1);
  }
  45% {
    transform: translateY(-4px) scale(1.006);
  }
  72% {
    transform: translateY(1px) scale(0.998);
  }
}

@keyframes pet-surprised {
  0%, 100% {
    transform: translate(calc(-50% + var(--pet-x)), var(--pet-y)) scale(1);
  }
  24% {
    transform: translate(calc(-50% + var(--pet-x)), calc(var(--pet-y) - 46px)) scale(1.06);
  }
  42% {
    transform: translate(calc(-50% + var(--pet-x)), calc(var(--pet-y) - 26px)) rotate(-2deg) scale(1.035);
  }
  68% {
    transform: translate(calc(-50% + var(--pet-x)), calc(var(--pet-y) - 18px)) rotate(2deg) scale(1.02);
  }
}

@keyframes pet-angry {
  0%, 100% {
    transform: translate(calc(-50% + var(--pet-x)), var(--pet-y)) rotate(0deg);
  }
  18% {
    transform: translate(calc(-50% + var(--pet-x) - 14px), calc(var(--pet-y) + 4px)) rotate(-2deg) scale(1.015);
  }
  36% {
    transform: translate(calc(-50% + var(--pet-x) + 14px), calc(var(--pet-y) + 4px)) rotate(2deg) scale(1.015);
  }
  54% {
    transform: translate(calc(-50% + var(--pet-x) - 8px), calc(var(--pet-y) + 2px)) rotate(-1.2deg);
  }
  72% {
    transform: translate(calc(-50% + var(--pet-x) + 8px), calc(var(--pet-y) + 2px)) rotate(1.2deg);
  }
}

@keyframes pet-approach {
  0%, 100% {
    transform: translate(calc(-50% + var(--pet-x)), var(--pet-y)) scale(1);
  }
  52% {
    transform: translate(calc(-50% + var(--pet-x)), calc(var(--pet-y) - 18px)) scale(1.08);
  }
  76% {
    transform: translate(calc(-50% + var(--pet-x)), calc(var(--pet-y) - 6px)) scale(1.04);
  }
}

@keyframes galgame-pet-happy {
  0%, 100% {
    transform: translate(calc(-50% + var(--pet-x)), var(--pet-y)) rotate(0deg) scale(1);
  }
  26% {
    transform: translate(calc(-50% + var(--pet-x) - 34px), calc(var(--pet-y) - 30px)) rotate(-4deg) scale(1.025);
  }
  58% {
    transform: translate(calc(-50% + var(--pet-x) + 26px), calc(var(--pet-y) - 18px)) rotate(3.5deg) scale(1.018);
  }
  82% {
    transform: translate(calc(-50% + var(--pet-x) - 10px), calc(var(--pet-y) - 8px)) rotate(-1deg) scale(1.008);
  }
}

@keyframes galgame-pet-wave {
  0%, 100% {
    transform: translate(calc(-50% + var(--pet-x)), var(--pet-y)) rotate(0deg);
  }
  18% {
    transform: translate(calc(-50% + var(--pet-x) - 28px), calc(var(--pet-y) - 18px)) rotate(-5deg) scale(1.018);
  }
  38% {
    transform: translate(calc(-50% + var(--pet-x) + 34px), calc(var(--pet-y) - 22px)) rotate(5deg) scale(1.02);
  }
  58% {
    transform: translate(calc(-50% + var(--pet-x) - 18px), calc(var(--pet-y) - 12px)) rotate(-3deg);
  }
  76% {
    transform: translate(calc(-50% + var(--pet-x) + 10px), calc(var(--pet-y) - 6px)) rotate(1.5deg);
  }
}

@keyframes galgame-pet-jump {
  0%, 100% {
    transform: translate(calc(-50% + var(--pet-x)), var(--pet-y)) scale(1);
  }
  12% {
    transform: translate(calc(-50% + var(--pet-x)), calc(var(--pet-y) + 18px)) scale(1.04, 0.96);
  }
  48% {
    transform: translate(calc(-50% + var(--pet-x)), calc(var(--pet-y) - 118px)) scale(1.035);
  }
  78% {
    transform: translate(calc(-50% + var(--pet-x)), calc(var(--pet-y) + 10px)) scale(1.055, 0.94);
  }
}

@keyframes galgame-pet-shy {
  0%, 100% {
    transform: translate(calc(-50% + var(--pet-x)), var(--pet-y)) rotate(0deg) scale(1);
    filter: none;
  }
  42% {
    transform: translate(calc(-50% + var(--pet-x) - 54px), calc(var(--pet-y) + 20px)) rotate(-4deg) scale(0.985);
    filter: saturate(1.16) brightness(1.05);
  }
  72% {
    transform: translate(calc(-50% + var(--pet-x) - 28px), calc(var(--pet-y) + 10px)) rotate(-2deg) scale(0.992);
  }
}

@keyframes galgame-pet-rest {
  0%, 100% {
    transform: translate(calc(-50% + var(--pet-x)), var(--pet-y)) rotate(0deg) scale(1);
  }
  50% {
    transform: translate(calc(-50% + var(--pet-x) + 24px), calc(var(--pet-y) + 48px)) rotate(3deg) scale(0.97);
  }
}

@keyframes galgame-pet-feed {
  0%, 100% {
    transform: translate(calc(-50% + var(--pet-x)), var(--pet-y)) scale(1);
  }
  38% {
    transform: translate(calc(-50% + var(--pet-x)), calc(var(--pet-y) + 36px)) scale(1.06, 0.95);
  }
  66% {
    transform: translate(calc(-50% + var(--pet-x)), calc(var(--pet-y) - 10px)) scale(0.992, 1.01);
  }
}

.composer textarea {
  min-height: 48px;
  max-height: 160px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.stage-light {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.28) 56%, rgba(0, 0, 0, 0.68) 100%),
    radial-gradient(ellipse at 50% 76%, color-mix(in srgb, var(--accent-warm), transparent 82%), transparent 15rem),
    radial-gradient(circle at 50% 24%, color-mix(in srgb, var(--accent), transparent 72%), transparent 22rem);
}

.standee {
  position: absolute;
  left: 50%;
  bottom: 110px;
  transform: translateX(-50%);
  max-width: min(92%, 390px);
  max-height: 74%;
  object-fit: contain;
  filter: drop-shadow(0 34px 44px rgba(0, 0, 0, 0.56));
}

.character-sheet {
  position: relative;
  z-index: 1;
  border-radius: 18px;
  padding: 16px;
  background: rgba(15, 18, 26, 0.88);
  box-shadow: none;
}

.character-sheet span {
  color: var(--muted);
  font-size: 13px;
}

.character-sheet h2 {
  margin-top: 5px;
  font-size: 30px;
}

.character-sheet p {
  margin-top: 8px;
  color: var(--soft);
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.tags span {
  padding: 6px 9px;
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid var(--line);
}

.play-status {
  display: grid;
  gap: 10px;
  margin: 12px 0;
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--accent-warm), transparent 72%);
  border-radius: var(--radius-md);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent-warm), transparent 88%), rgba(255, 255, 255, 0.045));
}

.play-status[hidden] {
  display: none;
}

.play-status-head,
.play-vitals {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
}

.play-status-head b {
  color: var(--text);
  font-size: 13px;
}

.play-status-head span,
.play-vitals span {
  color: var(--soft);
  font-size: 11.5px;
  font-weight: 750;
}

.play-meters {
  display: grid;
  gap: 7px;
}

.play-stat {
  display: grid;
  grid-template-columns: 34px 24px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
}

.play-stat span,
.play-stat strong {
  color: var(--soft);
  font-size: 11px;
}

.play-stat strong {
  text-align: right;
}

.play-stat i {
  position: relative;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.play-stat i::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--stat);
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-warm), var(--accent-2));
}

.memory-list {
  display: grid;
  gap: 5px;
  padding-top: 3px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.memory-list strong {
  color: var(--soft);
  font-size: 11px;
}

.memory-list span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.ending-card {
  display: grid;
  gap: 5px;
  padding: 11px 12px;
  border: 1px solid color-mix(in srgb, var(--accent-2), transparent 58%);
  border-radius: 14px;
  background:
    radial-gradient(circle at 12% 0%, color-mix(in srgb, var(--accent-2), transparent 78%), transparent 8rem),
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.025));
}

.ending-card span {
  color: color-mix(in srgb, var(--accent-2), white 20%);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.ending-card strong {
  color: var(--text);
  font-size: 15px;
}

.ending-card p,
.ending-card em {
  margin: 0;
  color: var(--soft);
  font-size: 12px;
  line-height: 1.5;
}

.ending-card em {
  color: var(--muted);
  font-style: normal;
}

.sheet-action {
  width: 100%;
  min-height: var(--control-h);
  margin: 0 0 12px;
  border: 1px solid color-mix(in srgb, var(--accent), transparent 56%);
  border-radius: var(--radius-md);
  color: var(--text);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent), transparent 78%), rgba(255, 255, 255, 0.08));
  font-size: 13px;
  font-weight: 800;
}

.sheet-action:hover {
  border-color: color-mix(in srgb, var(--accent), white 18%);
  box-shadow: var(--focus-ring);
}

.sheet-action:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  box-shadow: none;
}

a {
  color: var(--accent-2);
}

.modal {
  width: min(1240px, calc(100vw - 36px));
  max-height: min(920px, calc(100dvh - 36px));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 0;
  background: rgba(13, 16, 23, 0.96);
  color: var(--text);
  box-shadow: 0 18px 28px rgba(0, 0, 0, 0.44);
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(10px);
}

html[data-ui-style="galgame"] .modal::backdrop {
  background: rgba(0, 0, 0, 0.48);
  backdrop-filter: none;
}

.onboarding-modal {
  width: min(720px, calc(100vw - 36px));
}

.onboarding-body {
  display: grid;
  gap: 16px;
  max-height: calc(100dvh - 140px);
  overflow: auto;
  padding: 22px 24px 24px;
}

.onboarding-body section {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.045);
}

.onboarding-body h3 {
  font-size: 16px;
}

.onboarding-body p,
.onboarding-body li {
  color: var(--soft);
  line-height: 1.7;
}

.onboarding-body ul {
  margin: 0;
  padding-left: 20px;
}

.onboarding-body button {
  justify-self: end;
  min-height: 42px;
  padding: 0 18px;
  border-radius: 12px;
  color: #071015;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-weight: 900;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
}

.icon-button {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  font-size: 24px;
}

.modal-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(430px, 500px);
  gap: 18px;
  height: min(780px, calc(100dvh - 132px));
  padding: 22px;
}

.library-pane {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
}

.tools-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.library-count {
  min-width: 72px;
  color: var(--soft);
  font-size: 12px;
  text-align: right;
  white-space: nowrap;
}

.library-intro {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(122, 168, 255, 0.08), rgba(255, 156, 200, 0.06)),
    rgba(255, 255, 255, 0.02);
}

.library-intro strong {
  color: var(--text);
  font-size: 14px;
}

.library-intro span {
  color: var(--soft);
  font-size: 12px;
  line-height: 1.55;
}

.character-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  align-content: start;
  gap: 14px;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.character-card {
  position: relative;
  min-height: 248px;
  aspect-ratio: 0.74;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #151924;
  color: var(--text);
  text-align: left;
  transition: border-color 0.18s ease, transform 0.18s ease, background 0.18s ease;
}

.character-card.active {
  border-color: color-mix(in srgb, var(--accent), white 18%);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent), transparent 78%);
}

.character-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent), transparent 46%);
}

.character-pick {
  width: 100%;
  height: 100%;
  min-height: inherit;
  padding: 0;
  background:
    radial-gradient(circle at 50% 26%, color-mix(in srgb, var(--accent), transparent 72%), transparent 10rem),
    #151924;
  color: var(--text);
}

.character-pick:focus-visible,
.delete-card:focus-visible,
.character-empty button:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent), white 18%);
  outline-offset: 2px;
}

.character-card img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
  padding: 0;
}

.delete-card {
  position: absolute;
  z-index: 3;
  top: 10px;
  right: 10px;
  border-radius: 10px;
  padding: 7px 9px;
  color: var(--text);
  background: rgba(255, 117, 107, 0.18);
  border: 1px solid rgba(255, 117, 107, 0.4);
  font-size: 12px;
  font-weight: 800;
}

.delete-card:hover {
  background: rgba(255, 117, 107, 0.3);
}

.character-card-copy {
  position: absolute;
  inset: auto 0 0 0;
  display: grid;
  gap: 7px;
  padding: 58px 14px 14px;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.9) 38%, rgba(0, 0, 0, 0.96));
  pointer-events: none;
}

.character-card-vibe {
  justify-self: start;
  display: inline-grid;
  place-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  color: #071015;
  background: linear-gradient(135deg, var(--accent-warm), var(--accent-2));
  font-size: 11px;
  font-weight: 800;
}

.character-card b,
.character-card small {
  display: block;
}

.character-card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.character-card-title b {
  min-width: 0;
  overflow: hidden;
  font-size: 17px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.character-card-title span {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 3px 7px;
  color: #071015;
  background: color-mix(in srgb, var(--accent), white 14%);
  font-size: 11px;
  font-weight: 800;
}

.character-card small {
  overflow: hidden;
  color: rgba(255, 255, 255, 0.78);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.character-card p {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.68);
  font-size: 12px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.character-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.character-card-meta span {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 3px 7px;
  color: rgba(255, 255, 255, 0.76);
  background: rgba(255, 255, 255, 0.07);
  font-size: 11px;
  line-height: 1;
}

.character-empty {
  grid-column: 1 / -1;
  display: grid;
  place-items: center;
  gap: 10px;
  min-height: 330px;
  padding: 24px;
  border: 1px dashed rgba(255, 255, 255, 0.16);
  border-radius: 16px;
  background:
    radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--accent), transparent 88%), transparent 18rem),
    rgba(255, 255, 255, 0.035);
  text-align: center;
}

.character-empty strong {
  font-size: 18px;
}

.character-empty span {
  max-width: 34ch;
  color: var(--soft);
  line-height: 1.6;
}

.character-empty-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
}

.character-empty button {
  min-height: 38px;
  border-radius: 12px;
  padding: 0 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  font-weight: 800;
}

.character-empty button:last-child {
  color: #071015;
  background: color-mix(in srgb, var(--accent), white 12%);
  border-color: transparent;
}

.create-form {
  display: grid;
  align-content: start;
  gap: 14px;
  min-height: 0;
  overflow: auto;
  padding: 4px 4px 4px 0;
  border-radius: 0;
  border: 0;
  background: transparent;
}

.create-header,
.create-section,
.create-preview {
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.055);
}

.create-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
}

.create-header h3 {
  margin-top: 4px;
}

.create-header button {
  flex: 0 0 auto;
}

.create-preview {
  display: grid;
  grid-template-columns: 0.82fr 1fr 1fr;
  gap: 10px;
  padding: 10px;
}

.material-slot {
  position: relative;
  display: grid;
  grid-template-rows: minmax(118px, 1fr) auto;
  min-width: 0;
  min-height: 156px;
  margin: 0;
  overflow: hidden;
  border-radius: 13px;
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.08) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.08) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.08) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.08) 75%),
    radial-gradient(circle at 50% 18%, color-mix(in srgb, var(--accent-warm), transparent 76%), transparent 7rem),
    rgba(8, 11, 17, 0.68);
  background-position: 0 0, 0 8px, 8px -8px, -8px 0, 0 0, 0 0;
  background-size: 16px 16px, 16px 16px, 16px 16px, 16px 16px, auto, auto;
}

.material-slot img {
  width: 100%;
  height: 100%;
  min-height: 118px;
  object-fit: contain;
  object-position: center bottom;
  padding: 10px;
}

.avatar-slot img {
  width: min(112px, 78%);
  aspect-ratio: 1;
  align-self: center;
  justify-self: center;
  border-radius: 999px;
  object-fit: cover;
  padding: 0;
  border: 3px solid rgba(255, 255, 255, 0.86);
}

.material-slot figcaption {
  padding: 8px 10px 10px;
  color: var(--soft);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.create-section {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.create-section h4 {
  margin: 0;
  color: var(--soft);
  font-size: 13px;
}

.form-grid,
.upload-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.span-2 {
  grid-column: 1 / -1;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.candidate-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.candidate-tools button {
  padding: 10px 12px;
}

#candidateStatus {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.candidate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  max-height: 430px;
  overflow: auto;
  padding: 2px 4px 2px 0;
}

.candidate-card {
  display: grid;
  grid-template-rows: 160px auto;
  min-height: 280px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(14, 18, 27, 0.92);
}

.candidate-thumb {
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.055) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.055) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.055) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.055) 75%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent),
    #0d1119;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0, 0 0;
  background-size: 16px 16px, 16px 16px, 16px 16px, 16px 16px, auto;
}

.candidate-thumb img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  object-position: center;
}

.candidate-copy {
  display: grid;
  align-content: space-between;
  gap: 12px;
  min-width: 0;
  padding: 12px;
}

.candidate-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.candidate-meta b,
.candidate-meta small,
.candidate-meta em {
  display: block;
}

.candidate-meta b {
  width: fit-content;
  max-width: 100%;
  padding: 4px 8px;
  border-radius: 999px;
  color: #071015;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-size: 12px;
}

.candidate-meta small {
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quality-badge {
  width: fit-content;
  max-width: 100%;
  padding: 4px 8px;
  border-radius: 999px;
  color: #f7fbff;
  background: rgba(255, 255, 255, 0.11);
  border: 1px solid rgba(255, 255, 255, 0.16);
  font-size: 12px;
  font-weight: 900;
}

.candidate-card[data-quality="优选"] .quality-badge {
  color: #071015;
  background: linear-gradient(135deg, #a6f2d8, #ffe19a);
}

.candidate-card[data-quality="慎用"] {
  opacity: 0.72;
}

.candidate-card[data-quality="慎用"] .quality-badge {
  color: #ffe6ea;
  background: rgba(255, 117, 107, 0.2);
  border-color: rgba(255, 117, 107, 0.34);
}

.candidate-meta em {
  margin-top: 6px;
  color: #f5b9c6;
  font-size: 11px;
  font-style: normal;
  line-height: 1.45;
}

.candidate-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.candidate-actions button {
  min-height: 36px;
  padding: 0 8px;
  border-radius: 10px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 12px;
  font-weight: 800;
}

.candidate-actions button:hover,
.candidate-actions button[data-selected="true"] {
  color: #071015;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
}

.pet-style-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
}

.file-line,
.check-line {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
  color: var(--soft);
  font-size: 13px;
  font-weight: 700;
}

.file-line {
  align-items: stretch;
  flex-direction: column;
}

.file-line input {
  min-height: 44px;
  padding: 9px 10px;
}

.check-line input {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  accent-color: var(--accent-warm);
}

.pet-style-control label {
  position: relative;
}

.pet-style-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.pet-style-control span {
  display: grid;
  place-items: center;
  min-height: 36px;
  border-radius: 10px;
  color: var(--soft);
  font-weight: 800;
  font-size: 12px;
}

.pet-style-control input:checked + span {
  color: #071015;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.create-progress {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background:
    radial-gradient(circle at 16% 0%, color-mix(in srgb, var(--accent), transparent 72%), transparent 42%),
    rgba(255, 255, 255, 0.035);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.create-progress[hidden] {
  display: none;
}

.create-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: rgba(255, 246, 250, 0.88);
  font-size: 12px;
  font-weight: 780;
}

.create-progress-head b {
  color: color-mix(in srgb, var(--accent), white 28%);
  font-variant-numeric: tabular-nums;
}

.create-progress-track {
  position: relative;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.create-progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--accent-warm));
  box-shadow: 0 0 18px color-mix(in srgb, var(--accent), transparent 35%);
  transition: width 0.38s ease;
}

.create-progress[data-tone="done"] .create-progress-track span {
  background: linear-gradient(90deg, #76f0bd, #b8ffd9);
}

.create-progress[data-tone="error"] .create-progress-track span {
  background: linear-gradient(90deg, #ff6f8d, #ffd0d8);
}

#createStatus {
  min-height: 22px;
  color: var(--muted);
  font-size: 13px;
}

html[data-ui-style="galgame"] #app {
  display: block;
  position: relative;
  isolation: isolate;
  min-height: 100dvh;
  background: var(--galgame-bg-image) center / cover no-repeat;
}

html[data-ui-style="galgame"] #app::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at var(--scene-light-x, 72%) var(--scene-light-y, 18%), var(--scene-glow, rgba(255, 210, 170, 0.16)), transparent 24rem),
    linear-gradient(90deg, rgba(7, 9, 18, 0.3) 0%, transparent 30%, transparent 68%, rgba(7, 9, 18, 0.2) 100%),
    linear-gradient(180deg, var(--scene-top, rgba(6, 8, 16, 0.1)) 0%, transparent 44%, var(--scene-bottom, rgba(5, 6, 10, 0.62)) 100%);
}

html[data-ui-style="galgame"] #app::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: var(--galgame-bg-image-prev) center / cover no-repeat;
  opacity: 0;
}

html[data-ui-style="galgame"][data-bg-transition="active"] #app::after {
  animation: bg-crossfade-out 0.52s cubic-bezier(.16, 1, .3, 1) both;
}

html[data-ui-style="galgame"][data-galgame-atmosphere="on"] .galgame-atmosphere {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: block;
  pointer-events: none;
  opacity: 0.42;
  mix-blend-mode: screen;
  background:
    radial-gradient(circle at 16% 20%, rgba(255, 255, 255, 0.28) 0 1px, transparent 2px),
    radial-gradient(circle at 78% 34%, rgba(255, 255, 255, 0.2) 0 1px, transparent 2px),
    radial-gradient(circle at 48% 76%, rgba(255, 240, 210, 0.2) 0 1px, transparent 2px);
  background-size: 180px 130px, 240px 180px, 320px 220px;
  animation: scene-motes 14s linear infinite;
}

html[data-ui-style="galgame"][data-galgame-atmosphere="on"][data-galgame-scene="street"] .galgame-atmosphere,
html[data-ui-style="galgame"][data-galgame-atmosphere="on"][data-galgame-scene="room"] .galgame-atmosphere,
html[data-ui-style="galgame"][data-galgame-atmosphere="on"][data-galgame-scene="nightRoom"] .galgame-atmosphere {
  opacity: 0.32;
  mix-blend-mode: screen;
  background:
    linear-gradient(112deg, transparent 0 46%, rgba(210, 230, 255, 0.5) 47%, transparent 49%),
    linear-gradient(112deg, transparent 0 62%, rgba(210, 230, 255, 0.32) 63%, transparent 65%);
  background-size: 90px 150px, 130px 220px;
  animation: scene-rain 0.9s linear infinite;
}

html[data-ui-style="galgame"][data-galgame-atmosphere="on"][data-galgame-scene="sakura"] .galgame-atmosphere,
html[data-ui-style="galgame"][data-galgame-atmosphere="on"][data-galgame-scene="riverside"] .galgame-atmosphere,
html[data-ui-style="galgame"][data-galgame-atmosphere="on"][data-galgame-scene="shrine"] .galgame-atmosphere {
  opacity: 0.34;
  mix-blend-mode: normal;
  background:
    radial-gradient(ellipse at 22% 18%, rgba(255, 190, 214, 0.7) 0 2px, transparent 4px),
    radial-gradient(ellipse at 72% 28%, rgba(255, 218, 232, 0.62) 0 2px, transparent 4px),
    radial-gradient(ellipse at 46% 62%, rgba(255, 236, 244, 0.5) 0 1px, transparent 3px);
  background-size: 180px 120px, 260px 170px, 340px 220px;
  animation: scene-petals 18s linear infinite;
}

html[data-ui-style="galgame"] body {
  background: #10131b;
}

html[data-galgame-scene="library"] {
  --scene-glow: rgba(255, 206, 142, 0.18);
  --scene-bottom: rgba(42, 28, 32, 0.54);
}

html[data-galgame-scene="seaside"],
html[data-galgame-scene="riverside"],
html[data-galgame-scene="sakura"] {
  --scene-glow: rgba(255, 224, 160, 0.16);
  --scene-bottom: rgba(28, 46, 72, 0.46);
}

html[data-galgame-scene="shrine"] {
  --scene-glow: rgba(255, 142, 126, 0.18);
  --scene-bottom: rgba(32, 20, 28, 0.58);
}

html[data-galgame-scene="cafe"],
html[data-galgame-scene="nightRoom"],
html[data-galgame-scene="room"] {
  --scene-light-x: 28%;
  --scene-light-y: 26%;
  --scene-glow: rgba(255, 184, 126, 0.18);
  --scene-bottom: rgba(11, 12, 22, 0.62);
}

html[data-galgame-scene="rooftop"],
html[data-galgame-scene="classroom"] {
  --scene-glow: rgba(255, 245, 205, 0.16);
  --scene-bottom: rgba(24, 44, 72, 0.48);
}

html[data-galgame-scene="street"] {
  --scene-glow: rgba(120, 174, 255, 0.16);
  --scene-bottom: rgba(4, 8, 18, 0.7);
}

html[data-ui-style="galgame"] .rail {
  display: none;
}

html[data-ui-style="galgame"] .style-dock {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
  width: 58px;
  max-height: 40px;
  overflow: hidden;
  padding: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.46);
  border: 1px solid rgba(255, 255, 255, 0.62);
  opacity: 0.82;
  backdrop-filter: none;
  box-shadow: 0 8px 18px rgba(46, 68, 104, 0.16);
  cursor: pointer;
  transition: border-radius 0.16s ease, background 0.16s ease, opacity 0.16s ease, border-color 0.16s ease;
}

html[data-ui-style="galgame"] .style-dock::before {
  content: "菜单";
  display: grid;
  place-items: center;
  width: 46px;
  min-height: 28px;
  color: rgba(255, 255, 255, 0.92);
  font-size: 12px;
  font-weight: 800;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.55);
}

html[data-ui-style="galgame"] .style-dock > * {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-2px);
  transition: opacity 0.14s ease, transform 0.14s ease;
}

html[data-ui-style="galgame"] .style-dock:hover,
html[data-ui-style="galgame"] .style-dock:focus-within,
html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock {
  grid-template-columns: repeat(auto-fit, minmax(66px, 1fr));
  width: min(980px, calc(100vw - 36px));
  max-height: min(72vh, 360px);
  padding: 10px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(237, 246, 255, 0.64)),
    rgba(255, 255, 255, 0.6);
  border-color: rgba(255, 255, 255, 0.76);
  opacity: 1;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 16px 34px rgba(36, 62, 94, 0.22);
}

html[data-ui-style="galgame"] .style-dock:hover .galgame-bg-picker,
html[data-ui-style="galgame"] .style-dock:focus-within .galgame-bg-picker,
html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock .galgame-bg-picker {
  grid-column: 1 / -1;
}

html[data-ui-style="galgame"] .style-dock:hover::before,
html[data-ui-style="galgame"] .style-dock:focus-within::before,
html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock::before {
  display: none;
}

html[data-ui-style="galgame"] .style-dock:hover > *,
html[data-ui-style="galgame"] .style-dock:focus-within > *,
html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock > * {
  opacity: 1;
  pointer-events: auto;
  transform: none;
}

html[data-ui-style="galgame"] .style-dock span,
html[data-ui-style="galgame"] .style-dock button {
  min-height: 34px;
  color: rgba(35, 55, 82, 0.9);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(235, 245, 255, 0.68));
  border-color: rgba(120, 156, 195, 0.24);
  backdrop-filter: none;
  box-shadow: 0 4px 8px rgba(63, 94, 130, 0.08);
}

html[data-ui-style="galgame"] .style-dock span:hover,
html[data-ui-style="galgame"] .style-dock button:hover {
  color: #14304d;
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(120, 156, 195, 0.44);
  transform: translateY(-1px);
}

html[data-ui-style="galgame"] .style-dock input:checked + span,
html[data-ui-style="galgame"] .style-dock > button[data-active="true"] {
  color: #10233a;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent-warm), white 26%), color-mix(in srgb, var(--accent-2), white 18%));
  border-color: rgba(255, 255, 255, 0.86);
}

html[data-ui-style="galgame"] .galgame-tool {
  display: grid;
}

html[data-ui-style="galgame"] .galgame-frequency-control {
  display: flex;
}

html[data-ui-style="galgame"] .galgame-frequency-control span {
  min-height: 28px;
  padding: 0;
  border: 0;
  color: rgba(255, 255, 255, 0.72);
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

html[data-ui-style="galgame"] .galgame-frequency-control select {
  width: 72px;
  min-height: 28px;
  padding: 0 8px;
  border-radius: 999px;
}

html[data-ui-style="galgame"] .galgame-bg-picker {
  order: 2;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(74px, 1fr));
  gap: 7px;
  width: 100%;
}

html[data-ui-style="galgame"] .galgame-user-bg-choices {
  display: contents;
}

html[data-ui-style="galgame"] .galgame-bg-upload span {
  width: 100%;
  min-height: 46px;
  padding: 0 8px;
  border-radius: 12px;
  color: rgba(38, 60, 88, 0.9);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(230, 244, 255, 0.62)),
    rgba(255, 255, 255, 0.72);
  border: 1px dashed rgba(90, 129, 172, 0.42);
  text-shadow: none;
}

html[data-ui-style="galgame"] .galgame-bg-upload[data-active="true"] span {
  color: #fff;
  border-color: var(--accent-2);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.34);
}

html[data-ui-style="galgame"] .galgame-bg-choice {
  isolation: isolate;
  width: 100%;
  min-height: 46px;
  padding: 0;
  overflow: hidden;
  border-radius: 12px;
  color: rgba(255, 255, 255, 0.92);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(20, 34, 54, 0.56)),
    var(--bg-thumb) center / cover no-repeat;
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    0 4px 8px rgba(63, 94, 130, 0.12);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.68);
}

html[data-ui-style="galgame"] .galgame-custom-bg-choice {
  outline: 1px solid rgba(255, 255, 255, 0.34);
  outline-offset: -4px;
}

html[data-ui-style="galgame"] .galgame-bg-choice:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.52);
}

html[data-ui-style="galgame"] .galgame-bg-choice[data-active="true"] {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.94);
  box-shadow:
    inset 0 0 0 2px color-mix(in srgb, var(--accent-2), white 18%),
    0 8px 18px rgba(47, 80, 118, 0.24);
}

.galgame-log {
  position: fixed;
  top: 72px;
  right: 18px;
  z-index: 24;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(420px, calc(100vw - 36px));
  max-height: min(560px, calc(100dvh - 112px));
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 18px;
  color: #20324c;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(235, 246, 255, 0.64)),
    rgba(255, 255, 255, 0.62);
  backdrop-filter: none;
  box-shadow: 0 12px 28px rgba(48, 66, 96, 0.22);
}

.galgame-log[hidden] {
  display: none;
}

.galgame-log-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(112, 146, 184, 0.18);
}

.galgame-log-head strong {
  font-size: 14px;
}

.galgame-log-head button {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  color: #17314f;
  background: rgba(255, 255, 255, 0.82);
  font-size: 12px;
  font-weight: 800;
}

.galgame-log-body {
  display: grid;
  gap: 10px;
  min-height: 0;
  overflow: auto;
  padding: 14px;
}

.galgame-log-body article {
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid rgba(107, 141, 180, 0.18);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.56);
}

.galgame-log-body article.user {
  border-color: rgba(90, 140, 216, 0.22);
  background: rgba(214, 235, 255, 0.58);
}

.galgame-log-body article.choice {
  border-color: color-mix(in srgb, var(--accent-2), transparent 62%);
  background: color-mix(in srgb, var(--accent-2), white 82%);
}

.galgame-log-body article.route-event {
  border-color: rgba(255, 156, 200, 0.26);
  background: rgba(255, 235, 246, 0.62);
}

.galgame-log-body b {
  color: #315a84;
  font-size: 12px;
}

.galgame-log-body p,
.galgame-log-empty {
  margin: 0;
  color: rgba(35, 52, 76, 0.78);
  font-size: 13px;
  line-height: 1.65;
}

.galgame-route-status {
  position: fixed;
  left: 18px;
  top: 18px;
  z-index: 19;
  max-width: min(520px, calc(100vw - 36px));
  min-height: 36px;
  padding: 8px 14px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.9);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.05)),
    color-mix(in srgb, var(--accent), #121622 58%);
  box-shadow: 0 8px 14px rgba(0, 0, 0, 0.18);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.58);
  font-size: 13px;
  font-weight: 800;
  pointer-events: none;
}

.galgame-route-status[hidden],
html:not([data-ui-style="galgame"]) .galgame-route-status {
  display: none;
}

html[data-route-mood="warm"] .chat-shell::before,
html[data-route-mood="intimate"] .chat-shell::before {
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent-warm), white 10%), color-mix(in srgb, var(--accent), #251522 38%));
}

html[data-route-mood="trust"] .chat-shell::before {
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent-2), white 10%), color-mix(in srgb, var(--accent), #162532 36%));
}

html[data-route-mood="distant"] .chat-shell::before {
  background: linear-gradient(135deg, rgba(100, 116, 139, 0.9), rgba(37, 46, 61, 0.9));
}

.route-editor {
  width: min(720px, calc(100vw - 36px));
  max-height: min(720px, calc(100dvh - 48px));
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 14px;
  color: #fff;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02)),
    rgba(17, 20, 30, 0.94);
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.36);
}

.route-editor::backdrop {
  background: rgba(0, 0, 0, 0.38);
}

.route-editor form {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  max-height: min(720px, calc(100dvh - 48px));
}

.route-editor-head,
.route-editor-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.route-editor-head strong,
.route-editor-head span {
  display: block;
}

.route-editor-head strong {
  font-size: 16px;
}

.route-editor-head span {
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 12px;
}

.route-editor-head button,
.route-editor-actions button {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  color: #121622;
  background: rgba(255, 255, 255, 0.88);
  font-size: 12px;
  font-weight: 850;
}

.route-editor-actions {
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  border-bottom: 0;
}

.route-editor-actions button[type="submit"] {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.route-editor-body {
  display: grid;
  gap: 12px;
  min-height: 0;
  overflow: auto;
  padding: 16px;
}

.route-editor-row {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 10px;
}

.route-editor-row label {
  display: grid;
  gap: 6px;
  color: rgba(255, 255, 255, 0.76);
  font-size: 12px;
  font-weight: 800;
}

.route-editor-effects {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.route-editor input {
  min-height: 38px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.08);
}

html[data-ui-style="galgame"] .stage {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  border: 0;
  padding: 0;
  background: transparent;
  backdrop-filter: none;
  pointer-events: none;
}

html[data-ui-style="galgame"] .pet-surface {
  position: absolute;
  inset: 0;
  height: 100%;
  min-height: 0;
  border: 0;
  background: transparent;
}

html[data-ui-style="galgame"] .pet-actor,
html[data-ui-style="galgame"] .live2d-stage {
  left: 70%;
  bottom: 0;
  height: 90vh;
  max-width: none;
  transform: translateX(-50%);
  pointer-events: auto;
  margin-bottom: 0;
  transition: filter 0.22s ease, opacity 0.22s ease;
}

html[data-ui-style="galgame"] .pet-actor::before {
  content: "";
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: 1.5vh;
  z-index: 1;
  height: 7vh;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.36), rgba(0, 0, 0, 0.14) 44%, transparent 72%);
  transform: translateY(34%);
  pointer-events: none;
}

html[data-ui-style="galgame"] .pet-actor.chibi-pet {
  height: 65vh;
}

html[data-ui-style="galgame"] .pet-avatar {
  filter: drop-shadow(0 10px 25px rgba(0, 0, 0, 0.3));
  object-position: center bottom;
  transition: filter 0.22s ease, transform 0.22s ease;
}

html[data-ui-style="galgame"] .pet-avatar.opaque-pet {
  mix-blend-mode: normal;
  border-radius: 0;
}

html[data-ui-style="galgame"] .pet-avatar.dark-backdrop-pet {
  mix-blend-mode: screen;
}

html[data-ui-style="galgame"] .pet-avatar.light-backdrop-pet {
  mix-blend-mode: multiply;
}

html[data-ui-style="galgame"] .pet-avatar.unclean-pet {
  opacity: 0.92;
}

html[data-ui-style="galgame"] .pet-actor[data-emotion="happy"] .pet-avatar {
  filter: saturate(1.14) brightness(1.08) drop-shadow(0 12px 28px rgba(0, 0, 0, 0.28));
  transform: translateY(-4px);
}

html[data-ui-style="galgame"] .pet-actor[data-emotion="shy"] .pet-avatar {
  filter: saturate(1.16) brightness(1.04) sepia(0.1) drop-shadow(0 12px 28px rgba(255, 156, 200, 0.28));
  transform: translateX(-8px) rotate(-1.5deg);
}

html[data-ui-style="galgame"] .pet-actor[data-emotion="sad"] .pet-avatar {
  filter: saturate(0.82) brightness(0.9) drop-shadow(0 10px 25px rgba(0, 0, 0, 0.34));
  transform: translateY(8px);
}

html[data-ui-style="galgame"] .pet-actor[data-emotion="angry"] .pet-avatar {
  filter: contrast(1.12) saturate(1.16) drop-shadow(0 12px 28px rgba(255, 117, 107, 0.3));
  transform: translateX(6px) rotate(1.4deg);
}

html[data-ui-style="galgame"] .pet-actor[data-emotion="surprised"] .pet-avatar {
  filter: brightness(1.1) saturate(1.08) drop-shadow(0 12px 28px rgba(122, 168, 255, 0.3));
  transform: translateY(-14px) scale(1.015);
}

html[data-ui-style="galgame"] .pet-actor[data-motion="happy"],
html[data-ui-style="galgame"] .live2d-stage[data-motion="happy"] {
  animation: galgame-pet-happy 1.9s cubic-bezier(.16, 1, .3, 1) both;
}

html[data-ui-style="galgame"] .pet-actor[data-motion="wave"],
html[data-ui-style="galgame"] .live2d-stage[data-motion="wave"] {
  animation: galgame-pet-wave 2s cubic-bezier(.16, 1, .3, 1) both;
}

html[data-ui-style="galgame"] .pet-actor[data-motion="jump"],
html[data-ui-style="galgame"] .live2d-stage[data-motion="jump"] {
  animation: galgame-pet-jump 1.85s cubic-bezier(.16, 1, .3, 1) both;
}

html[data-ui-style="galgame"] .pet-actor[data-motion="shy"],
html[data-ui-style="galgame"] .live2d-stage[data-motion="shy"] {
  animation: galgame-pet-shy 2.05s ease both;
}

html[data-ui-style="galgame"] .pet-actor[data-motion="rest"],
html[data-ui-style="galgame"] .live2d-stage[data-motion="rest"] {
  animation: galgame-pet-rest 2.05s ease both;
}

html[data-ui-style="galgame"] .pet-actor[data-motion="feed"],
html[data-ui-style="galgame"] .live2d-stage[data-motion="feed"] {
  animation: galgame-pet-feed 1.8s ease both;
}

html[data-ui-style="galgame"] .pet-shadow,
html[data-ui-style="galgame"] .stage-light,
html[data-ui-style="galgame"] .character-sheet,
html[data-ui-style="galgame"] .pet-bubble,
html[data-ui-style="galgame"] .pet-toolbar {
  display: none;
}

html[data-ui-style="galgame"] .chat {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-direction: column;
  padding: 0 0 clamp(22px, 4vh, 44px);
  background: transparent;
}

html[data-ui-style="galgame"] .chat-head {
  display: none;
}

html[data-ui-style="galgame"] .chat-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(980px, calc(100vw - 112px));
  height: auto;
  min-height: 158px;
  margin: 0;
  overflow: visible;
  border: 1px solid rgba(220, 238, 255, 0.28);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.11), transparent 26%),
    linear-gradient(90deg, color-mix(in srgb, var(--accent), transparent 90%), transparent 42%, rgba(255, 255, 255, 0.035)),
    linear-gradient(180deg, rgba(23, 27, 42, 0.72), rgba(10, 12, 20, 0.66));
  backdrop-filter: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    inset 0 -1px 0 rgba(255, 255, 255, 0.06),
    0 16px 28px rgba(0, 0, 0, 0.28);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

html[data-ui-style="galgame"] .chat-shell::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  top: 8px;
  height: 1px;
  background:
    linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.46), transparent);
  pointer-events: none;
}

html[data-ui-style="galgame"][data-galgame-dialogue="hidden"] .chat-shell {
  opacity: 0;
  pointer-events: none;
  transform: translateY(18px);
}

html[data-ui-style="galgame"] .chat-shell::before {
  content: var(--galgame-name, "角色");
  position: absolute;
  top: -21px;
  left: 26px;
  z-index: 10;
  min-width: 128px;
  padding: 6px 22px 7px;
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: 9px 9px 9px 3px;
  color: #fff;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent-warm), white 6%), color-mix(in srgb, var(--accent), #263451 32%));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.34),
    0 6px 12px rgba(0, 0, 0, 0.22);
  text-align: center;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
}

html[data-ui-style="galgame"] .chat-shell:has(.bubble.user)::before {
  content: "我";
  background: linear-gradient(135deg, rgba(80, 130, 200, 0.95), rgba(50, 90, 150, 0.95));
}

html[data-ui-style="galgame"] .messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 10px;
  overflow: hidden;
  padding: 34px 36px 8px;
  background: transparent;
}

html[data-ui-style="galgame"] .empty-state {
  display: grid;
  justify-items: start;
  gap: 8px;
  max-width: min(660px, 100%);
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: rgba(238, 244, 255, 0.82);
  text-align: left;
  line-height: 1.55;
}

html[data-ui-style="galgame"] .empty-state strong {
  color: rgba(255, 255, 255, 0.96);
  font-size: 17px;
  line-height: 1.35;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.62);
}

html[data-ui-style="galgame"] .empty-state span {
  max-width: 46ch;
  color: rgba(229, 238, 255, 0.78);
  font-size: 13px;
}

html[data-ui-style="galgame"] .starter-actions {
  justify-content: flex-start;
  gap: 7px;
  margin-top: 6px;
}

html[data-ui-style="galgame"] .starter-actions button {
  min-height: 30px;
  padding: 0 13px;
  border-radius: 999px;
  color: rgba(244, 249, 255, 0.88);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.055));
  border: 1px solid rgba(230, 240, 255, 0.24);
  box-shadow: none;
  text-shadow: 0 1px 5px rgba(0, 0, 0, 0.46);
  font-size: 11px;
  font-weight: 800;
}

html[data-ui-style="galgame"] .starter-actions button:hover,
html[data-ui-style="galgame"] .starter-actions button:focus-visible {
  outline: 0;
  color: #102033;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), color-mix(in srgb, var(--accent-2), white 42%));
  border-color: rgba(255, 255, 255, 0.72);
  text-shadow: none;
}

html[data-ui-style="galgame"] .bubble {
  max-width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: #fff;
  text-shadow:
    0 1px 3px rgba(0, 0, 0, 0.82),
    0 0 12px rgba(0, 0, 0, 0.26);
  font-family: "Noto Serif SC", "Microsoft YaHei", serif;
  font-size: 21px;
  line-height: 1.64;
  text-wrap: pretty;
}

html[data-ui-style="galgame"] .bubble.user {
  color: #e0f0ff;
}

html[data-ui-style="galgame"] .bubble.assistant {
  color: #fff;
}

html[data-ui-style="galgame"] .bubble.assistant::after {
  content: "";
  display: inline-block;
  width: 0.52em;
  height: 1em;
  margin-left: 4px;
  border-right: 2px solid rgba(255, 255, 255, 0.82);
  vertical-align: -0.16em;
  animation: galgame-caret 0.9s steps(1) infinite;
}

html[data-ui-style="galgame"] .composer {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: auto;
  padding: 10px 28px 18px;
  border: 0;
  border-top: 1px solid rgba(232, 242, 255, 0.14);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(0, 0, 0, 0.1));
  box-shadow: none;
}

html[data-ui-style="galgame"] .composer::before {
  content: none;
}

html[data-ui-style="galgame"] .composer textarea {
  flex: 1;
  min-height: 42px;
  max-height: 86px;
  padding: 10px 13px;
  border: 1px solid rgba(232, 242, 255, 0.16);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.055);
  color: #fff;
  font-size: 15px;
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

html[data-ui-style="galgame"] .composer textarea:focus {
  border-color: color-mix(in srgb, var(--accent-2), white 20%);
  background: rgba(255, 255, 255, 0.09);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-2), transparent 78%);
}

html[data-ui-style="galgame"] .composer textarea::placeholder {
  color: rgba(229, 238, 255, 0.56);
}

html[data-ui-style="galgame"] .composer button {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  min-width: auto;
  min-height: auto;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 50%;
  color: #10131b;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.46),
    0 8px 14px rgba(0, 0, 0, 0.24);
  font-size: 14px;
  font-weight: 800;
  transition: transform 0.1s ease, filter 0.14s ease;
}

html[data-ui-style="galgame"] .composer button:hover {
  filter: brightness(1.08);
}

html[data-ui-style="galgame"] .composer button:active {
  transform: scale(0.95);
}

html[data-ui-style="galgame"] .galgame-choices {
  position: fixed;
  left: 50%;
  top: 42%;
  z-index: 18;
  display: grid;
  gap: 12px;
  width: min(660px, calc(100vw - 44px));
  margin: 0;
  padding: 0;
  transform: translate(-50%, -50%);
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  pointer-events: auto;
  animation: route-choice-in 0.2s cubic-bezier(.16, 1, .3, 1) both;
}

html[data-ui-style="galgame"] .galgame-choices button {
  --choice-offset: 0px;
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 56px;
  padding: 0 40px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 14px;
  color: #fff;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.36), rgba(255, 255, 255, 0.08)),
    linear-gradient(90deg, color-mix(in srgb, var(--accent), transparent 42%), color-mix(in srgb, var(--accent-2), transparent 58%));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.7),
    inset 0 -1px 0 rgba(255, 255, 255, 0.18),
    0 10px 18px rgba(0, 0, 0, 0.2);
  text-align: center;
  justify-content: center;
  text-shadow: 0 1px 5px rgba(0, 10, 24, 0.82);
  font-size: 16px;
  font-weight: 850;
  line-height: 1.25;
  transform: none;
  transition: border-color 0.14s ease, background 0.14s ease, transform 0.14s ease, box-shadow 0.14s ease, color 0.14s ease;
}

html[data-ui-style="galgame"] .galgame-choices button::before {
  content: "";
  position: absolute;
  left: 16px;
  top: 50%;
  width: 9px;
  height: 9px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.95), color-mix(in srgb, var(--accent-2), white 30%));
  box-shadow: 0 0 8px color-mix(in srgb, var(--accent-2), transparent 35%);
  opacity: 0.9;
  pointer-events: none;
  transform: translateY(-50%) rotate(45deg);
}

html[data-ui-style="galgame"] .galgame-choices button::after {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  pointer-events: none;
}

html[data-ui-style="galgame"] .galgame-choices button span {
  position: relative;
  z-index: 1;
}

html[data-ui-style="galgame"] .galgame-choices button:nth-child(1) {
  --choice-offset: 0px;
}

html[data-ui-style="galgame"] .galgame-choices button:nth-child(2) {
  --choice-offset: 0px;
}

html[data-ui-style="galgame"] .galgame-choices button:nth-child(3) {
  --choice-offset: 0px;
}

html[data-ui-style="galgame"] .galgame-choices button:hover {
  border-color: rgba(255, 255, 255, 0.78);
  color: #fff;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.48), rgba(255, 255, 255, 0.12)),
    linear-gradient(90deg, color-mix(in srgb, var(--accent), transparent 30%), color-mix(in srgb, var(--accent-2), transparent 42%));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.76),
    inset 0 -1px 0 rgba(255, 255, 255, 0.22),
    0 14px 24px rgba(0, 0, 0, 0.22);
  transform: translateY(-2px);
}

html[data-ui-style="galgame"] .galgame-choices[data-selecting="true"] button:not(:hover) {
  opacity: 0.56;
}

html[data-ui-style="galgame"] .galgame-choices[data-selecting="true"] button[data-selected="true"] {
  opacity: 1;
  border-color: rgba(255, 255, 255, 0.86);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.32) 24%, rgba(134, 236, 255, 0.42) 100%),
    color-mix(in srgb, var(--accent-2), transparent 42%);
  transform: translateY(-2px);
}

html[data-ui-style="galgame"] .galgame-choices button:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.9);
  outline-offset: 3px;
}

.route-event-toast {
  position: fixed;
  left: 50%;
  top: 64%;
  z-index: 26;
  max-width: min(520px, calc(100vw - 44px));
  padding: 10px 20px;
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.94);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.08)),
    color-mix(in srgb, var(--accent), transparent 64%);
  box-shadow: 0 8px 10px rgba(0, 0, 0, 0.22);
  text-align: center;
  text-shadow: 0 1px 5px rgba(0, 0, 0, 0.7);
  font-size: 14px;
  font-weight: 800;
  transform: translateX(-50%);
  animation: route-event-toast 2.4s ease both;
  pointer-events: none;
}

@keyframes route-choice-in {
  from {
    opacity: 0;
    transform: translate(-50%, calc(-50% + 10px));
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

@keyframes bg-crossfade-out {
  0% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@keyframes scene-motes {
  from {
    background-position: 0 0, 0 0, 0 0;
  }
  to {
    background-position: 0 -130px, 0 -180px, 0 -220px;
  }
}

@keyframes scene-rain {
  from {
    background-position: 0 0, 0 0;
  }
  to {
    background-position: -90px 150px, -130px 220px;
  }
}

@keyframes scene-petals {
  from {
    background-position: 0 0, 0 0, 0 0;
  }
  to {
    background-position: 180px 120px, -260px 170px, 340px 220px;
  }
}

@keyframes route-event-toast {
  0% {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
  12%, 76% {
    opacity: 1;
    transform: translate(-50%, 0);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -6px);
  }
}

/* =========================================
   Galgame 模式：Crystal Night VN 覆盖层
   ========================================= */
html[data-ui-style="galgame"] .chat {
  padding: 0;
}

html[data-ui-style="galgame"] .chat-shell {
  width: 100%;
  max-width: none;
  min-height: 28vh;
  margin: 0;
  padding-bottom: 2vh;
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(5, 7, 12, 0.58) 28%, rgba(4, 5, 9, 0.93) 100%);
  box-shadow: none;
}

html[data-ui-style="galgame"] .chat-shell::after {
  display: none;
}

html[data-ui-style="galgame"] .chat-shell::before {
  top: -38px;
  left: 6vw;
  min-width: auto;
  max-width: min(460px, 58vw);
  padding: 6px 34px 8px 16px;
  border: 0;
  border-top: 1px solid color-mix(in srgb, var(--accent), white 18%);
  border-bottom: 1px solid color-mix(in srgb, var(--accent), transparent 54%);
  border-radius: 0;
  color: #fff;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--accent), transparent 54%) 0%, rgba(0, 0, 0, 0.86) 3%, rgba(0, 0, 0, 0.48) 72%, transparent 100%);
  box-shadow: none;
  font-family: "Noto Serif SC", "Microsoft YaHei", serif;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 1px;
  line-height: 1.2;
  text-align: left;
}

html[data-ui-style="galgame"] .chat-shell:has(.bubble.user)::before {
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.86) 0%, rgba(31, 62, 112, 0.5) 72%, transparent 100%);
}

html[data-ui-style="galgame"] .messages {
  padding: 42px 6vw 10px;
}

html[data-ui-style="galgame"] .bubble {
  font-size: 25px;
  line-height: 1.78;
  text-shadow:
    2px 2px 6px rgba(0, 0, 0, 0.95),
    0 0 12px rgba(0, 0, 0, 0.58);
}

html[data-ui-style="galgame"] .composer {
  gap: 12px;
  padding: 0 6vw 1.3vh;
  border: 0;
  background: transparent;
}

html[data-ui-style="galgame"] .composer textarea {
  min-height: 42px;
  max-height: 90px;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.42);
  color: #fff;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.46);
  font-size: 16px;
}

html[data-ui-style="galgame"] .composer textarea:focus {
  border-color: color-mix(in srgb, var(--accent), white 18%);
  background: rgba(0, 0, 0, 0.5);
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.48),
    0 0 0 2px color-mix(in srgb, var(--accent), transparent 72%);
}

html[data-ui-style="galgame"] .composer button {
  width: auto;
  min-width: 78px;
  height: 42px;
  padding: 0 18px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 4px;
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: none;
}

html[data-ui-style="galgame"] .composer button:hover,
html[data-ui-style="galgame"] .composer button:focus-visible {
  outline: 0;
  color: #05070b;
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 16px color-mix(in srgb, var(--accent), transparent 52%);
}

html[data-ui-style="galgame"] .galgame-route-status {
  top: 24px;
  left: 0;
  right: auto;
  border: 0;
  border-top: 1px solid color-mix(in srgb, var(--accent), white 18%);
  border-bottom: 1px solid color-mix(in srgb, var(--accent), transparent 56%);
  border-radius: 0 4px 4px 0;
  padding: 8px 32px 8px 16px;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--accent), transparent 58%) 0%, rgba(0, 0, 0, 0.86) 4%, rgba(0, 0, 0, 0.42) 82%, transparent 100%);
  box-shadow: none;
  font-family: "Noto Serif SC", "Microsoft YaHei", serif;
  letter-spacing: 0.5px;
}

html[data-ui-style="galgame"] .style-dock {
  top: 24px;
  right: 24px;
  width: 112px;
  max-height: 34px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  opacity: 0.58;
}

html[data-ui-style="galgame"] .style-dock::before {
  content: "SYSTEM MENU";
  width: auto;
  min-height: 30px;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 1);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 1px;
}

html[data-ui-style="galgame"] .style-dock:hover,
html[data-ui-style="galgame"] .style-dock:focus-within,
html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock {
  grid-template-columns: repeat(auto-fit, minmax(66px, 1fr));
  width: min(920px, calc(100vw - 48px));
  max-height: min(72vh, 380px);
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.86);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.72);
  opacity: 1;
}

html[data-ui-style="galgame"] .style-dock span,
html[data-ui-style="galgame"] .style-dock button {
  min-height: 32px;
  border: 0;
  border-radius: 4px;
  color: rgba(235, 240, 250, 0.82);
  background: transparent;
  box-shadow: none;
}

html[data-ui-style="galgame"] .style-dock span:hover,
html[data-ui-style="galgame"] .style-dock button:hover,
html[data-ui-style="galgame"] .style-dock input:checked + span,
html[data-ui-style="galgame"] .style-dock > button[data-active="true"] {
  color: var(--accent);
  background: rgba(255, 255, 255, 0.09);
  border: 0;
  box-shadow: none;
}

html[data-ui-style="galgame"] .galgame-bg-picker {
  display: flex;
  grid-column: 1 / -1;
  gap: 10px;
  overflow-x: auto;
  padding: 2px 0 12px;
}

html[data-ui-style="galgame"] .galgame-user-bg-choices {
  display: contents;
}

html[data-ui-style="galgame"] .galgame-bg-choice,
html[data-ui-style="galgame"] .galgame-bg-upload span {
  flex: 0 0 118px;
  width: 118px;
  min-height: 66px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 4px;
  box-shadow: none;
}

html[data-ui-style="galgame"] .galgame-bg-choice:hover,
html[data-ui-style="galgame"] .galgame-bg-choice[data-active="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 16px color-mix(in srgb, var(--accent), transparent 58%);
}

html[data-ui-style="galgame"] .galgame-bg-upload span {
  color: rgba(235, 240, 250, 0.82);
  background: rgba(255, 255, 255, 0.06);
}

html[data-ui-style="galgame"] .empty-state {
  justify-items: center;
  align-items: center;
  width: 100%;
  max-width: none;
  text-align: center;
}

html[data-ui-style="galgame"] .empty-state strong {
  color: #fff;
  font-size: 21px;
  font-weight: 500;
  letter-spacing: 2px;
  text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.82);
}

html[data-ui-style="galgame"] .empty-state span {
  color: rgba(235, 240, 250, 0.78);
}

html[data-ui-style="galgame"] .starter-actions {
  justify-content: center;
  gap: 10px;
  margin-top: 10px;
}

html[data-ui-style="galgame"] .starter-actions button {
  min-height: 36px;
  padding: 0 22px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 4px;
  color: rgba(255, 255, 255, 0.92);
  background: rgba(0, 0, 0, 0.58);
  font-size: 12px;
  letter-spacing: 0.5px;
}

html[data-ui-style="galgame"] .starter-actions button:hover,
html[data-ui-style="galgame"] .starter-actions button:focus-visible {
  color: #fff;
  background: color-mix(in srgb, var(--accent), transparent 56%);
  border-color: var(--accent);
  box-shadow: 0 0 14px color-mix(in srgb, var(--accent), transparent 58%);
}

html[data-ui-style="galgame"] .galgame-choices {
  top: 42%;
  width: min(800px, 90vw);
  gap: 16px;
}

html[data-ui-style="galgame"] .galgame-choices button {
  min-height: 54px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 4px;
  color: #fff;
  background: rgba(0, 0, 0, 0.74);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.48);
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

html[data-ui-style="galgame"] .galgame-choices button::before {
  display: none;
}

html[data-ui-style="galgame"] .galgame-choices button::after {
  border-color: rgba(255, 255, 255, 0.08);
}

html[data-ui-style="galgame"] .galgame-choices button:hover,
html[data-ui-style="galgame"] .galgame-choices button:focus-visible {
  border-color: var(--accent);
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.82) 0%, color-mix(in srgb, var(--accent), transparent 58%) 50%, rgba(0, 0, 0, 0.82) 100%);
  box-shadow: 0 0 20px color-mix(in srgb, var(--accent), transparent 52%);
  transform: scale(1.018);
}

html[data-ui-style="galgame"] .galgame-log,
html[data-ui-style="galgame"] .route-editor {
  position: fixed;
  inset: 50% auto auto 50%;
  width: min(900px, 94vw);
  height: min(85vh, 760px);
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  background: rgba(12, 14, 18, 0.95);
  backdrop-filter: blur(16px);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.78);
}

html[data-ui-style="galgame"] .galgame-log[hidden] {
  display: none;
}

html[data-ui-style="galgame"] .route-editor::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

html[data-ui-style="galgame"] .galgame-log-head,
html[data-ui-style="galgame"] .route-editor-head,
html[data-ui-style="galgame"] .route-editor-actions {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
}

html[data-ui-style="galgame"] .galgame-log-head strong,
html[data-ui-style="galgame"] .route-editor-head strong {
  color: #fff;
  font-size: 18px;
  letter-spacing: 1px;
}

html[data-ui-style="galgame"] .galgame-log-head button,
html[data-ui-style="galgame"] .route-editor-head button,
html[data-ui-style="galgame"] .route-editor-actions button {
  border: 0;
  border-radius: 4px;
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

html[data-ui-style="galgame"] .route-editor-actions button[type="submit"] {
  color: #05070b;
  background: var(--accent);
}

html[data-ui-style="galgame"] .galgame-log-body article {
  padding: 16px 12px;
  border: 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
  border-radius: 0;
  background: transparent;
}

html[data-ui-style="galgame"] .galgame-log-body article.user,
html[data-ui-style="galgame"] .galgame-log-body article.choice {
  background: rgba(255, 255, 255, 0.025);
}

html[data-ui-style="galgame"] .galgame-log-body b,
html[data-ui-style="galgame"] .galgame-log-body article.route-event b {
  color: var(--accent);
  font-size: 14px;
}

html[data-ui-style="galgame"] .galgame-log-body p {
  color: #e6e9ef;
  font-size: 16px;
  line-height: 1.7;
}

html[data-ui-style="galgame"] .route-editor form {
  height: 100%;
  background: transparent;
}

html[data-ui-style="galgame"] .route-editor-row {
  border-color: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.025);
}

html[data-ui-style="galgame"] .route-editor input {
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.32);
}

@media (max-width: 760px) {
  html[data-ui-style="galgame"] .chat-shell {
    min-height: 34vh;
  }

  html[data-ui-style="galgame"] .chat-shell::before {
    top: -30px;
    left: 18px;
    max-width: calc(100vw - 48px);
    padding: 5px 24px 7px 12px;
    font-size: 17px;
  }

  html[data-ui-style="galgame"] .messages {
    padding: 34px 18px 8px;
  }

  html[data-ui-style="galgame"] .bubble {
    font-size: 18px;
    line-height: 1.62;
  }

  html[data-ui-style="galgame"] .composer {
    padding: 0 14px 12px;
  }

  html[data-ui-style="galgame"] .composer button {
    min-width: 58px;
    width: auto;
  }

  html[data-ui-style="galgame"] .starter-actions {
    gap: 7px;
  }

  html[data-ui-style="galgame"] .starter-actions button {
    min-height: 30px;
    padding: 0 12px;
    font-size: 11px;
  }

  html[data-ui-style="galgame"] .style-dock:hover,
  html[data-ui-style="galgame"] .style-dock:focus-within,
  html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock {
    width: calc(100vw - 24px);
    max-height: min(74vh, 420px);
  }

  html[data-ui-style="galgame"] .galgame-bg-choice,
  html[data-ui-style="galgame"] .galgame-bg-upload span {
    flex-basis: 104px;
    width: 104px;
  }

  html[data-ui-style="galgame"] .galgame-log,
  html[data-ui-style="galgame"] .route-editor {
    width: calc(100vw - 24px);
    height: 82vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  html[data-ui-style="galgame"] .galgame-atmosphere {
    animation: none;
  }

  html[data-ui-style="galgame"] .galgame-choices {
    animation: none;
  }

  html[data-ui-style="galgame"] .galgame-choices button {
    transition: none;
  }

  .route-event-toast {
    animation: none;
  }
}

@keyframes galgame-caret {
  0%, 49% {
    opacity: 1;
  }
  50%, 100% {
    opacity: 0;
  }
}

/* =========================================
   Workbench 模式：陪伴工作台 (默认)
   ========================================= */
html[data-ui-style="workbench"] .rail .panel:not(.style-panel) {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.014)),
    #111722;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: none;
  opacity: 1;
  transition: border-color 0.18s ease, background 0.18s ease;
}

html[data-ui-style="workbench"] .rail .panel:not(.style-panel):hover,
html[data-ui-style="workbench"] .rail .panel:not(.style-panel):focus-within {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.018)),
    #141a26;
  border-color: color-mix(in srgb, var(--accent), transparent 60%);
}

html[data-ui-style="workbench"] #app {
  display: grid;
  grid-template-columns: 320px minmax(520px, 1fr) 400px;
  background: var(--bg);
}

html[data-ui-style="workbench"] .chat {
  background:
    radial-gradient(circle at 50% -10%, color-mix(in srgb, var(--accent), transparent 92%), transparent 50%),
    linear-gradient(180deg, #0e1118 0%, #080a0f 100%);
  border-right: 1px solid var(--line);
}

html[data-ui-style="workbench"] .chat-shell {
  background:
    linear-gradient(180deg, rgba(21, 26, 37, 0.9), rgba(12, 15, 22, 0.88)),
    rgba(18, 22, 31, 0.86);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    0 12px 18px rgba(0, 0, 0, 0.26),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

html[data-ui-style="workbench"] .messages {
  background:
    radial-gradient(circle at 50% 8%, rgba(255, 255, 255, 0.028), transparent 24rem),
    linear-gradient(180deg, rgba(255, 255, 255, 0.012), rgba(0, 0, 0, 0.06));
  background-size: auto;
  background-position: center;
}

html[data-ui-style="workbench"] .empty-state {
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent-warm), transparent 91%), rgba(255, 255, 255, 0.025)),
    rgba(16, 19, 28, 0.72);
}

html[data-ui-style="workbench"] .stage {
  position: relative;
  isolation: isolate;
  background:
    radial-gradient(circle at 50% -8%, color-mix(in srgb, var(--accent), transparent 84%), transparent 30rem),
    radial-gradient(circle at 46% 44%, rgba(255, 156, 200, 0.1), transparent 20rem),
    linear-gradient(180deg, #11141d 0%, #090b10 100%);
}

html[data-ui-style="workbench"] .stage::after {
  content: "";
  position: absolute;
  left: 7%;
  right: 7%;
  bottom: 28px;
  z-index: 0;
  height: 72px;
  border-radius: 50%;
  background:
    radial-gradient(ellipse at center, rgba(255, 255, 255, 0.07), transparent 64%),
    radial-gradient(ellipse at center, color-mix(in srgb, var(--accent-warm), transparent 88%), transparent 72%);
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  pointer-events: none;
}

/* =========================================
   Workbench polish: minimal utility + role staging
   ========================================= */
html[data-ui-style="workbench"] {
  --workbench-surface: #11151d;
  --workbench-surface-2: #171c26;
  --workbench-line: rgba(255, 255, 255, 0.075);
  --workbench-text-muted: #a6b2c3;
}

html[data-ui-style="workbench"] body {
  background:
    radial-gradient(circle at 20% 8%, color-mix(in srgb, var(--accent), transparent 86%), transparent 24rem),
    radial-gradient(circle at 84% 16%, color-mix(in srgb, var(--accent-warm), transparent 89%), transparent 22rem),
    linear-gradient(135deg, #07090d 0%, #0b0e14 58%, #0c0b10 100%);
}

html[data-ui-style="workbench"] #app {
  grid-template-columns: 300px minmax(560px, 1fr) minmax(360px, 420px);
  gap: 18px;
  padding: 16px;
  background: transparent;
}

html[data-ui-style="workbench"] .rail,
html[data-ui-style="workbench"] .chat,
html[data-ui-style="workbench"] .stage {
  border: 1px solid var(--workbench-line);
  border-radius: 20px;
}

html[data-ui-style="workbench"] .rail {
  padding: 14px;
  background:
    linear-gradient(180deg, rgba(19, 23, 31, 0.94), rgba(10, 12, 18, 0.96)),
    #0f1219;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

html[data-ui-style="workbench"] .brand {
  grid-template-columns: 38px minmax(0, 1fr) auto;
  min-height: 58px;
  margin-bottom: 12px;
  padding: 10px;
  border-radius: 14px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent-warm), transparent 84%), transparent),
    rgba(255, 255, 255, 0.035);
  border-color: rgba(255, 255, 255, 0.09);
}

html[data-ui-style="workbench"] .brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
}

html[data-ui-style="workbench"] .brand strong {
  font-size: 14px;
}

html[data-ui-style="workbench"] .help-button {
  min-height: 30px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.055);
}

html[data-ui-style="workbench"] .select-target {
  min-height: 70px;
  padding: 10px;
  gap: 11px;
  border-radius: 15px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent), transparent 86%), rgba(255, 255, 255, 0.018)),
    var(--workbench-surface);
  border-color: color-mix(in srgb, var(--accent), transparent 78%);
}

html[data-ui-style="workbench"] .mini-portrait {
  width: 48px;
  height: 48px;
  border-radius: 14px;
}

html[data-ui-style="workbench"] .style-panel {
  padding: 12px;
  border-radius: 15px;
}

html[data-ui-style="workbench"] .rail .panel.quickstart-panel {
  max-height: none !important;
  padding: 14px;
  border-radius: 16px;
}

html[data-ui-style="workbench"] .rail .panel.quickstart-panel::before,
html[data-ui-style="workbench"] .rail .panel.quickstart-panel::after {
  content: none !important;
}

html[data-ui-style="workbench"] .style-switch {
  gap: 6px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.18);
}

html[data-ui-style="workbench"] .style-switch span {
  min-height: 34px;
  border-radius: 9px;
  font-size: 11px;
}

html[data-ui-style="workbench"] .rail .panel:not(.style-panel) {
  position: relative;
  overflow: hidden;
  max-height: 132px;
  padding: 12px;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.027);
  border-color: rgba(255, 255, 255, 0.075);
  transition:
    max-height 0.24s ease,
    background 0.18s ease,
    border-color 0.18s ease;
}

html[data-ui-style="workbench"] .rail .panel:not(.style-panel)::after {
  content: "高级";
  position: absolute;
  right: 12px;
  top: 12px;
  color: var(--workbench-text-muted);
  font-size: 11px;
  font-weight: 700;
  pointer-events: none;
}

html[data-ui-style="workbench"] .rail .panel.voice-api-panel::after {
  content: "声线";
}

html[data-ui-style="workbench"] .rail .panel.self-name-panel::after {
  content: none;
}

html[data-ui-style="workbench"] .rail .voice-api-panel {
  max-height: 176px;
}

html[data-ui-style="workbench"] .rail .voice-api-panel #voiceBaseUrl,
html[data-ui-style="workbench"] .rail .voice-api-panel #voiceKey,
html[data-ui-style="workbench"] .rail .voice-api-panel #voiceSearch,
html[data-ui-style="workbench"] .rail .voice-api-panel #acgnVoiceResults,
html[data-ui-style="workbench"] .rail .voice-api-panel #acgnVoiceSelect,
html[data-ui-style="workbench"] .rail .voice-api-panel .quota-row {
  display: none;
}

html[data-ui-style="workbench"] .rail .voice-api-panel:hover #voiceBaseUrl,
html[data-ui-style="workbench"] .rail .voice-api-panel:hover #voiceKey,
html[data-ui-style="workbench"] .rail .voice-api-panel:hover #voiceSearch,
html[data-ui-style="workbench"] .rail .voice-api-panel:hover #acgnVoiceResults,
html[data-ui-style="workbench"] .rail .voice-api-panel:hover #acgnVoiceSelect,
html[data-ui-style="workbench"] .rail .voice-api-panel:hover .quota-row,
html[data-ui-style="workbench"] .rail .voice-api-panel:focus-within #voiceBaseUrl,
html[data-ui-style="workbench"] .rail .voice-api-panel:focus-within #voiceKey,
html[data-ui-style="workbench"] .rail .voice-api-panel:focus-within #voiceSearch,
html[data-ui-style="workbench"] .rail .voice-api-panel:focus-within #acgnVoiceResults,
html[data-ui-style="workbench"] .rail .voice-api-panel:focus-within #acgnVoiceSelect,
html[data-ui-style="workbench"] .rail .voice-api-panel:focus-within .quota-row {
  display: grid;
}

html[data-ui-style="workbench"] .rail .panel:not(.style-panel)::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 24px;
  background: linear-gradient(180deg, transparent, #202735);
  pointer-events: none;
}

html[data-ui-style="workbench"] .rail .panel:not(.style-panel):hover::before,
html[data-ui-style="workbench"] .rail .panel:not(.style-panel):focus-within::before {
  content: none;
}

html[data-ui-style="workbench"] .rail .panel.compact.muted {
  display: block;
  max-height: none;
  margin-top: 12px;
  padding: 13px;
  border-radius: 15px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent), transparent 88%), rgba(255, 255, 255, 0.028)),
    #202735;
}

html[data-ui-style="workbench"] .rail .panel.compact.muted::after,
html[data-ui-style="workbench"] .rail .panel.compact.muted::before {
  content: none;
}

html[data-ui-style="workbench"] .rail .panel.compact.muted p {
  color: #c4cedb;
  font-size: 12px;
  line-height: 1.65;
}

html[data-ui-style="workbench"] .rail .panel:not(.style-panel):hover,
html[data-ui-style="workbench"] .rail .panel:not(.style-panel):focus-within {
  max-height: 760px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.016)),
    #111721;
  border-color: color-mix(in srgb, var(--accent), transparent 68%);
}

html[data-ui-style="workbench"] .rail .panel:not(.style-panel):hover::after,
html[data-ui-style="workbench"] .rail .panel:not(.style-panel):focus-within::after {
  content: "";
}

html[data-ui-style="workbench"] .compact > label:not(.check-line) {
  color: #f0f5fb;
  font-size: 12px;
}

html[data-ui-style="workbench"] input,
html[data-ui-style="workbench"] select,
html[data-ui-style="workbench"] textarea {
  border-radius: 11px;
  border-color: rgba(255, 255, 255, 0.105);
  background: rgba(7, 10, 15, 0.36);
}

html[data-ui-style="workbench"] .chat {
  display: grid;
  place-items: center;
  min-width: 0;
  padding: 0;
  background:
    radial-gradient(circle at 50% -16%, color-mix(in srgb, var(--accent), transparent 88%), transparent 30rem),
    linear-gradient(180deg, #10141d 0%, #090c12 100%);
  box-shadow:
    0 18px 40px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

html[data-ui-style="workbench"] .chat-shell {
  width: min(100%, 900px);
  height: calc(100dvh - 32px);
  max-height: none;
  border: 0;
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(18, 22, 30, 0.82), rgba(11, 14, 20, 0.88)),
    var(--workbench-surface);
  box-shadow: none;
}

html[data-ui-style="workbench"] .chat-head {
  padding: 20px 22px 16px;
  border-bottom-color: rgba(255, 255, 255, 0.065);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.032), transparent);
}

html[data-ui-style="workbench"] .chat-character {
  gap: 16px;
}

html[data-ui-style="workbench"] .active-avatar {
  order: 0;
  width: 54px;
  height: 54px;
  border-width: 2px;
  border-color: color-mix(in srgb, var(--accent), white 58%);
  box-shadow:
    0 0 0 4px color-mix(in srgb, var(--accent), transparent 86%),
    0 12px 18px rgba(0, 0, 0, 0.25);
}

html[data-ui-style="workbench"] h1 {
  margin-top: 3px;
  font-size: 24px;
  line-height: 1.18;
}

html[data-ui-style="workbench"] .presence-row {
  margin-top: 8px;
}

html[data-ui-style="workbench"] .presence-row span {
  min-height: 22px;
  padding: 0 8px;
  background: rgba(255, 255, 255, 0.055);
  font-size: 11px;
}

html[data-ui-style="workbench"] .chat-actions .ghost {
  min-height: 38px;
  padding: 0 13px;
  border-radius: 11px;
}

html[data-ui-style="workbench"] .messages {
  padding: 32px;
  background:
    radial-gradient(circle at 50% 36%, rgba(255, 255, 255, 0.025), transparent 24rem),
    linear-gradient(180deg, rgba(255, 255, 255, 0.01), rgba(0, 0, 0, 0.06));
}

html[data-ui-style="workbench"] .empty-state {
  position: relative;
  max-width: 440px;
  padding: 34px 34px 30px;
  border: 1px solid color-mix(in srgb, var(--accent-warm), transparent 70%);
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--accent-warm), transparent 82%), transparent 15rem),
    rgba(18, 16, 24, 0.72);
  color: var(--workbench-text-muted);
}

html[data-ui-style="workbench"] .empty-state::before {
  content: "";
  width: 54px;
  height: 3px;
  margin-bottom: 9px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-warm), var(--accent-2));
  opacity: 0.86;
}

html[data-ui-style="workbench"] .empty-state strong {
  font-size: 16px;
  line-height: 1.45;
}

html[data-ui-style="workbench"] .empty-state span {
  color: #aeb8c8;
  font-size: 13px;
  line-height: 1.7;
}

html[data-ui-style="workbench"] .starter-actions button {
  min-height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.055);
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

html[data-ui-style="workbench"] .starter-actions button:hover,
html[data-ui-style="workbench"] .starter-actions button:focus-visible {
  color: #081016;
  background: color-mix(in srgb, var(--accent-warm), white 8%);
  transform: translateY(-2px);
  outline: 0;
}

html[data-ui-style="workbench"] .bubble {
  max-width: min(680px, 78%);
  border-radius: 15px;
  font-size: 14px;
}

html[data-ui-style="workbench"] .bubble.user {
  color: #f7fbff;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent), #1b2230 42%), #1d2430);
  border: 1px solid color-mix(in srgb, var(--accent), transparent 76%);
  border-bottom-right-radius: 5px;
}

html[data-ui-style="workbench"] .bubble.assistant {
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--accent), transparent 88%), transparent),
    rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.075);
  border-left: 2px solid var(--accent);
  border-radius: 12px 15px 15px 12px;
}

html[data-ui-style="workbench"] .composer {
  position: relative;
  grid-template-columns: 1fr 48px;
  align-items: end;
  gap: 8px;
  margin: 0 22px 22px;
  padding: 10px 10px 10px 16px;
  border: 1px solid color-mix(in srgb, var(--accent), transparent 80%);
  border-radius: 18px;
  background: rgba(18, 22, 30, 0.92);
  box-shadow:
    0 16px 30px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

html[data-ui-style="workbench"] .composer:focus-within {
  border-color: color-mix(in srgb, var(--accent), white 8%);
  box-shadow:
    0 18px 34px rgba(0, 0, 0, 0.32),
    0 0 0 3px color-mix(in srgb, var(--accent), transparent 82%);
}

html[data-ui-style="workbench"] .composer textarea {
  min-height: 44px;
  padding: 11px 0 9px;
  border: 0;
  background: transparent;
}

html[data-ui-style="workbench"] .composer button {
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 14px;
  color: #081016;
  background: linear-gradient(135deg, var(--accent-warm), var(--accent-2));
}

html[data-ui-style="workbench"] .stage {
  padding: 0;
  background:
    radial-gradient(circle at 50% 8%, color-mix(in srgb, var(--accent), transparent 80%), transparent 24rem),
    radial-gradient(circle at 50% 70%, color-mix(in srgb, var(--accent-warm), transparent 88%), transparent 22rem),
    linear-gradient(180deg, #11151e 0%, #080a0f 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

html[data-ui-style="workbench"] .stage::before {
  content: "";
  position: absolute;
  inset: 12px;
  z-index: 0;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.045);
  pointer-events: none;
}

html[data-ui-style="workbench"] .pet-surface {
  height: 100%;
  min-height: 0;
}

html[data-ui-style="workbench"] .pet-actor {
  bottom: 44px;
  height: min(680px, calc(100% - 76px));
  max-width: 94%;
}

html[data-ui-style="workbench"] .pet-bubble {
  top: 96px;
  color: #0d1520;
  background: rgba(246, 249, 253, 0.94);
}

html[data-ui-style="workbench"] .character-sheet {
  position: absolute;
  left: 18px;
  right: 18px;
  top: 18px;
  bottom: auto;
  z-index: 3;
  padding: 12px;
  border-radius: 15px;
  background: rgba(11, 14, 20, 0.68);
  backdrop-filter: blur(14px);
  box-shadow: none;
}

html[data-ui-style="workbench"] .character-sheet h2 {
  font-size: 18px;
}

/* Workbench comfort tuning: softer type and less oppressive darks */
html[data-ui-style="workbench"] {
  --bg: #151922;
  --panel: rgba(31, 37, 49, 0.78);
  --panel-strong: rgba(38, 45, 58, 0.92);
  --text: #f1f5fb;
  --muted: #b2bdcc;
  --soft: #d6deea;
  --workbench-surface: #1a202a;
  --workbench-surface-2: #222936;
  --workbench-line: rgba(255, 255, 255, 0.1);
  --workbench-text-muted: #bac4d2;
}

html[data-ui-style="workbench"] body {
  background:
    linear-gradient(135deg, #171b24 0%, #1b202a 48%, #211d28 100%);
}

html[data-ui-style="workbench"] #app {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.012));
}

html[data-ui-style="workbench"] .rail {
  background:
    linear-gradient(180deg, rgba(31, 37, 49, 0.95), rgba(22, 27, 36, 0.96)),
    #1a202a;
}

html[data-ui-style="workbench"] .brand,
html[data-ui-style="workbench"] .select-target,
html[data-ui-style="workbench"] .style-panel,
html[data-ui-style="workbench"] .rail .panel:not(.style-panel) {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.024)),
    #202735;
}

html[data-ui-style="workbench"] .brand strong,
html[data-ui-style="workbench"] .select-target b,
html[data-ui-style="workbench"] .compact > label:not(.check-line),
html[data-ui-style="workbench"] .style-switch span,
html[data-ui-style="workbench"] .presence-row span,
html[data-ui-style="workbench"] .chat-actions .ghost,
html[data-ui-style="workbench"] .starter-actions button {
  font-weight: 650;
}

html[data-ui-style="workbench"] .help-button,
html[data-ui-style="workbench"] .quota-row button,
html[data-ui-style="workbench"] .composer button {
  font-weight: 700;
}

html[data-ui-style="workbench"] .brand-mark {
  font-weight: 750;
}

html[data-ui-style="workbench"] .chat {
  background:
    linear-gradient(180deg, #202735 0%, #19212d 100%);
  box-shadow:
    0 16px 28px rgba(0, 0, 0, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.045);
}

html[data-ui-style="workbench"] .chat-shell {
  background:
    linear-gradient(180deg, rgba(36, 44, 58, 0.92), rgba(25, 33, 45, 0.96)),
    #202837;
}

html[data-ui-style="workbench"] .chat-head {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.012));
}

html[data-ui-style="workbench"] h1 {
  font-size: 23px;
  font-weight: 720;
  letter-spacing: 0;
}

html[data-ui-style="workbench"] .messages {
  background: #1b2330;
  background-image: none;
  background-size: auto;
}

html[data-ui-style="workbench"] .empty-state {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.052), rgba(255, 255, 255, 0.026)),
    #251f2b;
  border-color: color-mix(in srgb, var(--accent-warm), transparent 58%);
}

html[data-ui-style="workbench"] .empty-state strong {
  font-weight: 680;
}

html[data-ui-style="workbench"] .bubble.user {
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent), #2a3444 46%), #273140);
}

html[data-ui-style="workbench"] .bubble.assistant {
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--accent), transparent 84%), transparent),
    rgba(255, 255, 255, 0.06);
}

html[data-ui-style="workbench"] .composer {
  background: rgba(32, 39, 52, 0.94);
  box-shadow:
    0 14px 24px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.045);
}

html[data-ui-style="workbench"] .composer textarea::placeholder {
  color: #c2ccd9;
}

html[data-ui-style="workbench"] .stage {
  background:
    linear-gradient(180deg, #332b38 0%, #262b37 58%, #202836 100%);
}

html[data-ui-style="workbench"] .stage::before {
  border-color: rgba(255, 255, 255, 0.07);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.006));
}

html[data-ui-style="workbench"] .stage::after {
  background:
    radial-gradient(ellipse at center, rgba(255, 196, 222, 0.18), transparent 64%),
    radial-gradient(ellipse at center, rgba(255, 255, 255, 0.1), transparent 72%);
}

html[data-ui-style="workbench"] .character-sheet {
  background: rgba(31, 28, 38, 0.78);
}

html[data-ui-style="workbench"] .character-sheet h2 {
  font-weight: 700;
}

/* Workbench warmth pass: Twilight Rose, softer room-like companion space */
html[data-ui-style="workbench"] {
  --bg: #181315;
  --panel: rgba(36, 29, 34, 0.72);
  --panel-strong: rgba(44, 35, 41, 0.9);
  --line: rgba(255, 184, 214, 0.13);
  --text: #fbf6f8;
  --muted: #bbaeb8;
  --soft: #e2d6de;
  --accent: #ffabcb;
  --accent-2: #ffd099;
  --accent-warm: #ffb8d6;
  --workbench-surface: #241d22;
  --workbench-surface-2: #2c242b;
  --workbench-line: rgba(255, 184, 214, 0.12);
  --workbench-text-muted: #c7bac4;
}

html[data-ui-style="workbench"] body {
  background:
    radial-gradient(circle at 88% 14%, rgba(255, 171, 203, 0.12), transparent 34rem),
    radial-gradient(circle at 18% 76%, rgba(255, 208, 153, 0.075), transparent 32rem),
    linear-gradient(135deg, #191416 0%, #1e171c 48%, #171417 100%);
}

html[data-ui-style="workbench"] #app {
  background:
    linear-gradient(180deg, rgba(255, 235, 244, 0.035), rgba(255, 235, 244, 0.012));
}

html[data-ui-style="workbench"] .rail {
  background:
    linear-gradient(180deg, rgba(35, 29, 34, 0.92), rgba(23, 19, 23, 0.96)),
    #211b20;
  border-color: rgba(255, 184, 214, 0.11);
}

html[data-ui-style="workbench"] .brand,
html[data-ui-style="workbench"] .select-target,
html[data-ui-style="workbench"] .style-panel,
html[data-ui-style="workbench"] .rail .panel:not(.style-panel) {
  background:
    linear-gradient(180deg, rgba(255, 236, 245, 0.064), rgba(255, 236, 245, 0.026)),
    #2a2229;
  border-color: rgba(255, 184, 214, 0.13);
}

html[data-ui-style="workbench"] .rail .panel:not(.style-panel)::before {
  background: linear-gradient(180deg, transparent, #2a2229);
}

html[data-ui-style="workbench"] .chat {
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 184, 214, 0.08), transparent 24rem),
    linear-gradient(180deg, rgba(42, 34, 41, 0.82), rgba(27, 23, 29, 0.92)),
    #241d22;
  border-color: rgba(255, 184, 214, 0.1);
}

html[data-ui-style="workbench"] .chat-shell {
  background:
    linear-gradient(180deg, rgba(43, 35, 42, 0.88), rgba(30, 25, 31, 0.94)),
    #261f25;
}

html[data-ui-style="workbench"] .chat-head {
  border-bottom-color: rgba(255, 184, 214, 0.1);
  background:
    linear-gradient(180deg, rgba(255, 236, 245, 0.055), rgba(255, 236, 245, 0.012));
}

html[data-ui-style="workbench"] .messages {
  background:
    radial-gradient(circle at 50% 38%, rgba(255, 208, 153, 0.026), transparent 22rem),
    #201b22;
}

html[data-ui-style="workbench"] .empty-state {
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 184, 214, 0.13), transparent 14rem),
    linear-gradient(180deg, rgba(255, 236, 245, 0.064), rgba(255, 236, 245, 0.026)),
    #2b222a;
  border-color: rgba(255, 184, 214, 0.28);
}

html[data-ui-style="workbench"] .empty-state span {
  color: #cfc2cb;
}

html[data-ui-style="workbench"] .bubble.user {
  background:
    linear-gradient(135deg, rgba(255, 171, 203, 0.22), rgba(255, 208, 153, 0.16)),
    #332631;
  border-color: rgba(255, 184, 214, 0.28);
  color: #fffafd;
}

html[data-ui-style="workbench"] .bubble.assistant {
  background:
    linear-gradient(90deg, rgba(255, 171, 203, 0.11), transparent),
    rgba(48, 39, 46, 0.74);
  border-color: rgba(255, 184, 214, 0.16);
  border-left-color: var(--accent);
  color: var(--text);
}

html[data-ui-style="workbench"] .composer {
  background: rgba(43, 35, 42, 0.92);
  border-color: rgba(255, 184, 214, 0.22);
}

html[data-ui-style="workbench"] .composer:focus-within {
  border-color: rgba(255, 184, 214, 0.45);
  box-shadow:
    0 18px 34px rgba(18, 10, 14, 0.28),
    0 0 0 3px rgba(255, 184, 214, 0.12);
}

html[data-ui-style="workbench"] .composer textarea::placeholder {
  color: #d3c7d0;
}

html[data-ui-style="workbench"] .composer button,
html[data-ui-style="workbench"] .style-switch input:checked + span,
html[data-ui-style="workbench"] .style-switch label:nth-child(1) span {
  background: linear-gradient(135deg, #ffb8d6, #ffd099);
}

html[data-ui-style="workbench"] .stage {
  background:
    radial-gradient(circle at 50% 20%, rgba(255, 208, 153, 0.105), transparent 26rem),
    radial-gradient(circle at 58% 62%, rgba(255, 171, 203, 0.095), transparent 24rem),
    linear-gradient(180deg, #35262f 0%, #261f27 58%, #1d1a20 100%);
  border-color: rgba(255, 184, 214, 0.12);
}

html[data-ui-style="workbench"] .stage::before {
  border-color: rgba(255, 184, 214, 0.1);
  background:
    radial-gradient(circle at 50% 24%, rgba(255, 208, 153, 0.05), transparent 50%),
    linear-gradient(180deg, rgba(255, 236, 245, 0.036), rgba(255, 236, 245, 0.008));
}

html[data-ui-style="workbench"] .stage::after {
  background:
    radial-gradient(ellipse at center, rgba(255, 184, 214, 0.2), transparent 64%),
    radial-gradient(ellipse at center, rgba(255, 208, 153, 0.11), transparent 72%);
}

html[data-ui-style="workbench"] .character-sheet {
  background:
    linear-gradient(180deg, rgba(44, 35, 42, 0.86), rgba(31, 25, 31, 0.78));
  border-color: rgba(255, 184, 214, 0.12);
  display: grid;
  gap: 4px;
  max-height: 140px;
  overflow: hidden;
}

html[data-ui-style="workbench"] .pet-bubble {
  background: rgba(255, 247, 251, 0.95);
}

html[data-ui-style="workbench"] .character-sheet h2 {
  font-size: 17px;
  line-height: 1.22;
}

html[data-ui-style="workbench"] .character-sheet p {
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
  line-height: 1.45;
}

html[data-ui-style="workbench"] .character-sheet .tags {
  gap: 6px;
}

html[data-ui-style="workbench"] .character-sheet .tags span {
  min-height: 24px;
  padding: 0 9px;
}

html[data-ui-style="workbench"] #sourceLink {
  color: #ffd099;
}

html[data-ui-style="workbench"] ::-webkit-scrollbar-thumb {
  background: rgba(255, 184, 214, 0.18);
}

html[data-ui-style="workbench"] ::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 184, 214, 0.34);
}

/* =========================================
   Pet Console 模式：桌宠核心控制台
   ========================================= */
html[data-ui-style="pet-console"] #app {
  display: flex;
  overflow: hidden;
  background: #05070b;
}

html[data-ui-style="pet-console"] .rail .panel:not(.style-panel),
html[data-ui-style="pet-console"] .rail .select-target {
  display: none;
}

html[data-ui-style="pet-console"] .rail {
  position: relative;
  z-index: 12;
  width: 240px;
  flex: 0 0 240px;
  background:
    linear-gradient(180deg, rgba(12, 16, 24, 0.98), rgba(5, 7, 11, 0.99)),
    #080a0f;
}

html[data-ui-style="pet-console"] .chat {
  order: 3;
  position: relative;
  z-index: 10;
  width: 360px;
  flex: 0 0 360px;
  min-height: 0;
  padding: 16px;
  background: rgba(10, 13, 19, 0.62);
  backdrop-filter: blur(22px);
  border-left: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: -14px 0 18px rgba(0, 0, 0, 0.34);
}

html[data-ui-style="pet-console"] .chat-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background:
    linear-gradient(180deg, rgba(18, 22, 31, 0.78), rgba(8, 10, 15, 0.74)),
    rgba(8, 10, 15, 0.82);
  box-shadow:
    0 10px 12px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

html[data-ui-style="pet-console"] .chat-head {
  display: grid;
  grid-template-columns: 1fr;
  align-items: start;
  gap: 12px;
  padding: 16px;
  background: transparent;
  border-bottom: 1px solid rgba(255, 255, 255, 0.045);
}

html[data-ui-style="pet-console"] .chat-head .ghost {
  width: 100%;
}

html[data-ui-style="pet-console"] .chat-character {
  align-items: flex-start;
  gap: 12px;
}

html[data-ui-style="pet-console"] .active-avatar {
  order: 0;
  width: 46px;
  height: 46px;
  border-width: 2px;
}

html[data-ui-style="pet-console"] h1 {
  font-size: 20px;
  line-height: 1.15;
}

html[data-ui-style="pet-console"] .presence-row {
  gap: 6px;
}

html[data-ui-style="pet-console"] .presence-row span {
  min-height: 22px;
  padding: 0 8px;
  font-size: 11px;
}

html[data-ui-style="pet-console"] .messages {
  padding: 14px;
  background: transparent;
}

html[data-ui-style="pet-console"] .empty-state {
  min-height: 100%;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.055);
  background:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.014) 1px, transparent 1px),
    rgba(0, 0, 0, 0.2);
  background-size: 36px 36px, 36px 36px, auto;
}

html[data-ui-style="pet-console"] .bubble {
  max-width: 100%;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
}

html[data-ui-style="pet-console"] .composer {
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.045);
  background: rgba(0, 0, 0, 0.28);
}

html[data-ui-style="pet-console"] .composer textarea {
  width: 100%;
  min-height: 76px;
  box-sizing: border-box;
}

html[data-ui-style="pet-console"] .composer button {
  width: 100%;
  min-height: 46px;
}

html[data-ui-style="pet-console"] .stage {
  order: 2;
  flex: 1 1 auto;
  position: relative;
  isolation: isolate;
  padding: 0;
  min-width: 0;
  background:
    radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--accent), transparent 82%), transparent 34rem),
    radial-gradient(circle at 50% 80%, rgba(255, 156, 200, 0.12), transparent 24rem),
    radial-gradient(circle at 50% 100%, rgba(255, 255, 255, 0.026), transparent 34rem),
    linear-gradient(180deg, #0b0e15 0%, #05070b 100%);
  border: 0;
}

html[data-ui-style="pet-console"] .stage::before {
  content: "CSP // STAGE";
  position: absolute;
  left: 40px;
  top: 40px;
  z-index: 1;
  color: rgba(255, 255, 255, 0.032);
  font-size: clamp(56px, 8vw, 100px);
  font-weight: 900;
  letter-spacing: 0;
  white-space: nowrap;
  pointer-events: none;
}

html[data-ui-style="pet-console"] .stage::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 18px;
  z-index: 1;
  width: min(62%, 660px);
  height: 92px;
  transform: translateX(-50%);
  border-radius: 50%;
  border-top: 1px solid color-mix(in srgb, var(--accent), transparent 78%);
  background:
    radial-gradient(ellipse at center, color-mix(in srgb, var(--accent), transparent 84%) 0%, transparent 68%),
    radial-gradient(ellipse at center, rgba(255, 255, 255, 0.055), transparent 72%);
  pointer-events: none;
}

html[data-ui-style="pet-console"] .pet-surface {
  position: relative;
  z-index: 2;
  height: 100%;
  border: 0;
  background: transparent;
}

html[data-ui-style="pet-console"] .pet-actor {
  left: 50%;
  height: min(92%, 90vh);
  max-width: 86%;
}

html[data-ui-style="pet-console"] .live2d-stage {
  left: 50%;
  height: min(92%, 90vh);
}

html[data-ui-style="pet-console"] .pet-toolbar {
  display: flex !important;
  width: max-content;
  min-width: 0;
  max-width: min(680px, calc(100% - 40px));
  bottom: 40px;
  left: 50%;
  padding: 10px;
  border-radius: 14px;
  background: rgba(18, 22, 31, 0.86);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow:
    0 12px 16px rgba(0, 0, 0, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  justify-content: center;
  gap: 10px;
  z-index: 10;
}

html[data-ui-style="pet-console"] .pet-toolbar button {
  min-height: 48px;
  padding: 0 24px;
  border-radius: 10px;
  font-size: 15px;
  background: rgba(255, 255, 255, 0.055);
  border: 0;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

html[data-ui-style="pet-console"] .pet-toolbar button:hover {
  background: var(--accent);
  color: #071015;
  transform: translateY(-2px);
}

html[data-ui-style="pet-console"] .character-sheet {
  display: none;
}

/* =========================================
   Album 模式：全屏角色卡册与素材库
   ========================================= */
html[data-ui-style="album"] #app {
  background: #080a0f;
}

html[data-ui-style="album"] .chat,
html[data-ui-style="album"] .stage {
  display: none;
}

html[data-ui-style="album"] .modal {
  position: fixed;
  inset: 0 0 0 auto;
  margin: 0;
  margin-left: 280px;
  width: calc(100vw - 280px);
  max-width: none;
  height: 100dvh;
  max-height: none;
  border: 0;
  border-radius: 0;
  background: #0b0e14;
  box-shadow: inset 1px 0 0 var(--line);
}

html[data-ui-style="album"] .modal::backdrop {
  background: transparent;
}

html[data-ui-style="album"] #closeCharacterModal {
  display: none;
}

html[data-ui-style="album"] .modal-head {
  padding: 24px 40px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

html[data-ui-style="album"] .modal-body {
  grid-template-columns: 1fr minmax(420px, 480px);
  height: calc(100dvh - 90px);
  padding: 0;
  gap: 0;
}

html[data-ui-style="album"] .library-pane {
  padding: 32px 40px;
  background: radial-gradient(circle at 0% 0%, rgba(122, 168, 255, 0.05), transparent 40rem);
}

html[data-ui-style="album"] .character-grid {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 24px;
  padding-right: 12px;
}

html[data-ui-style="album"] .character-card {
  min-height: 360px;
  border-radius: 16px;
  background: #11151e;
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

html[data-ui-style="album"] .character-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.4);
  border-color: color-mix(in srgb, var(--accent), transparent 50%);
}

html[data-ui-style="album"] .character-card img {
  object-position: center 10%;
  padding: 0;
  background: transparent;
}

html[data-ui-style="album"] .character-card-copy {
  padding-top: 80px;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.95) 50%);
}

html[data-ui-style="album"] .create-form {
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 0;
  background: rgba(18, 22, 31, 0.6);
  padding: 32px;
}

html[data-ui-style="album"] .create-preview {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

#showCreate[data-active="true"] {
  background: color-mix(in srgb, var(--accent), white 8%);
}

@media (max-width: 1100px) {
  #app,
  html[data-ui-style="galgame"] #app,
  html[data-ui-style="pet-console"] #app,
  html[data-ui-style="album"] #app {
    grid-template-columns: 320px 1fr;
  }

  .stage {
    display: none;
  }

  html[data-ui-style="galgame"] .stage {
    display: block;
  }

  html[data-ui-style="galgame"] .pet-actor,
  html[data-ui-style="galgame"] .live2d-stage {
    left: 68%;
    height: 86vh;
  }

  html[data-ui-style="pet-console"] #app {
    display: flex;
  }

  html[data-ui-style="pet-console"] .rail {
    width: 220px;
    flex-basis: 220px;
  }

  html[data-ui-style="pet-console"] .stage {
    flex: 1 1 auto;
    display: flex;
  }

  html[data-ui-style="pet-console"] .chat {
    width: 320px;
    flex-basis: 320px;
  }

  html[data-ui-style="pet-console"] .stage::before {
    left: 28px;
  }

  .modal-body,
  html[data-ui-style="album"] .modal-body {
    grid-template-columns: 1fr;
    height: min(820px, calc(100dvh - 132px));
    overflow: auto;
  }

  .library-pane,
  .create-form {
    min-height: 420px;
  }

  .modal[data-library-pane="list"] .create-form {
    display: none;
  }

  .modal[data-library-pane="create"] .library-pane {
    display: none;
  }

  html[data-ui-style="album"] .modal {
    margin-left: 320px;
    width: calc(100vw - 320px);
  }
}

@media (max-width: 760px) {
  #app,
  html[data-ui-style="galgame"] #app,
  html[data-ui-style="pet-console"] #app,
  html[data-ui-style="album"] #app {
    height: auto;
    min-height: 100vh;
    grid-template-columns: 1fr;
  }

  .rail {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .chat {
    min-height: 72vh;
    padding: 20px;
    grid-template-rows: auto 1fr auto;
  }

  html[data-ui-style="galgame"] .chat {
    padding: 0 0 10px;
  }

  html[data-ui-style="galgame"] #app {
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
  }

  html[data-ui-style="galgame"] .style-dock {
    top: 12px;
    right: 12px;
  }

  html[data-ui-style="galgame"] .style-dock:hover,
  html[data-ui-style="galgame"] .style-dock:focus-within,
  html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock {
    width: calc(100vw - 24px);
    max-height: min(70vh, 360px);
  }

  html[data-ui-style="galgame"] .galgame-bg-picker {
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  html[data-ui-style="galgame"] .pet-actor,
  html[data-ui-style="galgame"] .live2d-stage {
    left: 58%;
    height: 72vh;
    max-width: none;
  }

  html[data-ui-style="galgame"] .pet-actor.chibi-pet {
    height: 52vh;
  }

  html[data-ui-style="galgame"] .chat-shell {
    width: calc(100vw - 24px);
    min-height: 166px;
    margin-bottom: 10px;
  }

  html[data-ui-style="galgame"] .chat-head,
  html[data-ui-style="galgame"] .composer {
    margin-left: 0;
    margin-right: 0;
  }

  html[data-ui-style="galgame"] .messages {
    padding: 32px 18px 8px;
  }

  html[data-ui-style="galgame"] .bubble {
    font-size: 18px;
    line-height: 1.58;
  }

  html[data-ui-style="galgame"] .composer {
    gap: 8px;
    padding: 9px 14px 14px;
  }

  html[data-ui-style="galgame"] .composer textarea {
    min-height: 42px;
    font-size: 15px;
  }

  html[data-ui-style="galgame"] .composer button {
    width: 42px;
    height: 42px;
    font-size: 13px;
  }

  html[data-ui-style="galgame"] .chat-shell::before {
    left: 18px;
    min-width: 104px;
    top: -19px;
    padding: 5px 16px 6px;
    font-size: 14px;
  }

  html[data-ui-style="galgame"] .empty-state strong {
    font-size: 15px;
  }

  html[data-ui-style="galgame"] .empty-state span {
    font-size: 12px;
  }

  html[data-ui-style="galgame"] .starter-actions {
    gap: 6px;
  }

  html[data-ui-style="galgame"] .starter-actions button {
    min-height: 28px;
    padding-inline: 10px;
    font-size: 10.5px;
  }

  html[data-ui-style="galgame"] .galgame-choices {
    top: 42%;
    width: calc(100vw - 32px);
    gap: 10px;
  }

  html[data-ui-style="galgame"] .galgame-choices button {
    --choice-offset: 0px;
    min-height: 48px;
    padding: 0 22px 0 30px;
    font-size: 14px;
  }

  .chat-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .form-grid,
  .upload-grid,
  .create-preview {
    grid-template-columns: 1fr;
  }

  .tools-row {
    grid-template-columns: 1fr auto;
  }

  .tools-row input {
    grid-column: 1 / -1;
  }

  .library-count {
    justify-self: start;
    text-align: left;
  }

  #showCreate {
    justify-self: end;
  }

  .candidate-card {
    grid-template-rows: 150px auto;
    min-height: 270px;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .create-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .bubble {
    max-width: 94%;
  }

  .pet-toolbar {
    flex-wrap: wrap;
    width: min(300px, calc(100% - 32px));
    justify-content: center;
  }

  html[data-ui-style="album"] .modal {
    margin-left: 0;
    width: 100vw;
    border-left: 0;
  }

  html[data-ui-style="album"] .modal-body {
    grid-template-columns: 1fr;
  }

  html[data-ui-style="pet-console"] #app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
  }

  html[data-ui-style="pet-console"] .rail {
    width: 100%;
    flex-basis: auto;
  }

  html[data-ui-style="pet-console"] .chat {
    position: relative;
    order: 3;
    width: auto;
    flex: 0 0 auto;
    min-height: 520px;
    padding: 16px;
  }

  html[data-ui-style="pet-console"] .stage {
    order: 2;
    flex: 0 0 auto;
    min-height: 620px;
  }

  html[data-ui-style="pet-console"] .stage::before {
    left: 24px;
    top: auto;
    bottom: 24px;
    font-size: 48px;
  }

  html[data-ui-style="pet-console"] .pet-actor,
  html[data-ui-style="pet-console"] .live2d-stage {
    left: 50%;
    max-width: 92%;
  }

  html[data-ui-style="pet-console"] .pet-toolbar {
    left: 50%;
    min-width: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pet-actor,
  .pet-actor[data-motion],
  .pet-actor[data-speaking="true"] .pet-avatar,
  .live2d-stage,
  .live2d-stage[data-motion] {
    animation: none;
  }
}

html[data-ui-style="galgame"] .galgame-log {
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 18px;
  color: #20324c;
  background:
    radial-gradient(circle at 20% 0%, color-mix(in srgb, var(--accent), transparent 82%), transparent 18rem),
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(239, 247, 255, 0.78));
  backdrop-filter: blur(10px);
  box-shadow: 0 24px 64px rgba(35, 52, 76, 0.32);
}

html[data-ui-style="galgame"] .galgame-log-head {
  border-color: rgba(92, 127, 165, 0.16);
  background: rgba(255, 255, 255, 0.42);
}

html[data-ui-style="galgame"] .galgame-log-head strong {
  color: #1c2d44;
  letter-spacing: 0;
}

html[data-ui-style="galgame"] .galgame-log-head button,
html[data-ui-style="galgame"] .galgame-log-item-head button {
  color: #244260;
  background: rgba(255, 255, 255, 0.74);
}

html[data-ui-style="galgame"] .galgame-log-body article {
  padding: 12px;
  border: 1px solid rgba(107, 141, 180, 0.18);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.56);
}

html[data-ui-style="galgame"] .galgame-log-body article.user,
html[data-ui-style="galgame"] .galgame-log-body article.choice {
  background: rgba(214, 235, 255, 0.58);
}

html[data-ui-style="galgame"] .galgame-log-body b,
html[data-ui-style="galgame"] .galgame-log-body article.route-event b {
  color: #315a84;
  font-size: 12px;
}

html[data-ui-style="galgame"] .galgame-log-body p,
html[data-ui-style="galgame"] .galgame-log-empty {
  color: rgba(35, 52, 76, 0.78);
  font-size: 14px;
}

html[data-ui-style="workbench"] .character-sheet {
  max-height: none;
  overflow: visible;
}

html[data-ui-style="workbench"] .sheet-action {
  min-height: 32px;
  margin: 2px 0 8px;
  border-radius: 999px;
  font-size: 12px;
}

html[data-ui-style="workbench"] .play-status {
  gap: 8px;
  margin: 8px 0;
  padding: 10px;
}

html[data-ui-style="workbench"] .play-vitals {
  justify-content: flex-start;
}

html[data-ui-style="workbench"] .memory-list span {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.settings-drawer {
  inset: 0 0 0 auto;
  width: min(420px, 100vw);
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--line);
  color: var(--text);
  background:
    radial-gradient(circle at 20% 0%, color-mix(in srgb, var(--accent), transparent 84%), transparent 18rem),
    linear-gradient(180deg, rgba(29, 34, 46, 0.96), rgba(11, 14, 20, 0.98));
  box-shadow: -28px 0 70px rgba(0, 0, 0, 0.38);
}

.settings-drawer::backdrop {
  background: rgba(5, 7, 12, 0.42);
}

.settings-drawer form {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
}

.settings-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  border-bottom: 1px solid var(--line);
}

.settings-drawer-head strong {
  display: block;
  margin-top: 3px;
  font-size: 20px;
}

.settings-drawer-head button {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.09);
  font-weight: 900;
}

.settings-drawer-body {
  display: grid;
  align-content: start;
  gap: 14px;
  min-height: 0;
  overflow: auto;
  padding: 18px;
}

.settings-drawer-body .settings-panel {
  max-height: none;
  margin: 0;
}

/* Typography polish: softer Chinese UI, less heavy small text */
body,
button,
input,
select,
textarea {
  font-family: var(--font-ui);
  letter-spacing: 0;
}

.brand strong,
.select-target b,
.chat-character h1,
.character-sheet h2,
.character-card-title b,
.play-status-head b {
  font-family: var(--font-title);
}

html[data-ui-style="workbench"] .brand strong,
html[data-ui-style="workbench"] .select-target b,
html[data-ui-style="workbench"] .character-card-title b,
html[data-ui-style="workbench"] .character-sheet h2 {
  font-weight: 650;
}

html[data-ui-style="workbench"] .brand strong {
  font-size: 13.5px;
  line-height: 1.2;
}

html[data-ui-style="workbench"] .brand span,
html[data-ui-style="workbench"] .select-target small,
html[data-ui-style="workbench"] .self-name-panel p,
html[data-ui-style="workbench"] .rail .panel.compact.muted p {
  font-weight: 400;
  line-height: 1.58;
}

html[data-ui-style="workbench"] .help-button,
html[data-ui-style="workbench"] .style-switch span,
html[data-ui-style="workbench"] .compact > label:not(.check-line),
html[data-ui-style="workbench"] .self-name-panel label,
html[data-ui-style="workbench"] .character-card-meta span,
html[data-ui-style="workbench"] .tags span {
  font-weight: 600;
}

html[data-ui-style="workbench"] .style-switch span {
  font-size: 11.5px;
}

html[data-ui-style="workbench"] .self-name-panel input {
  font-size: 14px;
  font-weight: 400;
}

html[data-ui-style="workbench"] .character-sheet {
  gap: 7px;
}

html[data-ui-style="workbench"] .character-sheet > span,
html[data-ui-style="workbench"] .character-sheet p {
  font-size: 12px;
  line-height: 1.52;
}

html[data-ui-style="workbench"] .character-sheet h2 {
  font-size: 18px;
  line-height: 1.22;
}

html[data-ui-style="workbench"] .play-status {
  gap: 9px;
  padding: 11px;
}

html[data-ui-style="workbench"] .play-status-head b {
  font-size: 13.5px;
  font-weight: 650;
}

html[data-ui-style="workbench"] .play-status-head span,
html[data-ui-style="workbench"] .play-vitals span,
html[data-ui-style="workbench"] .play-stat span,
html[data-ui-style="workbench"] .play-stat strong,
html[data-ui-style="workbench"] .memory-list strong,
html[data-ui-style="workbench"] .memory-list span {
  font-weight: 400;
  line-height: 1.5;
}

html[data-ui-style="workbench"] .play-status-head span,
html[data-ui-style="workbench"] .play-vitals span {
  color: color-mix(in srgb, var(--soft), white 8%);
  font-size: 12px;
}

html[data-ui-style="workbench"] .play-stat {
  grid-template-columns: 34px 22px minmax(0, 1fr);
}

html[data-ui-style="workbench"] .play-stat span,
html[data-ui-style="workbench"] .play-stat strong {
  color: color-mix(in srgb, var(--soft), white 4%);
  font-size: 11.5px;
}

html[data-ui-style="workbench"] .memory-list strong {
  font-size: 11.5px;
  font-weight: 600;
}

html[data-ui-style="workbench"] .memory-list span {
  font-size: 11.5px;
}

/* Final type pass: keep the workbench soft, readable, and less admin-like */
body {
  -webkit-font-smoothing: antialiased;
  font-synthesis-weight: none;
}

html[data-ui-style="workbench"] .brand strong,
html[data-ui-style="workbench"] .select-target b,
html[data-ui-style="workbench"] .compact > label:not(.check-line),
html[data-ui-style="workbench"] .self-name-panel label,
html[data-ui-style="workbench"] .play-status-head b,
html[data-ui-style="workbench"] .memory-list strong,
html[data-ui-style="workbench"] .sheet-action,
html[data-ui-style="workbench"] #sourceLink {
  font-weight: 600;
}

html[data-ui-style="workbench"] .brand strong,
html[data-ui-style="workbench"] .select-target b,
html[data-ui-style="workbench"] .compact > label:not(.check-line),
html[data-ui-style="workbench"] .self-name-panel label,
html[data-ui-style="workbench"] .play-status-head b,
html[data-ui-style="workbench"] .memory-list strong {
  font-family: var(--font-ui);
}

html[data-ui-style="workbench"] .brand-mark {
  font-weight: 600;
  font-size: 18px;
}

html[data-ui-style="workbench"] .brand strong {
  font-size: 13px;
  letter-spacing: 0;
}

html[data-ui-style="workbench"] .brand span {
  color: rgba(244, 232, 238, 0.62);
  font-size: 11.5px;
}

html[data-ui-style="workbench"] .help-button,
html[data-ui-style="workbench"] .style-switch span,
html[data-ui-style="workbench"] .quota-row button,
html[data-ui-style="workbench"] .voice-api-panel button,
html[data-ui-style="workbench"] .pet-toolbar button,
html[data-ui-style="workbench"] .chat-actions .ghost,
html[data-ui-style="workbench"] .starter-actions button {
  font-weight: 550;
}

html[data-ui-style="workbench"] .style-switch span {
  min-height: 36px;
  font-size: 12px;
  line-height: 1.2;
}

html[data-ui-style="workbench"] .compact > label:not(.check-line),
html[data-ui-style="workbench"] .self-name-panel label {
  color: rgba(250, 236, 244, 0.78);
  font-size: 12px;
}

html[data-ui-style="workbench"] input,
html[data-ui-style="workbench"] select,
html[data-ui-style="workbench"] textarea {
  font-size: 13px;
  font-weight: 400;
}

html[data-ui-style="workbench"] .character-sheet {
  padding: 14px;
}

html[data-ui-style="workbench"] .character-sheet > span {
  color: rgba(250, 236, 244, 0.58);
  font-size: 11.5px;
}

html[data-ui-style="workbench"] .character-sheet h2 {
  color: rgba(255, 244, 249, 0.96);
  font-size: 18px;
  font-weight: 700;
}

html[data-ui-style="workbench"] .character-sheet p {
  color: rgba(250, 236, 244, 0.72);
  font-size: 12px;
  line-height: 1.65;
}

html[data-ui-style="workbench"] .tags span {
  min-height: 23px;
  padding: 0 8px;
  color: rgba(255, 244, 249, 0.78);
  font-size: 11px;
  font-weight: 500;
}

html[data-ui-style="workbench"] .play-status {
  gap: 10px;
  padding: 12px;
  border-color: rgba(255, 210, 226, 0.14);
  background:
    linear-gradient(180deg, rgba(255, 240, 247, 0.07), rgba(255, 240, 247, 0.025)),
    rgba(35, 27, 34, 0.76);
}

html[data-ui-style="workbench"] .play-status-head {
  align-items: flex-start;
  gap: 8px;
}

html[data-ui-style="workbench"] .play-status-head b {
  color: rgba(255, 244, 249, 0.92);
  font-size: 13px;
}

html[data-ui-style="workbench"] .play-status-head span,
html[data-ui-style="workbench"] .play-vitals span {
  color: rgba(250, 236, 244, 0.64);
  font-size: 11.5px;
}

html[data-ui-style="workbench"] .play-vitals {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

html[data-ui-style="workbench"] .play-vitals span {
  min-height: 26px;
  padding: 5px 7px;
  border: 1px solid rgba(255, 224, 236, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

html[data-ui-style="workbench"] .play-stat {
  grid-template-columns: 38px 24px minmax(0, 1fr);
  gap: 7px;
}

html[data-ui-style="workbench"] .play-stat span,
html[data-ui-style="workbench"] .play-stat strong {
  color: rgba(250, 236, 244, 0.68);
  font-size: 11px;
  font-weight: 400;
}

html[data-ui-style="workbench"] .play-stat strong {
  color: rgba(255, 244, 249, 0.76);
  text-align: right;
}

html[data-ui-style="workbench"] .memory-list {
  gap: 6px;
}

html[data-ui-style="workbench"] .memory-list li {
  padding: 7px 8px;
  border-color: rgba(255, 224, 236, 0.1);
  background: rgba(255, 255, 255, 0.035);
}

html[data-ui-style="workbench"] .memory-list strong,
html[data-ui-style="workbench"] .memory-list span {
  font-size: 11px;
  line-height: 1.45;
}

html[data-ui-style="workbench"] .chat-character h1,
html[data-ui-style="workbench"] .starter-card h2,
html[data-ui-style="workbench"] .message-name {
  font-family: var(--font-title);
  font-weight: 600;
  letter-spacing: 0;
}

html[data-ui-style="workbench"] .chat-character h1 {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.18;
}

html[data-ui-style="workbench"] .chat-character small,
html[data-ui-style="workbench"] .status-pill,
html[data-ui-style="workbench"] .starter-card p,
html[data-ui-style="workbench"] .message-text {
  font-family: var(--font-ui);
  font-weight: 400;
  letter-spacing: 0;
}

html[data-ui-style="workbench"] .status-pill {
  min-height: 23px;
  padding: 0 9px;
  font-size: 11px;
  font-weight: 500;
}

html[data-ui-style="workbench"] .starter-card h2 {
  color: rgba(255, 244, 249, 0.94);
  font-size: 19px;
  font-weight: 700;
}

html[data-ui-style="workbench"] .starter-card p {
  color: rgba(250, 236, 244, 0.68);
  font-size: 13px;
  line-height: 1.65;
}

html[data-ui-style="workbench"] .starter-actions button {
  min-height: 32px;
  padding: 0 13px;
  font-size: 12px;
  font-weight: 500;
}

html[data-ui-style="workbench"] .composer textarea,
html[data-ui-style="workbench"] .composer textarea::placeholder {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0;
}

html[data-ui-style="workbench"] .composer textarea::placeholder {
  color: rgba(250, 236, 244, 0.58);
}

html[data-ui-style="workbench"] .composer button {
  font-size: 14px;
  font-weight: 600;
}

html[data-ui-style="workbench"] .select-target b {
  font-size: 14px;
  line-height: 1.2;
}

html[data-ui-style="workbench"] .select-target small {
  color: rgba(250, 236, 244, 0.62);
  font-size: 12px;
}

/* Gemini pass: warm ACG companion polish, scoped to avoid admin-like global overrides */
html[data-ui-style="workbench"] body {
  background:
    radial-gradient(circle at 86% 12%, rgba(255, 174, 207, 0.1), transparent 34rem),
    radial-gradient(circle at 14% 10%, rgba(143, 180, 255, 0.1), transparent 38rem),
    radial-gradient(circle at 52% 72%, rgba(255, 208, 153, 0.055), transparent 42rem),
    linear-gradient(135deg, #120e13 0%, #1c1620 48%, #231b25 100%);
}

html[data-ui-style="workbench"] .rail,
html[data-ui-style="workbench"] .chat,
html[data-ui-style="workbench"] .stage {
  border-color: rgba(255, 230, 240, 0.09);
  box-shadow: 0 18px 42px rgba(10, 6, 10, 0.26);
}

html[data-ui-style="workbench"] .rail {
  padding: 16px;
  background:
    linear-gradient(180deg, rgba(255, 241, 248, 0.055), rgba(255, 241, 248, 0.018)),
    rgba(19, 14, 20, 0.72);
  backdrop-filter: blur(24px) saturate(118%);
}

html[data-ui-style="workbench"] .brand,
html[data-ui-style="workbench"] .select-target,
html[data-ui-style="workbench"] .style-panel,
html[data-ui-style="workbench"] .rail .panel:not(.style-panel) {
  border-color: rgba(255, 230, 240, 0.1);
  background:
    linear-gradient(180deg, rgba(255, 245, 250, 0.07), rgba(255, 245, 250, 0.026)),
    rgba(39, 30, 39, 0.62);
  box-shadow: none;
}

html[data-ui-style="workbench"] .brand {
  min-height: 70px;
}

html[data-ui-style="workbench"] .brand strong {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 650;
}

html[data-ui-style="workbench"] .brand span {
  color: rgba(252, 235, 244, 0.58);
}

html[data-ui-style="workbench"] .select-target {
  min-height: 72px;
  transition: transform 0.22s ease, border-color 0.22s ease, background 0.22s ease;
}

html[data-ui-style="workbench"] .select-target:hover,
html[data-ui-style="workbench"] .select-target:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(255, 184, 214, 0.34);
  background:
    linear-gradient(180deg, rgba(255, 245, 250, 0.095), rgba(255, 245, 250, 0.035)),
    rgba(47, 36, 46, 0.74);
  box-shadow: 0 10px 24px rgba(16, 9, 14, 0.22);
}

html[data-ui-style="workbench"] #currentName,
html[data-ui-style="workbench"] .select-target b {
  font-family: var(--font-ui);
  color: rgba(255, 245, 250, 0.94);
  font-weight: 650;
}

html[data-ui-style="workbench"] .chat {
  background:
    radial-gradient(circle at 50% -8%, rgba(255, 184, 214, 0.08), transparent 28rem),
    radial-gradient(circle at 18% 86%, rgba(255, 208, 153, 0.045), transparent 26rem),
    linear-gradient(180deg, #211a22 0%, #18131a 100%);
}

html[data-ui-style="workbench"] .chat-shell {
  border-color: rgba(255, 230, 240, 0.095);
  background:
    linear-gradient(180deg, rgba(47, 37, 46, 0.84), rgba(26, 20, 27, 0.94)),
    rgba(26, 20, 27, 0.88);
}

html[data-ui-style="workbench"] .chat-head {
  border-bottom-color: rgba(255, 230, 240, 0.1);
  background:
    linear-gradient(180deg, rgba(255, 245, 250, 0.055), rgba(255, 245, 250, 0.015));
}

html[data-ui-style="workbench"] .chat-character h1 {
  font-family: var(--font-serif);
  color: rgba(255, 245, 250, 0.98);
  font-size: 25px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

html[data-ui-style="workbench"] .status-pill {
  color: rgba(255, 241, 248, 0.78);
  border-color: rgba(255, 230, 240, 0.12);
  background: rgba(255, 255, 255, 0.055);
}

html[data-ui-style="workbench"] .messages {
  background:
    radial-gradient(circle at 50% 34%, rgba(255, 245, 250, 0.032), transparent 24rem),
    transparent;
}

html[data-ui-style="workbench"] .starter-card {
  border-color: rgba(255, 184, 214, 0.23);
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 184, 214, 0.08), transparent 18rem),
    linear-gradient(180deg, rgba(255, 245, 250, 0.06), rgba(255, 245, 250, 0.025)),
    rgba(48, 37, 47, 0.72);
}

html[data-ui-style="workbench"] .starter-card h2 {
  font-family: var(--font-serif);
  font-size: 20px;
  letter-spacing: 0.02em;
}

html[data-ui-style="workbench"] .starter-actions button {
  color: rgba(255, 241, 248, 0.84);
  border-color: rgba(255, 230, 240, 0.14);
  background: rgba(255, 255, 255, 0.05);
}

html[data-ui-style="workbench"] .composer {
  border-color: rgba(255, 184, 214, 0.24);
  background: rgba(43, 33, 42, 0.88);
}

html[data-ui-style="workbench"] .composer:focus-within {
  border-color: rgba(255, 184, 214, 0.46);
  box-shadow:
    0 18px 34px rgba(18, 10, 14, 0.24),
    0 0 0 3px rgba(255, 184, 214, 0.1);
}

html[data-ui-style="workbench"] .composer button {
  color: #211016;
  background: linear-gradient(135deg, #ffc1db, #ffd59e);
}

html[data-ui-style="workbench"] .stage {
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 208, 153, 0.13), transparent 25rem),
    radial-gradient(circle at 50% 76%, rgba(255, 184, 214, 0.14), transparent 18rem),
    linear-gradient(180deg, #362933 0%, #221b25 62%, #171219 100%);
}

html[data-ui-style="workbench"] .character-sheet {
  border-color: rgba(255, 230, 240, 0.12);
  background:
    linear-gradient(180deg, rgba(255, 245, 250, 0.064), rgba(255, 245, 250, 0.024)),
    rgba(32, 24, 31, 0.78);
  backdrop-filter: blur(18px) saturate(112%);
}

html[data-ui-style="workbench"] .character-sheet h2 {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

html[data-ui-style="workbench"] .play-status {
  border-color: rgba(255, 230, 240, 0.12);
  background:
    linear-gradient(180deg, rgba(255, 245, 250, 0.055), rgba(255, 245, 250, 0.02)),
    rgba(35, 27, 34, 0.68);
}

html[data-ui-style="workbench"] .play-stat-bar i {
  background: linear-gradient(90deg, #ffc1db, #ffd59e);
}

html[data-ui-style="workbench"] input,
html[data-ui-style="workbench"] select,
html[data-ui-style="workbench"] textarea {
  border-color: rgba(255, 230, 240, 0.11);
  background: rgba(14, 10, 14, 0.38);
}

html[data-ui-style="workbench"] input:focus,
html[data-ui-style="workbench"] select:focus,
html[data-ui-style="workbench"] textarea:focus {
  border-color: rgba(255, 184, 214, 0.44);
  box-shadow: 0 0 0 3px rgba(255, 184, 214, 0.12);
}

html[data-ui-style="galgame"] .message-text,
html[data-ui-style="galgame"] .galgame-log-body article,
html[data-ui-style="galgame"] .route-event-toast {
  font-family: var(--font-serif);
  letter-spacing: 0.02em;
}

/* Stage layout fix: keep the sheet from covering the character standee */
html[data-ui-style="workbench"] .stage {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  overflow: hidden;
  align-content: stretch;
  justify-content: stretch;
  align-items: stretch;
  justify-items: stretch;
}

html[data-ui-style="workbench"] .stage-light {
  pointer-events: none;
}

html[data-ui-style="workbench"] .character-sheet {
  position: relative;
  left: auto;
  right: auto;
  top: auto;
  bottom: auto;
  z-index: 4;
  order: 1;
  display: grid;
  gap: 9px;
  width: 100%;
  max-width: none;
  min-width: 0;
  justify-self: stretch;
  max-height: none;
  overflow: visible;
  padding: 16px;
  border-radius: 14px;
}

html[data-ui-style="workbench"] .pet-surface {
  order: 2;
  position: relative;
  z-index: 2;
  width: 100%;
  min-width: 0;
  min-height: 0;
  height: auto;
  overflow: visible;
}

html[data-ui-style="workbench"] .pet-actor {
  left: 50%;
  bottom: 18px;
  height: min(720px, calc(100% - 18px));
  max-width: 100%;
}

html[data-ui-style="workbench"] .live2d-stage {
  bottom: 28px;
  height: min(660px, calc(100% - 38px));
}

html[data-ui-style="workbench"] .character-sheet > span {
  font-size: 12.5px;
  line-height: 1.35;
}

html[data-ui-style="workbench"] .character-sheet h2 {
  margin-top: 0;
  font-size: 24px;
  line-height: 1.2;
}

html[data-ui-style="workbench"] .character-sheet p {
  font-size: 13px;
  line-height: 1.55;
  -webkit-line-clamp: 2;
}

html[data-ui-style="workbench"] .tags span {
  min-height: 26px;
  padding: 0 10px;
  font-size: 12px;
}

html[data-ui-style="workbench"] .play-status {
  gap: 10px;
  margin: 7px 0;
  padding: 13px;
}

html[data-ui-style="workbench"] .play-status-head b {
  font-size: 14px;
}

html[data-ui-style="workbench"] .play-status-head span,
html[data-ui-style="workbench"] .play-vitals span {
  font-size: 12.5px;
}

html[data-ui-style="workbench"] .play-stat {
  grid-template-columns: 40px 28px minmax(0, 1fr);
}

html[data-ui-style="workbench"] .play-stat span,
html[data-ui-style="workbench"] .play-stat strong {
  font-size: 12px;
}

html[data-ui-style="workbench"] .memory-list li {
  padding: 8px 9px;
}

html[data-ui-style="workbench"] .memory-list li:nth-child(n+2) {
  display: none;
}

html[data-ui-style="workbench"] .memory-list strong,
html[data-ui-style="workbench"] .memory-list span {
  font-size: 12px;
}

html[data-ui-style="workbench"] .memory-list span {
  -webkit-line-clamp: 1;
}

html[data-ui-style="workbench"] .sheet-action {
  min-height: 38px;
  margin: 4px 0 6px;
  font-size: 13px;
}

html[data-ui-style="workbench"] #sourceLink {
  font-size: 18px;
  line-height: 1.2;
}

@media (max-height: 860px) {
  html[data-ui-style="workbench"] .character-sheet {
    max-height: none;
  }

  html[data-ui-style="workbench"] .character-sheet h2 {
    font-size: 22px;
  }

  html[data-ui-style="workbench"] .play-status {
    padding: 11px;
  }
}

/* Right sheet density tune: larger text without stealing the standee stage */
html[data-ui-style="workbench"] .character-sheet {
  gap: 7px;
  padding: 14px;
}

html[data-ui-style="workbench"] .character-sheet > span {
  font-size: 13px;
}

html[data-ui-style="workbench"] .character-sheet h2 {
  font-size: 25px;
}

html[data-ui-style="workbench"] .character-sheet p {
  margin-top: 0;
  font-size: 13.5px;
  line-height: 1.48;
}

html[data-ui-style="workbench"] .character-sheet .tags {
  gap: 7px;
  margin: 6px 0 3px;
}

html[data-ui-style="workbench"] .character-sheet .tags span {
  min-height: 25px;
  padding: 0 10px;
  font-size: 12.5px;
}

html[data-ui-style="workbench"] .play-status {
  gap: 8px;
  margin: 5px 0;
  padding: 12px;
}

html[data-ui-style="workbench"] .play-status-head b {
  font-size: 15px;
}

html[data-ui-style="workbench"] .play-status-head span,
html[data-ui-style="workbench"] .play-vitals span,
html[data-ui-style="workbench"] .play-stat span,
html[data-ui-style="workbench"] .play-stat strong,
html[data-ui-style="workbench"] .memory-list strong,
html[data-ui-style="workbench"] .memory-list span {
  font-size: 13px;
}

html[data-ui-style="workbench"] .play-vitals {
  gap: 7px;
}

/* Workbench readability pass: larger UI rhythm and clearer message hierarchy */
html[data-ui-style="workbench"] .brand strong {
  font-size: 15px;
  line-height: 1.28;
}

html[data-ui-style="workbench"] .brand span {
  font-size: 12.5px;
  line-height: 1.45;
}

html[data-ui-style="workbench"] .compact > label:not(.check-line),
html[data-ui-style="workbench"] .self-name-panel label {
  font-size: 13.5px;
  line-height: 1.4;
}

html[data-ui-style="workbench"] .self-name-panel p,
html[data-ui-style="workbench"] .quickstart-copy p,
html[data-ui-style="workbench"] .library-intro span {
  font-size: 13.5px;
  line-height: 1.72;
}

html[data-ui-style="workbench"] .quickstart-copy strong,
html[data-ui-style="workbench"] .library-intro strong {
  font-size: 16px;
  line-height: 1.45;
}

html[data-ui-style="workbench"] .quickstart-pills span,
html[data-ui-style="workbench"] .presence-row span,
html[data-ui-style="workbench"] .character-card-vibe,
html[data-ui-style="workbench"] .character-card-meta span,
html[data-ui-style="workbench"] .tags span {
  font-size: 12.5px;
}

html[data-ui-style="workbench"] .help-button,
html[data-ui-style="workbench"] .chat-actions .ghost,
html[data-ui-style="workbench"] .starter-actions button,
html[data-ui-style="workbench"] .quickstart-primary,
html[data-ui-style="workbench"] .quickstart-secondary,
html[data-ui-style="workbench"] .composer button {
  font-size: 14px;
}

html[data-ui-style="workbench"] h1,
html[data-ui-style="workbench"] .chat-character h1 {
  font-size: 30px;
  line-height: 1.24;
}

html[data-ui-style="workbench"] .messages {
  gap: 22px;
  padding: 34px 34px 30px;
}

html[data-ui-style="workbench"] .message-meta {
  gap: 10px;
}

html[data-ui-style="workbench"] .message-row.user .message-meta {
  justify-content: flex-end;
}

html[data-ui-style="workbench"] .message-speaker {
  font-size: 13.5px;
  font-weight: 700;
}

html[data-ui-style="workbench"] .message-state {
  font-size: 12px;
}

html[data-ui-style="workbench"] .bubble {
  max-width: min(760px, 82%);
  padding: 16px 18px;
  border-radius: 17px;
  font-size: 16px;
  line-height: 1.82;
}

html[data-ui-style="workbench"] .empty-state strong {
  font-size: 20px;
  line-height: 1.5;
}

html[data-ui-style="workbench"] .empty-state span {
  font-size: 15px;
  line-height: 1.8;
}

html[data-ui-style="workbench"] .empty-mode {
  min-height: 30px;
  padding: 0 12px;
  font-size: 12.5px;
}

html[data-ui-style="workbench"] input,
html[data-ui-style="workbench"] select,
html[data-ui-style="workbench"] textarea,
html[data-ui-style="workbench"] .composer textarea,
html[data-ui-style="workbench"] .composer textarea::placeholder {
  font-size: 15px;
}

html[data-ui-style="workbench"] .character-card-title b {
  font-size: 18px;
}

html[data-ui-style="workbench"] .character-card small {
  font-size: 13px;
}

html[data-ui-style="workbench"] .character-card p {
  font-size: 13px;
  line-height: 1.6;
}

html[data-ui-style="workbench"] .character-sheet > span,
html[data-ui-style="workbench"] .character-sheet p,
html[data-ui-style="workbench"] .play-status-head span,
html[data-ui-style="workbench"] .play-vitals span,
html[data-ui-style="workbench"] .play-stat span,
html[data-ui-style="workbench"] .play-stat strong,
html[data-ui-style="workbench"] .memory-list strong,
html[data-ui-style="workbench"] .memory-list span {
  font-size: 13.5px;
}

html[data-ui-style="workbench"] .character-sheet h2 {
  font-size: 27px;
  line-height: 1.22;
}

html[data-ui-style="workbench"] .play-status-head b {
  font-size: 15.5px;
}

html[data-ui-style="workbench"] .play-vitals span {
  min-height: 28px;
}

html[data-ui-style="workbench"] .ending-card strong {
  font-size: 16px;
}

html[data-ui-style="workbench"] .memory-list li {
  padding: 7px 8px;
}

html[data-ui-style="workbench"] .sheet-action {
  min-height: 36px;
  margin: 3px 0 2px;
  font-size: 13.5px;
}

/* Final workbench polish: calmer spacing and stronger reading rhythm */
html[data-ui-style="workbench"] .chat-shell {
  width: min(100%, 1040px);
}

html[data-ui-style="workbench"] .chat-head {
  padding: 24px 26px 18px;
}

html[data-ui-style="workbench"] .chat-actions {
  gap: 10px;
}

html[data-ui-style="workbench"] .messages {
  gap: 24px;
  padding: 38px 38px 34px;
}

html[data-ui-style="workbench"] .message-meta {
  gap: 10px;
  padding-inline: 2px;
}

html[data-ui-style="workbench"] .message-state {
  letter-spacing: 0.01em;
}

html[data-ui-style="workbench"] .bubble {
  max-width: min(760px, 82%);
  padding: 17px 19px;
  border-radius: 18px;
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.14);
}

html[data-ui-style="workbench"] .composer {
  grid-template-columns: 1fr 52px;
  gap: 10px;
  margin: 0 26px 26px;
  padding: 12px 12px 12px 18px;
  border-radius: 20px;
}

html[data-ui-style="workbench"] .composer textarea {
  min-height: 56px;
  line-height: 1.7;
}

html[data-ui-style="workbench"] .composer button {
  width: 52px;
  height: 52px;
  border-radius: 16px;
}

html[data-ui-style="workbench"] .character-sheet {
  gap: 9px;
  padding: 16px;
}

html[data-ui-style="workbench"] #sourceLink {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  min-height: 30px;
  padding: 0 11px;
  border: 1px solid rgba(255, 208, 153, 0.26);
  border-radius: 999px;
  color: #ffd59e;
  background: rgba(255, 208, 153, 0.075);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

html[data-ui-style="workbench"] .pet-actor {
  height: min(760px, calc(100% - 8px));
}

/* Premium menu pass: Galgame system menu and settings drawer polish */
:root {
  --acg-menu-glass: rgba(34, 27, 35, 0.76);
  --acg-menu-glass-strong: rgba(42, 32, 42, 0.92);
  --acg-menu-line: rgba(255, 230, 240, 0.12);
  --acg-menu-line-hover: rgba(255, 184, 214, 0.34);
  --acg-menu-pink: #ffc1dc;
  --acg-menu-gold: #ffd59e;
  --acg-menu-mint: #7ee6cc;
}

html[data-ui-style="galgame"] .style-dock {
  position: fixed;
  top: 14px;
  left: 50%;
  right: auto;
  z-index: 80;
  display: grid;
  grid-template-columns: auto;
  width: max-content;
  min-width: 0;
  max-width: calc(100vw - 28px);
  max-height: 40px;
  padding: 6px 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-top: 0;
  border-radius: 0 0 16px 16px;
  background:
    linear-gradient(180deg, rgba(255, 245, 250, 0.08), rgba(255, 245, 250, 0.025)),
    rgba(22, 17, 23, 0.62);
  box-shadow:
    0 14px 36px rgba(7, 5, 8, 0.34),
    0 0 0 1px rgba(255, 255, 255, 0.035) inset;
  backdrop-filter: blur(22px) saturate(140%);
  transform: translateX(-50%);
  opacity: 0.9;
  transition:
    width 0.26s cubic-bezier(.16, 1, .3, 1),
    max-height 0.26s cubic-bezier(.16, 1, .3, 1),
    padding 0.22s ease,
    opacity 0.18s ease,
    background 0.18s ease;
}

html[data-ui-style="galgame"] .style-dock::before {
  content: "SYSTEM";
  display: grid;
  place-items: center;
  min-width: 94px;
  min-height: 28px;
  padding: 0 18px;
  border-radius: 999px;
  color: rgba(255, 244, 249, 0.92);
  background:
    linear-gradient(135deg, rgba(255, 193, 220, 0.18), rgba(255, 213, 158, 0.1)),
    rgba(255, 255, 255, 0.045);
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.11em;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.36);
}

html[data-ui-style="galgame"] .style-dock:hover,
html[data-ui-style="galgame"] .style-dock:focus-within,
html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock {
  grid-template-columns: repeat(auto-fit, minmax(74px, max-content));
  gap: 8px;
  width: min(980px, calc(100vw - 36px));
  max-height: min(72vh, 420px);
  padding: 12px;
  overflow: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  background:
    radial-gradient(circle at 18% 0%, rgba(255, 193, 220, 0.13), transparent 16rem),
    radial-gradient(circle at 82% 0%, rgba(126, 230, 204, 0.09), transparent 18rem),
    var(--acg-menu-glass-strong);
  opacity: 1;
}

html[data-ui-style="galgame"] .style-dock:hover::before,
html[data-ui-style="galgame"] .style-dock:focus-within::before,
html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock::before {
  content: "SYSTEM MENU";
  grid-column: 1 / -1;
  justify-self: start;
  min-height: 24px;
  padding: 0 4px;
  color: rgba(255, 213, 158, 0.94);
  background: transparent;
  font-size: 12px;
  letter-spacing: 0.12em;
}

html[data-ui-style="galgame"] .style-dock > * {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-3px);
  transition: opacity 0.16s ease, transform 0.18s ease, background 0.16s ease, border-color 0.16s ease;
}

html[data-ui-style="galgame"] .style-dock:hover > *,
html[data-ui-style="galgame"] .style-dock:focus-within > *,
html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock > * {
  opacity: 1;
  pointer-events: auto;
  transform: none;
}

html[data-ui-style="galgame"] .style-dock span,
html[data-ui-style="galgame"] .style-dock button,
html[data-ui-style="galgame"] .galgame-frequency-control {
  min-height: 36px;
  border: 1px solid rgba(255, 230, 240, 0.1);
  border-radius: 11px;
  color: rgba(255, 244, 249, 0.84);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.025)),
    rgba(255, 255, 255, 0.035);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 550;
  box-shadow: none;
}

html[data-ui-style="galgame"] .style-dock span:hover,
html[data-ui-style="galgame"] .style-dock button:hover,
html[data-ui-style="galgame"] .style-dock input:checked + span,
html[data-ui-style="galgame"] .style-dock > button[data-active="true"] {
  color: #241219;
  border-color: rgba(255, 226, 238, 0.48);
  background: linear-gradient(135deg, var(--acg-menu-pink), var(--acg-menu-gold));
  box-shadow: 0 8px 18px rgba(255, 184, 214, 0.18);
}

html[data-ui-style="galgame"] .galgame-frequency-control {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
}

html[data-ui-style="galgame"] .galgame-frequency-control span {
  min-height: 0;
  padding: 0;
  border: 0;
  color: rgba(255, 244, 249, 0.76);
  background: transparent;
  font-size: 12px;
  box-shadow: none;
}

html[data-ui-style="galgame"] .galgame-frequency-control select {
  width: 78px;
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid rgba(255, 230, 240, 0.12);
  border-radius: 999px;
  color: rgba(255, 244, 249, 0.9);
  background: rgba(0, 0, 0, 0.22);
  font-size: 12.5px;
}

html[data-ui-style="galgame"] .galgame-bg-picker {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 2px 0 4px;
}

html[data-ui-style="galgame"] .galgame-bg-choice,
html[data-ui-style="galgame"] .galgame-bg-upload span {
  flex: 0 0 118px;
  width: 118px;
  min-height: 50px;
  border: 1px solid rgba(255, 230, 240, 0.14);
  border-radius: 12px;
  color: rgba(255, 244, 249, 0.9);
  background-color: rgba(255, 255, 255, 0.045);
  font-size: 12.5px;
  font-weight: 600;
}

html[data-ui-style="galgame"] .galgame-bg-choice:hover,
html[data-ui-style="galgame"] .galgame-bg-upload span:hover,
html[data-ui-style="galgame"] .galgame-bg-choice[data-active="true"] {
  border-color: rgba(255, 213, 158, 0.68);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.16) inset,
    0 10px 24px rgba(255, 184, 214, 0.16);
}

.settings-drawer {
  width: min(460px, 100vw);
  border-left: 1px solid var(--acg-menu-line);
  color: rgba(255, 244, 249, 0.92);
  background:
    radial-gradient(circle at 18% 0%, rgba(255, 193, 220, 0.15), transparent 22rem),
    radial-gradient(circle at 92% 8%, rgba(126, 230, 204, 0.08), transparent 20rem),
    linear-gradient(180deg, rgba(43, 33, 42, 0.96), rgba(17, 13, 18, 0.98));
  box-shadow: -26px 0 70px rgba(8, 4, 8, 0.44);
  backdrop-filter: blur(30px) saturate(145%);
}

.settings-drawer::backdrop {
  background:
    radial-gradient(circle at 78% 18%, rgba(255, 193, 220, 0.08), transparent 28rem),
    rgba(5, 4, 7, 0.54);
  backdrop-filter: blur(3px);
}

.settings-drawer-head {
  padding: 22px 22px 18px;
  border-bottom: 1px solid rgba(255, 230, 240, 0.1);
  background:
    linear-gradient(180deg, rgba(255, 245, 250, 0.055), rgba(255, 245, 250, 0.014));
}

.settings-drawer-head .eyebrow {
  color: rgba(255, 213, 158, 0.86);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.12em;
}

.settings-drawer-head strong {
  color: rgba(255, 244, 249, 0.96);
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.settings-drawer-head button {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 230, 240, 0.12);
  border-radius: 999px;
  color: rgba(255, 244, 249, 0.78);
  background: rgba(255, 255, 255, 0.055);
  font-size: 18px;
  font-weight: 500;
  transition: transform 0.18s ease, color 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.settings-drawer-head button:hover {
  color: #241219;
  border-color: rgba(255, 226, 238, 0.52);
  background: linear-gradient(135deg, var(--acg-menu-pink), var(--acg-menu-gold));
  transform: rotate(90deg);
}

.settings-drawer-body {
  gap: 16px;
  padding: 18px;
}

.settings-drawer-body .settings-panel {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid rgba(255, 230, 240, 0.1);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 245, 250, 0.058), rgba(255, 245, 250, 0.018)),
    rgba(255, 255, 255, 0.026);
  box-shadow: none;
}

.settings-drawer-body .settings-panel:hover,
.settings-drawer-body .settings-panel:focus-within {
  border-color: rgba(255, 184, 214, 0.24);
  background:
    linear-gradient(180deg, rgba(255, 245, 250, 0.076), rgba(255, 245, 250, 0.024)),
    rgba(255, 255, 255, 0.032);
}

.settings-drawer-body .settings-panel > label:not(.check-line) {
  color: rgba(255, 213, 158, 0.88);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.08em;
}

.settings-drawer .field-hint,
.settings-drawer-body .settings-panel p {
  color: rgba(255, 244, 249, 0.6);
  font-size: 12.5px;
  line-height: 1.5;
}

.settings-drawer input,
.settings-drawer select,
.settings-drawer textarea {
  min-height: 38px;
  border-color: rgba(255, 230, 240, 0.12);
  border-radius: 10px;
  color: rgba(255, 244, 249, 0.92);
  background: rgba(0, 0, 0, 0.22);
  font-family: var(--font-ui);
  font-size: 13.5px;
}

.settings-drawer input:focus,
.settings-drawer select:focus,
.settings-drawer textarea:focus {
  outline: 0;
  border-color: rgba(255, 184, 214, 0.44);
  box-shadow: 0 0 0 3px rgba(255, 184, 214, 0.12);
}

.settings-drawer .check-line {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  margin: 2px 0;
  color: rgba(255, 244, 249, 0.76);
  font-size: 13px;
}

.settings-drawer .check-line input[type="checkbox"] {
  appearance: none;
  width: 18px;
  height: 18px;
  border: 1px solid rgba(255, 230, 240, 0.18);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.24);
  position: relative;
}

.settings-drawer .check-line input[type="checkbox"]:checked {
  border-color: rgba(255, 213, 158, 0.58);
  background: linear-gradient(135deg, var(--acg-menu-pink), var(--acg-menu-gold));
  box-shadow: 0 0 12px rgba(255, 184, 214, 0.22);
}

.settings-drawer .check-line input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 3px;
  width: 4px;
  height: 8px;
  border: solid #241219;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.settings-drawer .quota-row button,
.settings-drawer .voice-api-panel button {
  min-height: 36px;
  border-color: rgba(255, 230, 240, 0.14);
  border-radius: 10px;
  color: rgba(255, 244, 249, 0.86);
  background: rgba(255, 255, 255, 0.055);
  font-size: 13px;
  font-weight: 600;
}

.settings-drawer .quota-row button:hover,
.settings-drawer .voice-api-panel button:hover {
  color: #241219;
  border-color: rgba(255, 226, 238, 0.54);
  background: linear-gradient(135deg, var(--acg-menu-pink), var(--acg-menu-gold));
}

@media (max-width: 760px) {
  html[data-ui-style="galgame"] .style-dock {
    top: 10px;
    max-width: calc(100vw - 20px);
  }

  html[data-ui-style="galgame"] .style-dock:hover,
  html[data-ui-style="galgame"] .style-dock:focus-within,
  html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: calc(100vw - 20px);
  }

  .settings-drawer {
    width: 100vw;
  }
}

/* Premium menu verification fixes: remove clipped horizontal picker in expanded Galgame menu */
html[data-ui-style="galgame"] .style-dock:hover,
html[data-ui-style="galgame"] .style-dock:focus-within,
html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock {
  grid-template-columns: repeat(6, minmax(94px, 1fr));
  width: min(980px, calc(100vw - 36px));
  max-height: none;
  overflow: visible;
}

html[data-ui-style="galgame"] .galgame-frequency-control {
  grid-column: span 2;
  justify-content: space-between;
  min-width: 166px;
}

html[data-ui-style="galgame"] .galgame-frequency-control > span {
  white-space: nowrap;
}

html[data-ui-style="galgame"] .galgame-frequency-control select {
  flex: 1;
  min-width: 92px;
}

html[data-ui-style="galgame"] .galgame-bg-picker {
  display: grid;
  grid-template-columns: repeat(5, minmax(118px, 1fr));
  gap: 10px;
  overflow: visible;
  padding: 4px 0 0;
}

html[data-ui-style="galgame"] .galgame-bg-choice,
html[data-ui-style="galgame"] .galgame-bg-upload span {
  width: 100%;
  min-width: 0;
  flex-basis: auto;
}

@media (max-width: 900px) {
  html[data-ui-style="galgame"] .style-dock:hover,
  html[data-ui-style="galgame"] .style-dock:focus-within,
  html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock {
    grid-template-columns: repeat(4, minmax(88px, 1fr));
  }

  html[data-ui-style="galgame"] .galgame-bg-picker {
    grid-template-columns: repeat(3, minmax(96px, 1fr));
  }
}

@media (max-width: 760px) {
  html[data-ui-style="galgame"] .galgame-frequency-control {
    grid-column: 1 / -1;
  }

  html[data-ui-style="galgame"] .galgame-bg-picker {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Galgame SYSTEM menu redesign: compact VN-style system panel */
html[data-ui-style="galgame"] .style-dock {
  top: 14px;
  left: 50%;
  right: auto;
  width: 124px;
  min-height: 34px;
  height: 34px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(255, 239, 246, 0.18);
  background:
    linear-gradient(180deg, rgba(54, 44, 54, 0.78), rgba(28, 23, 31, 0.72));
  box-shadow:
    0 10px 26px rgba(15, 8, 15, 0.26),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(18px) saturate(132%);
  overflow: hidden;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  align-items: center;
  transform: translateX(-50%);
  transition:
    width 0.24s ease,
    height 0.24s ease,
    padding 0.24s ease,
    border-radius 0.24s ease,
    background 0.2s ease,
    box-shadow 0.2s ease;
}

html[data-ui-style="galgame"] .style-dock::before {
  content: "SYSTEM";
  grid-column: 1 / -1;
  display: grid;
  place-items: center;
  min-height: 34px;
  color: rgba(255, 214, 226, 0.96);
  background: transparent;
  box-shadow: none;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0.16em;
  text-shadow: 0 0 14px rgba(255, 184, 214, 0.22);
  pointer-events: none;
}

html[data-ui-style="galgame"] .style-dock > * {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-2px);
}

html[data-ui-style="galgame"] .style-dock:hover,
html[data-ui-style="galgame"] .style-dock:focus-within,
html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock {
  width: min(820px, calc(100vw - 32px));
  height: auto;
  max-height: min(52vh, 360px);
  padding: 18px;
  border-radius: 18px;
  row-gap: 12px;
  column-gap: 8px;
  overflow: hidden;
  background:
    radial-gradient(circle at 22% 0%, rgba(255, 193, 220, 0.11), transparent 18rem),
    linear-gradient(180deg, rgba(42, 35, 46, 0.92), rgba(24, 20, 29, 0.94));
  box-shadow:
    0 22px 54px rgba(10, 5, 10, 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.11);
}

html[data-ui-style="galgame"] .style-dock:hover::before,
html[data-ui-style="galgame"] .style-dock:focus-within::before,
html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock::before {
  content: "SYSTEM MENU";
  grid-column: 1 / 5;
  justify-self: start;
  min-height: 24px;
  padding: 0 2px;
  place-items: center start;
  color: rgba(255, 213, 158, 0.9);
  font-size: 11px;
  letter-spacing: 0.13em;
}

html[data-ui-style="galgame"] .style-dock:hover > *,
html[data-ui-style="galgame"] .style-dock:focus-within > *,
html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock > * {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
}

html[data-ui-style="galgame"] .style-dock > button {
  grid-row: 2;
  min-width: 0;
  min-height: 29px;
  height: 29px;
  padding: 0 8px;
  border: 1px solid rgba(255, 230, 240, 0.1);
  border-radius: 9px;
  color: rgba(255, 244, 249, 0.76);
  background: rgba(255, 255, 255, 0.045);
  box-shadow: none;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 680;
  white-space: nowrap;
}

html[data-ui-style="galgame"] .style-dock > button:hover,
html[data-ui-style="galgame"] .style-dock > button[data-active="true"] {
  color: #28141c;
  border-color: rgba(255, 226, 238, 0.5);
  background: linear-gradient(135deg, var(--acg-menu-pink), var(--acg-menu-gold));
  box-shadow: 0 8px 18px rgba(255, 184, 214, 0.16);
}

html[data-ui-style="galgame"] .style-dock > #galgameAutoScene,
html[data-ui-style="galgame"] .style-dock > #galgameAtmosphere,
html[data-ui-style="galgame"] .style-dock > #galgameBranchEdit {
  color: rgba(255, 213, 158, 0.78);
  background: rgba(255, 213, 158, 0.055);
}

html[data-ui-style="galgame"] .galgame-frequency-control {
  grid-row: 1;
  grid-column: 9 / 13;
  justify-self: end;
  width: auto;
  min-width: 150px;
  min-height: 28px;
  gap: 8px;
  padding: 3px 5px 3px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 230, 240, 0.1);
  color: rgba(255, 244, 249, 0.62);
  background: rgba(0, 0, 0, 0.2);
}

html[data-ui-style="galgame"] .galgame-frequency-control > span {
  min-height: 0;
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  box-shadow: none;
  font-size: 11.5px;
  font-weight: 680;
}

html[data-ui-style="galgame"] .galgame-frequency-control select {
  width: 76px;
  min-width: 76px;
  min-height: 22px;
  padding: 0 8px;
  border: 0;
  border-radius: 999px;
  color: rgba(255, 244, 249, 0.9);
  background: rgba(255, 255, 255, 0.075);
  font-size: 12px;
  font-weight: 680;
}

html[data-ui-style="galgame"] .style-dock > label:not(.galgame-frequency-control) {
  grid-row: 3;
  grid-column: span 3;
  display: grid;
  min-width: 0;
  height: 32px;
  margin: 0;
  cursor: pointer;
}

html[data-ui-style="galgame"] .style-dock > label:not(.galgame-frequency-control) input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

html[data-ui-style="galgame"] .style-dock > label:not(.galgame-frequency-control) span {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid rgba(255, 230, 240, 0.09);
  border-radius: 9px;
  color: rgba(255, 244, 249, 0.62);
  background: rgba(0, 0, 0, 0.17);
  box-shadow: none;
  font-size: 12.5px;
  font-weight: 700;
}

html[data-ui-style="galgame"] .style-dock > label:not(.galgame-frequency-control):hover span,
html[data-ui-style="galgame"] .style-dock > label:not(.galgame-frequency-control) input:checked + span {
  color: #2a151d;
  border-color: rgba(255, 226, 238, 0.5);
  background: linear-gradient(135deg, var(--acg-menu-pink), var(--acg-menu-gold));
  box-shadow: 0 8px 18px rgba(255, 184, 214, 0.13);
}

html[data-ui-style="galgame"] .galgame-bg-picker {
  grid-row: 4;
  grid-column: 1 / -1;
  display: flex;
  align-items: stretch;
  gap: 9px;
  margin-top: 2px;
  padding: 12px 1px 3px;
  border-top: 1px solid rgba(255, 230, 240, 0.08);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 213, 158, 0.38) transparent;
}

html[data-ui-style="galgame"] .galgame-bg-picker::before {
  content: "SCENE";
  flex: 0 0 auto;
  align-self: center;
  margin-right: 2px;
  color: rgba(255, 213, 158, 0.72);
  font-size: 10px;
  font-weight: 780;
  letter-spacing: 0.13em;
}

html[data-ui-style="galgame"] .galgame-bg-choice,
html[data-ui-style="galgame"] .galgame-bg-upload span {
  position: relative;
  flex: 0 0 86px;
  width: 86px;
  min-width: 86px;
  min-height: 54px;
  height: 54px;
  padding: 0 6px 5px;
  border: 1px solid rgba(255, 230, 240, 0.14);
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.94);
  background:
    linear-gradient(180deg, transparent 18%, rgba(0, 0, 0, 0.2) 58%, rgba(0, 0, 0, 0.62) 100%),
    var(--bg-thumb) center / cover no-repeat;
  box-shadow: none;
  font-size: 11px;
  font-weight: 760;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  white-space: nowrap;
  overflow: hidden;
}

html[data-ui-style="galgame"] .galgame-bg-choice:hover,
html[data-ui-style="galgame"] .galgame-bg-choice[data-active="true"] {
  border-color: rgba(255, 213, 158, 0.72);
  transform: translateY(-1px);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.12) inset,
    0 10px 20px rgba(255, 184, 214, 0.14);
}

html[data-ui-style="galgame"] .galgame-bg-upload {
  flex: 0 0 96px;
  width: 96px;
  display: block;
}

html[data-ui-style="galgame"] .galgame-bg-upload span {
  width: 96px;
  min-width: 96px;
  color: rgba(255, 244, 249, 0.66);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.015));
  border-style: dashed;
  text-shadow: none;
}

html[data-ui-style="galgame"] .galgame-user-bg-choices {
  flex: 0 0 auto;
  display: contents;
}

@media (max-width: 900px) {
  html[data-ui-style="galgame"] .style-dock:hover,
  html[data-ui-style="galgame"] .style-dock:focus-within,
  html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock {
    width: calc(100vw - 22px);
    max-height: min(62vh, 420px);
    overflow-y: auto;
  }

  html[data-ui-style="galgame"] .style-dock > button {
    grid-column: span 2;
  }

  html[data-ui-style="galgame"] .style-dock > label:not(.galgame-frequency-control) {
    grid-column: span 3;
  }
}

@media (max-width: 760px) {
  html[data-ui-style="galgame"] .style-dock {
    top: auto;
    bottom: 12px;
  }

  html[data-ui-style="galgame"] .style-dock:hover,
  html[data-ui-style="galgame"] .style-dock:focus-within,
  html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock {
    width: calc(100vw - 18px);
    max-height: 72vh;
    padding: 14px;
    border-radius: 18px;
  }

  html[data-ui-style="galgame"] .style-dock:hover::before,
  html[data-ui-style="galgame"] .style-dock:focus-within::before,
  html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock::before,
  html[data-ui-style="galgame"] .galgame-frequency-control,
  html[data-ui-style="galgame"] .style-dock > label:not(.galgame-frequency-control),
  html[data-ui-style="galgame"] .galgame-bg-picker {
    grid-column: 1 / -1;
  }

  html[data-ui-style="galgame"] .style-dock > button {
    grid-column: span 3;
  }
}

/* Galgame SYSTEM menu density fix: split tools and restore scene thumbnails */
html[data-ui-style="galgame"] .style-dock:hover,
html[data-ui-style="galgame"] .style-dock:focus-within,
html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock {
  width: min(860px, calc(100vw - 32px));
  grid-template-columns: repeat(12, minmax(0, 1fr));
}

html[data-ui-style="galgame"] .style-dock > button {
  font-size: 11.5px;
  padding: 0 5px;
}

html[data-ui-style="galgame"] .style-dock > #voiceToggleDock,
html[data-ui-style="galgame"] .style-dock > #galgameLogToggle,
html[data-ui-style="galgame"] .style-dock > #galgameSkipText,
html[data-ui-style="galgame"] .style-dock > #galgameHideToggle,
html[data-ui-style="galgame"] .style-dock > #galgameSave,
html[data-ui-style="galgame"] .style-dock > #galgameLoad,
html[data-ui-style="galgame"] .style-dock > #galgameAuto,
html[data-ui-style="galgame"] .style-dock > #galgameSkipRead {
  grid-row: 2;
  grid-column: span 1;
}

html[data-ui-style="galgame"] .style-dock > #galgameAutoScene,
html[data-ui-style="galgame"] .style-dock > #galgameAtmosphere,
html[data-ui-style="galgame"] .style-dock > #galgameBranchEdit {
  grid-row: 3;
  grid-column: span 2;
}

html[data-ui-style="galgame"] .style-dock > label:not(.galgame-frequency-control) {
  grid-row: 3;
  grid-column: span 2;
  height: 30px;
}

html[data-ui-style="galgame"] .style-dock > label:not(.galgame-frequency-control) span {
  min-height: 30px;
  font-size: 12px;
}

html[data-ui-style="galgame"] .galgame-bg-picker {
  grid-row: 4;
  max-width: 100%;
}

html[data-ui-style="galgame"] .style-dock .galgame-bg-choice,
html[data-ui-style="galgame"] .style-dock .galgame-bg-upload span {
  flex: 0 0 92px;
  width: 92px;
  min-width: 92px;
  min-height: 56px;
  height: 56px;
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.02) 8%, rgba(0, 0, 0, 0.12) 50%, rgba(0, 0, 0, 0.66) 100%),
    var(--bg-thumb) center / cover no-repeat !important;
}

html[data-ui-style="galgame"] .style-dock .galgame-bg-upload span {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.018)) !important;
}

@media (max-width: 900px) {
  html[data-ui-style="galgame"] .style-dock > #voiceToggleDock,
  html[data-ui-style="galgame"] .style-dock > #galgameLogToggle,
  html[data-ui-style="galgame"] .style-dock > #galgameSkipText,
  html[data-ui-style="galgame"] .style-dock > #galgameHideToggle,
  html[data-ui-style="galgame"] .style-dock > #galgameSave,
  html[data-ui-style="galgame"] .style-dock > #galgameLoad,
  html[data-ui-style="galgame"] .style-dock > #galgameAuto,
  html[data-ui-style="galgame"] .style-dock > #galgameSkipRead {
    grid-column: span 3;
  }

  html[data-ui-style="galgame"] .style-dock > #galgameAutoScene,
  html[data-ui-style="galgame"] .style-dock > #galgameAtmosphere,
  html[data-ui-style="galgame"] .style-dock > #galgameBranchEdit,
  html[data-ui-style="galgame"] .style-dock > label:not(.galgame-frequency-control) {
    grid-column: span 4;
  }
}

/* Galgame final pass: promote dialogue and branch choices to the primary stage */
html[data-ui-style="galgame"] .chat-shell {
  width: min(980px, calc(100vw - 44px));
  padding: 22px 22px 26px;
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(16, 10, 15, 0.18) 0%, rgba(16, 10, 15, 0.4) 24%, rgba(16, 10, 15, 0.72) 100%);
  box-shadow:
    0 26px 70px rgba(0, 0, 0, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(22px) saturate(125%);
}

html[data-ui-style="galgame"] .chat-shell::before {
  inset: 10px 14px auto;
  height: 1px;
  opacity: 0.3;
}

html[data-ui-style="galgame"] .messages {
  gap: 14px;
  padding: 6px 0 2px;
}

html[data-ui-style="galgame"] .galgame-speaker {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  width: fit-content;
  max-width: min(100%, 720px);
  padding: 10px 16px 9px;
  border: 1px solid rgba(255, 235, 244, 0.22);
  border-radius: 16px 16px 16px 6px;
  background:
    linear-gradient(135deg, rgba(255, 228, 240, 0.2), rgba(255, 255, 255, 0.06)),
    rgba(18, 10, 16, 0.58);
  box-shadow:
    0 10px 24px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(14px);
}

html[data-ui-style="galgame"] .galgame-speaker strong {
  color: #fff7fb;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 780;
  line-height: 1;
  letter-spacing: 0.03em;
}

html[data-ui-style="galgame"] .galgame-speaker span {
  color: rgba(255, 231, 239, 0.76);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

html[data-ui-style="galgame"] .galgame-speaker.user {
  margin-left: auto;
  border-radius: 16px 16px 6px 16px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent), transparent 70%), rgba(255, 255, 255, 0.08)),
    rgba(14, 11, 18, 0.62);
}

html[data-ui-style="galgame"] .bubble {
  width: min(100%, 920px);
  min-height: 112px;
  padding: 22px 26px;
  border: 1px solid rgba(255, 238, 245, 0.2);
  border-radius: 24px;
  color: rgba(255, 247, 251, 0.98);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.03)),
    linear-gradient(180deg, rgba(24, 14, 22, 0.86), rgba(11, 7, 12, 0.9));
  box-shadow:
    0 22px 42px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 540;
  line-height: 1.8;
  letter-spacing: 0.025em;
  text-shadow: 0 1px 14px rgba(0, 0, 0, 0.44);
}

html[data-ui-style="galgame"] .bubble.assistant {
  margin-right: auto;
}

html[data-ui-style="galgame"] .bubble.user {
  margin-left: auto;
  width: min(100%, 760px);
  min-height: 84px;
  color: rgba(255, 248, 252, 0.96);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.05)),
    linear-gradient(135deg, color-mix(in srgb, var(--accent), transparent 56%), rgba(27, 15, 26, 0.92));
  font-size: 19px;
  line-height: 1.65;
}

html[data-ui-style="galgame"] .galgame-route-status {
  top: 18px;
  left: 50%;
  z-index: 11;
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid rgba(255, 233, 241, 0.22);
  border-radius: 999px;
  color: rgba(255, 244, 248, 0.94);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.04)),
    rgba(18, 10, 15, 0.58);
  box-shadow:
    0 14px 34px rgba(0, 0, 0, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(16px);
  font-size: 13px;
  font-weight: 760;
  letter-spacing: 0.08em;
}

html[data-ui-style="galgame"] .galgame-choices {
  gap: 14px;
  width: min(100%, 900px);
  margin: 4px auto 0;
}

html[data-ui-style="galgame"] .galgame-choices button {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-items: center;
  justify-items: start;
  gap: 5px 14px;
  min-height: 86px;
  padding: 16px 20px 16px 18px;
  border-radius: 20px;
  text-align: left;
}

html[data-ui-style="galgame"] .galgame-choices button::before {
  left: 21px;
  width: 11px;
  height: 11px;
}

html[data-ui-style="galgame"] .galgame-choices button b {
  grid-row: 1 / span 2;
  grid-column: 1;
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 999px;
  color: rgba(255, 250, 252, 0.98);
  background: rgba(255, 255, 255, 0.12);
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
  position: relative;
  z-index: 1;
}

html[data-ui-style="galgame"] .galgame-choices button span {
  grid-column: 2;
  font-size: 18px;
  font-weight: 840;
  line-height: 1.35;
}

html[data-ui-style="galgame"] .galgame-choices button small {
  grid-column: 2;
  color: rgba(255, 234, 242, 0.74);
  font-size: 11px;
  font-weight: 760;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

html[data-ui-style="galgame"] .route-event-toast {
  top: auto;
  bottom: 198px;
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 14px;
  letter-spacing: 0.06em;
}

html[data-ui-style="galgame"] .style-dock {
  top: 16px;
  right: 16px;
  opacity: 0.78;
  transform: translateY(0);
}

html[data-ui-style="galgame"] .style-dock::before {
  color: rgba(255, 235, 243, 0.86);
  letter-spacing: 0.22em;
}

html[data-ui-style="galgame"] .style-dock:hover,
html[data-ui-style="galgame"] .style-dock:focus-within,
html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock {
  opacity: 1;
  background:
    linear-gradient(180deg, rgba(20, 12, 18, 0.92), rgba(9, 6, 10, 0.96));
  box-shadow:
    0 28px 60px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

@media (max-width: 900px) {
  html[data-ui-style="galgame"] .chat-shell {
    width: calc(100vw - 26px);
    padding: 18px 16px 22px;
    border-radius: 24px;
  }

  html[data-ui-style="galgame"] .bubble {
    min-height: 96px;
    padding: 18px 18px 20px;
    font-size: 18.5px;
    line-height: 1.72;
  }

  html[data-ui-style="galgame"] .bubble.user {
    width: min(100%, 100%);
    font-size: 17px;
  }

  html[data-ui-style="galgame"] .galgame-speaker {
    max-width: 100%;
    padding: 9px 13px 8px;
  }

  html[data-ui-style="galgame"] .galgame-speaker strong {
    font-size: 18px;
  }

  html[data-ui-style="galgame"] .galgame-choices button {
    min-height: 78px;
    padding: 14px 16px;
  }
}

@media (max-width: 640px) {
  html[data-ui-style="galgame"] .messages {
    gap: 11px;
  }

  html[data-ui-style="galgame"] .galgame-route-status {
    top: 12px;
    max-width: calc(100vw - 28px);
    min-height: 38px;
    padding: 0 14px;
    font-size: 11.5px;
    letter-spacing: 0.05em;
  }

  html[data-ui-style="galgame"] .bubble {
    min-height: 86px;
    border-radius: 20px;
    font-size: 17px;
    line-height: 1.64;
  }

  html[data-ui-style="galgame"] .bubble.user {
    font-size: 15.5px;
  }

  html[data-ui-style="galgame"] .galgame-choices {
    gap: 10px;
  }

  html[data-ui-style="galgame"] .galgame-choices button {
    grid-template-columns: 34px minmax(0, 1fr);
    min-height: 72px;
    gap: 3px 12px;
    padding: 13px 14px;
  }

  html[data-ui-style="galgame"] .galgame-choices button b {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }

  html[data-ui-style="galgame"] .galgame-choices button span {
    font-size: 15.5px;
  }

  html[data-ui-style="galgame"] .galgame-choices button small {
    font-size: 10px;
    letter-spacing: 0.12em;
  }

  html[data-ui-style="galgame"] .route-event-toast {
    bottom: 168px;
    max-width: calc(100vw - 28px);
    padding: 10px 16px;
  }
}

/* Galgame gameplay mode control */
.galgame-mode-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.galgame-mode-control span {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.galgame-mode-control select {
  min-height: 34px;
  border-radius: 10px;
}

html[data-ui-style="galgame"] .galgame-mode-control {
  grid-row: 3;
  grid-column: span 2;
  min-height: 32px;
  padding: 0 9px;
  border: 1px solid rgba(255, 230, 240, 0.1);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.17);
}

html[data-ui-style="galgame"] .galgame-mode-control span {
  color: rgba(255, 213, 158, 0.72);
  font-size: 10px;
}

html[data-ui-style="galgame"] .galgame-mode-control select {
  width: 100%;
  min-height: 28px;
  padding: 0 7px;
  border: 0;
  color: rgba(255, 244, 249, 0.92);
  background: transparent;
  font-size: 12px;
  font-weight: 760;
}

@media (max-width: 900px) {
  html[data-ui-style="galgame"] .galgame-mode-control {
    grid-column: span 4;
  }
}

@media (max-width: 760px) {
  html[data-ui-style="galgame"] .galgame-mode-control {
    grid-column: 1 / -1;
  }
}

/* Character Story Bible editor */
.story-bible-dialog {
  width: min(860px, calc(100vw - 28px));
  max-height: min(780px, calc(100dvh - 28px));
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 230, 240, 0.18);
  border-radius: 18px;
  color: rgba(255, 246, 250, 0.95);
  background:
    linear-gradient(180deg, rgba(28, 17, 25, 0.96), rgba(12, 8, 12, 0.98));
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.42);
}

.story-bible-dialog::backdrop {
  background: rgba(8, 4, 8, 0.66);
  backdrop-filter: blur(10px);
}

.story-bible-dialog form {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  max-height: inherit;
}

.story-bible-head,
.story-bible-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255, 230, 240, 0.1);
}

.story-bible-head strong {
  display: block;
  margin-top: 2px;
  font-size: 20px;
}

.story-bible-head button,
.story-bible-actions button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(255, 230, 240, 0.16);
  border-radius: 10px;
  color: rgba(255, 246, 250, 0.94);
  background: rgba(255, 255, 255, 0.08);
  font-weight: 760;
}

.story-bible-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 18px;
  overflow: auto;
}

.story-bible-body label {
  display: grid;
  gap: 7px;
  color: rgba(255, 230, 240, 0.72);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.story-bible-body textarea {
  width: 100%;
  min-height: 72px;
  resize: vertical;
  border: 1px solid rgba(255, 230, 240, 0.14);
  border-radius: 12px;
  color: rgba(255, 247, 251, 0.96);
  background: rgba(0, 0, 0, 0.22);
  font: 500 14px/1.55 var(--font-serif);
}

.story-bible-body textarea:focus {
  border-color: rgba(255, 184, 214, 0.5);
  box-shadow: 0 0 0 3px rgba(255, 184, 214, 0.12);
}

.story-bible-actions {
  border-top: 1px solid rgba(255, 230, 240, 0.1);
  border-bottom: 0;
}

.story-bible-actions span {
  min-width: 0;
  color: rgba(255, 230, 240, 0.72);
  font-size: 12px;
  font-weight: 760;
}

.story-bible-action {
  border-color: rgba(255, 213, 158, 0.28);
}

@media (max-width: 720px) {
  .story-bible-body {
    grid-template-columns: 1fr;
  }
}

/* Galgame menu readability fix: Chinese controls, no overlap with route badge */
html[data-ui-style="galgame"] .style-dock:hover,
html[data-ui-style="galgame"] .style-dock:focus-within,
html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock {
  top: 66px;
  right: 16px;
  grid-template-columns: repeat(8, minmax(78px, 1fr));
  width: min(920px, calc(100vw - 32px));
  max-height: min(74vh, 430px);
  overflow: visible;
  padding: 12px;
  z-index: 32;
}

html[data-ui-style="galgame"] .galgame-route-status {
  z-index: 24;
  max-width: min(760px, calc(100vw - 220px));
  transform: translateX(-50%);
  white-space: nowrap;
}

html[data-ui-style="galgame"] .galgame-frequency-control,
html[data-ui-style="galgame"] .galgame-mode-control {
  position: relative;
  z-index: 34;
  display: grid;
  grid-template-columns: auto minmax(112px, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 5px 8px 5px 12px;
  border: 1px solid rgba(255, 229, 240, 0.2);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 238, 245, 0.12), rgba(255, 255, 255, 0.035)),
    rgba(0, 0, 0, 0.28);
}

html[data-ui-style="galgame"] .galgame-frequency-control {
  grid-row: 1;
  grid-column: span 2;
}

html[data-ui-style="galgame"] .galgame-mode-control {
  grid-row: 1;
  grid-column: span 2;
}

html[data-ui-style="galgame"] .galgame-frequency-control span,
html[data-ui-style="galgame"] .galgame-mode-control span {
  min-height: auto;
  padding: 0;
  border: 0;
  color: rgba(255, 219, 158, 0.96);
  background: transparent;
  box-shadow: none;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

html[data-ui-style="galgame"] .galgame-frequency-control select,
html[data-ui-style="galgame"] .galgame-mode-control select {
  width: 100%;
  min-width: 112px;
  min-height: 32px;
  padding: 0 28px 0 10px;
  border: 1px solid rgba(255, 224, 236, 0.2);
  border-radius: 9px;
  color: #fff7fb;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.04)),
    rgba(20, 12, 18, 0.96);
  font-size: 13px;
  font-weight: 850;
  cursor: pointer;
}

html[data-ui-style="galgame"] .galgame-frequency-control select option,
html[data-ui-style="galgame"] .galgame-mode-control select option {
  color: #24151f;
  background: #fff2f7;
  font-size: 14px;
  font-weight: 800;
}

html[data-ui-style="galgame"] .style-dock > #voiceToggleDock,
html[data-ui-style="galgame"] .style-dock > #galgameLogToggle,
html[data-ui-style="galgame"] .style-dock > #galgameSkipText,
html[data-ui-style="galgame"] .style-dock > #galgameHideToggle,
html[data-ui-style="galgame"] .style-dock > #galgameSave,
html[data-ui-style="galgame"] .style-dock > #galgameLoad,
html[data-ui-style="galgame"] .style-dock > #galgameAuto,
html[data-ui-style="galgame"] .style-dock > #galgameSkipRead {
  grid-row: 2;
  grid-column: span 1;
}

html[data-ui-style="galgame"] .style-dock > #galgameAutoScene,
html[data-ui-style="galgame"] .style-dock > #galgameAtmosphere,
html[data-ui-style="galgame"] .style-dock > #galgameBranchEdit,
html[data-ui-style="galgame"] .style-dock > label:not(.galgame-frequency-control):not(.galgame-mode-control) {
  grid-row: 3;
  grid-column: span 2;
}

html[data-ui-style="galgame"] .galgame-bg-picker {
  grid-row: 4;
  grid-column: 1 / -1;
  margin-top: 2px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 230, 240, 0.12);
}

@media (max-width: 900px) {
  html[data-ui-style="galgame"] .style-dock:hover,
  html[data-ui-style="galgame"] .style-dock:focus-within,
  html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock {
    top: 58px;
    grid-template-columns: repeat(4, minmax(64px, 1fr));
  }

  html[data-ui-style="galgame"] .galgame-route-status {
    max-width: calc(100vw - 28px);
    white-space: normal;
  }

  html[data-ui-style="galgame"] .galgame-frequency-control,
  html[data-ui-style="galgame"] .galgame-mode-control {
    grid-column: span 2;
  }
}

/* Galgame choice overlay: route choices live in the center, away from dialogue text */
html[data-ui-style="galgame"] .messages > .galgame-choices {
  position: fixed;
  left: 50%;
  top: 48%;
  z-index: 27;
  display: grid;
  grid-template-columns: minmax(320px, 560px);
  width: min(560px, calc(100vw - 40px));
  max-height: min(52vh, 460px);
  overflow: auto;
  gap: 12px;
  margin: 0;
  padding: 14px;
  border: 1px solid rgba(255, 230, 240, 0.16);
  border-radius: 22px;
  background:
    radial-gradient(circle at 16% 0%, rgba(255, 220, 236, 0.16), transparent 12rem),
    linear-gradient(180deg, rgba(14, 9, 13, 0.92), rgba(5, 4, 7, 0.94));
  box-shadow:
    0 30px 90px rgba(0, 0, 0, 0.48),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transform: translate(-50%, -50%);
  backdrop-filter: blur(18px) saturate(120%);
}

html[data-ui-style="galgame"] .messages > .galgame-choices::before {
  content: "选择分支";
  display: block;
  padding: 0 4px 2px;
  color: rgba(255, 214, 226, 0.72);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.22em;
  text-align: center;
}

html[data-ui-style="galgame"] .messages > .galgame-choices button {
  width: 100%;
  min-height: 76px;
  padding: 14px 18px;
  border-radius: 17px;
}

html[data-ui-style="galgame"] .messages > .galgame-choices button:hover,
html[data-ui-style="galgame"] .messages > .galgame-choices button:focus-visible {
  transform: translateY(-1px);
}

html[data-ui-style="galgame"] .galgame-route-status {
  top: 14px;
  left: auto;
  right: 144px;
  z-index: 23;
  max-width: min(520px, calc(100vw - 310px));
  min-height: 34px;
  padding: 0 14px;
  transform: none;
  opacity: 0.9;
  white-space: nowrap;
}

html[data-ui-style="galgame"] .chat-shell::before {
  z-index: 28;
}

@media (max-width: 900px) {
  html[data-ui-style="galgame"] .messages > .galgame-choices {
    top: 46%;
    width: min(520px, calc(100vw - 24px));
    grid-template-columns: 1fr;
    padding: 12px;
  }

  html[data-ui-style="galgame"] .galgame-route-status {
    top: 56px;
    left: 14px;
    right: 14px;
    max-width: none;
    white-space: normal;
  }
}

/* Final VN overlay fix: click-only menu and body-level choices */
html[data-ui-style="galgame"] .style-dock,
html[data-ui-style="galgame"] .style-dock:hover {
  top: 16px;
  right: 16px;
  display: grid;
  grid-template-columns: 1fr;
  width: 112px;
  max-height: 34px;
  overflow: hidden;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  box-shadow: none;
  opacity: 0.78;
}

html[data-ui-style="galgame"] .style-dock:hover > *,
html[data-ui-style="galgame"] .style-dock:hover .galgame-bg-picker {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-2px);
}

html[data-ui-style="galgame"] .style-dock:hover::before {
  display: grid;
}

html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock,
html[data-ui-style="galgame"] .style-dock:focus-within {
  top: 64px;
  right: 18px;
  grid-template-columns: repeat(8, minmax(76px, 1fr));
  width: min(900px, calc(100vw - 36px));
  max-height: min(70vh, 420px);
  overflow: visible;
  padding: 12px;
  border: 1px solid rgba(255, 230, 240, 0.14);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(20, 12, 18, 0.94), rgba(7, 5, 9, 0.97));
  box-shadow:
    0 28px 68px rgba(0, 0, 0, 0.44),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  opacity: 1;
  z-index: 36;
}

html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock::before,
html[data-ui-style="galgame"] .style-dock:focus-within::before {
  display: none;
}

html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock > *,
html[data-ui-style="galgame"] .style-dock:focus-within > *,
html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock .galgame-bg-picker,
html[data-ui-style="galgame"] .style-dock:focus-within .galgame-bg-picker {
  opacity: 1;
  pointer-events: auto;
  transform: none;
}

html[data-ui-style="galgame"] .galgame-choice-layer {
  position: fixed;
  left: 47%;
  top: 43%;
  z-index: 34;
  width: min(520px, calc(100vw - 48px));
  transform: translate(-50%, -50%);
  pointer-events: none;
}

html[data-ui-style="galgame"] .galgame-choice-layer[hidden] {
  display: none;
}

html[data-ui-style="galgame"] .galgame-choice-layer .galgame-choices {
  position: static;
  display: grid;
  width: 100%;
  max-height: min(52vh, 430px);
  overflow: auto;
  gap: 12px;
  margin: 0;
  padding: 14px;
  border: 1px solid rgba(255, 230, 240, 0.16);
  border-radius: 22px;
  background:
    radial-gradient(circle at 16% 0%, rgba(255, 220, 236, 0.16), transparent 12rem),
    linear-gradient(180deg, rgba(14, 9, 13, 0.92), rgba(5, 4, 7, 0.94));
  box-shadow:
    0 30px 90px rgba(0, 0, 0, 0.48),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transform: none;
  pointer-events: auto;
  backdrop-filter: blur(18px) saturate(120%);
}

html[data-ui-style="galgame"] .galgame-choice-layer .galgame-choices::before {
  content: "选择分支";
  display: block;
  padding: 0 4px 2px;
  color: rgba(255, 214, 226, 0.72);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.22em;
  text-align: center;
}

html[data-ui-style="galgame"] .galgame-choice-layer .galgame-choices button {
  width: 100%;
  min-height: 76px;
  padding: 14px 18px;
  border-radius: 17px;
}

html[data-ui-style="galgame"] .messages > .galgame-choices {
  display: none !important;
}

html[data-ui-style="galgame"] .galgame-route-status {
  top: 14px;
  right: 144px;
  left: auto;
  z-index: 26;
  max-width: min(560px, calc(100vw - 330px));
  transform: none;
}

html[data-ui-style="galgame"] .chat-shell::before {
  top: -26px;
  left: 22px;
  z-index: 30;
}

@media (max-width: 900px) {
  html[data-ui-style="galgame"] .galgame-choice-layer {
    left: 50%;
    top: 42%;
    width: min(520px, calc(100vw - 24px));
  }

  html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock,
  html[data-ui-style="galgame"] .style-dock:focus-within {
    top: 58px;
    grid-template-columns: repeat(4, minmax(64px, 1fr));
  }

  html[data-ui-style="galgame"] .galgame-route-status {
    top: 52px;
    left: 14px;
    right: 14px;
    max-width: none;
  }
}

/* Gemini VN polish: transparent choices, glass dialogue, grouped menu */
:root {
  --vn-glass-bg: rgba(16, 18, 27, 0.58);
  --vn-glass-border: rgba(255, 235, 244, 0.16);
  --vn-card-bg: rgba(12, 8, 13, 0.52);
  --vn-card-hover: rgba(244, 92, 145, 0.18);
  --vn-shadow: 0 18px 54px rgba(0, 0, 0, 0.34);
  --vn-text-shadow: 0 2px 8px rgba(0, 0, 0, 0.82);
}

html[data-ui-style="galgame"] .galgame-choice-layer {
  left: 47%;
  top: 42%;
  width: min(560px, calc(100vw - 48px));
}

html[data-ui-style="galgame"] .galgame-choice-layer .galgame-choices {
  gap: 13px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

html[data-ui-style="galgame"] .galgame-choice-layer .galgame-choices::before {
  display: none;
}

html[data-ui-style="galgame"] .galgame-choice-layer .galgame-choices button {
  min-height: 72px;
  border: 1px solid rgba(255, 235, 244, 0.18);
  border-radius: 18px;
  background:
    linear-gradient(110deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.015)),
    var(--vn-card-bg);
  box-shadow:
    0 12px 36px rgba(0, 0, 0, 0.26),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  opacity: 0.9;
  backdrop-filter: blur(12px) saturate(116%);
  -webkit-backdrop-filter: blur(12px) saturate(116%);
}

html[data-ui-style="galgame"] .galgame-choice-layer .galgame-choices button:hover,
html[data-ui-style="galgame"] .galgame-choice-layer .galgame-choices button:focus-visible,
html[data-ui-style="galgame"] .galgame-choice-layer .galgame-choices button[data-selected="true"] {
  border-color: color-mix(in srgb, var(--accent-2), white 18%);
  background:
    radial-gradient(circle at 38% 50%, rgba(255, 115, 174, 0.22), transparent 12rem),
    linear-gradient(110deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.02)),
    var(--vn-card-hover);
  box-shadow:
    0 0 24px color-mix(in srgb, var(--accent-2), transparent 70%),
    0 16px 46px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  opacity: 1;
}

html[data-ui-style="galgame"] .galgame-choice-layer .galgame-choices button b {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.28);
  font-family: "Courier New", ui-monospace, monospace;
}

html[data-ui-style="galgame"] .galgame-choice-layer .galgame-choices button:hover b,
html[data-ui-style="galgame"] .galgame-choice-layer .galgame-choices button[data-selected="true"] b {
  background: color-mix(in srgb, var(--accent-2), transparent 32%);
  box-shadow: 0 0 14px color-mix(in srgb, var(--accent-2), transparent 58%);
}

html[data-ui-style="galgame"] .chat-shell {
  width: min(980px, calc(100vw - 60px));
  min-height: 176px;
  border: 1px solid var(--vn-glass-border);
  border-top-color: rgba(255, 255, 255, 0.28);
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.018)),
    linear-gradient(180deg, rgba(16, 18, 27, 0.34), rgba(9, 7, 12, 0.68));
  box-shadow:
    inset 0 1px 2px rgba(255, 255, 255, 0.08),
    var(--vn-shadow);
  backdrop-filter: blur(18px) saturate(118%);
  -webkit-backdrop-filter: blur(18px) saturate(118%);
}

html[data-ui-style="galgame"] .chat-shell::before {
  display: none !important;
}

html[data-ui-style="galgame"] .galgame-speaker {
  margin: 0 0 8px 2px;
  border: 0;
  border-left: 4px solid color-mix(in srgb, var(--accent-2), white 16%);
  border-radius: 0;
  padding: 2px 14px 3px 12px;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--accent), transparent 62%), transparent 100%);
  box-shadow: none;
  backdrop-filter: none;
}

html[data-ui-style="galgame"] .galgame-speaker strong {
  font-size: 23px;
  text-shadow: var(--vn-text-shadow);
}

html[data-ui-style="galgame"] .galgame-speaker span {
  color: rgba(255, 232, 241, 0.78);
  text-transform: none;
}

html[data-ui-style="galgame"] .bubble {
  min-height: 102px;
  border: 0;
  background: transparent;
  box-shadow: none;
  padding: 4px 6px 10px;
  color: rgba(255, 249, 252, 0.98);
  text-shadow: var(--vn-text-shadow);
  font-size: 22px;
  line-height: 1.82;
}

html[data-ui-style="galgame"] .composer {
  padding-top: 8px;
  background: transparent;
}

html[data-ui-style="galgame"] .style-dock .menu-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  width: 100%;
}

html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock,
html[data-ui-style="galgame"] .style-dock:focus-within {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(760px, calc(100vw - 36px));
  max-height: min(72vh, 440px);
  overflow: visible;
}

html[data-ui-style="galgame"] .style-dock .row-actions button {
  flex: 1 1 72px;
  min-width: 68px;
}

html[data-ui-style="galgame"] .style-dock .row-configs > * {
  flex: 1 1 128px;
  min-width: 118px;
}

html[data-ui-style="galgame"] .style-dock .row-configs label {
  height: 40px;
}

html[data-ui-style="galgame"] .style-dock .row-thumbnails {
  display: block;
  overflow: visible;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 230, 240, 0.12);
}

html[data-ui-style="galgame"] .style-dock .row-thumbnails .galgame-bg-picker {
  display: flex;
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

html[data-ui-style="galgame"] #galgameGameplayMode,
html[data-ui-style="galgame"] #galgameChoiceFrequency {
  min-width: 132px;
}

html[data-ui-style="galgame"] .galgame-route-status {
  opacity: 0.68;
  font-size: 12px;
}

@media (max-width: 900px) {
  html[data-ui-style="galgame"] .galgame-choice-layer {
    left: 50%;
    top: 40%;
  }

  html[data-ui-style="galgame"] .chat-shell {
    width: calc(100vw - 26px);
  }
}

/* Hard fix: grid menu configs and visible glass MENU trigger */
html[data-ui-style="galgame"] .style-dock:not(:focus-within):not(:has(:focus-visible)) {
  min-width: 96px;
  min-height: 36px;
}

html[data-ui-style="galgame"] .style-dock:not(:focus-within):not([aria-expanded="true"]) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 96px;
  max-height: 36px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  box-shadow:
    0 4px 14px rgba(0, 0, 0, 0.48),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(12px) saturate(118%);
  -webkit-backdrop-filter: blur(12px) saturate(118%);
  cursor: pointer;
  opacity: 0.96;
}

html[data-ui-style="galgame"] .style-dock:not(:focus-within):not([aria-expanded="true"])::before {
  content: "MENU";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-height: 0;
  color: #fff;
  font-family: "Cinzel", "Times New Roman", serif;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-shadow: 0 0 5px rgba(0, 0, 0, 0.86);
}

html[data-ui-style="galgame"] .style-dock:not(:focus-within):not([aria-expanded="true"])::after {
  content: "";
  width: 6px;
  height: 6px;
  margin-left: 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent-2), white 10%);
  box-shadow: 0 0 10px color-mix(in srgb, var(--accent-2), transparent 20%);
}

html[data-ui-style="galgame"] .style-dock:not(:focus-within):not([aria-expanded="true"]):hover {
  border-color: color-mix(in srgb, var(--accent-2), white 10%);
  background: rgba(244, 63, 94, 0.2);
  box-shadow:
    0 0 14px rgba(244, 63, 94, 0.5),
    0 4px 14px rgba(0, 0, 0, 0.56),
    inset 0 1px 0 rgba(255, 255, 255, 0.24);
  transform: translateY(-1px);
}

html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock,
html[data-ui-style="galgame"] .style-dock:focus-within {
  width: min(760px, calc(100vw - 36px));
}

html[data-ui-style="galgame"] .style-dock .menu-row.row-configs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
}

html[data-ui-style="galgame"] .style-dock .menu-row.row-configs > label,
html[data-ui-style="galgame"] .style-dock .menu-row.row-configs > button,
html[data-ui-style="galgame"] .style-dock .menu-row.row-configs > .galgame-frequency-control,
html[data-ui-style="galgame"] .style-dock .menu-row.row-configs > .galgame-mode-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  width: 100%;
  min-height: 40px;
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  box-sizing: border-box;
  white-space: nowrap;
}

html[data-ui-style="galgame"] .style-dock .menu-row.row-configs > button {
  justify-content: center;
}

html[data-ui-style="galgame"] .style-dock .menu-row.row-configs span {
  overflow: hidden;
  min-width: 0;
  max-width: 86px;
  text-overflow: ellipsis;
}

html[data-ui-style="galgame"] #galgameGameplayMode,
html[data-ui-style="galgame"] #galgameChoiceFrequency,
html[data-ui-style="galgame"] .style-dock .menu-row.row-configs select {
  flex: 0 0 116px;
  width: 116px;
  min-width: 88px;
  max-width: 116px;
  min-height: 30px;
  padding: 2px 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  color: #fff;
  background: #1a1c23;
  text-align: center;
  box-sizing: border-box;
}

@media (max-width: 720px) {
  html[data-ui-style="galgame"] .style-dock .menu-row.row-configs {
    grid-template-columns: 1fr;
  }

  html[data-ui-style="galgame"] .style-dock .menu-row.row-configs span {
    max-width: none;
  }
}

/* Apple-like VN cleanup: remove nested frames, keep only lightweight glass */
html[data-ui-style="galgame"] .chat {
  background: transparent;
  border: 0;
  padding-bottom: clamp(20px, 3.8vh, 42px);
}

html[data-ui-style="galgame"] .chat-shell {
  width: min(980px, calc(100vw - 64px));
  min-height: 168px;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  padding: 0;
}

html[data-ui-style="galgame"] .messages {
  padding: 0;
  gap: 8px;
  overflow: visible;
  background: transparent;
  border: 0;
  box-shadow: none;
}

html[data-ui-style="galgame"] .galgame-speaker {
  width: fit-content;
  max-width: min(760px, 100%);
  margin: 0 0 8px 0;
  padding: 5px 14px 6px 16px;
  border: 0;
  border-left: 3px solid color-mix(in srgb, var(--accent-2), white 20%);
  border-radius: 0;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--accent), transparent 70%), transparent 100%);
  box-shadow: none;
}

html[data-ui-style="galgame"] .galgame-speaker strong {
  font-size: 22px;
  font-weight: 760;
  letter-spacing: 0.01em;
}

html[data-ui-style="galgame"] .galgame-speaker span {
  font-size: 12px;
  letter-spacing: 0.08em;
}

html[data-ui-style="galgame"] .bubble {
  width: min(100%, 960px);
  min-height: 112px;
  padding: 21px 26px 22px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-top-color: rgba(255, 255, 255, 0.15);
  border-radius: 22px;
  background:
    linear-gradient(135deg, rgba(29, 34, 46, 0.5), rgba(20, 24, 33, 0.34)),
    rgba(8, 9, 14, 0.24);
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.16),
    0 16px 40px rgba(0, 0, 0, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  color: rgba(255, 250, 252, 0.98);
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.72);
  font-size: 21px;
  font-weight: 430;
  line-height: 1.68;
  letter-spacing: 0.01em;
  backdrop-filter: blur(16px) saturate(120%);
  -webkit-backdrop-filter: blur(16px) saturate(120%);
}

html[data-ui-style="galgame"] .bubble.user {
  width: min(100%, 760px);
  min-height: 86px;
  background:
    linear-gradient(135deg, rgba(122, 168, 255, 0.24), rgba(122, 168, 255, 0.09)),
    rgba(10, 16, 28, 0.2);
  border-color: rgba(122, 168, 255, 0.2);
  border-top-color: rgba(122, 168, 255, 0.35);
  box-shadow:
    0 8px 24px rgba(122, 168, 255, 0.12),
    0 16px 38px rgba(0, 0, 0, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  font-size: 19px;
}

html[data-ui-style="galgame"] .composer {
  width: min(720px, calc(100vw - 64px));
  margin: 10px auto 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

html[data-ui-style="galgame"] .composer textarea {
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(8, 8, 12, 0.44);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 8px 24px rgba(0, 0, 0, 0.16);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

html[data-ui-style="galgame"] .galgame-choice-layer .galgame-choices button {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-top-color: rgba(255, 255, 255, 0.16);
  background:
    linear-gradient(135deg, rgba(29, 34, 46, 0.46), rgba(20, 24, 33, 0.28)),
    rgba(8, 9, 14, 0.2);
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.16),
    0 16px 40px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  opacity: 0.88;
}

html[data-ui-style="galgame"] .galgame-choice-layer .galgame-choices button:hover,
html[data-ui-style="galgame"] .galgame-choice-layer .galgame-choices button:focus-visible,
html[data-ui-style="galgame"] .galgame-choice-layer .galgame-choices button[data-selected="true"] {
  background:
    linear-gradient(135deg, rgba(244, 92, 145, 0.2), rgba(244, 92, 145, 0.09)),
    rgba(10, 8, 14, 0.28);
  box-shadow:
    0 8px 24px color-mix(in srgb, var(--accent-2), transparent 80%),
    0 16px 40px rgba(0, 0, 0, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

@media (max-width: 900px) {
  html[data-ui-style="galgame"] .chat-shell,
  html[data-ui-style="galgame"] .composer {
    width: calc(100vw - 28px);
  }

  html[data-ui-style="galgame"] .bubble {
    min-height: 94px;
    padding: 18px 19px;
    font-size: 18px;
    line-height: 1.66;
  }
}

/* Global declutter: remove nested container frames in modal, forms, and rail */
#characterModal {
  padding: 0;
}

#characterModal .modal-body,
#characterModal .library-pane,
#characterModal .create-form {
  background: transparent;
  border: 0;
  box-shadow: none;
}

#characterModal .create-section {
  padding: 16px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

#characterModal .create-section:last-child {
  border-bottom: 0;
}

.rail .panel {
  border-color: rgba(255, 255, 255, 0.055);
  background: rgba(255, 255, 255, 0.02);
  box-shadow: none;
}

.rail .panel.compact,
.rail .quickstart-card,
.rail .self-name-panel {
  box-shadow: none;
}

/* Galgame final stable layer: one source of truth for menu, choices, and dialogue. */
html[data-ui-style="galgame"] {
  --vn-final-surface: rgba(12, 14, 22, 0.34);
  --vn-final-surface-strong: rgba(12, 14, 22, 0.58);
  --vn-final-line: rgba(255, 255, 255, 0.12);
  --vn-final-line-strong: rgba(255, 255, 255, 0.22);
  --vn-final-glow: color-mix(in srgb, var(--accent-2), transparent 70%);
}

html[data-ui-style="galgame"] .style-dock,
html[data-ui-style="galgame"] .style-dock:hover,
html[data-ui-style="galgame"] .style-dock:focus-within {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 80;
  box-sizing: border-box;
  transition:
    width 180ms ease,
    max-height 180ms ease,
    border-radius 180ms ease,
    background 180ms ease,
    box-shadow 180ms ease,
    transform 180ms ease,
    opacity 180ms ease;
}

html[data-ui-style="galgame"]:not([data-galgame-menu="open"]) .style-dock,
html[data-ui-style="galgame"]:not([data-galgame-menu="open"]) .style-dock:hover,
html[data-ui-style="galgame"]:not([data-galgame-menu="open"]) .style-dock:focus-within {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: 104px !important;
  min-width: 104px !important;
  max-width: 104px !important;
  height: 40px !important;
  min-height: 40px !important;
  max-height: 40px !important;
  overflow: hidden !important;
  padding: 0 14px !important;
  border: 1px solid rgba(255, 255, 255, 0.32) !important;
  border-radius: 999px !important;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.035)),
    rgba(12, 14, 22, 0.36) !important;
  box-shadow:
    0 10px 28px rgba(0, 0, 0, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.22) !important;
  opacity: 0.98 !important;
  cursor: pointer;
  pointer-events: auto;
  backdrop-filter: blur(14px) saturate(122%);
  -webkit-backdrop-filter: blur(14px) saturate(122%);
}

html[data-ui-style="galgame"]:not([data-galgame-menu="open"]) .style-dock:hover {
  border-color: color-mix(in srgb, var(--accent-2), white 22%) !important;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.16), rgba(244, 92, 145, 0.08)),
    rgba(12, 14, 22, 0.42) !important;
  box-shadow:
    0 0 18px color-mix(in srgb, var(--accent-2), transparent 62%),
    0 12px 30px rgba(0, 0, 0, 0.48),
    inset 0 1px 0 rgba(255, 255, 255, 0.26) !important;
  transform: translateY(-1px);
}

html[data-ui-style="galgame"]:not([data-galgame-menu="open"]) .style-dock > *,
html[data-ui-style="galgame"]:not([data-galgame-menu="open"]) .style-dock .galgame-bg-picker {
  position: absolute !important;
  opacity: 0 !important;
  pointer-events: none !important;
  transform: translateY(-4px) scale(0.98) !important;
}

html[data-ui-style="galgame"]:not([data-galgame-menu="open"]) .style-dock::before {
  content: "MENU" !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.98);
  font-family: "Cinzel", "Times New Roman", serif;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.16em;
  line-height: 1;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.78);
}

html[data-ui-style="galgame"]:not([data-galgame-menu="open"]) .style-dock::after {
  content: "";
  display: block;
  width: 7px;
  height: 7px;
  margin-left: 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent-2), white 14%);
  box-shadow: 0 0 12px color-mix(in srgb, var(--accent-2), transparent 18%);
}

html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock,
html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock:hover,
html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock:focus-within {
  display: grid !important;
  grid-template-columns: 1fr;
  gap: 10px;
  width: min(760px, calc(100vw - 32px)) !important;
  min-width: 0 !important;
  max-width: min(760px, calc(100vw - 32px)) !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: min(72dvh, 520px) !important;
  overflow: auto !important;
  padding: 12px !important;
  border: 1px solid rgba(255, 255, 255, 0.16) !important;
  border-top-color: rgba(255, 255, 255, 0.26) !important;
  border-radius: 22px !important;
  background:
    radial-gradient(circle at 18% 0%, rgba(255, 218, 232, 0.12), transparent 15rem),
    linear-gradient(135deg, rgba(20, 22, 31, 0.78), rgba(8, 9, 14, 0.68)) !important;
  box-shadow:
    0 26px 70px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.14) !important;
  opacity: 1 !important;
  cursor: default;
  backdrop-filter: blur(18px) saturate(124%);
  -webkit-backdrop-filter: blur(18px) saturate(124%);
}

html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock::before,
html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock::after {
  display: none !important;
}

html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock > *,
html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock .galgame-bg-picker {
  position: relative !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  transform: none !important;
}

html[data-ui-style="galgame"] .style-dock .menu-row {
  display: grid;
  width: 100%;
  min-width: 0;
  gap: 8px;
}

html[data-ui-style="galgame"] .style-dock .row-actions {
  grid-template-columns: repeat(8, minmax(58px, 1fr));
}

html[data-ui-style="galgame"] .style-dock .row-configs {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 10px !important;
}

html[data-ui-style="galgame"] .style-dock .row-thumbnails {
  grid-template-columns: 1fr;
}

html[data-ui-style="galgame"] .style-dock button,
html[data-ui-style="galgame"] .style-dock label {
  min-width: 0;
}

html[data-ui-style="galgame"] .style-dock .galgame-tool,
html[data-ui-style="galgame"] .style-dock .row-configs > label,
html[data-ui-style="galgame"] .style-dock .row-configs > button {
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  border-radius: 12px !important;
  background: rgba(255, 255, 255, 0.045) !important;
  color: rgba(255, 250, 252, 0.94) !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
}

html[data-ui-style="galgame"] .style-dock .galgame-tool:hover,
html[data-ui-style="galgame"] .style-dock .galgame-tool:focus-visible,
html[data-ui-style="galgame"] .style-dock .row-configs > label:focus-within,
html[data-ui-style="galgame"] .style-dock .row-configs > button:hover {
  border-color: color-mix(in srgb, var(--accent-2), white 18%) !important;
  background: color-mix(in srgb, var(--accent-2), transparent 84%) !important;
}

html[data-ui-style="galgame"] .style-dock .row-configs > label,
html[data-ui-style="galgame"] .style-dock .row-configs > .galgame-frequency-control,
html[data-ui-style="galgame"] .style-dock .row-configs > .galgame-mode-control {
  display: grid !important;
  grid-template-columns: minmax(72px, 1fr) minmax(112px, 132px);
  align-items: center;
  gap: 8px;
  padding: 6px 8px !important;
  white-space: nowrap;
}

html[data-ui-style="galgame"] .style-dock .row-configs span {
  max-width: none !important;
  overflow: hidden;
  color: rgba(255, 238, 246, 0.82);
  font-size: 12px;
  font-weight: 780;
  letter-spacing: 0.04em;
  text-overflow: ellipsis;
}

html[data-ui-style="galgame"] .style-dock select {
  width: 100% !important;
  min-width: 0 !important;
  max-width: none !important;
  min-height: 32px;
  border-radius: 9px;
  background: rgba(10, 12, 18, 0.84) !important;
  color: #fff !important;
  font-size: 13px;
}

html[data-ui-style="galgame"] .galgame-bg-picker {
  display: grid !important;
  grid-template-columns: repeat(6, minmax(42px, 1fr));
  gap: 8px;
  width: 100%;
  padding: 8px !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.035) !important;
  box-shadow: none !important;
}

html[data-ui-style="galgame"] .galgame-bg-choice {
  aspect-ratio: 16 / 9;
  min-height: 42px;
  border-radius: 10px;
}

html[data-ui-style="galgame"] .chat-shell {
  left: 50%;
  width: min(980px, calc(100vw - 64px)) !important;
  margin-inline: auto;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

html[data-ui-style="galgame"] .messages {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  overflow: visible !important;
}

html[data-ui-style="galgame"] .bubble {
  position: relative;
  width: min(100%, 960px) !important;
  min-height: 108px;
  border: 1px solid rgba(255, 255, 255, 0.075) !important;
  border-top-color: rgba(255, 255, 255, 0.18) !important;
  border-radius: 24px !important;
  background:
    linear-gradient(135deg, rgba(35, 39, 52, 0.48), rgba(14, 16, 24, 0.28)),
    rgba(6, 7, 12, 0.24) !important;
  box-shadow:
    0 10px 28px rgba(0, 0, 0, 0.18),
    0 24px 58px rgba(0, 0, 0, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.07) !important;
  color: rgba(255, 251, 253, 0.98);
  font-size: clamp(18px, 1.5vw, 22px) !important;
  line-height: 1.68 !important;
  letter-spacing: 0.01em;
  backdrop-filter: blur(17px) saturate(122%);
  -webkit-backdrop-filter: blur(17px) saturate(122%);
}

html[data-ui-style="galgame"] .bubble::before {
  content: "";
  position: absolute;
  inset: 1px 1px auto 1px;
  height: 42%;
  border-radius: 23px 23px 12px 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), transparent);
  pointer-events: none;
}

html[data-ui-style="galgame"] .bubble.user {
  width: min(100%, 760px) !important;
  min-height: 82px;
  background:
    linear-gradient(135deg, rgba(108, 160, 255, 0.22), rgba(108, 160, 255, 0.08)),
    rgba(8, 12, 22, 0.24) !important;
  border-color: rgba(122, 168, 255, 0.22) !important;
  border-top-color: rgba(168, 198, 255, 0.38) !important;
}

html[data-ui-style="galgame"] .galgame-choice-layer {
  position: fixed !important;
  left: 50% !important;
  top: 43% !important;
  z-index: 70 !important;
  width: min(600px, calc(100vw - 52px)) !important;
  transform: translate(-50%, -50%) !important;
  pointer-events: none;
}

html[data-ui-style="galgame"] .galgame-choice-layer[hidden] {
  display: none !important;
}

html[data-ui-style="galgame"] .galgame-choice-layer .galgame-choices {
  display: grid !important;
  gap: 12px !important;
  width: 100%;
  max-height: min(54dvh, 450px);
  overflow: auto;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  pointer-events: auto;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

html[data-ui-style="galgame"] .galgame-choice-layer .galgame-choices::before {
  display: none !important;
}

html[data-ui-style="galgame"] .galgame-choice-layer .galgame-choices button {
  min-height: 72px;
  padding: 14px 18px !important;
  border: 1px solid rgba(255, 255, 255, 0.105) !important;
  border-top-color: rgba(255, 255, 255, 0.22) !important;
  border-radius: 19px !important;
  background:
    linear-gradient(135deg, rgba(35, 39, 52, 0.4), rgba(14, 16, 24, 0.2)),
    rgba(8, 9, 14, 0.18) !important;
  box-shadow:
    0 12px 34px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.08) !important;
  opacity: 0.9;
  backdrop-filter: blur(14px) saturate(118%);
  -webkit-backdrop-filter: blur(14px) saturate(118%);
}

html[data-ui-style="galgame"] .galgame-choice-layer .galgame-choices button:hover,
html[data-ui-style="galgame"] .galgame-choice-layer .galgame-choices button:focus-visible,
html[data-ui-style="galgame"] .galgame-choice-layer .galgame-choices button[data-selected="true"] {
  border-color: color-mix(in srgb, var(--accent-2), white 22%) !important;
  background:
    radial-gradient(circle at 28% 40%, color-mix(in srgb, var(--accent-2), transparent 78%), transparent 12rem),
    linear-gradient(135deg, rgba(255, 255, 255, 0.09), rgba(244, 92, 145, 0.08)),
    rgba(10, 8, 14, 0.24) !important;
  box-shadow:
    0 0 22px color-mix(in srgb, var(--accent-2), transparent 70%),
    0 16px 42px rgba(0, 0, 0, 0.26),
    inset 0 1px 0 rgba(255, 255, 255, 0.1) !important;
  opacity: 1;
  transform: translateY(-1px);
}

html[data-ui-style="galgame"] .messages > .galgame-choices {
  display: none !important;
}

@media (max-width: 860px) {
  html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock {
    right: 10px;
    width: min(560px, calc(100vw - 20px)) !important;
    max-width: min(560px, calc(100vw - 20px)) !important;
  }

  html[data-ui-style="galgame"] .style-dock .row-actions {
    grid-template-columns: repeat(4, minmax(60px, 1fr));
  }

  html[data-ui-style="galgame"] .galgame-bg-picker {
    grid-template-columns: repeat(4, minmax(44px, 1fr));
  }
}

@media (max-width: 560px) {
  html[data-ui-style="galgame"] .style-dock {
    top: 10px;
    right: 10px;
  }

  html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock {
    padding: 10px !important;
  }

  html[data-ui-style="galgame"] .style-dock .row-actions,
  html[data-ui-style="galgame"] .style-dock .row-configs {
    grid-template-columns: 1fr 1fr !important;
  }

  html[data-ui-style="galgame"] .style-dock .row-configs > label,
  html[data-ui-style="galgame"] .style-dock .row-configs > .galgame-frequency-control,
  html[data-ui-style="galgame"] .style-dock .row-configs > .galgame-mode-control {
    grid-column: 1 / -1;
    grid-template-columns: minmax(72px, 1fr) minmax(116px, 46%);
  }

  html[data-ui-style="galgame"] .chat-shell,
  html[data-ui-style="galgame"] .composer {
    width: calc(100vw - 24px) !important;
  }

  html[data-ui-style="galgame"] .bubble {
    min-height: 90px;
    padding: 17px 18px !important;
  }

  html[data-ui-style="galgame"] .galgame-choice-layer {
    top: 42% !important;
    width: min(520px, calc(100vw - 24px)) !important;
  }

  html[data-ui-style="galgame"] .galgame-choice-layer .galgame-choices button {
    min-height: 64px;
  }
}

/* Galgame viewport lock: prevent the normal multi-column layout from pushing the VN dialogue off-screen. */
html[data-ui-style="galgame"],
html[data-ui-style="galgame"] body {
  width: 100%;
  max-width: 100%;
  height: 100%;
  overflow: hidden !important;
  overscroll-behavior: none;
}

html[data-ui-style="galgame"] #app,
html[data-ui-style="galgame"] .app-shell {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  max-width: 100vw !important;
  height: 100dvh !important;
  min-height: 100dvh !important;
  overflow: hidden !important;
}

html[data-ui-style="galgame"] .chat {
  position: fixed !important;
  inset: 0 !important;
  z-index: 35 !important;
  display: block !important;
  width: 100vw !important;
  max-width: 100vw !important;
  height: 100dvh !important;
  min-height: 100dvh !important;
  padding: 0 !important;
  overflow: visible !important;
  pointer-events: none;
}

html[data-ui-style="galgame"] .chat-shell {
  position: fixed !important;
  left: 50% !important;
  right: auto !important;
  bottom: clamp(18px, 3vh, 34px) !important;
  top: auto !important;
  z-index: 42 !important;
  display: flex !important;
  flex-direction: column;
  width: min(980px, calc(100vw - 64px)) !important;
  max-width: calc(100vw - 64px) !important;
  min-height: 0 !important;
  margin: 0 !important;
  transform: translateX(-50%) !important;
  pointer-events: auto;
}

html[data-ui-style="galgame"] .composer {
  width: min(720px, 100%) !important;
  max-width: 100% !important;
  margin: 10px auto 0 !important;
}

html[data-ui-style="galgame"] .stage {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  max-width: 100vw !important;
  height: 100dvh !important;
  overflow: hidden !important;
  pointer-events: none;
}

html[data-ui-style="galgame"] .pet-actor,
html[data-ui-style="galgame"] .live2d-stage {
  max-width: min(46vw, 620px) !important;
}

@media (max-width: 700px) {
  html[data-ui-style="galgame"] .chat-shell {
    bottom: 12px !important;
    width: calc(100vw - 24px) !important;
    max-width: calc(100vw - 24px) !important;
  }
}

/* Galgame menu v2: flatten nested boxes and keep one visual container only. */
html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock,
html[data-ui-style="galgame"] .style-dock:hover,
html[data-ui-style="galgame"] .style-dock:focus-within {
  gap: 12px !important;
  width: min(600px, calc(100vw - 20px)) !important;
  padding: 12px !important;
  background:
    radial-gradient(circle at 18% 0%, rgba(255, 202, 185, 0.16), transparent 30%),
    linear-gradient(180deg, rgba(19, 20, 29, 0.9), rgba(11, 12, 18, 0.82)) !important;
}

html[data-ui-style="galgame"] .style-dock .menu-row::before {
  color: rgba(255, 230, 218, 0.5) !important;
  font-size: 9px !important;
  letter-spacing: 0.18em !important;
}

html[data-ui-style="galgame"] .style-dock .row-actions {
  grid-template-columns: repeat(8, minmax(0, 1fr)) !important;
}

html[data-ui-style="galgame"] .style-dock .row-configs {
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  padding-top: 0 !important;
  border-top: 0 !important;
}

html[data-ui-style="galgame"] .style-dock .row-thumbnails {
  display: grid !important;
  gap: 8px !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

html[data-ui-style="galgame"] .style-dock .row-thumbnails::before {
  margin: 0 !important;
}

html[data-ui-style="galgame"] .style-dock span,
html[data-ui-style="galgame"] .style-dock button {
  background: rgba(255, 255, 255, 0.045) !important;
  border-color: rgba(255, 255, 255, 0.11) !important;
  box-shadow: none !important;
}

html[data-ui-style="galgame"] .style-dock .galgame-mode-control,
html[data-ui-style="galgame"] .style-dock .galgame-frequency-control {
  background: transparent !important;
  border: 0 !important;
  padding: 0 !important;
}

html[data-ui-style="galgame"] .style-dock .galgame-mode-control > span,
html[data-ui-style="galgame"] .style-dock .galgame-frequency-control > span {
  color: rgba(255, 230, 218, 0.48) !important;
}

html[data-ui-style="galgame"] .galgame-bg-picker {
  display: grid !important;
  grid-template-columns: repeat(6, minmax(64px, 1fr)) !important;
  gap: 8px !important;
  padding: 0 !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

html[data-ui-style="galgame"] .galgame-bg-picker::before,
html[data-ui-style="galgame"] .galgame-user-bg-choices::before {
  display: none !important;
  content: none !important;
}

html[data-ui-style="galgame"] .galgame-bg-choice,
html[data-ui-style="galgame"] .galgame-bg-upload span {
  min-height: 42px !important;
  border-radius: 9px !important;
  border-color: rgba(255, 255, 255, 0.16) !important;
  box-shadow: none !important;
}

html[data-ui-style="galgame"] .galgame-bg-choice[data-active="true"] {
  border-color: rgba(255, 226, 216, 0.92) !important;
  box-shadow:
    0 0 0 1px rgba(255, 191, 174, 0.42),
    0 8px 20px rgba(255, 165, 136, 0.16) !important;
}

@media (max-width: 700px) {
  html[data-ui-style="galgame"] .galgame-bg-picker {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
}

/* Galgame final cascade guard: keep the menu flat after older polish rules. */
html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock,
html[data-ui-style="galgame"] .style-dock:hover,
html[data-ui-style="galgame"] .style-dock:focus-within {
  width: min(600px, calc(100vw - 20px)) !important;
  gap: 12px !important;
  padding: 12px !important;
  background:
    radial-gradient(circle at 18% 0%, rgba(255, 202, 185, 0.15), transparent 30%),
    linear-gradient(180deg, rgba(18, 19, 28, 0.9), rgba(9, 10, 16, 0.8)) !important;
  border-color: rgba(255, 255, 255, 0.16) !important;
  box-shadow:
    0 24px 58px rgba(0, 0, 0, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.13) !important;
}

html[data-ui-style="galgame"] .style-dock .menu-row,
html[data-ui-style="galgame"] .style-dock .row-thumbnails,
html[data-ui-style="galgame"] .galgame-bg-picker {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

html[data-ui-style="galgame"] .style-dock .row-thumbnails {
  display: grid !important;
  gap: 8px !important;
  padding: 0 !important;
  border-radius: 0 !important;
}

html[data-ui-style="galgame"] .style-dock .row-configs {
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  padding-top: 0 !important;
  border-top: 0 !important;
}

html[data-ui-style="galgame"] .style-dock .galgame-mode-control,
html[data-ui-style="galgame"] .style-dock .galgame-frequency-control {
  grid-column: span 2 !important;
  padding: 0 !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

html[data-ui-style="galgame"] .style-dock .row-thumbnails::before,
html[data-ui-style="galgame"] .galgame-bg-picker::before,
html[data-ui-style="galgame"] .galgame-user-bg-choices::before {
  display: none !important;
  content: none !important;
}

html[data-ui-style="galgame"] .galgame-bg-choice,
html[data-ui-style="galgame"] .galgame-bg-upload span,
html[data-ui-style="galgame"] .style-dock button,
html[data-ui-style="galgame"] .style-dock label > span {
  background: rgba(255, 255, 255, 0.045) !important;
  border-color: rgba(255, 255, 255, 0.12) !important;
  box-shadow: none !important;
}

html[data-ui-style="galgame"] .galgame-bg-choice {
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.02), rgba(0, 0, 0, 0.36)),
    var(--bg-thumb) center / cover no-repeat !important;
}

html[data-ui-style="galgame"] .galgame-bg-picker {
  grid-template-columns: repeat(6, minmax(64px, 1fr)) !important;
  gap: 8px !important;
  padding: 0 !important;
}

@media (max-width: 700px) {
  html[data-ui-style="galgame"] .style-dock .row-configs {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  html[data-ui-style="galgame"] .galgame-bg-picker {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
}

/* Galgame dock de-boxing: remove nested card borders and keep only active cues. */
html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock,
html[data-ui-style="galgame"] .style-dock:hover,
html[data-ui-style="galgame"] .style-dock:focus-within {
  padding: 14px 16px 16px !important;
  gap: 14px !important;
  background:
    radial-gradient(circle at 12% -8%, rgba(255, 214, 196, 0.16), transparent 34%),
    linear-gradient(135deg, rgba(34, 41, 50, 0.84), rgba(12, 15, 22, 0.78)) !important;
}

html[data-ui-style="galgame"] .style-dock .row-actions {
  gap: 7px !important;
}

html[data-ui-style="galgame"] .style-dock .row-actions > button {
  min-height: 31px !important;
  padding: 0 10px !important;
  background: transparent !important;
  border: 0 !important;
  border-radius: 999px !important;
  color: rgba(255, 245, 240, 0.78) !important;
  box-shadow: none !important;
}

html[data-ui-style="galgame"] .style-dock .row-actions > button:hover,
html[data-ui-style="galgame"] .style-dock .row-actions > button[aria-pressed="true"],
html[data-ui-style="galgame"] .style-dock .row-actions > button[data-active="true"] {
  color: #fff !important;
  background: rgba(255, 255, 255, 0.1) !important;
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.18) !important;
}

html[data-ui-style="galgame"] .style-dock .row-configs {
  gap: 16px !important;
  align-items: end !important;
}

html[data-ui-style="galgame"] .style-dock .galgame-mode-control,
html[data-ui-style="galgame"] .style-dock .galgame-frequency-control {
  display: grid !important;
  grid-template-columns: auto 1fr !important;
  gap: 10px !important;
  min-height: 34px !important;
  padding: 0 0 7px !important;
  border: 0 !important;
  border-radius: 0 !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16) !important;
  background: transparent !important;
  box-shadow: none !important;
}

html[data-ui-style="galgame"] .style-dock .galgame-mode-control > span,
html[data-ui-style="galgame"] .style-dock .galgame-frequency-control > span {
  min-height: auto !important;
  padding: 0 !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

html[data-ui-style="galgame"] .style-dock .galgame-mode-control select,
html[data-ui-style="galgame"] .style-dock .galgame-frequency-control select {
  min-height: 28px !important;
  padding: 0 24px 0 8px !important;
  border: 0 !important;
  border-radius: 8px !important;
  background: rgba(0, 0, 0, 0.2) !important;
  box-shadow: none !important;
}

html[data-ui-style="galgame"] .style-dock .row-configs > button {
  min-height: 34px !important;
  border: 0 !important;
  border-radius: 999px !important;
  background: transparent !important;
  box-shadow: none !important;
  color: rgba(255, 245, 240, 0.76) !important;
}

html[data-ui-style="galgame"] .style-dock .row-configs > button:hover,
html[data-ui-style="galgame"] .style-dock .row-configs > button[aria-pressed="true"],
html[data-ui-style="galgame"] .style-dock .row-configs > button[data-active="true"] {
  color: #2a1714 !important;
  background: linear-gradient(135deg, #ffe3d8, #ffc3ad) !important;
  box-shadow: 0 8px 22px rgba(255, 177, 145, 0.2) !important;
}

html[data-ui-style="galgame"] .style-dock .row-thumbnails {
  margin-top: 2px !important;
  gap: 10px !important;
}

html[data-ui-style="galgame"] .galgame-bg-picker {
  grid-template-columns: repeat(6, minmax(74px, 1fr)) !important;
  gap: 10px 12px !important;
}

html[data-ui-style="galgame"] .galgame-bg-choice,
html[data-ui-style="galgame"] .galgame-bg-upload span {
  min-height: 54px !important;
  border: 0 !important;
  border-radius: 10px !important;
  box-shadow: none !important;
  overflow: hidden !important;
}

html[data-ui-style="galgame"] .galgame-bg-choice {
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.38)),
    var(--bg-thumb) center / cover no-repeat !important;
}

html[data-ui-style="galgame"] .galgame-bg-choice[data-active="true"] {
  outline: 2px solid rgba(255, 224, 214, 0.9) !important;
  outline-offset: 2px !important;
  box-shadow: 0 10px 26px rgba(255, 188, 160, 0.2) !important;
}

html[data-ui-style="galgame"] .galgame-bg-upload span {
  color: rgba(255, 245, 240, 0.72) !important;
  background: rgba(255, 255, 255, 0.055) !important;
  outline: 1px dashed rgba(255, 255, 255, 0.18) !important;
  outline-offset: -1px !important;
}

/* Galgame final cascade guard: keep the menu flat after older polish rules. */
html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock,
html[data-ui-style="galgame"] .style-dock:hover,
html[data-ui-style="galgame"] .style-dock:focus-within {
  width: min(600px, calc(100vw - 20px)) !important;
  gap: 12px !important;
  padding: 12px !important;
  background:
    radial-gradient(circle at 18% 0%, rgba(255, 202, 185, 0.15), transparent 30%),
    linear-gradient(180deg, rgba(18, 19, 28, 0.9), rgba(9, 10, 16, 0.8)) !important;
  border-color: rgba(255, 255, 255, 0.16) !important;
  box-shadow:
    0 24px 58px rgba(0, 0, 0, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.13) !important;
}

html[data-ui-style="galgame"] .style-dock .menu-row,
html[data-ui-style="galgame"] .style-dock .row-thumbnails,
html[data-ui-style="galgame"] .galgame-bg-picker {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

html[data-ui-style="galgame"] .style-dock .row-thumbnails {
  display: grid !important;
  gap: 8px !important;
  padding: 0 !important;
  border-radius: 0 !important;
}

html[data-ui-style="galgame"] .style-dock .row-configs {
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  padding-top: 0 !important;
  border-top: 0 !important;
}

html[data-ui-style="galgame"] .style-dock .galgame-mode-control,
html[data-ui-style="galgame"] .style-dock .galgame-frequency-control {
  grid-column: span 2 !important;
  padding: 0 !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

html[data-ui-style="galgame"] .style-dock .row-thumbnails::before,
html[data-ui-style="galgame"] .galgame-bg-picker::before,
html[data-ui-style="galgame"] .galgame-user-bg-choices::before {
  display: none !important;
  content: none !important;
}

html[data-ui-style="galgame"] .galgame-bg-choice,
html[data-ui-style="galgame"] .galgame-bg-upload span,
html[data-ui-style="galgame"] .style-dock button,
html[data-ui-style="galgame"] .style-dock label > span {
  background: rgba(255, 255, 255, 0.045) !important;
  border-color: rgba(255, 255, 255, 0.12) !important;
  box-shadow: none !important;
}

html[data-ui-style="galgame"] .galgame-bg-choice {
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.02), rgba(0, 0, 0, 0.36)),
    var(--bg-thumb) center / cover no-repeat !important;
}

html[data-ui-style="galgame"] .galgame-bg-picker {
  grid-template-columns: repeat(6, minmax(64px, 1fr)) !important;
  gap: 8px !important;
  padding: 0 !important;
}

@media (max-width: 700px) {
  html[data-ui-style="galgame"] .style-dock .row-configs {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  html[data-ui-style="galgame"] .galgame-bg-picker {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
}

/* Galgame final pass: one glass menu, no nested boxed sections. */
html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock,
html[data-ui-style="galgame"] .style-dock:hover,
html[data-ui-style="galgame"] .style-dock:focus-within {
  width: min(600px, calc(100vw - 20px)) !important;
  gap: 12px !important;
  padding: 12px !important;
  background:
    radial-gradient(circle at 18% 0%, rgba(255, 202, 185, 0.15), transparent 30%),
    linear-gradient(180deg, rgba(18, 19, 28, 0.9), rgba(9, 10, 16, 0.8)) !important;
  border-color: rgba(255, 255, 255, 0.16) !important;
  box-shadow:
    0 24px 58px rgba(0, 0, 0, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.13) !important;
}

html[data-ui-style="galgame"] .style-dock .menu-row,
html[data-ui-style="galgame"] .style-dock .row-thumbnails,
html[data-ui-style="galgame"] .galgame-bg-picker {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

html[data-ui-style="galgame"] .style-dock .row-thumbnails {
  display: grid !important;
  gap: 8px !important;
  padding: 0 !important;
  border-radius: 0 !important;
}

html[data-ui-style="galgame"] .style-dock .row-configs {
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  padding-top: 0 !important;
  border-top: 0 !important;
}

html[data-ui-style="galgame"] .style-dock .galgame-mode-control,
html[data-ui-style="galgame"] .style-dock .galgame-frequency-control {
  grid-column: span 2 !important;
  padding: 0 !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

html[data-ui-style="galgame"] .style-dock .galgame-mode-control > span,
html[data-ui-style="galgame"] .style-dock .galgame-frequency-control > span {
  color: rgba(255, 232, 224, 0.52) !important;
}

html[data-ui-style="galgame"] .galgame-bg-picker {
  grid-template-columns: repeat(6, minmax(64px, 1fr)) !important;
  gap: 8px !important;
  padding: 0 !important;
}

html[data-ui-style="galgame"] .style-dock .row-thumbnails::before,
html[data-ui-style="galgame"] .galgame-bg-picker::before,
html[data-ui-style="galgame"] .galgame-user-bg-choices::before {
  display: none !important;
  content: none !important;
}

html[data-ui-style="galgame"] .galgame-bg-choice,
html[data-ui-style="galgame"] .galgame-bg-upload span,
html[data-ui-style="galgame"] .style-dock button,
html[data-ui-style="galgame"] .style-dock label > span {
  background: rgba(255, 255, 255, 0.045) !important;
  border-color: rgba(255, 255, 255, 0.12) !important;
  box-shadow: none !important;
}

html[data-ui-style="galgame"] .galgame-bg-choice {
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.02), rgba(0, 0, 0, 0.36)),
    var(--bg-thumb) center / cover no-repeat !important;
}

@media (max-width: 700px) {
  html[data-ui-style="galgame"] .style-dock .row-configs {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  html[data-ui-style="galgame"] .galgame-bg-picker {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
}

/*
  Galgame menu polish: compact VN command panel with clear sections.
*/
html[data-ui-style="galgame"] .style-dock {
  --dock-line: rgba(255, 255, 255, 0.13);
  --dock-text: rgba(255, 250, 246, 0.92);
  --dock-muted: rgba(255, 236, 224, 0.58);
  top: 10px !important;
  right: 10px !important;
  width: 86px !important;
  max-height: 42px !important;
  padding: 5px !important;
  border-radius: 999px !important;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.02)),
    rgba(12, 13, 20, 0.58) !important;
  border: 1px solid rgba(255, 255, 255, 0.22) !important;
  box-shadow:
    0 12px 34px rgba(0, 0, 0, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.22) !important;
  backdrop-filter: blur(18px) saturate(132%) !important;
  -webkit-backdrop-filter: blur(18px) saturate(132%) !important;
}

html[data-ui-style="galgame"] .style-dock::before {
  content: "菜单" !important;
  width: 74px !important;
  min-height: 30px !important;
  color: #fff !important;
  letter-spacing: 0.14em;
  font-size: 12px !important;
  font-weight: 900 !important;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.72) !important;
}

html[data-ui-style="galgame"] .style-dock:hover,
html[data-ui-style="galgame"] .style-dock:focus-within,
html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock {
  display: grid !important;
  grid-template-columns: 1fr !important;
  gap: 9px !important;
  width: min(620px, calc(100vw - 20px)) !important;
  max-height: min(76vh, 520px) !important;
  overflow: auto !important;
  padding: 10px !important;
  border-radius: 20px !important;
  background:
    radial-gradient(circle at 12% 0%, rgba(255, 208, 191, 0.18), transparent 32%),
    radial-gradient(circle at 88% 100%, rgba(122, 168, 255, 0.12), transparent 34%),
    linear-gradient(180deg, rgba(27, 27, 38, 0.88), rgba(10, 12, 19, 0.78)) !important;
  border-color: rgba(255, 255, 255, 0.18) !important;
  box-shadow:
    0 24px 58px rgba(0, 0, 0, 0.48),
    inset 0 1px 0 rgba(255, 255, 255, 0.16) !important;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 208, 191, 0.45) transparent;
}

html[data-ui-style="galgame"] .style-dock::-webkit-scrollbar {
  width: 7px;
}

html[data-ui-style="galgame"] .style-dock::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(255, 208, 191, 0.36);
}

html[data-ui-style="galgame"] .style-dock:hover::before,
html[data-ui-style="galgame"] .style-dock:focus-within::before,
html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock::before {
  display: none !important;
}

html[data-ui-style="galgame"] .style-dock .menu-row {
  display: grid !important;
  gap: 8px !important;
  width: 100% !important;
  padding: 0 !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

html[data-ui-style="galgame"] .style-dock .menu-row::before {
  grid-column: 1 / -1;
  color: var(--dock-muted);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

html[data-ui-style="galgame"] .style-dock .row-actions {
  grid-template-columns: repeat(8, minmax(0, 1fr)) !important;
}

html[data-ui-style="galgame"] .style-dock .row-actions::before {
  content: "COMMAND";
}

html[data-ui-style="galgame"] .style-dock .row-configs {
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  padding-top: 8px !important;
  border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
}

html[data-ui-style="galgame"] .style-dock .row-configs::before {
  content: "PLAY / VIEW";
}

html[data-ui-style="galgame"] .style-dock .row-thumbnails {
  display: block !important;
  padding: 10px 8px 8px !important;
  border-radius: 16px !important;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)),
    rgba(255, 255, 255, 0.035) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
}

html[data-ui-style="galgame"] .style-dock .row-thumbnails::before {
  content: "SCENE";
  display: block;
  margin: 0 0 8px;
}

html[data-ui-style="galgame"] .style-dock span,
html[data-ui-style="galgame"] .style-dock button,
html[data-ui-style="galgame"] .style-dock select {
  min-width: 0 !important;
  min-height: 36px !important;
  border-radius: 11px !important;
  color: var(--dock-text) !important;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.025)),
    rgba(255, 255, 255, 0.045) !important;
  border: 1px solid var(--dock-line) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08) !important;
  text-shadow: none !important;
}

html[data-ui-style="galgame"] .style-dock span,
html[data-ui-style="galgame"] .style-dock button {
  padding: 0 9px !important;
  font-size: 11px !important;
  line-height: 1.15 !important;
  white-space: nowrap !important;
}

html[data-ui-style="galgame"] .style-dock button:hover,
html[data-ui-style="galgame"] .style-dock span:hover,
html[data-ui-style="galgame"] .style-dock select:hover {
  color: #fff !important;
  border-color: rgba(255, 208, 191, 0.42) !important;
  background:
    linear-gradient(180deg, rgba(255, 208, 191, 0.17), rgba(255, 255, 255, 0.04)),
    rgba(255, 255, 255, 0.07) !important;
  transform: translateY(-1px);
}

html[data-ui-style="galgame"] .style-dock input:checked + span,
html[data-ui-style="galgame"] .style-dock > button[data-active="true"],
html[data-ui-style="galgame"] .style-dock .menu-row > button[data-active="true"] {
  color: #2c1614 !important;
  background:
    linear-gradient(135deg, #ffe2d8, #ffbfae 58%, #ffd9ae) !important;
  border-color: rgba(255, 238, 224, 0.82) !important;
  box-shadow:
    0 8px 18px rgba(255, 165, 136, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.72) !important;
}

html[data-ui-style="galgame"] .style-dock .galgame-mode-control,
html[data-ui-style="galgame"] .style-dock .galgame-frequency-control {
  display: grid !important;
  grid-template-columns: auto minmax(112px, 1fr) !important;
  align-items: center !important;
  gap: 8px !important;
  grid-column: span 2 !important;
  min-height: 38px !important;
  padding: 4px 6px 4px 10px !important;
  border-radius: 12px !important;
  background: rgba(255, 255, 255, 0.045) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

html[data-ui-style="galgame"] .style-dock .galgame-mode-control > span,
html[data-ui-style="galgame"] .style-dock .galgame-frequency-control > span {
  display: block !important;
  min-height: auto !important;
  padding: 0 !important;
  color: var(--dock-muted) !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  font-size: 11px !important;
}

html[data-ui-style="galgame"] .style-dock .galgame-mode-control select,
html[data-ui-style="galgame"] .style-dock .galgame-frequency-control select {
  width: 100% !important;
  min-height: 30px !important;
  padding: 0 28px 0 10px !important;
  border-radius: 9px !important;
  color: #fff !important;
  background-color: rgba(5, 7, 12, 0.52) !important;
  font-size: 12px !important;
  font-weight: 800 !important;
}

html[data-ui-style="galgame"] .style-dock .style-switch {
  display: contents !important;
}

html[data-ui-style="galgame"] .style-dock .style-switch label span {
  min-height: 36px !important;
}

html[data-ui-style="galgame"] .galgame-bg-picker {
  display: grid !important;
  grid-template-columns: repeat(5, minmax(78px, 1fr)) !important;
  gap: 8px !important;
  width: 100% !important;
}

html[data-ui-style="galgame"] .galgame-bg-choice,
html[data-ui-style="galgame"] .galgame-bg-upload span {
  min-height: 44px !important;
  border-radius: 10px !important;
}

html[data-ui-style="galgame"] .galgame-bg-choice {
  color: #fff !important;
  border-color: rgba(255, 255, 255, 0.24) !important;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.06), rgba(0, 0, 0, 0.46)),
    var(--bg-thumb) center / cover no-repeat !important;
  box-shadow:
    0 8px 16px rgba(0, 0, 0, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.2) !important;
}

html[data-ui-style="galgame"] .galgame-bg-choice:hover {
  transform: translateY(-2px) !important;
  border-color: rgba(255, 208, 191, 0.72) !important;
  box-shadow:
    0 12px 22px rgba(0, 0, 0, 0.28),
    0 0 0 1px rgba(255, 208, 191, 0.14) !important;
}

html[data-ui-style="galgame"] .galgame-bg-choice[data-active="true"] {
  border-color: rgba(255, 226, 216, 0.96) !important;
  box-shadow:
    0 0 0 2px rgba(255, 191, 174, 0.46),
    0 12px 26px rgba(255, 165, 136, 0.18) !important;
}

html[data-ui-style="galgame"] .galgame-bg-upload span {
  color: rgba(255, 245, 240, 0.78) !important;
  background: rgba(255, 255, 255, 0.035) !important;
  border-color: rgba(255, 255, 255, 0.18) !important;
}

@media (max-width: 700px) {
  html[data-ui-style="galgame"] .style-dock:hover,
  html[data-ui-style="galgame"] .style-dock:focus-within,
  html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock {
    left: 10px !important;
    right: 10px !important;
    width: auto !important;
  }

  html[data-ui-style="galgame"] .style-dock .row-actions {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  }

  html[data-ui-style="galgame"] .style-dock .row-configs {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  html[data-ui-style="galgame"] .galgame-bg-picker {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
}

/* Galgame final cascade guard: keep the menu flat after older polish rules. */
html[data-ui-style="galgame"][data-galgame-menu="open"] .style-dock,
html[data-ui-style="galgame"] .style-dock:hover,
html[data-ui-style="galgame"] .style-dock:focus-within {
  width: min(600px, calc(100vw - 20px)) !important;
  gap: 12px !important;
  padding: 12px !important;
  background:
    radial-gradient(circle at 18% 0%, rgba(255, 202, 185, 0.15), transparent 30%),
    linear-gradient(180deg, rgba(18, 19, 28, 0.9), rgba(9, 10, 16, 0.8)) !important;
  border-color: rgba(255, 255, 255, 0.16) !important;
  box-shadow:
    0 24px 58px rgba(0, 0, 0, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.13) !important;
}

html[data-ui-style="galgame"] .style-dock .menu-row,
html[data-ui-style="galgame"] .style-dock .row-thumbnails,
html[data-ui-style="galgame"] .galgame-bg-picker {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

html[data-ui-style="galgame"] .style-dock .row-thumbnails {
  display: grid !important;
  gap: 8px !important;
  padding: 0 !important;
  border-radius: 0 !important;
}

html[data-ui-style="galgame"] .style-dock .row-configs {
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  padding-top: 0 !important;
  border-top: 0 !important;
}

html[data-ui-style="galgame"] .style-dock .galgame-mode-control,
html[data-ui-style="galgame"] .style-dock .galgame-frequency-control {
  grid-column: span 2 !important;
  padding: 0 !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

html[data-ui-style="galgame"] .style-dock .row-thumbnails::before,
html[data-ui-style="galgame"] .galgame-bg-picker::before,
html[data-ui-style="galgame"] .galgame-user-bg-choices::before {
  display: none !important;
  content: none !important;
}

html[data-ui-style="galgame"] .galgame-bg-choice,
html[data-ui-style="galgame"] .galgame-bg-upload span,
html[data-ui-style="galgame"] .style-dock button,
html[data-ui-style="galgame"] .style-dock label > span {
  background: rgba(255, 255, 255, 0.045) !important;
  border-color: rgba(255, 255, 255, 0.12) !important;
  box-shadow: none !important;
}

html[data-ui-style="galgame"] .galgame-bg-choice {
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.02), rgba(0, 0, 0, 0.36)),
    var(--bg-thumb) center / cover no-repeat !important;
}

html[data-ui-style="galgame"] .galgame-bg-picker {
  grid-template-columns: repeat(6, minmax(64px, 1fr)) !important;
  gap: 8px !important;
  padding: 0 !important;
}

@media (max-width: 700px) {
  html[data-ui-style="galgame"] .style-dock .row-configs {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  html[data-ui-style="galgame"] .galgame-bg-picker {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
}

/* =========================================
   Galgame UI Menu Button Optimization (V2)
   Target: all Galgame dock text buttons
   ========================================= */

html[data-ui-style="galgame"] .style-dock .row-actions,
html[data-ui-style="galgame"] .style-dock .row-configs {
  align-items: center !important;
}

html[data-ui-style="galgame"] .style-dock > label:has(> input[name="uiStyle"]),
html[data-ui-style="galgame"] .style-dock .row-configs > label:has(> input[name="uiStyle"]) {
  display: flex !important;
  align-items: stretch !important;
  justify-content: stretch !important;
  width: 100% !important;
  min-height: 44px !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

html[data-ui-style="galgame"] .style-dock .row-actions > button,
html[data-ui-style="galgame"] .style-dock .row-configs > button,
html[data-ui-style="galgame"] .style-dock .row-configs > button#galgameBranchEdit,
html[data-ui-style="galgame"] .style-dock > label > input[name="uiStyle"] + span,
html[data-ui-style="galgame"] .style-dock .row-configs > label > input[name="uiStyle"] + span {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 100% !important;
  height: 100% !important;
  min-height: 44px !important;
  padding: 0 14px !important;
  border: 1px solid rgba(255, 255, 255, 0.18) !important;
  border-radius: 12px !important;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.01) 45%, rgba(0, 0, 0, 0.2) 100%),
    rgba(20, 16, 24, 0.4) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1) !important;
  color: rgba(255, 250, 252, 0.9) !important;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6) !important;
  font-size: 13.5px !important;
  font-weight: 700 !important;
  letter-spacing: 0 !important;
  box-sizing: border-box !important;
  transition-property: background, border-color, box-shadow, color, transform !important;
  transition-duration: 0.2s !important;
  transition-timing-function: cubic-bezier(0.16, 1, 0.3, 1) !important;
}

html[data-ui-style="galgame"] .style-dock .row-actions > button:hover,
html[data-ui-style="galgame"] .style-dock .row-actions > button:focus-visible,
html[data-ui-style="galgame"] .style-dock .row-configs > button:hover,
html[data-ui-style="galgame"] .style-dock .row-configs > button:focus-visible,
html[data-ui-style="galgame"] .style-dock .row-configs > button#galgameBranchEdit:hover,
html[data-ui-style="galgame"] .style-dock .row-configs > button#galgameBranchEdit:focus-visible,
html[data-ui-style="galgame"] .style-dock > label:hover > input[name="uiStyle"] + span,
html[data-ui-style="galgame"] .style-dock .row-configs > label:hover > input[name="uiStyle"] + span,
html[data-ui-style="galgame"] .style-dock > label > input[name="uiStyle"]:focus-visible + span,
html[data-ui-style="galgame"] .style-dock .row-configs > label > input[name="uiStyle"]:focus-visible + span {
  border-color: rgba(255, 213, 158, 0.6) !important;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.14) 0%, rgba(255, 255, 255, 0.03) 45%, rgba(0, 0, 0, 0.25) 100%),
    rgba(20, 16, 24, 0.5) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    0 6px 16px rgba(255, 184, 214, 0.12) !important;
  color: #fff !important;
  transform: translateY(-1px) !important;
  outline: none !important;
}

html[data-ui-style="galgame"] .style-dock .row-actions > button[aria-pressed="true"],
html[data-ui-style="galgame"] .style-dock .row-actions > button[data-active="true"],
html[data-ui-style="galgame"] .style-dock .row-actions > button:active,
html[data-ui-style="galgame"] .style-dock .row-configs > button[aria-pressed="true"],
html[data-ui-style="galgame"] .style-dock .row-configs > button[data-active="true"],
html[data-ui-style="galgame"] .style-dock .row-configs > button:active,
html[data-ui-style="galgame"] .style-dock > label > input[name="uiStyle"]:checked + span,
html[data-ui-style="galgame"] .style-dock .row-configs > label > input[name="uiStyle"]:checked + span,
html[data-ui-style="galgame"] .style-dock .row-configs > button#galgameBranchEdit:active {
  border-color: rgba(255, 226, 216, 0.95) !important;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.05) 45%, rgba(0, 0, 0, 0.3) 100%),
    rgba(30, 20, 28, 0.6) !important;
  box-shadow:
    inset 0 0 0 1px rgba(255, 191, 174, 0.42),
    inset 0 1px 2px rgba(255, 255, 255, 0.3),
    0 8px 24px rgba(255, 165, 136, 0.22) !important;
  color: #fff !important;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8) !important;
  transform: translateY(0) !important;
}

html[data-ui-style="galgame"] .style-dock .row-actions > button:focus-visible,
html[data-ui-style="galgame"] .style-dock .row-configs > button:focus-visible,
html[data-ui-style="galgame"] .style-dock > label > input[name="uiStyle"]:focus-visible + span,
html[data-ui-style="galgame"] .style-dock .row-configs > label > input[name="uiStyle"]:focus-visible + span,
html[data-ui-style="galgame"] .style-dock .row-configs > button#galgameBranchEdit:focus-visible {
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.4),
    0 0 0 2px rgba(255, 213, 158, 0.6) !important;
}

/* Mobile scene picker: keep the expanded menu useful after adding more backgrounds. */
@media (max-width: 700px) {
  html[data-ui-style="galgame"] .style-dock .row-actions {
    order: 1 !important;
  }

  html[data-ui-style="galgame"] .style-dock .row-thumbnails {
    order: 2 !important;
    display: block !important;
    padding: 0 !important;
    background: transparent !important;
    border: 0 !important;
  }

  html[data-ui-style="galgame"] .style-dock .row-configs {
    order: 3 !important;
  }

  html[data-ui-style="galgame"] .galgame-bg-picker {
    display: flex !important;
    grid-template-columns: none !important;
    gap: 8px !important;
    width: 100% !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    padding: 0 2px 6px !important;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
  }

  html[data-ui-style="galgame"] .galgame-bg-picker::-webkit-scrollbar {
    height: 4px;
  }

  html[data-ui-style="galgame"] .galgame-bg-picker::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: rgba(255, 213, 158, 0.34);
  }

  html[data-ui-style="galgame"] .galgame-bg-choice,
  html[data-ui-style="galgame"] .galgame-bg-upload span {
    flex: 0 0 88px !important;
    width: 88px !important;
    min-width: 88px !important;
    min-height: 54px !important;
    height: 54px !important;
    scroll-snap-align: start;
  }

  html[data-ui-style="galgame"] .galgame-bg-upload span {
    flex-basis: 112px !important;
    width: 112px !important;
    min-width: 112px !important;
  }
}
