/* ═══════════════════════════════════════════════════════════════════════════
   AUTORES — "Imprenta" theme
   Minimalismo editorial: papel cálido, tinta casi negra, un acento burdeos
   usado con moderación, filetes finos y tipografía clásica.
   Fraunces (display) · Inter (UI) · PT Serif (cuerpo).
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Design tokens ─────────────────────────────────────────────────────── */
:root {
  /* Papel y tinta */
  --paper:        #f5f3ee;
  --paper-2:      #efece4;
  --surface:      #fffefb;
  --ink:          #1d1a16;
  --ink-soft:     #5c564c;
  --muted:        #7c756a;
  --faint:        #a39b8e;

  /* Filetes */
  --line:         #e5e0d5;
  --line-strong:  #d2cbbc;

  /* Acento — burdeos de imprenta */
  --accent:       #8a2b3a;
  --accent-h:     #a83448;
  --accent-deep:  #641f2b;
  --accent-bg:    #f6e9eb;

  /* Estados */
  --green:        #3d7a50;
  --green-bg:     #e9f2ea;
  --green-br:     #c4dcc9;
  --yellow:       #91660f;
  --yellow-bg:    #f7eed6;
  --yellow-br:    #e6d4a3;
  --red:          #b03d36;
  --red-bg:       #f9e9e6;
  --red-br:       #ecc7c1;

  /* Forma y profundidad */
  --radius:       10px;
  --radius-sm:    7px;
  --radius-lg:    14px;
  --shadow:       0 1px 2px rgba(29, 26, 22, .05);
  --shadow-md:    0 10px 30px -12px rgba(29, 26, 22, .18);

  /* Tipografía */
  --font-ui:      'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Fraunces', 'PT Serif', Georgia, serif;
  --font-body:    'PT Serif', Georgia, 'Times New Roman', serif;
  --font-mono:    ui-monospace, 'Cascadia Code', 'SF Mono', Consolas, monospace;

  --ease:         cubic-bezier(.4, 0, .2, 1);
}

/* ── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; transition: color .15s var(--ease); }
a:hover { color: var(--accent-deep); }
img { max-width: 100%; }
strong { font-weight: 700; }
em { font-style: italic; }

::selection { background: rgba(138, 43, 58, .18); }

* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 20px;
  border: 3px solid transparent;
  background-clip: content-box;
}

/* ── Navbar ────────────────────────────────────────────────────────────── */
.navbar {
  background: rgba(255, 254, 251, .92);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--line);
}
.nav-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.75rem;
  height: 60px;
}
.nav-brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-style: italic;
  font-size: 1.25rem;
  letter-spacing: -.01em;
  white-space: nowrap;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: .5rem;
}
.brand-mark { width: 24px; height: 24px; border-radius: 6px; }
.nav-brand:hover { color: var(--accent); }
.nav-links { display: flex; gap: .2rem; flex: 1; }
.nav-links a {
  font-family: var(--font-ui);
  color: var(--ink-soft);
  padding: .4rem .8rem;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 500;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.nav-links a:hover { background: var(--paper-2); color: var(--ink); }
.nav-user {
  display: flex; align-items: center; gap: .6rem;
  font-family: var(--font-ui);
  font-size: .85rem; color: var(--ink-soft); white-space: nowrap;
}
.btn-logout {
  font-family: var(--font-ui);
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--ink-soft);
  padding: .32rem .75rem;
  border-radius: var(--radius-sm);
  font-size: .78rem;
  font-weight: 500;
  transition: all .15s var(--ease);
}
.btn-logout:hover { border-color: var(--accent); color: var(--accent); }
.badge-editor {
  font-family: var(--font-ui);
  background: var(--ink);
  color: var(--paper);
  font-size: .6rem;
  padding: .22rem .55rem;
  border-radius: 3px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
}

