:root {
  --paper: #f3ead9;
  --paper-2: #f8f2e6;
  --paper-3: #e9dcc6;
  --paper-4: #fbf7ee;
  --ink: #1b1510;
  --ink-2: #2b2219;
  --muted: #6d6052;
  --muted-2: #8c7e6d;
  --red: #c33a2b;
  --red-deep: #9e2a20;
  --gold: #c89b52;
  --gold-soft: #e3c995;
  --jade: #2e6b5d;
  --hairline: rgba(27, 21, 16, .14);
  --hairline-strong: rgba(27, 21, 16, .24);
  --font-display: "Songti SC", "STSong", "SimSun", "Noto Serif CJK SC", serif;
  --font-sans: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Noto Sans CJK SC", sans-serif;
  --ease: cubic-bezier(.22, 1, .36, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
body::after {
  content: "";
  position: fixed; inset: 0;
  z-index: 999; pointer-events: none;
  opacity: .03;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='.8'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}
::selection { background: var(--red); color: var(--paper-4); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; }
img { display: block; max-width: 100%; }

.admin-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 18px;
  min-height: 66px;
  padding: 0 24px;
  background: rgba(27, 21, 16, .96);
  color: var(--paper-3);
  border-bottom: 1px solid rgba(243, 234, 217, .12);
  backdrop-filter: blur(16px);
}
.admin-brand { display: flex; align-items: center; gap: 11px; flex: 0 0 auto; }
.admin-seal {
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--red);
  color: var(--paper-4);
  font-family: var(--font-display);
  font-size: 19px; font-weight: 700;
  line-height: 1;
}
.admin-brand strong { display: block; color: var(--paper-4); font-size: 14px; letter-spacing: .05em; }
.admin-brand span { display: block; color: #978874; font-size: 8px; letter-spacing: .14em; }
.admin-tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 8px;
  border: 1px solid rgba(227, 201, 149, .24);
  border-radius: 999px;
  color: var(--gold-soft);
  font-size: 8px;
  letter-spacing: .1em;
  white-space: nowrap;
}
.admin-tag i { width: 5px; height: 5px; border-radius: 50%; background: var(--gold); }
.admin-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.save-state { display: flex; align-items: center; gap: 6px; color: #978874; font-size: 9px; white-space: nowrap; }
.save-state i { width: 5px; height: 5px; border-radius: 50%; background: #7a9b67; }
.save-state.is-dirty i { background: var(--gold); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 7px;
  font-size: 10px;
  letter-spacing: .03em;
  transition: background .2s ease, border-color .2s ease, color .2s ease, transform .2s var(--ease);
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--red); color: var(--paper-4); border-color: var(--red); }
.btn-primary:hover { background: var(--red-deep); border-color: var(--red-deep); }
.btn-ghost { border-color: rgba(243, 234, 217, .2); color: var(--paper-3); background: transparent; }
.btn-ghost:hover { border-color: rgba(243, 234, 217, .45); background: rgba(243, 234, 217, .06); }
.btn-paper { border-color: var(--hairline); background: var(--paper-4); color: var(--ink-2); }
.btn-paper:hover { border-color: var(--ink); }
.btn-danger { border-color: rgba(195, 58, 43, .3); background: transparent; color: var(--red); }
.btn-danger:hover { background: rgba(195, 58, 43, .06); }
.btn-sm { min-height: 26px; padding: 0 8px; font-size: 9px; }
.btn-icon { width: 26px; min-height: 26px; padding: 0; }

.admin-shell {
  display: grid;
  grid-template-columns: 228px minmax(0, 1fr) 392px;
  min-height: calc(100vh - 66px);
}
.admin-sidebar {
  position: sticky; top: 66px;
  display: flex; flex-direction: column;
  height: calc(100vh - 66px);
  padding: 26px 18px 20px;
  background: #17120e;
  color: var(--paper-3);
  border-right: 1px solid rgba(243, 234, 217, .08);
  overflow-y: auto;
}
.side-intro span { color: var(--gold); font-size: 8px; font-weight: 600; letter-spacing: .18em; }
.side-intro h1 { margin-top: 10px; color: var(--paper-4); font-family: var(--font-display); font-size: 26px; line-height: 1.22; letter-spacing: -.04em; }
.side-intro p { margin-top: 12px; color: #978874; font-size: 10px; line-height: 1.8; }
.side-tabs { display: flex; flex-direction: column; gap: 3px; margin-top: 26px; }
.side-tab {
  display: flex; align-items: center; gap: 9px;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #bdb09d;
  font-size: 11px;
  text-align: left;
  transition: background .2s ease, border-color .2s ease, color .2s ease;
}
.side-tab span { color: #837563; font-family: var(--font-display); font-size: 10px; }
.side-tab:hover { background: rgba(243, 234, 217, .05); color: var(--paper-4); }
.side-tab.is-active { background: rgba(195, 58, 43, .14); border-color: rgba(195, 58, 43, .26); color: var(--paper-4); }
.side-tab.is-active span { color: var(--gold-soft); }
.side-status {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid rgba(243, 234, 217, .1);
}
.side-status div { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; color: #837563; font-size: 9px; }
.side-status strong { color: #bdb09d; font-weight: 500; }
.side-note { margin-top: 12px; color: #6f6252; font-size: 8px; line-height: 1.75; }

.admin-main {
  min-width: 0;
  padding: 30px 34px 60px;
  background: var(--paper);
  overflow-y: auto;
  max-height: calc(100vh - 66px);
}
.panel-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; padding-bottom: 18px; border-bottom: 1px solid var(--hairline); }
.panel-head .eyebrow { color: var(--red); font-size: 9px; letter-spacing: .16em; }
.panel-head h2 { margin-top: 6px; font-family: var(--font-display); font-size: 27px; line-height: 1.2; letter-spacing: -.04em; }
.panel-head p { max-width: 310px; color: var(--muted-2); font-size: 10px; line-height: 1.8; text-align: right; }
.tab-panel { padding-top: 24px; }
.tab-panel[hidden] { display: none; }

.form-section { margin-bottom: 28px; padding: 20px; border: 1px solid var(--hairline); border-radius: 12px; background: rgba(255, 255, 255, .28); }
.form-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.form-section-head h3 { font-family: var(--font-display); font-size: 17px; letter-spacing: -.02em; }
.form-section-head span { color: var(--muted-2); font-size: 9px; letter-spacing: .06em; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.is-full { grid-column: 1 / -1; }
.field > span { color: var(--muted); font-size: 9px; letter-spacing: .06em; }
.field > span b { color: var(--muted-2); font-weight: 400; }
.field input, .field select, .field textarea {
  width: 100%;
  min-height: 34px;
  padding: 7px 9px;
  border: 1px solid var(--hairline);
  border-radius: 7px;
  background: var(--paper-4);
  color: var(--ink);
  font-size: 12px;
  line-height: 1.6;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: rgba(195, 58, 43, .5);
  box-shadow: 0 0 0 3px rgba(195, 58, 43, .07);
}
.field textarea { min-height: 76px; resize: vertical; }
.field.is-short textarea { min-height: 58px; }
.field input::placeholder, .field textarea::placeholder { color: #b4a793; }

.stats-editor { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.stat-edit { display: flex; flex-direction: column; gap: 5px; padding: 10px; border: 1px solid var(--hairline); border-radius: 8px; background: var(--paper-4); }
.stat-edit span { color: var(--muted-2); font-size: 8px; letter-spacing: .08em; }
.stat-edit input { min-height: 30px; padding: 5px 7px; }
.stat-edit input + input { border-top: 1px dashed var(--hairline); }

.list-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.list-toolbar p { color: var(--muted-2); font-size: 9px; }
.list-toolbar .btn { margin-left: 0; }
.list-toolbar .btn#addDonor { margin-left: auto; }
.editor-list { display: flex; flex-direction: column; gap: 10px; }
.editor-item {
  border: 1px solid var(--hairline);
  border-radius: 10px;
  background: var(--paper-4);
  overflow: hidden;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.editor-item:hover { border-color: rgba(27, 21, 16, .24); }
.editor-item.is-featured { border-color: rgba(195, 58, 43, .45); box-shadow: 0 0 0 2px rgba(195, 58, 43, .06); }
.editor-item-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--hairline); background: rgba(243, 234, 217, .34); }
.editor-item-head strong { font-size: 10px; letter-spacing: .04em; }
.editor-item-head em { color: var(--muted-2); font-size: 9px; font-style: normal; }
.editor-item-head .item-actions { display: flex; gap: 4px; margin-left: auto; }
.editor-item-body { padding: 12px; }
.editor-item-body .field-grid { gap: 10px; }
.checkline { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 9px; white-space: nowrap; }
.checkline input { width: 15px; height: 15px; min-height: 0; margin: 0; padding: 0; flex: 0 0 auto; accent-color: var(--red); }
.help-note { margin-top: 8px; color: var(--muted-2); font-size: 8.5px; line-height: 1.7; }

.data-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.data-card { padding: 16px; border: 1px solid var(--hairline); border-radius: 10px; background: var(--paper-4); }
.data-card h3 { font-family: var(--font-display); font-size: 17px; }
.data-card p { margin-top: 6px; color: var(--muted); font-size: 10px; line-height: 1.8; }
.data-card .btn { margin-top: 12px; }
.data-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.file-label { display: inline-flex; align-items: center; justify-content: center; min-height: 32px; padding: 0 12px; border: 1px solid var(--hairline); border-radius: 7px; background: var(--paper-4); color: var(--ink-2); font-size: 10px; cursor: pointer; }
.file-label:hover { border-color: var(--ink); }
.file-label input { display: none; }

.admin-preview {
  position: sticky; top: 66px;
  display: flex; flex-direction: column;
  height: calc(100vh - 66px);
  padding: 16px;
  background: #17120e;
  border-left: 1px solid rgba(243, 234, 217, .08);
}
.preview-head { display: flex; align-items: center; gap: 10px; padding-bottom: 10px; color: #bdb09d; font-size: 9px; letter-spacing: .08em; }
.preview-head .btn { margin-left: auto; }
.preview-frame {
  flex: 1;
  min-height: 0;
  border: 1px solid rgba(243, 234, 217, .12);
  border-radius: 12px;
  background: var(--paper);
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .24);
}
.preview-frame iframe { width: 100%; height: 100%; border: 0; display: block; background: var(--paper); }
.preview-note { margin-top: 10px; color: #6f6252; font-size: 8px; line-height: 1.7; }

.toast {
  position: fixed; left: 50%; bottom: 26px; z-index: 1000;
  transform: translate(-50%, 14px);
  max-width: min(90vw, 520px);
  padding: 10px 16px;
  border: 1px solid rgba(243, 234, 217, .16);
  border-radius: 8px;
  background: rgba(27, 21, 16, .96);
  color: var(--paper-3);
  font-size: 10px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, .24);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s var(--ease);
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1180px) {
  .admin-shell { grid-template-columns: 210px minmax(0, 1fr); }
  .admin-preview { grid-column: 1 / -1; position: static; height: 520px; border-left: 0; border-top: 1px solid rgba(243, 234, 217, .1); }
  .admin-main { max-height: none; }
  .admin-sidebar { height: calc(100vh - 66px); }
  .admin-preview .preview-frame { height: 100%; }
}
@media (max-width: 900px) {
  .admin-header { flex-wrap: wrap; gap: 8px 12px; padding: 10px 16px; }
  .admin-actions { width: 100%; margin-left: 0; flex-wrap: wrap; }
  .save-state { margin-left: auto; }
  .admin-shell { display: block; min-height: 0; }
  .admin-sidebar { position: static; height: auto; padding: 16px; }
  .side-intro h1 { font-size: 22px; }
  .side-intro p { display: none; }
  .side-tabs { flex-direction: row; flex-wrap: wrap; margin-top: 14px; }
  .side-tab { width: auto; flex: 1 1 auto; justify-content: center; padding: 8px 9px; }
  .side-tab span { display: none; }
  .side-status, .side-note { display: none; }
  .admin-main { padding: 22px 16px 40px; }
  .panel-head { display: block; }
  .panel-head p { margin-top: 8px; text-align: left; }
  .admin-preview { height: 560px; padding: 12px; }
}
@media (max-width: 620px) {
  .admin-brand-copy { display: block; }
  .admin-brand-copy > span { display: none; }
  .admin-actions .btn { flex: 1 1 auto; }
  .save-state { width: 100%; }
  .field-grid, .stats-editor, .data-grid { grid-template-columns: 1fr; }
  .stat-edit { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
  .stat-edit span { grid-column: 1 / -1; }
  .stat-edit input { min-width: 0; }
  .admin-main { padding: 18px 12px 36px; }
  .form-section { padding: 14px; }
  .editor-item-head { flex-wrap: wrap; }
  .editor-item-head .item-actions { margin-left: 0; width: 100%; }
  .admin-preview { height: 480px; }
  .preview-head { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
