:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-soft: #f1eee7;
  --ink: #1e2321;
  --muted: #5f6864;
  --line: #e4dfd5;
  --line-strong: #cfc8ba;
  --jade: #16382d;
  --jade-hover: #0f2920;
  --angola: #86172f;
  --angola-soft: rgba(134, 23, 47, 0.1);
  --ok: #1f6b4e;
  --ok-soft: rgba(31, 107, 78, 0.12);
  --warn: #8a5a18;
  --warn-soft: rgba(184, 134, 45, 0.14);
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 12px 32px rgba(22, 41, 34, 0.06);
}

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

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

a {
  color: inherit;
}

/* 登录页 */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at top right, rgba(22, 56, 45, 0.08), transparent 45%),
              radial-gradient(circle at bottom left, rgba(140, 35, 50, 0.06), transparent 45%),
              var(--bg);
}

.login-card {
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 36px 32px 28px;
  box-shadow: var(--shadow);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 26px;
}

.login-logo {
  width: 44px;
  height: 48px;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 3px 8px rgba(3, 95, 69, 0.1));
}

.login-brand-copy {
  min-width: 0;
}

.login-title {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.login-wordmark {
  font-family: "Cormorant Garamond", "Didot", "Bodoni 72", Georgia, serif;
  font-size: 26px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.06em;
  color: var(--angola);
}

.login-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--angola-soft);
  color: var(--angola);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.5;
}

.login-tagline {
  margin: 5px 0 0;
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--jade);
}

.login-sub {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.login-footer {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  text-align: center;
}

.link-muted {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
}

.link-muted:hover {
  color: var(--jade);
}

/* 顶部栏 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 0 clamp(16px, 3vw, 32px);
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-logo {
  width: 31px;
  height: 34px;
  object-fit: contain;
  flex-shrink: 0;
}

.topbar-brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.topbar-brand strong {
  font-family: "Cormorant Garamond", "Didot", "Bodoni 72", Georgia, serif;
  font-size: 22px;
  font-weight: 600;
  color: var(--angola);
  letter-spacing: 0.06em;
  text-transform: none;
  flex-shrink: 0;
}

.topbar-tagline {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--jade);
  white-space: nowrap;
}

.topbar-role {
  font-size: 11.5px;
  color: var(--muted);
  padding-left: 8px;
  border-left: 1px solid var(--line-strong);
  white-space: nowrap;
}

@media (max-width: 680px) {
  .topbar-tagline,
  .topbar-role {
    display: none;
  }
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.user-pill {
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 500;
}

.security-banner {
  background: var(--angola);
  color: #ffffff;
  padding: 10px clamp(16px, 3vw, 32px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 13px;
}

/* 主工作区 */
.workspace {
  max-width: 1380px;
  margin: 0 auto;
  padding: 24px clamp(16px, 3vw, 32px) 64px;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 88px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-btn {
  appearance: none;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 11px 14px;
  border-radius: 10px;
  font: inherit;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}

.nav-btn:hover {
  background: var(--surface-soft);
}

.nav-btn.is-active {
  background: var(--jade);
  color: #ffffff;
}

.panel-area {
  min-width: 0;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.panel-head h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
}

.panel-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13.5px;
}

/* 通用卡片与表单 */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: 0 4px 18px rgba(22, 41, 34, 0.03);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stack-sm {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stack-lg {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

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

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.flex-1 {
  flex: 1;
  min-width: 0;
}

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

.field > span,
.field-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
}

input[type="text"],
input[type="url"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--jade);
  box-shadow: 0 0 0 3px rgba(22, 56, 45, 0.12);
}

textarea {
  resize: vertical;
}

.checkbox-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13.5px;
  user-select: none;
}

.checkbox-align {
  align-self: end;
  padding-bottom: 10px;
}

.form-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.form-section:first-child {
  padding-top: 0;
  border-top: 0;
}

.form-section h3,
.form-section h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--jade);
}

.hint {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
}

.hint-inline {
  font-size: 12px;
  color: var(--muted);
}

.form-error {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--angola-soft);
  color: var(--angola);
  font-size: 13px;
  font-weight: 500;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

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