/* ── Flash messages ────────────────────────────────────────────────────── */
.flash {
  max-width: 1180px;
  margin: 1rem auto 0;
  padding: .75rem 1.1rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: .88rem;
  width: calc(100% - 3rem);
  display: flex; align-items: center; gap: .55rem;
  animation: rise-in .3s var(--ease) both;
}
@keyframes rise-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.flash::before { font-weight: 700; line-height: 1; }
.flash-ok    { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-br); }
.flash-ok::before    { content: '✓'; }
.flash-error { background: var(--red-bg); color: var(--red); border: 1px solid var(--red-br); }
.flash-error::before { content: '!'; }

/* ── Main content ──────────────────────────────────────────────────────── */
.main-content {
  max-width: 1180px;
  margin: 2.25rem auto;
  padding: 0 1.5rem;
  width: 100%;
  flex: 1;
  animation: rise-in .35s var(--ease) both;
}

/* ── Page header ───────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 1.9rem;
  gap: 1rem;
  flex-wrap: wrap;
  padding-bottom: 1.2rem;
  border-bottom: 1px solid var(--line);
}
.page-header h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 550;
  letter-spacing: -.02em;
  line-height: 1.12;
}
.page-overline,
.card-overline {
  font-family: var(--font-ui);
  font-size: .68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--accent);
  margin-bottom: .35rem;
}
.card-overline { margin-bottom: .9rem; }
.page-header-id { display: flex; align-items: center; gap: 1rem; }

/* ── Cards ─────────────────────────────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1.1rem;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.35rem;
  box-shadow: var(--shadow);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
  display: flex;
  flex-direction: column;
  gap: .7rem;
}
.card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-md); }
.card-title {
  font-family: var(--font-display);
  font-size: 1.22rem;
  font-weight: 600;
  letter-spacing: -.01em;
  line-height: 1.25;
}
.card-title a { color: var(--ink); }
.card-title a:hover { color: var(--accent); }
.card-desc { line-height: 1.5; }
.card-meta  { font-family: var(--font-ui); font-size: .78rem; color: var(--muted); display: flex; gap: .45rem; flex-wrap: wrap; align-items: center; }
.card-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: auto; padding-top: .55rem; align-items: center; }

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .55rem 1.1rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: .86rem;
  font-weight: 550;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), box-shadow .15s var(--ease);
  text-align: center;
  white-space: nowrap;
  line-height: 1.2;
}
.btn:hover { text-decoration: none; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(138, 43, 58, .25); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary  { background: var(--ink); color: var(--paper); }
.btn-primary:hover:not(:disabled) { background: var(--accent); color: #fff; }

.btn-secondary{ background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-secondary:hover { border-color: var(--ink); }

.btn-danger   { background: transparent; color: var(--red); border-color: transparent; }
.btn-danger:hover { background: var(--red-bg); border-color: var(--red-br); }

.btn-success  { background: var(--green-bg); color: var(--green); border-color: var(--green-br); }
.btn-success:hover { background: var(--green); color: #fff; }

.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink-soft); }
.btn-ghost:hover { border-color: var(--line-strong); color: var(--ink); }

.btn-sm { padding: .36rem .75rem; font-size: .8rem; }

/* ── Status badges ─────────────────────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: .38rem;
  padding: .2rem .65rem;
  border-radius: 30px;
  font-family: var(--font-ui);
  font-size: .73rem;
  font-weight: 550;
  white-space: nowrap;
}
.status-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; }
.status-listo    { background: var(--green-bg);  color: var(--green);  border: 1px solid var(--green-br); }
.status-listo::before    { background: var(--green); }
.status-necesita { background: var(--yellow-bg); color: var(--yellow); border: 1px solid var(--yellow-br); }
.status-necesita::before { background: var(--yellow); }
.status-faltante { background: var(--red-bg);    color: var(--red);    border: 1px solid var(--red-br); }
.status-faltante::before { background: var(--red); }

/* ── Fecha límite (deadline) ───────────────────────────────────────────── */
.deadline-badge {
  display: inline-flex;
  align-items: center;
  gap: .38rem;
  padding: .2rem .65rem;
  border-radius: 30px;
  font-family: var(--font-ui);
  font-size: .73rem;
  font-weight: 550;
}
.deadline-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; }
.deadline-ok    { background: var(--surface);   color: var(--ink-soft); border: 1px solid var(--line-strong); }
.deadline-ok::before    { background: var(--muted); }
.deadline-soon  { background: var(--yellow-bg); color: var(--yellow); border: 1px solid var(--yellow-br); }
.deadline-soon::before  { background: var(--yellow); }
.deadline-today { background: var(--red-bg);    color: var(--red);    border: 1px solid var(--red-br); }
.deadline-today::before { background: var(--red); }
.deadline-over  { background: var(--red-bg);    color: var(--red);    border: 1px solid var(--red-br); }
.deadline-over::before  { background: var(--red); }

