/*
 * WBC Digital CMS — admin interface.
 *
 * Hand-written CSS with no build step, so the whole CMS deploys by upload.
 * Design tokens are CSS custom properties; the brand blue (#146EF5) matches
 * the public site so the two feel like one product.
 */

/* ---------------------------------------------------------------- tokens */
:root {
  --blue:        #146EF5;
  --blue-dark:   #0B52D6;
  --blue-soft:   #E8F0FF;
  --blue-ring:   rgba(20, 110, 245, 0.18);

  --ink:         #0E1201;
  --ink-2:       #2C3038;
  --muted:       #64676D;
  --muted-2:     #8A8F98;

  --bg:          #F7F7F4;
  --surface:     #FFFFFF;
  --surface-2:   #FBFBF9;
  --line:        #E7E4DB;
  --line-2:      #F0EEE8;

  --ok:          #0F6B4C;
  --ok-soft:     #E6F5EF;
  --warn:        #8A5A00;
  --warn-soft:   #FFF3D6;
  --danger:      #B3261E;
  --danger-soft: #FDECEA;
  --info:        #1A4D7C;
  --info-soft:   #E8F2FA;

  --sidebar-bg:  #0B0F1A;
  --sidebar-ink: #C7CBD4;

  --radius:      12px;
  --radius-sm:   8px;
  --radius-lg:   18px;

  --shadow-sm:   0 1px 2px rgba(14, 18, 1, 0.05);
  --shadow:      0 4px 16px -6px rgba(14, 18, 1, 0.12);
  --shadow-lg:   0 24px 48px -20px rgba(14, 18, 1, 0.26);

  --sans:        'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display:     'DM Sans', var(--sans);
  --mono:        'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --sidebar-w:   248px;
  --header-h:    64px;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--display); letter-spacing: -0.02em; margin: 0; }

a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-dark); }

img { max-width: 100%; }

/* Visible focus for keyboard users on every interactive element. Removing
   this without an equivalent replacement makes the CMS unusable by keyboard. */
:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
  border-radius: 4px;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Skip link — first tab stop on every page. */
