:root {
  --paper: #fffdf9;
  --paper-deep: #fff7ee;
  --ink: #2d2027;
  --muted: #766a70;
  --line: #eadfe1;
  --berry: #d94367;
  --berry-dark: #ad294c;
  --berry-pale: #fff0f3;
  --violet: #7557a8;
  --violet-pale: #f3effb;
  --orange: #f29a4a;
  --orange-pale: #fff1df;
  --green: #487d63;
  --shadow: 0 18px 50px rgba(91, 55, 66, 0.09);
  --radius: 24px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 5% 8%, rgba(242, 154, 74, 0.12), transparent 24rem),
    radial-gradient(circle at 94% 20%, rgba(217, 67, 103, 0.1), transparent 28rem),
    var(--paper);
  font-family: "Noto Sans SC", "Microsoft YaHei UI", sans-serif;
  line-height: 1.6;
}

button, input, select { font: inherit; }
button { color: inherit; }
button:not(:disabled) { cursor: pointer; }

.paper-noise {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.25;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.08'/%3E%3C/svg%3E");
}

.site-header {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  min-height: 84px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; gap: 12px; align-items: center; color: inherit; text-decoration: none; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: white;
  background: var(--berry);
  border-radius: 13px 13px 13px 4px;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 24px;
  font-weight: 700;
  transform: rotate(-3deg);
  box-shadow: 4px 5px 0 var(--orange-pale);
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 18px; letter-spacing: 0.12em; }
.brand small { color: var(--muted); font-size: 12px; letter-spacing: 0.08em; }

.header-actions { display: flex; gap: 12px; align-items: center; }
.mode-badge {
  padding: 7px 12px;
  border: 1px solid #dbcfea;
  border-radius: 999px;
  color: var(--violet);
  background: var(--violet-pale);
  font-size: 12px;
  font-weight: 700;
}
.mode-badge i { display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; background: var(--violet); animation: pulse 1.8s infinite; }

.quiet-button, .mini-button, .text-button, .copy-chip {
  border: 0;
  background: transparent;
}
.quiet-button { padding: 9px 12px; border-radius: 10px; font-size: 14px; }
.quiet-button:hover { background: var(--berry-pale); color: var(--berry-dark); }