/* ── Stat tiles (panel del editor) ─────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: .8rem;
  margin-bottom: 2rem;
}
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}
.stat-value {
  display: block;
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 550;
  line-height: 1.1;
  letter-spacing: -.02em;
}
.stat-value small { font-size: 1.1rem; color: var(--muted); }
.stat-value.warn  { color: var(--yellow); }
.stat-value.alert { color: var(--red); }
.stat-label {
  font-family: var(--font-ui);
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
}

/* ── Progress bars ─────────────────────────────────────────────────────── */
.progress { display: flex; align-items: center; gap: .6rem; }
.progress-track {
  flex: 1;
  height: 6px;
  background: var(--paper-2);
  border-radius: 6px;
  overflow: hidden;
  display: flex;
}
.progress-fill { height: 100%; }
.progress-fill.green  { background: var(--green); }
.progress-fill.yellow { background: #d3a73e; }
.progress-label {
  font-family: var(--font-ui);
  font-size: .72rem;
  font-weight: 600;
  color: var(--muted);
  min-width: 2.4em;
  text-align: right;
}
.project-progress { max-width: 560px; display: flex; flex-direction: column; gap: .5rem; }

/* ── Forms ─────────────────────────────────────────────────────────────── */
.form-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2.25rem;
  box-shadow: var(--shadow-md);
  max-width: 440px;
  margin: 0 auto;
}
.form-card-brand {
  font-family: var(--font-display);
  font-style: italic;
  font-size: .95rem;
  color: var(--accent);
  margin-bottom: 1.6rem;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: .6rem;
}
.brand-mark-lg { width: 36px; height: 36px; border-radius: 8px; }
.form-card h1 {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 550;
  margin-bottom: 1.4rem;
  letter-spacing: -.02em;
}
.form-group { margin-bottom: 1.1rem; }
.form-group label {
  display: block;
  font-family: var(--font-ui);
  font-size: .72rem; font-weight: 600;
  margin-bottom: .38rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: .08em;
}
.label-soft { color: var(--faint); font-weight: 500; text-transform: none; letter-spacing: 0; }
.form-control {
  width: 100%;
  padding: .6rem .85rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: .92rem;
  background: var(--surface);
  color: var(--ink);
  transition: border .15s var(--ease), box-shadow .15s var(--ease);
}
.form-control::placeholder { color: var(--faint); }
.form-control:hover { border-color: var(--faint); }
.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(138, 43, 58, .12);
}
.form-control:disabled, .form-control[disabled] { background: var(--paper-2); color: var(--muted); cursor: not-allowed; }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 88px; font-family: var(--font-body); line-height: 1.6; }
textarea.form-control.mono { font-family: var(--font-mono); font-size: .8rem; line-height: 1.55; }
.form-hint { font-family: var(--font-ui); font-size: .77rem; color: var(--muted); margin-top: .3rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 500px) { .form-row { grid-template-columns: 1fr; } }

