:root {
  --main-color: #6f8b69;
  --ink-color: #3f4640;
  --muted-color: #846f65;
  --line-color: #d9cbb6;
  --paper-color: rgba(255, 255, 255, 0.94);
  --panel-color: #fbfaf6;
  --soft-green: #eef5ea;
  --soft-rose: #f4e6df;
  --shadow: 0 14px 36px rgba(80, 66, 54, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  background:
    linear-gradient(135deg, rgba(245, 241, 230, 0.96), rgba(232, 220, 196, 0.9)),
    #f5f1e6;
  color: var(--ink-color);
  font-family: "PingFang SC", "Microsoft YaHei", "宋体", serif;
  line-height: 1.7;
  margin: 0 auto;
  max-width: 1320px;
  min-height: 100vh;
  padding: 24px;
}

.admin-header {
  align-items: center;
  border-bottom: 2px dashed rgba(155, 128, 114, 0.72);
  display: flex;
  gap: 24px;
  justify-content: space-between;
  margin-bottom: 22px;
  padding: 4px 0 20px;
}

.admin-header h1,
.panel h2,
.preview-panel h2,
.entry-editor h2 {
  color: var(--main-color);
  letter-spacing: 0;
  line-height: 1.25;
  margin: 0;
}

.admin-header h1 {
  font-size: clamp(26px, 4vw, 42px);
}

.admin-header p {
  color: var(--muted-color);
  margin: 6px 0 0;
  max-width: 680px;
}

.admin-header nav {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

a,
button {
  align-items: center;
  background: var(--main-color);
  border: 1px solid transparent;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  text-decoration: none;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
  white-space: nowrap;
}

button:hover,
a:hover,
button:focus-visible,
a:focus-visible {
  background: #617d5b;
  box-shadow: 0 8px 18px rgba(80, 66, 54, 0.14);
  outline: none;
  transform: translateY(-1px);
}

.secondary,
.entry-actions button {
  background: #9b8072;
}

.secondary:hover,
.entry-actions button:hover {
  background: #876b5e;
}

.danger {
  background: #9f645a;
}

.danger:hover,
.danger:focus-visible {
  background: #8d5148;
}

.hidden {
  display: none !important;
}

.panel,
.entry-list-panel,
.editor-shell,
.entry-editor,
.preview-panel,
.status-card {
  background: var(--paper-color);
  border: 1px solid var(--line-color);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  margin: 18px 0;
  padding: 20px;
}

.login-panel {
  align-items: end;
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) auto;
}

.auth-panel {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
}

.auth-panel button {
  min-width: 112px;
}

.status-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 18px;
}

.status-card {
  min-width: 0;
  overflow: hidden;
  padding: 16px;
  position: relative;
}

.status-card::before {
  background: var(--soft-green);
  border-radius: 999px;
  content: "";
  height: 36px;
  position: absolute;
  right: -10px;
  top: -10px;
  width: 36px;
}

.status-card:nth-child(even)::before {
  background: var(--soft-rose);
}

.status-card span {
  color: var(--muted-color);
  display: block;
  font-size: 0.9em;
}

.status-card strong {
  color: var(--ink-color);
  display: block;
  font-size: 1.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace {
  align-items: start;
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 380px);
}

.editor-workspace {
  align-items: start;
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
}

.entry-list-panel,
.editor-shell {
  overflow: hidden;
}

.entry-list-toolbar,
.editor-topbar {
  align-items: center;
  background: linear-gradient(90deg, rgba(238, 245, 234, 0.96), rgba(244, 230, 223, 0.72));
  border-bottom: 1px solid var(--line-color);
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: space-between;
  padding: 20px 24px;
}

.entry-list-toolbar h2,
.editor-topbar h2 {
  color: var(--main-color);
  line-height: 1.25;
  margin: 0;
}

.entry-search {
  flex: 0 1 320px;
}

.entry-search input {
  min-height: 38px;
}

.entry-list {
  display: grid;
  gap: 16px;
  min-width: 0;
  padding: 20px;
}

.entry-empty {
  background: #fff;
  border: 1px dashed var(--line-color);
  border-radius: 8px;
  color: var(--muted-color);
  padding: 24px;
  text-align: center;
}

