:root {
  --ink: #161513;
  --ink-soft: #3a3732;
  --muted: #7a746b;
  --line: rgba(22, 21, 19, 0.1);
  --paper: #f4f1eb;
  --paper-2: #ebe6dc;
  --panel: #fffcf7;
  --cinnabar: #a83737;
  --cinnabar-soft: #f6e8e6;
  --ok: #2f6b3a;
  --ok-soft: #e7f2ea;
  --shadow: 0 18px 50px rgba(22, 21, 19, 0.08);
  --radius: 14px;
  --font-ui: "Outfit", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-brand: "Noto Serif SC", "Songti SC", serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(168, 55, 55, 0.08), transparent 28%),
    linear-gradient(160deg, #f7f4ee 0%, #efe9df 100%);
  font-family: var(--font-ui);
}

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

button {
  border: 0;
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  z-index: 1000;
  transform: translateX(-50%);
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff8f0;
  box-shadow: var(--shadow);
  font-size: 14px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 10px;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

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

.btn:active {
  transform: translateY(0);
  opacity: 0.9;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--ink);
  color: #fff8f0;
}

.btn-accent {
  background: var(--cinnabar);
  color: #fff8f0;
}

.btn-secondary {
  background: var(--paper-2);
  color: var(--ink);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  padding-left: 0;
  padding-right: 0;
}

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

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

.field > span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.field input,
.field textarea,
.field select,
.search-input,
.toolbar select,
.cover-upload input[type="file"] {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  outline: none;
}

.field textarea {
  resize: vertical;
  line-height: 1.6;
}

.field input:focus,
.field textarea:focus,
.field select:focus,
.search-input:focus,
.toolbar select:focus {
  border-color: rgba(168, 55, 55, 0.45);
  box-shadow: 0 0 0 3px rgba(168, 55, 55, 0.08);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--paper-2);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
}

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

.badge.offline {
  background: #ececec;
  color: #666;
}

.badge.draft {
  background: #fff1d8;
  color: #8a5a12;
}

/* Login */
.login-view {
  display: grid;
  grid-template-columns: minmax(0, 440px) minmax(0, 1fr);
  min-height: 100vh;
}

.login-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px;
  background: rgba(255, 252, 247, 0.92);
  backdrop-filter: blur(18px);
}

.login-brand {
  margin: 0 0 10px;
  color: var(--cinnabar);
  font-family: var(--font-brand);
  font-size: 18px;
  font-weight: 700;
}

.login-title {
  margin: 0;
  font-family: var(--font-brand);
  font-size: 40px;
  line-height: 1.15;
}

.login-desc {
  margin: 14px 0 28px;
  color: var(--muted);
  line-height: 1.6;
}

.login-error {
  margin: 14px 0 0;
  color: var(--cinnabar);
  font-size: 14px;
}

.login-aside {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(145deg, rgba(22, 21, 19, 0.72), rgba(168, 55, 55, 0.35)),
    url("data:image/svg+xml,%3Csvg width='160' height='160' viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 80h160M80 0v160' stroke='rgba(255,255,255,0.08)' stroke-width='1'/%3E%3C/svg%3E"),
    #1c1b1b;
}

.login-aside-copy {
  position: absolute;
  left: 56px;
  bottom: 56px;
  right: 56px;
  color: #fff8f0;
}

.login-aside-copy p {
  margin: 0 0 14px;
  opacity: 0.72;
  letter-spacing: 0.18em;
  font-size: 13px;
}

.login-aside-copy h2 {
  margin: 0;
  font-family: var(--font-brand);
  font-size: clamp(36px, 4vw, 56px);
  line-height: 1.25;
  font-weight: 600;
}

/* Shell */
.app-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  padding: 24px 18px;
  background: #171614;
  color: #f6f1e8;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 24px;
}

.sidebar-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--cinnabar);
  font-family: var(--font-brand);
  font-size: 20px;
}

.sidebar-brand strong {
  display: block;
  font-family: var(--font-brand);
  font-size: 18px;
}

.sidebar-brand small {
  color: rgba(246, 241, 232, 0.55);
  font-size: 12px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-item {
  text-align: left;
  padding: 12px 14px;
  border-radius: 10px;
  background: transparent;
  color: rgba(246, 241, 232, 0.72);
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  color: rgba(246, 241, 232, 0.6);
  font-size: 13px;
}

.sidebar-meta button {
  background: transparent;
  color: #fff;
  text-decoration: underline;
}

.workspace {
  padding: 28px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.header-with-back {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--cinnabar);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.page-header h1 {
  margin: 0;
  font-family: var(--font-brand);
  font-size: 34px;
  line-height: 1.15;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 12px;
  margin-bottom: 16px;
}

.table-card,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.table-card {
  overflow: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

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

.data-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  background: rgba(244, 241, 235, 0.8);
}

.data-table tbody tr:hover {
  background: rgba(168, 55, 55, 0.03);
}

.data-table .title-cell {
  font-weight: 600;
}

.data-table .empty-cell {
  color: var(--muted);
  text-align: center;
  padding: 48px 16px;
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.row-actions button {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  background: var(--paper-2);
}

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

.panel {
  padding: 18px;
}

.panel h3 {
  margin: 0 0 14px;
  font-family: var(--font-brand);
  font-size: 18px;
}

.body-editor {
  min-height: 420px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.body-editor .ql-toolbar.ql-snow {
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #faf7f2;
}

.body-editor .ql-container.ql-snow {
  border: 0;
  min-height: 360px;
  font-size: 15px;
  line-height: 1.7;
}

.cover-upload {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.cover-preview {
  overflow: hidden;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #eee;
  min-height: 120px;
}

.cover-preview img {
  display: block;
  width: 100%;
  height: 160px;
  object-fit: cover;
}

.audit-box {
  min-height: 52px;
  margin-bottom: 12px;
  padding: 12px;
  border-radius: 10px;
  background: var(--paper);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.audit-box.safe {
  background: var(--ok-soft);
  color: var(--ok);
}

.audit-box.risky {
  background: var(--cinnabar-soft);
  color: var(--cinnabar);
}

.action-stack {
  display: grid;
  gap: 10px;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

.media-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.media-card img {
  display: block;
  width: 100%;
  height: 140px;
  object-fit: cover;
  background: #ddd;
}

.media-card .media-meta {
  padding: 12px;
}

.media-card strong {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
}

.media-card small {
  color: var(--muted);
  font-size: 12px;
  word-break: break-all;
}

.empty-card {
  grid-column: 1 / -1;
  padding: 48px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
  background: rgba(255, 252, 247, 0.7);
}

.config-panel {
  max-width: 760px;
}

.config-tip {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.code-area {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
}

@media (max-width: 980px) {
  .login-view,
  .app-shell,
  .editor-layout,
  .toolbar {
    grid-template-columns: 1fr;
  }

  .login-aside {
    min-height: 220px;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
  }
}
