:root {
  --primary: #D1251A;
  --primary-dark: #8E1C17;
  --deep: #6F1511;
  --light: #F4E6D6;
  --bg: #F7F3EA;
  --surface: #fff;
  --text: #1E1916;
  --muted: #6b7280;
  --border: #E8E0D6;
  --danger: #c04444;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--text); background: var(--bg); }
.hidden { display: none !important; }
button, input, textarea, select { font: inherit; }
button, .button { min-height: 40px; padding: 0 17px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 999px; cursor: pointer; text-decoration: none; transition: .18s ease; }
.primary { color: white; background: var(--primary-dark); }
.primary:hover { background: var(--deep); transform: translateY(-1px); }
.ghost { color: var(--primary-dark); background: transparent; border: 1px solid var(--border); }
.ghost:hover { border-color: var(--primary); }
.small { min-height: 34px; padding-inline: 13px; font-size: 12px; }
.error { min-height: 20px; color: var(--danger); font-size: 13px; }
.login { min-height: 100vh; padding: 24px; display: grid; place-items: center; background: linear-gradient(135deg, #faf8f4, var(--light)); }
.login-card { width: min(420px, 100%); padding: 42px; display: grid; gap: 16px; background: white; border: 1px solid var(--border); border-radius: 22px; box-shadow: 0 24px 60px rgba(75,34,26,.12); }
.brand-mark { color: var(--primary); font-size: 14px; font-weight: 700; letter-spacing: .18em; }
.login-card h1 { margin: 0; font-size: 30px; }
.login-card p { margin: -8px 0 4px; color: var(--muted); }
.login-card label, .field-panel label, .field-label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; }
.captcha-row { display: flex; align-items: stretch; gap: 10px; }
.captcha-row input { min-width: 0; flex: 1; text-transform: uppercase; }
#captcha-image { width: 132px; height: 46px; flex: 0 0 auto; cursor: pointer; background: var(--light); border: 1px solid var(--border); border-radius: 9px; }
input, textarea, select { width: 100%; padding: 11px 13px; color: var(--text); background: white; border: 1px solid var(--border); border-radius: 9px; }
input:focus, textarea:focus, select:focus { outline: 2px solid rgba(209,37,26,.14); border-color: var(--primary); }
.topbar { min-height: 68px; padding: 12px 28px; position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 22px; color: white; background: #1E1916; }
.topbar > div:first-child { display: flex; align-items: center; gap: 13px; }
.topbar strong { color: var(--primary); font-size: 19px; }
.topbar span { font-size: 13px; opacity: .76; }
.top-actions { display: flex; align-items: center; gap: 9px; }
.topbar .ghost { color: white; border-color: rgba(255,255,255,.24); }
.pending-badge { padding: 5px 10px; color: #ffe49b; background: rgba(255,206,94,.12); border: 1px solid rgba(255,206,94,.3); border-radius: 999px; }
.view { width: min(1120px, calc(100% - 40px)); margin: 0 auto; padding: 44px 0 70px; }
.view-head { margin-bottom: 26px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.view-head p { margin: 0 0 5px; color: var(--primary-dark); font-size: 11px; font-weight: 700; letter-spacing: .16em; }
.view-head h1 { margin: 0; font-size: 30px; }
.view-actions { display: flex; gap: 9px; }
.import-status { min-height: 20px; margin: -16px 0 12px; color: var(--muted); font-size: 13px; text-align: right; }
.article-list { display: grid; gap: 10px; }
.article-row { padding: 18px 20px; display: flex; align-items: center; justify-content: space-between; gap: 20px; background: white; border: 1px solid var(--border); border-radius: 14px; }
.article-summary { min-width: 0; flex: 1; }
.article-row h2 { margin: 0 0 8px; font-size: 17px; }
.article-row p { margin: 0; display: flex; flex-wrap: wrap; gap: 8px 13px; align-items: center; color: var(--muted); font-size: 12px; }
.article-row code { color: #9a8d7e; }
.status { padding: 2px 8px; border-radius: 999px; }
.status.live { color: #8E1C17; background: #FBE7E3; }
.status.new-draft { color: #916300; background: #fff2c7; }
.status.edited-draft { color: #9c4c22; background: #ffeadc; }
.row-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.row-actions button:disabled { cursor: default; opacity: .48; transform: none; }
.row-more-actions summary { min-height: 34px; padding-inline: 13px; font-size: 12px; }
.row-more-actions .action-menu { top: calc(100% + 8px); bottom: auto; z-index: 12; }
.empty { padding: 70px; color: var(--muted); text-align: center; background: white; border: 1px dashed var(--border); border-radius: 14px; }
#edit-form { display: grid; gap: 18px; }
.field-panel, .editor-panel { padding: 24px; background: white; border: 1px solid var(--border); border-radius: 16px; }
.field-panel { display: grid; gap: 15px; }
.field-panel small { font-weight: 400; opacity: .8; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.custom-select { position: relative; }
.select-trigger { width: 100%; padding: 0 13px; justify-content: space-between; color: var(--text); background: white; border: 1px solid var(--border); border-radius: 9px; text-align: left; }
.select-trigger:hover, .custom-select.open .select-trigger { border-color: var(--primary); }
.custom-select.open .select-trigger { outline: 2px solid rgba(209,37,26,.14); }
.select-chevron { color: var(--muted); transition: transform .18s ease; }
.custom-select.open .select-chevron { transform: rotate(180deg); }
.select-menu { width: 100%; margin-top: 7px; position: absolute; z-index: 20; overflow: hidden; background: white; border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 18px 45px rgba(75,34,26,.16); }
.select-options { max-height: 220px; padding: 7px; display: grid; gap: 2px; overflow-y: auto; }
.select-option { width: 100%; min-height: 40px; padding: 0 11px; justify-content: space-between; color: var(--text); background: transparent; border-radius: 8px; }
.select-option:hover { background: #FAF3E8; }
.select-option[aria-selected="true"] { color: var(--primary-dark); background: #FBE7E3; font-weight: 600; }
.option-check { opacity: 0; color: var(--primary-dark); }
.select-option[aria-selected="true"] .option-check { opacity: 1; }
.category-create { padding: 12px; background: #FAF7F1; border-top: 1px solid var(--border); }
.category-create > span { display: block; margin-bottom: 8px; color: var(--text); font-weight: 600; }
.category-create > div { display: flex; gap: 8px; }
.category-create input { min-width: 0; }
.category-create button { min-width: 68px; flex: 0 0 auto; white-space: nowrap; }
.category-create .error { min-height: 0; margin: 6px 2px 0; }
.editor-titlebar { align-items: flex-end; }
.editor-titlebar > div { display: grid; gap: 12px; }
.editor-titlebar > .status { margin-bottom: 4px; padding: 6px 12px; font-size: 13px; }
.back-button { min-height: auto; width: max-content; padding: 0; color: var(--muted); background: transparent; border-radius: 0; }
.back-button:hover { color: var(--primary-dark); }
.version-note { margin: -12px 0 18px; padding: 13px 16px; color: #6b5a4f; background: #F8EEE6; border: 1px solid var(--border); border-radius: 11px; font-size: 13px; }
.auto-meta { margin: 0; padding: 11px 13px; color: var(--muted); background: #FAF7F1; border-radius: 9px; font-size: 12px; }
.editor-head { margin-bottom: 13px; display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.editor-head > div { display: flex; align-items: center; gap: 9px; }
.editor-head small { color: var(--muted); font-size: 12px; font-weight: 400; }
#upload-status { color: var(--muted); font-size: 12px; }
.editor-grid { min-height: 480px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
#body { min-height: 480px; resize: vertical; font-family: inherit; font-size: 15px; line-height: 1.8; }
.preview { padding: 22px; overflow: auto; background: #fbfaf7; border: 1px solid var(--border); border-radius: 9px; line-height: 1.8; }
.preview:empty::before { content: "文章预览会显示在这里"; color: var(--muted); }
.preview h1, .preview h2, .preview h3 { color: var(--primary-dark); }
.preview img { max-width: 100%; }
.edit-actions { padding: 15px 18px; position: sticky; bottom: 14px; z-index: 5; display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,.96); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 12px 32px rgba(75,34,26,.1); backdrop-filter: blur(10px); }
.save-button { background: white; }
.more-actions { position: relative; }
.more-actions summary { min-height: 40px; padding: 0 15px; display: flex; align-items: center; color: var(--muted); background: white; border: 1px solid var(--border); border-radius: 999px; cursor: pointer; font-size: 13px; list-style: none; }
.more-actions summary::-webkit-details-marker { display: none; }
.more-actions summary::after { content: "⌄"; margin-left: 7px; transition: transform .18s ease; }
.more-actions[open] summary::after { transform: rotate(180deg); }
.more-actions[open] summary { color: var(--primary-dark); border-color: var(--primary); }
.action-menu { min-width: 180px; padding: 7px; position: absolute; right: 0; bottom: calc(100% + 8px); display: grid; gap: 2px; background: white; border: 1px solid var(--border); border-radius: 11px; box-shadow: 0 14px 36px rgba(75,34,26,.16); }
.menu-action { width: 100%; min-height: 38px; padding: 0 11px; justify-content: flex-start; color: var(--text); background: transparent; border-radius: 7px; font-size: 13px; }
.menu-action:hover { background: #FAF1EA; }
.menu-action.danger { color: var(--danger); }
.menu-action.danger:hover { background: #fff0f0; }
#message { margin-left: 8px; color: var(--muted); font-size: 13px; }
.modal { position: fixed; inset: 0; z-index: 30; padding: 20px; display: grid; place-items: center; background: rgba(0,0,0,.6); }
.modal-card { width: min(780px, 100%); max-height: 82vh; background: white; border-radius: 16px; overflow: hidden; }
.modal-card > div { padding: 15px 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.category-manager { width: min(680px, 100%); }
.modal-card > .modal-head { padding: 18px 20px; }
.modal-head > div { display: grid; gap: 4px; }
.modal-head small { color: var(--muted); font-size: 12px; font-weight: 400; }
.password-card { width: min(500px, 100%); }
.modal-card > .password-form { padding: 20px; display: grid; gap: 14px; border: 0; }
.password-form label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; }
.password-hint { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.password-form .error { margin: -4px 0 0; }
.password-actions { display: flex; justify-content: flex-end; gap: 9px; }
.modal-card > .category-manager-body { max-height: 68vh; padding: 20px; display: block; overflow-y: auto; border: 0; }
.manager-create { display: flex; gap: 9px; }
.manager-create input { min-width: 0; }
.manager-create button { flex: 0 0 auto; white-space: nowrap; }
.category-manager-list { margin-top: 8px; display: grid; gap: 8px; }
.category-manager-row { padding: 13px 14px; background: #FAF7F1; border: 1px solid var(--border); border-radius: 11px; }
.category-row-main { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.category-row-name { min-width: 0; display: grid; gap: 3px; }
.category-row-name strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.category-row-name span { color: var(--muted); font-size: 12px; }
.category-row-actions { display: flex; gap: 5px; }
.category-row-actions button { min-height: 32px; padding-inline: 10px; font-size: 12px; }
.category-row-actions .danger { color: var(--danger); }
.category-row-actions button:disabled { cursor: not-allowed; opacity: .45; }
.category-inline-panel { margin-top: 11px; padding-top: 11px; display: grid; gap: 9px; border-top: 1px solid var(--border); }
.category-inline-panel p { margin: 0; color: var(--muted); font-size: 12px; }
.category-rename-form { display: flex; gap: 8px; }
.category-rename-form input { min-width: 0; }
.category-inline-actions, .replacement-options { display: flex; flex-wrap: wrap; gap: 7px; }
.category-inline-actions button, .replacement-options button { min-height: 32px; padding-inline: 11px; font-size: 12px; }
.confirm-danger { color: white; background: var(--danger); }
.replacement-options button { color: var(--primary-dark); background: white; border: 1px solid var(--border); }
.replacement-options button:hover { border-color: var(--primary); background: #FBEAE6; }
.build-card { width: min(780px, 100%); }
#build-log { max-height: 62vh; margin: 0; padding: 18px; overflow: auto; color: var(--muted); background: #faf7f1; white-space: pre-wrap; font-size: 12px; }
@media (max-width: 760px) {
  .topbar, .view-head, .article-row { align-items: flex-start; flex-direction: column; }
  .top-actions { width: 100%; flex-wrap: wrap; }
  .view-actions { width: 100%; }
  .view-actions button { flex: 1; }
  .field-row, .editor-grid { grid-template-columns: 1fr; }
  .view { width: min(100% - 28px, 1120px); padding-top: 28px; }
  .row-actions { width: 100%; }
  .row-actions > button, .row-more-actions { flex: 1; }
  .row-more-actions summary { width: 100%; justify-content: center; }
  .edit-actions { flex-wrap: wrap; }
  #message { width: 100%; margin: 4px 0 0; }
  .login-card { padding: 30px 24px; }
  .manager-create, .category-row-main, .category-rename-form { align-items: stretch; flex-direction: column; }
}