.entry-summary {
  align-items: center;
  background: #fff;
  border: 1px solid rgba(217, 203, 182, 0.78);
  border-radius: 8px;
  display: grid;
  gap: 18px;
  grid-template-columns: 88px minmax(0, 1fr);
  min-width: 0;
  padding: 18px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.entry-summary:hover {
  border-color: rgba(111, 139, 105, 0.42);
  box-shadow: 0 12px 26px rgba(80, 66, 54, 0.11);
  transform: translateY(-1px);
}

.entry-summary-media {
  align-items: center;
  background: var(--soft-green);
  border-radius: 8px;
  color: var(--main-color);
  display: flex;
  font-size: 24px;
  height: 88px;
  justify-content: center;
  overflow: hidden;
  width: 88px;
}

.entry-summary-media img {
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.entry-summary-body {
  min-width: 0;
}

.entry-summary h3,
.entry-summary p {
  margin: 0;
}

.entry-summary h3 {
  color: var(--main-color);
  font-size: 1.16em;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-summary-meta,
.entry-summary-excerpt {
  color: var(--muted-color);
  line-height: 1.55;
  margin-top: 8px;
}

.entry-summary-excerpt {
  color: var(--ink-color);
  display: -webkit-box;
  margin-top: 10px;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.entry-summary-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.entry-summary-badges span {
  background: var(--panel-color);
  border: 1px solid rgba(217, 203, 182, 0.78);
  border-radius: 999px;
  color: var(--muted-color);
  font-size: 0.86em;
  line-height: 1.4;
  padding: 5px 10px;
}

.entry-summary-actions {
  border-top: 1px dashed rgba(217, 203, 182, 0.86);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  grid-column: 1 / -1;
  justify-content: flex-end;
  padding-top: 14px;
}

.entry-summary-actions button {
  min-height: 40px;
  min-width: 78px;
  padding: 0 14px;
}

button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.3);
  opacity: 0.48;
  transform: none;
}

.editor-topbar {
  align-items: center;
}

.editor-topbar > div:nth-child(2) {
  flex: 1 1 260px;
  min-width: 0;
}

.editor-topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

#editorMount .entry-editor {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

#editorMount .entry-editor-header {
  display: none;
}

.entry-editor {
  overflow: hidden;
  padding: 0;
}

.entry-editor-header {
  align-items: center;
  background: linear-gradient(90deg, rgba(238, 245, 234, 0.96), rgba(244, 230, 223, 0.72));
  border-bottom: 1px solid var(--line-color);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  padding: 16px 18px;
}

.entry-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.entry-actions button {
  min-height: 34px;
  padding: 0 10px;
}

.form-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(90px, 0.55fr) minmax(160px, 1.2fr) repeat(2, minmax(120px, 0.8fr));
  padding: 24px;
}

label {
  color: var(--muted-color);
  display: grid;
  gap: 8px;
  min-width: 0;
}

.wide {
  grid-column: 1 / -1;
}

input,
textarea {
  background: #fff;
  border: 1px solid var(--line-color);
  border-radius: 8px;
  color: var(--ink-color);
  font: inherit;
  min-height: 46px;
  padding: 12px 14px;
  width: 100%;
}

input:focus,
textarea:focus {
  border-color: var(--main-color);
  box-shadow: 0 0 0 3px rgba(111, 139, 105, 0.14);
  outline: none;
}

textarea {
  min-height: 132px;
  resize: vertical;
}

.upload-inline {
  align-items: end;
  background: var(--panel-color);
  border-top: 1px dashed var(--line-color);
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 20px 24px 24px;
}

.upload-inline .upload-message {
  color: var(--muted-color);
  grid-column: 1 / -1;
  overflow-wrap: anywhere;
}

.preview-panel {
  overflow: hidden;
  padding: 0;
  position: sticky;
  top: 16px;
}

.editor-preview-panel {
  top: 16px;
}

.preview-panel h2 {
  background: linear-gradient(90deg, rgba(238, 245, 234, 0.96), rgba(244, 230, 223, 0.72));
  border-bottom: 1px solid var(--line-color);
  padding: 16px 18px;
}

#preview {
  display: grid;
  gap: 12px;
  margin: 0;
  max-height: 64vh;
  overflow: auto;
  padding: 16px;
}

.preview-card {
  background: #fff;
  border: 1px solid rgba(217, 203, 182, 0.72);
  border-radius: 8px;
  box-shadow: 0 8px 18px rgba(80, 66, 54, 0.08);
  padding: 14px;
}

