:root {
  color-scheme: light;
  --ink: #3b1715;
  --muted: #8f6d64;
  --paper: #f8edda;
  --paper-soft: #fff8eb;
  --red: #a61e1d;
  --red-deep: #651313;
  --red-bright: #d33a2e;
  --gold: #d8a949;
  --line: rgba(97, 37, 31, 0.18);
  --shadow: 0 20px 60px rgba(70, 17, 16, 0.16);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; color: var(--ink); background: #efe1c8; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.grain { position: fixed; inset: 0; pointer-events: none; opacity: .28; background-image: radial-gradient(rgba(83, 27, 22, .14) .7px, transparent .7px); background-size: 7px 7px; mix-blend-mode: multiply; }
.login-shell, .app-shell { position: relative; z-index: 1; }
.login-shell { min-height: 100vh; padding: 42px 7vw; background: linear-gradient(120deg, rgba(91, 15, 18, .98), rgba(150, 27, 26, .95) 52%, rgba(209, 74, 48, .92)), url("./assets/logo.png"); color: var(--paper-soft); }
.brand-lockup { display: flex; align-items: center; gap: 18px; }
.brand-lockup img { width: 222px; max-width: 46vw; }
.brand-lockup p { margin: 0; color: rgba(255, 241, 215, .74); font-size: 11px; letter-spacing: .24em; text-transform: uppercase; }
.login-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(300px, 420px); gap: 8vw; align-items: center; min-height: calc(100vh - 120px); }
.eyebrow, .card-kicker, .section-heading p { margin: 0 0 12px; color: var(--gold); font: 700 11px/1.3 Georgia, serif; letter-spacing: .22em; text-transform: uppercase; }
h1, h2 { margin: 0; font-family: Georgia, "STSong", serif; }
.login-story h1 { max-width: 820px; font-size: clamp(48px, 6vw, 94px); line-height: 1.08; letter-spacing: -.06em; }
em { color: #f5cd76; font-style: normal; }
.login-story > p:not(.eyebrow) { max-width: 620px; margin: 30px 0; color: rgba(255, 244, 222, .82); font-size: 17px; line-height: 1.9; }
.story-rule { width: 86px; height: 2px; margin: 28px 0 18px; background: var(--gold); }
.login-story span { color: rgba(255, 241, 215, .7); font-size: 12px; letter-spacing: .08em; }
.login-card, .form-panel, .result-panel, .history-section { border: 1px solid var(--line); background: rgba(255, 248, 235, .92); box-shadow: var(--shadow); }
.login-card { padding: 36px; color: var(--ink); }
.login-card h2 { margin-bottom: 28px; font-size: 34px; }
label { display: grid; gap: 8px; margin-bottom: 16px; color: #743731; font-size: 13px; font-weight: 700; }
input, select, textarea { width: 100%; border: 1px solid rgba(112, 46, 41, .22); border-radius: 4px; background: rgba(255, 255, 255, .68); padding: 12px 14px; color: var(--ink); outline: none; transition: border-color .2s, box-shadow .2s; }
textarea { min-height: 120px; resize: vertical; line-height: 1.7; }
input:focus, select:focus, textarea:focus { border-color: var(--red-bright); box-shadow: 0 0 0 3px rgba(196, 54, 45, .12); }
button, .download-button { border: 1px solid transparent; border-radius: 3px; background: var(--red); padding: 13px 22px; color: white; font-weight: 800; text-decoration: none; transition: transform .2s, background .2s; }
button:hover, .download-button:hover { transform: translateY(-2px); background: var(--red-bright); }
.error { min-height: 20px; color: #c23830; font-size: 13px; line-height: 1.5; }
.preview-hint { margin: 8px 0 0; border-left: 3px solid var(--gold); padding: 10px 12px; background: rgba(216, 169, 73, .12); color: #86541b; font-size: 12px; line-height: 1.7; }
.preview-hint code { font-family: Consolas, monospace; }
.app-shell { min-height: 100vh; background: linear-gradient(135deg, #f5ead6, #ead6b6); }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 18px 6vw; border-bottom: 1px solid var(--line); background: rgba(105, 18, 19, .96); }
.brand-lockup.compact img { width: 170px; }
.brand-lockup.compact p { color: #f5d78c; }
.top-actions { display: flex; align-items: center; gap: 14px; }
.status-chip { border: 1px solid rgba(255,255,255,.18); border-radius: 99px; padding: 7px 11px; color: #f3d28c; font-size: 12px; }
.ghost-button { border-color: rgba(255,255,255,.2); background: transparent; padding: 8px 13px; font-size: 12px; }
.hero { padding: 70px 6vw 36px; }
.hero h1 { max-width: 940px; font-size: clamp(42px, 5vw, 76px); line-height: 1.08; color: var(--red-deep); letter-spacing: -.05em; }
.hero-nowrap { white-space: nowrap; }
.hero p:last-child { max-width: 710px; color: var(--muted); line-height: 1.8; }
.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(340px, .88fr); gap: 24px; padding: 0 6vw; }
.form-panel, .result-panel, .history-section { padding: 26px; }
.section-heading { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.section-heading span { display: grid; width: 38px; height: 38px; place-items: center; border: 1px solid var(--gold); border-radius: 99px; color: var(--red); font-family: Georgia, serif; }
.section-heading p { margin: 0; color: var(--muted); }
.section-heading h2 { font-size: 28px; color: var(--red-deep); }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.wide { grid-column: 1 / -1; }
.submit-row { display: flex; align-items: center; gap: 16px; padding-top: 8px; border-top: 1px solid var(--line); }
.submit-row p { color: var(--muted); font-size: 12px; line-height: 1.5; }
.result-panel { min-height: 660px; }
.result-empty, .result-loading { display: grid; min-height: 480px; place-items: center; align-content: center; padding: 30px; text-align: center; color: var(--muted); }
.result-empty strong, .result-loading strong { color: var(--red-deep); font-family: Georgia, "STSong", serif; font-size: 28px; }
.result-empty p, .result-loading p { max-width: 360px; line-height: 1.8; }
.loading-ring { width: 52px; height: 52px; margin-bottom: 18px; border: 3px solid rgba(166,30,29,.16); border-top-color: var(--red); border-radius: 50%; animation: spin 1s linear infinite; }
.result-card img { display: block; width: min(100%, 430px); margin: 0 auto; box-shadow: 0 16px 40px rgba(80, 23, 20, .2); }
.result-meta { display: grid; gap: 8px; padding-top: 18px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.result-meta p { margin: 0; }
.download-button { justify-self: start; margin-top: 6px; }
.publish-copy-panel { margin-top: 12px; border: 1px solid var(--line); background: rgba(255, 250, 243, .82); padding: 14px; color: var(--ink); }
.copy-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.copy-heading strong { color: var(--red-deep); font-size: 15px; }
.publish-copy-panel pre { max-height: 260px; overflow: auto; margin: 0; white-space: pre-wrap; word-break: break-word; font-family: inherit; font-size: 13px; line-height: 1.8; color: var(--ink); }
.copy-heading .secondary-button { padding: 8px 12px; font-size: 12px; }
.history-section { margin: 26px 6vw 0; box-shadow: none; }
.history-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; }
.history-card { position: relative; border: 1px solid var(--line); background: rgba(255,255,255,.46); padding: 9px; }
.history-preview { display: block; position: relative; overflow: hidden; }
.history-card img { display: block; width: 100%; aspect-ratio: 9 / 16; object-fit: cover; }
.history-actions { position: absolute; top: 14px; right: 14px; display: flex; gap: 7px; opacity: 0; transform: translateY(-4px); transition: opacity .18s, transform .18s; }
.history-card:hover .history-actions, .history-card:focus-within .history-actions { opacity: 1; transform: translateY(0); }
.history-icon-button { display: grid; width: 34px; height: 34px; place-items: center; border: 1px solid rgba(255,255,255,.72); border-radius: 99px; background: rgba(101,19,19,.82); padding: 0; color: white; box-shadow: 0 8px 20px rgba(49,12,10,.22); }
.history-icon-button svg { width: 17px; height: 17px; fill: currentColor; }
.history-icon-button:hover { background: var(--red-bright); transform: translateY(-1px); }
.history-icon-button.danger { background: rgba(166,30,29,.88); }
.history-card strong, .history-card span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-card .generated-by { margin: 8px 0 0; color: var(--red); font-size: 12px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-card strong { margin-top: 8px; color: var(--red-deep); font-size: 13px; }
.history-card span { margin-top: 4px; color: var(--muted); font-size: 11px; }
.console-view { min-height: calc(100vh - 76px); padding: 62px 0 32px; }
.console-heading { display: flex; justify-content: space-between; align-items: end; gap: 24px; padding: 0 6vw 14px; }
.console-heading h1 { color: var(--red-deep); font-size: clamp(42px, 5vw, 72px); line-height: 1; letter-spacing: -.05em; }
.console-heading p:last-child { max-width: 680px; color: var(--muted); line-height: 1.8; }
.console-back-button { align-self: center; white-space: nowrap; }
.admin-section { margin-bottom: 32px; }
.admin-grid { display: grid; grid-template-columns: minmax(260px, .72fr) minmax(0, 1.28fr); gap: 22px; }
.account-form, .accounts-panel { border: 1px solid var(--line); background: rgba(255,255,255,.38); padding: 18px; }
.account-form h3, .accounts-panel h3 { margin: 0 0 16px; color: var(--red-deep); font-family: Georgia, "STSong", serif; font-size: 21px; }
.accounts-grid { display: grid; gap: 10px; }
.account-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 12px; align-items: center; border-bottom: 1px solid var(--line); padding: 11px 0; }
.account-row:last-child { border-bottom: 0; }
.account-name strong, .account-name span { display: block; }
.account-name strong { color: var(--red-deep); font-size: 14px; }
.account-name span, .account-usage span { margin-top: 4px; color: var(--muted); font-size: 11px; }
.account-usage { min-width: 92px; color: var(--red); text-align: right; font-size: 13px; font-weight: 800; }
.account-actions { display: flex; gap: 7px; }
.secondary-button, .danger-button { padding: 8px 12px; font-size: 12px; }
.secondary-button { border-color: rgba(166,30,29,.18); background: rgba(166,30,29,.08); color: var(--red); }
.danger-button { border-color: rgba(166,30,29,.18); background: transparent; padding: 8px 12px; color: var(--red); font-size: 12px; }
.secondary-button:hover, .danger-button:hover { background: var(--red); color: white; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 900px) {
  .login-grid, .workspace-grid, .admin-grid { grid-template-columns: 1fr; }
  .login-grid { align-content: center; }
  .login-story { padding-top: 64px; }
  .result-panel { min-height: auto; }
  .result-empty, .result-loading { min-height: 280px; }
}
@media (max-width: 540px) {
  .login-shell { padding: 24px; }
  .login-story h1 { font-size: 52px; }
  .hero, .workspace-grid { padding-left: 18px; padding-right: 18px; }
  .topbar { padding: 14px 18px; }
  .brand-lockup.compact img { width: 138px; }
  .brand-lockup.compact p { display: none; }
  .status-chip { display: none; }
  .field-grid { grid-template-columns: 1fr; }
  .wide { grid-column: auto; }
  .submit-row { align-items: flex-start; flex-direction: column; }
  .history-section { margin-left: 18px; margin-right: 18px; }
  .console-heading { align-items: flex-start; flex-direction: column; padding-left: 18px; padding-right: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
