/* ============================================================
   Portafolio de Ensayos — Carmen Jimena Velásquez Mairena
   Sistema de diseño compartido (público + administrador)
   Minimalista · azules / celestes / crema · día y noche
   ============================================================ */

/* ---------- Reset ligero ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}
img, svg { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }
ul, ol { padding-left: 1.2em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ============================================================
   TOKENS — tema por defecto: "Celeste", modo día
   ============================================================ */
:root {
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-read:    'Fraunces', Georgia, 'Times New Roman', serif;
  --font-ui:      'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;

  /* Neutros — DÍA (crema) */
  --bg:         #FAF6EE;
  --bg-elev:    #FFFFFF;
  --surface:    #FFFFFF;
  --surface-2:  #F4EEE1;
  --surface-3:  #ECE3D2;
  --text:       #202A38;
  --text-soft:  #55617A;
  --text-mute:  #8A93A6;
  --border:     #E8DFCE;
  --border-soft:#F1EADC;

  /* Acento — CELESTE */
  --accent:        #2F8ACD;
  --accent-2:      #66C6EC;
  --accent-strong: #256FA6;
  --accent-contrast:#FFFFFF;

  /* Estados */
  --danger:  #D9534F;
  --danger-strong:#B23C38;
  --success: #2FA36B;
  --warning: #D99A2B;

  /* Derivados */
  --accent-soft:  color-mix(in srgb, var(--accent) 12%, var(--surface));
  --accent-tint:  color-mix(in srgb, var(--accent) 8%, transparent);
  --grad:         linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  --grad-soft:    linear-gradient(135deg, color-mix(in srgb, var(--accent) 22%, var(--surface)), color-mix(in srgb, var(--accent-2) 22%, var(--surface)));

  /* Radios */
  --r-sm: 9px;
  --r:    14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-pill: 999px;

  /* Sombras */
  --shadow-color: 210 30% 30%;
  --shadow-sm: 0 1px 2px hsl(var(--shadow-color) / .08), 0 1px 3px hsl(var(--shadow-color) / .06);
  --shadow-md: 0 4px 14px hsl(var(--shadow-color) / .10), 0 2px 6px hsl(var(--shadow-color) / .06);
  --shadow-lg: 0 18px 48px hsl(var(--shadow-color) / .18), 0 6px 18px hsl(var(--shadow-color) / .10);

  /* Transiciones */
  --t-fast: 120ms cubic-bezier(.4,0,.2,1);
  --t:      220ms cubic-bezier(.4,0,.2,1);
  --t-slow: 400ms cubic-bezier(.4,0,.2,1);

  --maxw: 1180px;
}

/* ---------- Modo NOCHE (neutros) ---------- */
[data-mode="dark"] {
  --bg:         #0D1420;
  --bg-elev:    #121C2C;
  --surface:    #14202F;
  --surface-2:  #1B2940;
  --surface-3:  #24344F;
  --text:       #EAF1FA;
  --text-soft:  #AEBCD2;
  --text-mute:  #7C8AA3;
  --border:     #263449;
  --border-soft:#1B2740;
  --shadow-color: 220 60% 3%;
  --shadow-sm: 0 1px 2px hsl(var(--shadow-color) / .5);
  --shadow-md: 0 6px 18px hsl(var(--shadow-color) / .5);
  --shadow-lg: 0 22px 55px hsl(var(--shadow-color) / .6);
  --accent-soft: color-mix(in srgb, var(--accent) 22%, var(--surface));
}

/* ============================================================
   PALETAS (acentos) — funcionan en día y noche
   ============================================================ */