.section-bar h3 {
  margin: 0;
  font-size: 16px;
}

/* 按钮 */
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.btn-primary {
  background: var(--jade);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--jade-hover);
}

.btn-accent {
  background: #ffffff;
  color: var(--angola);
}

.btn-outline {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--ink);
}

.btn-outline:hover {
  border-color: var(--jade);
  color: var(--jade);
}

.btn-danger {
  background: var(--angola-soft);
  border-color: rgba(140, 35, 50, 0.25);
  color: var(--angola);
}

.btn-danger:hover {
  background: var(--angola);
  color: #ffffff;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
}

.btn-ghost:hover {
  background: var(--surface-soft);
  color: var(--ink);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 12.5px;
}

.btn-xs {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-block {
  width: 100%;
}

.file-btn {
  position: relative;
  overflow: hidden;
}

/* 工具栏与筛选 */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.filter-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 14px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
}

.chip.is-active {
  background: var(--jade);
  border-color: var(--jade);
  color: #ffffff;
}

.select-sm {
  width: auto;
  min-width: 140px;
}

/* 动态卡片列表 */
.card-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.update-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: grid;
  grid-template-columns: 144px minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
}

.update-row-thumb {
  width: 144px;
  aspect-ratio: 4 / 3;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.update-row-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.update-row-info h3 {
  margin: 6px 0 4px;
  font-size: 16px;
  line-height: 1.4;
}

.update-row-info p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--surface-soft);
  color: var(--muted);
}

.badge-pub {
  background: var(--ok-soft);
  color: var(--ok);
}

.badge-draft {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge-pin {
  background: var(--angola-soft);
  color: var(--angola);
}

.update-row-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

/* 全站文案编辑区 */
.storage-badge {
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}

.section-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.cms-field-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cms-field-card.is-overridden {
  border-color: rgba(140, 35, 50, 0.36);
  background: #fffdf9;
}

.cms-field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.cms-field-title {
  font-weight: 600;
  font-size: 13.5px;
}

/* 媒体预览 */
.media-picker-row {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.thumb-box {
  width: 140px;
  aspect-ratio: 4 / 3;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
}

.thumb-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.gallery-editor {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.gallery-thumbs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.gallery-chip {
  position: relative;
  width: 96px;
  aspect-ratio: 4 / 3;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface-soft);
}

.gallery-chip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gallery-chip button {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 0;
  background: rgba(18, 28, 24, 0.78);
  color: #ffffff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

/* ICP 预览 */
.icp-preview {
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--jade);
  color: rgba(255, 255, 255, 0.88);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 13px;
}

.icp-preview-label {
  color: rgba(255, 255, 255, 0.6);
}

/* 表格 */
.security-top {
  margin-bottom: 18px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.data-table th {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  background: var(--bg);
}

.table-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* 模态框 */
.modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(14, 24, 20, 0.56);
  backdrop-filter: blur(3px);
}

.modal-dialog {
  position: relative;
  z-index: 1;
  width: min(520px, 100%);
  max-height: 90vh;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(10, 20, 16, 0.25);
}

.modal-lg {
  width: min(920px, 100%);
}

.modal-head {
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-head h3 {
  margin: 0;
  font-size: 17px;
}

.modal-x {
  appearance: none;
  border: 0;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  width: 34px;
  height: 34px;
  border-radius: 50%;
}

.modal-x:hover {
  background: var(--surface-soft);
  color: var(--ink);
}

.modal-body {
  padding: 20px 22px;
  overflow-y: auto;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 150;
  padding: 12px 18px;
  border-radius: 10px;
  background: var(--jade);
  color: #ffffff;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: 0 12px 28px rgba(14, 30, 24, 0.24);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.is-error {
  background: var(--angola);
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
}

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

  .sidebar {
    position: static;
    flex-direction: row;
    overflow-x: auto;
  }

  .nav-btn {
    white-space: nowrap;
  }

  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }

  .update-row {
    grid-template-columns: 1fr;
  }

  .update-row-thumb {
    width: 100%;
    max-width: 280px;
  }

  .update-row-actions {
    flex-direction: row;
    justify-content: flex-start;
  }

  .media-picker-row {
    flex-direction: column;
  }
}
