:root {
  color-scheme: light;
  --bg: #f6f5ef;
  --backdrop-glow: #e9e6d9;
  --character-shadow: #77664c45;
  --surface: #fffefa;
  --ink: #202821;
  --muted: #5e685f;
  --line: #dedfd3;
  --dark-green: #254735;
  --soft: #e6eddf;
  --accent: #315c44;
  --action-ink: #fff;
  --paper: #fbfaf5;
  --paper-line: #e1e2d7;
  --control-line: #d7dacd;
  --shadow: #36402b0b;
  --error: #a33828;
  --font: "Ubuntu", "Yuanti SC", "Microsoft YaHei", "微软雅黑", "PingFang SC", -apple-system, BlinkMacSystemFont, sans-serif;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #151a17;
  --backdrop-glow: #28332a;
  --character-shadow: #090e0a9c;
  --surface: #1d241f;
  --ink: #edf1e9;
  --muted: #a6b3a8;
  --line: #37443b;
  --dark-green: #aed1b1;
  --soft: #304437;
  --accent: #c4dfbe;
  --action-ink: #18271c;
  --paper: #191f1b;
  --paper-line: #364038;
  --control-line: #49594b;
  --shadow: #0003;
  --error: #ffa999;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; background: radial-gradient(ellipse at center bottom, var(--backdrop-glow), transparent 68%); }
button, input, select, textarea { font: inherit; }
button, select, summary { cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

.shell { width: min(1080px, calc(100% - 88px)); margin-inline: auto; }
main.shell { flex: 1 0 auto; display: flex; flex-direction: column; gap: clamp(24px, 5vh, 46px); padding-block: clamp(24px, 6vh, 56px) 32px; }
.character-scene { position: relative; align-self: center; width: min(100%, 990px); }
.character-scene::before {
  content: "";
  position: absolute;
  inset: auto 4% 1% 4%;
  height: 15%;
  background: radial-gradient(ellipse at center, var(--character-shadow), transparent 72%);
}
.character-lineup {
  position: relative;
  display: block;
  width: 100%;
  height: auto;
  mix-blend-mode: multiply;
  filter: saturate(.88);
  opacity: .92;
}
:root[data-theme="dark"] .character-scene { isolation: isolate; }
:root[data-theme="dark"] .character-scene::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -24% max(-3vw, -12px) 0;
  background:
    radial-gradient(ellipse 32% 40% at 17% 43%, #4c6650b3, transparent),
    radial-gradient(ellipse 33% 43% at 85% 46%, #4c6650a6, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent);
}
:root[data-theme="dark"] .character-lineup {
  mix-blend-mode: normal;
  filter: saturate(.8) brightness(.92) drop-shadow(0 -1px 2px #accaaa2b);
  opacity: .9;
}
.masthead { border-bottom: 1px solid var(--line); }
.header-inner { height: 73px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--ink); font-size: 19px; font-weight: 700; letter-spacing: .08em; text-decoration: none; }
.brand-mark { display: block; flex: none; }
.status-icon { display: inline-flex; align-items: center; justify-content: center; gap: 2px; }
.status-icon i { width: 2px; height: 6px; border-radius: 3px; background: currentColor; }
.status-icon i:nth-child(even) { height: 11px; }
.status-icon i:nth-child(3) { height: 17px; }
.theme-trigger { display: grid; place-items: center; width: 40px; height: 40px; flex: none; padding: 0; border: 1px solid var(--control-line); border-radius: 10px; color: var(--accent); background: var(--surface); }
.theme-trigger:hover { background: var(--soft); }
.theme-icon { display: none; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
:root:not([data-theme-preference]) [data-theme-icon="system"],
:root[data-theme-preference="system"] [data-theme-icon="system"],
:root[data-theme-preference="light"] [data-theme-icon="light"],
:root[data-theme-preference="dark"] [data-theme-icon="dark"] { display: block; }

.studio { background: var(--surface); border: 1px solid var(--line); border-radius: 19px; box-shadow: 0 11px 28px var(--shadow); }
.login-shell { justify-content: center; align-items: center; }
.login-card { display: grid; width: min(100%, 370px); gap: 12px; padding: 26px; }
.login-card .brand { margin: 0 0 10px; }
.login-card label, .login-error { font-size: 14px; }
.login-card input { width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid var(--paper-line); border-radius: 8px; background: var(--paper); color: var(--ink); }
.login-error { margin: 0; color: var(--error); }
.editor { min-width: 0; padding: 27px 29px 21px; }
.paper { display: flex; flex-direction: column; border: 1px solid var(--paper-line); border-radius: 11px; background: var(--paper); }
.paper:focus-within { border-color: var(--accent); }
textarea { width: 100%; height: 211px; min-height: 140px; display: block; resize: vertical; border: 0; border-radius: 11px 11px 0 0; background: transparent; color: var(--ink); padding: 18px 19px; font-size: 16px; line-height: 1.95; }
textarea:focus-visible { outline: none; }
textarea::placeholder { color: var(--muted); opacity: 1; }
.counter { padding: 0 14px 10px; text-align: right; font-size: 12px; font-variant-numeric: tabular-nums; color: var(--muted); }
.counter output { color: var(--accent); font-weight: 650; }
.settings { border-top: 1px solid var(--line); }
.settings summary { display: flex; align-items: center; gap: 9px; min-height: 54px; padding: 10px 29px; font-size: 14px; font-weight: 600; list-style: none; }
.settings summary::-webkit-details-marker { display: none; }
.settings summary::before { content: ""; width: 7px; height: 7px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: translateY(-2px) rotate(45deg); }
.settings[open] summary::before { transform: translateY(2px) rotate(225deg); }
#settings-caption { margin-left: auto; color: var(--muted); font-size: 12px; font-weight: 400; }
.settings-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; gap: 11px 18px; padding: 0 29px 19px; }
.field label { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 550; }
select { width: 100%; min-height: 41px; border: 1px solid var(--control-line); border-radius: 8px; color: var(--ink); background: var(--surface); padding: 8px 10px; font-size: 14px; }
.speed-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.speed-heading output { font-size: 13px; color: var(--accent); font-variant-numeric: tabular-nums; font-weight: 650; }
input[type="range"] { display: block; width: 100%; margin: 0; accent-color: var(--accent); height: 41px; cursor: pointer; }
.engine-note { grid-column: 1 / -1; color: var(--muted); margin: 0; font-size: 12px; line-height: 1.55; }
.transport { border-top: 1px solid var(--line); padding: 15px 29px; display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.transport-status, .transport-actions, .play-actions { display: flex; align-items: center; gap: 11px; }
.transport-status { min-width: 0; }
.transport-copy { min-width: 0; overflow-wrap: anywhere; }
.status-icon { background: var(--soft); color: var(--accent); border-radius: 50%; width: 43px; height: 43px; flex: 0 0 auto; }
.transport p { margin: 0; }
#status { font-size: 14px; font-weight: 650; }
#status-detail { color: var(--muted); font-size: 12px; margin-top: 4px; }
body[data-error="true"] #status { color: var(--error); }
.primary, .secondary { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 46px; border: 1px solid transparent; border-radius: 9px; padding: 9px 15px; font-size: 14px; font-weight: 650; white-space: nowrap; text-decoration: none; }
.primary { min-width: 137px; background: var(--dark-green); color: var(--action-ink); }
.primary:hover:not(:disabled) { background: var(--accent); }
.primary:disabled { opacity: .55; cursor: not-allowed; }
.secondary { border-color: var(--line); color: var(--accent); background: transparent; }
.secondary:hover { background: var(--soft); }
.symbol { display: inline-block; width: 0; height: 0; border-top: 5px solid transparent; border-bottom: 5px solid transparent; border-left: 8px solid currentColor; }
body[data-playing="true"] .symbol { width: 9px; height: 11px; border: 0; border-inline: 3px solid currentColor; }
@media (max-width: 760px) {
  .shell { width: calc(100% - 40px); }
  .editor, .settings summary, .settings-fields, .transport { padding-inline: 19px; }
}
@media (max-width: 570px) {
  .shell { width: calc(100% - 30px); }
  .header-inner { height: 60px; }
  .editor { padding: 17px; }
  .settings summary, .settings-fields { padding-inline: 17px; }
  .settings-fields { grid-template-columns: minmax(0, 1fr); }
  textarea { height: 154px; padding: 13px; }
  .transport { padding: 13px 17px; flex-wrap: wrap; }
  .transport-actions { margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
  .transport-actions, .play-actions { gap: 6px; }
  .primary, .secondary { padding-inline: 11px; min-height: 44px; }
  .primary { min-width: 109px; }
}