[data-palette="oceano"] {
  --accent: #167C9E; --accent-2: #24B7A6; --accent-strong: #0F6079;
}
[data-palette="cielo"] {
  --accent: #4C9BDB; --accent-2: #A6DDF8; --accent-strong: #3B7DB6;
}
[data-palette="crema"] {
  --accent: #6E8FB3; --accent-2: #AEC7DF; --accent-strong: #566F8E;
}
[data-palette="crema"]:not([data-mode="dark"]) {
  --bg: #F7F1E6; --surface-2: #F0E8D8; --surface-3: #E6DBC6; --border: #E4D9C4;
}
[data-palette="lavanda"] {
  --accent: #7B7FD1; --accent-2: #B5AEEE; --accent-strong: #6064B4;
}
/* un poco más de brillo del acento en noche */
[data-palette="celeste"][data-mode="dark"] { --accent: #46A0DD; }
[data-palette="oceano"][data-mode="dark"]  { --accent: #24A6C0; }
[data-palette="crema"][data-mode="dark"]   { --accent: #86A6C8; }
[data-palette="lavanda"][data-mode="dark"] { --accent: #9498E0; }

/* Transición suave al cambiar de tema */
body, .topbar, .card, .modal, .input, .textarea, .select, .btn,
.chip, .dropzone, .hero, .reader, .segmented, .stat, .toast, .footer,
.icon-btn, .menu, .drawer {
  transition: background-color var(--t), color var(--t), border-color var(--t), box-shadow var(--t);
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto; }
}

/* ============================================================
   TIPOGRAFÍA
   ============================================================ */
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; line-height: 1.15; letter-spacing: -0.01em; }
.display { font-family: var(--font-display); }
.muted { color: var(--text-soft); }
.mute-2 { color: var(--text-mute); }
.eyebrow {
  font-family: var(--font-ui); font-size: .72rem; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase; color: var(--accent-strong);
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 clamp(1rem, 4vw, 2.5rem); }
.page { padding-block: clamp(1.5rem, 4vw, 2.75rem) 5rem; }
.row { display: flex; align-items: center; gap: .6rem; }
.row-wrap { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.grow { flex: 1 1 auto; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.divider { height: 1px; background: var(--border); border: 0; margin: 1.25rem 0; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar__inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; height: 68px; }
.brand { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.brand__mark {
  width: 42px; height: 42px; flex: none; border-radius: 12px;
  display: grid; place-items: center; color: var(--accent-contrast);
  background: var(--grad); box-shadow: var(--shadow-sm);
  font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; letter-spacing: .02em;
}
.brand__text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand__title { font-family: var(--font-display); font-weight: 600; font-size: 1.02rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand__sub { font-size: .74rem; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ============================================================
   BOTONES
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .62rem 1.05rem; border-radius: var(--r-pill);
  font-family: var(--font-ui); font-weight: 600; font-size: .92rem;
  border: 1px solid transparent; white-space: nowrap; user-select: none;
  transition: transform var(--t-fast), background-color var(--t), border-color var(--t), box-shadow var(--t), color var(--t);
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn svg { width: 18px; height: 18px; }
.btn--primary { background: var(--grad); color: var(--accent-contrast); box-shadow: var(--shadow-sm); }
.btn--primary:hover { box-shadow: var(--shadow-md); filter: brightness(1.04); }
.btn--soft { background: var(--accent-soft); color: var(--accent-strong); }
.btn--soft:hover { background: color-mix(in srgb, var(--accent) 20%, var(--surface)); }
.btn--ghost { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: var(--shadow-sm); }
.btn--ghost:hover { border-color: var(--accent); color: var(--accent-strong); }
.btn--danger { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); color: var(--danger-strong); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.btn--danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn--sm { padding: .42rem .8rem; font-size: .82rem; }
.btn--lg { padding: .8rem 1.4rem; font-size: 1rem; }
.btn--block { width: 100%; }

.icon-btn {
  width: 40px; height: 40px; flex: none; border-radius: 12px;
  display: grid; place-items: center; color: var(--text-soft);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  transition: all var(--t-fast);
}
.icon-btn:hover { color: var(--accent-strong); border-color: var(--accent); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn--plain { background: transparent; border-color: transparent; box-shadow: none; }
.icon-btn--plain:hover { background: var(--accent-soft); }
.icon-btn--sm { width: 32px; height: 32px; border-radius: 9px; }
.icon-btn--sm svg { width: 16px; height: 16px; }
.icon-btn--danger:hover { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }

/* ============================================================
   CONTROLES DE TEMA
   ============================================================ */
.theme-controls { display: flex; align-items: center; gap: .5rem; }
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + .5rem); z-index: 60;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r);
  box-shadow: var(--shadow-lg); padding: .6rem; min-width: 232px;
  opacity: 0; visibility: hidden; transform: translateY(-6px) scale(.98); transform-origin: top right;
  transition: opacity var(--t), transform var(--t), visibility var(--t);
}
.menu.open { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }
.menu__label { font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-mute); padding: .35rem .5rem; }
.palette-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: .4rem; padding: .25rem .3rem .5rem; }
.swatch {
  aspect-ratio: 1; border-radius: 10px; border: 2px solid var(--border);
  position: relative; overflow: hidden; transition: all var(--t-fast);
}
.swatch::after { content: ""; position: absolute; inset: 0; background: var(--sw); }
.swatch:hover { transform: translateY(-2px); }
.swatch[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.swatch[aria-pressed="true"]::before {
  content: ""; position: absolute; inset: 0; z-index: 1; margin: auto;
  width: 12px; height: 12px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 2px rgba(0,0,0,.15);
}

/* interruptor día/noche */
.mode-toggle {
  position: relative; width: 40px; height: 40px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  display: grid; place-items: center; color: var(--text-soft); overflow: hidden;
}
.mode-toggle:hover { color: var(--accent-strong); border-color: var(--accent); }
.mode-toggle svg { width: 20px; height: 20px; transition: transform var(--t-slow), opacity var(--t); }
.mode-toggle .i-moon { position: absolute; }
[data-mode="dark"] .mode-toggle .i-sun  { opacity: 0; transform: rotate(-90deg) scale(.4); }
[data-mode="dark"] .mode-toggle .i-moon { opacity: 1; transform: rotate(0) scale(1); }
:root:not([data-mode="dark"]) .mode-toggle .i-sun  { opacity: 1; transform: rotate(0) scale(1); }
:root:not([data-mode="dark"]) .mode-toggle .i-moon { opacity: 0; transform: rotate(90deg) scale(.4); }

/* ============================================================
   FORMULARIOS
   ============================================================ */
.field { display: flex; flex-direction: column; gap: .38rem; }
.field__label { font-size: .82rem; font-weight: 600; color: var(--text-soft); }
.field__hint { font-size: .76rem; color: var(--text-mute); }
.input, .textarea, .select {
  width: 100%; padding: .68rem .85rem; border-radius: var(--r-sm);
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  font-size: .94rem; transition: border-color var(--t), box-shadow var(--t), background var(--t);
}
.input::placeholder, .textarea::placeholder { color: var(--text-mute); }
.input:focus, .textarea:focus, .select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.textarea { resize: vertical; min-height: 96px; line-height: 1.55; }
.select { appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238A93A6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .8rem center; padding-right: 2.3rem;
}

/* Interruptor */
.switch { position: relative; display: inline-flex; align-items: center; gap: .6rem; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track { width: 44px; height: 25px; border-radius: 999px; background: var(--surface-3); position: relative; transition: background var(--t); flex: none; }
.switch__track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 19px; height: 19px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform var(--t); }
.switch input:checked + .switch__track { background: var(--accent); }
.switch input:checked + .switch__track::after { transform: translateX(19px); }

/* Segmentado */
.segmented { display: inline-flex; padding: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-pill); gap: 2px; }
.segmented__opt {
  display: inline-flex; align-items: center; gap: .4rem; padding: .38rem .8rem;
  border-radius: var(--r-pill); font-size: .84rem; font-weight: 600; color: var(--text-soft);
  transition: all var(--t-fast);
}
.segmented__opt svg { width: 16px; height: 16px; }
.segmented__opt[aria-pressed="true"] { background: var(--surface); color: var(--accent-strong); box-shadow: var(--shadow-sm); }

/* Buscador */
.search { position: relative; flex: 1 1 260px; min-width: 0; }
.search svg { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--text-mute); pointer-events: none; }
.search .input { padding-left: 2.5rem; border-radius: var(--r-pill); }

/* Etiquetas / chips */
.chip {
  display: inline-flex; align-items: center; gap: .35rem; padding: .28rem .7rem;
  border-radius: var(--r-pill); font-size: .78rem; font-weight: 600;
  background: var(--surface-2); color: var(--text-soft); border: 1px solid var(--border);
  transition: all var(--t-fast); white-space: nowrap;
}
button.chip { cursor: pointer; }
button.chip:hover { border-color: var(--accent); color: var(--accent-strong); }
.chip--accent, .chip[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-strong); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.chip svg { width: 13px; height: 13px; }
.chip__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.chip__x { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; opacity: .6; }
.chip__x:hover { opacity: 1; background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }

/* Entrada de etiquetas */
.tag-input { display: flex; flex-wrap: wrap; gap: .4rem; padding: .45rem; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface); }
.tag-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tag-input input { flex: 1 1 90px; min-width: 90px; border: none; outline: none; background: transparent; padding: .2rem .3rem; font-size: .9rem; }

/* ============================================================
   TARJETAS DE ENSAYO
   ============================================================ */
.essays { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.25rem; }
.essays--list { grid-template-columns: 1fr; }

.card {
  position: relative; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  overflow: hidden; box-shadow: var(--shadow-sm);
  transition: transform var(--t), box-shadow var(--t), border-color var(--t);
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); }
.card__cover {
  position: relative; aspect-ratio: 16 / 8.5; overflow: hidden;
  display: grid; place-items: center; background: var(--grad-soft);
}
.card__cover img { width: 100%; height: 100%; object-fit: cover; }
.card__cover-motif { position: absolute; inset: 0; }
.card__initial {
  position: relative; font-family: var(--font-display); font-weight: 500;
  font-size: 3.4rem; color: color-mix(in srgb, var(--accent-strong) 78%, transparent);
  text-shadow: 0 2px 10px hsl(var(--shadow-color) / .12);
}
.card__cover-badge {
  position: absolute; left: .8rem; top: .8rem; z-index: 2;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(6px); border: 1px solid var(--border-soft);
}
.card__star {
  position: absolute; right: .7rem; top: .7rem; z-index: 2; width: 30px; height: 30px;
  border-radius: 50%; display: grid; place-items: center;
  background: color-mix(in srgb, var(--surface) 85%, transparent); color: var(--warning);
  backdrop-filter: blur(6px); box-shadow: var(--shadow-sm);
}
.card__body { padding: 1rem 1.1rem 1.1rem; display: flex; flex-direction: column; gap: .55rem; flex: 1; }
.card__title { font-size: 1.16rem; line-height: 1.25; }
.card__title[contenteditable="true"] { outline: none; border-radius: 6px; padding: 2px 4px; margin: -2px -4px; }
.card__title[contenteditable="true"]:focus { background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent); }
.card__meta { display: flex; align-items: center; gap: .6rem; font-size: .78rem; color: var(--text-mute); flex-wrap: wrap; }
.card__meta .dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; }
.card__excerpt { font-size: .9rem; color: var(--text-soft); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card__tags { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: auto; }
.card__actions { display: flex; align-items: center; gap: .4rem; padding: .7rem 1.1rem; border-top: 1px solid var(--border-soft); background: var(--surface); }
.card__actions .grow { display: flex; gap: .4rem; }
.drag-handle { cursor: grab; color: var(--text-mute); }
.drag-handle:active { cursor: grabbing; }
.card.dragging { opacity: .5; }
.card.drag-over { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

/* Vista de lista */
.essays--list .card { flex-direction: row; align-items: stretch; }
.essays--list .card__cover { aspect-ratio: auto; width: 168px; flex: none; }
.essays--list .card__body { flex: 1; }
.essays--list .card__actions { border-top: none; border-left: 1px solid var(--border-soft); flex-direction: column; align-items: stretch; justify-content: center; width: 56px; padding: .6rem; }
.essays--list .card__actions .grow { flex-direction: column; }
@media (max-width: 640px) {
  .essays--list .card { flex-direction: column; }
  .essays--list .card__cover { width: 100%; aspect-ratio: 16/7; }
  .essays--list .card__actions { flex-direction: row; width: auto; border-left: none; border-top: 1px solid var(--border-soft); }
  .essays--list .card__actions .grow { flex-direction: row; }
}

/* ============================================================
   DROPZONE / SUBIDA
   ============================================================ */
.dropzone {
  border: 2px dashed var(--border); border-radius: var(--r-lg); background: var(--surface);
  padding: clamp(1.5rem, 4vw, 2.6rem); text-align: center; cursor: pointer;
  transition: all var(--t); position: relative;
}
.dropzone:hover { border-color: var(--accent); background: var(--accent-tint); }
.dropzone--over { border-color: var(--accent); background: var(--accent-soft); transform: scale(1.005); }
.dropzone__icon {
  width: 62px; height: 62px; margin: 0 auto .9rem; border-radius: 18px;
  display: grid; place-items: center; color: var(--accent-contrast); background: var(--grad); box-shadow: var(--shadow-md);
}
.dropzone__icon svg { width: 30px; height: 30px; }
.dropzone__title { font-family: var(--font-display); font-size: 1.15rem; font-weight: 600; }
.dropzone__text { color: var(--text-soft); font-size: .9rem; margin-top: .2rem; }
.dropzone__formats { display: flex; gap: .4rem; justify-content: center; flex-wrap: wrap; margin-top: .9rem; }

/* Cola de procesamiento */
.queue { display: flex; flex-direction: column; gap: .5rem; margin-top: 1rem; }
.queue__item { display: flex; align-items: center; gap: .75rem; padding: .7rem .9rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); }
.queue__ico { width: 34px; height: 34px; flex: none; border-radius: 9px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--border); color: var(--accent-strong); }
.queue__ico svg { width: 18px; height: 18px; }
.queue__name { font-weight: 600; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue__status { font-size: .76rem; color: var(--text-mute); }
.queue__status.ok { color: var(--success); }
.queue__status.err { color: var(--danger); }

/* ============================================================
   MODALES
   ============================================================ */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 1rem;
  background: color-mix(in srgb, #0a1020 55%, transparent); backdrop-filter: blur(4px);
  opacity: 0; visibility: hidden; transition: opacity var(--t), visibility var(--t);
}
.modal-backdrop.open { opacity: 1; visibility: visible; }
.modal {
  width: 100%; max-width: 620px; max-height: 92vh; display: flex; flex-direction: column;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); overflow: hidden;
  transform: translateY(14px) scale(.98); transition: transform var(--t);
}
.modal-backdrop.open .modal { transform: translateY(0) scale(1); }
.modal--wide { max-width: 780px; }
.modal--reader { max-width: 840px; }
.modal__head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.1rem 1.3rem; border-bottom: 1px solid var(--border); }
.modal__title { font-size: 1.2rem; }
.modal__body { padding: 1.3rem; overflow-y: auto; display: flex; flex-direction: column; gap: 1rem; }
.modal__foot { display: flex; align-items: center; justify-content: flex-end; gap: .7rem; padding: 1rem 1.3rem; border-top: 1px solid var(--border); background: var(--surface); }
.modal__foot .grow { display: flex; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-grid .col-2 { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }

/* ============================================================
   LECTOR DE ENSAYO
   ============================================================ */
.reader__head { padding: 1.6rem 1.8rem 1.2rem; border-bottom: 1px solid var(--border); }
.reader__title { font-size: clamp(1.5rem, 3vw, 2.1rem); line-height: 1.15; margin-bottom: .5rem; }
.reader__meta { display: flex; flex-wrap: wrap; align-items: center; gap: .7rem; font-size: .82rem; color: var(--text-mute); }
.reader__body { padding: clamp(1.2rem, 4vw, 2.2rem) clamp(1.2rem, 4vw, 2.6rem) 2.4rem; overflow-y: auto; }

/* Contenido tipográfico del ensayo */
.essay-content { font-family: var(--font-read); font-size: 1.08rem; line-height: 1.75; color: var(--text); max-width: 68ch; margin: 0 auto; }
.essay-content > *:first-child { margin-top: 0; }
.essay-content p { margin: 0 0 1.1em; }
.essay-content h1, .essay-content h2, .essay-content h3, .essay-content h4 { margin: 1.6em 0 .5em; line-height: 1.25; }
.essay-content h1 { font-size: 1.7em; } .essay-content h2 { font-size: 1.4em; } .essay-content h3 { font-size: 1.18em; }
.essay-content ul, .essay-content ol { margin: 0 0 1.1em; padding-left: 1.4em; }
.essay-content li { margin-bottom: .4em; }
.essay-content a { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 2px; }
.essay-content blockquote {
  margin: 1.4em 0; padding: .3em 0 .3em 1.3em; border-left: 3px solid var(--accent);
  color: var(--text-soft); font-style: italic;
}
.essay-content img { border-radius: var(--r-sm); margin: 1.4em auto; box-shadow: var(--shadow-md); }
.essay-content hr { border: 0; height: 1px; background: var(--border); margin: 2em 0; }
.essay-content table { width: 100%; border-collapse: collapse; margin: 1.4em 0; font-family: var(--font-ui); font-size: .92rem; }
.essay-content th, .essay-content td { border: 1px solid var(--border); padding: .55em .8em; text-align: left; }
.essay-content th { background: var(--surface-2); font-weight: 600; }
.essay-content code { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; background: var(--surface-2); padding: .1em .4em; border-radius: 5px; font-size: .9em; }
.essay-content pre { background: var(--surface-2); padding: 1em; border-radius: var(--r-sm); overflow-x: auto; margin: 1.4em 0; }
.essay-content pre code { background: none; padding: 0; }

/* ============================================================
   ESTADOS VACÍOS / CARGA
   ============================================================ */
.empty { text-align: center; padding: clamp(2.5rem, 8vw, 5rem) 1.5rem; }
.empty__icon { width: 84px; height: 84px; margin: 0 auto 1.2rem; border-radius: 24px; display: grid; place-items: center; color: var(--accent-strong); background: var(--accent-soft); }
.empty__icon svg { width: 40px; height: 40px; }
.empty__title { font-size: 1.4rem; margin-bottom: .4rem; }
.empty__text { color: var(--text-soft); max-width: 42ch; margin: 0 auto 1.5rem; }

.spinner { width: 20px; height: 20px; border: 2.5px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: var(--r-sm); }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ============================================================
   TOASTS
   ============================================================ */
.toasts { position: fixed; bottom: 1.2rem; right: 1.2rem; z-index: 200; display: flex; flex-direction: column; gap: .6rem; max-width: min(380px, calc(100vw - 2rem)); }
.toast {
  display: flex; align-items: center; gap: .7rem; padding: .8rem 1rem;
  background: var(--bg-elev); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: var(--r-sm); box-shadow: var(--shadow-lg); font-size: .9rem;
  animation: toastIn var(--t) both;
}
.toast.leaving { animation: toastOut var(--t) forwards; }
.toast--success { border-left-color: var(--success); }
.toast--error { border-left-color: var(--danger); }
.toast--info { border-left-color: var(--accent); }
.toast__ico { flex: none; color: var(--accent); }
.toast--success .toast__ico { color: var(--success); }
.toast--error .toast__ico { color: var(--danger); }
.toast__ico svg { width: 20px; height: 20px; }
@keyframes toastIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(40px); } }

