:root {
  color-scheme: light;
  --paper: #f5f3ee;
  --card: #fffefa;
  --ink: #222526;
  --muted: #777c7c;
  --line: #e8e5dd;
  --accent: #6f67c7;
  --accent-dark: #5149a9;
  --accent-soft: #efedfb;
  --mint: #cbe2d8;
  --coral: #ed9a7e;
  --yellow: #f5d891;
  --shadow: 0 16px 40px rgba(49, 48, 42, .06);
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--paper); color: var(--ink); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid #aaa5ec; outline-offset: 2px; }
a { color: inherit; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 27px 18px 20px; display: flex; flex-direction: column; background: #fbfaf7; border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 9px 31px; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 14px; color: white; background: var(--accent); font-size: 22px; transform: rotate(-7deg); }
.brand-title { font-family: Georgia, "Microsoft YaHei", serif; font-size: 18px; letter-spacing: -.5px; }
.brand-caption { margin-top: 3px; color: var(--muted); font-size: 10px; letter-spacing: 1.3px; text-transform: uppercase; }
.nav-label { margin: 12px 12px 8px; color: #9a9b98; font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase; }
.nav-list { display: grid; gap: 5px; }
.nav-item { border: 0; border-radius: 12px; padding: 11px 13px; display: flex; align-items: center; gap: 12px; color: #626767; background: transparent; text-align: left; font-size: 13px; transition: background .18s, color .18s; }
.nav-item:hover { color: var(--ink); background: #f2f0e9; }
.nav-item.active { color: var(--accent-dark); background: var(--accent-soft); font-weight: 650; }
.nav-icon { width: 18px; text-align: center; font-size: 17px; }
.sidebar-bottom { margin-top: auto; }
.phase-card { padding: 15px; border: 1px solid #e7e2d8; border-radius: 15px; background: #f7f4eb; }
.phase-card .eyebrow { color: #9a7851; }
.phase-card p { margin: 8px 0 12px; color: #68655f; font-size: 11px; line-height: 1.65; }
.phase-link { border: 0; padding: 0; color: var(--accent-dark); background: transparent; font-size: 11px; font-weight: 700; }
.user-row { margin-top: 17px; padding: 13px 7px 0; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.user-avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: #594d90; background: #dedaf4; font-size: 13px; font-weight: 700; }
.user-email { min-width: 0; flex: 1; overflow: hidden; color: #575b5b; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.logout-button { border: 0; color: #8b8e8d; background: transparent; font-size: 11px; }
.main { min-width: 0; padding: 0 44px 60px; }
.topbar { min-height: 79px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.crumb { color: #969997; font-size: 11px; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.provider-pill { display: flex; align-items: center; gap: 7px; border: 1px solid #e7e4dc; border-radius: 99px; padding: 7px 11px; color: #787d7c; background: #fbfaf7; font-size: 10px; }
.provider-dot { width: 7px; height: 7px; border-radius: 50%; background: #d8aa61; }
.content { max-width: 1240px; margin: 0 auto; padding-top: 37px; }
.page-heading { margin-bottom: 24px; display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.eyebrow { color: var(--accent); font-size: 10px; font-weight: 750; letter-spacing: 1.6px; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin: 7px 0 0; font-family: Georgia, "Microsoft YaHei", serif; font-size: clamp(25px, 3vw, 34px); font-weight: 500; letter-spacing: -.8px; }
.heading-copy { max-width: 570px; margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.65; }
.button { min-height: 39px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 10px; padding: 0 15px; color: white; background: var(--accent); font-size: 12px; font-weight: 650; text-decoration: none; transition: background .15s, transform .15s; }
.button:hover { background: var(--accent-dark); transform: translateY(-1px); }
.button.secondary { border-color: var(--line); color: #555c5b; background: #fffefa; }
.button.secondary:hover { border-color: #d4d0e8; color: var(--accent-dark); background: #faf9ff; }
.button.ghost { color: var(--accent-dark); background: transparent; }
.button.ghost:hover { background: var(--accent-soft); }
.button.danger { border-color: #f0d1c8; color: #a44f3a; background: #fff8f5; }
.button:disabled { cursor: not-allowed; opacity: .55; transform: none; }
.stats-grid { margin: 24px 0 29px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
.stat-card { padding: 17px 19px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); }
.stat-label { color: var(--muted); font-size: 11px; }
.stat-value { margin-top: 11px; font-family: Georgia, serif; font-size: 25px; }
.stat-note { margin-top: 3px; color: #a1a3a1; font-size: 10px; }
.section-head { margin: 27px 0 13px; display: flex; align-items: center; justify-content: space-between; }
.section-head h2 { margin: 0; font-family: Georgia, "Microsoft YaHei", serif; font-size: 17px; font-weight: 500; }
.section-head span { color: #969997; font-size: 11px; }
.character-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.character-card { overflow: hidden; border: 1px solid var(--line); border-radius: 15px; background: var(--card); cursor: pointer; transition: box-shadow .2s, transform .2s; }
.character-card:hover { box-shadow: var(--shadow); transform: translateY(-3px); }
.character-art { position: relative; height: 188px; overflow: hidden; display: grid; place-items: center; background: #ebe9f4; }
.character-art.color-1 { background: #e9eee8; }
.character-art.color-2 { background: #f5e9de; }
.character-art.color-3 { background: #e5edf1; }
.character-art img { width: 100%; height: 100%; object-fit: cover; }
.avatar-art { width: 112px; height: 112px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.75); border-radius: 50%; color: #554c96; background: rgba(255,255,255,.63); font-family: Georgia, serif; font-size: 42px; box-shadow: 0 10px 24px rgba(49,48,42,.08); }
.status-tag { position: absolute; top: 12px; left: 12px; border: 1px solid rgba(255,255,255,.75); border-radius: 99px; padding: 6px 9px; color: #65676a; background: rgba(255,255,255,.8); backdrop-filter: blur(8px); font-size: 9px; }
.character-info { padding: 15px 16px 16px; }
.character-title-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.character-title { overflow: hidden; font-size: 14px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.character-date { color: #a2a4a1; font-size: 9px; }
.character-subtitle { min-height: 18px; margin: 6px 0 13px; overflow: hidden; color: #8a8e8d; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { border-radius: 6px; padding: 4px 7px; color: #716c96; background: #f1eff9; font-size: 9px; }
.empty-state { padding: 56px 24px; border: 1px dashed #d9d6cf; border-radius: 16px; background: rgba(255,254,250,.7); text-align: center; }
.empty-illustration { width: 66px; height: 66px; margin: 0 auto 15px; display: grid; place-items: center; border-radius: 24px; color: var(--accent-dark); background: var(--accent-soft); font-size: 27px; }
.empty-state h2 { margin-bottom: 8px; font-family: Georgia, serif; font-size: 20px; font-weight: 500; }
.empty-state p { max-width: 430px; margin: 0 auto 18px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.banner { margin: 17px 0; padding: 14px 16px; border: 1px solid #e9dfc8; border-radius: 12px; display: flex; align-items: flex-start; gap: 10px; color: #6f6554; background: #faf6e9; font-size: 11px; line-height: 1.65; }
.banner.info { border-color: #e2dff4; color: #5e5a81; background: #f5f3fc; }
.banner.success { border-color: #d6e6db; color: #4e6d59; background: #f0f7f1; }
.banner-icon { flex: 0 0 auto; font-size: 16px; }
.panel { border: 1px solid var(--line); border-radius: 15px; background: var(--card); box-shadow: 0 8px 24px rgba(49,48,42,.025); }
.form-panel { padding: 23px; }
.mode-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; }
.mode-option { position: relative; min-height: 119px; padding: 15px; border: 1px solid var(--line); border-radius: 12px; display: flex; flex-direction: column; align-items: flex-start; gap: 9px; color: var(--ink); background: #fffefa; text-align: left; }
.mode-option.selected { border-color: #aca7e4; background: #f7f6fe; box-shadow: inset 0 0 0 1px #c5c1ef; }
.mode-option strong { font-size: 12px; }
.mode-option small { color: var(--muted); font-size: 10px; line-height: 1.5; }
.mode-icon { color: var(--accent-dark); font-size: 19px; }
.form-grid { margin-top: 21px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px 13px; }
.field { min-width: 0; display: grid; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field label, .field-label { color: #565d5c; font-size: 11px; font-weight: 650; }
.field label span { color: #a0a2a0; font-weight: 400; }
.field input, .field textarea, .field select { width: 100%; border: 1px solid #e2e0d9; border-radius: 9px; padding: 11px 12px; color: var(--ink); background: #fffefa; font-size: 12px; }
.field textarea { min-height: 82px; resize: vertical; line-height: 1.6; }
.field input::placeholder, .field textarea::placeholder { color: #b4b6b3; }
.field-help { color: #969a98; font-size: 10px; line-height: 1.55; }
.upload-zone { padding: 17px; border: 1px dashed #c8c3df; border-radius: 11px; display: flex; align-items: center; gap: 13px; color: var(--accent-dark); background: #faf9ff; cursor: pointer; }
.upload-zone:hover { border-color: #928bd5; background: #f6f4ff; }
.upload-zone input { display: none; }
.upload-zone strong { display: block; color: #4d4a67; font-size: 11px; }
.upload-zone small { display: block; margin-top: 4px; color: #9999a2; font-size: 9px; }
.upload-zone .upload-icon { font-size: 20px; }
.upload-preview { width: 58px; height: 58px; border-radius: 9px; object-fit: cover; }
.checkline { align-items: flex-start; display: flex; gap: 9px; color: #6c7170; font-size: 10px; line-height: 1.55; }
.checkline input { margin-top: 2px; accent-color: var(--accent); }
.form-actions { margin-top: 20px; padding-top: 17px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.detail-layout { display: grid; grid-template-columns: minmax(260px, .8fr) minmax(0, 1.2fr); gap: 19px; }
.detail-portrait { position: relative; min-height: 330px; overflow: hidden; border-radius: 15px; display: grid; place-items: center; background: #ebe9f4; }
.detail-portrait img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.detail-portrait .avatar-art { width: 142px; height: 142px; font-size: 58px; }
.detail-card { padding: 21px; }
.detail-title { margin: 6px 0 7px; font-family: Georgia, "Microsoft YaHei", serif; font-size: 27px; font-weight: 500; }
.detail-description { color: #777c7a; font-size: 12px; line-height: 1.7; white-space: pre-wrap; }
.detail-actions { margin: 15px 0 20px; display: flex; flex-wrap: wrap; gap: 8px; }
.detail-divider { margin: 18px 0; border: 0; border-top: 1px solid var(--line); }
.attribute-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 13px; }
.attribute { padding: 11px 12px; border-radius: 9px; background: #f7f6f1; }
.attribute span { display: block; color: #929694; font-size: 9px; }
.attribute strong { display: block; margin-top: 5px; color: #4d5251; font-size: 11px; font-weight: 600; }
.template-toolbar { margin: 20px 0 14px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; }
.filter-row { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-chip { border: 1px solid #e4e1d9; border-radius: 99px; padding: 7px 12px; color: #737877; background: #fffefa; font-size: 10px; }
.filter-chip.active { border-color: var(--accent); color: white; background: var(--accent); }
.template-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; }
.template-card { padding: 13px; border: 1px solid var(--line); border-radius: 13px; background: var(--card); }
.template-preview { height: 132px; margin-bottom: 11px; border-radius: 9px; display: grid; place-items: center; background: #f1eff8; }
.template-card:nth-child(3n+2) .template-preview { background: #eff3ed; }
.template-card:nth-child(3n) .template-preview { background: #f8f0e8; }
.template-preview svg { width: 76px; height: 112px; overflow: visible; }
.template-preview .face-glyph { color: #675fb3; font-family: Georgia, serif; font-size: 62px; }
.template-meta { color: #9b9d9b; font-size: 9px; }
.template-name { margin: 4px 0 5px; font-size: 12px; font-weight: 700; }
.template-desc { margin: 0; color: #8a8e8d; font-size: 10px; line-height: 1.5; }
.generate-layout { display: grid; grid-template-columns: minmax(0,1fr) 290px; gap: 16px; align-items: start; }
.selector-section { padding: 18px; }
.selector-section + .selector-section { margin-top: 12px; }
.selector-title { margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; }
.selector-title h2 { margin: 0; font-size: 13px; }
.selector-title span { color: #999d9b; font-size: 10px; }
.select-grid { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 8px; }
.select-template { min-height: 90px; padding: 9px 6px; border: 1px solid var(--line); border-radius: 10px; display: grid; place-items: center; gap: 5px; color: #686c6b; background: #fffefa; text-align: center; }
.select-template:hover { border-color: #bab5e9; }
.select-template.selected { border-color: var(--accent); color: var(--accent-dark); background: #f6f4ff; box-shadow: inset 0 0 0 1px #c9c5ee; }
.select-template .mini-glyph { font-family: Georgia, serif; font-size: 22px; }
.select-template small { font-size: 9px; }
.generate-side { padding: 18px; position: sticky; top: 16px; }
.selected-art { height: 175px; margin-bottom: 15px; border-radius: 11px; display: grid; place-items: center; background: linear-gradient(145deg, #eae8f5, #f8f0e7); }
.selected-art img { width: 100%; height: 100%; border-radius: 11px; object-fit: cover; }
.selected-art .avatar-art { width: 82px; height: 82px; font-size: 31px; }
.generate-side h2 { margin: 0 0 5px; font-size: 14px; }
.generate-side p { color: #888d8b; font-size: 10px; line-height: 1.55; }
.range-row { margin: 14px 0; display: flex; justify-content: space-between; color: #717775; font-size: 10px; }
.range-control { width: 100%; accent-color: var(--accent); }
.generate-side .button { width: 100%; margin-top: 10px; }
.notice-small { margin-top: 10px; color: #9a9c99; font-size: 9px; line-height: 1.55; }
.generation-list { display: grid; gap: 8px; }
.generation-row { padding: 11px 12px; border: 1px solid var(--line); border-radius: 9px; display: flex; align-items: center; justify-content: space-between; background: var(--card); font-size: 10px; }
.generation-row small { display: block; margin-top: 4px; color: #9a9d9b; }
.badge-blocked { border-radius: 99px; padding: 5px 8px; color: #8b6a31; background: #faf3df; font-size: 9px; }
.auth-wrap, .share-wrap { min-height: 100vh; padding: 25px; display: grid; place-items: center; background: radial-gradient(ellipse at 12% 20%, #e6e2f6 0, transparent 35%), radial-gradient(ellipse at 92% 82%, #e7eee4 0, transparent 34%), var(--paper); }
.auth-card { width: min(100%, 420px); padding: 33px; border: 1px solid rgba(230,227,219,.9); border-radius: 19px; background: rgba(255,254,250,.9); box-shadow: 0 25px 75px rgba(56,53,72,.1); }
.auth-card .brand { padding: 0 0 25px; }
.auth-card h1 { font-size: 28px; }
.auth-card > p { margin: 10px 0 22px; color: var(--muted); font-size: 12px; line-height: 1.65; }
.auth-card .field + .field { margin-top: 13px; }
.auth-submit { width: 100%; margin-top: 17px; }
.auth-switch { margin-top: 16px; color: #8b8f8e; font-size: 11px; text-align: center; }
.auth-switch button { border: 0; color: var(--accent-dark); background: transparent; font-weight: 650; }
.share-card { width: min(100%, 780px); overflow: hidden; border: 1px solid var(--line); border-radius: 17px; background: var(--card); box-shadow: var(--shadow); }
.share-head { padding: 19px 23px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.share-head .brand { padding: 0; }
.share-body { padding: 23px; display: grid; grid-template-columns: 250px minmax(0,1fr); gap: 22px; }
.share-portrait { min-height: 290px; overflow: hidden; border-radius: 13px; display: grid; place-items: center; background: #efedf7; }
.share-portrait img { width: 100%; height: 100%; min-height: 290px; object-fit: cover; }
.share-footer { padding: 14px 23px; border-top: 1px solid var(--line); color: #a0a29f; font-size: 9px; }
.share-link-box { margin: 14px 0; padding: 12px; border: 1px solid var(--line); border-radius: 9px; display: flex; align-items: center; gap: 8px; background: #fbfaf6; }
.share-link-box input { min-width: 0; flex: 1; border: 0; outline: 0; color: #777; background: transparent; font-size: 10px; }
.toast { position: fixed; z-index: 20; left: 50%; bottom: 22px; max-width: calc(100% - 32px); padding: 11px 15px; border-radius: 10px; color: white; background: #323638; box-shadow: 0 8px 22px rgba(0,0,0,.18); font-size: 11px; opacity: 0; pointer-events: none; transform: translate(-50%, 12px); transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.muted { color: var(--muted); }
.small { font-size: 10px; }
.mt-12 { margin-top: 12px; }
.hide { display: none !important; }
.quota-bar { margin-bottom: 20px; padding: 12px 15px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); background: var(--card); font-size: 12px; line-height: 1.8; }
.recovery-code { white-space: pre-wrap; overflow-wrap: anywhere; padding: 18px; border-radius: 10px; background: var(--accent-soft); font-size: 16px; line-height: 1.8; user-select: all; }
.form-error { color: #aa3c35; font-size: 12px; line-height: 1.6; }
.terms-card { width: min(100%, 760px); padding: 28px; line-height: 1.8; }
.terms-text { white-space: pre-wrap; font-size: 14px; }
button:disabled { opacity: .6; cursor: wait; }

@media (max-width: 1040px) {
  .main { padding-right: 25px; padding-left: 25px; }
  .character-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .template-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .select-grid { grid-template-columns: repeat(4,minmax(0,1fr)); }
}
@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 13px 14px 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 0 3px 12px; }
  .nav-label, .sidebar-bottom { display: none; }
  .nav-list { display: flex; gap: 5px; overflow-x: auto; padding-bottom: 11px; }
  .nav-item { flex: 0 0 auto; padding: 9px 10px; font-size: 11px; }
  .nav-icon { font-size: 14px; }
  .main { padding: 0 17px 40px; }
  .topbar { min-height: 55px; }
  .content { padding-top: 25px; }
  .provider-pill { font-size: 9px; }
  .stats-grid { gap: 7px; }
  .stat-card { padding: 12px 11px; }
  .stat-value { font-size: 21px; }
  .character-grid { gap: 10px; }
  .character-art { height: 145px; }
  .character-info { padding: 12px; }
  .detail-layout, .generate-layout { grid-template-columns: 1fr; }
  .detail-portrait { min-height: 240px; }
  .generate-side { position: static; }
  .select-grid { grid-template-columns: repeat(4,minmax(0,1fr)); }
  .template-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .share-body { grid-template-columns: 1fr; }
  .share-portrait { min-height: 240px; }
}
@media (max-width: 440px) {
  .page-heading { align-items: flex-start; flex-direction: column; }
  .page-heading > .button { align-self: stretch; }
  .character-grid { grid-template-columns: 1fr; }
  .character-art { height: 195px; }
  .mode-grid { grid-template-columns: 1fr; }
  .mode-option { min-height: auto; display: grid; grid-template-columns: 26px 1fr; }
  .mode-option small { grid-column: 2; }
  .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .form-panel { padding: 16px; }
  .select-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .stats-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .stat-note { display: none; }
}
@media print {
  body { background: white; }
  .sidebar, .topbar, .detail-actions, .page-heading > .button, .banner, .toast { display: none !important; }
  .app-shell { display: block; }
  .main { padding: 0; }
  .content { max-width: none; padding: 0; }
  .detail-layout { grid-template-columns: 34% 1fr; }
  .panel, .detail-portrait { break-inside: avoid; box-shadow: none; }
  .detail-portrait { min-height: 270px; }
  .character-grid { grid-template-columns: repeat(3,1fr); }
}
