:root {
  --pri: #1f3a5f;
  --pri-h: #2c4f7c;
  --pri-soft: #e8eef6;
  --ok: #1e7d46;
  --err: #b3352c;
  --err-soft: #f7e6e4;
  --line: #dfe3e8;
  --bg: #f4f6f9;
  --card: #ffffff;
  --txt: #22303f;
  --mut: #66788c;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--txt);
  background: var(--bg);
  font-size: 15px;
}

a { color: var(--pri); }

h1 { font-size: 22px; margin: 0 0 4px; }

.btn {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--txt);
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  text-decoration: none;
  line-height: 1.35;
}
.btn:hover { border-color: #c4ccd6; background: #fafbfd; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--pri); border-color: var(--pri); color: #fff; }
.btn-primary:hover { background: var(--pri-h); border-color: var(--pri-h); }
.btn-danger { color: var(--err); border-color: #e5c1bd; background: #fff; }
.btn-danger:hover { background: var(--err-soft); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: #eef1f5; }
.btn-sm { padding: 4px 10px; font-size: 13px; border-radius: 6px; }

input[type="text"], input[type="password"], input[type="number"], textarea, select {
  font-family: inherit;
  font-size: 14px;
  color: var(--txt);
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  width: 100%;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--pri-soft); border-color: var(--pri); }
textarea { resize: vertical; min-height: 90px; line-height: 1.5; }

label.field { display: block; margin-bottom: 12px; font-size: 13px; color: var(--mut); }
label.field > span { display: block; margin-bottom: 4px; font-weight: 600; }

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .brand { font-weight: 800; font-size: 16px; color: var(--pri); white-space: nowrap; }
.topbar .crumb { color: var(--mut); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .spacer { flex: 1; }
.topbar .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.page-wrap { max-width: 1000px; margin: 0 auto; padding: 26px 20px 60px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; margin-top: 18px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
}
.site-card .site-url { color: var(--mut); font-size: 13px; word-break: break-all; text-decoration: none; display: block; margin: 6px 0 14px; }
.site-card:hover { border-color: #c4ccd6; box-shadow: 0 2px 10px rgba(31, 58, 95, .07); }

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #22334a;
  color: #fff;
  padding: 11px 18px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, .25);
  z-index: 100;
  max-width: 380px;
}
.toast.err { background: var(--err); }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 25, 38, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
  padding: 20px;
}
.modal-box {
  background: #fff;
  border-radius: 14px;
  padding: 24px;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .3);
}
.modal-box h2 { margin: 0 0 10px; font-size: 18px; }
.modal-box .modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.modal-box p { font-size: 14px; line-height: 1.5; }
.hidden { display: none !important; }

.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); }
.login-card { width: 360px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 30px 28px; }
.login-card .brand { font-size: 20px; font-weight: 800; color: var(--pri); margin-bottom: 4px; }
.login-card .sub { color: var(--mut); font-size: 13px; margin-bottom: 22px; }
.form-error { color: var(--err); font-size: 13px; min-height: 18px; margin: 8px 0; }

.editor-shell {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) 470px;
  height: calc(100vh - 57px);
}

.ed-menu {
  overflow-y: auto;
  background: #fafbfd;
  border-right: 1px solid var(--line);
  padding: 14px 10px 30px;
}
.ed-menu .home-link {
  display: block;
  padding: 9px 12px;
  font-weight: 700;
  text-decoration: none;
  color: var(--pri);
  border-bottom: 1px solid var(--line);
  margin-bottom: 10px;
  border-radius: 6px;
}
.ed-menu ul { list-style: none; margin: 0; padding: 0; }
.ed-menu ul a {
  display: block;
  padding: 7px 12px;
  color: var(--txt);
  text-decoration: none;
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.35;
}
.ed-menu ul a:hover { background: var(--pri-soft); }
.ed-menu ul a.active { background: var(--pri-soft); font-weight: 700; }
.ed-menu .add-section { margin-top: 18px; padding: 0 2px; }
.ed-menu .add-section input { margin-bottom: 8px; }