/* ============================================================
   BARRA DE ALMACENAMIENTO / STATS (admin)
   ============================================================ */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; }
.stat { padding: 1.1rem 1.2rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-sm); }
.stat__num { font-family: var(--font-display); font-size: 1.8rem; font-weight: 600; line-height: 1; }
.stat__label { font-size: .8rem; color: var(--text-soft); margin-top: .3rem; }
.storagebar { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin-top: .55rem; }
.storagebar__fill { height: 100%; background: var(--grad); border-radius: 999px; transition: width var(--t-slow); }

/* ============================================================
   HERO / PORTADA (público)
   ============================================================ */
.hero { position: relative; overflow: hidden; border-bottom: 1px solid var(--border); }
.hero__bg {
  position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(62% 85% at 88% -10%, var(--accent-tint), transparent 70%),
    radial-gradient(52% 72% at -5% 110%, color-mix(in srgb, var(--accent-2) 14%, transparent), transparent 70%);
}
.hero__inner { position: relative; z-index: 1; display: flex; gap: clamp(1.5rem, 5vw, 3rem); align-items: center; padding-block: clamp(2.5rem, 7vw, 4.5rem); flex-wrap: wrap; }
.hero__avatar {
  width: clamp(96px, 18vw, 132px); height: clamp(96px, 18vw, 132px); flex: none; border-radius: 30px;
  display: grid; place-items: center; background: var(--grad); color: var(--accent-contrast);
  font-family: var(--font-display); font-size: clamp(2.4rem, 6vw, 3.4rem); font-weight: 500;
  box-shadow: var(--shadow-lg); position: relative;
}
.hero__avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.hero__text { flex: 1 1 340px; min-width: 0; }
.hero__name { font-size: clamp(2rem, 5.5vw, 3.1rem); line-height: 1.05; margin: .5rem 0 .3rem; }
.hero__role { font-size: clamp(1rem, 2.4vw, 1.2rem); color: var(--accent-strong); font-weight: 600; }
.hero__bio { color: var(--text-soft); margin-top: .9rem; max-width: 62ch; font-size: 1.02rem; }
.hero__meta { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.2rem; }

