/* ============================================================
   PIE — Programa de Integración Escolar
   Estilos basados en el sistema de diseño ProfeAcademī (Claude Design handoff).
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100vh; font-family: 'Poppins', sans-serif; }

/* ── Theme variables ── */
body.theme-light { --bg: #fffee0; --bg2: #B7E8EB; }
body.theme-dark  { --bg: #1a1a2e; --bg2: #0f0f23; }
body.theme-rosa  { --bg: #fff0f5; --bg2: #F8BBD9; }
body.theme-neon  { --bg: #191d1e; --bg2: #283139; }

/* PIE accent — teal/azul calmo para el programa de integración */
:root {
  --pie: #2f9e9e;
  --pie-deep: #1f7a8c;
  --pie-soft: rgba(47,158,158,0.12);
  --primary: #7c3aed;
  --primary-deep: #6d28d9;
}

/* ── Fondo de olas animado ── */
.pa-bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.pa-ocean { height: 5%; width: 100%; position: absolute; bottom: 0; left: 0; }
.pa-wave {
  background: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/85486/wave.svg') repeat-x;
  position: absolute; top: -198px; width: 6400px; height: 198px;
  animation: paWave 7s cubic-bezier(0.36,0.45,0.63,0.53) infinite;
  transform: translate3d(0,0,0);
}
.pa-wave:nth-child(2) {
  top: -175px;
  animation: paWave 7s cubic-bezier(0.36,0.45,0.63,0.53) -.125s infinite,
             paSwell 7s ease -1.25s infinite;
}
@keyframes paWave  { 0% { margin-left: 0; } 100% { margin-left: -1600px; } }
@keyframes paSwell { 0%,100% { transform: translate3d(0,-25px,0); } 50% { transform: translate3d(0,5px,0); } }

body.theme-light .pa-bg  { background: radial-gradient(ellipse at center,#fffee0,#fffee0,#B7E8EB); }
body.theme-light .pa-ocean { background: #015871; }
body.theme-dark  .pa-bg  { background: radial-gradient(ellipse at center,#1a1a2e,#16213e,#0f0f23); }
body.theme-dark  .pa-ocean { background: #1a1a2e; }
body.theme-dark  .pa-wave  { filter: brightness(0) saturate(100%) invert(8%) sepia(15%) saturate(2796%) hue-rotate(209deg) brightness(95%) contrast(103%); }
body.theme-rosa  .pa-bg  { background: radial-gradient(ellipse at center,#fff0f5,#ffe8f0,#F8BBD9); }
body.theme-rosa  .pa-ocean { background: #C2185B; }
body.theme-rosa  .pa-wave  { filter: brightness(0) saturate(100%) invert(27%) sepia(51%) saturate(2878%) hue-rotate(346deg) brightness(104%) contrast(97%); }
body.theme-neon  .pa-bg  { background: linear-gradient(0deg,#191d1e 50%,#283139 100%); }
body.theme-neon  .pa-ocean { background: #0a0d0e; }
body.theme-neon  .pa-wave  { filter: brightness(0) saturate(100%) invert(70%) sepia(100%) saturate(3000%) hue-rotate(160deg) brightness(110%) contrast(105%); opacity: .8; }
body.theme-neon  .pa-wave:nth-child(2) { filter: brightness(0) saturate(100%) invert(50%) sepia(100%) saturate(5000%) hue-rotate(280deg) brightness(120%) contrast(115%); opacity: .7; }

/* ── Header superior fijo (marca + usuario) ── */
.pa-top-header {
  position: fixed; top: 10px; left: 12px; right: 12px; z-index: 1000; height: 64px;
  background: rgba(255,255,255,0.80);
  backdrop-filter: blur(22px) saturate(160%); -webkit-backdrop-filter: blur(22px) saturate(160%);
  border-radius: 18px; border: 1px solid rgba(255,255,255,0.55);
  box-shadow: 0 4px 24px rgba(0,0,0,0.08), inset 0 1px 0 rgba(255,255,255,0.65);
  padding: 0 1.25rem; transition: background 0.3s ease, box-shadow 0.3s ease;
}
body.theme-dark .pa-top-header { background: rgba(10,6,24,0.72); border-color: rgba(255,255,255,0.1); box-shadow: 0 4px 24px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.07); }
body.theme-neon .pa-top-header { background: rgba(4,4,20,0.75); border-color: rgba(0,255,255,0.12); box-shadow: 0 4px 24px rgba(0,255,255,0.08), inset 0 1px 0 rgba(0,255,255,0.07); }
body.theme-rosa .pa-top-header { background: rgba(255,240,250,0.80); border-color: rgba(255,255,255,0.55); }
.pa-top-header-inner { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }

.pa-header-brand { display: flex; align-items: center; gap: 0.55rem; text-decoration: none; cursor: pointer; background: none; border: none; }
.pa-header-logo { height: 2rem; width: auto; object-fit: contain; }
.pa-header-wordmark { font-size: 1.3rem; line-height: 1; display: flex; align-items: baseline; }
.pa-header-wordmark .title-profe { font-family: 'Abril Fatface', cursive; font-weight: 400; color: #1a1a1a; transition: color 0.3s; }
body.theme-dark .pa-header-wordmark .title-profe, body.theme-neon .pa-header-wordmark .title-profe { color: #f1f5f9; }
.pa-header-wordmark .title-academi { font-family: 'Pacifico', cursive; font-weight: 400; color: #ff9500; }

.pa-header-right { display: flex; align-items: center; gap: 0.5rem; }

/* User chip */
.pa-user-wrap { position: relative; }
.pa-user-chip {
  display: flex; align-items: center; gap: 7px;
  background: rgba(255,149,0,0.09); border: 1px solid rgba(255,149,0,0.28);
  border-radius: 50px; cursor: pointer; padding: 4px 10px 4px 4px;
  font-family: 'Poppins', sans-serif;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}
.pa-user-chip:hover { background: rgba(255,149,0,0.15); border-color: rgba(255,149,0,0.48); box-shadow: 0 2px 10px rgba(255,149,0,0.18); }
.pa-user-chip:active { transform: scale(0.97); }
body.theme-dark .pa-user-chip { background: rgba(255,149,0,0.1); border-color: rgba(255,149,0,0.28); }
body.theme-neon .pa-user-chip { background: rgba(0,255,255,0.06); border-color: rgba(0,255,255,0.2); }
body.theme-rosa .pa-user-chip { background: rgba(236,72,153,0.07); border-color: rgba(236,72,153,0.2); }
.pa-avatar {
  width: 2rem; height: 2rem; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 800; flex-shrink: 0; color: #fff;
  text-transform: uppercase; font-family: 'Poppins', sans-serif;
}
.pa-chip-name { font-size: 13px; font-weight: 500; color: #1f2937; white-space: nowrap; }
body.theme-dark .pa-chip-name, body.theme-neon .pa-chip-name { color: #e2e8f0; }
body.theme-rosa .pa-chip-name { color: #880e4f; }
.pa-rol-badge {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 3px 10px; border-radius: 7px; border: 0;
  letter-spacing: 1px; font-size: 0.57rem; font-weight: 800;
  text-transform: uppercase; color: #fff; cursor: default;
  font-family: 'Poppins', sans-serif; transition: box-shadow 0.15s, transform 0.15s;
}
.rol-admin    { background: #ef4444; box-shadow: rgb(185,28,28) 0px 3px 0px 0px; }
.rol-profesor { background: #3b82f6; box-shadow: rgb(30,100,200) 0px 3px 0px 0px; }
.pa-chevron { color: #9ca3af; transition: transform 0.2s; margin-left: 1px; }
.pa-user-chip.open .pa-chevron { transform: rotate(180deg); }

/* Dropdown (theme switcher) */
.pa-dropdown {
  display: none; position: absolute; top: calc(100% + 8px); right: 0;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(16px) saturate(150%); -webkit-backdrop-filter: blur(16px) saturate(150%);
  border-radius: 14px; border: 1px solid rgba(255,255,255,0.6);
  box-shadow: 0 8px 28px rgba(0,0,0,0.12), inset 0 1px 0 rgba(255,255,255,0.7);
  min-width: 220px; z-index: 2000; overflow: hidden; animation: dropIn 0.16s ease;
}
.pa-dropdown.open { display: block; }
@keyframes dropIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
body.theme-dark .pa-dropdown { background: rgba(17,12,36,0.96); border-color: rgba(255,255,255,0.1); box-shadow: 0 8px 28px rgba(0,0,0,0.45); }
body.theme-neon .pa-dropdown { background: rgba(4,4,20,0.96); border-color: rgba(0,255,255,0.15); }
.drop-section { padding: 10px 14px 4px; }
.drop-label { font-size: 9px; font-weight: 700; color: #9ca3af; letter-spacing: 0.08em; text-transform: uppercase; }
.drop-themes { display: flex; gap: 5px; padding: 6px 12px 10px; }
.drop-theme-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: 1px solid rgba(0,0,0,0.08); border-radius: 9px;
  padding: 5px 6px; cursor: pointer; flex: 1; font-family: 'Poppins', sans-serif;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.drop-theme-btn:hover { background: rgba(0,0,0,0.04); transform: scale(1.07); border-color: rgba(0,0,0,0.15); }
.drop-theme-btn.active { background: rgba(255,149,0,0.1); border-color: rgba(255,149,0,0.45); box-shadow: 0 2px 0 rgba(255,149,0,0.3); }
.drop-theme-btn span:first-child { font-size: 1rem; }
.drop-theme-btn span:last-child  { font-size: 8px; font-weight: 600; color: #6b7280; }
body.theme-dark .drop-theme-btn { border-color: rgba(255,255,255,0.1); }
body.theme-dark .drop-theme-btn:hover { background: rgba(255,255,255,0.06); }
body.theme-dark .drop-theme-btn span:last-child, body.theme-neon .drop-theme-btn span:last-child { color: #9ca3af; }
.drop-divider { height: 1px; background: rgba(0,0,0,0.07); margin: 3px 0; }
body.theme-dark .drop-divider, body.theme-neon .drop-divider { background: rgba(255,255,255,0.08); }
.drop-item {
  display: flex; align-items: center; gap: 8px; padding: 9px 14px; cursor: pointer;
  font-size: 13px; font-weight: 500; color: #374151; font-family: 'Poppins', sans-serif;
  transition: background 0.12s; border: none; background: none; width: 100%; text-align: left;
}
.drop-item:hover { background: rgba(255,149,0,0.07); }
.drop-item svg { width: 15px; height: 15px; flex-shrink: 0; }
body.theme-dark .drop-item, body.theme-neon .drop-item { color: #e2e8f0; }
body.theme-dark .drop-item:hover, body.theme-neon .drop-item:hover { background: rgba(255,149,0,0.08); }

/* ── Sub-header de pantalla (volver + título) ── */
.pie-subhead { position: sticky; top: 84px; z-index: 900; margin: 0 0 1.4rem; }
.pie-subhead-inner {
  display: flex; align-items: center; gap: 14px;
  background: rgba(255,255,255,0.72);
  backdrop-filter: blur(20px) saturate(150%); -webkit-backdrop-filter: blur(20px) saturate(150%);
  border: 1px solid rgba(255,255,255,0.5); border-radius: 18px;
  box-shadow: 0 6px 26px rgba(31,122,140,0.10), inset 0 1px 0 rgba(255,255,255,0.6);
  padding: 0.9rem 1.1rem;
}
body.theme-dark .pie-subhead-inner, body.theme-neon .pie-subhead-inner { background: rgba(12,14,30,0.72); border-color: rgba(255,255,255,0.08); }
body.theme-rosa .pie-subhead-inner { background: rgba(255,240,250,0.78); }
.pie-back {
  width: 46px; height: 46px; border-radius: 50%; border: none; cursor: pointer; flex-shrink: 0;
  background: linear-gradient(135deg, var(--pie), var(--pie-deep)); color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(31,122,140,0.35), inset 0 1px 0 rgba(255,255,255,0.25);
  transition: all 0.3s ease; text-decoration: none;
}
.pie-back:hover { transform: scale(1.08) translateX(-1px); box-shadow: 0 6px 20px rgba(31,122,140,0.5); }
.pie-mark {
  width: 46px; height: 46px; border-radius: 14px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--pie), var(--pie-deep));
  display: flex; align-items: center; justify-content: center; color: #fff;
  box-shadow: 0 4px 14px rgba(31,122,140,0.32), inset 0 1px 0 rgba(255,255,255,0.25);
}
.pie-head-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pie-head-title { font-size: 1.15rem; font-weight: 700; color: #14323a; line-height: 1.25; }
.pie-head-title b { color: var(--pie-deep); font-weight: 800; }
.pie-head-sub { font-size: 0.78rem; color: #5b7a80; font-weight: 500; }
body.theme-dark .pie-head-title, body.theme-neon .pie-head-title { color: #eafcff; }
body.theme-dark .pie-head-sub, body.theme-neon .pie-head-sub { color: #8fb6bd; }
body.theme-rosa .pie-head-title { color: #5b1437; }
.pie-mode-tag {
  margin-left: auto; flex-shrink: 0; align-self: center;
  padding: 6px 13px; border-radius: 50px; font-size: 0.62rem; font-weight: 800;
  letter-spacing: 0.08em; text-transform: uppercase; white-space: nowrap;
}
.pie-mode-admin { background: rgba(239,68,68,0.12); color: #dc2626; border: 1px solid rgba(239,68,68,0.3); }
.pie-mode-read  { background: rgba(59,130,246,0.12); color: #2563eb; border: 1px solid rgba(59,130,246,0.3); }
body.theme-dark .pie-mode-read, body.theme-neon .pie-mode-read { color: #93c5fd; }

/* ── Shell de layout ── */
.pie-main { position: relative; z-index: 10; min-height: 100vh; padding-top: 84px; }
.pie-wrap { max-width: 940px; margin: 0 auto; padding: 0 16px 64px; }

/* ── Glass panel ── */
.pie-panel {
  background: rgba(255,255,255,0.72);
  backdrop-filter: blur(18px) saturate(150%); -webkit-backdrop-filter: blur(18px) saturate(150%);
  border: 1px solid rgba(255,255,255,0.55); border-radius: 22px;
  box-shadow: 0 8px 34px rgba(31,122,140,0.10), inset 0 1px 0 rgba(255,255,255,0.6);
  padding: 1.6rem 1.7rem; margin-bottom: 1.4rem;
}
body.theme-dark .pie-panel, body.theme-neon .pie-panel { background: rgba(14,16,34,0.7); border-color: rgba(255,255,255,0.08); box-shadow: 0 8px 34px rgba(0,0,0,0.4); }
body.theme-rosa .pie-panel { background: rgba(255,242,250,0.76); }

.pie-panel-title {
  display: flex; align-items: center; gap: 10px;
  font-size: 1.02rem; font-weight: 700; color: #14323a; margin-bottom: 0.35rem;
}
.pie-panel-title svg { color: var(--pie-deep); }
body.theme-dark .pie-panel-title, body.theme-neon .pie-panel-title { color: #eafcff; }
body.theme-rosa .pie-panel-title { color: #5b1437; }
.pie-panel-desc { font-size: 0.82rem; color: #5b7a80; font-weight: 400; margin-bottom: 1.3rem; line-height: 1.5; }
body.theme-dark .pie-panel-desc, body.theme-neon .pie-panel-desc { color: #8fb6bd; }

/* ── Form ── */
.pie-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem 1.3rem; }
.pie-field { display: flex; flex-direction: column; gap: 7px; }
.pie-field.full { grid-column: 1 / -1; }
.pie-label {
  font-size: 0.72rem; font-weight: 700; color: #46666c;
  letter-spacing: 0.04em; text-transform: uppercase; display: flex; align-items: center; gap: 6px;
}
.pie-label .opt { font-weight: 500; text-transform: none; letter-spacing: 0; color: #9bb3b8; font-size: 0.7rem; }
body.theme-dark .pie-label, body.theme-neon .pie-label { color: #a9cdd3; }

.pie-input, .pie-select, .pie-textarea {
  width: 100%; font-family: 'Poppins', sans-serif; font-size: 0.9rem; color: #15323a;
  background: rgba(255,255,255,0.85); border: 1.5px solid rgba(31,122,140,0.18);
  border-radius: 12px; padding: 0.7rem 0.9rem; outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.pie-select { appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%231f7a8c' stroke-width='2.4' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.85rem center; padding-right: 2.4rem;
}
.pie-textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
.pie-input:focus, .pie-select:focus, .pie-textarea:focus {
  border-color: var(--pie); box-shadow: 0 0 0 4px var(--pie-soft); background: #fff;
}
.pie-input:disabled, .pie-select:disabled { opacity: 0.55; cursor: not-allowed; }
.pie-select option { color: #15323a; }
body.theme-dark .pie-input, body.theme-dark .pie-select, body.theme-dark .pie-textarea,
body.theme-neon .pie-input, body.theme-neon .pie-select, body.theme-neon .pie-textarea {
  background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.14); color: #eafcff;
}
body.theme-dark .pie-select option, body.theme-neon .pie-select option { color: #15323a; }

/* ── Chip-picker de especialistas ── */
.pie-picker {
  border: 1.5px solid rgba(31,122,140,0.18); border-radius: 14px;
  background: rgba(255,255,255,0.5); padding: 0.75rem; transition: border-color 0.2s, box-shadow 0.2s;
}
.pie-picker.focus-within { border-color: var(--pie); box-shadow: 0 0 0 4px var(--pie-soft); }
body.theme-dark .pie-picker, body.theme-neon .pie-picker { background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.14); }
.pie-picker-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.pie-pchip {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,0.8); border: 1.5px solid rgba(31,122,140,0.2);
  border-radius: 50px; padding: 5px 6px 5px 5px; cursor: pointer;
  font-size: 0.78rem; font-weight: 500; color: #2c4a50;
  transition: all 0.18s ease; user-select: none;
}
.pie-pchip:hover { border-color: var(--pie); transform: translateY(-1px); box-shadow: 0 3px 10px rgba(31,122,140,0.15); }
.pie-pchip.on { background: linear-gradient(135deg, var(--pie), var(--pie-deep)); border-color: transparent; color: #fff; box-shadow: 0 4px 12px rgba(31,122,140,0.32); }
.pie-pchip .pa-avatar { width: 1.55rem; height: 1.55rem; font-size: 0.6rem; }
.pie-pchip .pchip-role { font-size: 0.64rem; opacity: 0.7; font-weight: 500; }
.pie-pchip.on .pchip-role { opacity: 0.85; }
.pie-pchip .pchip-tick { width: 16px; height: 16px; opacity: 0; margin-right: 2px; transition: opacity 0.15s; }
.pie-pchip.on .pchip-tick { opacity: 1; }
body.theme-dark .pie-pchip, body.theme-neon .pie-pchip { background: rgba(255,255,255,0.06); color: #cfe9ed; border-color: rgba(255,255,255,0.12); }
.pie-picker-hint { font-size: 0.7rem; color: #9bb3b8; margin-top: 0.6rem; display: flex; align-items: center; gap: 5px; }

/* ── Buttons ── */
.pie-actions { display: flex; align-items: center; gap: 14px; margin-top: 1.5rem; flex-wrap: wrap; }
.pie-btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: 'Poppins', sans-serif; font-size: 0.86rem; font-weight: 600;
  border: none; border-radius: 0.9em; padding: 0.7em 1.5em; cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25,1,0.5,1);
}
.pie-btn-primary { background: linear-gradient(135deg, var(--pie), var(--pie-deep)); color: #fff; box-shadow: 0 5px 16px rgba(31,122,140,0.4); }
.pie-btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(31,122,140,0.55); }
.pie-btn-primary:active { transform: translateY(1px) scale(0.99); }
.pie-btn-primary:disabled { opacity: 0.55; cursor: not-allowed; transform: none; box-shadow: none; }
.pie-btn-ghost { background: rgba(31,122,140,0.08); color: var(--pie-deep); }
.pie-btn-ghost:hover { background: rgba(31,122,140,0.16); }
body.theme-dark .pie-btn-ghost, body.theme-neon .pie-btn-ghost { color: #7fd6d6; background: rgba(47,158,158,0.16); }

/* ── Status message ── */
.pie-status { font-size: 0.82rem; font-weight: 600; display: none; align-items: center; gap: 7px; }
.pie-status.show { display: inline-flex; animation: statusIn 0.3s ease; }
@keyframes statusIn { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: translateX(0); } }
.pie-status.ok   { color: #0f9d6c; }
.pie-status.err  { color: #dc2626; }

/* ── List section ── */
.pie-list-head { display: flex; align-items: center; gap: 12px; margin-bottom: 1.1rem; flex-wrap: wrap; }
.pie-list-title { font-size: 1.05rem; font-weight: 700; color: #14323a; display: flex; align-items: center; gap: 10px; }
body.theme-dark .pie-list-title, body.theme-neon .pie-list-title { color: #eafcff; }
body.theme-rosa .pie-list-title { color: #5b1437; }
.pie-count {
  background: var(--pie-soft); color: var(--pie-deep); font-size: 0.74rem; font-weight: 700;
  padding: 3px 11px; border-radius: 50px; border: 1px solid rgba(31,122,140,0.2);
}
body.theme-dark .pie-count, body.theme-neon .pie-count { color: #7fd6d6; }

/* Segmented layout control */
.pie-seg {
  margin-left: auto; display: inline-flex; gap: 2px; padding: 3px;
  background: rgba(31,122,140,0.08); border-radius: 50px; border: 1px solid rgba(31,122,140,0.14);
}
.pie-seg button {
  display: inline-flex; align-items: center; gap: 5px;
  background: none; border: none; cursor: pointer; padding: 6px 13px; border-radius: 50px;
  font-family: 'Poppins', sans-serif; font-size: 0.72rem; font-weight: 600; color: #5b7a80;
  transition: all 0.2s ease;
}
.pie-seg button svg { width: 14px; height: 14px; }
.pie-seg button.on { background: #fff; color: var(--pie-deep); box-shadow: 0 2px 8px rgba(31,122,140,0.18); }
body.theme-dark .pie-seg, body.theme-neon .pie-seg { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.1); }
body.theme-dark .pie-seg button.on, body.theme-neon .pie-seg button.on { background: rgba(47,158,158,0.3); color: #cffafe; box-shadow: none; }

/* ── Student cards grid ── */
.pie-grid { display: grid; gap: 1.1rem; }
.pie-grid.cols { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.pie-grid.rows { grid-template-columns: 1fr; }

.pie-card {
  position: relative; background: rgba(255,255,255,0.78);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255,255,255,0.6); border-radius: 18px;
  box-shadow: 0 6px 24px rgba(31,122,140,0.10), inset 0 1px 0 rgba(255,255,255,0.6);
  padding: 1.2rem 1.25rem; overflow: hidden;
  opacity: 1;
  animation: paFadeUp 0.45s cubic-bezier(0.34,1.3,0.64,1) both;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.pie-card:hover { transform: translateY(-4px); box-shadow: 0 14px 38px rgba(31,122,140,0.18); }
.pie-card::after {
  content: ''; position: absolute; top: 0; left: 0; width: 4px; height: 100%;
  background: linear-gradient(180deg, var(--pie), var(--pie-deep));
}
/* entrada solo-transform — las tarjetas quedan a opacity:1 aunque la animación
   se congele en una pestaña en segundo plano (el contenido nunca se oculta) */
@keyframes paFadeUp { from { transform: translateY(16px); } to { transform: translateY(0); } }
body.theme-dark .pie-card, body.theme-neon .pie-card { background: rgba(16,18,38,0.78); border-color: rgba(255,255,255,0.08); }
body.theme-rosa .pie-card { background: rgba(255,244,250,0.82); }

.pie-card-top { display: flex; align-items: flex-start; gap: 12px; }
.pie-card-avatar {
  width: 44px; height: 44px; border-radius: 13px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 0.92rem; text-transform: uppercase;
  box-shadow: 0 4px 12px rgba(0,0,0,0.14);
}
.pie-card-id { min-width: 0; flex: 1; }
.pie-card-name { font-size: 1rem; font-weight: 700; color: #15323a; line-height: 1.25; }
body.theme-dark .pie-card-name, body.theme-neon .pie-card-name { color: #eafcff; }
body.theme-rosa .pie-card-name { color: #5b1437; }
.pie-curso-badge {
  display: inline-flex; align-items: center; gap: 4px; margin-top: 4px;
  background: rgba(124,58,237,0.1); color: var(--primary); border: 1px solid rgba(124,58,237,0.22);
  font-size: 0.68rem; font-weight: 700; padding: 2px 9px; border-radius: 50px;
}
body.theme-dark .pie-curso-badge, body.theme-neon .pie-curso-badge { color: #c4b5fd; }

.pie-card-diag {
  margin-top: 0.85rem; font-size: 0.8rem; line-height: 1.5; color: #41616a;
  background: rgba(31,122,140,0.06); border-radius: 11px; padding: 0.6rem 0.75rem;
  border-left: 2px solid rgba(31,122,140,0.35);
}
.pie-card-diag .diag-label { display: block; font-size: 0.62rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--pie-deep); margin-bottom: 2px; }
body.theme-dark .pie-card-diag, body.theme-neon .pie-card-diag { color: #b6d4d9; background: rgba(47,158,158,0.1); }
.pie-card-diag.empty { color: #9bb3b8; font-style: italic; border-left-color: rgba(155,179,184,0.4); }

.pie-card-section-label { font-size: 0.62rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: #7a979c; margin: 0.95rem 0 0.5rem; }
.pie-spec-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pie-spec-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.7); border: 1px solid rgba(31,122,140,0.2);
  border-radius: 50px; padding: 3px 11px 3px 4px; font-size: 0.72rem; font-weight: 500; color: #2c4a50;
}
.pie-spec-chip .dot { width: 18px; height: 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.52rem; font-weight: 800; color: #fff; }
body.theme-dark .pie-spec-chip, body.theme-neon .pie-spec-chip { background: rgba(255,255,255,0.06); color: #cfe9ed; border-color: rgba(255,255,255,0.1); }
.pie-spec-none { font-size: 0.74rem; color: #9bb3b8; font-style: italic; }

.pie-card-actions { display: flex; gap: 8px; margin-top: 1.1rem; }
.pie-icon-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: 'Poppins', sans-serif; font-size: 0.74rem; font-weight: 600;
  border: 1px solid transparent; border-radius: 10px; padding: 0.45em 0.85em; cursor: pointer;
  transition: all 0.2s ease; background: none;
}
.pie-icon-btn svg { width: 14px; height: 14px; }
.pie-edit { color: var(--pie-deep); border-color: rgba(31,122,140,0.25); background: rgba(31,122,140,0.06); }
.pie-edit:hover { background: rgba(31,122,140,0.14); }
.pie-del { color: #dc2626; border-color: rgba(239,68,68,0.25); background: rgba(239,68,68,0.05); }
.pie-del:hover { background: rgba(239,68,68,0.13); }
body.theme-dark .pie-edit, body.theme-neon .pie-edit { color: #7fd6d6; }

/* ── Avatars variant ── */
.pie-card.v-avatars .pie-spec-chips { gap: 0; }
.pie-card.v-avatars .pie-spec-chip { background: none; border: none; padding: 0; margin-left: -8px; }
.pie-card.v-avatars .pie-spec-chip:first-child { margin-left: 0; }
.pie-card.v-avatars .pie-spec-chip .spec-name { display: none; }
.pie-card.v-avatars .pie-spec-chip .dot {
  width: 30px; height: 30px; font-size: 0.62rem; border: 2px solid rgba(255,255,255,0.9);
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
body.theme-dark .pie-card.v-avatars .pie-spec-chip .dot, body.theme-neon .pie-card.v-avatars .pie-spec-chip .dot { border-color: rgba(20,22,42,0.9); }
.pie-card.v-avatars .pie-avatar-stack { display: flex; align-items: center; }
.pie-card.v-avatars .spec-extra { font-size: 0.74rem; color: #5b7a80; font-weight: 600; margin-left: 10px; align-self: center; }

/* ── List (rows) variant ── */
.pie-card.v-list { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 1.2rem; padding: 1rem 1.3rem; }
.pie-card.v-list .pie-card-top { display: contents; }
.pie-card.v-list .pie-card-diag { margin-top: 0; grid-column: 2; max-width: 380px; }
.pie-card.v-list .pie-list-mid { display: flex; flex-direction: column; gap: 0.5rem; min-width: 0; }
.pie-card.v-list .pie-card-section-label { margin: 0; }
.pie-card.v-list .pie-card-actions { margin-top: 0; }
@media (max-width: 680px) {
  .pie-card.v-list { grid-template-columns: 1fr; }
}

/* ── Empty state ── */
.pie-empty {
  text-align: center; padding: 3rem 1.5rem; color: #6b8a90;
  border: 2px dashed rgba(31,122,140,0.2); border-radius: 20px; background: rgba(255,255,255,0.4);
}
.pie-empty svg { color: rgba(31,122,140,0.4); margin-bottom: 0.8rem; }
.pie-empty h3 { font-size: 1rem; font-weight: 700; color: #2c4a50; margin-bottom: 0.3rem; }
.pie-empty p { font-size: 0.84rem; }
body.theme-dark .pie-empty, body.theme-neon .pie-empty { background: rgba(255,255,255,0.03); color: #8fb6bd; }
body.theme-dark .pie-empty h3, body.theme-neon .pie-empty h3 { color: #cfe9ed; }

/* ── Form-card editing highlight ── */
.pie-panel.editing { box-shadow: 0 0 0 2px var(--pie), 0 8px 34px rgba(31,122,140,0.2); }
.pie-editing-tag {
  display: none; align-items: center; gap: 6px; margin-left: 10px;
  background: rgba(245,158,11,0.14); color: #b45309; border: 1px solid rgba(245,158,11,0.3);
  font-size: 0.64rem; font-weight: 700; padding: 3px 10px; border-radius: 50px; text-transform: uppercase; letter-spacing: 0.04em;
}
.pie-panel.editing .pie-editing-tag { display: inline-flex; }

/* Loading state */
.pie-loading { text-align: center; padding: 3rem 1.5rem; color: #6b8a90; font-size: 0.9rem; }

/* Responsive */

/* Tablet y móvil: el sub-header deja de ser persistente (sticky).
   En escritorio se mantiene como está. */
@media (max-width: 1024px) {
  .pie-subhead { position: static; top: auto; }
}

@media (max-width: 640px) {
  .pie-form-grid { grid-template-columns: 1fr; }
  .pa-header-wordmark { display: none; }
}

/* Pantallas angostas (p. ej. dentro del iframe del launcher) */
@media (max-width: 560px) {
  .pie-wrap { padding: 0 12px 48px; }

  /* Sub-header: que el título mande y la etiqueta de modo baje de línea */
  .pie-subhead-inner { flex-wrap: wrap; gap: 10px 12px; padding: 0.85rem 0.95rem; }
  .pie-back, .pie-mark { width: 40px; height: 40px; }
  .pie-head-text { flex: 1 1 140px; min-width: 0; }
  .pie-head-title { font-size: 1rem; }
  .pie-head-sub { font-size: 0.74rem; }
  /* El badge baja solo a su propia línea (no cabe junto al texto que crece);
     ancho según contenido e indentado bajo el texto — nunca desborda. */
  .pie-mode-tag { margin: 0 0 0 52px; width: fit-content; max-width: 100%; }

  /* Paneles y form más compactos */
  .pie-panel { padding: 1.25rem 1.15rem; border-radius: 18px; }
  .pie-form-grid { grid-template-columns: 1fr; gap: 0.95rem; }

  /* Tarjetas siempre a una columna para no comprimir el contenido */
  .pie-grid.cols { grid-template-columns: 1fr; }
  .pie-list-head { gap: 8px; }
  .pie-seg { margin-left: 0; }
}