.preview-card h3 {
  color: var(--main-color);
  line-height: 1.35;
  margin: 0 0 8px;
}

.preview-card p,
.preview-card ul,
.preview-card blockquote {
  margin: 8px 0;
}

.preview-card ul {
  padding-left: 1.3em;
}

.preview-meta,
.preview-card blockquote {
  color: var(--muted-color);
}

.preview-card blockquote {
  border-left: 3px solid var(--main-color);
  padding-left: 12px;
}

.preview-card img {
  border-radius: 5px;
  display: block;
  filter: sepia(0.24);
  height: auto;
  margin-top: 10px;
  max-height: 220px;
  object-fit: contain;
  width: 100%;
}

.preview-card video {
  background: rgba(111, 139, 105, 0.1);
  border-radius: 5px;
  display: block;
  margin-top: 10px;
  max-height: 260px;
  object-fit: contain;
  width: 100%;
}

.publish-box {
  align-items: start;
  background: var(--panel-color);
  border-top: 1px dashed var(--line-color);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 18px 18px;
}

.publish-box button {
  width: 100%;
}

.result {
  color: var(--muted-color);
  margin: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 1100px) {
  body {
    max-width: 980px;
  }

  .status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .editor-workspace {
    grid-template-columns: 1fr;
  }

  .preview-panel {
    position: static;
  }

  #preview {
    max-height: none;
  }
}

@media (max-width: 760px) {
  body {
    padding: 16px;
  }

  .admin-header h1 {
    font-size: 30px;
  }

  .admin-header p {
    font-size: 0.94em;
  }

  .admin-header {
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
  }

  .admin-header nav,
  .auth-panel {
    justify-content: stretch;
  }

  .admin-header nav a,
  .admin-header nav button,
  .auth-panel button {
    flex: 1 1 150px;
  }

  .login-panel,
  .form-grid,
  .upload-inline {
    grid-template-columns: 1fr;
  }

  .status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .status-card {
    min-height: 82px;
    padding: 12px;
  }

  .workspace {
    gap: 14px;
  }

  .editor-workspace {
    gap: 14px;
  }

  .entry-list-toolbar,
  .editor-topbar {
    align-items: stretch;
    flex-direction: column;
    padding: 16px;
  }

  .entry-search {
    flex-basis: auto;
  }

  .entry-summary {
    align-items: start;
    gap: 14px;
    grid-template-columns: 72px minmax(0, 1fr);
    padding: 14px;
  }

  .entry-summary-media {
    height: 72px;
    width: 72px;
  }

  .entry-summary-actions {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    justify-content: stretch;
  }

  .entry-summary-actions button {
    min-height: 42px;
    min-width: 0;
    padding: 0 8px;
  }

  .editor-topbar-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .preview-panel {
    order: -1;
  }

  .editor-preview-panel {
    order: 0;
  }

  #preview {
    max-height: 42vh;
    padding: 12px;
  }

  .preview-card {
    padding: 12px;
  }

  .upload-inline button {
    width: 100%;
  }

  .entry-editor-header {
    align-items: stretch;
    flex-direction: column;
  }

  .entry-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .entry-actions button {
    min-height: 38px;
  }
}

@media (max-width: 480px) {
  body {
    padding: 12px;
  }

  .panel,
  .status-card,
  .preview-card {
    padding: 12px;
  }

  .status-grid {
    gap: 10px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .status-card span {
    font-size: 0.84em;
  }

  .status-card strong {
    font-size: 0.92em;
  }

  .entry-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .entry-list {
    gap: 14px;
    padding: 12px;
  }

  .entry-summary {
    gap: 10px;
    grid-template-columns: 64px minmax(0, 1fr);
    padding: 12px;
  }

  .entry-summary-media {
    height: 64px;
    width: 64px;
  }

  .entry-summary-actions {
    gap: 8px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .entry-summary-actions button {
    width: 100%;
  }

  .editor-topbar-actions {
    grid-template-columns: 1fr;
  }

  a,
  button {
    min-height: 44px;
  }

  .admin-header nav a,
  .admin-header nav button,
  .auth-panel button,
  .publish-box button,
  .upload-inline button,
  .login-panel button {
    width: 100%;
  }
}

@media (max-width: 360px) {
  .status-grid {
    grid-template-columns: 1fr;
  }
}