/* ── Tables ────────────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: collapse; font-family: var(--font-ui); font-size: .88rem; }
th {
  text-align: left; padding: .75rem 1rem;
  border-bottom: 1px solid var(--line-strong);
  font-weight: 600; font-size: .68rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: .1em;
}
td { padding: .8rem 1rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s var(--ease); }
tbody tr:hover td { background: var(--paper); }
.user-cell { display: flex; align-items: center; gap: .65rem; color: var(--ink); }
.user-cell:hover strong { color: var(--accent); }

/* ── Items list ────────────────────────────────────────────────────────── */
.items-list { display: flex; flex-direction: column; gap: .55rem; }
.item-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .85rem 1.1rem;
  display: flex;
  align-items: center;
  gap: .9rem;
  box-shadow: var(--shadow);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.item-row:hover { border-color: var(--line-strong); box-shadow: var(--shadow-md); }
.item-main { flex: 1; min-width: 0; }
.item-drag-handle { cursor: grab; color: var(--faint); font-size: 1.05rem; user-select: none; padding: 0 .2rem; }
.item-row:hover .item-drag-handle { color: var(--muted); }
.item-drag-handle:active { cursor: grabbing; }
.item-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.02rem;
  letter-spacing: -.01em;
  line-height: 1.3;
}
.item-author {
  font-family: var(--font-ui); font-size: .82rem; color: var(--ink-soft);
  display: flex; align-items: center; gap: .4rem; white-space: nowrap;
}
.item-actions { display: flex; gap: .4rem; flex-shrink: 0; align-items: center; }
.item-wc { white-space: nowrap; }
.item-row.dragging { opacity: .4; }
.item-row.drag-over { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(138, 43, 58, .2); }
.status-select.status-listo    { color: var(--green); }
.status-select.status-necesita_edicion { color: var(--yellow); }
.status-select.status-faltante { color: var(--red); }

/* ── Mini lists (actividad, perfiles) ──────────────────────────────────── */
.mini-list { display: flex; flex-direction: column; }
.mini-row {
  display: flex; align-items: center; gap: .8rem;
  padding: .65rem .2rem;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  transition: background .12s var(--ease);
}
.mini-row:last-child { border-bottom: none; }
.mini-row:hover { background: var(--paper); }
.mini-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .1rem; }
.mini-title { font-family: var(--font-display); font-weight: 600; font-size: .95rem; line-height: 1.3; }
.mini-row:hover .mini-title { color: var(--accent); }

/* ── Avatares ──────────────────────────────────────────────────────────── */
.avatar-img { border-radius: 50%; object-fit: cover; border: 1px solid var(--line-strong); flex-shrink: 0; }
.avatar-initials {
  border-radius: 50%;
  background: var(--accent-bg);
  color: var(--accent);
  border: 1px solid #ecd5d9;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-ui); font-weight: 600;
  flex-shrink: 0;
  letter-spacing: .02em;
}

/* ── Profile page ──────────────────────────────────────────────────────── */
.profile-layout { display: grid; grid-template-columns: 240px 1fr; gap: 1.25rem; align-items: start; }
.profile-avatar-section { text-align: center; align-items: center; }
@media (max-width: 640px) { .profile-layout { grid-template-columns: 1fr; } }

/* ── Inline edit forms ─────────────────────────────────────────────────── */
.inline-form { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.inline-form select,
.inline-form input[type=text] {
  padding: .42rem .7rem;
  font-family: var(--font-ui);
  font-size: .84rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  transition: border .15s var(--ease), box-shadow .15s var(--ease);
}
.inline-form select:focus,
.inline-form input[type=text]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(138,43,58,.12); }

