:root {
  --color-accent: #d23922;
  --color-primary: #8e1f12;
  --color-primary-hover: #73180d;
  --color-published: #137643;
  --color-bg: #fbf9f8;
  --color-card: #ffffff;
  --color-border: #eeeae8;
  --color-border-focus: #d23922;
  --color-text: #1a1a1a;
  --color-text-muted: #6b6867;
  --color-error: #dc2626;
  --color-warning: #d97706;
  --radius-card: 16px;
  --radius-input: 12px;
  --radius-pill: 9999px;
  --font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font-family);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Header */
.app-header {
  background: #ffffff;
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.brand-text {
  font-size: 20px;
  font-weight: 800;
  color: var(--color-primary);
  letter-spacing: -0.5px;
}
.brand-badge {
  background: var(--color-accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  text-transform: uppercase;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.user-pill {
  font-size: 13px;
  color: var(--color-text-muted);
  background: #f4f1f0;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--color-border);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--color-primary-hover); }
.btn-outline { background: #fff; color: var(--color-text); border-color: var(--color-border); }
.btn-outline:hover:not(:disabled) { border-color: var(--color-accent); color: var(--color-accent); }
.btn-sm { padding: 5px 12px; font-size: 13px; }

/* Main Layout */
.app-main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px;
}
.top-nav {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.columns {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 24px;
  align-items: start;
}
@media (max-width: 960px) {
  .columns { grid-template-columns: 1fr; }
}

/* Cards */
.sidebar-card, .editor-card, .login-card, .users-section {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}
.section-card {
  background: #faf8f7;
  border: 1px solid var(--color-border);
  border-radius: 14px;
  padding: 16px;
  margin: 16px 0;
}
.section-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 12px 0;
  color: var(--color-primary);
}

/* Sidebar List */
.sidebar-header h2 {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 12px 0;
}
.filter-pills {
  display: flex;
  gap: 6px;
  margin: 10px 0 14px 0;
  flex-wrap: wrap;
}
.pill {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--color-border);
  background: #fff;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}
.pill:hover { border-color: var(--color-accent); color: var(--color-accent); }
.pill.active { background: var(--color-accent); color: #fff; border-color: var(--color-accent); }
.posts-list {
  max-height: calc(100vh - 280px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.post-item-btn {
  text-align: left;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.post-item-btn:hover { border-color: var(--color-accent); background: #fdfcfc; }
.post-item-btn.selected { border-color: var(--color-primary); background: #fdf5f4; box-shadow: 0 0 0 1px var(--color-primary); }
.post-item-title { font-weight: 600; font-size: 14px; color: var(--color-text); line-height: 1.35; }
.post-item-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--color-text-muted); }

/* Vietnamese Status Badges */
.badge-status {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
}
.badge-draft { background: #f0eded; color: #555555; }
.badge-pending { background: #fef3c7; color: #b45309; }
.badge-approved { background: #dbeafe; color: #1d4ed8; }
.badge-publishing { background: #dbeafe; color: #1d4ed8; }
.badge-published { background: #dcfce7; color: #137643; }
.badge-rejected { background: #fee2e2; color: #b91c1c; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--color-border);
}
.page-num { font-size: 12px; color: var(--color-text-muted); font-weight: 600; }

/* Editor Form */
.editor-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--color-border);
}
.editor-header h1 { font-size: 20px; font-weight: 800; margin: 0; color: var(--color-text); }
.state-meta { font-size: 13px; color: var(--color-text-muted); margin: 4px 0 0 0; }
.lock-banner {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  margin-bottom: 14px;
}

/* Form Controls - Standardized */
.form-group { margin-bottom: 14px; }
.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 640px) {
  .pair { grid-template-columns: 1fr; }
}
label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 6px;
}
.req { color: var(--color-error); }

/* All text/date/number/email/select/textarea inputs have width 100%, padding 10px 14px, border 1px #eeeae8, radius 12px */
input:not([type="checkbox"]):not([type="radio"]), select, textarea, #filter {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  color: var(--color-text);
  background: #fff;
  border: 1px solid #eeeae8;
  border-radius: 12px;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:not([type="checkbox"]):not([type="radio"]):focus, select:focus, textarea:focus, #filter:focus {
  border-color: #d23922;
  box-shadow: 0 0 0 2px rgba(210, 57, 34, 0.12);
}
input:disabled, textarea:disabled, select:disabled {
  background: #f6f4f3;
  color: #888;
  cursor: not-allowed;
}
input[type="checkbox"], input[type="radio"] {
  width: auto;
  cursor: pointer;
}
textarea { resize: vertical; }

.label-with-counter {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.counter {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
}
.counter.warn { color: var(--color-warning); font-weight: 700; }
.counter.block { color: var(--color-error); font-weight: 800; }
.field-error {
  color: var(--color-error);
  font-size: 12px;
  font-weight: 600;
  margin-top: 4px;
  min-height: 16px;
}

/* Permalink Preview */
.permalink-box {
  background: #f6f4f3;
  border: 1px dashed var(--color-border);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 14px;
  word-break: break-all;
}
.permalink-label { font-weight: 600; color: var(--color-text-muted); margin-right: 6px; }
.permalink-val { font-family: monospace; font-weight: 700; color: var(--color-primary); }

/* Category Tree with Same-Row Primary Radio */
.category-tree {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid #eeeae8;
  border-radius: 12px;
  background: #fff;
  padding: 10px;
}
.cat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 10px;
  border-radius: 8px;
  transition: background 0.15s ease;
}
.cat-item:hover { background: #fdf7f6; }
.cat-left {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  margin: 0;
}
.cat-primary-inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-primary);
  background: #fdf5f4;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(210, 57, 34, 0.2);
  cursor: pointer;
  margin: 0;
}
.depth-1 { margin-left: 20px; border-left: 2px solid var(--color-border); }
.depth-2 { margin-left: 40px; border-left: 2px solid var(--color-border); }

/* Tags Widget */
.tags-container {
  border: 1px solid #eeeae8;
  border-radius: 12px;
  background: #fff;
  padding: 10px;
}
.tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
  min-height: 24px;
}
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f4f1f0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
}
.tag-remove {
  border: 0;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0;
  font-size: 14px;
  line-height: 1;
}
.tag-remove:hover { color: var(--color-error); }
.tag-input-row {
  display: flex;
  gap: 8px;
}

/* Image Widget */
.image-upload-widget {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 16px;
  align-items: start;
}
@media (max-width: 640px) {
  .image-upload-widget { grid-template-columns: 1fr; }
}
.image-preview-box {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  overflow: hidden;
  background: #eeeae8;
  display: flex;
  align-items: center;
  justify-content: center;
}
.image-preview-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.placeholder-box {
  font-size: 11px;
  color: var(--color-text-muted);
  text-align: center;
  padding: 8px;
}
.upload-action-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.helper-text { font-size: 12px; color: var(--color-text-muted); }

/* Checkboxes */
.checkbox-align {
  display: flex;
  align-items: center;
  padding-top: 24px;
}
.check-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
  margin: 0;
}

/* Google SERP Card */
.serp-wrapper {
  margin-top: 14px;
  border-top: 1px solid var(--color-border);
  padding-top: 14px;
}
.serp-title-bar {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.serp-box {
  background: #ffffff;
  border: 1px solid #dadce0;
  border-radius: 12px;
  padding: 16px;
  max-width: 600px;
}
.serp-url-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  line-height: 1.3;
  margin-bottom: 4px;
}
.serp-site-name { font-weight: 600; color: #202124; }
.serp-url { color: #4d5156; word-break: break-all; }
.serp-link {
  color: #1a0dab;
  font-size: 18px;
  font-weight: 400;
  line-height: 1.3;
  cursor: pointer;
  margin-bottom: 4px;
}
.serp-link:hover { text-decoration: underline; }
.serp-desc {
  font-size: 14px;
  line-height: 1.4;
  color: #4d5156;
  word-break: break-word;
}

/* Editor Toolbar & Panes */
.content-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 10px;
}
.content-tabs {
  display: inline-flex;
  background: #eeeae8;
  padding: 3px;
  border-radius: var(--radius-pill);
}
.tab-btn {
  border: 0;
  background: transparent;
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-pill);
  cursor: pointer;
  color: var(--color-text-muted);
}
.tab-btn.active {
  background: #fff;
  color: var(--color-text);
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.tb-btn {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.tb-btn:hover { border-color: var(--color-accent); color: var(--color-accent); }
.tb-accent { background: #fdf5f4; border-color: var(--color-accent); color: var(--color-primary); }

.pane-preview {
  min-height: 400px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 20px;
  overflow-y: auto;
}
.article-preview-content {
  line-height: 1.7;
  font-size: 15px;
}
.article-preview-content h2, .article-preview-content h3 { color: var(--color-primary); }
.article-preview-content img { max-width: 100%; height: auto; border-radius: 8px; }
.article-preview-content table { border-collapse: collapse; width: 100%; margin: 16px 0; }
.article-preview-content th, .article-preview-content td { border: 1px solid var(--color-border); padding: 8px 12px; text-align: left; }
.article-preview-content th { background: #faf8f7; }

/* Actions Bar */
.editor-actions-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
}
.extra-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.policy-card, .history-details {
  margin-top: 16px;
  background: #faf8f7;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 14px;
}
.history-details summary { font-weight: 600; cursor: pointer; }
.history-details pre {
  margin: 10px 0 0 0;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 10px;
  font-size: 12px;
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
}

/* Alert Message */
.alert-box {
  background: #fdf2f2;
  border: 1px solid #fecaca;
  color: var(--color-error);
  padding: 12px 16px;
  border-radius: 12px;
  margin-bottom: 16px;
  font-size: 14px;
  font-weight: 600;
}

[hidden] { display: none !important; }

/* =========================================================
   Layout v2 (Claude UI review 2026-11-06): writing-first editor
   ========================================================= */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }

/* Header */
.header-inner { gap: 20px; }
.main-tabs { display: flex; gap: 4px; margin-right: auto; margin-left: 12px; }
.main-tab { border: 0; background: transparent; font: inherit; font-size: 14px; font-weight: 600; color: var(--color-text-muted); padding: 8px 14px; border-radius: 10px; cursor: pointer; }
.main-tab:hover { background: #f4f1f0; color: var(--color-text); }
.main-tab.active { background: #fbe9e5; color: var(--color-primary); }
.site-link { font-size: 13px; color: var(--color-text-muted); text-decoration: none; }
.site-link:hover { color: var(--color-accent); }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-block { width: 100%; }
.icon-btn { width: 34px; height: 34px; display: inline-grid; place-items: center; border: 1px solid var(--color-border); background: #fff; border-radius: 10px; cursor: pointer; font-size: 16px; color: var(--color-text-muted); flex: none; }
.icon-btn:hover { border-color: var(--color-accent); color: var(--color-accent); }

/* Login */
.login-card { max-width: 440px; margin: 10vh auto 0; text-align: center; padding: 40px 32px; }
.login-card h1 { margin: 12px 0 8px; font-size: 28px; letter-spacing: -.02em; }
.login-card p { color: var(--color-text-muted); margin: 0 0 24px; }
.login-badge { display: inline-block; font-size: 12px; font-weight: 700; color: var(--color-accent); background: #fbe9e5; padding: 4px 10px; border-radius: 999px; }
.login-help { font-size: 13px; margin: 18px 0 0 !important; }

/* Posts view */
.app-main { padding: 16px 20px 40px; }
.columns { grid-template-columns: 320px minmax(0, 1fr); gap: 20px; }
.sidebar-card { position: sticky; top: 76px; max-height: calc(100vh - 92px); display: flex; flex-direction: column; padding: 16px; }
.sidebar-header { display: grid; gap: 10px; }
.sidebar-title-row { display: flex; align-items: center; justify-content: space-between; }
.sidebar-title-row h2 { margin: 0; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.count-chip { font-size: 12px; font-weight: 700; color: var(--color-text-muted); background: #f4f1f0; border-radius: 999px; padding: 1px 8px; }
.count-chip:empty { display: none; }
.sidebar-header input[type="search"] { width: 100%; }
.filter-pills { display: flex; flex-wrap: nowrap; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.filter-pills .pill { flex: none; }
.posts-list { overflow-y: auto; margin: 12px -4px 0; padding: 0 4px; flex: 1; min-height: 120px; display: grid; gap: 6px; align-content: start; }
.post-item-btn { padding: 10px 12px; border-radius: 12px; }
.post-item-title { font-size: 14px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.post-item-meta { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.post-item-info { font-size: 12px; color: var(--color-text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pagination { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--color-border); display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* Empty state */
.empty-state { background: var(--color-card); border: 1px dashed #e2d9d6; border-radius: var(--radius-card); padding: 48px 32px; text-align: center; }
.empty-icon { font-size: 40px; }
.empty-state h2 { margin: 10px 0 6px; font-size: 22px; }
.empty-state > p { color: var(--color-text-muted); margin: 0 auto 20px; max-width: 460px; }
.stats-row { display: flex; justify-content: center; gap: 12px; margin: 28px 0 8px; flex-wrap: wrap; }
.stat { min-width: 120px; padding: 14px 16px; border: 1px solid var(--color-border); border-radius: 14px; background: #fff; display: grid; }
.stat b { font-size: 26px; line-height: 1.1; }
.stat span { font-size: 13px; color: var(--color-text-muted); }
.flow-steps { list-style: none; counter-reset: step; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding: 0; margin: 24px auto 0; max-width: 720px; text-align: left; }
.flow-steps li { counter-increment: step; padding: 14px; border-radius: 14px; background: #faf6f5; display: grid; gap: 2px; }
.flow-steps li::before { content: counter(step); width: 24px; height: 24px; border-radius: 50%; background: var(--color-accent); color: #fff; font-size: 13px; font-weight: 700; display: grid; place-items: center; margin-bottom: 6px; }
.flow-steps b { font-size: 14px; }
.flow-steps span { font-size: 12.5px; color: var(--color-text-muted); }

/* Editor */
.editor-card { padding: 0; overflow: visible; }
.editor-topbar { position: sticky; top: 61px; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 20px; background: rgba(255,255,255,.96); backdrop-filter: blur(6px); border-bottom: 1px solid var(--color-border); border-radius: var(--radius-card) var(--radius-card) 0 0; }
.editor-topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.editor-topbar-left h1 { margin: 0; font-size: 16px; }
.state-meta { margin: 0; font-size: 12px; color: var(--color-text-muted); }
.editor-topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.extra-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.dirty-flag { font-size: 12px; font-weight: 600; color: var(--color-warning); }
.back-btn { display: none; }
.lock-banner { margin: 16px 20px 0; }
.editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; padding: 20px; align-items: start; }
.editor-main { display: grid; gap: 18px; min-width: 0; }
.title-group { margin: 0; }
#title { width: 100%; border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: 4px 0 8px; font: inherit; font-size: 28px; font-weight: 800; line-height: 1.3; letter-spacing: -.02em; resize: none; overflow: hidden; background: transparent; color: var(--color-text); box-shadow: none; }
#title:focus { outline: none; border-bottom-color: var(--color-accent); }
#title::placeholder { color: #c2bab7; }
.content-card { border: 1px solid var(--color-border); border-radius: 14px; overflow: hidden; background: #fff; }
.content-header-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; padding: 8px 10px; background: #faf8f7; border-bottom: 1px solid var(--color-border); margin: 0; }
.content-tabs { display: flex; gap: 4px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 4px; }
.pane-editor textarea#body { width: 100%; min-height: 520px; border: 0; border-radius: 0; padding: 18px 20px; font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 15px; line-height: 1.75; resize: vertical; box-shadow: none; display: block; }
.pane-editor textarea#body:focus { outline: none; }
.pane-preview { padding: 18px 22px; min-height: 520px; }
.md-help { margin: 0; padding: 8px 14px; border-top: 1px solid var(--color-border); background: #faf8f7; font-size: 12px; }
.md-help code { background: #fff; border: 1px solid var(--color-border); border-radius: 4px; padding: 0 4px; font-size: 11.5px; }
.content-card .field-error { padding: 0 14px; }

/* Settings sidebar */
.editor-side { display: grid; gap: 14px; position: sticky; top: 132px; max-height: calc(100vh - 148px); overflow-y: auto; padding-right: 2px; }
.side-card { border: 1px solid var(--color-border); border-radius: 14px; padding: 14px; background: #fff; display: grid; gap: 10px; margin: 0; }
.side-card .form-group { margin: 0; }
.side-title { margin: 0; font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--color-text-muted); }
details.side-card > summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
details.side-card > summary::-webkit-details-marker { display: none; }
details.side-card > summary::after { content: "\25BE"; font-size: 12px; transition: transform .15s; }
details.side-card[open] > summary::after { transform: rotate(180deg); }
details.side-card:not([open]) { gap: 0; }
.side-card .helper-text { margin: 0; font-size: 12px; }
.side-card .category-tree { max-height: 260px; }
.permalink-box { margin: 0; padding: 8px 10px; font-size: 12px; word-break: break-all; }
.image-preview-box { aspect-ratio: 1200 / 630; border-radius: 10px; overflow: hidden; background: #faf6f5; display: grid; }
.image-preview-box img { width: 100%; height: 100%; object-fit: cover; }
.image-preview-box .placeholder-box { width: 100%; height: 100%; border: 1.5px dashed #e2d9d6; border-radius: 10px; background: transparent; font: inherit; font-size: 13px; color: var(--color-text-muted); cursor: pointer; }
.image-preview-box .placeholder-box:hover { border-color: var(--color-accent); color: var(--color-accent); }
.upload-action-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
details.advanced summary { cursor: pointer; font-size: 13px; color: var(--color-text-muted); }
details.advanced[open] { display: grid; gap: 10px; }
.serp-box { margin: 4px 0 0; }
.history-details pre { white-space: pre-wrap; font-size: 12px; max-height: 240px; overflow: auto; margin: 0; }
.side-card .pair { grid-template-columns: 1fr 1fr; gap: 8px; }

/* Users */
.users-section { max-width: 920px; margin: 0 auto; display: grid; gap: 18px; }
.users-head h2 { margin: 0 0 2px; }
.users-head p { margin: 0; }
.invite-form { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto; gap: 12px; align-items: end; padding: 16px; background: #faf8f7; border-radius: 14px; }
.invite-form .form-group { margin: 0; }
.user-list { display: grid; gap: 8px; }
.user-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 14px; border: 1px solid var(--color-border); border-radius: 12px; }
.user-row.is-locked { opacity: .6; }
.user-info { display: grid; margin-right: auto; min-width: 200px; }
.user-info b { font-size: 14px; }
.user-row select { width: auto; }
.import-details { border-top: 1px solid var(--color-border); padding-top: 14px; }
.import-details summary { cursor: pointer; font-size: 13px; color: var(--color-text-muted); }

/* Tablet */
@media (max-width: 1180px) {
  .editor-grid { grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; }
}

/* Mobile: one column; list OR editor */
@media (max-width: 960px) {
  .app-main { padding: 12px 12px 40px; }
  .header-inner { padding: 10px 12px; gap: 10px; flex-wrap: wrap; }
  .main-tabs { order: 3; width: 100%; margin: 0; }
  .site-link { display: none; }
  .user-pill { max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .columns { grid-template-columns: 1fr; }
  .sidebar-card { position: static; max-height: none; }
  .posts-list { max-height: none; overflow: visible; }
  body.is-editing .sidebar-card { display: none; }
  body:not(.is-editing) .editor-area { display: none; }
  .back-btn { display: inline-grid; }
  .editor-topbar { top: 0; padding: 10px 12px; }
  .editor-topbar-right { width: 100%; }
  .editor-topbar-right .btn { flex: 1 1 auto; }
  .editor-grid { grid-template-columns: 1fr; padding: 14px 12px; }
  .editor-side { position: static; max-height: none; overflow: visible; }
  #title { font-size: 22px; }
  .pane-editor textarea#body { min-height: 60vh; padding: 14px; font-size: 16px; }
  .flow-steps { grid-template-columns: 1fr; }
  .invite-form { grid-template-columns: 1fr; }
}

/* Medium screens: give the editor the full width while editing */
@media (max-width: 1399px) {
  body.is-editing .columns { grid-template-columns: minmax(0, 1fr); }
  body.is-editing .sidebar-card { display: none; }
  body.is-editing .back-btn { display: inline-grid; }
}

/* Category tree inside the narrow settings column */
.side-card .category-tree { padding: 6px; }
.side-card .cat-item { justify-content: space-between; gap: 6px; padding: 5px 6px; }
.side-card .cat-left { min-width: 0; flex: 1; }
.side-card .cat-primary-inline { flex: none; white-space: nowrap; padding: 1px 7px; }
.side-card .depth-1 { margin-left: 12px; }
.side-card .depth-2 { margin-left: 24px; }
@media (max-width: 960px) {
  .header-right { margin-left: auto; }
  .header-right .user-pill { display: none; }
  .main-tab { flex: 1; }
}
