/* Panel de redacción · El Contrapeso */
:root {
  --paper: #f4efe6; --card: #fffdf9; --deep: #e9e0d3; --line: #d8cfc2;
  --ink: #171713; --soft: #6a655d; --red: #b62828; --red-dark: #8f1f24;
  --gold: #d7a24a; --green: #2f7d32; --orange: #c77700; --blue: #2c5c8a; --sage: #4f6b5c;
  --serif: Georgia, 'Times New Roman', serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --radius: 6px;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--paper); color: var(--ink); font: 15px/1.5 var(--sans); }
a { color: var(--red-dark); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; font-family: var(--serif); letter-spacing: -.02em; }
.boot { padding: 40px; color: var(--soft); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

/* Botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 8px 14px; border: 1px solid var(--ink); border-radius: var(--radius); background: var(--card); font-weight: 600; font-size: 14px; text-decoration: none; color: var(--ink); white-space: nowrap; transition: background .15s, color .15s, border-color .15s; }
.btn:hover { background: var(--deep); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); border-color: var(--red-dark); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { background: #333; }
.btn-ghost { border-color: transparent; background: none; }
.btn-ghost:hover { background: var(--deep); }
.btn-danger { border-color: var(--red); color: var(--red); background: none; }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-small { min-height: 30px; padding: 4px 10px; font-size: 13px; }
.btn-block { width: 100%; }

/* Acceso */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: min(100%, 400px); padding: 34px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 10px 10px 0 var(--deep); }
.brand { font: 700 30px/1 var(--serif); letter-spacing: -.06em; }
.brand i { color: var(--red); font-style: normal; font-size: .5em; vertical-align: .35em; margin-right: .1em; }
.auth-card .brand { margin-bottom: 6px; }
.auth-card p { color: var(--soft); margin: 0 0 22px; }
.auth-card form { display: grid; gap: 14px; }
.error { padding: 10px 12px; border-radius: var(--radius); background: #fbe9e7; color: var(--red-dark); font-size: 14px; }

/* Estructura */
.shell { display: grid; grid-template-columns: 230px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; padding: 20px 14px; background: var(--ink); color: #eee8df; overflow-y: auto; }
.sidebar .brand { padding: 0 8px 4px; color: #fff; font-size: 24px; }
.sidebar .sub { padding: 0 8px 18px; color: #a39f97; font: 11px var(--mono); letter-spacing: .1em; text-transform: uppercase; }
.sidebar a, .sidebar button.link { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 0; border-radius: var(--radius); background: none; color: #eee8df; text-decoration: none; text-align: left; font-size: 14.5px; }
.sidebar a:hover, .sidebar button.link:hover { background: #2a2a26; }
.sidebar a.active { background: var(--red); color: #fff; }
.sidebar .icon { width: 20px; text-align: center; }
.sidebar .sep { height: 1px; margin: 12px 4px; background: #34342f; }
.sidebar .me { margin-top: auto; padding: 12px 10px 4px; color: #a39f97; font-size: 13px; }
.sidebar .me strong { display: block; color: #fff; }
.sidebar .count { margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 10px; background: var(--gold); color: var(--ink); font: 700 11px/18px var(--mono); text-align: center; }
.main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; min-height: 58px; padding: 10px 28px; background: color-mix(in srgb, var(--paper) 94%, transparent); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.topbar h1 { font-size: 22px; }
.topbar .spacer { flex: 1; }
.menu-toggle { display: none; }
.publish-status { display: inline-flex; align-items: center; gap: 8px; color: var(--soft); font-size: 13px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); flex: none; }
.dot.busy { background: var(--orange); animation: blink 1s infinite; }
.dot.bad { background: var(--red); }
@keyframes blink { 50% { opacity: .3; } }
.content { padding: 24px 28px 60px; }

/* Listados */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.search { flex: 1 1 240px; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 6px 12px; border: 1px solid var(--line); border-radius: 20px; background: var(--card); font-size: 13px; }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip b { margin-left: 4px; font-family: var(--mono); font-weight: 600; opacity: .7; }
.list { background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.row { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.row:last-child { border-bottom: 0; }
.row:hover { background: #faf6ef; }
.thumb { width: 64px; height: 44px; border-radius: 4px; background: var(--deep) center / cover no-repeat; }
.row-title { display: block; font: 600 16px/1.3 var(--serif); }
.row-meta { display: block; margin-top: 3px; color: var(--soft); font-size: 13px; }
.row-meta span + span::before { content: '·'; margin: 0 6px; }
.badge { display: inline-block; padding: 3px 9px; border-radius: 12px; font: 600 11.5px/1.4 var(--sans); white-space: nowrap; }
.b-draft { background: var(--deep); color: var(--soft); }
.b-review { background: #fff1d6; color: #8a5600; }
.b-scheduled { background: #e3edf7; color: var(--blue); }
.b-published { background: #e5f2e6; color: var(--green); }
.b-off { background: #eee; color: #888; }
.empty { padding: 40px; text-align: center; color: var(--soft); }

/* Formularios */
label.field, .field { display: grid; gap: 6px; }
.field + .field { margin-top: 16px; }
.field > span.label { font-weight: 600; font-size: 13.5px; }
.hint { color: var(--soft); font-size: 12.5px; }
.counter { float: right; color: var(--soft); font: 12px var(--mono); }
.counter.over { color: var(--red); font-weight: 700; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=datetime-local], input[type=search], select, textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
input:focus, select:focus, textarea:focus { border-color: var(--ink); outline: none; }
textarea { min-height: 84px; resize: vertical; }
textarea.code { min-height: 140px; font: 13px/1.4 var(--mono); }
input[readonly], select:disabled, textarea[readonly] { background: #f3efe8; color: var(--soft); }
.title-input { min-height: 0 !important; resize: none; overflow: hidden; padding: 6px 0 !important; border: 0 !important; border-bottom: 2px solid var(--line) !important; border-radius: 0 !important; background: none !important; font: 700 clamp(26px, 3vw, 38px)/1.15 var(--serif) !important; letter-spacing: -.03em; }
.title-input:focus { border-bottom-color: var(--red) !important; }
.kicker-input { border: 0 !important; background: none !important; padding: 4px 0 !important; color: var(--red); font: 600 13px var(--mono) !important; letter-spacing: .08em; text-transform: uppercase; }
.excerpt-input { min-height: 70px !important; border: 0 !important; border-left: 3px solid var(--line) !important; border-radius: 0 !important; background: none !important; font: 18px/1.45 var(--serif) !important; color: #3b3a35; }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { appearance: none; width: 40px; height: 22px; margin: 0; flex: none; border-radius: 11px; background: var(--line); position: relative; transition: background .15s; cursor: pointer; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked { background: var(--green); }
.switch input:checked::after { transform: translateX(18px); }
.switch input:disabled { opacity: .5; }
.checks { display: grid; gap: 6px; }
.checks label { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.tags span { display: inline-flex; align-items: center; gap: 4px; padding: 3px 4px 3px 10px; border-radius: 14px; background: var(--deep); font-size: 13px; }
.tags span button { border: 0; background: none; padding: 0 4px; font-size: 15px; line-height: 1; color: var(--soft); }
.tags input { flex: 1 1 120px; min-width: 100px; border: 0 !important; padding: 4px !important; }
.image-field { display: grid; gap: 8px; }
.image-preview { position: relative; min-height: 90px; border: 1px dashed var(--line); border-radius: var(--radius); background: var(--deep) center / cover no-repeat; display: grid; place-items: center; color: var(--soft); font-size: 13px; overflow: hidden; }
.image-preview.has { aspect-ratio: 16 / 9; border-style: solid; }
.image-preview.drag { border-color: var(--red); background-color: #fbe9e7; }
.image-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.list-field { display: grid; gap: 10px; }
.list-item { padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.list-item-head { display: flex; gap: 6px; align-items: center; margin-bottom: 10px; }
.list-item-head strong { flex: 1; }
.group-title { margin: 26px 0 12px; padding-top: 18px; border-top: 1px solid var(--line); font: 700 18px var(--serif); }

/* Editor de artículo */
.editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 26px; align-items: start; }
.editor-main { display: grid; gap: 14px; min-width: 0; }
.editor-side { display: grid; gap: 16px; position: sticky; top: 74px; max-height: calc(100vh - 90px); overflow-y: auto; padding-bottom: 20px; }
.panel { padding: 18px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
.panel h3 { margin-bottom: 12px; font-size: 17px; }
.panel .field + .field { margin-top: 13px; }
.state-line { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-size: 14px; }
.actions { display: grid; gap: 8px; }
.actions-row { display: flex; gap: 8px; flex-wrap: wrap; }
.restore { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 10px 14px; border-radius: var(--radius); background: #fff1d6; font-size: 14px; }
.restore span { flex: 1; }
.toastui-editor-defaultUI { border-color: var(--line) !important; border-radius: 10px !important; background: #fff; }
.toastui-editor-contents { font-family: var(--serif) !important; font-size: 17px !important; }
.editor-help { margin: -4px 0 0; color: var(--soft); font-size: 12.5px; }
.editor-help code { padding: 1px 5px; background: var(--deep); border-radius: 3px; }

/* SEO en directo */
.seo-score { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.seo-score b { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; color: #fff; font: 700 15px var(--mono); }
.seo-score b.good { background: var(--green); } .seo-score b.ok { background: var(--orange); } .seo-score b.bad { background: var(--red); }
.seo-checks { margin: 0; padding: 0; list-style: none; font-size: 13px; }
.seo-checks li { display: flex; gap: 8px; padding: 5px 0; border-top: 1px solid #eee5d8; }
.seo-checks i { flex: none; width: 9px; height: 9px; margin-top: 5px; border-radius: 50%; }
.seo-checks i.good { background: var(--green); } .seo-checks i.ok { background: var(--orange); } .seo-checks i.bad { background: var(--red); }
.snippet { margin-bottom: 14px; padding: 12px; border: 1px solid #e3ddd3; border-radius: var(--radius); background: #fff; font-family: Arial, sans-serif; }
.snippet .s-url { color: #202124; font-size: 12px; }
.snippet .s-title { margin: 3px 0; color: #1a0dab; font-size: 17px; line-height: 1.25; }
.snippet .s-desc { color: #4d5156; font-size: 13px; line-height: 1.4; }

/* Tablas (usuarios, actividad) */
table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
th, td { padding: 11px 14px; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; vertical-align: middle; }
th { background: var(--deep); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--soft); }
tr:last-child td { border-bottom: 0; }
.muted { color: var(--soft); }

/* Ventana modal */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(15, 15, 12, .55); }
.modal-card { width: min(100%, 480px); max-height: 92vh; overflow-y: auto; padding: 26px; background: var(--card); border-radius: 10px; }
.modal-card h2 { margin-bottom: 16px; font-size: 24px; }
.modal-card .actions-row { margin-top: 20px; justify-content: flex-end; }
.toast { position: fixed; z-index: 60; right: 20px; bottom: 20px; max-width: 380px; padding: 13px 16px; border-radius: 8px; background: var(--ink); color: #fff; font-size: 14px; opacity: 0; transform: translateY(20px); transition: .25s; pointer-events: none; }
.toast.show { opacity: 1; transform: none; }
.toast.err { background: var(--red-dark); }

@media (max-width: 1100px) {
  .editor-grid { grid-template-columns: 1fr; }
  .editor-side { position: static; max-height: none; overflow: visible; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 40; inset: 0 auto 0 0; width: 260px; transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .4); }
  .menu-toggle { display: inline-flex; }
  .topbar { padding: 10px 16px; }
  .topbar h1 { font-size: 19px; }
  .publish-status .txt, .publish-status .btn, .long { display: none; }
  .topbar .btn-ghost:not(.menu-toggle) { padding: 8px; }
  .content { padding: 18px 16px 60px; }
  .row { grid-template-columns: 48px minmax(0, 1fr); }
  .row .badge { grid-column: 2; justify-self: start; }
  .thumb { width: 48px; height: 48px; }
  table { display: block; overflow-x: auto; }
}
.editor-extra { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }

/* Publicidad: huecos con dibujo y vista previa ------------------------------ */
.slot-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; margin-top: 6px; }
.slot-card { position: relative; display: grid; grid-template-columns: 46px 1fr; gap: 10px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); cursor: pointer; transition: border-color .15s, background .15s; }
.slot-card:hover { border-color: var(--soft); }
.slot-card input { position: absolute; top: 8px; right: 8px; margin: 0; }
.slot-card:has(input:checked) { border-color: var(--red); background: #fbeeee; box-shadow: inset 0 0 0 1px var(--red); }
.slot-card b { display: block; padding-right: 20px; font-size: 13px; line-height: 1.25; }
.slot-card small { display: block; margin-top: 3px; color: var(--soft); font: 11px var(--mono); }
.slot-map { width: 46px; height: auto; }
.slot-map .pg { fill: #fff; stroke: var(--line); }
.slot-map .bl { fill: var(--deep); }
.slot-map .hl { fill: var(--red); }
[data-col="publicidad"] .image-preview.has { aspect-ratio: auto; min-height: 120px; background-size: contain; background-color: #fff; }
.adpv { padding: 12px 0; border-top: 1px solid var(--line); }
.adpv:first-child { padding-top: 0; border-top: 0; }
.adpv > b { display: block; margin-bottom: 8px; font-size: 13px; }
.adpv-dev { display: block; margin: 6px 0 4px; color: var(--soft); font: 10.5px var(--mono); text-transform: uppercase; letter-spacing: .06em; }
.adpv-frame { width: 100%; padding: 6px; border: 1px dashed var(--line); background: var(--paper); container-type: inline-size; }
.adpv-frame img { display: block; width: auto; height: auto; max-width: 100%; max-height: calc(100cqw * var(--max, 10)); margin: 0 auto; }
.adpv-mobile { width: 62%; }
.adpv-ok, .adpv-warn { margin: 8px 0 0; font-size: 12.5px; line-height: 1.4; }
.adpv-ok { color: var(--green); }
.adpv-warn { padding: 8px 10px; border-radius: var(--radius); background: #fdf3e2; color: #7a4d00; }
.adpv-sizes { margin: 10px 0 0; padding: 0; list-style: none; font-size: 12.5px; }
.adpv-sizes li { display: flex; justify-content: space-between; gap: 8px; padding: 5px 0; border-top: 1px solid var(--line); }
.adpv-sizes b { font: 12px var(--mono); white-space: nowrap; }

/* Portada: huecos fijados o automáticos ----------------------------------- */
.fp-intro { margin: 0 0 6px; }
.fp-group { padding: 18px 0 6px; border-top: 1px solid var(--line); }
.fp-group:first-of-type { border-top: 0; }
.fp-group h3 { margin: 0; font: 700 18px var(--serif); }
.fp-group > .hint { margin: 4px 0 10px; }
.fp-row { display: grid; grid-template-columns: 26px 64px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 10px; margin-bottom: 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.fp-row.is-fixed { border-color: var(--red); box-shadow: inset 3px 0 0 var(--red); }
.fp-n { padding-top: 4px; color: var(--soft); font: 700 14px var(--mono); text-align: center; }
.fp-thumb { width: 64px; height: 48px; border-radius: 4px; background: var(--deep) center / cover no-repeat; }
.fp-main { display: grid; gap: 6px; min-width: 0; }
.fp-now { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: baseline; font-size: 14px; line-height: 1.3; }
.fp-empty { color: var(--soft); font-weight: 400; }
.fp-tag { padding: 2px 7px; border-radius: 999px; background: #eee; color: #666; font: 600 11px var(--sans); white-space: nowrap; }
.fp-tag.on { background: #fbeeee; color: var(--red); }
.fp-tag.off { background: #fdf3e2; color: #7a4d00; }
.fp-main select { width: 100%; }
.fp-until { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; color: var(--soft); }
.fp-until input { width: auto; padding: 5px 8px; font-size: 13px; }
.fp-until .chip { padding: 4px 9px; font-size: 12px; }
.fp-move { display: flex; flex-direction: column; gap: 4px; }
@media (max-width: 700px) {
  .fp-row { grid-template-columns: 22px minmax(0, 1fr) auto; }
  .fp-thumb { display: none; }
}
