:root {
  --brand-red: #ba1e26;
  --brand-red-dark: #94151c;
  --ink: #111111;
  --ink-soft: #373737;
  --muted: #666666;
  --rule: #dfdcd5;
  --bg: #f6f4ef;
  --surface: #ffffff;
  --ok-bg: #ecf7ef;
  --ok-text: #186234;
  --err-bg: #fdeeee;
  --err-text: #9d171f;
  --font-display: "Lora", Georgia, serif;
  --font-serif: "Lora", Georgia, serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

.staff-topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: #141414;
  color: #f4f1ea;
  border-bottom: 3px solid var(--brand-red);
}

.staff-topbar-inner {
  max-width: 1380px;
  margin: 0 auto;
  padding: 0 24px;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.staff-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.staff-brand img {
  width: 26px;
  height: 26px;
  border-radius: 2px;
}

.staff-brand-title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.25rem;
  font-weight: 700;
  color: #ffffff;
}

.staff-brand-tag {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 2px 7px;
  background: var(--brand-red);
  color: #ffffff;
  border-radius: 2px;
}

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

.staff-nav a {
  padding: 7px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #cfcac0;
  border-radius: 3px;
}

.staff-nav a:hover,
.staff-nav a.is-active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.11);
}

.staff-user-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.8rem;
  color: #d6d2c9;
}

.staff-main {
  max-width: 1380px;
  margin: 0 auto;
  padding: 28px 24px 64px;
}

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

.page-head h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 700;
}

.page-head p {
  margin: 4px 0 0;
  color: var(--muted);
}

/* Flash banners */
.flash {
  padding: 12px 16px;
  border-radius: 4px;
  margin-bottom: 20px;
  font-weight: 600;
  font-size: 0.88rem;
}

.flash--ok {
  background: var(--ok-bg);
  color: var(--ok-text);
  border-left: 4px solid var(--ok-text);
}

.flash--err {
  background: var(--err-bg);
  color: var(--err-text);
  border-left: 4px solid var(--err-text);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 15px;
  border-radius: 3px;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-primary {
  background: var(--brand-red);
  color: #ffffff;
  border-color: var(--brand-red);
}

.btn-primary:hover {
  background: var(--brand-red-dark);
}

.btn-dark {
  background: var(--ink);
  color: #ffffff;
  border-color: var(--ink);
}

.btn-dark:hover {
  background: #2b2b2b;
}

.btn-secondary {
  background: #ffffff;
  color: var(--ink);
  border-color: #c8c3b8;
}

.btn-secondary:hover {
  border-color: var(--ink);
}

.btn-ghost {
  background: transparent;
  color: #d6d2c9;
  border-color: rgba(255, 255, 255, 0.28);
  padding: 5px 10px;
  font-size: 0.72rem;
}

.btn-ghost:hover {
  color: #ffffff;
  border-color: #ffffff;
}

.btn-danger {
  background: #ffffff;
  color: var(--err-text);
  border-color: #e4b6b9;
}

.btn-danger:hover {
  background: var(--err-bg);
  border-color: var(--err-text);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.72rem;
}

/* Cards & Stats */
.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 22px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.stat-tile {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-top: 3px solid var(--ink);
  border-radius: 4px;
  padding: 16px 18px;
}

.stat-tile--red {
  border-top-color: var(--brand-red);
}

.stat-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-val {
  margin-top: 4px;
  font-family: var(--font-display);
  font-size: 1.85rem;
  font-weight: 700;
  line-height: 1.1;
}

/* Filter Bar & Tables */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 18px;
}

.input,
.select,
.textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #c9c4ba;
  border-radius: 3px;
  background: #ffffff;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 0.9rem;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: 2px solid var(--brand-red);
  outline-offset: -1px;
}

.filter-bar .input,
.filter-bar .select {
  width: auto;
  min-width: 160px;
}

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 4px;
}

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

table.staff-table th,
table.staff-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #ece9e1;
  text-align: left;
  vertical-align: middle;
}

table.staff-table th {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  background: #faf9f6;
}

.story-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.story-thumb {
  width: 64px;
  height: 44px;
  object-fit: cover;
  border-radius: 2px;
  background: #ece9e1;
  flex-shrink: 0;
}

.story-cell-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
}

.story-cell-title:hover {
  color: var(--brand-red);
}

.story-cell-meta {
  font-size: 0.76rem;
  color: var(--muted);
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 2px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

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

.badge-draft {
  background: #fff4df;
  color: #8a5600;
}

.badge-archived {
  background: #eceae5;
  color: #555555;
}

.badge-placement {
  background: #f8e8e9;
  color: var(--brand-red);
}

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

.actions-row form {
  margin: 0;
}

/* =========================================================
   ARTICLE COMPOSER & LIVE PREVIEW
   ========================================================= */
.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
  align-items: start;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.73rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.field-hint {
  margin-top: 4px;
  font-size: 0.76rem;
  color: var(--muted);
}

.headline-input {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 700;
  padding: 12px 14px;
}

.dek-input {
  font-family: var(--font-serif);
  font-size: 1.05rem;
}

.md-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  background: #faf9f6;
  border: 1px solid #c9c4ba;
  border-bottom: none;
  border-radius: 3px 3px 0 0;
}

.md-toolbar-group {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tb-btn {
  padding: 5px 9px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 3px;
  font-family: var(--font-sans);
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
}

.tb-btn:hover,
.tb-btn.is-active {
  background: #ffffff;
  border-color: #c9c4ba;
  color: var(--brand-red);
}

.md-textarea {
  min-height: 460px;
  border-radius: 0 0 3px 3px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.92rem;
  line-height: 1.65;
  resize: vertical;
}

.preview-pane {
  display: none;
  min-height: 460px;
  padding: 28px 32px;
  background: #ffffff;
  border: 1px solid #c9c4ba;
  border-radius: 0 0 3px 3px;
  font-family: var(--font-serif);
  font-size: 1.15rem;
  line-height: 1.75;
}

.preview-pane.is-visible {
  display: block;
}

.preview-pane blockquote {
  margin: 1.5em 0;
  padding-left: 20px;
  border-left: 3px solid var(--brand-red);
  font-family: var(--font-display);
  font-style: italic;
}

.preview-pane img {
  margin: 1.5em auto;
  border-radius: 2px;
}

.cover-preview-box {
  margin-bottom: 12px;
  border: 1px dashed #c8c3b8;
  border-radius: 3px;
  background: #faf9f6;
  padding: 12px;
  text-align: center;
}

.cover-preview-box img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 2px;
  margin-bottom: 8px;
}

.upload-status {
  margin-top: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}

/* Media Picker Grid */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 16px;
}

.media-card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.media-card img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: #ece9e1;
}

.media-card-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.media-picker-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  padding-top: 8px;
}

.picker-thumb-btn {
  padding: 0;
  border: 2px solid transparent;
  background: #ece9e1;
  border-radius: 2px;
  overflow: hidden;
  cursor: pointer;
}

.picker-thumb-btn:hover {
  border-color: var(--brand-red);
}

.picker-thumb-btn img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
}

/* Login Page */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #141414;
}

.login-card {
  width: 100%;
  max-width: 410px;
  background: #ffffff;
  border-top: 4px solid var(--brand-red);
  border-radius: 4px;
  padding: 36px 32px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 10px;
}

.login-brand img {
  width: 34px;
  height: 34px;
  border-radius: 2px;
}

.login-brand span {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.8rem;
  font-weight: 700;
}

.login-sub {
  text-align: center;
  margin: 0 0 24px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .editor-grid,
  .two-col {
    grid-template-columns: 1fr;
  }
}
