:root {
  color-scheme: dark;
  --bg: #12121d;
  --panel: #1d1e28;
  --field: #262730;
  --line: #363742;
  --text: #ffffff;
  --muted: #a9abb7;
  --dim: #6b7280;
  --accent: #ff72ab;
  --danger: #ff727d;
  --success: #6fd6a0;
  --radius: 8px;
  font-family: Inter, "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: #090a10; color: var(--text); }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

.app-shell { width: min(100%, 430px); min-height: 100dvh; margin: 0 auto; background: var(--bg); position: relative; overflow: hidden; }
.landing { min-height: 100dvh; display: flex; flex-direction: column; position: relative; isolation: isolate; overflow: hidden; }
.landing-header { position: absolute; z-index: 3; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; padding: max(16px, env(safe-area-inset-top)) 18px 12px; }
.brand-logo { width: 86px; height: auto; max-height: 48px; display: block; object-fit: contain; object-position: left center; }
.account-button { min-height: 42px; max-width: 250px; display: inline-flex; align-items: center; gap: 9px; border: 1px solid rgba(255,255,255,.18); border-radius: 21px; background: rgba(18,18,29,.72); padding: 4px 12px 4px 5px; cursor: pointer; backdrop-filter: blur(12px); }
.account-avatar { width: 32px; height: 32px; flex: 0 0 32px; display: grid; place-items: center; position: relative; overflow: hidden; border-radius: 50%; background: linear-gradient(135deg, #c36ccf, #fc9081); color: white; font-size: 13px; font-weight: 800; }
.apple-avatar { background: white; color: #111116; font-size: 17px; }
.player-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.account-meta { min-width: 0; text-align: left; }
.account-meta b, .account-meta small { display: block; max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-meta b { font-size: 12px; }
.account-meta small { margin-top: 1px; color: var(--muted); font-size: 10px; }
.account-login { display: inline-flex; align-items: center; gap: 7px; padding: 0 8px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.apple-logo { width: 15px; height: 18px; flex: 0 0 auto; display: block; }
.apple-avatar .apple-logo { width: 13px; height: 17px; }
.landing-media { position: absolute; z-index: -1; inset: 0; overflow: hidden; }
.landing-media::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to bottom, transparent 42%, rgba(18,18,29,.68) 65%, var(--bg) 88%); pointer-events: none; }
.landing-media > picture,
.landing-media > picture > img { width: 100%; height: 100%; display: block; }
.landing-media > picture > img { object-fit: cover; object-position: center center; }
.landing-copy { position: absolute; z-index: 1; left: 24px; right: 24px; bottom: clamp(178px, 29dvh, 220px); }
.landing-copy h1 { margin: 5px 0 10px; font-size: 32px; line-height: 1.2; letter-spacing: 0; }
.landing-copy > p:last-child { margin: 0; color: #e1e2e8; font-size: 15px; line-height: 1.7; }
.eyebrow { margin: 0; color: #ff9cc1; font-size: 11px; font-weight: 700; letter-spacing: 0; }
.landing-actions { position: absolute; z-index: 2; left: 0; right: 0; bottom: 0; padding: 8px 24px max(26px, env(safe-area-inset-bottom)); }

.primary-button, .secondary-button, .text-button { min-height: 48px; border: 0; border-radius: var(--radius); font-weight: 700; cursor: pointer; }
.primary-button { width: 100%; background: linear-gradient(100deg, #c36ccf, #fc9081); color: white; }
.primary-button:disabled { opacity: .42; cursor: not-allowed; }
.secondary-button { background: var(--field); border: 1px solid var(--line); }
.text-button { width: 100%; background: transparent; color: var(--muted); margin-top: 6px; }
.icon-button { width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%; background: transparent; font-size: 28px; cursor: pointer; }
.icon-button svg { width: 20px; height: 20px; display: block; margin: auto; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.save-button { border: 1px solid rgba(255,255,255,.16); border-radius: var(--radius); background: var(--field); }
.save-button:hover { background: #30313c; }

.creator-view { min-height: 100dvh; padding-bottom: 86px; }
.app-header { min-height: 72px; display: grid; grid-template-columns: 44px 1fr auto; align-items: center; padding: max(10px, env(safe-area-inset-top)) 12px 6px; border-bottom: 1px solid rgba(255,255,255,.06); }
.header-title { text-align: center; }
.app-header h1 { margin: 1px 0 0; font-size: 18px; letter-spacing: 0; }
.app-header p { margin: 0; color: var(--dim); font-size: 11px; }
.header-actions { display: flex; align-items: center; gap: 2px; }
.account-button.compact { min-height: 40px; border: 0; background: transparent; padding: 4px; }
.account-button.compact .account-meta { display: none; }
.account-button.compact .account-login { padding: 0 4px; }
.step-tabs { display: flex; overflow-x: auto; scrollbar-width: none; gap: 5px; padding: 12px 16px 10px; border-bottom: 1px solid rgba(255,255,255,.06); }
.step-tabs::-webkit-scrollbar { display: none; }
.step-tab { flex: 0 0 auto; min-width: 62px; height: 34px; border: 0; border-radius: 17px; color: var(--dim); background: transparent; font-size: 12px; cursor: pointer; }
.step-tab.active { background: white; color: #161620; font-weight: 700; }
.step-tab.done { color: #ff9fc3; }
.step-content { padding: 18px 16px 28px; }
.step-title { margin: 0 0 4px; font-size: 22px; letter-spacing: 0; }
.step-description { margin: 0 0 20px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.section { margin: 0 0 22px; }
.section-label { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 9px; font-size: 14px; font-weight: 700; }
.section-label small { color: var(--dim); font-size: 11px; font-weight: 500; }
.required { color: var(--accent); }
.field, select.field, textarea.field { width: 100%; border: 1px solid transparent; border-radius: var(--radius); background: var(--field); color: var(--text); padding: 13px 14px; }
.field:focus { border-color: var(--accent); outline: none; }
textarea.field { min-height: 118px; resize: vertical; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.field-with-unit { position: relative; }
.field-with-unit .field { padding-right: 44px; }
.field-unit { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--dim); font-size: 12px; }
.counter { display: block; margin-top: 6px; color: var(--dim); text-align: right; font-size: 11px; }
.hint { color: var(--dim); font-size: 11px; line-height: 1.5; }
.error-text { display: block; margin-top: 6px; color: var(--danger); font-size: 12px; }
.chip-list, .token-list { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 36px; border: 1px solid var(--line); border-radius: 18px; background: transparent; padding: 7px 13px; color: #d8dae3; font-size: 13px; cursor: pointer; }
.chip.selected { border-color: white; background: white; color: #171720; font-weight: 700; }
.chip.add { border-style: dashed; color: #ff9fc3; }
.token-list { margin-top: 9px; }
.token { border: 0; background: #342a38; color: #ff9fc3; border-radius: 5px; padding: 6px 9px; font-size: 11px; cursor: pointer; }

.upload-main { display: grid; grid-template-columns: 136px 1fr; gap: 14px; align-items: center; }
.avatar-preview { width: 136px; aspect-ratio: 3 / 4; border: 1px dashed #555765; border-radius: var(--radius); background: var(--field); overflow: hidden; display: grid; place-items: center; color: var(--dim); cursor: pointer; }
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.upload-copy h3 { margin: 0 0 7px; font-size: 15px; }
.upload-copy p { margin: 0 0 11px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.small-button { min-height: 36px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--field); padding: 0 12px; cursor: pointer; }
.media-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.danger-button { border-color: #57323a; background: #2b2026; color: #ff9da8; }
.media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.media-item { aspect-ratio: 1; position: relative; overflow: hidden; border-radius: var(--radius); background: var(--field); }
.media-item img { width: 100%; height: 100%; object-fit: cover; }
.media-remove { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border: 0; border-radius: 50%; background: rgba(0,0,0,.72); cursor: pointer; }
.media-add { aspect-ratio: 1; border: 1px dashed #555765; border-radius: var(--radius); background: transparent; color: var(--dim); cursor: pointer; }

.choice-stack { display: grid; gap: 8px; }
.choice-card { min-height: 52px; display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: var(--radius); padding: 11px 13px; background: var(--panel); cursor: pointer; }
.choice-card.selected { border-color: var(--accent); background: #30232f; }
.choice-card input { accent-color: var(--accent); }
.choice-card span { font-size: 13px; }
.sidebar-account { display: none; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 13px 14px; border-radius: var(--radius); background: var(--panel); }
.switch-copy b { display: block; font-size: 14px; }
.switch-copy small { color: var(--dim); font-size: 11px; }
.status-switch-row { align-items: flex-start; }
.status-switch-row .switch-copy { min-width: 0; flex: 1; }
.status-preview { display: block; margin-top: 5px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.status-switch-row .switch { flex: 0 0 auto; }
.switch { width: 46px; height: 26px; appearance: none; border-radius: 13px; background: #454651; position: relative; cursor: pointer; transition: .2s; }
.switch::after { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; border-radius: 50%; background: white; transition: .2s; }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(20px); }
.ai-row { display: flex; justify-content: flex-end; margin: 8px 0; }
.ai-button { border: 0; background: transparent; color: #ff9fc3; padding: 5px; font-size: 12px; cursor: pointer; }

.bottom-actions { position: fixed; z-index: 5; bottom: 0; left: 50%; transform: translateX(-50%); width: min(100%, 430px); display: grid; grid-template-columns: 104px 1fr; gap: 10px; padding: 12px 16px max(14px, env(safe-area-inset-bottom)); border-top: 1px solid rgba(255,255,255,.08); background: rgba(18,18,29,.96); backdrop-filter: blur(12px); }

.preview-hero { min-height: 330px; position: relative; overflow: hidden; margin: -18px -16px 20px; }
.preview-hero img { width: 100%; height: 360px; object-fit: cover; }
.preview-hero::after { content: ""; position: absolute; inset: 40% 0 0; background: linear-gradient(transparent, var(--bg)); }
.preview-name { position: absolute; z-index: 1; left: 20px; right: 20px; bottom: 20px; }
.preview-name h2 { margin: 0 0 5px; font-size: 28px; letter-spacing: 0; }
.preview-name p { margin: 0; color: #d9dbe4; font-size: 13px; }
.preview-section { padding: 15px 0; border-bottom: 1px solid rgba(255,255,255,.08); }
.preview-section h3 { margin: 0 0 8px; font-size: 14px; }
.preview-section p { margin: 0; color: #c5c7d1; line-height: 1.65; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.preview-tags { display: flex; flex-wrap: wrap; gap: 7px; }
.preview-tag { padding: 5px 9px; border-radius: 4px; background: var(--field); color: #dddfe7; font-size: 11px; }
.copyright { margin-top: 18px; display: flex; align-items: flex-start; gap: 9px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.copyright input { margin-top: 2px; accent-color: var(--accent); }

dialog { color: var(--text); border: 1px solid var(--line); background: var(--panel); }
dialog::backdrop { background: rgba(0,0,0,.72); backdrop-filter: blur(3px); }
.sheet { width: min(100% - 20px, 410px); max-height: 90dvh; margin: auto auto 10px; border-radius: 12px 12px 8px 8px; padding: 10px 18px 18px; overflow-y: auto; }
.sheet-handle { width: 42px; height: 4px; border-radius: 2px; background: #5b5d69; margin: 0 auto 14px; }
.notice-heading { display: flex; gap: 12px; align-items: center; }
.notice-heading > img { width: 54px; height: 54px; object-fit: contain; }
.notice-heading p { margin: 0 0 2px; color: var(--dim); font-size: 11px; }
.notice-heading h2 { margin: 0; font-size: 21px; }
.sheet h3 { margin: 20px 0 10px; font-size: 13px; color: #ffb2c9; }
.notice-list { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 9px; }
.notice-list li { display: flex; align-items: center; gap: 10px; }
.notice-list img { width: 34px; height: 34px; object-fit: contain; }
.notice-list span { min-width: 0; }
.notice-list b, .notice-list small { display: block; }
.notice-list b { font-size: 13px; margin-bottom: 2px; }
.notice-list small { color: var(--dim); font-size: 10px; line-height: 1.4; }
.modal { width: min(100% - 32px, 380px); border-radius: var(--radius); padding: 20px; }
.modal h2 { margin: 0 0 14px; font-size: 18px; }
.apple-login-dialog { width: min(100% - 32px, 420px); }
.apple-login-dialog #appleid-signin { width: 100%; min-height: 44px; display: grid; place-items: center; }
.apple-login-dialog #appleid-signin[hidden] { display: none; }
.apple-login-status { min-height: 18px; margin: 12px 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.apple-login-status.error { color: var(--danger); }
.apple-login-dialog > .secondary-button { width: 100%; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 18px; }
.dialog-field { width: 100%; min-height: 120px; }
.login-form { display: grid; gap: 13px; }
.login-form label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; }
.apple-auth-heading { display: flex; align-items: center; gap: 10px; margin: -2px 0 18px; padding-bottom: 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
.apple-auth-heading p { margin: 0; font-size: 15px; font-weight: 700; }
.apple-auth-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: white; color: #111116; font-size: 23px; }
.modal.apple-auth #dialogConfirm { background: white; color: #111116; }
.account-detail { display: flex; align-items: center; gap: 13px; padding: 14px; border-radius: var(--radius); background: var(--field); }
.account-detail .account-avatar { width: 44px; height: 44px; flex-basis: 44px; font-size: 17px; }
.account-detail b, .account-detail small { display: block; }
.account-detail small { margin-top: 3px; color: var(--muted); }
.logout-button { width: 100%; min-height: 42px; margin-top: 12px; border: 1px solid #57323a; border-radius: var(--radius); background: #2b2026; color: #ff9da8; cursor: pointer; }
.toast { position: fixed; z-index: 20; left: 50%; bottom: 98px; transform: translate(-50%, 12px); width: max-content; max-width: calc(100% - 40px); padding: 10px 14px; border-radius: 6px; background: #f2f2f4; color: #171720; opacity: 0; pointer-events: none; transition: .2s; font-size: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.28); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 768px) {
  .apple-login-dialog { width: min(calc(100% - 48px), 320px); padding: 16px; }
  .apple-login-dialog h2 { margin-bottom: 12px; font-size: 16px; }
  .apple-login-dialog #appleid-signin { min-height: 42px; }
  .apple-login-status { min-height: 12px; margin: 8px 0; font-size: 11px; }
  .apple-login-dialog > .secondary-button { min-height: 42px; font-size: 14px; }
}

@media (min-width: 600px) {
  body { padding: 20px 0; }
  .app-shell { min-height: calc(100dvh - 40px); border: 1px solid #292a35; box-shadow: 0 24px 80px rgba(0,0,0,.48); }
  .landing, .creator-view { min-height: calc(100dvh - 42px); }
  .bottom-actions { bottom: 20px; border: 1px solid rgba(255,255,255,.08); }
}

@media (min-width: 769px) {
  body { padding: 0; overflow: hidden; }
  .app-shell { width: 100%; max-width: none; height: 100dvh; min-height: 100dvh; border: 0; box-shadow: none; }

  .landing { min-height: 100dvh; }
  .landing-header { padding: 24px clamp(48px, 7vw, 112px); }
  .brand-logo { width: 96px; max-height: 52px; }
  .landing-media > picture > img { object-position: center top; }
  .landing-media::after { background: linear-gradient(to bottom, transparent 42%, rgba(18,18,29,.48) 76%, var(--bg)); }
  .landing-copy { left: clamp(48px, 7vw, 112px); right: auto; bottom: 64px; width: min(52vw, 660px); }
  .landing-copy h1 { font-size: 48px; margin-bottom: 14px; }
  .landing-copy > p:last-child { max-width: 590px; font-size: 17px; line-height: 1.75; }
  .eyebrow { font-size: 12px; }
  .landing-actions { position: absolute; z-index: 2; left: auto; right: clamp(48px, 7vw, 112px); bottom: 60px; width: 320px; padding: 0; }

  .creator-view {
    height: 100dvh;
    min-height: 100dvh;
    padding: 0;
    display: grid;
    grid-template-columns: 236px minmax(0, 1fr);
    grid-template-rows: 76px minmax(0, 1fr) 82px;
    overflow: hidden;
  }
  .app-header { grid-column: 1 / -1; grid-row: 1; min-height: 76px; padding: 10px 24px; background: #171721; border-bottom-color: rgba(255,255,255,.08); }
  .app-header h1 { font-size: 19px; }
  .account-button.compact { min-width: 190px; border: 1px solid rgba(255,255,255,.12); background: var(--panel); padding: 4px 12px 4px 5px; }
  .account-button.compact .account-meta { display: block; }
  .step-tabs {
    grid-column: 1;
    grid-row: 2 / 4;
    min-height: 0;
    flex-direction: column;
    gap: 7px;
    overflow: hidden;
    padding: 26px 16px;
    background: #171721;
    border-right: 1px solid rgba(255,255,255,.08);
    border-bottom: 0;
  }
  .step-tab { width: 100%; min-width: 0; height: 48px; border-radius: 6px; padding: 0 16px; text-align: left; font-size: 13px; }
  .step-tab.active { background: var(--panel); color: white; box-shadow: inset 3px 0 0 var(--accent); }
  .step-tab.done { color: #ff9fc3; }
  .sidebar-account { width: 100%; display: flex; align-items: center; gap: 10px; margin-top: auto; border: 1px solid rgba(255,255,255,.08); border-radius: 6px; background: var(--panel); padding: 10px; cursor: pointer; }
  .sidebar-account .account-meta b, .sidebar-account .account-meta small { max-width: 140px; }
  .step-content {
    grid-column: 2;
    grid-row: 2;
    width: min(100%, 980px);
    min-height: 0;
    margin: 0 auto;
    padding: 34px 48px 64px;
    overflow-y: auto;
    scrollbar-color: #454651 transparent;
  }
  .step-title { font-size: 26px; }
  .step-description { margin-bottom: 28px; font-size: 14px; }
  .section { margin-bottom: 26px; }
  .field-row { gap: 16px; }
  textarea.field { min-height: 138px; }
  .upload-main { grid-template-columns: 180px 1fr; gap: 24px; }
  .avatar-preview { width: 180px; }
  .media-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }

  .bottom-actions {
    grid-column: 2;
    grid-row: 3;
    position: static;
    width: auto;
    transform: none;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 15px 40px;
    border: 0;
    border-top: 1px solid rgba(255,255,255,.08);
    background: #171721;
    backdrop-filter: none;
  }
  .bottom-actions .secondary-button { width: 150px; }
  .bottom-actions .primary-button { width: 230px; }
  .preview-hero { min-height: 420px; height: 420px; margin: -34px -48px 28px; }
  .preview-hero img { height: 450px; object-position: center 28%; }
  .preview-name { left: 48px; right: 48px; bottom: 30px; }
  .preview-name h2 { font-size: 34px; }
  .toast { bottom: 102px; }
  .sheet { margin-bottom: auto; }
}

@media (min-width: 769px) and (max-width: 1100px) {
  .landing-header { padding-inline: 32px; }
  .landing-media > picture > img { object-position: 72% center; }
  .landing-media::after { background: linear-gradient(to bottom, transparent 35%, rgba(18,18,29,.66) 62%, var(--bg) 88%); }
  .landing-copy { left: 32px; right: 32px; bottom: 172px; width: auto; }
  .landing-copy > p:last-child { max-width: 600px; }
  .landing-actions { left: 32px; right: 32px; bottom: 28px; width: auto; }
}

@media (max-width: 360px) {
  .upload-main { grid-template-columns: 112px 1fr; }
  .avatar-preview { width: 112px; }
  .field-row { grid-template-columns: 1fr; }
  .step-tab { min-width: 58px; }
}