.filters { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin: 1.75rem 0 1.4rem; }
.cat-scroll { display: flex; gap: .5rem; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.cat-scroll::-webkit-scrollbar { height: 6px; }

.footer { border-top: 1px solid var(--border); padding: 2rem 0 3rem; margin-top: 3rem; color: var(--text-soft); font-size: .9rem; }
.footer__inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

/* ============================================================
   VARIOS
   ============================================================ */
.count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-strong); font-size: .72rem; font-weight: 700; }
.badge-lang { display: inline-flex; align-items: center; gap: .3rem; }
.hint-box { display: flex; gap: .7rem; padding: .85rem 1rem; background: var(--accent-tint); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); border-radius: var(--r-sm); font-size: .86rem; color: var(--text-soft); }
.hint-box svg { flex: none; width: 18px; height: 18px; color: var(--accent-strong); margin-top: 2px; }

/* scrollbars sutiles */
* { scrollbar-color: var(--surface-3) transparent; }
.modal__body::-webkit-scrollbar, .reader__body::-webkit-scrollbar, .menu::-webkit-scrollbar { width: 9px; }
.modal__body::-webkit-scrollbar-thumb, .reader__body::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 999px; border: 2px solid var(--bg-elev); }

/* entrada animada de tarjetas */
.animate-in { animation: cardIn var(--t-slow) both; }
@keyframes cardIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ============================================================
   EDITOR DE CONTENIDO (admin)
   ============================================================ */