.ed-main { overflow-y: auto; padding: 22px 26px 90px; }
.section-card { margin-bottom: 22px; }
.section-card > .card-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.section-card .sec-title { flex: 1; min-width: 220px; font-weight: 700; font-size: 15px; }
.chip {
  font-size: 11px;
  color: var(--mut);
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 2px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.row-btns { display: flex; gap: 6px; align-items: center; }

.article-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  margin: 12px 0;
  background: #fdfdfe;
}
.article-card > .card-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.article-card .art-title { flex: 1; min-width: 200px; font-weight: 600; }
.article-card .art-type { width: auto; }
.article-card textarea { background: #fff; }

.ed-right {
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  background: #fff;
  min-height: 0;
}
.right-tabs { display: flex; border-bottom: 1px solid var(--line); }
.right-tabs button {
  flex: 1;
  padding: 10px;
  border: 0;
  background: #fafbfd;
  font-family: inherit;
  font-size: 14px;
  color: var(--mut);
  cursor: pointer;
}
.right-tabs button.active { background: #fff; color: var(--pri); font-weight: 700; box-shadow: inset 0 -2px 0 var(--pri); }
.tabpanel { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: auto; }
#tab-preview { padding: 0; }
#previewFrame { width: 100%; height: 100%; border: 0; flex: 1; background: #fff; }
#tab-style { padding: 18px; }
.style-row { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.style-row label { flex: 1; font-size: 13px; color: var(--mut); }
.style-row input[type="color"] { width: 46px; height: 34px; padding: 2px; border: 1px solid var(--line); border-radius: 6px; background: #fff; cursor: pointer; }
.style-row input[type="text"], .style-row input[type="number"] { width: 110px; }
.style-note { font-size: 12px; color: var(--mut); line-height: 1.5; margin-top: 14px; }

.switch-label { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--txt); cursor: pointer; white-space: nowrap; }

.history-list { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }
.version-card { display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.version-card .vdate { font-weight: 700; font-size: 14px; }
.version-card .vmeta { color: var(--mut); font-size: 13px; }
.version-card .vactions { display: flex; gap: 6px; flex-wrap: wrap; }

.dirty-dot { width: 9px; height: 9px; border-radius: 50%; background: #e8a33d; display: inline-block; margin-left: 4px; }

@media (max-width: 1180px) {
  .editor-shell { grid-template-columns: 220px minmax(0, 1fr); }
  .ed-right { display: none; }
  .ed-right.open { display: flex; position: fixed; right: 0; top: 57px; bottom: 0; width: min(500px, 100vw); z-index: 40; box-shadow: -8px 0 30px rgba(0, 0, 0, .15); }
}
@media (max-width: 760px) {
  .editor-shell { grid-template-columns: 1fr; height: auto; }
  .ed-menu { border-right: 0; border-bottom: 1px solid var(--line); max-height: 200px; }
  .ed-main { overflow: visible; }
}

/* ---------- v2: importación de secciones ---------- */
.v2-badge { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 999px; background: var(--pri); color: #fff; font-size: 11px; font-weight: 700; letter-spacing: .5px; vertical-align: middle; }
#tab-import { padding: 18px; }
.import-btns { display: flex; gap: 8px; margin: 12px 0; }
.import-btns .btn { flex: 1; }
.imp-sec { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; padding: 5px 0; border-bottom: 1px solid var(--line); }
.imp-sec:last-child { border-bottom: 0; }
.imp-arts { margin: 2px 0 8px; padding-left: 18px; color: var(--txt); font-size: 13px; }
.imp-arts .vmeta { color: var(--mut); }
#impResult .card, #impCurrent .card { padding: 12px 14px; margin-top: 8px; }
.import-help { margin-top: 16px; font-size: 12px; color: var(--mut); }
.import-help summary { cursor: pointer; color: var(--pri); font-size: 13px; }
.import-help pre { background: var(--pri-soft); padding: 10px 12px; border-radius: 8px; font-size: 12px; overflow: auto; }
.menu-sep { border-top: 1px dashed var(--line); margin: 8px 0; }
.menu-imported { font-style: italic; color: var(--mut) !important; }
.import-note-card { padding: 10px 14px; font-size: 13px; color: var(--mut); }

/* ---------- v2.1: secciones blog fijas y edición de importadas ---------- */
.sec-title-fixed { font-weight: 700; font-size: 15px; color: var(--pri); flex: 1; }
.chip-imported { background: var(--pri-soft); color: var(--pri); }
.sec-imported { border-left: 3px solid var(--pri-soft); }
.art-date-inp { width: 130px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; font-size: 12px; color: var(--mut); flex: none; }
.menu-hint { font-size: 11px; color: var(--mut); line-height: 1.5; margin: 10px 0 0; }
