:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --panel-2: #f1f3f9;
  --text: #171a21;
  --muted: #6b7280;
  --line: #e3e6ef;
  --primary: #6d3bf5;
  --primary-2: #8b5cf6;
  --primary-soft: #f0eaff;
  --danger: #dc2626;
  --success: #0f9f6e;
  --warning: #b45309;
  --shadow: 0 12px 40px rgba(28, 24, 55, 0.08);
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  font-size: 14px;
  line-height: 1.55;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

/* ---------------- Login ---------------- */
.login-view {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 15% 0%, #ede7ff 0%, transparent 60%),
    radial-gradient(700px 500px at 100% 100%, #e7f6ff 0%, transparent 55%),
    var(--bg);
}

.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 34px;
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 14px 0 4px;
  font-size: 24px;
  letter-spacing: -0.02em;
}

.login-card p {
  margin: 0 0 18px;
}

.login-card label {
  display: block;
  margin-bottom: 14px;
}

.login-card label span {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.login-card input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  outline: none;
}

.login-card input:focus {
  border-color: var(--primary-2);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.login-note {
  margin-top: 16px !important;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.form-error {
  min-height: 20px;
  margin: 10px 0 0 !important;
  color: var(--danger);
  font-size: 13px;
}

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  font-size: 26px;
  background: linear-gradient(135deg, var(--primary), #b06cff);
  box-shadow: 0 10px 24px rgba(109, 59, 245, 0.28);
}

.brand-mark.small {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  font-size: 18px;
  box-shadow: none;
}

/* ---------------- App shell ---------------- */
.app-view {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 64px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}

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

.brand-title {
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 12px;
  color: var(--muted);
}

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

.layout {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
}

.sidebar {
  width: 300px;
  flex: 0 0 300px;
  border-right: 1px solid var(--line);
  background: #fbfbfe;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-head {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.search {
  width: 100%;
  height: 38px;
  margin-top: 10px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  outline: none;
}

.search:focus {
  border-color: var(--primary-2);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.sidebar-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.post-list {
  flex: 1 1 auto;
  overflow: auto;
  padding: 8px;
}

.post-item {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 12px;
  padding: 11px 12px;
  cursor: pointer;
  display: block;
}

.post-item:hover {
  background: #f0f1f7;
}

.post-item.active {
  background: #fff;
  border-color: var(--line);
  box-shadow: 0 6px 18px rgba(28, 24, 55, 0.06);
}

.post-item-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.post-item-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.post-item-platforms {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-empty {
  padding: 28px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.main {
  flex: 1 1 auto;
  min-width: 0;
  overflow: auto;
  padding: 22px;
}

/* ---------------- Empty ---------------- */
.empty-view {
  min-height: calc(100vh - 130px);
  display: grid;
  place-items: center;
}

.empty-card {
  width: min(520px, 100%);
  text-align: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 44px 34px;
  box-shadow: var(--shadow);
}

.empty-icon {
  font-size: 42px;
  margin-bottom: 8px;
}

.empty-card h2 {
  margin: 0 0 8px;
  font-size: 20px;
}

.empty-card p {
  margin: 0 0 20px;
}

/* ---------------- Editor ---------------- */
.editor-view {
  max-width: 1280px;
  margin: 0 auto;
}

.editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.editor-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.editor-title-row h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.01em;
}

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

.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 16px;
  align-items: start;
}

.editor-main,
.editor-side {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-weight: 650;
  margin-bottom: 10px;
}

.panel-actions {
  display: flex;
  gap: 10px;
}

.field {
  display: block;
  margin-bottom: 14px;
}

.field > span,
.field-head > span:first-child {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

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

.field-head > span:first-child {
  margin-bottom: 0;
}

.field.compact {
  margin-bottom: 10px;
}

input[type="text"],
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 10px 12px;
  outline: none;
}

input[type="text"]:focus,
textarea:focus,
select:focus {
  border-color: var(--primary-2);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

textarea {
  resize: vertical;
}

.rich-editor {
  min-height: 340px;
  max-height: 60vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  background: #fff;
  outline: none;
  line-height: 1.75;
}

.rich-editor:focus {
  border-color: var(--primary-2);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.rich-editor:empty::before {
  content: attr(data-placeholder);
  color: #a0a6b5;
}

.rich-editor img {
  max-width: 100%;
  border-radius: 8px;
}

.rich-editor blockquote {
  margin: 10px 0;
  padding: 8px 14px;
  border-left: 3px solid var(--primary-2);
  background: var(--panel-2);
  color: #4b5563;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 7px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 12px 12px 0 0;
  background: #fafafe;
}

.toolbar + .rich-editor {
  border-radius: 0 0 12px 12px;
}

.toolbar button {
  min-width: 32px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  color: #374151;
}

.toolbar button:hover {
  background: #fff;
  border-color: var(--line);
}

.hint {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.row {
  display: flex;
  align-items: center;
}

.gap {
  gap: 8px;
}

.image-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 10px;
}

.image-thumb {
  position: relative;
  width: 86px;
  height: 86px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--panel-2);
}

.image-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-thumb button {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: rgba(17, 24, 39, 0.7);
  color: #fff;
  cursor: pointer;
  line-height: 1;
}

.media-file {
  padding: 10px 12px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  margin-bottom: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cover-preview {
  width: 100%;
  aspect-ratio: 16 / 10;
  border: 1px dashed var(--line);
  border-radius: 11px;
  overflow: hidden;
  display: grid;
  place-items: center;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  background: var(--panel-2);
}

.cover-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cover-preview.empty {
  border-style: dashed;
}

.platform-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  max-height: 280px;
  overflow: auto;
  padding-right: 2px;
}

.checkline,
.platform-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}

.platform-item {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fbfbfe;
}

.platform-item:has(input:checked) {
  background: var(--primary-soft);
  border-color: #d8c9ff;
}

.platform-item input,
.checkline input {
  accent-color: var(--primary);
}

.publish-logs {
  max-height: 180px;
  overflow: auto;
  line-height: 1.7;
  white-space: pre-wrap;
}

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}

.btn:hover {
  background: #f7f7fb;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn.primary {
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 20px rgba(109, 59, 245, 0.22);
}

.btn.primary:hover {
  filter: brightness(1.03);
}

.btn.danger {
  color: var(--danger);
}

.btn.danger:hover {
  background: #fef2f2;
  border-color: #fecaca;
}

.btn.ghost {
  background: transparent;
}

.btn.small {
  height: 32px;
  padding: 0 11px;
  font-size: 13px;
  border-radius: 9px;
}

.btn.block {
  width: 100%;
}

.link-btn {
  border: 0;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  padding: 0;
  font-size: 12px;
}

.link-btn:hover {
  text-decoration: underline;
}

.pill {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--panel-2);
  color: var(--muted);
}

.pill-muted {
  background: #f1f2f7;
  color: #6b7280;
}

.pill-ok {
  background: #e8f8f1;
  color: var(--success);
}

.pill-warn {
  background: #fff7e8;
  color: var(--warning);
}

.pill-err {
  background: #fef2f2;
  color: var(--danger);
}

.pill-publishing {
  background: #eef2ff;
  color: #4f46e5;
}

/* ---------------- Toast + modal ---------------- */
.toast-container {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
  max-width: min(420px, calc(100vw - 36px));
}

.toast {
  padding: 11px 14px;
  border-radius: 11px;
  background: #1f2430;
  color: #fff;
  box-shadow: 0 10px 30px rgba(17, 24, 39, 0.25);
  font-size: 13px;
  animation: toast-in 0.18s ease-out;
}

.toast.success {
  background: #0f9f6e;
}

.toast.error {
  background: #dc2626;
}

.toast.warn {
  background: #b45309;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.45);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 1100;
}

.modal-card {
  width: min(560px, 100%);
  background: #fff;
  border-radius: 18px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.modal-card h3 {
  margin: 0 0 10px;
  font-size: 18px;
}

.modal-body {
  color: #374151;
  font-size: 14px;
  line-height: 1.7;
  max-height: 55vh;
  overflow: auto;
  white-space: pre-wrap;
}

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

/* ---------------- Responsive ---------------- */
@media (max-width: 980px) {
  .editor-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .editor-side {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
}

@media (max-width: 760px) {
  .layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    flex: 0 0 auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: 46vh;
  }

  .main {
    padding: 14px;
  }

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

  .editor-actions {
    justify-content: flex-end;
  }

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

  .topbar {
    padding: 0 12px;
  }

  .brand-sub {
    display: none;
  }

  .topbar-right .muted {
    display: none;
  }
}
