:root{
  --bg:#f7f3ef;
  --paper:#fffdfb;
  --paper-soft:#fbf7fb;

  --ink:#211829;
  --text:#493b50;
  --muted:#817585;

  --purple:#642176;
  --purple-2:#89509a;
  --purple-soft:#eee3f1;

  --gold:#b88b48;
  --gold-soft:#e6d3ae;

  --green:#25a66d;
  --red:#c94b5d;

  --border:#e7dfe5;

  --sidebar:250px;
  --topbar:76px;

  --radius:20px;

  --shadow:
    0 18px 55px
    rgba(62,37,67,.07);

  --shadow-soft:
    0 8px 28px
    rgba(62,37,67,.045);
}

*{
  box-sizing:border-box;
}

html,
body{
  margin:0;
  min-height:100%;
}

body{
  color:var(--ink);

  background:
    radial-gradient(
      900px 600px
      at 100% 0%,
      rgba(189,151,203,.18),
      transparent 60%
    ),
    var(--bg);

  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

button,
input{
  font:inherit;
}

button{
  cursor:pointer;
}

.hidden{
  display:none !important;
}

/* SIDEBAR */

.sidebar{
  position:fixed;
  inset:0 auto 0 0;

  width:var(--sidebar);

  padding:
    30px
    22px
    24px;

  display:flex;
  flex-direction:column;

  background:
    linear-gradient(
      180deg,
      #fffdfb,
      #faf6fb
    );

  border-right:
    1px solid
    var(--border);

  z-index:30;
}

.brand{
  display:flex;
  align-items:center;
  gap:12px;

  min-height:54px;

  margin-bottom:34px;
}

.brand-mark{
  font-family:
    Georgia,
    "Times New Roman",
    serif;

  font-size:29px;
  font-weight:700;

  letter-spacing:-1.5px;

  background:
    linear-gradient(
      90deg,
      #642176,
      #a45cb2 55%,
      #b88b48
    );

  color:transparent;
  background-clip:text;
  -webkit-background-clip:text;
}

.brand-copy{
  display:flex;
  flex-direction:column;
  gap:2px;
}

.brand-copy strong{
  font-size:13px;
}

.brand-copy span{
  color:var(--muted);

  font-size:8px;
  text-transform:uppercase;
  letter-spacing:.12em;
}

.back-master{
  width:100%;

  margin:
    -15px 0
    18px;

  padding:
    10px 12px;

  border:
    1px solid
    var(--border);

  border-radius:12px;

  background:var(--paper);

  color:var(--purple);

  text-align:left;
}

.nav{
  display:flex;
  flex-direction:column;
  gap:5px;
}

.nav-button{
  min-height:48px;

  display:flex;
  align-items:center;
  gap:12px;

  padding:
    0 14px;

  border:0;
  border-radius:13px;

  background:transparent;

  color:var(--text);

  font-weight:650;

  text-align:left;
}

.nav-button:hover{
  background:#f4edf5;
}

.nav-button.active{
  background:
    linear-gradient(
      90deg,
      #eee1f0,
      #f7eff8
    );

  color:var(--purple);
}

.nav-icon{
  width:28px;
  height:28px;

  display:grid;
  place-items:center;

  border-radius:9px;

  background:#f1e7f3;

  color:var(--purple);
}

.nav-button.active
.nav-icon{
  background:var(--purple);
  color:#fff;
}

.sidebar-note{
  margin-top:auto;

  padding:
    20px;

  display:flex;
  flex-direction:column;
  gap:10px;

  border:
    1px solid
    #eadbea;

  border-radius:17px;

  background:
    linear-gradient(
      145deg,
      #f6edf7,
      #fffaf1
    );
}

.sidebar-note strong{
  font-family:
    Georgia,
    "Times New Roman",
    serif;

  font-size:20px;
  line-height:1.08;

  color:var(--purple);
}

.sidebar-note span{
  color:var(--muted);
  font-size:11px;
  line-height:1.5;
}

/* TOPBAR */

.topbar{
  position:fixed;
  top:0;
  left:var(--sidebar);
  right:0;

  height:var(--topbar);

  padding:
    0 30px;

  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:14px;

  border-bottom:
    1px solid
    var(--border);

  background:
    rgba(255,253,251,.92);

  backdrop-filter:
    blur(18px);

  z-index:25;
}

.mobile-menu{
  display:none;
}

.search{
  margin-right:auto;

  width:
    min(
      520px,
      47vw
    );

  height:43px;

  display:flex;
  align-items:center;
  gap:10px;

  padding:
    0 14px;

  border:
    1px solid
    var(--border);

  border-radius:13px;

  background:#fff;
}

.search span{
  color:var(--purple);
}

.search input{
  width:100%;
  border:0;
  outline:0;
  background:transparent;
  color:var(--ink);
}

.runtime{
  height:39px;

  display:flex;
  align-items:center;
  gap:8px;

  padding:
    0 14px;

  border:
    1px solid
    #d8eadf;

  border-radius:999px;

  background:#f3faf6;

  color:#25724e;

  font-size:11px;
  font-weight:700;
}

.runtime-dot{
  width:8px;
  height:8px;

  border-radius:50%;

  background:var(--green);
}

.runtime.offline{
  border-color:#f0d7db;
  background:#fff5f6;
  color:#a84454;
}

.runtime.offline
.runtime-dot{
  background:var(--red);
}

.context-chip{
  height:39px;

  display:flex;
  align-items:center;

  padding:
    0 14px;

  border-radius:999px;

  background:
    var(--purple-soft);

  color:var(--purple);

  font-size:11px;
  font-weight:750;
}

/* CONTENT */

.main{
  min-height:100vh;

  margin-left:
    var(--sidebar);

  padding:
    calc(
      var(--topbar) +
      32px
    )
    32px
    60px;
}

.hero{
  position:relative;

  min-height:255px;

  padding:
    42px
    48px;

  display:flex;
  align-items:center;

  overflow:hidden;

  border:
    1px solid
    rgba(184,139,72,.42);

  border-radius:
    26px;

  background:
    linear-gradient(
      120deg,
      #fffdfb 0%,
      #fcf7fb 62%,
      #fffaf0 100%
    );

  box-shadow:
    var(--shadow-soft);
}

.hero > div:first-child{
  position:relative;
  z-index:2;
  max-width:680px;
}

.eyebrow{
  margin-bottom:12px;

  color:var(--gold);

  font-size:10px;
  font-weight:800;

  letter-spacing:.18em;
}

.hero h1{
  margin:0;

  font-family:
    Georgia,
    "Times New Roman",
    serif;

  font-size:
    clamp(
      38px,
      4.6vw,
      64px
    );

  line-height:.98;

  letter-spacing:-.035em;
}

.hero p{
  max-width:610px;

  margin:
    18px 0 0;

  color:var(--muted);

  font-size:14px;
  line-height:1.65;
}

.hero-art{
  position:absolute;
  inset:0 0 0 45%;
  overflow:hidden;
}

.orb{
  position:absolute;
  border-radius:50%;
}

.orb-a{
  width:510px;
  height:510px;

  right:-170px;
  top:-210px;

  border:
    45px solid
    rgba(173,116,188,.13);
}

.orb-b{
  width:410px;
  height:410px;

  right:-50px;
  top:-100px;

  border:
    3px solid
    rgba(184,139,72,.32);

  transform:rotate(22deg);
}

.orb-c{
  width:360px;
  height:130px;

  right:70px;
  bottom:-50px;

  border:
    2px solid
    rgba(118,48,132,.24);

  transform:
    rotate(-12deg);
}

.section{
  margin-top:36px;
}

.section-head{
  margin-bottom:20px;

  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap:18px;
}

.section-kicker{
  color:var(--gold);

  font-size:9px;
  font-weight:800;

  letter-spacing:.16em;
}

.section h2{
  margin:
    5px 0 4px;

  font-family:
    Georgia,
    "Times New Roman",
    serif;

  font-size:34px;
}

.section-head p{
  margin:0;
  color:var(--muted);
  font-size:12px;
}

.content{
  display:grid;
  grid-template-columns:
    repeat(
      2,
      minmax(0,1fr)
    );

  gap:18px;
}

.loading-card,
.empty{
  grid-column:1/-1;

  padding:35px;

  border:
    1px dashed
    #d9cdd9;

  border-radius:
    var(--radius);

  background:
    rgba(255,255,255,.55);

  color:var(--muted);
}

/* CARDS */

.workspace-card{
  min-height:215px;

  padding:24px;

  display:flex;
  flex-direction:column;

  border:
    1px solid
    var(--border);

  border-radius:
    var(--radius);

  background:
    var(--paper);

  box-shadow:
    var(--shadow-soft);
}

.workspace-card:hover{
  transform:
    translateY(-2px);

  box-shadow:
    var(--shadow);

  transition:
    .18s ease;
}

.workspace-top{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
}

.workspace-icon{
  width:42px;
  height:42px;

  display:grid;
  place-items:center;

  border-radius:13px;

  background:
    linear-gradient(
      145deg,
      #eee0f1,
      #faf3fb
    );

  color:var(--purple);

  font-family:
    Georgia,
    serif;

  font-size:18px;
  font-weight:700;
}

.status{
  padding:
    6px 9px;

  border-radius:
    999px;

  background:#f0e6f2;

  color:var(--purple);

  font-size:9px;
  font-weight:800;
}

.workspace-card h3{
  margin:
    20px 0 5px;

  font-size:17px;
}

.workspace-card p{
  margin:0;

  color:var(--muted);

  font-size:11px;
  line-height:1.5;
}

.workspace-meta{
  margin-top:10px;

  color:#928695;

  font-size:9px;
}

.workspace-actions{
  margin-top:auto;

  padding-top:20px;

  display:flex;
  gap:8px;
}

.primary,
.secondary{
  min-height:39px;

  padding:
    0 15px;

  border-radius:11px;

  font-size:11px;
  font-weight:750;
}

.primary{
  border:
    1px solid
    var(--purple);

  background:
    var(--purple);

  color:white;
}

.secondary{
  border:
    1px solid
    var(--border);

  background:#fff;

  color:var(--purple);
}

.module-grid{
  grid-column:1/-1;

  display:grid;
  grid-template-columns:
    repeat(
      3,
      minmax(0,1fr)
    );

  gap:15px;
}

.module-card{
  min-height:150px;

  padding:20px;

  border:
    1px solid
    var(--border);

  border-radius:17px;

  background:var(--paper);

  text-align:left;
}

.module-card[disabled]{
  cursor:not-allowed;
  opacity:.55;
}

.module-card strong{
  display:block;
  margin-bottom:7px;
}

.module-card span{
  color:var(--muted);
  font-size:11px;
  line-height:1.4;
}

/* TOAST */

.toast{
  position:fixed;
  right:24px;
  bottom:24px;

  max-width:370px;

  padding:
    13px 16px;

  border-radius:13px;

  background:#291832;
  color:white;

  box-shadow:
    var(--shadow);

  opacity:0;
  transform:
    translateY(12px);

  pointer-events:none;

  transition:
    .18s ease;

  z-index:100;
}

.toast.show{
  opacity:1;
  transform:none;
}

/* RESPONSIVE */

@media(
  max-width:900px
){

  :root{
    --sidebar:0px;
  }

  .sidebar{
    width:260px;

    transform:
      translateX(-105%);

    transition:
      transform .2s ease;

    box-shadow:
      20px 0 50px
      rgba(40,20,45,.12);
  }

  body.nav-open
  .sidebar{
    transform:none;
  }

  .topbar{
    left:0;
    padding:
      0 15px;
  }

  .mobile-menu{
    display:grid;
    place-items:center;

    width:40px;
    height:40px;

    border:
      1px solid
      var(--border);

    border-radius:12px;

    background:white;

    color:var(--purple);
  }

  .search{
    width:auto;
    flex:1;
  }

  .context-chip{
    display:none;
  }

  .main{
    margin-left:0;

    padding-left:18px;
    padding-right:18px;
  }

  .content{
    grid-template-columns:1fr;
  }

  .module-grid{
    grid-template-columns:1fr;
  }

  .hero{
    min-height:280px;
    padding:35px 28px;
  }

  .hero-art{
    left:30%;
    opacity:.7;
  }

}

@media(
  max-width:580px
){

  .runtime span:last-child{
    display:none;
  }

  .runtime{
    width:39px;
    padding:0;
    justify-content:center;
  }

  .section-head{
    align-items:flex-start;
    flex-direction:column;
  }

}

/* ==========================================================
   MAG V4 · GLOBAL WIDE LAYOUT AUTHORITY
   ========================================================== */

.main{
  width:auto;
  max-width:none;
}

.section{
  width:100%;
}

.content{
  width:100%;

  align-items:start;

  grid-template-columns:
    repeat(
      2,
      minmax(0,1fr)
    );
}

/*
 * Las pantallas MASTER operativas sustituyen
 * hero + section-head por su propio encabezado.
 */
body.v4-master-runtime-active
.hero{
  display:none;
}

body.v4-master-runtime-active
.section{
  margin-top:0;
}

body.v4-master-runtime-active
.section > .section-head{
  display:none;
}

body.v4-master-runtime-active
.content{
  display:block;
}

/*
 * MASTER nunca puede quedar atrapado
 * en una sola columna del grid base.
 */
.content > .v4-master-view{
  grid-column:1 / -1;

  width:100%;
  max-width:none;
}

/*
 * Los módulos de workspace también deben
 * utilizar todo el lienzo disponible.
 */
.content > .module-shell{
  grid-column:1 / -1;

  width:100%;
  max-width:none;
}

/* Aprovechar pantallas grandes */
@media(min-width:1500px){

  .main{
    padding-left:38px;
    padding-right:38px;
  }

  .content{
    gap:20px;
  }

}

/* No sacrificar móvil */
@media(max-width:900px){

  body.v4-master-runtime-active
  .main{
    padding-top:
      calc(
        var(--topbar) +
        18px
      );
  }

}
