@font-face { font-family: "Inter Variable"; font-weight: 100 900; font-display: swap; src: url(/fonts/inter-latin.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC; }
@font-face { font-family: "Inter Variable"; font-weight: 100 900; font-display: swap; src: url(/fonts/inter-latin-ext.woff2) format("woff2"); unicode-range: U+0100-02BA, U+0218-021B; }
@font-face { font-family: "Cormorant Garamond Variable"; font-weight: 300 700; font-display: swap; src: url(/fonts/cormorant-garamond-latin.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: "Cormorant Garamond Variable"; font-weight: 300 700; font-display: swap; src: url(/fonts/cormorant-garamond-latin-ext.woff2) format("woff2"); unicode-range: U+0100-02BA, U+0218-021B; }
[hidden] { display: none !important; }
:root {
  --ink: #1f2420; --ink-70: #464b46; --ink-45: #6f736d;
  --forest: #1f3b33; --forest-deep: #152923; --forest-tint: #e6ede8;
  --bronze: #a47a48; --cream: #fbf8f2; --sand: #f2ebdf; --line: #e3dacb;
  --red: #9b2c2c; --red-tint: #fbeaea; --ok: #2f6b4f;
  font-family: "Inter Variable", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink); background: var(--cream);
}
* { box-sizing: border-box; }
body { margin: 0; font-size: 15px; line-height: 1.5; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--forest); }
h1, h2, h3 { font-family: "Cormorant Garamond Variable", Georgia, serif; font-weight: 600; margin: 0; line-height: 1.15; }
h1 { font-size: 2rem; } h2 { font-size: 1.45rem; }