.skip-link {
  position: absolute; left: -9999px; top: 8px; z-index: 999;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--radius-sm);
}
.skip-link:focus { left: 8px; color: #fff; }

/* ---------------------------------------------------------------- layout */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-ink);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar__brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar__brand img { width: 34px; height: 34px; border-radius: 8px; object-fit: cover; }
.sidebar__brand-text { font-family: var(--display); font-weight: 800; font-size: 15px; color: #fff; line-height: 1.2; }
.sidebar__brand-sub { font-size: 11px; color: #737C90; font-family: var(--mono); letter-spacing: 0.06em; }

.sidebar__nav { padding: 14px 12px; flex: 1; }

.sidebar__group + .sidebar__group { margin-top: 22px; }
.sidebar__group-label {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em;
  text-transform: uppercase; color: #5A6274; padding: 0 10px 8px;
}

.sidebar__link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--sidebar-ink) !important; font-size: 13.5px; font-weight: 500;
  transition: background .15s ease, color .15s ease;
}
.sidebar__link:hover { background: rgba(255,255,255,0.06); color: #fff !important; }
.sidebar__link.is-active { background: var(--blue); color: #fff !important; }
.sidebar__link svg { width: 17px; height: 17px; flex: 0 0 17px; }
.sidebar__count {
  margin-left: auto; font-size: 11px; font-family: var(--mono);
  background: rgba(255,255,255,0.1); padding: 2px 7px; border-radius: 20px;
}
.sidebar__link.is-active .sidebar__count { background: rgba(255,255,255,0.22); }
.sidebar__count--alert { background: var(--blue); color: #fff; }

.sidebar__footer { padding: 14px; border-top: 1px solid rgba(255,255,255,0.08); }
.sidebar__user { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.sidebar__avatar {
  width: 32px; height: 32px; border-radius: 50%; object-fit: cover;
  background: var(--blue); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex: 0 0 32px;
}
.sidebar__user-name { font-size: 13px; color: #fff; font-weight: 600; line-height: 1.25; }
.sidebar__user-role { font-size: 11px; color: #737C90; font-family: var(--mono); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 30;
}
.topbar__title { font-size: 17px; font-weight: 700; font-family: var(--display); }
.topbar__actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.content { padding: 26px; flex: 1; max-width: 1400px; width: 100%; }
.content--narrow { max-width: 880px; }

.nav-toggle { display: none; background: none; border: 0; cursor: pointer; padding: 8px; color: var(--ink); }

/* ----------------------------------------------------------- components */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card__header {
  padding: 16px 20px; border-bottom: 1px solid var(--line-2);
  display: flex; align-items: center; gap: 12px;
}
.card__title { font-size: 14.5px; font-weight: 700; font-family: var(--display); }
.card__body { padding: 20px; }
.card__footer {
  padding: 14px 20px; border-top: 1px solid var(--line-2);
  background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius);
  display: flex; gap: 10px; align-items: center;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-family: var(--display); font-weight: 600; font-size: 13.5px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .1s ease, color .15s ease;
  white-space: nowrap; text-decoration: none; line-height: 1.3;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 15px; height: 15px; }

.btn--primary { background: var(--blue); color: #fff !important; }
.btn--primary:hover { background: var(--blue-dark); color: #fff !important; }

.btn--secondary { background: var(--surface); color: var(--ink) !important; border-color: var(--line); }
.btn--secondary:hover { background: var(--surface-2); border-color: var(--muted-2); color: var(--ink) !important; }

.btn--ghost { background: transparent; color: var(--muted) !important; }
.btn--ghost:hover { background: var(--line-2); color: var(--ink) !important; }

.btn--danger { background: var(--danger); color: #fff !important; }
.btn--danger:hover { background: #8E1D17; color: #fff !important; }

.btn--danger-ghost { background: transparent; color: var(--danger) !important; border-color: var(--line); }
.btn--danger-ghost:hover { background: var(--danger-soft); border-color: var(--danger); }

.btn--sm { padding: 6px 11px; font-size: 12.5px; }
.btn--icon { padding: 7px; }
.btn--block { width: 100%; }

/* A disabled button must look disabled and stop pointer events, or a
   double-click during submit fires the action twice. */
.btn[disabled], .btn.is-loading { opacity: .55; pointer-events: none; }
.btn.is-loading::after {
  content: ''; width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------ form bits */
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }

.label {
  display: block; font-size: 12.5px; font-weight: 600;
  color: var(--ink-2); margin-bottom: 6px;
}
.label__optional { color: var(--muted-2); font-weight: 400; }

.help { font-size: 12px; color: var(--muted); margin-top: 5px; line-height: 1.45; }

.input, .textarea, .select {
  width: 100%; font-family: var(--sans); font-size: 14px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 9px 12px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus, .textarea:focus, .select:focus {
  outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-ring);
}
.input::placeholder, .textarea::placeholder { color: var(--muted-2); }
.textarea { resize: vertical; min-height: 84px; line-height: 1.6; }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364676D' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
  padding-right: 32px;
}

.input--title {
  font-family: var(--display); font-size: 24px; font-weight: 800;
  letter-spacing: -0.02em; padding: 12px 14px;
}

.input.has-error, .textarea.has-error, .select.has-error { border-color: var(--danger); }
.field__error { font-size: 12px; color: var(--danger); margin-top: 5px; font-weight: 500; }

.checkbox, .radio { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; }
.checkbox input, .radio input { margin: 2px 0 0; width: 15px; height: 15px; accent-color: var(--blue); flex: 0 0 15px; }
.checkbox__text { font-size: 13.5px; }
.checkbox__hint { font-size: 12px; color: var(--muted); }

.input-group { display: flex; }
.input-group .input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group__addon {
  display: flex; align-items: center; padding: 0 11px;
  background: var(--surface-2); border: 1px solid var(--line); border-right: 0;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap;
}
.input-group__addon + .input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

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

/* ---------------------------------------------------------------- badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; font-family: var(--mono);
  letter-spacing: 0.04em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 20px;
  background: var(--line-2); color: var(--muted);
}
.badge--published { background: var(--ok-soft); color: var(--ok); }
.badge--draft     { background: var(--line-2); color: var(--muted); }
.badge--scheduled { background: var(--warn-soft); color: var(--warn); }
.badge--archived  { background: var(--danger-soft); color: var(--danger); }
.badge--featured  { background: var(--blue-soft); color: var(--blue); }
.badge--new       { background: var(--blue); color: #fff; }

.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; font-family: var(--mono); font-size: 10.5px;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted-2);
  font-weight: 500; padding: 11px 16px; border-bottom: 1px solid var(--line);
  white-space: nowrap; background: var(--surface-2);
}
.table td { padding: 13px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table__title { font-weight: 600; color: var(--ink); font-size: 14px; }
.table__meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.table__thumb {
  width: 44px; height: 34px; border-radius: 6px; object-fit: cover;
  background: var(--line-2); flex: 0 0 44px;
}
.table__actions { display: flex; gap: 6px; justify-content: flex-end; }
.table__drag { cursor: grab; color: var(--muted-2); padding: 4px; }
.table__drag:active { cursor: grabbing; }
tr.is-dragging { opacity: .4; background: var(--blue-soft) !important; }

/* ------------------------------------------------------------- messages */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 15px; border-radius: var(--radius-sm);
  font-size: 13.5px; margin-bottom: 18px; border: 1px solid transparent;
}
.alert svg { flex: 0 0 17px; width: 17px; height: 17px; margin-top: 1px; }
.alert--success { background: var(--ok-soft); color: var(--ok); border-color: #B7D9C9; }
.alert--error   { background: var(--danger-soft); color: var(--danger); border-color: #F2C4C0; }
.alert--info    { background: var(--info-soft); color: var(--info); border-color: #C3DDF0; }
.alert--warning { background: var(--warn-soft); color: var(--warn); border-color: #ECD9A8; }
.alert__close { margin-left: auto; background: none; border: 0; cursor: pointer; color: inherit; opacity: .6; padding: 0; }
.alert__close:hover { opacity: 1; }

.empty {
  text-align: center; padding: 56px 24px; color: var(--muted);
}
.empty__icon {
  width: 46px; height: 46px; margin: 0 auto 14px;
  color: var(--muted-2); opacity: .5;
}
.empty__title { font-family: var(--display); font-size: 16px; font-weight: 700; color: var(--ink); margin-bottom: 6px; }
.empty__text { font-size: 13.5px; max-width: 38ch; margin: 0 auto 18px; line-height: 1.6; }

/* ------------------------------------------------------------ dashboard */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px;
  display: block; color: inherit; transition: border-color .15s ease, transform .15s ease;
}
a.stat:hover { border-color: var(--blue); transform: translateY(-2px); color: inherit; }
.stat__label {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--muted-2); margin-bottom: 9px;
  display: flex; align-items: center; gap: 6px;
}
.stat__value { font-family: var(--display); font-size: 30px; font-weight: 800; line-height: 1; letter-spacing: -0.03em; }
.stat__sub { font-size: 12px; color: var(--muted); margin-top: 7px; }
.stat__sub b { color: var(--ink-2); font-weight: 600; }

.sparkline { display: flex; align-items: flex-end; gap: 4px; height: 44px; margin-top: 12px; }
.sparkline__bar {
  flex: 1; background: var(--blue-soft); border-radius: 3px 3px 0 0;
  min-height: 3px; position: relative;
}
.sparkline__bar:last-child { background: var(--blue); }
.sparkline__labels {
  display: flex; gap: 4px; margin-top: 5px;
  font-family: var(--mono); font-size: 9.5px; color: var(--muted-2);
}
.sparkline__labels span { flex: 1; text-align: center; }

.timeline { display: flex; flex-direction: column; }
.timeline__item {
  display: flex; gap: 11px; padding: 11px 0;
  border-bottom: 1px solid var(--line-2); font-size: 13px;
}
.timeline__item:last-child { border-bottom: 0; }
.timeline__dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--blue);
  margin-top: 6px; flex: 0 0 7px;
}
.timeline__time { margin-left: auto; font-size: 11.5px; color: var(--muted-2); white-space: nowrap; }

/* ------------------------------------------------------------- toolbar */
.toolbar {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap; margin-bottom: 16px;
}
.toolbar__search { position: relative; flex: 1; min-width: 200px; max-width: 340px; }
.toolbar__search .input { padding-left: 34px; }
.toolbar__search svg {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--muted-2); pointer-events: none;
}
.toolbar__spacer { flex: 1; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tab {
  padding: 9px 14px; font-size: 13.5px; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent; white-space: nowrap; margin-bottom: -1px;
}
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--blue); border-bottom-color: var(--blue); }
.tab__count { font-family: var(--mono); font-size: 11px; opacity: .7; margin-left: 4px; }

.pagination { display: flex; gap: 5px; align-items: center; justify-content: center; padding: 18px 0 0; }
.pagination__link {
  min-width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: 13px; color: var(--ink) !important; background: var(--surface); padding: 0 9px;
}
.pagination__link:hover { border-color: var(--blue); color: var(--blue) !important; }
.pagination__link.is-active { background: var(--blue); border-color: var(--blue); color: #fff !important; }
.pagination__link.is-disabled { opacity: .4; pointer-events: none; }

/* --------------------------------------------------------------- editor */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.editor__side { display: flex; flex-direction: column; gap: 16px; position: sticky; top: calc(var(--header-h) + 20px); }

.editor__bar {
  position: sticky; top: var(--header-h); z-index: 20;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 11px 16px; margin-bottom: 18px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
}
.editor__status { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.editor__status.is-dirty { color: var(--warn); font-weight: 600; }

.slug-preview {
  font-family: var(--mono); font-size: 12px; color: var(--muted);
  display: flex; align-items: center; gap: 6px; margin-top: 6px; flex-wrap: wrap;
}
.slug-preview b { color: var(--ink-2); font-weight: 600; }

/* ---------------------------------------------------------- block builder */
.blocks { display: flex; flex-direction: column; gap: 12px; }

.block {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.block:hover { border-color: var(--muted-2); }
.block.is-open { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-ring); }
.block.is-dragging { opacity: .45; }
.block.is-drop-target { border-color: var(--blue); border-style: dashed; }

.block__head {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; background: var(--surface-2);
  border-bottom: 1px solid transparent; cursor: pointer;
}
.block.is-open .block__head { border-bottom-color: var(--line-2); }
.block__handle { cursor: grab; color: var(--muted-2); display: flex; padding: 2px; }
.block__handle:active { cursor: grabbing; }
.block__icon { width: 26px; height: 26px; border-radius: 6px; background: var(--blue-soft); color: var(--blue);
               display: flex; align-items: center; justify-content: center; flex: 0 0 26px; }
.block__icon svg { width: 14px; height: 14px; }
.block__label { font-weight: 600; font-size: 13.5px; }
.block__summary { font-size: 12px; color: var(--muted); margin-left: 8px;
                  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46ch; }
.block__tools { margin-left: auto; display: flex; gap: 3px; align-items: center; }
.block__body { padding: 16px; display: none; }
.block.is-open .block__body { display: block; }

.block-picker {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 9px; padding: 4px;
}
.block-picker__item {
  display: flex; align-items: center; gap: 9px; padding: 11px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer; text-align: left; width: 100%;
  font-family: var(--sans); font-size: 13px; color: var(--ink);
  transition: border-color .15s ease, background .15s ease;
}
.block-picker__item:hover { border-color: var(--blue); background: var(--blue-soft); }
.block-picker__item svg { width: 16px; height: 16px; color: var(--blue); flex: 0 0 16px; }
.block-picker__desc { font-size: 11.5px; color: var(--muted); display: block; margin-top: 1px; }

.repeater__item {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 13px; margin-bottom: 9px; background: var(--surface-2);
  position: relative;
}
.repeater__head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
  font-size: 11px; font-family: var(--mono); color: var(--muted-2);
  letter-spacing: 0.08em; text-transform: uppercase;
}
.repeater__remove { margin-left: auto; }

/* ------------------------------------------------------------ rich text */
.rte { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.rte:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-ring); }
.rte__toolbar {
  display: flex; gap: 2px; padding: 6px; flex-wrap: wrap;
  border-bottom: 1px solid var(--line-2); background: var(--surface-2);
}
.rte__btn {
  width: 29px; height: 29px; display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: transparent; border-radius: 5px; cursor: pointer; color: var(--ink-2);
}
.rte__btn:hover { background: var(--line-2); }
.rte__btn.is-active { background: var(--blue-soft); color: var(--blue); }
.rte__btn svg { width: 15px; height: 15px; }
.rte__sep { width: 1px; background: var(--line); margin: 4px 4px; }
.rte__area {
  min-height: 160px; padding: 13px 15px; font-size: 15px; line-height: 1.7; outline: none;
}
.rte__area:empty::before { content: attr(data-placeholder); color: var(--muted-2); }
.rte__area p { margin: 0 0 0.9em; }
.rte__area p:last-child { margin-bottom: 0; }
.rte__area h2 { font-size: 1.4em; margin: 1.2em 0 .5em; }
.rte__area h3 { font-size: 1.18em; margin: 1.1em 0 .4em; }
.rte__area ul, .rte__area ol { padding-left: 1.4em; margin: 0 0 .9em; }
.rte__area li { margin-bottom: .3em; }
.rte__area blockquote {
  margin: 1em 0; padding: .5em 0 .5em 1em;
  border-left: 3px solid var(--blue); color: var(--muted); font-style: italic;
}
.rte__area a { text-decoration: underline; }
.rte__area code { font-family: var(--mono); font-size: .9em; background: var(--line-2); padding: 1px 5px; border-radius: 4px; }
.rte__area img { border-radius: var(--radius-sm); }

/* ------------------------------------------------------------ media bits */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 13px; }
.media-item {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  overflow: hidden; background: var(--surface); cursor: pointer;
  transition: border-color .15s ease, transform .15s ease; position: relative;
  padding: 0; text-align: left; width: 100%; font-family: inherit;
}
.media-item:hover { border-color: var(--blue); transform: translateY(-2px); }
.media-item.is-selected { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-ring); }
.media-item__img {
  aspect-ratio: 4 / 3; width: 100%; object-fit: cover; display: block;
  background: var(--line-2);
}
.media-item__body { padding: 9px 11px; }
.media-item__name {
  font-size: 12px; font-weight: 500; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; color: var(--ink);
}
.media-item__meta { font-size: 11px; color: var(--muted-2); font-family: var(--mono); margin-top: 2px; }
.media-item__warn { color: var(--warn); font-size: 11px; margin-top: 3px; display: flex; align-items: center; gap: 4px; }

.image-picker {
  border: 1px dashed var(--line); border-radius: var(--radius-sm);
  padding: 16px; text-align: center; background: var(--surface-2);
  cursor: pointer; transition: border-color .15s ease, background .15s ease;
  width: 100%; font-family: inherit; color: var(--muted);
}
.image-picker:hover { border-color: var(--blue); background: var(--blue-soft); }
.image-picker__preview { position: relative; border-radius: var(--radius-sm); overflow: hidden; }
.image-picker__preview img { display: block; width: 100%; max-height: 190px; object-fit: cover; }
.image-picker__clear {
  position: absolute; top: 7px; right: 7px;
  background: rgba(0,0,0,.62); color: #fff; border: 0; border-radius: 50%;
  width: 25px; height: 25px; cursor: pointer; display: flex;
  align-items: center; justify-content: center;
}
.image-picker__clear:hover { background: rgba(0,0,0,.82); }

.dropzone {
  border: 2px dashed var(--line); border-radius: var(--radius);
  padding: 34px 20px; text-align: center; color: var(--muted);
  transition: border-color .15s ease, background .15s ease;
}
.dropzone.is-over { border-color: var(--blue); background: var(--blue-soft); }

/* ---------------------------------------------------------------- modal */
.modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(14,18,1,.45); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal[hidden] { display: none; }
.modal__panel {
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 780px;
  max-height: 88vh; display: flex; flex-direction: column; overflow: hidden;
}
.modal__panel--sm { max-width: 440px; }
.modal__head {
  padding: 16px 20px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px;
}
.modal__title { font-family: var(--display); font-weight: 700; font-size: 16px; }
.modal__body { padding: 20px; overflow-y: auto; flex: 1; }
.modal__foot {
  padding: 14px 20px; border-top: 1px solid var(--line);
  display: flex; gap: 9px; justify-content: flex-end; background: var(--surface-2);
}
.modal__close { margin-left: auto; background: none; border: 0; cursor: pointer; color: var(--muted); padding: 4px; }
.modal__close:hover { color: var(--ink); }

/* Keyboard hint, matching the "Esc to close / Cmd+Enter to submit" convention
   used throughout the CMS. */
.kbd {
  font-family: var(--mono); font-size: 10.5px; padding: 2px 5px;
  background: var(--line-2); border: 1px solid var(--line);
  border-radius: 4px; color: var(--muted); line-height: 1.4;
}

.toast-stack {
  position: fixed; bottom: 20px; right: 20px; z-index: 200;
  display: flex; flex-direction: column; gap: 9px; max-width: 340px;
}
.toast {
  background: var(--ink); color: #fff; padding: 11px 15px;
  border-radius: var(--radius-sm); font-size: 13.5px;
  box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 9px;
  animation: toast-in .22s cubic-bezier(.16,1,.3,1);
}
.toast--error { background: var(--danger); }
.toast--success { background: var(--ok); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* --------------------------------------------------------------- utility */
.stack { display: flex; flex-direction: column; }
.stack--sm { gap: 8px; }
.stack--md { gap: 16px; }
.stack--lg { gap: 24px; }
.row { display: flex; align-items: center; gap: 10px; }
.row--between { justify-content: space-between; }
.row--wrap { flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------------ auth pages */
.auth {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: radial-gradient(120% 90% at 78% 8%, #123a86 0%, #0a1330 42%, #050812 100%);
}
.auth__card {
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 415px; padding: 34px;
}
.auth__brand { display: flex; align-items: center; gap: 11px; margin-bottom: 24px; }
.auth__brand img { width: 42px; height: 42px; border-radius: 10px; }
.auth__title { font-size: 21px; font-weight: 800; margin-bottom: 5px; }
.auth__sub { color: var(--muted); font-size: 13.5px; margin-bottom: 24px; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1100px) {
  .editor { grid-template-columns: minmax(0, 1fr); }
  .editor__side { position: static; }
}

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

  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 60;
    transform: translateX(-100%); transition: transform .25s ease;
    height: 100vh;
  }
  .sidebar.is-open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .nav-toggle { display: inline-flex; }
  .content { padding: 18px 16px; }
  .topbar { padding: 0 16px; }

  /* Backdrop only exists on mobile, where the sidebar overlays content. */
  .sidebar-backdrop {
    position: fixed; inset: 0; background: rgba(14,18,1,.4);
    z-index: 55; display: none;
  }
  .sidebar-backdrop.is-open { display: block; }
}

@media (max-width: 640px) {
  .grid--2, .grid--3, .grid--4 { grid-template-columns: minmax(0, 1fr); }
  .toolbar__search { max-width: none; }
  .modal { padding: 0; align-items: flex-end; }
  .modal__panel { max-width: none; max-height: 94vh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .card__footer, .modal__foot { flex-direction: column-reverse; }
  .card__footer .btn, .modal__foot .btn { width: 100%; }
}

@media print {
  .sidebar, .topbar, .editor__bar, .btn { display: none !important; }
}

/* ------------------------------------------------------- markdown editor */

/* Blocks / Markdown authoring-mode switch. */
.mode-switch {
  display: inline-flex; background: var(--line-2);
  border-radius: var(--radius-sm); padding: 3px; gap: 2px;
}
.mode-switch__btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border: 0; background: transparent; cursor: pointer;
  font-family: var(--display); font-weight: 600; font-size: 12.5px;
  color: var(--muted); border-radius: 6px;
  transition: background .15s ease, color .15s ease;
}
.mode-switch__btn:hover { color: var(--ink); }
.mode-switch__btn.is-active { background: var(--surface); color: var(--blue); box-shadow: var(--shadow-sm); }
.mode-switch__btn svg { width: 14px; height: 14px; }

.md-toolbar {
  display: flex; align-items: center; gap: 2px; flex-wrap: wrap;
  padding: 6px; background: var(--surface-2);
  border: 1px solid var(--line); border-bottom: 0;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.md-toolbar .rte__btn[data-md="h2"] { font-family: var(--display); font-weight: 700; font-size: 12px; }

/* Side-by-side once there is room; stacked on narrow screens. */
.md-panes { display: grid; grid-template-columns: 1fr; }
.md-panes.is-split { grid-template-columns: 1fr 1fr; }

.md-input {
  width: 100%; min-height: 460px; resize: vertical;
  font-family: var(--mono); font-size: 13.5px; line-height: 1.7;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  padding: 16px 18px; tab-size: 2;
}
.md-panes.is-split .md-input { border-radius: 0 0 0 var(--radius-sm); }
.md-input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-ring); }
.md-input::placeholder { color: var(--muted-2); }

.md-preview {
  border: 1px solid var(--line); border-left: 0;
  border-radius: 0 0 var(--radius-sm) 0;
  padding: 16px 20px; overflow-y: auto; max-height: 640px;
  background: var(--surface-2); font-size: 14.5px;
}
.md-preview > :first-child { margin-top: 0; }
.md-preview h2 { font-family: var(--display); font-size: 1.35rem; margin: 1.4em 0 .5em; }
.md-preview h3 { font-family: var(--display); font-size: 1.12rem; margin: 1.3em 0 .4em; }
.md-preview p { margin: 0 0 1em; line-height: 1.7; }
.md-preview ul, .md-preview ol { padding-left: 1.4em; margin: 0 0 1em; }
.md-preview blockquote {
  margin: 1.2em 0; padding: .3em 0 .3em 1em;
  border-left: 3px solid var(--blue); color: var(--muted); font-style: italic;
}
.md-preview pre {
  background: var(--sidebar-bg); color: #E6E9EF; padding: 14px;
  border-radius: var(--radius-sm); overflow-x: auto; font-size: 12.5px;
}
.md-preview pre code { background: none; color: inherit; padding: 0; }
.md-preview code { font-family: var(--mono); font-size: .9em; background: var(--line-2); padding: 1px 5px; border-radius: 4px; }
.md-preview img { max-width: 100%; border-radius: var(--radius-sm); }
.md-preview table { width: 100%; border-collapse: collapse; margin: 1em 0; font-size: .92em; }
.md-preview th, .md-preview td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; }
.md-preview th { background: var(--line-2); font-weight: 600; }
.md-preview__empty { color: var(--muted-2); font-style: italic; }

@media (max-width: 900px) {
  /* Never split on a phone — two 45%-wide columns are unusable. */
  .md-panes.is-split { grid-template-columns: 1fr; }
  .md-panes.is-split .md-input { border-radius: 0; }
  .md-preview { border-left: 1px solid var(--line); border-radius: 0 0 var(--radius-sm) var(--radius-sm); }
}
