*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", sans-serif;
  background: #f3ede4;
  color: #333;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
}

.app {
  max-width: 500px;
  margin: 0 auto;
  padding: 0 16px;
}

.app-header {
  text-align: center;
  padding: 16px 0 12px;
}

.app-header h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #5c4a3d;
}

.app-header h1 .brand {
  color: #5c4a3d;
}

.app-header h1 .subtitle-part {
  color: #8b7c69;
  font-weight: 400;
  font-size: 16px;
}

.header-wrapper {
  display: inline-flex;
  align-items: flex-start;
  justify-content: center;
  position: relative;
}

.version-badge {
  position: absolute;
  top: 2px;
  right: -60px;
  padding: 0 6px;
  font-size: 10px;
  line-height: 16px;
  font-weight: 500;
  color: #c0392b;
  border: 1px solid #e74c3c;
  border-radius: 3px;
  background: transparent;
  cursor: pointer;
}

/* Version modal */
.version-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.version-modal {
  background: #fff;
  border-radius: 16px;
  padding: 24px 24px 20px;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}
.version-modal h3 {
  margin: 0 0 12px;
  font-size: 17px;
  color: #3d3028;
  font-weight: 700;
}
.version-modal .version-tag {
  display: inline-block;
  padding: 0 6px;
  font-size: 10px;
  line-height: 16px;
  font-weight: 500;
  color: #c0392b;
  border: 1px solid #e74c3c;
  border-radius: 3px;
  vertical-align: middle;
  margin-left: 6px;
}
.version-modal .version-status {
  font-size: 13px;
  color: #8b7c69;
  margin: 0 0 14px;
}
.version-modal ul {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
}
.version-modal li {
  font-size: 13px;
  color: #5c4a3d;
  line-height: 1.8;
  padding-left: 16px;
  position: relative;
}
.version-modal li::before {
  content: "•";
  position: absolute;
  left: 0;
  color: #8b7c69;
}
.version-modal .modal-close-btn {
  display: block;
  width: 100%;
  padding: 10px 0;
  border: none;
  border-radius: 10px;
  background: #f3ede4;
  color: #6b5546;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.app-main {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.layout-main {
  background: rgba(255, 255, 255, 0.88);
  border-radius: 16px;
  padding: 20px 20px 16px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.section-title {
  margin: 0 0 20px;
  font-size: 18px;
  font-weight: 700;
  color: #3d3028;
}

.form-grid {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field-label {
  font-size: 14px;
  font-weight: 500;
  color: #3d3028;
  display: flex;
  align-items: center;
  gap: 4px;
}

.field-hint {
  font-size: 12px;
  color: #a09586;
  font-weight: 400;
}

.field-required {
  color: #c0392b;
  font-weight: 600;
}

.text-input,
.text-area {
  width: 100%;
  min-width: 0;
  border-radius: 10px;
  border: 1px solid #e0d7cc;
  background-color: #faf8f5;
  color: #333;
  padding: 12px 14px;
  font-size: 16px;
  line-height: 1.5;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
  -webkit-appearance: none;
}

input.text-input,
select.text-input {
  height: 48px;
}

select.text-input {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' fill='none' stroke='%23999' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.text-input::placeholder,
.text-area::placeholder {
  color: #b5aa9e;
}

.text-input:focus,
.text-area:focus {
  border-color: #c4956e;
  box-shadow: 0 0 0 3px rgba(196, 149, 110, 0.15);
  background-color: #fff;
}

.text-area {
  resize: vertical;
  min-height: 140px;
  height: auto;
  font-size: 16px;
}

.char-count {
  text-align: right;
  display: block;
  margin-top: 2px;
}

/* Buttons */
.btn {
  border-radius: 12px;
  border: none;
  padding: 8px 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #6b5546;
  color: #fff;
  transition: background 0.2s, transform 0.1s, opacity 0.2s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn.primary {
  background: #6b5546;
  color: #fff;
}

.btn.primary:active {
  transform: scale(0.98);
  background: #5a4639;
}

.btn.ghost {
  background: transparent;
  color: #6b5546;
  border: 1px solid #d4c9bc;
}

.btn.ghost:active {
  background: rgba(107, 85, 70, 0.08);
}

.btn.small {
  padding: 6px 14px;
  font-size: 13px;
  border-radius: 8px;
  white-space: nowrap;
}

.btn.large {
  padding: 14px 24px;
  font-size: 16px;
}

.btn.full-width {
  width: 100%;
  height: 50px;
  font-size: 16px;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.btn.danger {
  background: #78706a;
}

.btn.danger:active {
  background: #665e58;
}

.actions {
  margin-top: 20px;
}

.status-text {
  font-size: 13px;
  color: #9a8b79;
  text-align: center;
  display: block;
  margin-top: 10px;
  min-height: 20px;
}

.status-text.error {
  color: #c0392b;
}

.status-text.success {
  color: #2e7d32;
}

/* Success card */
.success-card {
  text-align: center;
  padding: 48px 20px;
}

.success-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #5a9e6f;
  color: white;
  font-size: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
  line-height: 1;
}

.success-card h2 {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 700;
  color: #3d3028;
}

.success-card p {
  margin: 0 0 32px;
  font-size: 15px;
  color: #8b7c69;
}

/* Admin: Login section */
.login-section {
  margin-bottom: 20px;
}

.divider {
  margin: 16px 0;
  border: 0;
  border-top: 1px dashed #e0d7c8;
}

.user-info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  color: #5f574c;
}

/* Admin: Submission cards */
.submission-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.submission-card {
  background: #fff;
  border: 1px solid #ebe5dc;
  border-radius: 12px;
  padding: 14px 16px;
  cursor: pointer;
  transition: background 0.15s;
}

.submission-card:active {
  background: #f8f3ed;
}

.submission-card-title {
  font-size: 15px;
  font-weight: 600;
  color: #3d3028;
  margin-bottom: 6px;
  word-break: break-all;
}

.submission-card-content {
  font-size: 14px;
  color: #5f574c;
  line-height: 1.6;
  word-break: break-all;
  white-space: pre-wrap;
}

.submission-card-content.truncated {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.submission-meta {
  font-size: 12px;
  color: #a09586;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
  align-items: center;
}

.submission-meta span {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: #f5f0ea;
  padding: 2px 8px;
  border-radius: 4px;
}

.submission-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
  gap: 8px;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin-top: 16px;
  font-size: 14px;
  color: #666;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #a09586;
  font-size: 14px;
}

/* 排版预览 */
#wemd-wrapper.theme-beige {
  --preview-bg: #fdfdf3; --preview-text: #4c453c; --preview-border: #e2e0d3;
  --preview-footer: #bcbbb2; --preview-disclaimer: #c8c3b8; --preview-title: #4c453c;
}
#wemd-wrapper.theme-white {
  --preview-bg: #ffffff; --preview-text: #3c3c3c; --preview-border: #c8c8c8;
  --preview-footer: #787878; --preview-disclaimer: #787878; --preview-title: #282828;
}

#wemd-wrapper {
  background: var(--preview-bg, #fdfdf3);
  padding: 10px;
  border-radius: 8px;
  overflow: hidden;
}

#wemd {
  background-color: var(--preview-bg, #fdfdf3);
  color: var(--preview-text, #4c453c);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 18px;
  line-height: 1.75;
  word-break: break-word;
  padding: 20px 19px;
  border: 1px solid var(--preview-border, #e2e0d3);
  outline: 1px solid var(--preview-border, #e2e0d3);
  outline-offset: 3px;
  box-sizing: border-box;
  box-shadow: 0 0 0 10px var(--preview-bg, #fdfdf3);
  margin: 10px;
}
#wemd p {
  margin: 0 0 12px 0;
  color: var(--preview-text, #4c453c);
  font-size: 18px;
  line-height: 1.75;
  background-color: var(--preview-bg, #fdfdf3);
}
#wemd p:last-child { margin-bottom: 0; }
#wemd h1, #wemd h2, #wemd h3, #wemd h4, #wemd h5, #wemd h6 {
  margin: 0 0 12px 0;
  padding: 0;
  font-weight: bold;
  color: var(--preview-title, #4c453c);
  background-color: var(--preview-bg, #fdfdf3);
}
#wemd h1 { font-size: 22px; }
#wemd h2 { font-size: 18px; }
#wemd h3 { font-size: 18px; }
#wemd h4 { font-size: 17px; }
#wemd h5, #wemd h6 { font-size: 16px; }
#wemd strong { font-weight: bold; color: var(--preview-text, #4c453c); }
#wemd ul, #wemd ol {
  margin: 12px 0;
  padding-left: 25px;
  color: var(--preview-text, #4c453c);
  background-color: var(--preview-bg, #fdfdf3);
}
#wemd li { margin: 6px 0; background-color: var(--preview-bg, #fdfdf3); }
#wemd blockquote {
  margin: 15px 0;
  padding: 15px;
  border-left: 3px solid var(--preview-border, #e2e0d3);
  background-color: var(--preview-bg, #fdfdf3);
}
#wemd a { color: var(--preview-text, #4c453c); text-decoration: underline; }
#wemd hr {
  margin: 20px 0;
  border: none;
  border-top: 1px solid var(--preview-border, #e2e0d3);
}
#wemd .campus-header {
  font-size: 12px;
  color: var(--preview-footer, #bcbbb2);
  letter-spacing: 1px;
  margin: 14px 0 5px 0;
  padding: 0 6px;
  line-height: 1;
}
#wemd .campus-spacer {
  min-height: 3px;
  margin: 0;
  padding: 0;
}
#wemd .campus-author-info {
  font-size: 12px;
  color: var(--preview-footer, #bcbbb2);
  letter-spacing: 1px;
  margin: 0;
  padding: 0 6px;
  line-height: 1;
}
#wemd .campus-author-info p {
  margin: 0;
  font-size: 12px;
  color: var(--preview-footer, #bcbbb2);
  line-height: 1;
}
.campus-footer-disclaimer {
  font-size: 12px;
  color: var(--preview-disclaimer, #c8c3b8);
  line-height: 1.8;
  letter-spacing: 1px;
  margin: 12px 0 0 0;
  padding: 0 16px;
  text-align: left;
  background-color: var(--preview-bg, #fdfdf3);
}
.campus-footer-disclaimer p {
  margin: 0 0 8px 0;
  font-size: 12px;
  color: var(--preview-disclaimer, #c8c3b8);
  line-height: 1.8;
  background-color: var(--preview-bg, #fdfdf3);
}
.campus-footer-disclaimer p:last-child { margin-bottom: 0; }
.campus-footer-disclaimer .disclaimer-empty-line {
  margin: 0;
  color: #6b5546;
}

.hidden {
  display: none !important;
}

.app-footer {
  padding: 16px 0 20px;
  text-align: center;
  font-size: 12px;
  color: #b5aa9e;
}

/* Status badges */
.status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
  vertical-align: middle;
  margin-left: 6px;
}

.status-badge.status-pending         { background: #f0ebe4; color: #a09586; }
.status-badge.status-under_review    { background: #e3eef6; color: #2980b9; }
.status-badge.status-accept          { background: #e0f2e5; color: #27ae60; }
.status-badge.status-minor_revision  { background: #fef3e0; color: #f39c12; }
.status-badge.status-major_revision  { background: #fde8d0; color: #e67e22; }
.status-badge.status-reject_resubmit { background: #fde0de; color: #e74c3c; }
.status-badge.status-reject          { background: #f5d5d2; color: #c0392b; }

/* Status filter bar */
.status-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.status-filter-bar .filter-chip {
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 12px;
  border: 1px solid #d4c9bc;
  background: transparent;
  color: #6b5546;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.status-filter-bar .filter-chip:hover {
  background: #f5f0ea;
}

.status-filter-bar .filter-chip.active {
  background: #6b5546;
  color: #fff;
  border-color: #6b5546;
}

/* Status action buttons in cards */
.status-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.status-actions .btn {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  color: #fff;
  transition: opacity 0.15s;
}

.status-actions .btn:hover {
  opacity: 0.85;
}

/* Status change modal */
.status-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.status-modal {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

.status-modal h3 {
  margin: 0 0 4px;
  font-size: 16px;
  color: #3d3028;
}

.status-modal .modal-desc {
  font-size: 13px;
  color: #8b7c69;
  margin: 0 0 12px;
}

.status-modal .modal-btns {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.status-modal .modal-btns .btn {
  flex: 1;
}

/* Confirm submission modal */
.confirm-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.confirm-modal {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  max-width: 460px;
  width: 100%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  max-height: 85vh;
  overflow-y: auto;
}

.confirm-modal-title {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 700;
  color: #3d3028;
}

.confirm-modal-desc {
  font-size: 13px;
  color: #8b7c69;
  margin: 0 0 16px;
}


.confirm-modal-btns {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.confirm-modal-btns .btn {
  flex: 1;
  height: 46px;
  font-size: 15px;
}

/* Status history timeline */
.status-history-section {
  margin-top: 20px;
  padding: 14px;
  background: #faf8f5;
  border-radius: 10px;
  border: 1px solid #ebe5dc;
}

.status-history-section h4 {
  margin: 0 0 10px;
  font-size: 13px;
  color: #8b7c69;
  font-weight: 600;
}

.history-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px dashed #e0d7c8;
  font-size: 13px;
  color: #5f574c;
  flex-wrap: wrap;
}

.history-item:last-child {
  border-bottom: none;
}

.history-time {
  color: #a09586;
  font-size: 12px;
  white-space: nowrap;
}

.history-arrow {
  color: #a09586;
}

.history-notes {
  font-size: 12px;
  color: #8b7c69;
  padding: 2px 0 6px 0;
  width: 100%;
}

/* Workbench status bar */
.wb-status-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 12px 14px;
  background: #faf8f5;
  border-radius: 10px;
  border: 1px solid #ebe5dc;
}

.wb-status-bar .status-label {
  font-size: 13px;
  color: #8b7c69;
  font-weight: 600;
}

/* Review panel */
.wb-review-panel {
  margin-bottom: 16px;
  padding: 16px;
  background: #f7f3ee;
  border-radius: 12px;
  border: 1px solid #e0d7cc;
  border-left: 4px solid #5b8c7e;
}

.review-panel-title {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 700;
  color: #3d3028;
}

.review-final-section {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed #e0d7c8;
}

.review-final-hint {
  font-size: 13px;
  color: #8b7c69;
  margin: 0 0 10px;
}

.review-final-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.review-final-actions .btn {
  padding: 8px 16px;
  font-size: 13px;
  border-radius: 8px;
}

.review-locked-notice {
  margin-top: 14px;
  padding: 12px 16px;
  background: #f0ebe4;
  border-radius: 8px;
  font-size: 13px;
  color: #a09586;
  text-align: center;
  font-weight: 600;
}

.text-input:disabled,
.text-area:disabled,
select.text-input:disabled {
  background-color: #f0ebe4;
  color: #a09586;
  cursor: not-allowed;
  border-color: #e0d7cc;
}

/* Sensitive word detection */
.sw-results {
  margin-top: 12px;
  padding: 14px;
  background: #faf8f5;
  border-radius: 10px;
  border: 1px solid #ebe5dc;
}

.sw-summary {
  font-size: 14px;
  font-weight: 600;
  color: #3d3028;
  margin-bottom: 8px;
}

.sw-count.safe { color: #27ae60; }
.sw-count.warn { color: #c0392b; }

.sw-cat-group {
  margin-bottom: 8px;
}

.sw-cat-group:last-child {
  margin-bottom: 0;
}

.sw-cat-label {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
}

.sw-cat-label.sw-cat-0 { background: #fde0de; color: #e74c3c; }
.sw-cat-label.sw-cat-1 { background: #f5d5d2; color: #c0392b; }
.sw-cat-label.sw-cat-2 { background: #eedff2; color: #8e44ad; }
.sw-cat-label.sw-cat-3 { background: #fde8d0; color: #e67e22; }
.sw-cat-label.sw-cat-4 { background: #fef3e0; color: #f39c12; }
.sw-cat-label.sw-cat-5 { background: #f0ebe4; color: #a09586; }
.sw-cat-label.sw-cat-6 { background: #ddeaf6; color: #3498db; }

.sw-word-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.sw-word {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
}

.sw-word.sw-cat-0 { background: rgba(231, 76, 60, 0.12); color: #c0392b; }
.sw-word.sw-cat-1 { background: rgba(192, 57, 43, 0.12); color: #96281b; }
.sw-word.sw-cat-2 { background: rgba(142, 68, 173, 0.12); color: #6c3483; }
.sw-word.sw-cat-3 { background: rgba(230, 126, 34, 0.12); color: #b5651d; }
.sw-word.sw-cat-4 { background: rgba(243, 156, 18, 0.12); color: #b7950b; }
.sw-word.sw-cat-5 { background: rgba(160, 149, 134, 0.12); color: #6b5546; }
.sw-word.sw-cat-6 { background: rgba(52, 152, 219, 0.12); color: #2471a3; }

#wemd mark.sw-hit {
  background: none;
  border-radius: 2px;
  padding: 0 1px;
}

#wemd mark.sw-cat-0 { background: rgba(231, 76, 60, 0.22); }
#wemd mark.sw-cat-1 { background: rgba(192, 57, 43, 0.22); }
#wemd mark.sw-cat-2 { background: rgba(142, 68, 173, 0.22); }
#wemd mark.sw-cat-3 { background: rgba(230, 126, 34, 0.22); }
#wemd mark.sw-cat-4 { background: rgba(243, 156, 18, 0.22); }
#wemd mark.sw-cat-5 { background: rgba(160, 149, 134, 0.22); }
#wemd mark.sw-cat-6 { background: rgba(52, 152, 219, 0.22); }

@media (max-width: 400px) {
  .app {
    padding: 0 12px;
  }

  .layout-main {
    padding: 20px 16px;
  }

  .status-filter-bar {
    gap: 4px;
  }

  .status-filter-bar .filter-chip {
    padding: 3px 8px;
    font-size: 11px;
  }
}