.btn { display: inline-flex; align-items: center; gap: .4rem; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: .55rem 1.1rem; cursor: pointer; font-weight: 500; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:hover { border-color: var(--bronze); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--forest); border-color: var(--forest); color: #fff; }
.btn-primary:hover { background: var(--forest-deep); }
.btn-danger { color: var(--red); }
.btn-sm { padding: .3rem .75rem; font-size: .85rem; }
.link { background: none; border: 0; padding: 0; color: var(--forest); text-decoration: underline; cursor: pointer; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background: var(--forest); }
.login form { width: min(24rem, 100%); background: var(--cream); border-radius: 1.2rem; padding: 2.2rem; display: grid; gap: 1rem; box-shadow: 0 30px 60px -30px rgba(0,0,0,.5); }
.login .eyebrow { font-size: .75rem; letter-spacing: .14em; text-transform: uppercase; color: var(--bronze); font-weight: 600; }

/* Bara de sus */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 1rem; padding: .8rem 1.5rem; background: var(--forest); color: #fff; }
.top .brand { font-family: "Cormorant Garamond Variable", Georgia, serif; font-size: 1.3rem; font-weight: 600; color: #fff; text-decoration: none; }
.top .spacer { flex: 1; }
.top .who { font-size: .85rem; opacity: .85; }
.top .btn { background: transparent; color: #fff; border-color: rgba(255,255,255,.35); }

.status { margin: 0; padding: .6rem 1.5rem; font-size: .9rem; border-bottom: 1px solid var(--line); background: var(--sand); display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.status.ok { background: var(--forest-tint); }
.status.err { background: var(--red-tint); color: var(--red); }
.status ul { margin: .3rem 0 0; padding-left: 1.2rem; flex-basis: 100%; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--bronze); border-top-color: transparent; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(1turn); } }

main { max-width: 72rem; margin: 0 auto; padding: 2rem 1.5rem 4rem; }

/* Lista */
.list-head { display: flex; align-items: end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.cards { display: grid; gap: .7rem; }
.card { display: grid; grid-template-columns: 1fr auto; gap: .3rem 1rem; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: .9rem; padding: 1rem 1.2rem; }
.card h3 { font-family: inherit; font-size: 1.02rem; font-weight: 600; }
.card .meta { font-size: .85rem; color: var(--ink-45); display: flex; gap: .8rem; flex-wrap: wrap; }
.badge { display: inline-block; font-size: .72rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; padding: .15rem .55rem; border-radius: 999px; }
.badge.pub { background: var(--forest-tint); color: var(--ok); }
.badge.draft { background: var(--sand); color: var(--bronze); }
.card .actions { grid-row: span 2; display: flex; gap: .5rem; }
.section-title { margin: 2rem 0 .8rem; font-size: .8rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-45); font-weight: 600; }

/* Editor */
.editor { display: grid; gap: 2rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1100px) { .editor { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } main.wide { max-width: 110rem; } }
.panel { display: grid; gap: 1.1rem; align-content: start; }
.field { display: grid; gap: .35rem; }
.field > span { font-weight: 600; font-size: .9rem; }
.field small, .hint { color: var(--ink-45); font-size: .8rem; }
.field input[type=text], .field input[type=date], .field input[type=url], .field select, .field textarea, .login input {
  width: 100%; border: 1px solid var(--line); border-radius: .6rem; background: #fff; padding: .6rem .75rem;
}
.field input:focus, .field textarea:focus, .field select:focus, .login input:focus { outline: 2px solid var(--bronze); outline-offset: 1px; border-color: transparent; }
.counter { font-size: .78rem; color: var(--ink-45); text-align: right; }
.counter.bad { color: var(--red); font-weight: 600; }
.counter.good { color: var(--ok); }
fieldset { border: 1px solid var(--line); border-radius: .8rem; padding: 1rem 1.1rem; margin: 0; background: #fff; }
legend { font-weight: 600; font-size: .9rem; padding: 0 .4rem; }
details summary { cursor: pointer; font-weight: 600; font-size: .9rem; }

.toolbar { display: flex; flex-wrap: wrap; gap: .3rem; padding: .45rem; border: 1px solid var(--line); border-bottom: 0; border-radius: .6rem .6rem 0 0; background: var(--sand); position: sticky; top: 3.4rem; z-index: 5; }
.toolbar button { border: 1px solid transparent; background: transparent; border-radius: .4rem; padding: .3rem .6rem; cursor: pointer; font-size: .85rem; }
.toolbar button:hover { background: #fff; border-color: var(--line); }
.toolbar .sep { width: 1px; background: var(--line); margin: 0 .2rem; }
textarea.body { display: block; width: 100%; min-height: 34rem; border: 1px solid var(--line); border-radius: 0 0 .6rem .6rem; background: #fff; padding: .9rem 1rem; font-size: .95rem; line-height: 1.7; resize: vertical; }
textarea.body:focus { outline: 2px solid var(--bronze); outline-offset: 1px; }

.related { display: grid; gap: .2rem; max-height: 16rem; overflow: auto; }
.related label { display: flex; gap: .5rem; align-items: center; font-size: .9rem; }
.related .grp { margin-top: .5rem; font-size: .75rem; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-45); font-weight: 600; }
.sources input { width: 100%; border: 1px solid var(--line); border-radius: .6rem; background: #fff; padding: .5rem .7rem; }
.sources .row { display: grid; grid-template-columns: 1fr 1fr auto; gap: .4rem; margin-bottom: .4rem; }
@media (max-width: 640px) { .sources .row { grid-template-columns: 1fr; } }

.hero-box { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.hero-box img { width: 11rem; aspect-ratio: 16/9; object-fit: cover; border-radius: .5rem; border: 1px solid var(--line); background: var(--sand); }

.actions-bar { position: sticky; bottom: 0; z-index: 5; display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; padding: .9rem 0; background: linear-gradient(transparent, var(--cream) 30%); }
.problems { background: var(--red-tint); color: var(--red); border-radius: .7rem; padding: .8rem 1rem; }
.problems ul { margin: .3rem 0 0; padding-left: 1.2rem; }

.preview-wrap { position: sticky; top: 4.5rem; align-self: start; }
.preview-wrap iframe { width: 100%; height: calc(100vh - 7rem); border: 1px solid var(--line); border-radius: .8rem; background: #fff; }
@media (max-width: 1099px) { .preview-wrap { position: static; } .preview-wrap iframe { height: 80vh; } }
.tabs { display: none; gap: .4rem; margin-bottom: 1rem; }
@media (max-width: 1099px) { .tabs { display: flex; } .editor[data-tab=edit] .preview-wrap, .editor[data-tab=preview] .panel { display: none; } }

#toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%) translateY(150%); background: var(--ink); color: #fff; padding: .7rem 1.2rem; border-radius: 999px; transition: transform .25s; z-index: 50; max-width: 90vw; visibility: hidden; }
#toast.show { transform: translateX(-50%) translateY(0); visibility: visible; }
#toast.err { background: var(--red); }

dialog { border: 0; border-radius: 1rem; padding: 1.5rem; width: min(30rem, 92vw); box-shadow: 0 30px 60px -20px rgba(0,0,0,.4); }
dialog::backdrop { background: rgba(20,30,25,.45); }
dialog form { display: grid; gap: .9rem; }
.help { background: #fff; border: 1px solid var(--line); border-radius: .8rem; padding: 1rem 1.2rem; font-size: .9rem; color: var(--ink-70); }
.help code { background: var(--sand); padding: .05rem .3rem; border-radius: .25rem; }
@media (max-width: 640px) {
  .top { padding: .6rem 1rem; gap: .6rem; }
  .top .brand { font-size: 1.1rem; }
  .top .who, .top a.btn { display: none; }
  main { padding: 1.2rem 1rem 3rem; }
  .actions-bar { background: var(--cream); border-top: 1px solid var(--line); padding: .6rem 0; }
}