.file-mode-notice {
  position: sticky;
  top: 10px;
  z-index: 30;
  width: min(920px, calc(100% - 40px));
  margin: 14px auto 0;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border: 1px solid #e7b975;
  border-radius: 15px;
  color: #684116;
  background: #fff1d8;
  box-shadow: 0 12px 32px rgba(99, 65, 23, 0.14);
}
.file-mode-notice strong, .file-mode-notice span { display: block; }
.file-mode-notice span { margin-top: 2px; font-size: 12px; }
.file-mode-notice a { flex: 0 0 auto; padding: 8px 12px; border-radius: 9px; color: white; background: #a85b18; font-size: 12px; font-weight: 800; text-decoration: none; }

main { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }
.hero { min-height: 390px; display: flex; align-items: center; justify-content: space-between; gap: 60px; padding: 74px 6% 56px; }
.hero-copy { max-width: 720px; animation: rise 0.7s both; }
.eyebrow, .section-index { margin: 0 0 12px; color: var(--berry-dark); font-size: 12px; font-weight: 800; letter-spacing: 0.15em; text-transform: uppercase; }
.eyebrow span { display: inline-grid; place-items: center; width: 28px; height: 28px; margin-right: 8px; border: 1px solid currentColor; border-radius: 50%; }
.hero h1 {
  margin: 0;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: clamp(42px, 6vw, 72px);
  line-height: 1.08;
  font-weight: 700;
  letter-spacing: -0.04em;
}
.hero h1 em { position: relative; color: var(--berry); font-style: normal; white-space: nowrap; }
.hero h1 em::after { content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 9px; z-index: -1; background: var(--orange); opacity: 0.35; transform: rotate(-1deg); border-radius: 50%; }
.hero-description { max-width: 610px; margin: 24px 0 0; color: var(--muted); font-size: 17px; }

.hero-note {
  position: relative;
  flex: 0 0 210px;
  padding: 36px 27px 25px;
  background: #fff2b8;
  box-shadow: 10px 14px 0 rgba(242, 154, 74, 0.14), 0 20px 40px rgba(82, 61, 38, 0.1);
  transform: rotate(3deg);
  animation: float-in 0.8s 0.15s both;
}
.hero-note::after { content: ""; position: absolute; right: -9px; bottom: -10px; border-width: 18px 0 0 20px; border-style: solid; border-color: transparent transparent transparent #e7d584; transform: rotate(-3deg); }
.hero-note .pin { position: absolute; left: 50%; top: 12px; width: 11px; height: 11px; border-radius: 50%; background: var(--berry); box-shadow: 1px 2px 3px rgba(0,0,0,.2); }
.hero-note b { font-size: 13px; color: #806a21; letter-spacing: .08em; }
.hero-note p { margin: 15px 0; font-family: "STKaiti", "KaiTi", serif; font-size: 25px; line-height: 1.45; }
.hero-note small { color: #8d7b44; }

.workbench-grid { display: grid; grid-template-columns: minmax(320px, 0.78fr) minmax(0, 1.22fr); gap: 24px; align-items: start; }
.input-column, .result-column { display: grid; gap: 24px; }
.input-column { position: sticky; top: 18px; }
.panel { border: 1px solid rgba(212, 192, 198, 0.74); border-radius: var(--radius); background: rgba(255,255,255,.88); box-shadow: var(--shadow); overflow: hidden; }
.input-panel, .titles-panel, .article-panel, .assets-panel { padding: 28px; }
.panel-heading { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; margin-bottom: 24px; }
.panel-heading h2, .history-heading h2 { margin: 0; font-family: "STKaiti", "KaiTi", serif; font-size: 28px; line-height: 1.2; }
.required-note { color: var(--muted); font-size: 12px; }

#creatorForm { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 14px; }
.field { display: grid; gap: 7px; min-width: 0; }
.field-wide { grid-column: 1 / -1; }
.field > span, .field legend { color: #51444a; font-size: 13px; font-weight: 700; }
.field b { color: var(--berry); }
.field i { color: var(--muted); font-size: 11px; font-style: normal; font-weight: 400; }
.field small { color: #978a90; font-size: 11px; }
input[type="text"], select {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  outline: none;
  color: var(--ink);
  background: #fffdfa;
  transition: border-color .2s, box-shadow .2s, transform .2s;
}
input[type="text"]:focus, select:focus { border-color: var(--berry); box-shadow: 0 0 0 4px rgba(217,67,103,.1); }
input.invalid, select.invalid { border-color: var(--berry); background: var(--berry-pale); }
.length-field { margin: 0; padding: 0; border: 0; }
.length-field legend { margin-bottom: 7px; }
.segmented-control { display: grid; grid-template-columns: repeat(3, 1fr); padding: 4px; border: 1px solid var(--line); border-radius: 14px; background: #fbf7f4; }
.segmented-control input { position: absolute; opacity: 0; }
.segmented-control span { display: grid; place-items: center; padding: 7px 2px; border-radius: 10px; color: var(--muted); font-size: 13px; transition: .2s; }
.segmented-control small { display: block; font-size: 9px; }
.segmented-control input:checked + span { color: var(--berry-dark); background: white; box-shadow: 0 4px 12px rgba(93,60,70,.1); font-weight: 700; }
.form-error { grid-column: 1 / -1; padding: 10px 12px; border-radius: 10px; color: var(--berry-dark); background: var(--berry-pale); font-size: 13px; }
.form-actions { grid-column: 1 / -1; display: flex; align-items: center; gap: 18px; padding-top: 4px; }
.primary-button, .secondary-button {
  min-height: 49px;
  padding: 0 19px;
  border-radius: 14px;
  font-weight: 800;
  transition: transform .2s, box-shadow .2s, opacity .2s;
}
.primary-button { display: inline-flex; align-items: center; justify-content: space-between; gap: 28px; border: 1px solid var(--berry); color: white; background: var(--berry); box-shadow: 0 8px 0 #a92849; }
.primary-button:not(:disabled):hover { transform: translateY(-2px); box-shadow: 0 10px 0 #a92849; }
.primary-button:not(:disabled):active { transform: translateY(5px); box-shadow: 0 3px 0 #a92849; }
.primary-button:disabled, .secondary-button:disabled, .mini-button:disabled { cursor: not-allowed; opacity: .45; }
.primary-button.compact { min-height: 43px; box-shadow: 0 5px 0 #a92849; }
.text-button { color: var(--muted); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }

.progress-panel { padding: 23px 26px; background: #2f2632; color: white; }
.progress-panel .section-index { color: #d7c8ea; }
.progress-topline { display: flex; justify-content: space-between; align-items: flex-start; }
.progress-topline h2 { margin: 0; font-family: "STKaiti", "KaiTi", serif; font-size: 25px; }
#progressPercent { color: #d7c8ea; font-size: 13px; }
.progress-track { height: 5px; margin: 18px 0 20px; overflow: hidden; border-radius: 99px; background: rgba(255,255,255,.12); }
.progress-track i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #f07490, #f7b15f); transition: width .45s ease; }
.progress-steps { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.progress-steps li { display: flex; gap: 10px; align-items: center; color: #9e929f; font-size: 12px; }
.progress-steps span { display: grid; place-items: center; width: 23px; height: 23px; border: 1px solid #605665; border-radius: 50%; font-size: 10px; }
.progress-steps li.active { color: white; font-weight: 700; }
.progress-steps li.active span { border-color: #f07490; background: #f07490; }
.progress-steps li.done { color: #b7d6c4; }
.progress-steps li.done span { border-color: var(--green); background: var(--green); }
.progress-message { margin: 17px 0 0; padding-top: 14px; border-top: 1px dashed #544a56; color: #c8bdc9; font-size: 12px; }

.result-heading { align-items: center; }
.mini-button { padding: 7px 10px; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); background: white; font-size: 12px; white-space: nowrap; }
.mini-button:not(:disabled):hover { color: var(--berry-dark); border-color: #e6a8b7; background: var(--berry-pale); }
.empty-state { display: grid; place-items: center; min-height: 235px; padding: 30px; border: 1px dashed #dccdd1; border-radius: 18px; text-align: center; background: linear-gradient(135deg, rgba(255,247,238,.6), rgba(255,240,243,.5)); }
.empty-state b { font-family: "STKaiti", "KaiTi", serif; font-size: 20px; }
.empty-state p { max-width: 330px; margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.empty-doodle { color: var(--orange); font-size: 38px; transform: rotate(12deg); }
.compact-empty { min-height: 150px; }
.compact-empty > span { color: #c6b5ba; font-family: Georgia, serif; font-size: 28px; }
.title-list { display: grid; gap: 10px; }
.title-option { position: relative; display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; align-items: center; min-height: 68px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 15px; background: #fffdfa; transition: border-color .2s, transform .2s, box-shadow .2s; }
.title-option:hover { transform: translateX(3px); border-color: #e6a8b7; }
.title-option.selected { border-color: var(--berry); background: var(--berry-pale); box-shadow: 4px 5px 0 rgba(217,67,103,.09); }
.title-option input { position: absolute; opacity: 0; }
.title-number { display: grid; place-items: center; width: 31px; height: 31px; border-radius: 9px; color: var(--violet); background: var(--violet-pale); font-family: Georgia, serif; font-size: 12px; font-weight: 700; }
.title-copy { min-width: 0; }
.title-copy b { display: block; line-height: 1.45; font-size: 14px; }
.title-copy small { color: var(--muted); font-size: 10px; }
.icon-copy { width: 34px; height: 34px; border: 0; border-radius: 9px; color: var(--muted); background: white; }
.icon-copy:hover { color: var(--berry); background: #f9e5ea; }
.title-actions { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 20px; padding-top: 18px; border-top: 1px dashed var(--line); }
.title-actions p { margin: 0; color: var(--muted); font-size: 12px; }

.inline-actions { display: flex; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
.article-result { border-radius: 18px; background: #fffdf9; }
.article-title-line { padding: 18px 20px; border-left: 4px solid var(--berry); background: var(--berry-pale); }
.article-title-line h3 { margin: 0; font-family: "STKaiti", "KaiTi", serif; font-size: 24px; line-height: 1.35; }
.article-title-line span { color: var(--muted); font-size: 11px; }
.article-body { max-height: 570px; overflow: auto; padding: 22px 20px; white-space: pre-wrap; line-height: 1.95; font-size: 14px; scrollbar-color: #dfb1bd transparent; }
.disclaimer { margin: 0; padding: 13px 20px; border-top: 1px dashed var(--line); color: #8e777d; background: var(--orange-pale); font-size: 11px; }

.assets-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.asset-card { min-width: 0; padding: 18px; border: 1px solid var(--line); border-radius: 17px; background: #fffdfa; }
.asset-label { margin-bottom: 12px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .12em; }
.cover-card { position: relative; overflow: hidden; background: var(--berry); color: white; }
.cover-card::after { content: "✦"; position: absolute; right: -6px; top: -18px; color: rgba(255,255,255,.16); font-size: 100px; }
.cover-card .asset-label { color: #ffd9e2; }
.cover-card h3 { position: relative; z-index: 1; margin: 0; max-width: 85%; font-family: "STKaiti", "KaiTi", serif; font-size: 28px; line-height: 1.15; }
.cover-card p { position: relative; z-index: 1; margin: 8px 0 20px; font-size: 12px; }
.copy-chip { position: relative; z-index: 1; padding: 6px 10px; border-radius: 8px; color: var(--berry-dark); background: white; font-size: 11px; font-weight: 700; }
.prompt-item { padding: 12px 0; border-top: 1px dashed var(--line); }
.prompt-item:first-child { padding-top: 0; border-top: 0; }
.prompt-item b { display: block; color: var(--violet); font-size: 12px; }
.prompt-item p { margin: 5px 0 8px; color: var(--muted); font-size: 11px; line-height: 1.65; }
.prompt-copy { border: 0; padding: 0; color: var(--berry-dark); background: transparent; font-size: 11px; font-weight: 700; }
.tag-list { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 18px; }
.tag-list span { padding: 5px 8px; border-radius: 8px; color: var(--violet); background: var(--violet-pale); font-size: 11px; }
.time-card { background: var(--orange-pale); border-color: #f2d1a4; }
.time-card strong { display: block; color: #a45b18; font-family: "STKaiti", "KaiTi", serif; font-size: 23px; }
.time-card p { margin: 8px 0 0; color: #806344; font-size: 12px; }

.final-actions { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 20px 24px; border: 1px solid #d8c9e8; border-radius: 20px; background: var(--violet-pale); box-shadow: var(--shadow); }
.final-actions b, .final-actions span { display: block; }
.final-actions span { color: var(--muted); font-size: 12px; }
.final-buttons { display: flex; gap: 11px; }
.secondary-button { border: 1px solid #c7b5dc; color: var(--violet); background: white; }
.secondary-button:hover { transform: translateY(-2px); box-shadow: 0 7px 16px rgba(86,61,116,.12); }

.history-section { margin: 90px 0 60px; padding-top: 38px; border-top: 1px solid var(--line); }
.history-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; margin-bottom: 28px; }
.history-heading h2 { font-size: 39px; }
.history-heading p:not(.eyebrow) { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.history-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; }
.history-card { position: relative; display: flex; min-height: 210px; flex-direction: column; padding: 21px; border: 1px solid var(--line); border-radius: 19px; background: rgba(255,255,255,.88); box-shadow: 0 9px 26px rgba(91,55,66,.06); transition: transform .2s, box-shadow .2s; }
.history-card:hover { transform: translateY(-4px) rotate(-.3deg); box-shadow: var(--shadow); }
.history-card:nth-child(3n+2) { transform: rotate(.5deg); }
.history-card:nth-child(3n+2):hover { transform: translateY(-4px) rotate(0); }
.history-meta { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 10px; }
.history-card h3 { margin: 15px 0 7px; font-family: "STKaiti", "KaiTi", serif; font-size: 21px; line-height: 1.35; }
.history-card p { display: -webkit-box; margin: 0 0 17px; overflow: hidden; color: var(--muted); font-size: 12px; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.history-buttons { display: flex; gap: 8px; margin-top: auto; }
.history-buttons button { border: 1px solid var(--line); padding: 6px 9px; border-radius: 8px; background: white; font-size: 11px; }
.history-buttons button:hover { border-color: #e6a8b7; color: var(--berry-dark); }
.history-buttons .delete-button:hover { border-color: var(--berry); color: white; background: var(--berry); }
.history-empty { display: grid; place-items: center; min-height: 160px; border: 1px dashed var(--line); border-radius: 20px; color: var(--muted); text-align: center; }
.history-empty span { font-size: 32px; }
.history-empty p { margin: 4px; font-size: 13px; }

footer { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 24px 0 35px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 20px; color: var(--muted); font-size: 11px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 20; max-width: min(380px, calc(100% - 40px)); padding: 12px 17px; border-radius: 12px; color: white; background: #2f2632; box-shadow: 0 15px 40px rgba(47,38,50,.25); font-size: 13px; opacity: 0; transform: translateY(16px); pointer-events: none; transition: .25s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--berry-dark); }
.is-loading { position: relative; pointer-events: none; }
.is-loading span { opacity: .25; }
.is-loading::after { content: ""; position: absolute; left: 50%; top: 50%; width: 17px; height: 17px; margin: -9px; border: 2px solid rgba(255,255,255,.4); border-top-color: white; border-radius: 50%; animation: spin .7s linear infinite; }

@keyframes rise { from { opacity: 0; transform: translateY(22px); } to { opacity: 1; transform: none; } }
@keyframes float-in { from { opacity: 0; transform: translateY(24px) rotate(7deg); } to { opacity: 1; transform: rotate(3deg); } }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px rgba(117,87,168,.12); } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 940px) {
  .hero { padding-inline: 2%; }
  .workbench-grid { grid-template-columns: 1fr; }
  .input-column { position: static; }
  .history-list { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 650px) {
  .site-header, main, footer { width: min(100% - 24px, 1180px); }
  .site-header { min-height: 70px; }
  .brand small, .mode-badge { display: none; }
  .brand-mark { width: 37px; height: 37px; }
  .quiet-button { padding-inline: 6px; }
  .file-mode-notice { align-items: stretch; flex-direction: column; width: calc(100% - 24px); }
  .file-mode-notice a { text-align: center; }
  .hero { min-height: auto; padding: 50px 7px 40px; }
  .hero h1 { font-size: 42px; }
  .hero-description { font-size: 14px; }
  .hero-note { display: none; }
  .panel { border-radius: 19px; }
  .input-panel, .titles-panel, .article-panel, .assets-panel { padding: 20px 16px; }
  .panel-heading { display: block; }
  .panel-heading h2 { font-size: 24px; }
  .result-heading .mini-button, .result-heading .inline-actions { margin-top: 14px; }
  #creatorForm { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
  .form-error, .form-actions { grid-column: auto; }
  .segmented-control small { display: none; }
  .form-actions { justify-content: space-between; }
  .primary-button { gap: 18px; }
  .title-option { grid-template-columns: 31px 1fr auto; padding-inline: 8px; }
  .title-actions, .final-actions, .history-heading { align-items: stretch; flex-direction: column; }
  .title-actions .primary-button, .final-buttons > button { flex: 1; }
  .assets-grid { grid-template-columns: 1fr; }
  .inline-actions { justify-content: flex-start; }
  .article-body { max-height: none; }
  .history-section { margin-top: 60px; }
  .history-heading { display: flex; }
  .history-list { grid-template-columns: 1fr; }
  footer { flex-direction: column; }
  .toast { right: 12px; bottom: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