.editor { border: 1px solid var(--border); border-radius: var(--r-sm); overflow: hidden; background: var(--surface); }
.editor:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.editor__toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: .4rem; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.editor__btn { min-width: 34px; height: 34px; padding: 0 .4rem; border-radius: 8px; display: grid; place-items: center; color: var(--text-soft); font-weight: 700; font-size: .85rem; }
.editor__btn:hover { background: var(--accent-soft); color: var(--accent-strong); }
.editor__btn svg { width: 17px; height: 17px; }
.editor__sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.editor__area { padding: 1rem 1.15rem; min-height: 200px; max-height: 42vh; overflow-y: auto; outline: none; font-size: 1rem; }
.editor__area:empty::before { content: attr(data-placeholder); color: var(--text-mute); }

/* Miniatura / subida de imagen (portada, avatar) */
.thumb-up { display: flex; align-items: center; gap: .85rem; flex-wrap: wrap; }
.thumb-up__prev { width: 104px; height: 68px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); overflow: hidden; display: grid; place-items: center; color: var(--text-mute); flex: none; }
.thumb-up__prev.round { width: 72px; height: 72px; border-radius: 50%; }
.thumb-up__prev img { width: 100%; height: 100%; object-fit: cover; }
.thumb-up__prev svg { width: 24px; height: 24px; }

/* Cabecera de acciones del admin */
.admin-actions { display: flex; gap: .55rem; flex-wrap: wrap; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.section-title { display: flex; align-items: center; gap: .6rem; font-family: var(--font-display); font-size: 1.35rem; font-weight: 600; }
.section-title svg { width: 22px; height: 22px; color: var(--accent-strong); }
.mb { margin-bottom: 2rem; }
.card__cover.mini { aspect-ratio: auto; }

@media (max-width: 720px) {
  .topbar__inner { height: 60px; }
  .brand__sub { display: none; }
  .hide-sm { display: none !important; }
}