/* ── Author chips ──────────────────────────────────────────────────────── */
.author-chips { display: flex; flex-wrap: wrap; gap: .45rem; margin-bottom: 1rem; }
.author-chip {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 30px;
  padding: .22rem .7rem .22rem .28rem;
  font-family: var(--font-ui);
  font-size: .82rem;
  display: flex; align-items: center; gap: .45rem;
  color: var(--ink);
  transition: border-color .15s var(--ease);
}
.author-chip:hover { border-color: var(--line-strong); }
.author-chip a { color: var(--ink); }
.author-chip a:hover { color: var(--accent); }
.author-chip .remove-author {
  cursor: pointer; color: var(--muted);
  border: none; background: var(--paper-2); line-height: 1; font-size: .8rem;
  width: 19px; height: 19px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all .15s var(--ease);
}
.author-chip .remove-author:hover { background: var(--accent); color: #fff; }

/* ── Status summary dots ───────────────────────────────────────────────── */
.status-summary { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; font-family: var(--font-ui); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.status-dot.green  { background: var(--green); }
.status-dot.yellow { background: #d3a73e; }
.status-dot.red    { background: var(--red); }
.status-count { font-size: .78rem; color: var(--muted); }
.status-sep { color: var(--faint); }

/* ── Acuerdo de Edición ────────────────────────────────────────────────── */
.agreement {
  font-family: var(--font-ui);
  font-size: .82rem;
  color: var(--ink-soft);
  line-height: 1.65;
}
.agreement p { margin-bottom: .7rem; }
.agreement p:last-child { margin-bottom: 0; }
.agreement h3 {
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: .7rem;
  letter-spacing: -.01em;
}
.agreement h4 {
  font-size: .76rem;
  font-weight: 700;
  color: var(--ink);
  margin: 1rem 0 .4rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.agreement ul { margin: 0 0 .7rem 1.2rem; }
.agreement li { margin-bottom: .3rem; }
.agreement-accepted {
  font-weight: 600;
  color: var(--green);
  background: var(--green-bg);
  border: 1px solid var(--green-br);
  border-radius: var(--radius-sm);
  padding: .45rem .75rem;
}
.agreement-details { margin-bottom: 1rem; box-shadow: none; }
.agreement-details summary { font-size: .84rem; padding: .7rem 1rem; }
.agreement-details .card-inner { max-height: 280px; overflow-y: auto; }
.agreement-accept {
  display: flex;
  gap: .55rem;
  align-items: flex-start;
  font-family: var(--font-ui);
  font-size: .85rem;
  color: var(--ink-soft);
  margin-bottom: .5rem;
  cursor: pointer;
  line-height: 1.5;
}
.agreement-accept input { margin-top: .2rem; accent-color: var(--accent); }

/* ── Aviso de invitación (registro) ────────────────────────────────────── */
.invite-banner {
  background: var(--accent-bg);
  border: 1px solid #ecd5d9;
  border-radius: var(--radius-sm);
  padding: .8rem 1rem;
  font-family: var(--font-ui);
  font-size: .86rem;
  color: var(--accent-deep);
  line-height: 1.55;
  margin-bottom: 1.25rem;
}

/* ── Login page ────────────────────────────────────────────────────────── */
body.login-page { align-items: center; justify-content: center; padding: 2rem 1rem; }
body.login-page .main-content { width: 100%; display: flex; flex-direction: column; justify-content: center; }

/* ── Section header ────────────────────────────────────────────────────── */
.section-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 1rem; gap: 1rem; }
.section-header h2,
.page-header h2 {
  font-family: var(--font-display);
  font-size: 1.28rem;
  font-weight: 600;
  letter-spacing: -.01em;
}

/* ── Divider ───────────────────────────────────────────────────────────── */
.divider { border: none; height: 1px; background: var(--line); margin: 1.75rem 0; }

/* ── Empty state ───────────────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 3.5rem 1.5rem;
  color: var(--ink-soft);
  font-size: 1rem;
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
}
.empty-state .emoji { font-size: 2.2rem; margin-bottom: .8rem; display: block; }

/* ── Modal ─────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(29, 26, 22, .45);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 1rem;
  animation: fade-in .15s var(--ease) both;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  max-width: 640px; width: 100%;
  max-height: 82vh;
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: modal-in .22s var(--ease) both;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.modal-header { padding: 1.1rem 1.4rem; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-family: var(--font-display); font-size: 1.12rem; font-weight: 600; }
.modal-close { cursor: pointer; background: none; border: none; font-size: 1.1rem; color: var(--muted); line-height: 1; transition: color .15s var(--ease); }
.modal-close:hover { color: var(--accent); }
.modal-body { padding: 1.4rem; overflow-y: auto; flex: 1; }
.modal-foot { padding: 1.05rem 1.4rem; border-top: 1px solid var(--line); display: flex; gap: .6rem; justify-content: flex-end; }
.version-preview { white-space: pre-wrap; font-family: var(--font-body); font-size: .92rem; line-height: 1.7; }

/* ── Breadcrumb ────────────────────────────────────────────────────────── */
.breadcrumb { font-family: var(--font-ui); font-size: .8rem; color: var(--muted); margin-bottom: 1.2rem; display: flex; gap: .45rem; align-items: center; flex-wrap: wrap; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { color: var(--faint); }

/* ── Details/summary ───────────────────────────────────────────────────── */
details {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
details summary {
  cursor: pointer; padding: .85rem 1.25rem;
  font-family: var(--font-ui); font-weight: 550; font-size: .88rem;
  user-select: none; color: var(--ink-soft);
  list-style: none;
  transition: color .15s var(--ease);
}
details summary::-webkit-details-marker { display: none; }
details summary::after { content: '▾'; float: right; color: var(--faint); transition: transform .2s var(--ease); }
details[open] summary::after { transform: rotate(180deg); }
details summary:hover { color: var(--accent); }
details[open] summary { border-bottom: 1px solid var(--line); }
details .card-inner { padding: 1.1rem 1.25rem 1.25rem; }

/* ── Layout grids ──────────────────────────────────────────────────────── */
.admin-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.1rem;
  align-items: start;
}
.dash-two-col {
  display: grid;
  grid-template-columns: 1.7fr 1fr;
  gap: 1.5rem;
  align-items: start;
}
.settings-grid {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 1.1rem;
  align-items: start;
}
@media (max-width: 900px) {
  .dash-two-col, .settings-grid { grid-template-columns: 1fr; }
}

/* ── Configuración: etiquetas y clave API ──────────────────────────────── */
.tag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: .5rem;
}
.tag-check {
  display: flex; align-items: center; gap: .5rem;
  cursor: pointer;
  padding: .42rem .65rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: .84rem;
  transition: border-color .15s var(--ease);
}
.tag-check:hover { border-color: var(--line-strong); }
.tag-check input { accent-color: var(--accent); }
.key-status {
  display: inline-flex; align-items: center; gap: .45rem;
  font-family: var(--font-ui); font-size: .8rem; font-weight: 550;
  padding: .3rem .7rem; border-radius: 30px;
  margin-bottom: .5rem;
}
.key-status .key-dot { width: 7px; height: 7px; border-radius: 50%; }
.key-status.ok      { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-br); }
.key-status.ok .key-dot      { background: var(--green); }
.key-status.missing { background: var(--yellow-bg); color: var(--yellow); border: 1px solid var(--yellow-br); }
.key-status.missing .key-dot { background: var(--yellow); }

/* ── Código inline ─────────────────────────────────────────────────────── */
code {
  font-family: var(--font-mono);
  font-size: .82em;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: .08em .35em;
}

/* ── Vista de lectura ──────────────────────────────────────────────────── */
.reading-wrap { max-width: 720px; margin: 0 auto; }
.reading-head { margin-bottom: 1.6rem; }
.reading-title {
  font-family: var(--font-display);
  font-size: 2.1rem;
  font-weight: 550;
  letter-spacing: -.02em;
  line-height: 1.15;
  margin: .15rem 0 .8rem;
}
.reading-meta { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; font-family: var(--font-ui); }
.reading-author { display: inline-flex; align-items: center; gap: .45rem; font-size: .85rem; color: var(--ink-soft); }
.reading-content {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 2.5rem 2.75rem;
  font-family: var(--font-body);
  font-size: 1.08rem;
  line-height: 1.9;
  color: var(--ink);
  overflow-wrap: break-word;
}
.reading-content p { margin-bottom: 1.05rem; }
.reading-content p:last-child { margin-bottom: 0; }
.reading-content h3, .reading-content h4, .reading-content h5, .reading-content h6 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -.01em;
  line-height: 1.25;
  margin: 1.6rem 0 .7rem;
}
.reading-content h3:first-child, .reading-content h4:first-child { margin-top: 0; }
.reading-content h3 { font-size: 1.5rem; }
.reading-content h4 { font-size: 1.25rem; }
.reading-content h5 { font-size: 1.08rem; }
.reading-content h6 { font-size: .95rem; color: var(--ink-soft); }
.reading-content ul { margin: 0 0 1.05rem 1.3rem; }
.reading-content li { margin-bottom: .35rem; }
.reading-content blockquote {
  border-left: 3px solid var(--line-strong);
  padding: .2rem 0 .2rem 1rem;
  margin: 0 0 1.05rem;
  color: var(--ink-soft);
  font-style: italic;
}
.reading-content hr { border: none; height: 1px; background: var(--line); margin: 1.6rem auto; max-width: 180px; }
.reading-content img {
  display: block;
  max-width: 100%;
  border-radius: var(--radius-sm);
  margin: 1.1rem auto;
}
.reading-content mark { background: var(--yellow-bg); padding: .05em .25em; border-radius: 3px; }

/* ── Hamburger nav button ──────────────────────────────────────────────── */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: .4rem;
  margin-left: auto;
  color: var(--ink);
  flex-direction: column;
  gap: 5px;
}
.nav-toggle span {
  display: block; width: 21px; height: 2px;
  background: currentColor; border-radius: 2px;
  transition: all .2s var(--ease);
}
.nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; }
.nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Util ──────────────────────────────────────────────────────────────── */
.text-muted  { color: var(--muted); }
.text-sm     { font-size: .85rem; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.flex { display: flex; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 160px; }
.hidden { display: none; }

/* ─────────────────────────────────────────────────────────────────────────
   RESPONSIVE — 640px and below
   ───────────────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .nav-inner { flex-wrap: wrap; height: auto; padding: .7rem 1.1rem; gap: .5rem; }
  .nav-brand { flex: 1; }
  .nav-toggle { display: flex; }
  .nav-links {
    display: none; flex-direction: column;
    width: 100%; padding: .3rem 0 .5rem; gap: .15rem;
  }
  .nav-links.open { display: flex; animation: rise-in .25s var(--ease) both; }
  .nav-links a { padding: .7rem .6rem; }
  /* El usuario y "Salir" viven dentro del menú desplegado, no en una fila fija */
  .nav-user { display: none; }
  .nav-links.open ~ .nav-user {
    display: flex;
    width: 100%;
    padding: .55rem .5rem .3rem;
    border-top: 1px solid var(--line);
    font-size: .82rem;
    animation: rise-in .25s var(--ease) both;
  }

  .main-content { margin: 1.25rem auto; padding: 0 1rem; }
  .flash { margin: .6rem auto 0; width: calc(100% - 2rem); }
  .card-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .page-header h1 { font-size: 1.6rem; }

  .item-row { flex-wrap: wrap; gap: .55rem; }
  .item-main { width: 100%; }
  .item-drag-handle { order: -1; }
  .item-actions { width: 100%; justify-content: flex-end; }

  .inline-form { flex-direction: column; align-items: stretch; }
  .inline-form select, .inline-form input[type=text] { width: 100%; }

  /* 16px mínimo en campos: evita el zoom automático de iOS al enfocar */
  .form-control,
  .inline-form select,
  .inline-form input[type=text],
  #paste-modal-area { font-size: 16px; }

  .admin-two-col { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(3, 1fr); }

  .btn { min-height: 44px; padding: .55rem 1.05rem; }
  .btn-sm { min-height: 38px; padding: .45rem .8rem; font-size: .8rem; }

  .form-card { padding: 1.6rem 1.4rem; }
  .section-header { flex-wrap: wrap; }
  .reading-content { padding: 1.5rem 1.25rem; font-size: 1.02rem; }
  .reading-title { font-size: 1.6rem; }
  .modal { max-width: 100%; max-height: 92vh; }
  details summary { padding: .8rem 1.1rem; }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
